}
} else {
+ if (exists $cache{joinTime}) {
+ my $delta = time() - $cache{joinTime};
+ my $timestr = &Time2String($delta);
+ my $rate = sprintf("%.1f", $delta / &getJoinChans() );
+ delete $cache{joinTime};
+
+ &DEBUG("time taken to join all chans: $timestr; rate: $rate sec/join");
+ }
# chanserv check: global channels, in case we missed one.
foreach ( &ChanConfList("chanServ_ops") ) {
undef %channels;
undef %floodjoin;
- @joinchan = &getJoinChans();
+ @joinchan = &getJoinChans(1);
+ $cache{joinTime} = time();
}
sub getJoinChans {
+ my($show) = @_;
my @chans;
my @skip;
push(@chans, $_);
}
+ my $str;
if (scalar @skip) {
- &status("gJC: channels not auto-joining: @skip");
+ $str = "gJC: channels not auto-joining: @skip";
} else {
- &status("gJC: auto-joining all chans.");
+ $str = "gJC: auto-joining all chans.";
}
+ &status($str) if ($show);
+
return @chans;
}
&status("End of motd. Now lets join some channels...");
if (!scalar @joinchan) {
&WARN("joinchan array is empty!!!");
- @joinchan = &getJoinChans();
+ @joinchan = &getJoinChans(1);
}
# unfortunately, Net::IRC does not implement this :(
- &rawout("NOTIFY $ident");
- &DEBUG("adding self to NOTIFY list.");
+ # invalid command... what is it?
+# &rawout("NOTIFY $ident");
+# &DEBUG("adding self to NOTIFY list.");
&joinNextChan();
}
sub on_quit {
my ($self, $event) = @_;
- my $nick = $event->nick();
- my $reason = ($event->args)[0];
+ my $nick = $event->nick();
+ my $reason = ($event->args)[0];
+
# hack for ICC.
$msgType = "public";
$who = $nick;
&DEBUG("on_quit: nuh{lc $nick} does not exist! FIXME");
}
delete $userstats{lc $nick} if (&IsChanConf("seenStats"));
+ delete $chanstats{lc $nick};
# should fix chanstats inconsistencies bug #2.
- if ($reason=~/^($mask{host})\s($mask{host})$/) { # netsplit.
+ if ($reason =~ /^($mask{host})\s($mask{host})$/) { # netsplit.
$reason = "NETSPLIT: $1 <=> $2";
if (&ChanConfList("chanlimitcheck") and !scalar keys %netsplit) {
}
if ($nick !~ /^\Q$ident\E$/ and $nick =~ /^\Q$param{'ircNick'}\E$/i) {
- &status("own nickname became free; changing.");
+ &status("nickchange: own nickname became free; changing.");
&nick($param{'ircNick'});
}
}
delete $sched{"leakCheck"}{RUNNING};
}
- # flood.
+ # flood. this is dealt with in floodLoop()
foreach $blah1 (keys %flood) {
foreach $blah2 (keys %{ $flood{$blah1} }) {
$count += scalar(keys %{ $flood{$blah1}{$blah2} });
$count += scalar(keys %{ $floodjoin{$blah1}{$blah2} });
}
}
- &DEBUG("leak: hash flood has $count total keys.",2);
+ &DEBUG("leak: hash floodjoin has $count total keys.",2);
# floodwarn.
$count = scalar(keys %floodwarn);
}
}
+ # chanstats
+ $count = scalar(keys %chanstats);
+ &DEBUG("leak: hash chanstats has $count total keys.",2);
+
+ # nuh.
my $delete = 0;
foreach (keys %nuh) {
next if (&IsNickInAnyChan($_));
}
my @x = &getJoinChans();
- my $iconf = scalar( @x );
- my $inow = scalar( keys %channels );
+ my $iconf = scalar( @x );
+ my $inow = scalar( keys %channels );
if ($iconf > 2 and $inow * 2 <= $iconf) {
&FIXME("ircCheck: current channels * 2 <= config channels. FIXME.");
@joinchan = @x;
}
return unless ($backup);
+ my $age = &Time2String(time() - (stat $file)[9]);
+
### TODO: do internal copying.
- &status("Backup: $file to $file~");
+ &status("Backup: $file ($age)");
CORE::system("/bin/cp $file $file~");
}
}
if (&validChan($thischan)) {
- &msg($who,"I'm already on $thischan...");
- return;
+ &msg($who,"warn: I'm already on $thischan, joining anyway...");
+# return;
}
}
$cache{join}{$thischan} = $who; # used for on_join self.
$reply .= ". At the moment, ". &IJoin(@array);
# Step 3:
- ### TODO: what's wrong with the following?
+ my %new;
foreach (keys %userstats) {
- next if (exists $userstats{$_}{'Count'});
- delete $userstats{$_};
- $delete++;
+ next unless (exists $userstats{$_}{'Count'});
+ $new{$_} = $userstats{$_}{'Count'};
}
- &DEBUG("chanstats: delete: $delete... nowtotal => ".scalar(keys %userstats) );
- my %new = map { $userstats{$_}{'Count'} => $_ } keys %userstats;
my($count) = (sort { $b <=> $a } keys %new)[0];
if ($count) {
$reply .= ". \002$new{$count}\002 has said the most with a total of \002$count\002 messages";
}
if (&IsParam("logType") and $param{'logType'} =~ /DAILY/i) {
- my ($day,$month,$year) = (localtime(time()))[3,4,5];
+ my ($day,$month,$year) = (localtime time())[3,4,5];
$logDate = sprintf("%04d%02d%02d",$year+1900,$month+1,$day);
$file{log} .= "-".$logDate;
}
my $okay = 0;
if (! -f $file) {
- # ironically this does not get logged :)
&WARN("compress: file ($file) does not exist.");
return 0;
}
- if (-f "$file.gz" or -f "$file.bz2") {
+ if ( -f "$file.gz" or -f "$file.bz2" ) {
&WARN("compress: file.(gz|bz2) already exists.");
return 0;
}
}
sub FIXME {
- &status("${b_cyan}!FIXME!$ob $_[0] (SHOULD NOT HAPPEN?)");
+ &status("${b_cyan}!FIXME!$ob $_[0]");
}
sub TODO {
my $status;
if ($input eq $logold) {
+ # allow perl flooding
$logrepeat++ unless (/!WARN! PERL: Use of uninitialized/);
+ # todo: prevent massive repetitive throttling.
if ($logrepeat >= 3) {
$logrepeat = 0;
&status("LOG: repeat throttle.");
sleep 1;
}
+ } else {
+ $logold = $input;
}
- $logold = $input;
# if it's not a scalar, attempt to warn and fix.
- if (ref($input) ne "") {
- &status("status: 'input' is not scalar (".ref($input).").");
- if (ref($input) eq "ARRAY") {
+ my $ref = ref $input;
+ if (defined $ref and $ref ne "") {
+ &status("status: 'input' is not scalar ($ref).");
+
+ if ($ref eq "ARRAY") {
foreach (@$input) {
&WARN("status: '$_'.");
}
# Something is using this w/ NULL.
if (!defined $input or $input =~ /^\s*$/) {
- $input = "Blank status call?";
+ $input = "Blank status call? HELP HELP HELP";
}
- $input =~ s/\n+$//;
- $input =~ s/\002|037//g; # bold,video,underline => remove.
- # pump up the stats (or loglinenum).
+ for ($input) {
+ s/\n+$//;
+ s/\n/<NL>/g;
+ s/\002|037//g; # bold,video,underline => remove.
+ }
+
+ # pump up the stats.
$statcount++;
# fix style of output if process is child.
### LOG THROTTLING.
### TODO: move this _after_ printing?
- my $time = time();
- my $reset = 0;
- if ($logtime != $time) {
- $reset++;
- } elsif ($logtime == $time) {
- if ($logcount < 25) { # too high?
+ my $time = time();
+ my $reset = 0;
+
+ if ($logtime == $time) {
+ if ($logcount < 25) { # too high?
$logcount++;
} else {
sleep 1;
&status("LOG: Throttling."); # recursive?
$reset++;
}
+ } else { # $logtime != $time.
+ $reset++;
}
+
if ($reset) {
$logtime = $time;
$logcount = 0;
$status = "!$statcount! ".$input;
if ($statcount > 1000) {
print LOG "ERROR: FORKED PROCESS RAN AWAY; KILLING.\n";
- print LOG "VERB: ".(&Time2String(time() - $forkedtime))."\n";
+ print LOG "VERB: ".(&Time2String($time - $forkedtime))."\n";
exit 0;
}
} else {
return unless (defined fileno LOG);
# remove control characters from logging.
- $input =~ s/\e\[[0-9;]+m//g;
- $input =~ s/[\cA-\c_]//g;
+ for ($input) {
+ s/\e\[[0-9;]+m//g; # escape codes.
+ s/[\cA-\c_]//g; # control chars.
+ }
$input = "FORK($$) ".$input if ($statcountfix);
my $date;
if (&IsParam("logType") and $param{'logType'} =~ /DAILY/i) {
- $date = sprintf("%02d:%02d.%02d", (localtime(time()))[2,1,0]);
+ $date = sprintf("%02d:%02d.%02d", (localtime $time)[2,1,0]);
- my ($day,$month,$year) = (localtime(time()))[3,4,5];
+ my ($day,$month,$year) = (localtime $time)[3,4,5];
my $newlogDate = sprintf("%04d%02d%02d",$year+1900,$month+1,$day);
if (defined $logDate and $newlogDate != $logDate) {
&closeLog();
&openLog();
}
} else {
- $date = time();
+ $date = $time;
}
print LOG sprintf("%s %s\n", $date, $input);