2 # User Command Extension Stubs
3 # WARN: this file does not reload on HUP.
6 if (&IsParam("useStrict")) { use strict; }
8 $babel_lang_regex = "fr|sp|po|pt|it|ge|de|gr|en";
10 ### COMMAND HOOK IMPLEMENTATION.
11 # addCmdHook("SECTION", 'TEXT_HOOK',
14 # CheckModule => 1, # ???
15 # Module => 'blah.pl' # preload module.
16 # Identifier => 'config_label', # change to Config?
17 # Help => 'help_label',
18 # Cmdstats => 'text_label',)
23 my ($hashname, $ident, %hash) = @_;
25 if (exists ${"hooks_$hashname"}{$ident}) {
26 ### &WARN("aCH: cmd hooks \%$hashname{$ident} already exists.");
30 &VERB("aCH: added $ident",2); # use $hash{'Identifier'}?
31 ### hrm... prevent warnings?
32 ${"hooks_$hashname"}{$ident} = \%hash;
37 my ($hashname, $line) = @_;
38 $line =~ /^(\S+)( (.*))?$/;
39 my $cmd = $1; # command name is whitespaceless.
41 my @args = split(/\s+/, $flatarg || '');
46 if (!defined %{"hooks_$hashname"}) {
47 &WARN("cmd hooks \%$hashname does not exist.");
52 &WARN("cstubs: cmd == NULL.");
56 foreach (keys %{"hooks_$hashname"}) {
57 # rename to something else! like $id or $label?
60 next unless ($cmd =~ /^$ident$/i);
63 &WARN("pCH: Multiple hook match: $ident");
67 &status("hooks($hashname): $cmd matched '$ident'");
68 my %hash = %{ ${"hooks_$hashname"}{$ident} };
70 if (!scalar keys %hash) {
71 &WARN("CmdHook: hash is NULL?");
75 if ($hash{NoArgs} and $flatarg) {
76 &DEBUG("cmd $ident does not take args ('$flatarg'); skipping.");
80 if (!exists $hash{CODEREF}) {
81 &ERROR("CODEREF undefined for $cmd or $ident.");
86 foreach (keys %hash) {
87 &VERB(" $cmd->$_ => '$hash{$_}'.",2);
91 if (exists $hash{'Help'} and !scalar(@args)) {
92 &help( $hash{'Help'} );
97 if (exists $hash{'Identifier'}) {
98 return 1 unless (&hasParam($hash{'Identifier'}));
102 if (exists $hash{'UserFlag'}) {
103 return 1 unless (&hasFlag($hash{'UserFlag'}));
106 ### FORKER,IDENTIFIER,CODEREF.
107 if (exists $hash{'Forker'}) {
108 $hash{'Identifier'} .= "-" if ($hash{'Forker'} eq "NULL");
110 if (exists $hash{'ArrayArgs'}) {
111 &Forker($hash{'Identifier'}, sub { \&{ $hash{'CODEREF'} }(@args) } );
113 &Forker($hash{'Identifier'}, sub { \&{ $hash{'CODEREF'} }($flatarg) } );
117 if (exists $hash{'Module'}) {
118 &loadMyModule($myModules{ $hash{'Module'} });
121 # check if CODEREF exists.
122 if (!defined &{ $hash{'CODEREF'} }) {
123 &WARN("coderef $hash{'CODEREF'} don't exist.");
125 &msg($who, "coderef does not exist for $ident.");
131 if (exists $hash{'ArrayArgs'}) {
132 &{ $hash{'CODEREF'} }(@args);
134 &{ $hash{'CODEREF'} }($flatarg);
139 if (exists $hash{'Cmdstats'}) {
140 $cmdstats{ $hash{'Cmdstats'} }++;
143 &VERB("hooks: End of command.",2);
153 ### START ADDING HOOKS.
155 &addCmdHook("extra", 'd?bugs', ('CODEREF' => 'DBugs::Parse',
156 'Forker' => 1, 'Identifier' => 'debianExtra',
157 'Cmdstats' => 'Debian Bugs') );
158 &addCmdHook("extra", 'dauthor', ('CODEREF' => 'Debian::searchAuthor',
159 'Forker' => 1, 'Identifier' => 'debian',
160 'Cmdstats' => 'Debian Author Search', 'Help' => "dauthor" ) );
161 &addCmdHook("extra", '(d|search)desc', ('CODEREF' => 'Debian::searchDescFE',
162 'Forker' => 1, 'Identifier' => 'debian',
163 'Cmdstats' => 'Debian Desc Search', 'Help' => "ddesc" ) );
164 &addCmdHook("extra", 'dnew', ('CODEREF' => 'DebianNew',
165 'Identifier' => 'debian' ) );
166 &addCmdHook("extra", 'dincoming', ('CODEREF' => 'Debian::generateIncoming',
167 'Forker' => 1, 'Identifier' => 'debian' ) );
168 &addCmdHook("extra", 'dstats', ('CODEREF' => 'Debian::infoStats',
169 'Forker' => 1, 'Identifier' => 'debian',
170 'Cmdstats' => 'Debian Statistics' ) );
171 &addCmdHook("extra", 'd?contents', ('CODEREF' => 'Debian::searchContents',
172 'Forker' => 1, 'Identifier' => 'debian',
173 'Cmdstats' => 'Debian Contents Search', 'Help' => "contents" ) );
174 &addCmdHook("extra", 'd?find', ('CODEREF' => 'Debian::DebianFind',
175 'Forker' => 1, 'Identifier' => 'debian',
176 'Cmdstats' => 'Debian Search', 'Help' => "find" ) );
177 &addCmdHook("extra", 'insult', ('CODEREF' => 'Insult::Insult',
178 'Forker' => 1, 'Identifier' => 'insult', 'Help' => "insult" ) );
179 &addCmdHook("extra", 'kernel', ('CODEREF' => 'Kernel::Kernel',
180 'Forker' => 1, 'Identifier' => 'kernel',
181 'Cmdstats' => 'Kernel', 'NoArgs' => 1) );
182 &addCmdHook("extra", 'listauth', ('CODEREF' => 'CmdListAuth',
183 'Identifier' => 'search', Module => 'factoids',
184 'Help' => 'listauth') );
185 &addCmdHook("extra", 'quote', ('CODEREF' => 'Quote::Quote',
186 'Forker' => 1, 'Identifier' => 'quote',
187 'Help' => 'quote', 'Cmdstats' => 'Quote') );
188 &addCmdHook("extra", 'countdown', ('CODEREF' => 'Countdown',
189 'Module' => 'countdown', 'Identifier' => 'countdown',
190 'Cmdstats' => 'Countdown') );
191 &addCmdHook("extra", 'lart', ('CODEREF' => 'lart',
192 'Identifier' => 'lart', 'Help' => 'lart') );
193 &addCmdHook("extra", 'convert', ('CODEREF' => 'convert',
194 'Forker' => 1, 'Identifier' => 'units',
195 'Help' => 'convert') );
196 &addCmdHook("extra", '(cookie|random)', ('CODEREF' => 'cookie',
197 'Forker' => 1, 'Identifier' => 'factoids') );
198 &addCmdHook("extra", 'u(ser)?info', ('CODEREF' => 'userinfo',
199 'Identifier' => 'userinfo', 'Help' => 'userinfo',
200 'Module' => 'userinfo') );
201 &addCmdHook("extra", 'rootWarn', ('CODEREF' => 'CmdrootWarn',
202 'Identifier' => 'rootWarn', 'Module' => 'rootwarn') );
203 &addCmdHook("extra", 'seen', ('CODEREF' => 'seen', 'Identifier' =>
205 &addCmdHook("extra", 'dict', ('CODEREF' => 'Dict::Dict',
206 'Identifier' => 'dict', 'Help' => 'dict',
207 'Forker' => 1, 'Cmdstats' => 'Dict') );
208 &addCmdHook("extra", 'slashdot', ('CODEREF' => 'Slashdot::Slashdot',
209 'Identifier' => 'slashdot', 'Forker' => 1,
210 'Cmdstats' => 'Slashdot') );
211 &addCmdHook("extra", 'uptime', ('CODEREF' => 'uptime', 'Identifier' => 'uptime',
212 'Cmdstats' => 'Uptime') );
213 &addCmdHook("extra", 'nullski', ('CODEREF' => 'nullski', ) );
214 &addCmdHook("extra", '(fm|freshmeat)', ('CODEREF' => 'Freshmeat::Freshmeat',
215 'Identifier' => 'freshmeat', 'Cmdstats' => 'Freshmeat',
216 'Forker' => 1, 'Help' => 'freshmeat') );
217 &addCmdHook("extra", 'verstats', ('CODEREF' => 'do_verstats' ) );
220 ### END OF ADDING HOOKS.
222 &status("CMD: loaded ".scalar(keys %hooks_extra)." EXTRA command hooks.");
225 if (!defined $message) {
226 &WARN("Modules: message is undefined. should never happen.");
230 # babel bot: Jonathan Feinberg++
233 (?:babel(?:fish)?|x|xlate|translate)
235 (to|from) # direction of translation (through)
237 ($babel_lang_regex)\w* # which language?
239 (.+) # The phrase to be translated
241 return unless (&hasParam("babelfish"));
243 &Forker("babelfish", sub { &babel::babelfish(lc $1, lc $2, $3); } );
245 $cmdstats{'BabelFish'}++;
249 my $debiancmd = 'conflicts?|depends?|desc|file|info|provides?';
250 $debiancmd .= '|recommends?|suggests?|maint|maintainer';
252 if ($message =~ /^($debiancmd)(\s+(.*))?$/i) {
253 return unless (&hasParam("debian"));
256 if (defined $package) {
257 &Forker("debian", sub { &Debian::infoPackages($1, $package); } );
265 # google searching. Simon++
266 if ($message =~ /^(?:search\s+)?(\S+)\s+for\s+['"]?(.*?)["']?\s*\?*$/i) {
267 return unless (&hasParam("wwwsearch"));
269 &Forker("wwwsearch", sub { &W3Search::W3Search($1,$2); } );
271 $cmdstats{'WWWSearch'}++;
275 # text counters. (eg: hehstats)
277 $itc = &getChanConf("ircTextCounters");
278 $itc = &findChanConf("ircTextCounters") unless ($itc);
280 $itc =~ s/([^\w\s])/\\$1/g;
281 my $z = join '|', split ' ', $itc;
283 if ($message =~ /^_stats(\s+(\S+))$/i) {
288 if ($message =~ /^($z)stats(\s+(\S+))?$/i) {
292 # even more uglier with channel/time arguments.
294 # my $c = $chan || "PRIVATE";
295 my $where = "type=".&dbQuote($type);
296 $where .= " AND channel=".&dbQuote($c) if (defined $c);
297 &DEBUG("not using chan arg") if (!defined $c);
298 my $sum = (&dbRawReturn("SELECT SUM(counter) FROM stats"
299 ." WHERE ".$where ))[0];
301 if (!defined $arg or $arg =~ /^\s*$/) {
302 # this is way fucking ugly.
304 my %hash = &dbGetCol("stats", "nick,counter",
305 $where." ORDER BY counter DESC LIMIT 3", 1);
309 # unfortunately we have to sort it again!
310 # todo: make dbGetCol return hash and array? too much effort.
312 foreach $i (sort { $b <=> $a } keys %hash) {
313 foreach (keys %{ $hash{$i} }) {
314 my $p = sprintf("%.01f", 100*$i/$sum);
316 push(@top, "\002$_\002 -- $i ($p%)");
320 &DEBUG("*stats: tp => $tp");
322 $topstr = ". Top ".scalar(@top).": ".join(', ', @top);
326 &pSReply("total count of \037$type\037 on \002$c\002: $sum$topstr");
328 &pSReply("zero counter for \037$type\037.");
331 my $x = (&dbRawReturn("SELECT SUM(counter) FROM stats".
332 " WHERE $where AND nick=".&dbQuote($arg) ))[0];
334 if (!defined $x) { # !defined.
335 &pSReply("$arg has not said $type yet.");
340 my @array = &dbGet("stats", "nick",
341 $where." ORDER BY counter", 1);
344 for($i=0; $i<scalar @array; $i++) {
345 next unless ($array[0] =~ /^\Q$who\E$/);
351 my $total = scalar(@array);
353 if ($total and $good) {
354 my $pct = sprintf("%.01f", 100*(1+$total-$i)/$total);
355 $xtra = ", ranked $i\002/\002$total (percentile: \002$pct\002 %)";
358 my $pct1 = sprintf("%.01f", 100*$x/$sum);
359 &pSReply("\002$arg\002 has said \037$type\037 \002$x\002 times (\002$pct1\002 %)$xtra");
366 &DEBUG("regex failed: $@");
371 # list{keys|values}. xk++. Idea taken from #linuxwarez@EFNET
372 if ($message =~ /^list(\S+)(\s+(.*))?$/i) {
373 return unless (&hasParam("search"));
378 $thiscmd =~ s/^vals$/values/;
379 # $args =~ s/\s+$//g;
380 return if ($thiscmd ne "keys" && $thiscmd ne "values");
383 if (!defined $args or $args =~ /^\s*$/) {
384 &help("list". $thiscmd);
388 # suggested by asuffield and \broken.
389 if ($args =~ /^["']/ and $args =~ /["']$/) {
390 &DEBUG("list*: removed quotes.");
391 $args =~ s/^["']|["']$//g;
394 if (length $args == 1) {
395 &msg($who,"search string is too short.");
399 &Forker("search", sub { &Search::Search($thiscmd, $args); } );
401 $cmdstats{'Factoid Search'}++;
405 # Nickometer. Adam Spiers++
406 if ($message =~ /^(?:lame|nick)ometer(?: for)? (\S+)/i) {
407 return unless (&hasParam("nickometer"));
409 my $term = (lc $1 eq 'me') ? $who : $1;
411 &loadMyModule($myModules{'nickometer'});
413 if ($term =~ /^$mask{chan}$/) {
414 &status("Doing nickometer for chan $term.");
416 if (!&validChan($term)) {
417 &msg($who, "error: channel is invalid.");
423 foreach (keys %{ $channels{lc $term}{''} }) {
426 &WARN("nickometer: nick in chan $term undefined?");
430 my $value = &nickometer($str);
431 $nickometer{$value}{$str} = 1;
435 ### TODO: compact with map?
437 foreach (sort {$b <=> $a} keys %nickometer) {
438 my $str = join(", ", sort keys %{ $nickometer{$_} });
439 push(@list, "$str ($_%)");
442 &pSReply( &formListReply(0, "Nickometer list for $term ", @list) );
448 my $percentage = &nickometer($term);
450 if ($percentage =~ /NaN/) {
451 $percentage = "off the scale";
453 $percentage = sprintf("%0.4f", $percentage);
454 $percentage =~ s/\.?0+$//;
458 if ($msgType eq 'public') {
459 &say("'$term' is $percentage lame, $who");
461 &msg($who, "the 'lame nick-o-meter' reading for $term is $percentage, $who");
467 # Topic management. xk++
468 # may want to add a userflags for topic. -xk
469 if ($message =~ /^topic(\s+(.*))?$/i) {
470 return unless (&hasParam("topic"));
472 my $chan = $talkchannel;
473 my @args = split / /, $2 || "";
476 &msg($who,"Try 'help topic'");
480 $chan = lc(shift @args) if ($msgType eq 'private');
481 my $thiscmd = shift @args;
484 if ($msgType eq 'public' && $thiscmd =~ /^#/) {
485 &msg($who, "error: channel argument is not required.");
486 &msg($who, "\002Usage\002: topic <CMD>");
490 # topic over private:
491 if ($msgType eq 'private' && $chan !~ /^#/) {
492 &msg($who, "error: channel argument is required.");
493 &msg($who, "\002Usage\002: topic #channel <CMD>");
497 if (&validChan($chan) == 0) {
498 &msg($who,"error: invalid channel \002$chan\002");
502 # for semi-outsiders.
503 if (!&IsNickInChan($who,$chan)) {
504 &msg($who, "Failed. You ($who) are not in $chan, hey?");
509 &loadMyModule($myModules{'topic'});
510 &Topic($chan, $thiscmd, join(' ', @args));
511 $cmdstats{'Topic'}++;
516 if ($message =~ /^wingate$/i) {
517 return unless (&hasParam("wingate"));
519 my $reply = "Wingate statistics: scanned \002"
520 .scalar(keys %wingate)."\002 hosts";
521 my $queue = scalar(keys %wingateToDo);
523 $reply .= ". I have \002$queue\002 hosts in the queue";
524 $reply .= ". Started the scan ".&Time2String(time() - $wingaterun)." ago";
527 &performStrictReply("$reply.");
532 # do nothing and let the other routines have a go
540 if (!defined $query) {
542 &msg($who, "I have \002".&countKeys("freshmeat")."\002 entries.");
546 &Freshmeat::Freshmeat($query);
552 &msg($who, "- Uptime for $ident -");
553 &msg($who, "Now: ". &Time2String(&uptimeNow()) ." running $bot_version");
555 foreach (&uptimeGetInfo()) {
557 my $time = &Time2String($1);
560 &msg($who, "$count: $time $2");
567 my($person) = lc shift;
570 if (!defined $person or $person =~ /^$/) {
573 my $i = &countKeys("seen");
574 &msg($who,"there ". &fixPlural("is",$i) ." \002$i\002 ".
575 "seen ". &fixPlural("entry",$i) ." that I know of.");
582 &seenFlush(); # very evil hack. oh well, better safe than sorry.
584 ### TODO: Support &dbGetColInfo(); like in &FactInfo();
585 my $select = "nick,time,channel,host,message";
586 if ($person eq "random") {
587 @seen = &randKey("seen", $select);
589 @seen = &dbGet("seen", $select, "nick=".&dbQuote($person) );
592 if (scalar @seen < 2) {
594 &DEBUG("seen: _ => '$_'.");
596 &performReply("i haven't seen '$person'");
602 ### TODO: multi channel support. may require &IsNick() to return
603 ### all channels or something.
604 my @chans = &getNickInChans($seen[0]);
606 $reply = "$seen[0] is currently on";
610 next unless (exists $userstats{lc $seen[0]}{'Join'});
611 $reply .= " (".&Time2String(time() - $userstats{lc $seen[0]}{'Join'}).")";
614 if (&IsParam("seenStats")) {
616 $i = $userstats{lc $seen[0]}{'Count'};
617 $reply .= ". Has said a total of \002$i\002 messages" if (defined $i);
618 $i = $userstats{lc $seen[0]}{'Time'};
619 $reply .= ". Is idling for ".&Time2String(time() - $i) if (defined $i);
622 my $howlong = &Time2String(time() - $seen[1]);
623 $reply = "$seen[0] <$seen[3]> was last seen on IRC ".
624 "in channel $seen[2], $howlong ago, ".
625 "saying\002:\002 '$seen[4]'.";
632 # User Information Services. requested by Flugh.
634 my ($arg) = join(' ',@_);
636 if ($arg =~ /^set(\s+(.*))?$/i) {
639 &help("userinfo set");
643 &UserInfoSet(split /\s+/, $arg, 2);
644 } elsif ($arg =~ /^unset(\s+(.*))?$/i) {
647 &help("userinfo unset");
651 &UserInfoSet($arg, "");
657 # cookie (random). xk++
661 # lets find that secret cookie.
662 my $target = ($msgType ne 'public') ? $who : $talkchannel;
663 my $cookiemsg = &getRandom(keys %{ $lang{'cookie'} });
666 ### WILL CHEW TONS OF MEM.
667 ### TODO: convert this to a Forker function!
669 my @list = &searchTable("factoids", "factoid_key", "factoid_value", $arg);
670 $key = &getRandom(@list);
671 $val = &getFactInfo("factoids", $key, "factoid_value");
673 ($key,$value) = &randKey("factoids","factoid_key,factoid_value");
677 s/##KEY/\002$key\002/;
680 s/\$who/$who/; # cheap fix.
681 s/(\S+)?\s*<\S+>/$1 /;
685 if ($cookiemsg =~ s/^ACTION //i) {
686 &action($target, $cookiemsg);
688 &msg($target, $cookiemsg);
693 my $arg = join(' ',@_);
694 my ($from,$to) = ('','');
696 ($from,$to) = ($1,$2) if ($arg =~ /^(.*?) to (.*)$/i);
697 ($from,$to) = ($2,$1) if ($arg =~ /^(.*?) from (.*)$/i);
699 if (!$to or !$from) {
700 &msg($who, "Invalid format!");
705 &Units::convertUnits($from, $to);
711 my ($target) = &fixString($_[0]);
713 my $chan = $talkchannel;
715 if ($msgType eq 'private') {
716 if ($target =~ /^($mask{chan})\s+(.*)$/) {
721 &msg($who, "error: invalid format or missing arguments.");
727 my $line = &getRandomLineFromFile($bot_data_dir. "/blootbot.lart");
729 if ($target =~ /^(me|you|itself|\Q$ident\E)$/i) {
730 $line =~ s/WHO/$who/g;
732 $line =~ s/WHO/$target/g;
734 $line .= ", courtesy of $who" if ($extra);
736 &action($chan, $line);
738 &status("lart: error reading file?");
743 my $idx = "debian/Packages-woody.idx";
748 $error++ unless ( -e $idx);
749 $error++ unless ( -e "$idx-old");
752 $error = "no woody/woody-old index file found.";
753 &ERROR("Debian: $error");
759 open(IDX2, "$idx-old");
773 next if (exists $pkg{$_});
779 &::performStrictReply( &::formListReply(0, "New debian packages:", @new) );
785 if (!defined $chan) {
790 if (!&validChan($chan)) {
791 &msg($who, "chan $chan is invalid.");
795 if (scalar @vernick > scalar(keys %{ $channels{lc $chan}{''} })/4) {
796 &msg($who, "verstats already in progress for someone else.");
800 &msg($who, "Sending CTCP VERSION...");
801 $conn->ctcp("VERSION", $chan);
802 $cache{verstats}{chan} = $chan;
803 $cache{verstats}{who} = $who;
804 $cache{verstats}{msgType} = $msgType;
806 $conn->schedule(60, sub {
808 my $c = lc $cache{verstats}{chan};
809 my $total = keys %{ $channels{$c}{''} };
811 $who = $cache{verstats}{who};
812 $msgType = $cache{verstats}{msgType};
813 delete $cache{verstats}; # sufficient?
815 foreach (keys %ver) {
816 $vtotal += scalar keys %{ $ver{$_} };
820 my $unknown = $total - $vtotal;
821 my $perc = sprintf("%.1f", $unknown * 100 / $total);
823 $sorted{$perc}{"unknown/cloak"} = "$unknown ($perc%)";
825 foreach (keys %ver) {
826 my $count = scalar keys %{ $ver{$_} };
827 $perc = sprintf("%.01f", $count * 100 / $total);
828 $perc =~ s/.0$//; # lame compression.
830 $sorted{$perc}{$_} = "$count ($perc%)";
833 ### can be compressed to a map?
835 foreach ( sort { $b <=> $a } keys %sorted ) {
837 foreach (sort keys %{ $sorted{$perc} }) {
838 push(@list, "$_ - $sorted{$perc}{$_}");
842 &pSReply( &formListReply(0, "IRC Client versions for $c ", @list) );
844 # clean up not-needed data structures.
855 # even more uglier with channel/time arguments.
857 # my $c = $chan || "PRIVATE";
858 my $where = "channel=".&dbQuote($c) if (defined $c);
859 &DEBUG("not using chan arg") if (!defined $c);
860 my $sum = (&dbRawReturn("SELECT SUM(counter) FROM stats"
861 ." WHERE ".$where ))[0];
863 if (!defined $arg or $arg =~ /^\s*$/) {
864 # this is way fucking ugly.
865 &DEBUG("_stats: !arg");
867 my %hash = &dbGetCol("stats", "nick,counter",
868 $where." ORDER BY counter DESC LIMIT 3", 1);
872 # unfortunately we have to sort it again!
873 # todo: make dbGetCol return hash and array? too much effort.
875 foreach $i (sort { $b <=> $a } keys %hash) {
876 foreach (keys %{ $hash{$i} }) {
877 my $p = sprintf("%.01f", 100*$i/$sum);
879 push(@top, "\002$_\002 -- $i ($p%)");
884 &DEBUG("*stats: tp => $tp");
886 $topstr = ". Top ".scalar(@top).": ".join(', ', @top);
890 &pSReply("total count of \037$type\037 on \002$c\002: $sum$topstr");
892 &pSReply("zero counter for \037$type\037.");
895 my %hash = &dbGetCol("stats", "type,counter",
896 "$where AND nick=".&dbQuote($arg) );
898 foreach (keys %hash) {
899 &DEBUG("_stats: hash{$_} => $hash{$_}");
901 my @array = &dbGet("stats", "nick",
902 $where." ORDER BY counter", 1);
905 for($i=0; $i<scalar @array; $i++) {
906 next unless ($array[0] =~ /^\Q$who\E$/);
912 my $total = scalar(@array);
913 &DEBUG(" i => $i, good => $good, total => $total");
918 if (!defined $x) { # !defined.
919 &pSReply("$arg has not said $type yet.");
924 if ($total and $good) {
925 my $pct = sprintf("%.01f", 100*(1+$total-$i)/$total);
926 $xtra = ", ranked $i\002/\002$total (percentile: \002$pct\002 %)";
929 my $pct1 = sprintf("%.01f", 100*$x/$sum);
930 &pSReply("\002$arg\002 has said \037$type\037 \002$x\002 times (\002$pct1\002 %)$xtra");
934 sub nullski { my ($arg) = @_; return unless (defined $arg);
935 foreach (`$arg`) { &msg($who,$_); } }