- &ScheduleThis($interval, "chanlimitCheck");
- return if ($_[0] eq "2");
- }
-
- my $str = join(' ', &ChanConfList("chanlimitcheck") );
-
- foreach $chan ( &ChanConfList("chanlimitcheck") ) {
- next unless (&validChan($chan));
-
- if ($chan eq "_default") {
- &WARN("chanlimit: we're doing $chan!! HELP ME!");
- next;
- }
-
- my $limitplus = &getChanConfDefault("chanlimitcheckPlus", 5, $chan);
- my $newlimit = scalar(keys %{ $channels{$chan}{''} }) + $limitplus;
- my $limit = $channels{$chan}{'l'};
-
- if (scalar keys %netsplitservers) {
- if (defined $limit) {
- &status("chanlimit: netsplit; removing it for $chan.");
- $conn->mode($chan, "-l");
- $cache{chanlimitChange}{$chan} = time();
- &status("chanlimit: netsplit; removed.");
- }
-
- next;
- }
-
- if (defined $limit and scalar keys %{ $channels{$chan}{''} } > $limit) {
- &FIXME("LIMIT: set too low!!!");
- ### run NAMES again and flush it.
- }
-
- if (defined $limit and $limit == $newlimit) {
- $cache{chanlimitChange}{$chan} = time();
- next;
- }
-
- if (!exists $channels{$chan}{'o'}{$mynick}) {
- &status("chanlimit: dont have ops on $chan.") unless (exists $cache{warn}{chanlimit}{$chan});
- $cache{warn}{chanlimit}{$chan} = 1;
- &chanServCheck($chan);
- next;
- }
- delete $cache{warn}{chanlimit}{$chan};
-
- if (!defined $limit) {
- &status("chanlimit: $chan: setting for first time or from netsplit.");
- }
-
- if (exists $cache{chanlimitChange}{$chan}) {
- my $delta = time() - $cache{chanlimitChange}{$chan};
- if ($delta < $interval*60) {
- &DEBUG("chanlimit: not going to change chanlimit! ($delta<$interval*60)");
- return;
- }
- }
-
- $conn->mode($chan, "+l", $newlimit);
- $cache{chanlimitChange}{$chan} = time();
+ &ScheduleThis( $interval * 60, 'chanlimitCheck' ); # default 10 minutes
+ return if ( $_[0] eq '2' );
+ }
+
+ my $str = join( ' ', &ChanConfList('chanlimitcheck') );
+
+ foreach $chan ( &ChanConfList('chanlimitcheck') ) {
+ next unless ( &validChan($chan) );
+
+ if ( $chan eq '_default' ) {
+ &WARN("chanlimit: we're doing $chan!! HELP ME!");
+ next;
+ }
+
+ my $limitplus = &getChanConfDefault( 'chanlimitcheckPlus', 5, $chan );
+ my $newlimit = scalar( keys %{ $channels{$chan}{''} } ) + $limitplus;
+ my $limit = $channels{$chan}{'l'};
+
+ if ( scalar keys %netsplitservers ) {
+ if ( defined $limit ) {
+ &status("chanlimit: netsplit; removing it for $chan.");
+ $conn->mode( $chan, '-l' );
+ $cache{chanlimitChange}{$chan} = time();
+ &status('chanlimit: netsplit; removed.');
+ }
+
+ next;
+ }
+
+ if ( defined $limit and scalar keys %{ $channels{$chan}{''} } > $limit )
+ {
+ &FIXME('LIMIT: set too low!!!');
+ ### run NAMES again and flush it.
+ }
+
+ if ( defined $limit and $limit == $newlimit ) {
+ $cache{chanlimitChange}{$chan} = time();
+ next;
+ }
+
+ if ( !exists $channels{$chan}{'o'}{$mynick} ) {
+ &status("chanlimit: dont have ops on $chan.")
+ unless ( exists $cache{warn}{chanlimit}{$chan} );
+ $cache{warn}{chanlimit}{$chan} = 1;
+ &chanServCheck($chan);
+ next;
+ }
+ delete $cache{warn}{chanlimit}{$chan};
+
+ if ( !defined $limit ) {
+ &status(
+ "chanlimit: $chan: setting for first time or from netsplit.");
+ }
+
+ if ( exists $cache{chanlimitChange}{$chan} ) {
+ my $delta = time() - $cache{chanlimitChange}{$chan};
+ if ( $delta < $interval * 60 ) {
+ &DEBUG(
+"chanlimit: not going to change chanlimit! ($delta<$interval*60)"
+ );
+ return;
+ }
+ }
+
+ $conn->mode( $chan, '+l', $newlimit );
+ $cache{chanlimitChange}{$chan} = time();