#channel" but "CTCP VERSION $nick".
there's a max of 5*30/3 nicks unless we change verstats_flush.
- status() now supports a hack'ish hook to debug %channels (that is,
ircCheck())
- if ignoreCheck hasn't been run in more than 60 seconds and we have a
possible ignore match, run it. unfortunately, the first message will
be ignored if the removed entry matches the person asking the bot.
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@536
c11ca15a-4712-0410-83d8-
924469b57eb5
$cache{verstats}{who} = $who;
$cache{verstats}{msgType} = $msgType;
+ $conn->schedule(30, sub {
+ my $c = lc $cache{verstats}{chan};
+ @vernicktodo = ();
+ foreach (keys %{ $channels{$c}{''} } ) {
+ next if (grep /^\Q$_\E$/i, @vernick);
+ push(@vernicktodo, $_);
+ }
+
+ &verstats_flush();
+ } );
+
$conn->schedule(60, sub {
my $vtotal = 0;
my $c = lc $cache{verstats}{chan};
my $unknown = $total - $vtotal;
my $perc = sprintf("%.1f", $unknown * 100 / $total);
$perc =~ s/.0$//;
- $sorted{$perc}{"unknown/cloak"} = "$unknown ($perc%)";
+ $sorted{$perc}{"unknown/cloak"} = "$unknown ($perc%)" if ($unknown);
foreach (keys %ver) {
my $count = scalar keys %{ $ver{$_} };
return;
}
+sub verstats_flush {
+ for (1..5) {
+ last unless (scalar @vernicktodo);
+
+ my $n = shift(@vernicktodo);
+ $conn->ctcp("VERSION", $n);
+ }
+
+ return unless (scalar @vernicktodo);
+
+ $conn->schedule(3, \&verstats_flush() );
+}
+
sub textstats_main {
my($arg) = @_;
foreach (@ignore) {
s/\*/\\S*/g;
- next unless (eval { $nuh =~ /^$_$/i });
+ next unless (eval { $nuh =~ /^$_$/i } );
+
+ # better to ignore an extra message than to allow one to get
+ # through, although it would be better to go through ignore
+ # checking again.
+ if (time() - $cache{ignoreCheckTime} > 60) {
+ &ignoreCheck();
+ }
&status("IGNORE <$who> $message");
return;
@joinchan = &getJoinChans(1);
}
+ # ok, we're free to do whatever we want now. go for it!
+ $running = 1;
+
# unfortunately, Net::IRC does not implement this :(
# invalid command... what is it?
# &rawout("NOTIFY $ident");
### $chan = $reason; # no.
my $count = 0;
- foreach (keys %channels) {
+ foreach (grep !/^_default$/, keys %channels) {
# fixes inconsistent chanstats bug #1.
if (!&IsNickInChan($nick,$_)) {
$count++;
&leakCheck(2); # mandatory
&ignoreCheck(1); # mandatory
&seenFlushOld(2);
-# &ircCheck(2); # mandatory
&ircCheck(1); # mandatory
&miscCheck(1); # mandatory
&miscCheck2(2); # mandatory
$count++;
}
}
+
+ $cache{ignoreCheckTime} = time();
+
&VERB("ignore: $count items deleted.",2);
}
return if ($_[0] eq "2"); # defer.
}
+ $cache{statusSafe} = 1;
+
my @x = &getJoinChans();
my $iconf = scalar( @x );
my $inow = scalar( keys %channels );
if (grep /^\s*$/, keys %channels) {
&WARN("ircCheck: we have a NULL chan in hash channels? removing!");
- if (exists $channels{''}) {
- &DEBUG("ircCheck: ok it existed!");
- } else {
- &DEBUG("ircCheck: this hsould never happen!");
+ if (!exists $channels{''}) {
+ &DEBUG("ircCheck: this should never happen!");
}
delete $channels{''};
}
+ $cache{statusSafe} = 0;
+
### USER FILE.
if ($utime_userfile > $wtime_userfile and time() - $wtime_userfile > 3600) {
&writeUserFile();
$pubsize $pubcount $pubtime
$msgsize $msgcount $msgtime
$notsize $notcount $nottime
+ $running
);
# dynamic hash.
$utime_chanfile = 0;
$wtime_chanfile = 0;
$ucount_chanfile = 0;
+$running = 0;
### more variables...
$msgtime = time();
$msgsize = 0;
use strict;
use vars qw($statcount $bot_pid $forkedtime $statcountfix $addressed);
-use vars qw($logDate $logold $logcount $logtime $logrepeat);
+use vars qw($logDate $logold $logcount $logtime $logrepeat $running);
use vars qw(@backlog);
-use vars qw(%param %file);
+use vars qw(%param %file %cache);
require 5.001;
my($input) = @_;
my $status;
+ # a way to hook onto status without looping.
+ # todo: find why $channels{undef} is created.
+ if (0 and $running and !$cache{statusSafe}) {
+ &ircCheck();
+ }
+
if ($input eq $logold) {
# allow perl flooding
$logrepeat++ unless ($input =~ /PERL: Use of uninitialized/);
if ($logrepeat >= 3) {
$logrepeat = 0;
&status("LOG: repeat throttle.");
+ # we block it to ensure sequence of logging is intact.
+ # could go with $conn->schedule but that's evil :)
sleep 1;
}
} else {
# Something is using this w/ NULL.
if (!defined $input or $input =~ /^\s*$/) {
- $input = "Blank status call? HELP HELP HELP";
+ $input = "ERROR: Blank status call? HELP HELP HELP";
}
for ($input) {
printf $_green."[%6d]".$ob." ", $statcount;
}
- # three uberstabs to Derek Moeller.
+ # three uberstabs to Derek Moeller. I don't remember why but he
+ # deserved it :)
my $printable = $input;
if ($printable =~ s/^(<\/\S+>) //) {
my $newlogDate = sprintf("%04d%02d%02d",$year+1900,$month+1,$day);
if (defined $logDate and $newlogDate != $logDate) {
&closeLog();
- &compress($file{log});
+ &compress( $file{log} );
&openLog();
}
} else {
$date = $time;
}
- print LOG sprintf("%s %s\n", $date, $input);
+ printf LOG "%s %s\n", $date, $input;
}
sub openSQLDebug {
return if ($age == $moduleAge{$file});
if ($age < $moduleAge{$file}) {
- &WARN("rM: we're not gonna downgrade the file. use 'touch'.");
+ &WARN("rM: we're not gonna downgrade '$file'; use touch.");
return;
}