]> git.donarmstrong.com Git - infobot.git/commitdiff
woot! %myModules is dead
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 23 Nov 2004 08:03:48 +0000 (08:03 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 23 Nov 2004 08:03:48 +0000 (08:03 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1079 c11ca15a-4712-0410-83d8-924469b57eb5

files/sample/blootbot.chan
src/CommandStubs.pl
src/Factoids/Core.pl
src/Factoids/Question.pl
src/IRC/IrcHooks.pl
src/Misc.pl
src/Process.pl
src/modules.pl

index befec069135c76afd58ef215e1e3219c58973bab..c855e759703b3d95728ef37235761547ee9fa772 100644 (file)
@@ -1,4 +1,4 @@
-#v1: blootbot -- infobot -- written Tue Nov 23 07:38:10 2004
+#v1: blootbot -- infobot -- written Tue Nov 23 07:55:42 2004
 
 #botpark
     +RootWarn
index 21fd9ca2ff16f6a0c4cdfba64b7a2a6920f65254..873c0ce7c1b410823d61de451306de19b6d94678 100644 (file)
@@ -124,7 +124,7 @@ sub parseCmdHook {
 
        } else {
            if (exists $hash{'Module'}) {
-               &loadMyModule($myModules{ $hash{'Module'} });
+               &loadMyModule($hash{'Module'});
            }
 
            # check if CODEREF exists.
@@ -351,7 +351,7 @@ sub Modules {
 
        my $term = (lc $1 eq 'me') ? $who : $1;
 
-       &loadMyModule($myModules{'nickometer'});
+       &loadMyModule('nickometer');
 
        if ($term =~ /^$mask{chan}$/) {
            &status("Doing nickometer for chan $term.");
@@ -449,7 +449,7 @@ sub Modules {
        }
 
        # now lets do it.
-       &loadMyModule($myModules{'Topic'});
+       &loadMyModule('Topic');
        &Topic($chan, $thiscmd, join(' ', @args));
        $cmdstats{'Topic'}++;
        return;
index f32736126c6d889015ebdfba603147bfe8d697e6..684922d0759bcc804a7be7406d12de4c0e4798dc 100644 (file)
@@ -496,8 +496,8 @@ sub FactoidStuff {
     if (defined $result and $result !~ /^0?$/) {       # question.
        &status("question: <$who> $message");
        $count{'Question'}++;
-    } elsif (&IsChanConf("Math") > 0 and $addressed) { # perl math.
-       &loadMyModule("Math");
+    } elsif (&IsChanConf('Math') > 0 and $addressed) { # perl math.
+       &loadMyModule('Math');
        my $newresult = &perlMath();
 
        if (defined $newresult and $newresult ne "") {
@@ -513,7 +513,7 @@ sub FactoidStuff {
     }
 
     # why would a friendly bot get passed here?
-    if (&IsParam("friendlyBots")) {
+    if (&IsParam('friendlyBots')) {
        return if (grep lc($_) eq lc($who), split(/\s+/, $param{'friendlyBots'}));
     }
 
index 06ab16cde4cc1828d83f3c2397060b3a52ec26cb..4451aaa30d6e3f2224a312bf8e3b33ff4c4f85fd 100644 (file)
@@ -155,8 +155,8 @@ sub doQuestion {
     }
 
     ### TODO: Use &Forker(); move function to Debian.pl
-    if (&IsChanConf("debianForFactoid")) {
-       &loadMyModule($myModules{'Debian'});
+    if (&IsChanConf('debianForFactoid')) {
+       &loadMyModule('Debian');
        $result = &Debian::DebianFind($query);  # ???
        ### TODO: debian module should tell, through shm, that it went
        ###       ok or not.
index 57b41a01c064593ec2f8423f38f5dac7882636f4..6db8b75e1ed6a4b31dbca093c4c0d5ec2bb27897 100644 (file)
@@ -115,7 +115,7 @@ sub on_chat {
 
     if ($message =~ s/^\.//) { # dcc chat commands.
        ### TODO: make use of &Forker(); here?
-       &loadMyModule( $myModules{'UserDCC'} );
+       &loadMyModule('UserDCC');
 
        &DCCBroadcast("#$who# $message","m");
 
@@ -577,16 +577,16 @@ sub on_join {
     );
 
     ### NEWS:
-    if (&IsChanConf("news") && &IsChanConf("newsKeepRead")) {
-       if (!&loadMyModule("news")) {   # just in case.
-           &DEBUG("could not load news.");
+    if (&IsChanConf('news') && &IsChanConf('newsKeepRead')) {
+       if (!&loadMyModule('news')) {   # just in case.
+           &DEBUG('could not load news.');
        } else {
            &News::latest($chan);
        }
     }
 
     ### botmail:
-    if (&IsChanConf("botmail")) {
+    if (&IsChanConf('botmail')) {
        &botmail::check(lc $who);
     }
 
index df5e8de99789b42ea8ccd5c023eacbe57ed4beb4..bef0f917634d5ad1ed340c07f01522524b6e4f5a 100644 (file)
@@ -621,7 +621,7 @@ sub Forker {
 
     ### TODO: use AUTOLOAD
     ### very lame hack.
-    if ($label !~ /-/ and !&loadMyModule($myModules{$label})) {
+    if ($label !~ /-/ and !&loadMyModule($label)) {
        &DEBUG("Forker: failed?");
        &delForked($label);
     }
index 42602ba3735ae890fcdeb8b88c56b190acb206b6..39854e1ffc95b155d36ad1cc10fa2e471e47526b 100644 (file)
@@ -340,7 +340,7 @@ sub process {
 
        # allow administration of bot via messages (default is DCC CHAT only)
        if (&IsFlag("A")) {
-           &loadMyModule( $myModules{'UserDCC'} );
+           &loadMyModule('UserDCC');
            $er = &userDCC();
            if (!defined $er) {
                return 'SOMETHING 2';
index ffdd7987781cdfccb84f08811fc6206206af893c..a1cc28f256bfaca0a094e694aafa6a13dd5c82ce 100644 (file)
@@ -20,45 +20,6 @@ if ($@) {
 }
 &showProc(" (IO::Socket)");
 
-### MODULES.
-%myModules = (
-       "babelfish"     => "babelfish.pl",
-       "botmail"       => "botmail.pl",
-       "BZFlag"        => "BZFlag.pl",
-       "countdown"     => "countdown.pl",
-       "Debian"        => "Debian.pl",
-       "DebianExtra"   => "DebianExtra.pl",
-       "Dict"          => "Dict.pl",
-       "DumpVars"      => "DumpVars.pl",
-       "Exchange"      => "Exchange.pl",
-       "Factoids"      => "Factoids.pl",
-       "HTTPDtype"     => "HTTPDtype.pl",
-       "insult"        => "insult.pl",
-       "UserDCC"       => "UserDCC.pl",
-       "Kernel"        => "Kernel.pl",
-       "News"          => "News.pl",
-       "nickometer"    => "nickometer.pl",
-       "pager"         => "pager.pl",
-       "Math"          => "Math.pl",
-       "Plug"          => "Plug.pl",
-       "Quote"         => "Quote.pl",
-       "RootWarn"      => "RootWarn.pl",
-       "Rss"           => "Rss.pl",
-       "Search"        => "Search.pl",
-       "slashdot"      => "slashdot.pl",
-       "DumpVars2"     => "DumpVars2.pl",
-       "Topic"         => "Topic.pl",
-       "Units"         => "Units.pl",
-       "Uptime"        => "Uptime.pl",
-       "UserInfo"      => "UserInfo.pl",
-       "Weather"       => "Weather.pl",
-       "wikipedia"     => "wikipedia.pl",
-       "Wingate"       => "Wingate.pl",
-       "W3Search"      => "W3Search.pl",
-       "zfi"           => "zfi.pl",
-       "Zippy"         => "Zippy.pl",
-       "zsi"           => "zsi.pl",
-);
 ### THIS IS NOT LOADED ON RELOAD :(
 my @myModulesLoadNow;
 my @myModulesReloadNot;
@@ -180,16 +141,11 @@ sub loadMyModulesNow {
        }
 
        if (!&IsParam($_) and !&IsChanConf($_) and !&getChanConfList($_)) {
-           if (exists $myModules{$_}) {
-               &status("myModule: $myModules{$_} or $_ (1) not loaded.");
-           } else {
-               &DEBUG("myModule: $_ (2) not loaded.");
-           }
-
+           &DEBUG("loadMyModuleNow: $_ (2) not loaded.");
            next;
        }
 
-       &loadMyModule($myModules{$_});
+       &loadMyModule($_);
        $loaded++;
     }
 
@@ -301,32 +257,22 @@ sub loadPerlModule {
 }
 
 sub loadMyModule {
-    my ($tmp) = @_;
-    if (!defined $tmp) {
+    my ($modulename) = @_;
+    if (!defined $modulename) {
        &WARN("loadMyModule: module is NULL.");
        return 0;
     }
 
-    my ($modulename, $modulebase);
-    if (exists $myModules{$tmp}) {
-       ($modulename, $modulebase) = ($tmp, $myModules{$tmp});
-    } else {
-       $modulebase = $tmp;
-       if ($tmp = grep /^$modulebase$/, keys %myModules) {
-           &DEBUG("lMM: lame hack, file => name => $tmp.");
-           $modulename = $tmp;
-       }
-    }
-    my $modulefile = "$bot_src_dir/Modules/$modulebase";
+    my $modulefile = "$bot_src_dir/Modules/$modulename.pl";
 
     # call reloadModule() which checks age of file and reload.
-    if (grep /\/$modulebase$/, keys %INC) {
-       &reloadModule($modulebase);
+    if (grep /\/$modulename$/, keys %INC) {
+       &reloadModule($modulename);
        return 1;       # depend on reloadModule?
     }
 
     if (! -f $modulefile) {
-       &ERROR("lMM: module ($modulebase) does not exist.");
+       &ERROR("lMM: module ($modulename) does not exist.");
        if ($$ == $bot_pid) {   # parent.
            &shutdown() if (defined $shm and defined $dbh);
        } else {                        # child.
@@ -339,7 +285,7 @@ sub loadMyModule {
 
     eval "require \"$modulefile\"";
     if ($@) {
-       &ERROR("cannot load my module: $modulebase");
+       &ERROR("cannot load my module: $modulename");
        if ($bot_pid != $$) {   # child.
            &DEBUG("b4 delfork 2");
            &delForked($modulename);
@@ -350,8 +296,8 @@ sub loadMyModule {
     } else {
        $moduleAge{$modulefile} = (stat $modulefile)[9];
 
-       &status("Loaded $modulebase");
-       &showProc(" ($modulebase)");
+       &status("Loaded $modulename");
+       &showProc(" ($modulename)");
        return 1;
     }
 }
@@ -377,11 +323,9 @@ sub AUTOLOAD {
 
     $AUTOLOAD =~ s/^(\S+):://g;
 
-    if (exists $myModules{lc $AUTOLOAD}) {
-       # hopefully this will work.
-       &DEBUG("Trying to load module $AUTOLOAD...");
-       &loadMyModule(lc $AUTOLOAD);
-    }
+    # hopefully this will work.
+    &DEBUG("Trying to load module $AUTOLOAD...");
+    &loadMyModule($AUTOLOAD);
 }
 
 sub getPerlFiles {