]> git.donarmstrong.com Git - infobot.git/commitdiff
nslookup -> dns as a forker
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 17 Feb 2005 03:58:03 +0000 (03:58 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 17 Feb 2005 03:58:03 +0000 (03:58 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1130 c11ca15a-4712-0410-83d8-924469b57eb5

files/blootbot.help
files/sample/blootbot.chan
files/sample/blootbot.config
src/CommandStubs.pl
src/DynaConfig.pl
src/Modules/dns.pl [new file with mode: 0644]
src/UserExtra.pl

index 790c813860374ed2a94c14fbaa623eea1f3f198b..2b843eaac2d535bf0b2107ad149e7a93daee768a 100644 (file)
@@ -165,6 +165,11 @@ dict: U: ## <query>
 dict: E: ## AI
 dict: E: ## 1 linux
 
+dns: D: Query DNS
+dns: U: ## <host|ip>
+dns: E: ## debian.org
+dns: E: ## 3.1.33.7
+
 do: D: operator command to do things in a channel
 do: U: ## <chan> <what>
 
@@ -307,11 +312,6 @@ nickometer: U: ## {nick,channel}
 nickometer: E: ## unknown_lamer
 nickometer: E: ## #botpark
 
-nslookup: D: Query DNS
-nslookup: U: ## <host|ip>
-nslookup: E: ## debian.org
-nslookup: E: ## 3.1.33.7
-
 ord: D: Convert ascii to decimal
 ord: U: ## <single character>
 ord: E: ## c
index e7c92337fa412a5ca50de99b94be6b84e178b855..e6220b78870c156f7dc13933cc347ac3498a5480 100644 (file)
@@ -1,4 +1,4 @@
-#v1: blootbot -- infobot -- written Thu Feb 17 03:17:32 2005
+#v1: blootbot -- infobot -- written Thu Feb 17 03:57:07 2005
 
 #botpark
     +RootWarn
@@ -39,7 +39,6 @@ _default
     +Weather
     +Zippy
     +allowConv
-    +allowDNS
     +allowTelling
     +babelfish
     +botmail
@@ -49,6 +48,7 @@ _default
     +cookie
     +countdown
     debianRefreshInterval 7
+    +dns
     +factoidArguments
     floodMessages 10:30
     floodRepeat 2:10
index f8b072f6f90abe0ac7d04119e99cc52677ed3b1a..2dde0259b57e50eedc9ab71efab03b92f5b80a79 100644 (file)
@@ -171,9 +171,6 @@ set Math            1
 # [0/1] ord/chr etc
 set allowConv          1
 
-# [0/1] do you want to allow DNS lookup
-set allowDNS           1
-
 # [0/1] Forking... disable for non-nix OS or to reduce mem usage.
 #      Disabling should make the bot work on Win32 and MacOS.
 set forking            1
index b007d36c6093c93b73e50d70dafdd5390f436cda..e153fce062226fbc308760ad2a1200b79f141bc8 100644 (file)
@@ -280,6 +280,9 @@ sub parseCmdHook {
 &addCmdHook("extra", '[ia]?spell', ('CODEREF' => 'spell::query',
        'Identifier' => 'spell', 'Cmdstats' => 'spell',
        'Forker' => 1, 'Help' => 'spell') );
+&addCmdHook("extra", 'dns|d?nslookup|host', ('CODEREF' => 'dns::query',
+       'Identifier' => 'dns', 'Cmdstats' => 'dns',
+       'Forker' => 1, 'Help' => 'dns') );
 ###
 ### END OF ADDING HOOKS.
 ###
index 80522673501b884e378ba372f864f37c4c300006..c5d9aa7ca7851a17fa66c05c4370b93b96d7f62e 100644 (file)
@@ -828,16 +828,6 @@ sub rehashConfVars {
     delete $cache{confvars};
 }
 
-# registered flags... not used yet.
-my @regFlagsChan = (
-       "autojoin",
-       "limitcheckInterval",
-       "limitcheckPlus",
-       "allowConv",
-       "allowDNS",
-### TODO: finish off this list.
-);
-
 my @regFlagsUser = (
        # possible chars to include in FLAG
        "A",    # bot administration over /msg
diff --git a/src/Modules/dns.pl b/src/Modules/dns.pl
new file mode 100644 (file)
index 0000000..73369eb
--- /dev/null
@@ -0,0 +1,54 @@
+#
+#       dns.pl: host lookups
+#       Author: Tim Riker <Tim@Rikers.org>
+#       Source: extracted from UserExtra.pl
+#  Licensing: Artistic License (as perl itself)
+#      Version: v0.1
+#
+#  Copyright (c) 2005 Tim Riker
+#
+
+package dns;
+
+use strict;
+
+sub dns::dns {
+       my $dns = shift;
+       my($match, $x, $y, $result, $pid);
+
+       if ($dns =~ /(\d+\.\d+\.\d+\.\d+)/) {
+               use Socket;
+
+               &main::status("DNS query by IP address: $dns");
+
+               $y = pack('C4', split(/\./, $dns));
+               $x = (gethostbyaddr($y, &AF_INET));
+
+               if ($x !~ /^\s*$/) {
+                       $result = "$dns is $x" unless ($x =~ /^\s*$/);
+               } else {
+                       $result = "I can't find the address $dns in DNS";
+               }
+
+       } else {
+
+               &main::status("DNS query by name: $dns");
+               $x = join('.',unpack('C4',(gethostbyname($dns))[4]));
+
+               if ($x !~ /^\s*$/) {
+                       $result = "$dns is $x";
+               } else {
+                       $result = "I can't find $dns in DNS";
+               }
+       }
+
+       return($result);
+}
+
+sub dns::query {
+       &::performStrictReply(&dns(@_));
+       return;
+}
+
+1;
+# vim: ts=2 sw=2
index 584a43b40636aa9ba453c5707f60afa770581374..9d27eb9d5e52280399af1d0cbef20b0f99d8c4e5 100644 (file)
@@ -26,9 +26,6 @@ use vars qw(%channels %chanstats %cmdstats %count %ircstats %param
 &addCmdHook("main", 'help', ('CODEREF' => 'help',
        'Cmdstats' => 'Help', ) );
 &addCmdHook("main", 'karma', ('CODEREF' => 'karma', ) );
-&addCmdHook("main", 'd?nslookup', ('CODEREF' => 'DNS',
-       Help => 'nslookup', Identifier => 'allowDNS',
-       Forker => "NULL", ) );
 &addCmdHook("main", 'tell|explain', ('CODEREF' => 'tell',
        Help => 'tell', Identifier => 'allowTelling',
        Cmdstats => 'Tell') );
@@ -234,12 +231,6 @@ sub karma {
     }
 }
 
-sub nslookup {
-    my $query = shift;
-    &status("DNS Lookup: $query");
-    &DNS($query);
-}
-
 sub tell {
     my $args = shift;
     my ($target, $tell_obj) = ('','');
@@ -350,45 +341,6 @@ sub tell {
     &msg($target, $reply);
 }
 
-sub DNS {
-    my $dns = shift;
-    my($match, $x, $y, $result);
-    my $pid;
-    $dns =~ s/^\s+|\s+$//g;
-
-    if (!defined $dns or $dns =~ /^\s*$/ or $dns =~ / /) {
-       &help("dns");
-       return;
-    }
-
-    if ($dns =~ /(\d+\.\d+\.\d+\.\d+)/) {
-       $match = $1;
-       &status("DNS query by IP address: $match");
-
-       $y = pack('C4', split(/\./, $match));
-       $x = (gethostbyaddr($y, &AF_INET));
-
-       if ($x !~ /^\s*$/) {
-           $result = $match." is ".$x unless ($x =~ /^\s*$/);
-       } else {
-           $result = "I can't seem to find that address in DNS";
-       }
-
-    } else {
-
-       &status("DNS query by name: $dns");
-       $x = join('.',unpack('C4',(gethostbyname($dns))[4]));
-
-       if ($x !~ /^\s*$/) {
-           $result = $dns." is ".$x;
-       } else {
-           $result = "I can\'t find that machine name";
-       }
-    }
-
-    &performReply($result);
-}
-
 sub countryStats {
     if (exists $cache{countryStats}) {
        &msg($who,"countrystats is already running!");