]> git.donarmstrong.com Git - infobot.git/commitdiff
- more fixes to new-style config, should be 99% of it.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 2 Feb 2001 13:09:09 +0000 (13:09 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 2 Feb 2001 13:09:09 +0000 (13:09 +0000)
- 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@298 c11ca15a-4712-0410-83d8-924469b57eb5

blootbot/src/IRC/Irc.pl
blootbot/src/IRC/IrcHooks.pl
blootbot/src/IRC/Schedulers.pl
blootbot/src/Modules/RootWarn.pl
blootbot/src/Modules/Wingate.pl

index b0b683402135f17281feb29baba8fca18e9481d2..8d40b141e2aace32b8fa18cd23ca603cdde12eb7 100644 (file)
@@ -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.");
index b3418cd1d7f9f567d8431f3cca7b04f3bb3e6feb..a1ad9fb586f43f7e1d26bc11e587c23394f532ca 100644 (file)
@@ -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 (<IN>) {
@@ -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?");
     }
index 8b922fd9618bc4c4cfa818ad175e80d21684cdd6..b518f7cdd5e57bb8a545ce50d5b1ca3aa96109f8 100644 (file)
@@ -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.");
index fdd7fc1c285364eca2a5cb13afacf06e05342a06..7a87214675a63c8ae9dd2950be1d6273da52a11f 100644 (file)
@@ -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");
            }
        }
     }
index 53aaf267f9a3ca4db835149b8b6de078325e133c..f834fb467e19248d109db2e54db50d97f62ac023 100644 (file)
@@ -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\*");