]> git.donarmstrong.com Git - infobot.git/blobdiff - src/UserExtra.pl
- one more last try.
[infobot.git] / src / UserExtra.pl
index e38fa950b04a0495ff5fdadd765123d54564d028..d967932054e65630971ea1071e70f3bfbc3f893d 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'}).
@@ -819,10 +822,9 @@ sub userCommands {
 
        return;
 
-       # todo: use dbGetColNiceHash().
        my %hash = &sqlSelectColHash("stats", "nick,counter",
                { type => "cmdstats" }, 1);
-# does ORDER matter when used with a hash?
+# ORDER won't be retained in a hash
 #                      " ORDER BY counter DESC", 1);
 
 if (0) {
@@ -839,22 +841,41 @@ if (0) {
     }
 
     # 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;