my $time = $schedule{$codename}[3];
if (defined $time and $time > time()) {
- &WARN("Sched for $codename already exists.");
+ &WARN("Sched for $codename already exists in " . &Time2String(time() - $time) . ".");
return;
}
-# &VERB("Scheduling \&$codename() for ".&Time2String($waittime),3);
+ #&VERB("Scheduling \&$codename() for " . &Time2String($waittime),3);
my $retval = $conn->schedule($waittime, sub {
\&$codename;
# ONCE OFF.
# REPETITIVE.
- # 1 for run straight away, 2 for on next-run.
- &uptimeLoop(1);
+ # 2 for on next-run.
&randomQuote(2);
&randomFactoid(2);
- &logLoop(1);
- &chanlimitCheck(1);
- &netsplitCheck(1); # mandatory
- &floodLoop(1); # mandatory
&seenFlush(2);
&leakCheck(2); # mandatory
- &ignoreCheck(1); # mandatory
&seenFlushOld(2);
- &ircCheck(1); # mandatory
- &miscCheck(1); # mandatory
&miscCheck2(2); # mandatory
- &shmFlush(1); # mandatory
&slashdotLoop(2);
&plugLoop(2);
&kernelLoop(2);
&wingateWriteFile(2);
&factoidCheck(2); # takes a couple of seconds on a 486. defer it
# TODO: convert to new format... or nuke altogether.
- &newsFlush(1);
+ &newsFlush(2);
+
+ # 1 for run straight away
+ &uptimeLoop(1);
+ &logLoop(1);
+ &chanlimitCheck(1);
+ &netsplitCheck(1); # mandatory
+ &floodLoop(1); # mandatory
+ &ignoreCheck(1); # mandatory
+ &miscCheck(1); # mandatory
+ &shmFlush(1); # mandatory
+ sleep 1;
+ &ircCheck(1); # mandatory
# TODO: squeeze this into a one-liner.
# my $count = map { exists $sched{$_}{TIME} } keys %sched;
}
&status("Schedulers: $count will be running.");
-### &scheduleList();
+ &scheduleList();
}
sub ScheduleThis {
my $time = $sched{$codename}{TIME};
if (defined $time and $time > time()) {
- &WARN("Sched for $codename already exists.");
+ &WARN("Sched for $codename already exists in " . &Time2String(time() - $time) . ".");
return;
}
-# &VERB("Scheduling \&$codename() for ".&Time2String($waittime),3);
+ &DEBUG("Scheduling \&$codename() " . \&$codename . " for " . &Time2String($waittime),3);
my $retval = $conn->schedule($waittime, \&$codename, @args);
$sched{$codename}{LABEL} = $retval;
return if ($_[0] eq "2"); # defer.
}
- my $line = &getRandomLineFromFile($bot_data_dir. "/blootbot.randtext");
- if (!defined $line) {
- &ERROR("random Quote: weird error?");
- return;
- }
-
foreach ( &ChanConfList("randomQuote") ) {
next unless (&validChan($_));
+ my $line = &getRandomLineFromFile($bot_data_dir. "/blootbot.randtext");
+ if (!defined $line) {
+ &ERROR("random Quote: weird error?");
+ return;
+ }
+
&status("sending random Quote to $_.");
&action($_, "Ponders: ".$line);
}
return if ($_[0] eq "2"); # defer.
}
- while (1) {
- ($key,$val) = &randKey("factoids","factoid_key,factoid_value");
-### $val =~ tr/^[A-Z]/[a-z]/; # blah is Good => blah is good.
- last if (defined $val and $val !~ /^</);
-
- $error++;
- if ($error == 5) {
- &ERROR("rF: tried 5 times but failed.");
- return;
- }
- }
-
foreach ( &ChanConfList("randomFactoid") ) {
next unless (&validChan($_));
&status("sending random Factoid to $_.");
+ while (1) {
+ ($key,$val) = &randKey("factoids","factoid_key,factoid_value");
+ &DEBUG("rF: $key, $val");
+### $val =~ tr/^[A-Z]/[a-z]/; # blah is Good => blah is good.
+ last if ((defined $val) and ($val !~ /^</) and ($key !~ /\#DEL\#/) and ($key !~ /^CMD:/));
+
+ $error++;
+ if ($error == 5) {
+ &ERROR("rF: tried 5 times but failed.");
+ return;
+ }
+ }
&action($_, "Thinks: \037$key\037 is $val");
### FIXME: Use &getReply() on above to format factoid properly?
$good++;
sub chanlimitCheck {
my $interval = &getChanConfDefault("chanlimitcheckInterval", 10);
+ my $mynick=$conn->nick();
if (@_) {
&ScheduleThis($interval, "chanlimitCheck");
next;
}
- if (!exists $channels{$chan}{'o'}{$ident}) {
+ 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);
$cache{statusSafe} = 1;
foreach (sort keys %conns) {
$conn=$conns{$_};
+ my $mynick=$conn->nick();
&DEBUG("ircCheck for $_");
my @join = &getJoinChans(1);
if (scalar @join) {
} else {
&status('ircCheck: possible lost in space; checking.'.
scalar(gmtime) );
- &msg($ident, "TEST");
+ &msg($mynick, "TEST");
$cache{connect} = time();
}
}
sub uptimeLoop {
return if (!defined &uptimeWriteFile);
-# return unless &IsChanConf("uptime");
+# return unless &IsChanConf('Uptime');
if (@_) {
- &ScheduleThis(60, "uptimeLoop");
- return if ($_[0] eq "2"); # defer.
+ &ScheduleThis(60, 'uptimeLoop');
+ return if ($_[0] eq '2'); # defer.
}
&uptimeWriteFile();
sub slashdotLoop {
if (@_) {
- &ScheduleThis(60, "slashdotLoop");
+ &ScheduleThis(60, 'slashdotLoop');
return if ($_[0] eq "2");
}
- my @chans = &ChanConfList("slashdotAnnounce");
+ my @chans = &ChanConfList('slashdotAnnounce');
return unless (scalar @chans);
- &Forker("slashdot", sub {
+ &Forker('slashdot', sub {
my $line = &Slashdot::slashdotAnnounce();
return unless (defined $line);
sub plugLoop {
if (@_) {
- &ScheduleThis(60, "plugLoop");
+ &ScheduleThis(60, 'plugLoop');
return if ($_[0] eq "2");
}
- my @chans = &ChanConfList("plugAnnounce");
+ my @chans = &ChanConfList('plugAnnounce');
return unless (scalar @chans);
- &Forker("plug", sub {
+ &Forker('Plug', sub {
my $line = &Plug::plugAnnounce();
return unless (defined $line);
}
sub wingateCheck {
- return unless &IsChanConf("wingate");
+ return unless &IsChanConf('Wingate');
### FILE CACHE OF OFFENDING WINGATES.
foreach (grep /^$host$/, @wingateBad) {
&status("Wingate: RUNNING ON $host BY $who");
- &ban("*!*\@$host", "") if &IsChanConf("wingateBan");
+ &ban("*!*\@$host", "") if &IsChanConf('wingateBan');
- my $reason = &getChanConf("wingateKick");
+ my $reason = &getChanConf('wingateKick');
next unless ($reason);
&kick($who, "", $reason)
&DEBUG("Already scanned $host. good.");
}
- my $interval = &getChanConfDefault("wingateInterval", 60); # seconds.
- return if (defined $forked{'wingate'});
+ my $interval = &getChanConfDefault('wingateInterval', 60); # seconds.
+ return if (defined $forked{'Wingate'});
return if (time() - $wingaterun <= $interval);
return unless (scalar(keys %wingateToDo));
$wingaterun = time();
- &Forker("wingate", sub { &Wingate::Wingates(keys %wingateToDo); } );
+ &Forker('Wingate', sub { &Wingate::Wingates(keys %wingateToDo); } );
undef @wingateNow;
}
### TODO: ??
sub wingateWriteFile {
if (@_) {
- &ScheduleThis(60, "wingateWriteFile");
+ &ScheduleThis(60, 'wingateWriteFile');
return if ($_[0] eq "2"); # defer.
}
my $file = "$bot_base_dir/$param{'ircUser'}.wingate";
if ($bot_pid != $$) {
- &DEBUG("wingateWriteFile: Reorganising!");
+ &DEBUG('wingateWriteFile: Reorganising!');
open(IN, $file);
while (<IN>) {
@wingateNow = sort keys %hash;
}
- &DEBUG("wingateWF: writing...");
+ &DEBUG('wingateWF: writing...');
open(OUT, ">$file");
foreach (@wingateNow) {
print OUT "$_\n";
# b - weird time.
###
- &DEBUG("sched:");
- foreach (keys %{ $irc->{_queue} }) {
+ my $reply = "sched:";
+ foreach (keys %{ $irc->{_queue}}) {
my $q = $_;
-
+ my $coderef = $irc->{_queue}->{$q}->[1];
my $sched;
foreach (keys %sched) {
- next unless ($q eq $sched{$_});
- $sched = $_;
+ my $schedname = $_;
+ next unless defined(\&$schedname);
+ next unless ($coderef eq \&$schedname);
+ $sched = $schedname;
last;
}
my $time = $irc->{_queue}->{$q}->[0] - time();
if (defined $sched) {
- &DEBUG(" $sched($q): ".&Time2String($time) );
+ $reply = "$reply, $sched($q):" . &Time2String($time);
} else {
- &DEBUG(" NULL($q): ".&Time2String($time) );
+ $reply = "$reply, NULL($q):" . &Time2String($time);
}
}
- &DEBUG("end of sList.");
+ &DEBUG("$reply");
}
sub mkBackup {