From dc7d877b03a08d98569c86e9ebacb44cc5f98163 Mon Sep 17 00:00:00 2001 From: dms Date: Fri, 2 Feb 2001 13:09:09 +0000 Subject: [PATCH] - more fixes to new-style config, should be 99% of it. - convert IsParam() to IsChanConf() - IRC/IrcHooks.pl: minor output update - IRC/Schedulers.pl: - minor update. - make getChanConfDefault(PARAM,VALUE,CHAN) instead for convenience. - temp ignore removal checking loop fixed. git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@298 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/IRC/Irc.pl | 4 +++- src/IRC/IrcHooks.pl | 29 +++++++++++++++-------------- src/IRC/Schedulers.pl | 24 +++++++++++++++--------- src/Modules/RootWarn.pl | 15 +++++++-------- src/Modules/Wingate.pl | 7 ++++--- 5 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/IRC/Irc.pl b/src/IRC/Irc.pl index b0b6834..8d40b14 100644 --- a/src/IRC/Irc.pl +++ b/src/IRC/Irc.pl @@ -77,6 +77,8 @@ sub irc { my $resolve = inet_ntoa($packed); &status(" resolved to $resolve."); + ### warning in Sys/Hostname line 78??? + ### caused inside Net::IRC? } $irc = new Net::IRC; @@ -662,7 +664,7 @@ sub closeDCC { sub joinfloodCheck { my($who,$chan,$userhost) = @_; - return unless (&IsParam("joinfloodCheck")); + return unless (&IsChanConf("joinfloodCheck")); if (exists $netsplit{lc $who}) { # netsplit join. &DEBUG("jfC: $who was in netsnipe; not checking."); diff --git a/src/IRC/IrcHooks.pl b/src/IRC/IrcHooks.pl index b3418cd..a1ad9fb 100644 --- a/src/IRC/IrcHooks.pl +++ b/src/IRC/IrcHooks.pl @@ -139,7 +139,7 @@ sub on_endofmotd { $ircstats{'ConnectTime'} = time(); $ircstats{'ConnectCount'}++; - if (&IsParam("wingate")) { + if (&IsChanConf("wingate")) { my $file = "$bot_base_dir/$param{'ircUser'}.wingate"; open(IN, $file); while () { @@ -370,7 +370,7 @@ sub on_join { $who = $event->nick(); $chanstats{$chan}{'Join'}++; - $userstats{lc $who}{'Join'} = time() if (&IsParam("seenStats")); + $userstats{lc $who}{'Join'} = time() if (&IsChanConf("seenStats")); &joinfloodCheck($who, $chan, $event->userhost); @@ -610,7 +610,7 @@ sub on_part { $chanstats{$chan}{'Part'}++; &DeleteUserInfo($nick,$chan); &clearChanVars($chan) if ($nick eq $ident); - if (!&IsNickInAnyChan($nick) and &IsParam("seenStats")) { + if (!&IsNickInAnyChan($nick) and &IsChanConf("seenStats")) { delete $userstats{lc $nick}; } @@ -664,12 +664,12 @@ sub on_public { $msgtime = time(); $lastWho{$chan} = $nick; ### TODO: use $nick or lc $nick? - if (&IsParam("seenStats")) { + if (&IsChanConf("seenStats")) { $userstats{lc $nick}{'Count'}++; $userstats{lc $nick}{'Time'} = time(); } -# if (&IsParam("hehCounter")) { +# if (&IsChanConf("hehCounter")) { # #... # } @@ -693,7 +693,7 @@ sub on_quit { } else { &DEBUG("on_quit: nuh{lc $nick} does not exist! FIXME"); } - delete $userstats{lc $nick} if (&IsParam("seenStats")); + delete $userstats{lc $nick} if (&IsChanConf("seenStats")); # should fix chanstats inconsistencies bug #2. if ($reason=~/^($mask{host})\s($mask{host})$/) { # netsplit. @@ -708,8 +708,9 @@ sub on_quit { &status(">>> $b_cyan$nick$ob has signed off IRC $b_red($ob$reason$b_red)$ob"); if ($nick =~ /^\Q$ident\E$/) { - &DEBUG("!!! THIS SHOULD NEVER HAPPEN. FIXME HOPEFULLY"); + &DEBUG("^^^ THIS SHOULD NEVER HAPPEN."); } + if ($nick !~ /^\Q$ident\E$/ and $nick =~ /^\Q$param{'ircNick'}\E$/i) { &status("own nickname became free; changing."); &nick($param{'ircNick'}); @@ -755,13 +756,13 @@ sub on_topic { # this may be fixed at a later date with topic queueing. ### - $topic{$chan}{'Current'} = $topic if (1 and &IsParam("topic") == 1); + $topic{$chan}{'Current'} = $topic if (1 and &IsChanConf("topic") == 1); $chanstats{$chan}{'Topic'}++; &status(">>> topic/$b_blue$chan$ob by $b_cyan$nick$ob -> $topic"); } else { # join. my ($nick, $chan, $topic) = $event->args; - if (&IsParam("topic")) { + if (&IsChanConf("topic")) { $topic{$chan}{'Current'} = $topic; &topicAddHistory($chan,$topic); } @@ -1033,8 +1034,8 @@ sub hookMsg { &DEBUG("unknown msgType => $msgType."); } - if ((!$skipmessage or &IsParam("seenStoreAll")) and - &IsParam("seen") and + if ((!$skipmessage or &IsChanConf("seenStoreAll")) and + &IsChanConf("seen") and $msgType =~ /public/ ) { $seencache{$who}{'time'} = time(); @@ -1060,10 +1061,10 @@ sub hookMsg { } if (defined $nuh) { - if (defined $userHandle) { - &DEBUG("line 1074: remove verifyUser"); + if (!defined $userHandle) { + &DEBUG("line 1074: need verifyUser?"); + &verifyUser($who, $nuh); } - $userHandle = &verifyUser($who, $nuh); } else { &DEBUG("hookMsg: 'nuh' not defined?"); } diff --git a/src/IRC/Schedulers.pl b/src/IRC/Schedulers.pl index 8b922fd..b518f7c 100644 --- a/src/IRC/Schedulers.pl +++ b/src/IRC/Schedulers.pl @@ -355,7 +355,7 @@ sub floodLoop { } my $time = time(); - my $interval = &getChanConfDefault("floodCycle","",60); + my $interval = &getChanConfDefault("floodCycle",60); foreach $who (keys %flood) { foreach (keys %{$flood{$who}}) { @@ -439,6 +439,10 @@ sub seenFlush { &DEBUG("seenFlush: NO VALID FACTOID SUPPORT?"); } + if ($stats{'count_old'} ||= 1) { + &DEBUG("had to set count_old to 1."); + } + &status("Flushed $flushed seen entries.") if ($flushed); &VERB(sprintf(" new seen: %03.01f%% (%d/%d)", $stats{'new'}*100/$stats{'count_old'}, @@ -504,10 +508,10 @@ sub ignoreCheck { my $chan = $_; foreach (keys %{ $ignore{$chan} }) { - my @array = $ignore{$chan}{$_}; + my @array = \@{ $ignore{$chan}{$_} }; foreach (@array) { - &DEBUG(" => $_"); + &DEBUG("ignore: => $_"); } next; @@ -545,6 +549,7 @@ sub ircCheck { if ($ident !~ /^\Q$param{ircNick}\E$/) { &WARN("ircCheck: ident($ident) != param{ircNick}($param{IrcNick})."); + ### TODO: schedule check for own nick if taken? } &joinNextChan(); @@ -737,16 +742,17 @@ sub kernelLoop { } sub wingateCheck { - return unless &IsParam("wingate"); - return unless ($param{'wingate'} =~ /^(.*\s+)?$chan(\s+.*)?$/i); + return unless &IsChanConf("wingate"); ### FILE CACHE OF OFFENDING WINGATES. foreach (grep /^$host$/, @wingateBad) { &status("Wingate: RUNNING ON $host BY $who"); - &ban("*!*\@$host", "") if &IsParam("wingateBan"); + &ban("*!*\@$host", "") if &IsChanConf("wingateBan"); + + my $reason = &getChanConf("wingateKick"); - next unless (&IsParam("wingateKick")); - &kick($who, "", $param{'wingateKick'}) + next unless ($reason); + &kick($who, "", $reason) } ### RUN CACHE OF TRIED WINGATES. @@ -863,7 +869,7 @@ sub scheduleList { } sub getChanConfDefault { - my($what, $chan, $default) = @_; + my($what, $default, $chan) = @_; if (exists $param{$what}) { &DEBUG("backward-compat: found param{$what} instead."); diff --git a/src/Modules/RootWarn.pl b/src/Modules/RootWarn.pl index fdd7fc1..7a87214 100644 --- a/src/Modules/RootWarn.pl +++ b/src/Modules/RootWarn.pl @@ -10,9 +10,10 @@ use strict; sub rootWarn { my ($nick,$user,$host,$chan) = @_; my $attempt = &dbGet("rootwarn", "nick", lc($nick), "attempt") || 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 { @@ -34,13 +35,11 @@ sub rootWarn { } } 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"); } } } diff --git a/src/Modules/Wingate.pl b/src/Modules/Wingate.pl index 53aaf26..f834fb4 100644 --- a/src/Modules/Wingate.pl +++ b/src/Modules/Wingate.pl @@ -72,12 +72,13 @@ sub Wingate { if ($wingate) { &::status("Wingate: RUNNING ON $host BY $::who."); - if (&::IsParam("wingateBan")) { + if (&::IsChanConf("wingateBan") > 0) { &::ban("*!*\@$host", ""); } - if (&::IsParam("wingateKick")) { - &::kick($::who, "", $::param{'wingateKick'}); + my $reason = &::getChanConf("wingateKick"); + if ($reason) { + &::kick($::who, "", $reason); } push(@::wingateBad, "$host\*"); -- 2.39.2