X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2FUserExtra.pl;h=12ec9c324a2f6729c5381cf2341b602f9da802c5;hb=3e80b587d8a517bbefd5d4d53d528a2c93aacb84;hp=047916436b1c6ccb445bdf676c25a0b0e195c6f7;hpb=877487b059946b5d280f243023ac0b6b308a36a3;p=infobot.git diff --git a/src/UserExtra.pl b/src/UserExtra.pl index 0479164..12ec9c3 100644 --- a/src/UserExtra.pl +++ b/src/UserExtra.pl @@ -1,41 +1,15 @@ # # UserExtra.pl: User Commands, Public. # Author: dms -# Version: v0.2b (20000707) -# Created: 20000107 # use strict; use vars qw($message $arg $qWord $verb $lobotomized $who $result $chan $conn $msgType $query $talkchannel $ident $memusage); use vars qw(%channels %chanstats %cmdstats %count %ircstats %param - %cache %mask %userstats %hooks_main); + %cache %mask %userstats); -### -### Start of command hooks for UserExtra. -### - -&addCmdHook("main", 'chan(stats|info)', ('CODEREF' => 'chaninfo', ) ); -&addCmdHook("main", 'cmd(stats|info)', ('CODEREF' => 'cmdstats', ) ); -&addCmdHook("main", 'sched(stats|info)', ('CODEREF' => 'scheduleList', ) ); -&addCmdHook("main", 'factinfo', ('CODEREF' => 'factinfo', - 'Cmdstats' => 'Factoid Info', Module => 'Factoids', ) ); -&addCmdHook("main", 'factstats?', ('CODEREF' => 'factstats', - 'Cmdstats' => 'Factoid Stats', Help => "factstats", - Forker => 1, 'Identifier' => 'Factoids', ) ); -&addCmdHook("main", 'help', ('CODEREF' => 'help', - 'Cmdstats' => 'Help', ) ); -&addCmdHook("main", 'karma', ('CODEREF' => 'karma', ) ); -&addCmdHook("main", 'tell|explain', ('CODEREF' => 'tell', - Help => 'tell', Identifier => 'allowTelling', - Cmdstats => 'Tell') ); -&addCmdHook("main", 'News', ('CODEREF' => 'News::Parse', - Module => 'News', 'Cmdstats' => 'News' ) ); -&addCmdHook("main", 'countrystats', ('CODEREF' => 'countryStats', -# Forker => "NULL", - ) ); - -&status("CMD: loaded ".scalar(keys %hooks_main)." MAIN command hooks."); +### hooks get added in CommandHooks.pl. ### ### Start of commands for hooks. @@ -47,7 +21,7 @@ sub chaninfo { if ($chan eq "") { # all channels. my $i = keys %channels; - my $reply = "i am on \002$i\002 ".&fixPlural("channel",$i); + my $reply = "I'm on \002$i\002 ".&fixPlural("channel",$i); my $tucount = 0; # total user count. my $uucount = 0; # unique user count. my @array; @@ -61,11 +35,10 @@ sub chaninfo { } next if (/^_default$/); - my $str = sprintf("%s (%d)", $_, scalar(keys %{ $channels{$_}{''} })); + my $str = sprintf("%s/%d", $_, scalar(keys %{ $channels{$_}{''} })); push(@array, $str); } &performStrictReply($reply.": ".join(', ', @array)); - &ircCheck(); ### total user count. foreach $chan (keys %channels) { @@ -73,18 +46,14 @@ sub chaninfo { } ### unique user count. - my @nicks; + my %nicks = (); foreach $chan (keys %channels) { - foreach (keys %{ $channels{$chan}{''} }) { - next if (grep /^\Q$_\E$/, @nicks); - $uucount++; - push(@nicks, $_); + my $nick; + foreach $nick (keys %{ $channels{$chan}{''} }) { + $nicks{$nick}++; } } - - if (scalar @nicks != $uucount) { - &DEBUG("nicks != uucount..."); - } + $uucount = scalar(keys %nicks); my $chans = scalar(keys %channels); &performStrictReply( @@ -93,6 +62,7 @@ sub chaninfo { ", distributed over \002$chans\002 ". &fixPlural("channel", $chans)."." ); + &ircCheck(); return; } @@ -214,7 +184,7 @@ sub factinfo { sub factstats { my $type = shift(@_); - &Forker("factoids", sub { + &Forker("Factoids", sub { &performStrictReply( &CmdFactStats($type) ); } ); } @@ -306,8 +276,7 @@ sub tell { # support command redirection. # recursive cmdHooks aswell :) my $done = 0; - $done++ if &parseCmdHook("main", $tell_obj); - $done++ if &parseCmdHook("extra", $tell_obj); + $done++ if &parseCmdHook($tell_obj); $message = $tell_obj; $done++ unless (&Modules()); @@ -589,15 +558,20 @@ sub userCommands { } # rot13 it. - if ($message =~ /^rot13(\s+(.*))?/i) { - my $reply = $2; + if ($message =~ /^rot([0-9]*)(\s+(.*))?/i) { + my $reply = $3; if (!defined $reply) { &help("rot13"); return; } + my $num = $1 % 26; + my $upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + my $lower="abcdefghijklmnopqrstuvwxyz"; + my $to=substr($upper,$num).substr($upper,0,$num).substr($lower,$num).substr($lower,0,$num); + eval "\$reply =~ tr/$upper$lower/$to/;"; - $reply =~ y/A-Za-z/N-ZA-Mn-za-m/; + #$reply =~ y/A-Za-z/N-ZA-Mn-za-m/; &performStrictReply($reply); return; @@ -737,23 +711,6 @@ sub userCommands { ); return; - - my %hash = &sqlSelectColHash("stats", "nick,counter", - { type => "cmdstats" }, 1); -# ORDER won't be retained in a hash -# " ORDER BY counter DESC", 1); - -if (0) { - foreach (keys %hash) { - my $i = $_; - foreach (keys %{ $hash{$i} }) { - &DEBUG("cmdstats: $hash{$i}{$_} = $_"); - } - } - &DEBUG("end of cmdstats."); -} - - return; } # wantNick. xk++