#
# 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.
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;
}
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) {
}
### unique user count.
- my @nicks;
+ my %nicks = ();
foreach $chan (keys %channels) {
- my $nick = '';
+ my $nick;
foreach $nick (keys %{ $channels{$chan}{''} }) {
- next if (grep /^\Q$nick\E$/, @nicks);
- $uucount++;
- push(@nicks, $nick);
+ $nicks{$nick}++;
}
}
- &::DEBUG(join ":", @nicks);
-
- if (scalar @nicks != $uucount) {
- &DEBUG("nicks != uucount...");
- }
+ $uucount = scalar(keys %nicks);
my $chans = scalar(keys %channels);
&performStrictReply(
", distributed over \002$chans\002 ".
&fixPlural("channel", $chans)."."
);
+ &ircCheck();
return;
}
sub factstats {
my $type = shift(@_);
- &Forker("factoids", sub {
+ &Forker("Factoids", sub {
&performStrictReply( &CmdFactStats($type) );
} );
}
# 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());
}
# 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;
);
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++