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