]> git.donarmstrong.com Git - infobot.git/commitdiff
chan limit check code should now be disabled/re-enabled in relation to netsplits...
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 8 Feb 2001 13:52:19 +0000 (13:52 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 8 Feb 2001 13:52:19 +0000 (13:52 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@360 c11ca15a-4712-0410-83d8-924469b57eb5

src/IRC/IrcHooks.pl
src/IRC/Schedulers.pl

index 597fb3a788dfba339de521c20cbe1b4fac5d2c0c..9eec53b043cfa0fa0276b020e810951d36e62ac2 100644 (file)
@@ -406,7 +406,7 @@ sub on_join {
     }
 
     if ($netsplit and !$netsplittime) {
-       &status("ok.... re-running chanlimitCheck in 60.");
+       &DEBUG("on_join: ok.... re-running chanlimitCheck in 60.");
        $conn->schedule(60, sub {
                &chanlimitCheck();
                $netsplittime = undef;
@@ -448,21 +448,7 @@ sub on_join {
                    $channels{$chan}{'o'}{$ident});
 
     ### chanlimit check.
-    my $l = $channels{$chan}{'l'};
-    if (defined $l and &IsChanConf("chanlimitcheck")) {
-       my $plus = &getChanConfDefault("chanlimitcheckPlus", 5, $chan);
-       my $nowl = scalar(keys %{ $channels{$chan}{''} });
-
-       if ($plus <= 3) {
-           &WARN("clc: stupid to have plus at $plus, fix it!");
-       }
-
-       ### check if we have ops.
-       if ($nowl > $l - 3 and $plus > 3) {
-           &WARN("clc: nowl($nowl) > l($l) - 3");
-           &rawout("MODE $chan +l ".($nowl+$plus) );
-       }
-    }
+    &chanLimitVerify($chan);
 
     # used to determine sync time.
     if ($who =~ /^$ident$/i) {
@@ -725,10 +711,15 @@ sub on_quit {
 
     foreach (keys %channels) {
        # fixes inconsistent chanstats bug #1.
-       next unless (&IsNickInChan($nick,$_));
+       if (!&IsNickInChan($nick,$_)) {
+           &DEBUG("on_quit: nick $nick was not in chan $_.");
+           next;
+       }
        $chanstats{$_}{'SignOff'}++;
     }
+
     &DeleteUserInfo($nick, keys %channels);
+
     if (exists $nuh{lc $nick}) {
        delete $nuh{lc $nick};
     } else {
@@ -740,6 +731,11 @@ sub on_quit {
     if ($reason=~/^($mask{host})\s($mask{host})$/) {   # netsplit.
        $reason = "NETSPLIT: $1 <=> $2";
 
+       if (&ChanConfList("chanlimitcheck") and !scalar keys %netsplit) {
+           &DEBUG("on_quit: netsplit detected; disabling chan limit.");
+           &rawout("MODE $chan -l");
+       }
+
        $netsplit{lc $nick} = time();
        if (!exists $netsplitservers{$1}{$2}) {
            &status("netsplit detected between $1 and $2.");
@@ -1121,4 +1117,29 @@ sub hookMsg {
     return;
 }
 
+sub chanLimitVerify {
+    my($chan)  = @_;
+    my $l      = $channels{$chan}{'l'};
+
+    # only change it if it's not set.
+    if (defined $l and &IsChanConf("chanlimitcheck")) {
+       my $plus = &getChanConfDefault("chanlimitcheckPlus", 5, $chan);
+       my $nowl = scalar(keys %{ $channels{$chan}{''} });
+       my $delta       = $nowl - $l;
+       $delta          =~ s/^\-//;
+
+       if ($plus <= 3) {
+           &WARN("clc: stupid to have plus at $plus, fix it!");
+       }
+
+       ### todo: check if we have ops.
+       ### todo: if not, check if nickserv/chanserv is avail.
+       ### todo: unify code with chanlimitcheck()
+       if ($delta > 3) {
+           &WARN("clc: nowl($nowl) > l($l) - 3");
+           &rawout("MODE $chan +l ".($nowl+$plus) );
+       }
+    }
+}
+
 1;
index 591d5299e41ac339987e584a41a4bf728fc0f073..e6ae976991b99f3d32d36aeaf59ef215bf3ad1b6 100644 (file)
@@ -307,9 +307,14 @@ sub chanlimitCheck {
 
        if (!exists $channels{$_}{'o'}{$ident}) {
            &ERROR("chanlimitcheck: dont have ops on $_.");
+           ### TODO: check chanserv?
            next;
        }
 
+       if (!defined $limit) {
+           &DEBUG("setting limit for first time or from netsplit for $_");
+       }
+
        &rawout("MODE $_ +l $newlimit");
     }
 }
@@ -334,17 +339,22 @@ sub netsplitCheck {
     }
 
     # %netsplit hash checker.
+    my $count  = scalar keys %netsplit;
     foreach (keys %netsplit) {
        if (&IsNickInAnyChan($_)) {
            &DEBUG("netsplitC: $_ is in some chan; removing from netsplit list.");
            delete $netsplit{$_};
        }
-       next unless (time() - $netsplit{$_} > 60*60*2); # 2 hours.
-       next if (&IsNickInAnyChan($_));
+       next unless (time() - $netsplit{$_} > 60*10);
 
-       &DEBUG("netsplitC: $_ didn't come back from netsplit in 2 hours; removing from netsplit list.");
+       &DEBUG("netsplitC: $_ didn't come back from netsplit; removing from netsplit list.");
        delete $netsplit{$_};
     }
+
+    if ($count and !scalar keys %netsplit) {
+       &DEBUG("ok, netsplit is hopefully gone. reinstating chanlimit check.");
+       &chanlimitCheck();
+    }
 }
 
 sub floodLoop {