[vhffs-dev] [1064] Implement whois function to modobot.pl.

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1064
Author:   misric
Date:     2007-11-06 22:13:06 +0000 (Tue, 06 Nov 2007)

Log Message:
-----------
Implement whois function to modobot.pl. Need Net::DNS.

Modified Paths:
--------------
    trunk/vhffs-irc/modobot.pl


Modified: trunk/vhffs-irc/modobot.pl
===================================================================
--- trunk/vhffs-irc/modobot.pl	2007-11-05 20:49:38 UTC (rev 1063)
+++ trunk/vhffs-irc/modobot.pl	2007-11-06 22:13:06 UTC (rev 1064)
@@ -21,6 +21,7 @@
 use Vhffs::ObjectFactory;
 
 use Net::IRC;
+use Net::DNS;
 use Text::Wrapper;
 
 binmode STDOUT, ':utf8';
@@ -312,6 +313,7 @@
         irc_msg("owner <group> - give owner information of <group>");
         irc_msg("lsgroup <group> - give the list of users of <group>");
         irc_msg("quotacheck <limit> - give the list of <limit> users where quota limit nearly reach "); 
+	irc_msg("whois <domain> - gige NS for <domain>");
 
    }
     elsif ($texte =~ m/^${mynick}: list$/)
@@ -352,7 +354,22 @@
         quotacheck($limit);
     }
 
+    elsif ($texte =~ m/^${mynick}: whois [a-z0-9\.\-]+$/)
+    {
+	my $whois = $texte;
+	$whois =~ s/^${mynick}: whois //;
+	my $resolv = Net::DNS::Resolver->new;
+	
+	if (my $query = $resolv->query($whois, "NS")) 
+	{
+	    irc_msg ("Domain $whois registered");
+	    foreach my $rr (grep { $_->type eq 'NS' } $query->answer) 
+		{ irc_msg("NS : ".$rr->nsdname); }
+ 	}
+  	else { irc_msg("query failed for $whois : ".$resolv->errorstring); }
+    }
 
+
 } # on_public
 
 sub on_kick {


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/