&ircCheck();
next;
}
- push(@array, "$_ (".scalar(keys %{ $channels{$_}{''} }).")");
+ next if (/^_default$/);
+
+ my $str = sprintf("%s (%d)", $_, scalar(keys %{ $channels{$_}{''} }));
+ push(@array, $str);
}
- &pSReply($reply.": ".join(' ', @array));
+ &pSReply($reply.": ".join(', ', @array));
### total user count.
foreach $chan (keys %channels) {
push(@nicks, $_);
}
}
- &DEBUG("nicks => '".scalar(@nicks)."'...");
+
if (scalar @nicks != $uucount) {
&DEBUG("nicks != uucount...");
}
sub karma {
my $target = lc( shift || $who );
- my $karma = &dbGet("stats", "counter", "nick=".
- &dbQuote($target)." AND type='karma'") || 0;
+ my $karma = &sqlSelect("stats", "counter",
+ { nick => $target, type => "karma" }) || 0;
if ($karma != 0) {
&pSReply("$target has karma of $karma");
if ($message =~ /^statu?s$/i) {
my $startString = scalar(gmtime $^T);
my $upString = &Time2String(time() - $^T);
- my $count = &countKeys("factoids");
+ my $factoids = &countKeys("factoids");
$count{'Commands'} = 0;
foreach (keys %cmdstats) {
"Since $startString, there have been".
" \002$count{'Update'}\002 ".
&fixPlural("modification", $count{'Update'}).
- " and \002$count{'Question'}\002 ".
+ ", \002$count{'Question'}\002 ".
&fixPlural("question",$count{'Question'}).
- " and \002$count{'Dunno'}\002 ".
+ ", \002$count{'Dunno'}\002 ".
&fixPlural("dunno",$count{'Dunno'}).
- " and \002$count{'Moron'}\002 ".
+ ", \002$count{'Moron'}\002 ".
&fixPlural("moron",$count{'Moron'}).
" and \002$count{'Commands'}\002 ".
&fixPlural("command",$count{'Commands'}).
". I have been awake for $upString this session, and ".
- "currently reference \002$count\002 factoids. ".
+ "currently reference \002$factoids\002 factoids. ".
"I'm using about \002$memusage\002 ".
"kB of memory."
);
- # todo: use dbGetColNiceHash().
- my %hash = &dbGetCol("stats", "nick,counter", "type='cmdstats'".
-# " ORDER BY counter DESC LIMIT 3", 1);
- " ORDER BY counter DESC", 1);
+ 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) {
}
# wantNick. xk++
- if ($message =~ /^wantNick$/i) {
+ if ($message =~ /^wantNick(\+)?$/i) {
+ my ($force) = ($1) ? 1 : 0;
+ $force = 0 unless (&IsFlag("n"));
+
+ # cannot trust Net::IRC's nick()
if ($param{'ircNick'} eq $ident) {
&msg($who, "I hope you're right. I'll try anyway.");
+ &DEBUG("ircNick => $param{'ircNick'}");
+ &DEBUG("ident => $ident");
}
- &DEBUG("ircNick => $param{'ircNick'}");
- &DEBUG("ident => $ident");
- if (! &IsNickInAnyChan( $param{ircNick} ) ) {
+ # fallback check, I guess. needed?
+ 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.. I shouldn't do it (BUG?) but doing it anyway!");
- &DEBUG("wN: nick is somewhere... should try later.");
- &nick($param{'ircNick'});
+ &nick($param{ 'ircNick' });
+ return;
+ }
+
+ # idea from dondelecarlo :)
+ # todo: use cache{nickserv}
+ if ($param{'nickServ_pass'}) {
+ return if ($param{'ircNick'} eq $ident or $force == 0);
+
+ &status("someone is using our nick; GHOSTing");
+ &msg($who, "using GHOST on $param{'ircNick'}.");
+ &msg("NickServ", "GHOST $param{'ircNick'} $param{'nickServ_pass'}");
+
+ $conn->schedule(5, sub {
+ &status("going to change nick after GHOST.");
+ &nick( $param{'ircNick'} );
+ } );
+
+ return;
}
return;