From: timriker Date: Tue, 23 Nov 2004 08:03:48 +0000 (+0000) Subject: woot! %myModules is dead X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f50dcff8690c6f4c16c9df9ea5bf1729674b2257;p=infobot.git woot! %myModules is dead git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1079 c11ca15a-4712-0410-83d8-924469b57eb5 --- diff --git a/files/sample/blootbot.chan b/files/sample/blootbot.chan index befec06..c855e75 100644 --- a/files/sample/blootbot.chan +++ b/files/sample/blootbot.chan @@ -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 diff --git a/src/CommandStubs.pl b/src/CommandStubs.pl index 21fd9ca..873c0ce 100644 --- a/src/CommandStubs.pl +++ b/src/CommandStubs.pl @@ -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; diff --git a/src/Factoids/Core.pl b/src/Factoids/Core.pl index f327361..684922d 100644 --- a/src/Factoids/Core.pl +++ b/src/Factoids/Core.pl @@ -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'})); } diff --git a/src/Factoids/Question.pl b/src/Factoids/Question.pl index 06ab16c..4451aaa 100644 --- a/src/Factoids/Question.pl +++ b/src/Factoids/Question.pl @@ -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. diff --git a/src/IRC/IrcHooks.pl b/src/IRC/IrcHooks.pl index 57b41a0..6db8b75 100644 --- a/src/IRC/IrcHooks.pl +++ b/src/IRC/IrcHooks.pl @@ -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); } diff --git a/src/Misc.pl b/src/Misc.pl index df5e8de..bef0f91 100644 --- a/src/Misc.pl +++ b/src/Misc.pl @@ -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); } diff --git a/src/Process.pl b/src/Process.pl index 42602ba..39854e1 100644 --- a/src/Process.pl +++ b/src/Process.pl @@ -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'; diff --git a/src/modules.pl b/src/modules.pl index ffdd798..a1cc28f 100644 --- a/src/modules.pl +++ b/src/modules.pl @@ -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 {