X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2FCommandStubs.pl;h=6b0d77880c147d99274f916a9aec1edc6f0526ce;hb=78c32cb96ec107422071b827dd0653a440d260e0;hp=5b26d5b721b30f772c8fa1c410ba2a5d2c999277;hpb=86db0043eef3704e334e1375d5554ebf144234e0;p=infobot.git diff --git a/src/CommandStubs.pl b/src/CommandStubs.pl index 5b26d5b..6b0d778 100644 --- a/src/CommandStubs.pl +++ b/src/CommandStubs.pl @@ -3,7 +3,8 @@ # WARN: this file does not reload on HUP. # -# use strict; # TODO +# TODO: +# use strict; use vars qw($who $msgType $conn $chan $message $ident $talkchannel $bot_version $babel_lang_regex $bot_data_dir); @@ -13,14 +14,13 @@ use vars qw(%channels %cache %mask %userstats %myModules %cmdstats # FIX THE FOLLOWING: use vars qw($total $x $type $i $good); -$babel_lang_regex = "fr|sp|es|po|pt|it|ge|de|gr|en|zh|ja|jp|ko|kr|ru"; +$babel_lang_regex = "de|ge|gr|el|sp|es|en|fr|it|ja|jp|ko|kr|nl|po|pt|ru|zh|zt"; $w3search_regex = "google"; ### COMMAND HOOK IMPLEMENTATION. # addCmdHook("SECTION", 'TEXT_HOOK', -# (CODEREF => 'Blah', +# (CODEREF => 'Blah', # Forker => 1, -# CheckModule => 1, # ??? # Module => 'blah.pl' # preload module. # Identifier => 'config_label', # change to Config? # Help => 'help_label', @@ -44,7 +44,8 @@ sub addCmdHook { # RUN IF ADDRESSED. sub parseCmdHook { my ($hashname, $line) = @_; - $line =~ /^(\S+)( (.*))?$/; + $line =~ s/^\s+|\s+$//g; # again. + $line =~ /^(\S+)(\s+(.*))?$/; my $cmd = $1; # command name is whitespaceless. my $flatarg = $3; my @args = split(/\s+/, $flatarg || ''); @@ -73,7 +74,7 @@ sub parseCmdHook { next; } - &status("hooks($hashname): $cmd matched '$ident'"); + &status("hooks($hashname): $cmd matched '$ident' '$flatarg'"); my %hash = %{ ${"hooks_$hashname"}{$ident} }; if (!scalar keys %hash) { @@ -189,7 +190,7 @@ sub parseCmdHook { 'Forker' => 1, 'Identifier' => 'kernel', 'Cmdstats' => 'Kernel', 'NoArgs' => 1) ); &addCmdHook("extra", 'listauth', ('CODEREF' => 'CmdListAuth', - 'Identifier' => 'search', Module => 'factoids', + 'Identifier' => 'search', Module => 'factoids', 'Help' => 'listauth') ); &addCmdHook("extra", 'quote', ('CODEREF' => 'Quote::Quote', 'Forker' => 1, 'Identifier' => 'quote', @@ -227,9 +228,15 @@ sub parseCmdHook { &addCmdHook("extra", 'weather', ('CODEREF' => 'Weather::Weather', 'Identifier' => 'weather', 'Help' => 'weather', 'Cmdstats' => 'weather', 'Forker' => 1) ); +&addCmdHook("extra", 'metar', ('CODEREF' => 'Weather::Metar', + 'Identifier' => 'weather', 'Help' => 'weather', + 'Cmdstats' => 'weather', 'Forker' => 1) ); &addCmdHook("extra", 'bzflist', ('CODEREF' => 'BZFlag::list', 'Identifier' => 'bzflag', 'Cmdstats' => 'BZFlag', 'Forker' => 1) ); +&addCmdHook("extra", 'bzflist17', ('CODEREF' => 'BZFlag::list17', + 'Identifier' => 'bzflag', 'Cmdstats' => 'BZFlag', + 'Forker' => 1) ); &addCmdHook("extra", 'bzfquery', ('CODEREF' => 'BZFlag::query', 'Identifier' => 'bzflag', 'Cmdstats' => 'BZFlag', 'Forker' => 1, 'Help' => 'bzflag') ); @@ -247,7 +254,15 @@ sub parseCmdHook { 'Forker' => 1) ); &addCmdHook("extra", '(botmail|message)', ('CODEREF' => 'botmail::parse', 'Identifier' => 'botmail', 'Cmdstats' => 'botmail') ); - +&addCmdHook("extra", 'httpdtype', ('CODEREF' => 'HTTPDtype::HTTPDtype', + 'Identifier' => 'httpdtype', 'Cmdstats' => 'httpdtype', + 'Forker' => 1) ); +&addCmdHook("extra", 'rss', ('CODEREF' => 'Rss::Rss', + 'Identifier' => 'rss', 'Cmdstats' => 'rss', + 'Forker' => 1, 'Help' => 'rss') ); +&addCmdHook("extra", 'wiki(pedia)?', ('CODEREF' => 'wikipedia::wikipedia', + 'Identifier' => 'wikipedia', 'Cmdstats' => 'wikipedia', + 'Forker' => 1, 'Help' => 'wikipedia') ); ### ### END OF ADDING HOOKS. ### @@ -278,7 +293,7 @@ sub Modules { return; } - my $debiancmd = 'conflicts?|depends?|desc|file|info|provides?'; + my $debiancmd = 'conflicts?|depends?|desc|file|(?:d)?info|provides?'; $debiancmd .= '|recommends?|suggests?|maint|maintainer'; if ($message =~ /^($debiancmd)(\s+(.*))?$/i) { @@ -295,7 +310,7 @@ sub Modules { } # google searching. Simon++ - if ($message =~ /^(?:search\s+)?($w3search_regex)\s+for\s+['"]?(.*?)["']?\s*\?*$/i) { + if ($message =~ /^(?:search\s+)?($w3search_regex)\s+(?:for\s+)?['"]?(.*?)["']?\s*\?*$/i) { return unless (&hasParam("wwwsearch")); &Forker("wwwsearch", sub { &W3Search::W3Search($1,$2); } ); @@ -541,7 +556,7 @@ sub seen { $reply .= " (".&Time2String(time() - $userstats{lc $seen[0]}{'Join'}).")"; } - if (&IsParam("seenStats")) { + if (&IsChanConf("seenStats") > 0) { my $i; $i = $userstats{lc $seen[0]}{'Count'}; $reply .= ". Has said a total of \002$i\002 messages" if (defined $i); @@ -641,6 +656,7 @@ sub lart { my ($target) = &fixString($_[0]); my $extra = 0; my $chan = $talkchannel; + my ($for); if ($msgType eq 'private') { if ($target =~ /^($mask{chan})\s+(.*)$/) { @@ -653,6 +669,10 @@ sub lart { return; } } + if ($target =~ /^(.*)(\s+for\s+.*)$/) { + $target = $1; + $for = $2; + } my $line = &getRandomLineFromFile($bot_data_dir. "/blootbot.lart"); if (defined $line) { @@ -661,6 +681,7 @@ sub lart { } else { $line =~ s/WHO/$target/g; } + $line .= $for if ($for); $line .= ", courtesy of $who" if ($extra); &action($chan, $line); @@ -846,7 +867,7 @@ sub do_text_counters { if (!defined $arg or $arg =~ /^\s*$/) { # this is way fucking ugly. - # TODO convert $where to hash + # TODO: convert $where to hash my %hash = &sqlSelectColHash("stats", "nick,counter", { }, $where." ORDER BY counter DESC LIMIT 3", 1 @@ -874,7 +895,7 @@ sub do_text_counters { &pSReply("zero counter for \037$type\037."); } } else { - # TODO convert $where to hash and use a sqlSelect + # TODO: convert $where to hash and use a sqlSelect my $x = (&sqlRawReturn("SELECT SUM(counter) FROM stats". " WHERE $where AND nick=".&sqlQuote($arg) ))[0]; @@ -884,7 +905,7 @@ sub do_text_counters { } # defined. - # TODO convert $where to hash + # TODO: convert $where to hash my @array = &sqlSelect("stats", "nick", undef, $where." ORDER BY counter", 1 ); @@ -958,7 +979,7 @@ sub textstats_main { return; } - # TODO add nick to where_href + # TODO: add nick to where_href my %hash = &sqlSelectColHash("stats", "type,counter", $where_href, " AND nick=".&sqlQuote($arg) ); @@ -971,7 +992,7 @@ sub textstats_main { foreach (keys %hash) { &DEBUG("_stats: hash{$_} => $hash{$_}"); # ranking. - # TODO convert $where to hash + # TODO: convert $where to hash my @array = &sqlSelect("stats", "nick", undef, $where." ORDER BY counter", 1); $good = 0; @@ -1005,7 +1026,11 @@ sub textstats_main { &pSReply("\002$arg\002 has said \037$type\037 \002$x\002 times (\002$pct1\002 %)$xtra"); } -sub nullski { my ($arg) = @_; return unless (defined $arg); - foreach (`$arg`) { &msg($who,$_); } } +sub nullski { + my ($arg) = @_; + return unless (defined $arg); + # big security hole + #foreach (`$arg`) { &msg($who,$_); } +} 1;