]> git.donarmstrong.com Git - infobot.git/blobdiff - src/UserExtra.pl
- try and not kill ourself :)
[infobot.git] / src / UserExtra.pl
index d468fff6eb3e7501c31fbe6cf98bb9f069062b7d..aaf37c488f42ec5a6dbae2fa2311d659474b4681 100644 (file)
@@ -63,9 +63,12 @@ sub chaninfo {
                &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) {
@@ -81,7 +84,7 @@ sub chaninfo {
                push(@nicks, $_);
            }
        }
-       &DEBUG("nicks => '".scalar(@nicks)."'...");
+
        if (scalar @nicks != $uucount) {
            &DEBUG("nicks != uucount...");
        }
@@ -221,8 +224,8 @@ sub factstats {
 
 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");
@@ -803,11 +806,11 @@ sub userCommands {
        "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'}).
@@ -817,10 +820,12 @@ sub userCommands {
          "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) {
@@ -837,23 +842,31 @@ if (0) {
 
     # wantNick. xk++
     if ($message =~ /^wantNick$/i) {
+       # 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 :)
+       if ($param{'ircNick'} ne $ident and $param{'nickServ_pass'}) {
+           &status("someone is using our nick; KILLing");
+           &msg("NickServ", "GHOST $param{'ircNick'} $param{'nickServ_pass'}");
+           return;
+       }
+
+       &nick( $param{'ircNick'} );
+
        return;
     }