my $mode;
if ($chan eq "") { # all channels.
- my $count = 0;
my $i = keys %channels;
my $reply = "i am on \002$i\002 ".&fixPlural("channel",$i);
+ my $tucount = 0; # total user count.
+ my $uucount = 0; # unique user count.
my @array;
### line 1.
}
&pSReply($reply.": ".join(' ', @array));
- ### line 2.
+ ### total user count.
foreach $chan (keys %channels) {
- # crappy debugging...
- # TODO: use $mask{chan} instead?
- if ($chan =~ / /) {
- &ERROR("bad channel: chan => '$chan'.");
+ $tucount += scalar(keys %{$channels{$chan}{''}});
+ }
+
+ ### unique user count.
+ my @nicks;
+ foreach $chan (keys %channels) {
+ foreach (keys %{ $channels{$chan}{''} }) {
+ next if (grep /^\Q$_\E$/, @nicks);
+ $uucount++;
+ push(@nicks, $_);
}
- $count += scalar(keys %{$channels{$chan}{''}});
}
+
+ my $chans = scalar(keys %channels);
&pSReply(
- "i've cached \002$count\002 ".&fixPlural("user",$count).
- " distributed over \002".scalar(keys %channels)."\002 ".
- &fixPlural("channel",scalar(keys %channels))."."
+ "i've cached \002$tucount\002 ". &fixPlural("user",$tucount).
+ ", \002$uucount\002 unique ". &fixPlural("user",$uucount).
+ ", distributed over \002$chans\002 ".
+ &fixPlural("channel", $chans)."."
);
return;
$target = $talkchannel if ($target =~ /^us$/i);
$target = $who if ($target =~ /^(me|myself)$/i);
- &status("target: $target query: $query");
+ &status("tell: target = $target, query = $query");
# "intrusive".
if ($target !~ /^$mask{chan}$/ and !&IsNickInAnyChan($target)) {
return;
}
- # ...
+ my $oldwho = $who;
+ my $oldmtype = $msgType;
+ $who = $target;
my $result = &doQuestion($tell_obj);
- &DEBUG("result => $result.");
-# return if ($result eq);
+ # ^ returns '0' if nothing was found.
+ $who = $oldwho;
# no such factoid.
- if ($result eq "") {
- &msg($who, "i dunno what is '$tell_obj'.");
+ if ($result =~ /^0?$/) {
+ $who = $target;
+ $msgType = "private";
+
+ # support command redirection.
+ # recursive cmdHooks aswell :)
+ my $done = 0;
+ $done++ if &parseCmdHook("main", $tell_obj);
+ $done++ if &parseCmdHook("extra", $tell_obj);
+ $message = $tell_obj;
+ $done++ unless (&Modules());
+
+ &DEBUG("setting old values of who and msgType.");
+ $who = $oldwho;
+ $msgType = $oldmtype;
+
+ if ($done) {
+ &msg($who, "told $target about CMD '$tell_obj'");
+ } else {
+ &msg($who, "i dunno what is '$tell_obj'.");
+ }
+
return;
}
# success.
&status("tell: <$who> telling $target about $tell_obj.");
if ($who ne $target) {
- &msg($who, "told $target about $tell_obj ($result)")
- unless ($dont_tell_me);
+ if ($dont_tell_me) {
+ &msg($who, "told $target about $tell_obj.");
+ } else {
+ &msg($who, "told $target about $tell_obj ($result)");
+ }
+
$reply = "$who wants you to know: $result";
} else {
$reply = "telling yourself: $result";
sub userCommands {
# conversion: ascii.
if ($message =~ /^(asci*|chr) (\d+)$/) {
- return '' unless (&IsParam("allowConv"));
+ return unless (&IsParam("allowConv"));
- $arg = $2;
- if ($arg < 32) {
- $arg += 64;
- $result = "^".chr($arg);
- } else {
- $result = chr($2);
- }
- $result = "NULL" if ($arg == 0);
+ $arg = $2;
+ $result = chr($arg);
+ $result = "NULL" if ($arg == 0);
&performReply( sprintf("ascii %s is '%s'", $arg, $result) );
+
return;
}
# conversion: ord.
if ($message =~ /^ord (.)$/) {
- return '' unless (&IsParam("allowConv"));
+ return unless (&IsParam("allowConv"));
$arg = $1;
if (ord($arg) < 32) {
# hex.
if ($message =~ /^hex(\s+(.*))?$/i) {
+ return unless (&IsParam("allowConv"));
my $arg = $2;
if (!defined $arg) {
my @redir;
&status("Redirect '$factoid' (". ($#list) .")...");
for (@list) {
+ my $x = $_;
next if (/^\Q$factoid\E$/i);
&status(" Redirecting '$_'.");
my $was = &getFactoid($_);
+ if ($was =~ /<REPLY> see/i) {
+ &status("warn: not redirecting a redirection.");
+ next;
+ }
+
&DEBUG(" was '$was'.");
- push(@redir,$_);
- &setFactInfo($_, "factoid_value", "<REPLY> see $factoid");
+ push(@redir,$x);
+ &setFactInfo($x, "factoid_value", "<REPLY> see $factoid");
}
&status("Done.");
if ($message =~ /^ircstats$/i) {
my $count = $ircstats{'ConnectCount'};
my $format_time = &Time2String(time() - $ircstats{'ConnectTime'});
+ my $total_time = time() - $ircstats{'ConnectTime'} + $ircstats{'TotalTime'};
my $reply;
+ &DEBUG("ircstats: total_time => $total_time.");
+ &DEBUG("ircstats: offtime => $ircstats{'OffTime'}");
+
foreach (keys %ircstats) {
&DEBUG("ircstats: $_ => '$ircstats{$_}'.");
}
&msg($who, "I hope you're right. I'll try anyway.");
}
- my $str = "attempting to change nick to $param{'ircNick'}";
- &status($str);
- &msg($who, $str);
+ if (! &IsNickInAnyChan( $param{ircNick} ) ) {
+ my $str = "attempting to change nick to $param{'ircNick'}";
+ &status($str);
+ &msg($who, $str);
+ &nick($param{'ircNick'});
+ } else {
+ &msg($who, "hrm... can't do it");
+ &DEBUG("wN: nick is somewhere... should try later.");
+ }
- &nick($param{'ircNick'});
return;
}