#!/usr/bin/perl -w # whois.pl # # Adds Internic WHOIS support to the normal /whois command. # Based on the arguments you pass to the /whois command, this script # will query either your system's whois command, or the IRC server. # This works for IRC nick, domain, and Internic !HANDLE queries. # # Author: James # # # v1.0 - First release # v1.1 - Fixed bug in parsing output of host handle queries # # # # Syntax: /whois # # can be either a nick, domain, or !handle IRC::register("whois.pl", "1.1", "", ""); IRC::add_command_handler("whois", "my_whois"); sub my_whois { my $arg = $_[0]; $arg =~ s/\s+/ /g; $arg = quotemeta($arg); if ($arg =~ /\./) { open(NSI,"whois $arg|") or IRC::print("WHOIS command failed: $!\n"),goto DOMEND; while() { if ($_ =~ /^No match for/) { IRC::print $_; goto DOMEND; } if ($_ !~ /^Registrant:/) { next } while() { IRC::print($_); } break; } DOMEND: close(NSI); return 1; } elsif ($arg =~ /\!/) { open(NSI, "whois $arg|") or IRC::print("WHOIS command failed: $!\n"),goto HANEND; while() { if ($_ =~ /^No match for handle/) { IRC::print $_; goto HANEND; } elsif ($_ =~ /^NO MATCH:/) { IRC::print $_; goto HANEND; } elsif ($_ !~ /(^.*\,.*\(.*\).*\@.*$)|(.*\(.*\)$)/) { next } IRC::print($_); while() { IRC::print($_); } break; } HANEND: close(NSI); return 1; } else { IRC::command("/quote WHOIS $arg"); } return 1; } 1;