X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2FCommandStubs.pl;h=7aec2a61eb684a20805f37cae4dbafaf9bce4d85;hb=99f86352e2eff21f5eef65c16c41b44e1bfa17b6;hp=9b9eec568a7916d7e412aa47d3491891e30f6eeb;hpb=3192b5c2d5d0f4218b2e4a41f81827bca445ee0c;p=infobot.git diff --git a/src/CommandStubs.pl b/src/CommandStubs.pl index 9b9eec5..7aec2a6 100644 --- a/src/CommandStubs.pl +++ b/src/CommandStubs.pl @@ -3,7 +3,7 @@ # WARN: this file does not reload on HUP. # -if (&IsParam("useStrict")) { use strict; } +#use strict; $babel_lang_regex = "fr|sp|po|pt|it|ge|de|gr|en"; @@ -73,7 +73,7 @@ sub parseCmdHook { } if ($hash{NoArgs} and $flatarg) { - &DEBUG("cmd $ident does not take args; skipping."); + &DEBUG("cmd $ident does not take args ('$flatarg'); skipping."); next; } @@ -215,6 +215,9 @@ sub parseCmdHook { 'Identifier' => 'freshmeat', 'Cmdstats' => 'Freshmeat', 'Forker' => 1, 'Help' => 'freshmeat') ); &addCmdHook("extra", 'verstats', ('CODEREF' => 'do_verstats' ) ); +&addCmdHook("extra", 'weather', ('CODEREF' => 'Weather::Weather', + 'Identifier' => 'weather', 'Help' => 'weather', + 'Cmdstats' => 'Weather') ); ### ### END OF ADDING HOOKS. @@ -280,6 +283,11 @@ sub Modules { $itc =~ s/([^\w\s])/\\$1/g; my $z = join '|', split ' ', $itc; + if ($msgType eq "privmsg" and $message =~ / ($mask{chan})$/) { + &DEBUG("ircTC: privmsg detected; chan = $1"); + $chan = $1; + } + if ($message =~ /^_stats(\s+(\S+))$/i) { &textstats_main($2); return; @@ -317,7 +325,7 @@ sub Modules { } } my $topstr = ""; - &DEBUG("tp => $tp"); + &DEBUG("*stats: tp => $tp"); if (scalar @top) { $topstr = ". Top ".scalar(@top).": ".join(', ', @top); } @@ -524,7 +532,7 @@ sub Modules { $reply .= ". Started the scan ".&Time2String(time() - $wingaterun)." ago"; } - &performStrictReply("$reply."); + &pSReply("$reply."); return; } @@ -567,6 +575,11 @@ sub seen { my($person) = lc shift; $person =~ s/\?*$//; + if (&whatInterface() !~ /IRC/) { + &status("seen disabled in CLI."); + return; + } + if (!defined $person or $person =~ /^$/) { &help("seen"); @@ -724,7 +737,7 @@ sub lart { } } - my $line = &getRandomLineFromFile($bot_misc_dir. "/blootbot.lart"); + my $line = &getRandomLineFromFile($bot_data_dir. "/blootbot.lart"); if (defined $line) { if ($target =~ /^(me|you|itself|\Q$ident\E)$/i) { $line =~ s/WHO/$who/g; @@ -776,7 +789,7 @@ sub DebianNew { } close IDX1; - &::performStrictReply( &::formListReply(0, "New debian packages:", @new) ); + &::pSReply( &::formListReply(0, "New debian packages:", @new) ); } sub do_verstats { @@ -797,12 +810,24 @@ sub do_verstats { return; } - &msg($who, "Sending CTCP VERSION..."); + &msg($who, "Sending CTCP VERSION to #$chan..."); $conn->ctcp("VERSION", $chan); $cache{verstats}{chan} = $chan; $cache{verstats}{who} = $who; $cache{verstats}{msgType} = $msgType; + $conn->schedule(30, sub { + my $c = lc $cache{verstats}{chan}; + @vernicktodo = (); + + foreach (keys %{ $channels{$c}{''} } ) { + next if (grep /^\Q$_\E$/i, @vernick); + push(@vernicktodo, $_); + } + + &verstats_flush(); + } ); + $conn->schedule(60, sub { my $vtotal = 0; my $c = lc $cache{verstats}{chan}; @@ -820,7 +845,7 @@ sub do_verstats { my $unknown = $total - $vtotal; my $perc = sprintf("%.1f", $unknown * 100 / $total); $perc =~ s/.0$//; - $sorted{$perc}{"unknown/cloak"} = "$unknown ($perc%)"; + $sorted{$perc}{"unknown/cloak"} = "$unknown ($perc%)" if ($unknown); foreach (keys %ver) { my $count = scalar keys %{ $ver{$_} }; @@ -849,6 +874,19 @@ sub do_verstats { return; } +sub verstats_flush { + for (1..5) { + last unless (scalar @vernicktodo); + + my $n = shift(@vernicktodo); + $conn->ctcp("VERSION", $n); + } + + return unless (scalar @vernicktodo); + + $conn->schedule(3, \&verstats_flush() ); +} + sub textstats_main { my($arg) = @_; @@ -881,7 +919,7 @@ sub textstats_main { } my $topstr = ""; - &DEBUG("tp => $tp"); + &DEBUG("*stats: tp => $tp"); if (scalar @top) { $topstr = ". Top ".scalar(@top).": ".join(', ', @top); }