]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Modules/RootWarn.pl
standard TODO: and FIXME:
[infobot.git] / src / Modules / RootWarn.pl
index cb3d967499637c15df3185a86e56ddd85b3cfe13..ae44676965e352a819a7de17d912e162193c0827 100644 (file)
@@ -13,7 +13,7 @@ use vars qw($dbh $found $ident);
 sub rootWarn {
     my ($nick,$user,$host,$chan) = @_;
     my $n      = lc $nick;
-    my $attempt = &dbGet("rootwarn", "attempt", "nick=".&dbQuote($n) ) || 0;
+    my $attempt = &sqlSelect("rootwarn", "attempt", { nick => $n } ) || 0;
     my $warnmode       = &getChanConf("rootWarnMode");
 
     if ($attempt == 0) {       # first timer.
@@ -21,25 +21,24 @@ sub rootWarn {
            &status("rootwarn: Detected root user; notifying user");
        } else {
            &status("rootwarn: Detected root user; notifying nick and channel.");
-           &msg($chan, "ROO".("O" x int(rand 68))."T has landed!");
+           &msg($chan, "ROO".("O" x int(rand 8))."T has landed!");
        }
 
        if ($_ = &getFactoid("root")) {
-           &msg($nick, "root is $_");
+           &msg($nick, "rootwarn: $attempt : $_");
        } else {
            &status("root needs to be defined in database.");
        }
 
     } elsif ($attempt < 2) {   # 2nd/3rd time occurrance.
-       &status("RootWarn: not first time root user; msg'ing $nick.");
        if ($_ = &getFactoid("root again")) {
-           &msg($nick, $_);
+           &status("RootWarn: not first time root user; msg'ing $nick.");
+           &msg($nick, "rootwarn: $attempt : $_");
        } else {
            &status("root again needs to be defined in database.");
        }
 
     } else {                   # >3rd time occurrance.
-
        # disable this for the time being.
        if (0 and $warnmode =~ /aggressive/i) {
            if ($channels{$chan}{'o'}{$ident}) {
@@ -47,6 +46,11 @@ sub rootWarn {
                rawout("MODE $chan +b *!root\@$host");  # ban
                &kick($chan,$nick,"bye bye");
            }
+       } elsif ($_ = &getFactoid("root again")) {
+           &status("RootWarn: $attempt times; msg'ing $nick.");
+           &msg($nick, "rootwarn: $attempt : $_");
+       } else {
+           &status("root again needs to be defined in database.");
        }
     }
 
@@ -55,7 +59,7 @@ sub rootWarn {
     # ok... don't record the attempt if nick==root.
     return if ($nick eq "root");
 
-    &dbSet("rootwarn", { nick => lc($nick) }, {
+    &sqlSet("rootwarn", { nick => lc($nick) }, {
        attempt => $attempt,
        time    => time(),
        host    => $user."\@".$host,
@@ -66,7 +70,7 @@ sub rootWarn {
 }
 
 # Extras function.
-# todo: support arguments to get info on a particular nick?
+# TODO: support arguments to get info on a particular nick?
 sub CmdrootWarn {
     my $reply;
     my $count = &countKeys("rootwarn");