]> git.donarmstrong.com Git - infobot.git/blob - src/UserExtra.pl
- irctextcounters: add percentage to top3
[infobot.git] / src / UserExtra.pl
1 #
2 # UserExtra.pl: User Commands, Public.
3 #       Author: dms
4 #      Version: v0.2b (20000707)
5 #      Created: 20000107
6 #
7
8 if (&IsParam("useStrict")) { use strict; }
9
10 use vars qw($message $arg $qWord $verb $lobotomized);
11 use vars qw(%channels %chanstats %cmdstats);
12
13 ###
14 ### Start of command hooks for UserExtra.
15 ###
16
17 &addCmdHook("main", 'chan(stats|info)', ('CODEREF' => 'chaninfo', ) );
18 &addCmdHook("main", 'cmd(stats|info)', ('CODEREF' => 'cmdstats', ) );
19 &addCmdHook("main", 'factinfo', ('CODEREF' => 'factinfo', 
20         'Cmdstats' => 'Factoid Info', Module => 'factoids', ) );
21 &addCmdHook("main", 'factstats?', ('CODEREF' => 'factstats', 
22         'Cmdstats' => 'Factoid Statistics', Help => "factstats", 
23         Forker => 1, 'Identifier' => 'factoids', ) );
24 &addCmdHook("main", 'help', ('CODEREF' => 'help', 
25         'Cmdstats' => 'Help', ) );
26 &addCmdHook("main", 'karma', ('CODEREF' => 'karma', ) );
27 &addCmdHook("main", 'i?spell', ('CODEREF' => 'ispell', 
28         Help => 'spell', Identifier => 'spell', ) );
29 &addCmdHook("main", 'd?nslookup', ('CODEREF' => 'DNS', 
30         Help => 'nslookup', Identifier => 'allowDNS',
31         Forker => "NULL", ) );
32 &addCmdHook("main", 'tell|explain', ('CODEREF' => 'tell', 
33         Help => 'tell', Identifier => 'allowTelling',
34         Cmdstats => 'Tell') );
35 &addCmdHook("main", 'news', ('CODEREF' => 'News::Parse', 
36         Module => 'news', 'Cmdstats' => 'News' ) );
37 &addCmdHook("main", 'countrystats', ('CODEREF' => 'countryStats', 
38 #       Forker => "NULL",
39  ) );
40
41 &status("CMD: loaded ".scalar(keys %hooks_main)." MAIN command hooks.");
42
43 ###
44 ### Start of commands for hooks.
45 ###
46
47 sub chaninfo {
48     my $chan = lc shift(@_);
49     my $mode;
50
51     if ($chan eq "") {          # all channels.
52         my $i           = keys %channels;
53         my $reply       = "i am on \002$i\002 ".&fixPlural("channel",$i);
54         my $tucount     = 0;    # total user count.
55         my $uucount     = 0;    # unique user count.
56         my @array;
57
58         ### line 1.
59         foreach (sort keys %channels) {
60             if (/^\s*$/ or / /) {
61                 &status("chanstats: fe channels: chan == NULL.");
62                 &ircCheck();
63                 next;
64             }
65             push(@array, "$_ (".scalar(keys %{ $channels{$_}{''} }).")");
66         }
67         &pSReply($reply.": ".join(' ', @array));
68
69         ### total user count.
70         foreach $chan (keys %channels) {
71             $tucount += scalar(keys %{ $channels{$chan}{''} });
72         }
73
74         ### unique user count.
75         my @nicks;
76         foreach $chan (keys %channels) {
77             foreach (keys %{ $channels{$chan}{''} }) {
78                 next if (grep /^\Q$_\E$/, @nicks);
79                 $uucount++;
80                 push(@nicks, $_);
81             }
82         }
83         &DEBUG("nicks => '".scalar(@nicks)."'...");
84         if (scalar @nicks != $uucount) {
85             &DEBUG("nicks != uucount...");
86         }
87
88         my $chans = scalar(keys %channels);
89         &pSReply(
90             "i've cached \002$tucount\002 ". &fixPlural("user",$tucount).
91             ", \002$uucount\002 unique ". &fixPlural("user",$uucount).
92             ", distributed over \002$chans\002 ".
93             &fixPlural("channel", $chans)."."
94         );
95
96         return;
97     }
98
99     # channel specific.
100
101     if (&validChan($chan) == 0) {
102         &msg($who,"error: invalid channel \002$chan\002");
103         return;
104     }
105
106     # Step 1:
107     my @array;
108     foreach (sort keys %{ $chanstats{$chan} }) {
109         my $int = $chanstats{$chan}{$_};
110         next unless ($int);
111
112         push(@array, "\002$int\002 ". &fixPlural($_,$int));
113     }
114     my $reply = "On \002$chan\002, there ".
115                 &fixPlural("has",scalar(@array)). " been ".
116                 &IJoin(@array);
117
118     # Step 1b: check channel inconstencies.
119     $chanstats{$chan}{'Join'}           ||= 0;
120     $chanstats{$chan}{'SignOff'}        ||= 0;
121     $chanstats{$chan}{'Part'}           ||= 0;
122
123     my $delta_stats = $chanstats{$chan}{'Join'}
124                 - $chanstats{$chan}{'SignOff'}
125                 - $chanstats{$chan}{'Part'};
126
127     if ($delta_stats) {
128         my $total = scalar(keys %{ $channels{$chan}{''} });
129         &status("chaninfo: join ~= signoff + part (drift of $delta_stats < $total).");
130
131         if ($delta_stats > $total) {
132             &ERROR("chaninfo: delta_stats exceeds total users.");
133         }
134     }
135
136     # Step 2:
137     undef @array;
138     my $type;
139     foreach ("v","o","") {
140         my $int = scalar(keys %{ $channels{$chan}{$_} });
141         next unless ($int);
142
143         $type = "Voice" if ($_ eq "v");
144         $type = "Opped" if ($_ eq "o");
145         $type = "Total" if ($_ eq "");
146
147         push(@array,"\002$int\002 $type");
148     }
149     $reply .= ".  At the moment, ". &IJoin(@array);
150
151     # Step 3:
152     my %new;
153     foreach (keys %userstats) {
154         next unless (exists $userstats{$_}{'Count'});
155         if ($userstats{$_}{'Count'} =~ /^\D+$/) {
156             &WARN("userstats{$_}{Count} is non-digit.");
157             next;
158         }
159
160         $new{$_} = $userstats{$_}{'Count'};
161     }
162
163     my($count) = (sort { $a <=> $b } keys %new)[0];
164     if ($count) {
165         $reply .= ".  \002$count\002 has said the most with a total of \002$new{$count}\002 messages";
166     }
167     &pSReply("$reply.");
168 }
169
170 # Command statistics.
171 sub cmdstats {
172     my @array;
173
174     if (!scalar(keys %cmdstats)) {
175         &performReply("no-one has run any commands yet");
176         return;
177     }
178
179     my %countstats;
180     foreach (keys %cmdstats) {
181         $countstats{ $cmdstats{$_} }{$_} = 1;
182     }
183
184     foreach (sort {$b <=> $a} keys %countstats) {
185         my $int = $_;
186         next unless ($int);
187
188         foreach (keys %{ $countstats{$int} }) {
189             push(@array, "\002$int\002 of $_");
190         }
191     }
192     &pSReply("command usage include ". &IJoin(@array).".");
193 }
194
195 # Factoid extension info. xk++
196 sub factinfo {
197     my $faqtoid = lc shift(@_);
198     my $query   = "";
199
200     if ($faqtoid =~ /^\-(\S+)(\s+(.*))$/) {
201         &msg($who,"error: individual factoid info queries not supported as yet.");
202         &msg($who,"it's possible that the factoid mistakenly begins with '-'.");
203         return;
204
205         $query   = lc $1;
206         $faqtoid = lc $3;
207     }
208
209     &CmdFactInfo($faqtoid, $query);
210 }
211
212 sub factstats {
213     my $type = shift(@_);
214
215     &Forker("factoids", sub {
216         &pSReply( &CmdFactStats($type) );
217     } );
218 }
219
220 sub karma {
221     my $target  = lc( shift || $who );
222     my $karma   = &dbGet("stats", "counter", "nick=".
223                         &dbQuote($target)." AND type='karma'") || 0; 
224
225     if ($karma != 0) {
226         &pSReply("$target has karma of $karma");
227     } else {
228         &pSReply("$target has neutral karma");
229     }
230 }
231
232 sub ispell {
233     my $query = shift;
234
235     if (! -x "/usr/bin/spell") {
236         &msg($who, "no binary found.");
237         return;
238     }
239
240     if (!&validExec($query)) {
241         &msg($who,"argument appears to be fuzzy.");
242         return;
243     }
244
245     my $reply = "I can't find alternate spellings for '$query'";
246
247     foreach (`/bin/echo '$query' | /usr/bin/ispell -a -S`) {
248         chop;
249         last if !length;                # end of query.
250
251         if (/^\@/) {            # intro line.
252             next;
253         } elsif (/^\*/) {               # possibly correct.
254             $reply = "'$query' may be spelled correctly";
255             last;
256         } elsif (/^\&/) {               # possible correction(s).
257             s/^\& (\S+) \d+ \d+: //;
258             my @array = split(/,? /);
259
260             $reply = "possible spellings for $query: @array";
261             last;
262         } elsif (/^\+/) {
263             &DEBUG("spell: '+' found => '$_'.");
264             last;
265         } else {
266             &DEBUG("spell: unknown: '$_'.");
267         }
268     }
269
270     &pSReply($reply);
271 }
272
273 sub nslookup {
274     my $query = shift;
275     &status("DNS Lookup: $query");
276     &DNS($query);
277 }
278
279 sub tell {
280     my $args = shift;
281     my ($target, $tell_obj) = ('','');
282     my $dont_tell_me    = 0;
283     my $reply;
284
285     ### is this fixed elsewhere?
286     $args =~ s/\s+/ /g;         # fix up spaces.
287     $args =~ s/^\s+|\s+$//g;    # again.
288
289     # this one catches most of them
290     if ($args =~ /^(\S+) (-?)about (.*)$/i) {
291         $target         = $1;
292         $tell_obj       = $3;
293         $dont_tell_me   = ($2) ? 1 : 0;
294
295         $tell_obj       = $who  if ($tell_obj =~ /^(me|myself)$/i);
296         $query          = $tell_obj;
297     } elsif ($args =~ /^(\S+) where (\S+) can (\S+) (.*)$/i) {
298         # i'm sure this could all be nicely collapsed
299         $target         = $1;
300         $tell_obj       = $4;
301         $query          = $tell_obj;
302
303     } elsif ($args =~ /^(\S+) (what|where) (.*?) (is|are)[.?!]*$/i) {
304         $target         = $1;
305         $qWord          = $2;
306         $tell_obj       = $3;
307         $verb           = $4;
308         $query          = "$qWord $verb $tell_obj";
309
310     } elsif ($args =~ /^(.*?) to (\S+)$/i) {
311         $target         = $3;
312         $tell_obj       = $2;
313         $query          = $tell_obj;
314     }
315
316     # check target type. Deny channel targets.
317     if ($target !~ /^$mask{nick}$/ or $target =~ /^$mask{chan}$/) {
318         &msg($who,"No, $who, I won't. (target invalid?)");
319         return;
320     }
321
322     $target     = $talkchannel  if ($target =~ /^us$/i);
323     $target     = $who          if ($target =~ /^(me|myself)$/i);
324
325     &status("tell: target = $target, query = $query");  
326
327     # "intrusive".
328 #    if ($target !~ /^$mask{chan}$/ and !&IsNickInAnyChan($target)) {
329 #       &msg($who, "No, $target is not in any of my chans.");
330 #       return;
331 #    }
332
333     # self.
334     if ($target =~  /^\Q$ident\E$/i) {
335         &msg($who, "Isn't that a bit silly?");
336         return;
337     }
338
339     my $oldwho          = $who;
340     my $oldmtype        = $msgType;
341     $who                = $target;
342     my $result = &doQuestion($tell_obj);
343         # ^ returns '0' if nothing was found.
344     $who                = $oldwho;
345
346     # no such factoid.
347     if ($result =~ /^0?$/) {
348         $who            = $target;
349         $msgType        = "private";
350
351         # support command redirection.
352         # recursive cmdHooks aswell :)
353         my $done = 0;
354         $done++ if &parseCmdHook("main", $tell_obj);
355         $done++ if &parseCmdHook("extra", $tell_obj);
356         $message        = $tell_obj;
357         $done++ unless (&Modules());
358
359         &VERB("tell: setting old values of who and msgType.",2);
360         $who            = $oldwho;
361         $msgType        = $oldmtype;
362
363         if ($done) {
364             &msg($who, "told $target about CMD '$tell_obj'");
365         } else {
366             &msg($who, "i dunno what is '$tell_obj'.");
367         }
368
369         return;
370     }
371
372     # success.
373     &status("tell: <$who> telling $target about $tell_obj.");
374     if ($who ne $target) {
375         if ($dont_tell_me) {
376             &msg($who, "told $target about $tell_obj.");
377         } else {
378             &msg($who, "told $target about $tell_obj ($result)");
379         }
380
381         $reply = "$who wants you to know: $result";
382     } else {
383         $reply = "telling yourself: $result";
384     }
385
386     &msg($target, $reply);
387 }
388
389 sub DNS {
390     my $dns = shift;
391     my($match, $x, $y, $result);
392     my $pid;
393     $dns =~ s/^\s+|\s+$//g;
394
395     if ($dns =~ /(\d+\.\d+\.\d+\.\d+)/) {
396         $match = $1;
397         &status("DNS query by IP address: $match");
398
399         $y = pack('C4', split(/\./, $match));
400         $x = (gethostbyaddr($y, &AF_INET));
401
402         if ($x !~ /^\s*$/) {
403             $result = $match." is ".$x unless ($x =~ /^\s*$/);
404         } else {
405             $result = "I can't seem to find that address in DNS";
406         }
407
408     } else {
409
410         &status("DNS query by name: $dns");
411         $x = join('.',unpack('C4',(gethostbyname($dns))[4]));
412
413         if ($x !~ /^\s*$/) {
414             $result = $dns." is ".$x;
415         } else {
416             $result = "I can\'t find that machine name";
417         }
418     }
419
420     &performReply($result);
421 }
422
423 sub countryStats {
424     if (exists $cache{countryStats}) {
425         &msg($who,"countrystats is already running!");
426         return;
427     }
428
429     if ($chan eq "") {
430         $chan = $_[0];
431     }
432
433     if ($chan eq "") {
434         &help("countrystats");
435         return;
436     }
437
438     &rawout("WHO $chan");
439     $cache{countryStats}{chan}  = $chan;
440     $cache{countryStats}{mtype} = $msgType;
441     $cache{countryStats}{who}   = $who;
442     $cache{on_who_Hack}         = 1;
443 }
444
445 sub do_countrystats {
446     $chan       = $cache{countryStats}{chan};
447     $msgType    = $cache{countryStats}{mtype};
448     $who        = $cache{countryStats}{who};
449
450     my $total   = 0;
451     my %cstats;
452     foreach (keys %{ $cache{nuhInfo} }) {
453         my $h = $cache{nuhInfo}{$_}{Host};
454
455         if ($h =~ /^.*\.(\D+)$/) {      # host
456             $cstats{$1}++;
457         } else {                        # ip
458             $cstats{unresolve}++;
459         }
460         $total++;
461     }
462     my %count;
463     foreach (keys %cstats) {
464         $count{ $cstats{$_} }{$_} = 1;
465     }
466
467     my @list;
468     foreach (sort {$b <=> $a} keys %count) {
469         my $str = join(", ", sort keys %{ $count{$_} });
470 #       push(@list, "$str ($_)");
471         my $perc        = sprintf("%.01f", 100 * $_ / $total);
472         $perc           =~ s/\.0+$//;
473         push(@list, "$str ($_, $perc %)");
474     }
475
476     # todo: move this into a scheduler like nickometer
477     $msgType    = "private";
478     &pSReply( &formListReply(0, "Country Stats ", @list) );
479
480     delete $cache{countryStats};
481     delete $cache{on_who_Hack};
482 }
483
484 ###
485 ### amalgamated commands.
486 ###
487
488 sub userCommands {
489     # conversion: ascii.
490     if ($message =~ /^(asci*|chr) (\d+)$/) {
491         &DEBUG("ascii/chr called ...");
492         return unless (&hasParam("allowConv"));
493
494         &DEBUG("ascii/chr called");
495
496         $arg    = $2;
497         $result = chr($arg);
498         $result = "NULL"        if ($arg == 0);
499
500         &performReply( sprintf("ascii %s is '%s'", $arg, $result) );
501
502         return;
503     }
504
505     # conversion: ord.
506     if ($message =~ /^ord(\s+(.*))$/) {
507         return unless (&hasParam("allowConv"));
508
509         $arg = $2;
510
511         if (!defined $arg or length $arg != 1) {
512             &help("ord");
513             return;
514         }
515
516         if (ord($arg) < 32) {
517             $arg = chr(ord($arg) + 64);
518             if ($arg eq chr(64)) {
519                 $arg = 'NULL';
520             } else {
521                 $arg = '^'.$arg;
522             }
523         }
524
525         &performReply( sprintf("'%s' is ascii %s", $arg, ord $1) );
526         return;
527     }
528
529     # hex.
530     if ($message =~ /^hex(\s+(.*))?$/i) {
531         return unless (&hasParam("allowConv"));
532         my $arg = $2;
533
534         if (!defined $arg) {
535             &help("hex");
536             return;
537         }
538
539         if (length $arg > 80) {
540             &msg($who, "Too long.");
541             return;
542         }
543
544         my $retval;
545         foreach (split //, $arg) {
546             $retval .= sprintf(" %X", ord($_));
547         }
548
549         &pSReply("$arg is$retval");
550
551         return;
552     }
553
554     # crypt.
555     if ($message =~ /^crypt(\s+(.*))?$/i) {
556         my @args        = split /\s+/, $2;
557
558         if (!scalar @args or scalar @args > 2) {
559             &help("crypt");
560             return;
561         }
562
563         if (scalar @args == 2) {
564             if (length $args[0] != 2) {
565                 &msg($who, "invalid format...");
566                 return;
567             }
568
569             &pSReply( crypt($args[1], $args[0]) );
570         } else {
571             &pSReply( &mkcrypt($args[0]) );
572         }
573
574         return;
575     }
576
577     # cycle.
578     if ($message =~ /^(cycle)(\s+(\S+))?$/i) {
579         return unless (&hasFlag("o"));
580         my $chan = lc $3;
581
582         if ($chan eq "") {
583             if ($msgType =~ /public/) {
584                 $chan = $talkchannel;
585                 &DEBUG("cycle: setting chan to '$chan'.");
586             } else {
587                 &help("cycle");
588                 return;
589             }
590         }
591
592         if (&validChan($chan) == 0) {
593             &msg($who,"error: invalid channel \002$chan\002");
594             return;
595         }
596
597         &msg($chan, "I'm coming back. (courtesy of $who)");
598         &part($chan);
599 ###     &ScheduleThis(5, "getNickInUse") if (@_);
600         &status("Schedule rejoin in 5secs to $chan by $who.");
601         $conn->schedule(5, sub { &joinchan($chan); });
602
603         return;
604     }
605
606     # redir.
607     if ($message =~ /^redir(\s+(.*))?/i) {
608         return unless (&hasFlag("o"));
609         my $factoid = $2;
610
611         if (!defined $factoid) {
612             &help("redir");
613             return;
614         }
615
616         my $val  = &getFactInfo($factoid, "factoid_value");
617         if (!defined $val or $val eq "") {
618             &msg($who, "error: '$factoid' does not exist.");
619             return;
620         }
621         &DEBUG("val => '$val'.");
622         my @list = &searchTable("factoids", "factoid_key",
623                                         "factoid_value", "^$val\$");
624
625         if (scalar @list == 1) {
626             &msg($who, "hrm... '$factoid' is unique.");
627             return;
628         }
629         if (scalar @list > 5) {
630             &msg($who, "A bit too many factoids to be redirected, hey?");
631             return;
632         }
633
634         my @redir;
635         &status("Redirect '$factoid' (". ($#list) .")...");
636         for (@list) {
637             my $x = $_;
638             next if (/^\Q$factoid\E$/i);
639
640             &status("  Redirecting '$_'.");
641             my $was = &getFactoid($_);
642             if ($was =~ /<REPLY> see/i) {
643                 &status("warn: not redirecting a redirection.");
644                 next;
645             }
646
647             &DEBUG("  was '$was'.");
648             push(@redir,$x);
649             &setFactInfo($x, "factoid_value", "<REPLY> see $factoid");
650         }
651         &status("Done.");
652
653         &msg($who, &formListReply(0, "'$factoid' is redirected to by '", @redir));
654
655         return;
656     }
657
658     # rot13 it.
659     if ($message =~ /^rot13(\s+(.*))?/i) {
660         my $reply = $2;
661
662         if (!defined $reply) {
663             &help("rot13");
664             return;
665         }
666
667         $reply =~ y/A-Za-z/N-ZA-Mn-za-m/;
668         &pSReply($reply);
669
670         return;
671     }
672
673     # cpustats.
674     if ($message =~ /^cpustats$/i) {
675         if ($^O !~ /linux/) {
676             &ERROR("cpustats: your OS is not supported yet.");
677             return;
678         }
679
680         ### poor method to get info out of file, please fix.
681         open(STAT,"/proc/$$/stat");
682         my $line = <STAT>;
683         chop $line;
684         my @data = split(/ /, $line);
685         close STAT;
686
687         # utime(13) + stime(14).
688         my $cpu_usage   = sprintf("%.01f", ($data[13]+$data[14]) / 100 );
689         # cutime(15) + cstime (16).
690         my $cpu_usage2  = sprintf("%.01f", ($data[15]+$data[16]) / 100 );
691         my $time        = time() - $^T;
692         my $raw_perc    = $cpu_usage*100/$time;
693         my $raw_perc2   = $cpu_usage2*100/$time;
694         my $perc;
695         my $perc2;
696
697         if ($raw_perc > 1) {
698             $perc       = sprintf("%.01f", $raw_perc);
699             $perc2      = sprintf("%.01f", $raw_perc2);
700         } elsif ($raw_perc > 0.1) {
701             $perc       = sprintf("%.02f", $raw_perc);
702             $perc2      = sprintf("%.02f", $raw_perc2);
703         } else {                        # <=0.1
704             $perc       = sprintf("%.03f", $raw_perc);
705             $perc2      = sprintf("%.03f", $raw_perc2);
706         }
707
708         &pSReply("Total CPU usage: $cpu_usage s ... Percentage CPU used: $perc % (+childs: $perc2 %)");
709
710         return;
711     }
712
713     # ircstats.
714     if ($message =~ /^ircstats?$/i) {
715         $ircstats{'TotalTime'}  ||= 0;
716         $ircstats{'OffTime'}    ||= 0;
717
718         my $count       = $ircstats{'ConnectCount'};
719         my $format_time = &Time2String(time() - $ircstats{'ConnectTime'});
720         my $total_time  = time() - $ircstats{'ConnectTime'} +
721                                 $ircstats{'TotalTime'};
722         my $reply;
723
724         my $connectivity = 100 * ($total_time - $ircstats{'OffTime'}) /
725                                 $total_time;
726         my $p = sprintf("%.03f", $connectivity);
727         $p =~ s/(\.\d*)0+$/$1/;
728         if ($p =~ s/\.0$//) {
729             # this should not happen... but why...
730         } else {
731             $p =~ s/\.$//
732         }
733
734         if ($total_time != (time() - $ircstats{'ConnectTime'}) ) {
735             my $tt_format = &Time2String($total_time);
736             &DEBUG("tt_format => $tt_format");
737         }
738
739         ### RECONNECT COUNT.
740         if ($count == 1) {      # good.
741             $reply = "I'm connected to $ircstats{'Server'} and have been so".
742                 " for $format_time";
743         } else {
744             $reply = "Currently I'm hooked up to $ircstats{'Server'} but only".
745                 " for $format_time.  ".
746                 "I had to reconnect \002$count\002 times.".
747                 "   Connectivity: $p %";
748         }
749
750         ### REASON.
751         my $reason = $ircstats{'DisconnectReason'};
752         if (defined $reason) {
753             $reply .= ".  I was last disconnected for '$reason'.";
754         }
755
756         &pSReply($reply);
757                 
758         return;
759     }
760
761     # status.
762     if ($message =~ /^statu?s$/i) {
763         my $startString = scalar(localtime $^T);
764         my $upString    = &Time2String(time() - $^T);
765         my $count       = &countKeys("factoids");
766
767         $count{'Commands'}      = 0;
768         foreach (keys %cmdstats) {
769             $count{'Commands'} += $cmdstats{$_};
770         }
771
772         &pSReply(
773         "Since $startString, there have been".
774           " \002$count{'Update'}\002 ".
775                 &fixPlural("modification", $count{'Update'}).
776           " and \002$count{'Question'}\002 ".
777                 &fixPlural("question",$count{'Question'}).
778           " and \002$count{'Dunno'}\002 ".
779                 &fixPlural("dunno",$count{'Dunno'}).
780           " and \002$count{'Moron'}\002 ".
781                 &fixPlural("moron",$count{'Moron'}).
782           " and \002$count{'Commands'}\002 ".
783                 &fixPlural("command",$count{'Commands'}).
784           ".  I have been awake for $upString this session, and ".
785           "currently reference \002$count\002 factoids.  ".
786           "I'm using about \002$memusage\002 ".
787           "kB of memory."
788         );
789
790         # todo: make dbGetColNiceHash().
791         my %hash = &dbGetCol("stats", "nick,counter", "type='cmdstats'".
792 #                       " ORDER BY counter DESC LIMIT 3", 1);
793                         " ORDER BY counter DESC", 1);
794
795         foreach (keys %hash) {
796             &DEBUG("cmdstats: hash{$_} => $hash{$_}");
797         }
798         &DEBUG("end of cmdstats.");
799
800         return;
801     }
802
803     # wantNick. xk++
804     if ($message =~ /^wantNick$/i) {
805         if ($param{'ircNick'} eq $ident) {
806             &msg($who, "I hope you're right. I'll try anyway.");
807         }
808
809         if (! &IsNickInAnyChan( $param{ircNick} ) ) {
810             my $str = "attempting to change nick to $param{'ircNick'}";
811             &status($str);
812             &msg($who, $str);
813             &nick($param{'ircNick'});
814         } else {
815             &msg($who, "hrm... can't do it");
816             &DEBUG("wN: nick is somewhere... should try later.");
817         }
818
819         return;
820     }
821
822     return "CONTINUE";
823 }
824
825 1;