]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Modules/RootWarn.pl
- bot stats: "blah has blah... is ranked xx/yy (zz percentile)"
[infobot.git] / src / Modules / RootWarn.pl
index 1a3d6c6df8536da241856226e82ce52c6c003d06..5c2cf62d9680e4ff6196698eeba442010dcc55ab 100644 (file)
@@ -9,7 +9,8 @@
 
 sub rootWarn {
     my ($nick,$user,$host,$chan) = @_;
-    my $attempt = &dbGet("rootwarn", "attempt", "nick='".lc($nick)."'") || 0;
+    my $n      = lc $nick;
+    my $attempt = &dbGet("rootwarn", "attempt", "nick=".&dbQuote($n) ) || 0;
     my $warnmode       = &getChanConf("rootWarnMode");
 
     if ($attempt == 0) {       # first timer.
@@ -17,7 +18,7 @@ sub rootWarn {
            &status("rootwarn: Detected root user; notifying user");
        } else {
            &status("rootwarn: Detected root user; notifying nick and channel.");
-           rawout("PRIVMSG $chan :R".("O" x int(rand 70 + 2))."T has landed!");
+           rawout("PRIVMSG $chan :ROO".("O" x int(rand 68))."T has landed!");
        }
 
        if ($_ = &getFactoid("root")) {
@@ -49,17 +50,14 @@ sub rootWarn {
     $attempt++;
     ### TODO: OPTIMIZE THIS.
     # ok... don't record the attempt if nick==root.
-    if (1 and $nick ne "root") {       # old
-       &dbSet("rootwarn", { nick => lc($nick) }, { attempt => $attempt });
-       &dbSet("rootwarn", { nick => lc($nick) }, { time => time() });
-       &dbSet("rootwarn", { nick => lc($nick) }, { host => $user."\@".$host });
-       &dbSet("rootwarn", { nick => lc($nick) }, { channel => $chan });
-    } else {   # new. replace. TODO
-       &dbSet("rootwarn", "nick", lc($nick), "attempt", $attempt);
-       &dbSet("rootwarn", "nick", lc($nick), "time", time());
-       &dbSet("rootwarn", "nick", lc($nick), "host", $user."\@".$host);
-       &dbSet("rootwarn", "nick", lc($nick), "channel", $chan);
-    }
+    return if ($nick eq "root");
+
+    &dbSet("rootwarn", { nick => lc($nick) }, {
+       attempt => $attempt,
+       time    => time(),
+       host    => $user."\@".$host,
+       channel => $chan,
+    } );
 
     return;
 }
@@ -79,8 +77,8 @@ sub CmdrootWarn {
     $reply = "there ".&fixPlural("has",$count) ." been \002$count\002 ".
                &fixPlural("rooter",$count) ." warned about root.";
 
-    if ($param{'DBType'} !~ /^mysql$/i) {
-       &FIXME("rootwarn does not yet support non-mysql.");
+    if ($param{'DBType'} !~ /^(pg|my)sql$/i) {
+       &FIXME("rootwarn does not yet support non-{my,pg}sql.");
        return;
     }