#
# RootWarn.pl: Warn people about usage of root on IRC.
-# Author: xk <xk@leguin.openprojects.net>
-# Version: v0.2c (19991125)
+# Author: dms
+# Version: v0.3 (20000923)
# Created: 19991008
#
sub rootWarn {
my ($nick,$user,$host,$chan) = @_;
- my $attempt = &dbGet("rootwarn", "nick", lc($nick), "attempt") || 0;
+ my $attempt = &dbGet("rootwarn", "attempt", "nick='.lc($nick)."'") || 0;
+ my $warnmode = &getChanConf("rootWarnMode");
if ($attempt == 0) { # first timer.
- if (&IsParam("rootWarnMode") && $param{'rootWarnMode'} =~ /aggressive/i) {
+ 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!");
} else {
}
} else { # >3rd time occurrance.
- if (&IsParam("rootWarnMode")) {
- if ($param{'rootWarnMode'} =~ /aggressive/i) {
- if ($channels{$chan}{'o'}{$ident}) {
- &status("RootWarn: $nick... sigh... bye bye.");
- rawout("MODE $chan +b *!root\@$host"); # ban
- &kick($chan,$nick,"bye bye");
- }
+ if ($warnmode =~ /aggressive/i) {
+ if ($channels{$chan}{'o'}{$ident}) {
+ &status("RootWarn: $nick... sigh... bye bye.");
+ rawout("MODE $chan +b *!root\@$host"); # ban
+ &kick($chan,$nick,"bye bye");
}
}
}
my $count = &countKeys("rootwarn");
if ($count == 0) {
- return "no-one has been warned about root, woohoo";
+ &performReply("no-one has been warned about root, woohoo");
+ return;
}
# reply #1.
$reply = "there ".&fixPlural("has",$count) ." been \002$i\002 ".
&fixPlural("rooter",$count) ." warned about root.";
+ if ($param{'DBType'} !~ /^mysql$/i) {
+ &FIXME("rootwarn does not yet support non-mysql.");
+ return;
+ }
+
# reply #2.
$found = 0;
my $query = "SELECT attempt FROM rootwarn WHERE attempt > 2";
" done it at least 3 times.";
}
- return $reply;
+ &performStrictReply($reply);
}
1;