}
sub randomQuote {
- my $line = &getRandomLineFromFile($infobot_misc_dir. "/infobot.randtext");
+ my $line = &getRandomLineFromFile($bot_misc_dir. "/blootbot.randtext");
if (!defined $line) {
&ERROR("random Quote: weird error?");
return;
}
sub logCycle {
+ # check if current size is too large.
if ( -s $file{log} > $param{'maxLogSize'}) {
my $date = sprintf("%04d%02d%02d", (localtime)[5,4,3]);
$file{log} = $param{'logfile'} ."-". $date;
&status("cycling log file.");
}
+ # check if all the logs exceed size.
+ my $logdir = "$bot_base_dir/log/";
+ if (opendir(LOGS, $logdir)) {
+ my $tsize = 0;
+ my (%age, %size);
+
+ while (defined($_ = readdir LOGS)) {
+ my $logfile = "$logdir/$_";
+
+ next unless ( -f $logfile);
+ my $size = -s $logfile;
+ my $age = (stat $logfile)[9]; ### or 8 ?
+
+ $age{$age} = $logfile;
+ $size{$logfile} = $size;
+
+ $tsize += $size;
+ }
+ closedir LOGS;
+
+ my $delete = 0;
+ while ($tsize > $param{'maxLogSize'}) {
+ &status("LOG: current size > max ($tsize > $param{'maxLogSize'})");
+ my $oldest = (sort {$a <=> $b} keys %age)[0];
+ &status("LOG: unlinking $age{$oldest}.");
+ ### NOT YET.
+ # unlink $age{$oldest};
+ $tsize -= $oldest;
+ $delete++;
+ }
+
+ ### TODO: add how many b,kb,mb removed?
+ if ($delete) {
+ &status("LOG: removed $delete logs.");
+ }
+ } else {
+ &WARN("could not open dir $logdir");
+ }
+
&ScheduleThis(60, "logCycle") if (@_);
}
}
}
+ # %netsplit hash checker.
+ 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.
+
+ if (!&IsNickInAnyChan($_)) {
+ &DEBUG("netsplitC: $_ didn't come back from netsplit in 2 hours; removing from netsplit list.");
+ delete $netsplit{$_};
+ }
+ }
+
&ScheduleThis(30, "netsplitCheck") if (@_);
}
}
&VERB("Flushed $flushed seen entries.",2);
+ &DEBUG("seen: ".scalar(keys %seenflush)." remaining.");
my $interval = $param{'seenFlushInterval'} || 60;
&ScheduleThis($interval, "seenFlush") if (@_);
&FIXME("ircCheck: current channels * 2 <= config channels. FIXME.");
}
+ my @ipcs;
+ if ( -x "/usr/bin/ipcs") {
+ @ipcs = `/usr/bin/ipcs`;
+ } else {
+ &WARN("ircCheck: no 'ipcs' binary.");
+ }
+
# shmid stale remove.
- foreach (`ipcs`) {
+ foreach (@ipcs) {
chop;
# key, shmid, owner, perms, bytes, nattch
next unless ($shmid != $shm and $size == 2000);
&status("SHM: nuking shmid $shmid");
- system("ipcrm shm $shmid >/dev/null");
+ system("/usr/bin/ipcrm shm $shmid >/dev/null");
}
if (!$conn->connected and time - $msgtime > 3600) {
&WARN("ircCheck: ident($ident) != param{ircNick}($param{IrcNick}).");
}
+ if (scalar @joinchan) {
+ &WARN("We have some channels to join, doing so.");
+ &joinNextChan();
+ }
+
&ScheduleThis(240, "ircCheck") if (@_);
}
&ScheduleThis(5, "shmFlush") if (@_);
}
+sub getNickInUse {
+ if ($ident eq $param{'ircNick'}) {
+ &status("okay, got my nick back.");
+ return;
+ }
+
+ &status("Trying to get my nick back.");
+ &nick($param{'ircNick'});
+
+ &ScheduleThis(5, "getNickInUse") if (@_);
+}
+
sub uptimeCycle {
&uptimeWriteFile();
sub wingateWriteFile {
return unless (scalar @wingateCache);
- my $file = "$infobot_base_dir/$param{'ircUser'}.wingate";
- if ($infobot_pid != $$) {
+ my $file = "$bot_base_dir/$param{'ircUser'}.wingate";
+ if ($bot_pid != $$) {
&DEBUG("wingateWriteFile: Reorganising!");
open(IN, $file);