]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Modules/RootWarn.pl
- irctextcounters: add percentage to top3
[infobot.git] / src / Modules / RootWarn.pl
index 185130f31718077a5943afe73a2f2d123c70fb04..835c605d47493911c2c6bd7d14aaa7aa915f5573 100644 (file)
@@ -9,15 +9,16 @@
 
 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.
-       if ($warnmode =~ /aggressive/i) {
-           &status(">>> Detected root user; notifying nick and channel.");
-           rawout("PRIVMSG $chan :R".("O" x int(rand 80 + 2))."T has landed!");
+       if (defined $warnmode and $warnmode =~ /quiet/i) {
+           &status("rootwarn: Detected root user; notifying user");
        } else {
-           &status(">>> Detected root user; notifying user");
+           &status("rootwarn: Detected root user; notifying nick and channel.");
+           rawout("PRIVMSG $chan :ROO".("O" x int(rand 68))."T has landed!");
        }
 
        if ($_ = &getFactoid("root")) {
@@ -35,7 +36,9 @@ sub rootWarn {
        }
 
     } else {                   # >3rd time occurrance.
-       if ($warnmode =~ /aggressive/i) {
+
+       # disable this for the time being.
+       if (0 and $warnmode =~ /aggressive/i) {
            if ($channels{$chan}{'o'}{$ident}) {
                &status("RootWarn: $nick... sigh... bye bye.");
                rawout("MODE $chan +b *!root\@$host");  # ban
@@ -46,12 +49,13 @@ sub rootWarn {
 
     $attempt++;
     ### TODO: OPTIMIZE THIS.
-    if (1) {   # old
+    # 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.
+    } 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);
@@ -62,6 +66,7 @@ sub rootWarn {
 }
 
 # Extras function.
+# todo: support arguments to get info on a particular nick?
 sub CmdrootWarn {
     my $reply;
     my $count = &countKeys("rootwarn");
@@ -72,7 +77,7 @@ sub CmdrootWarn {
     }
 
     # reply #1.
-    $reply = "there ".&fixPlural("has",$count) ." been \002$i\002 ".
+    $reply = "there ".&fixPlural("has",$count) ." been \002$count\002 ".
                &fixPlural("rooter",$count) ." warned about root.";
 
     if ($param{'DBType'} !~ /^mysql$/i) {