From 125f660a9a417e22b302e61a0de92c437253fe32 Mon Sep 17 00:00:00 2001 From: dms Date: Wed, 18 Apr 2001 14:30:54 +0000 Subject: [PATCH] fix chanlimitChange time w3search => "blah for blah" fails - fixed. git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@447 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/IRC/IrcHelpers.pl | 6 +++--- src/IRC/Schedulers.pl | 12 ++++++++---- src/Modules/W3Search.pl | 9 +++------ src/core.pl | 10 +++++----- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/IRC/IrcHelpers.pl b/src/IRC/IrcHelpers.pl index b2b33d1..56811b7 100644 --- a/src/IRC/IrcHelpers.pl +++ b/src/IRC/IrcHelpers.pl @@ -258,6 +258,7 @@ sub chanLimitVerify { if (defined $l and &IsChanConf("chanlimitcheck")) { my $plus = &getChanConfDefault("chanlimitcheckPlus", 5, $chan); my $count = scalar(keys %{ $channels{$chan}{''} }); + my $int = &getChanConfDefault("chanlimitcheckInterval", 10, $chan); my $delta = $count + $plus - $l; $delta =~ s/^\-//; @@ -267,11 +268,9 @@ sub chanLimitVerify { } if (exists $cache{ "chanlimitChange_$chan" }) { - if (time() - $cache{ "chanlimitChange_$chan" } < 60) { - &DEBUG("not going to change chanlimit!"); + if (time() - $cache{ "chanlimitChange_$chan" } < $int*60) { return; } - delete $cache{ "chanlimitChange_$chan" }; } ### todo: check if we have ops. @@ -280,6 +279,7 @@ sub chanLimitVerify { if ($delta > 5) { &status("clc: big change in limit; changing."); &rawout("MODE $chan +l ".($count+$plus) ); + $cache{ "chanlimitChange_$chan" } = time(); } } } diff --git a/src/IRC/Schedulers.pl b/src/IRC/Schedulers.pl index c8d663c..59ca412 100644 --- a/src/IRC/Schedulers.pl +++ b/src/IRC/Schedulers.pl @@ -379,11 +379,11 @@ sub chanlimitCheck { } if (exists $cache{ "chanlimitChange_$chan" }) { - if (time() - $cache{ "chanlimitChange_$chan" } < 60) { - &DEBUG("not going to change chanlimit!"); + my $delta = time() - $cache{ "chanlimitChange_$chan" }; + if ($delta < $interval*60) { + &DEBUG("not going to change chanlimit! ($delta<$interval*60)"); return; } - delete $cache{ "chanlimitChange_$chan" }; } &rawout("MODE $chan +l $newlimit"); @@ -662,7 +662,7 @@ sub ircCheck { &rawout("PRIVMSG ChanServ :OP $chan $ident"); } - if (!$conn->connected or time - $msgtime > 3600) { + if (!$conn->connected or time() - $msgtime > 3600) { # todo: shouldn't we use cache{connect} somewhere? if (exists $cache{connect}) { &WARN("ircCheck: no msg for 3600 and disco'd! reconnecting!"); @@ -704,6 +704,10 @@ sub ircCheck { &DEBUG("channels END"); } + &DEBUG("ircstats..."); + &DEBUG(" pubsleep: $pubsleep"); + &DEBUG(" msgsleep: $msgsleep"); + ### USER FILE. if ($utime_userfile > $wtime_userfile and time() - $wtime_userfile > 3600) { &writeUserFile(); diff --git a/src/Modules/W3Search.pl b/src/Modules/W3Search.pl index 8f216b8..9bbe78c 100644 --- a/src/Modules/W3Search.pl +++ b/src/Modules/W3Search.pl @@ -16,19 +16,16 @@ sub W3Search { my ($where, $what, $type) = @_; my $retval = "$where can't find \002$what\002"; - return unless &::loadPerlModule("WWW::Search"); - - if (defined $type) { - &::DEBUG("W3S: type => $type"); - } - my @matches = grep { lc($_) eq lc($where) ? $_ : undef } @W3Search_engines; if (@matches) { $where = shift @matches; } else { &::msg($::who, "i don't know how to check '$where'"); + return; } + return unless &::loadPerlModule("WWW::Search"); + my $Search = new WWW::Search($where); my $Query = WWW::Search::escape_query($what); $Search->native_query($Query, diff --git a/src/core.pl b/src/core.pl index a2e7478..48fe3cf 100644 --- a/src/core.pl +++ b/src/core.pl @@ -19,8 +19,8 @@ use vars qw( $flag_quit $msgType $utime_userfile $wtime_userfile $ucount_userfile $utime_chanfile $wtime_chanfile $ucount_chanfile - $pubsize $pubcount $pubtime - $msgsize $msgcount $msgtime + $pubsize $pubcount $pubtime $pubsleep + $msgsize $msgcount $msgtime $msgsleep ); # dynamic hash. @@ -56,12 +56,12 @@ $utime_chanfile = 0; $wtime_chanfile = 0; $ucount_chanfile = 0; ### more variables... -$msgtime = 0; +$msgtime = time(); $msgsize = 0; -$msgcount = 0; +$msgcount = $msgsleep = 0; $pubtime = 0; $pubsize = 0; -$pubcount = 0; +$pubcount = $pubsleep = 0; ### $bot_version = "blootbot cvs (20010214) -- $^O"; $noreply = "NOREPLY"; -- 2.39.2