2 # ProcessExtra.pl: Extensions to Process.pl
4 # Version: v0.5 (20010124)
8 if (&IsParam("useStrict")) { use strict; }
10 use POSIX qw(strftime);
14 &VERB("Starting schedulers...",2);
19 # 1 for run straight away, 2 for on next-run.
26 &netsplitCheck(1); # mandatory
27 &floodLoop(1); # mandatory
29 &leakCheck(2); # mandatory
30 &ignoreCheck(1); # mandatory
32 &ircCheck(1); # mandatory
33 &miscCheck(1); # mandatory
34 &shmFlush(1); # mandatory
42 # my $count = map { exists $sched{$_}{TIME} } keys %sched;
44 foreach (keys %sched) {
45 # next unless (exists $sched{$_}{TIME});
46 my $time = $sched{$_}{TIME};
47 next unless (defined $time and $time > time());
52 &status("Schedulers: $count will be running.");
57 my ($interval, $codename, @args) = @_;
58 my $waittime = &getRandomInt($interval);
60 if (!defined $waittime) {
61 &WARN("interval == waittime == UNDEF for $codename.");
65 my $time = $sched{$codename}{TIME};
66 if (defined $time and $time > time()) {
67 &WARN("Sched for $codename already exists.");
71 # &VERB("Scheduling \&$codename() for ".&Time2String($waittime),3);
73 my $retval = $conn->schedule($waittime, \&$codename, @args);
74 $sched{$codename}{LABEL} = $retval;
75 $sched{$codename}{TIME} = time()+$waittime;
76 $sched{$codename}{RUNNING} = 1;
80 #### LET THE FUN BEGIN.
84 my $interval = &getChanConfDefault("randomQuoteInterval", 60);
86 &ScheduleThis($interval, "randomQuote");
87 return if ($_[0] eq "2"); # defer.
89 delete $sched{"randomQuote"}{RUNNING};
92 my $line = &getRandomLineFromFile($bot_misc_dir. "/blootbot.randtext");
94 &ERROR("random Quote: weird error?");
98 foreach ( &ChanConfList("randomQuote") ) {
99 next unless (&validChan($_));
101 &status("sending random Quote to $_.");
102 &action($_, "Ponders: ".$line);
104 ### TODO: if there were no channels, don't reschedule until channel
105 ### configuration is modified.
112 my $interval = &getChanConfDefault("randomFactoidInterval", 60);
114 &ScheduleThis($interval, "randomFactoid");
115 return if ($_[0] eq "2"); # defer.
117 delete $sched{"randomFactoid"}{RUNNING};
121 ($key,$val) = &randKey("factoids","factoid_key,factoid_value");
122 ### $val =~ tr/^[A-Z]/[a-z]/; # blah is Good => blah is good.
123 last if ($val !~ /^</);
126 &ERROR("rF: tried 5 times but failed.");
131 foreach ( &ChanConfList("randomFactoid") ) {
132 next unless (&validChan($_));
134 &status("sending random Factoid to $_.");
135 &action($_, "Thinks: \037$key\037 is $val");
136 ### FIXME: Use &getReply() on above to format factoid properly?
141 sub randomFreshmeat {
142 my $interval = &getChanConfDefault("randomFresheatInterval", 60);
145 &ScheduleThis($interval, "randomFreshmeat");
146 return if ($_[0] eq "2"); # defer.
148 delete $sched{"randomFreshmeat"}{RUNNING};
151 my @chans = &ChanConfList("randomFreshmeat");
152 return unless (scalar @chans);
154 &Forker("freshmeat", sub {
155 my $retval = &Freshmeat::randPackage();
158 next unless (&validChan($_));
160 &status("sending random Freshmeat to $_.");
168 &ScheduleThis(60, "logLoop");
169 return if ($_[0] eq "2"); # defer.
171 delete $sched{"logLoop"}{RUNNING};
174 return unless (defined fileno LOG);
175 return unless (&IsParam("logfile"));
176 return unless (&IsParam("maxLogSize"));
178 ### check if current size is too large.
179 if ( -s $file{log} > $param{'maxLogSize'}) {
180 my $date = sprintf("%04d%02d%02d", (localtime)[5,4,3]);
181 $file{log} = $param{'logfile'} ."-". $date;
182 &status("cycling log file.");
184 if ( -e $file{log}) {
188 $newlog = $file{log}."-".$i;
189 last if (! -e $newlog);
192 $file{log} = $newlog;
196 CORE::system("/bin/mv '$param{'logfile'}' '$file{log}'");
197 &compress($file{log});
199 &status("cycling log file.");
202 ### check if all the logs exceed size.
203 my $logdir = "$bot_base_dir/log/";
204 if (opendir(LOGS, $logdir)) {
208 while (defined($_ = readdir LOGS)) {
209 my $logfile = "$logdir/$_";
211 next unless ( -f $logfile);
212 my $size = -s $logfile;
213 my $age = (stat $logfile)[9];
215 $age{$age} = $logfile;
216 $size{$logfile} = $size;
223 while ($tsize > $param{'maxLogSize'}) {
224 &status("LOG: current size > max ($tsize > $param{'maxLogSize'})");
225 my $oldest = (sort {$a <=> $b} keys %age)[0];
226 &status("LOG: unlinking $age{$oldest}.");
227 unlink $age{$oldest};
232 ### TODO: add how many b,kb,mb removed?
233 &status("LOG: removed $delete logs.") if ($delete);
235 &WARN("could not open dir $logdir");
242 &ScheduleThis(1440, "seenFlushOld");
243 return if ($_[0] eq "2"); # defer.
245 delete $sched{"seenFlushOld"}{RUNNING};
248 # is this global-only?
249 return unless (&IsChanConf("seen") > 0);
250 return unless (&IsChanConf("seenFlushInterval") > 0);
252 # global setting. does not make sense for per-channel.
253 my $max_time = &getChanConfDefault("seenMaxDays", 30) *60*60*24;
256 if ($param{'DBType'} =~ /^pg|postgres|mysql/i) {
257 my $query = "SELECT nick,time FROM seen GROUP BY nick HAVING UNIX_TIMESTAMP() - time > $max_time";
258 my $sth = $dbh->prepare($query);
261 while (my @row = $sth->fetchrow_array) {
262 my ($nick,$time) = @row;
264 &dbDel("seen","nick",$nick);
268 } elsif ($param{'DBType'} =~ /^dbm/i) {
271 foreach (keys %seen) {
272 my $delta_time = $time - &dbGet("seen", "NULL", $_, "time");
273 next unless ($delta_time > $max_time);
275 &DEBUG("seenFlushOld: ".&Time2String($delta_time) );
280 &FIXME("seenFlushOld: for PG/NO-DB.");
282 &VERB("SEEN deleted $delete seen entries.",2);
288 &ScheduleThis(1440, "newsFlush");
289 return if ($_[0] eq "2"); # defer.
291 delete $sched{"newsFlush"}{RUNNING};
294 return unless (&IsChanConf("news") > 0);
298 foreach $chan (keys %::news) {
299 foreach $item (keys %{ $::news{$chan} }) {
300 my $t = $::news{$chan}{$item}{Expire};
302 next if ($t == 0 or $t == -1);
304 &status("newsFlush: Fixed Expire time for $chan/$item, should not happen anyway.");
305 $::news{$chan}{$item}{Expire} = time() + $t*60*60*24;
309 $oldest = $t if ($t < $oldest);
311 next unless (time() > $t);
312 # todo: show how old it was.
313 &DEBUG("delete $chan/'$item'.");
314 delete $::news{$chan}{$item};
319 # todo: flush users aswell.
321 foreach $chan (keys %::newsuser) {
322 foreach (keys %{ $::newsuser{$chan} }) {
323 my $t = $::newsuser{$chan}{$_};
324 if (!defined $t or $t < 1000) {
325 &DEBUG("something wrong with newsuser{$chan}{$_} => $t");
329 next unless ($oldest > $t);
331 delete $::newsuser{$chan}{$_};
338 # &VERB("NEWS deleted $delete seen entries.",2);
339 &status("NEWS deleted $delete news entries; $duser user cache.");
343 my $interval = &getChanConfDefault("chanlimitcheckInterval", 10);
346 &ScheduleThis($interval, "chanlimitCheck");
347 return if ($_[0] eq "2");
349 delete $sched{"chanlimitCheck"}{RUNNING};
352 foreach $chan ( &ChanConfList("chanlimitcheck") ) {
353 next unless (&validChan($chan));
355 my $limitplus = &getChanConfDefault("chanlimitcheckPlus", 5, $chan);
356 my $newlimit = scalar(keys %{$channels{$chan}{''}}) + $limitplus;
357 my $limit = $channels{$chan}{'l'};
359 if (defined $limit and scalar keys %{$channels{$chan}{''}} > $limit) {
360 &FIXME("LIMIT: set too low!!! FIXME");
361 ### run NAMES again and flush it.
364 next unless (!defined $limit or $limit != $newlimit);
366 if (!exists $channels{$chan}{'o'}{$ident}) {
367 &ERROR("chanlimitcheck: dont have ops on $chan.") unless (exists $cache{warn}{chanlimit}{$chan});
368 $cache{warn}{chanlimit}{$chan} = 1;
369 ### TODO: check chanserv?
372 delete $cache{warn}{chanlimit}{$chan};
374 if (!defined $limit) {
375 &DEBUG("setting limit for first time or from netsplit for $chan");
378 &rawout("MODE $chan +l $newlimit");
386 &ScheduleThis(30, "netsplitCheck");
387 return if ($_[0] eq "2");
389 delete $sched{"netsplitCheck"}{RUNNING};
392 foreach $s1 (keys %netsplitservers) {
393 foreach $s2 (keys %{$netsplitservers{$s1}}) {
394 if (time() - $netsplitservers{$s1}{$s2} > 3600) {
395 &status("netsplit between $s1 and $s2 appears to be stale.");
396 delete $netsplitservers{$s1}{$s2};
401 # %netsplit hash checker.
402 my $count = scalar keys %netsplit;
403 foreach (keys %netsplit) {
404 if (&IsNickInAnyChan($_)) {
405 &DEBUG("netsplitC: $_ is in some chan; removing from netsplit list.");
406 delete $netsplit{$_};
408 next unless (time() - $netsplit{$_} > 60*10);
410 &DEBUG("netsplitC: $_ didn't come back from netsplit; removing from netsplit list.");
411 delete $netsplit{$_};
414 if ($count and !scalar keys %netsplit) {
415 &DEBUG("ok, netsplit is hopefully gone. reinstating chanlimit check.");
425 &ScheduleThis(60, "floodLoop"); # minutes.
426 return if ($_[0] eq "2");
428 delete $sched{"floodLoop"}{RUNNING};
432 my $interval = &getChanConfDefault("floodCycle",60);
434 foreach $who (keys %flood) {
435 foreach (keys %{$flood{$who}}) {
436 if (!exists $flood{$who}{$_}) {
437 &WARN("flood{$who}{$_} undefined?");
441 if ($time - $flood{$who}{$_} > $interval) {
442 delete $flood{$who}{$_};
447 &VERB("floodLoop: deleted $delete items.",2);
452 my $interval = &getChanConfDefault("seenFlushInterval", 60);
453 &ScheduleThis($interval, "seenFlush");
454 return if ($_[0] eq "2");
456 delete $sched{"seenFlush"}{RUNNING};
462 $stats{'count_old'} = &countKeys("seen") || 0;
466 if ($param{'DBType'} =~ /^mysql|pg|postgres/i) {
467 foreach $nick (keys %seencache) {
468 my $exists = &dbGet("seen","nick", $nick, "nick");
470 if (defined $exists and $exists) {
471 &dbUpdate("seen", "nick", $nick, (
472 "time" => $seencache{$nick}{'time'},
473 "host" => $seencache{$nick}{'host'},
474 "channel" => $seencache{$nick}{'chan'},
475 "message" => $seencache{$nick}{'msg'},
479 my $retval = &dbInsert("seen", $nick, (
480 "nick" => $seencache{$nick}{'nick'},
481 "time" => $seencache{$nick}{'time'},
482 "host" => $seencache{$nick}{'host'},
483 "channel" => $seencache{$nick}{'chan'},
484 "message" => $seencache{$nick}{'msg'},
488 ### TODO: put bad nick into a list and don't do it again!
489 &FIXME("Should never happen! (nick => $nick)") if !$retval;
492 delete $seencache{$nick};
496 } elsif ($param{'DBType'} =~ /^dbm/i) {
498 foreach $nick (keys %seencache) {
499 my $retval = &dbInsert("seen", $nick, (
500 "nick" => $seencache{$nick}{'nick'},
501 "time" => $seencache{$nick}{'time'},
502 "host" => $seencache{$nick}{'host'},
503 "channel" => $seencache{$nick}{'chan'},
504 "message" => $seencache{$nick}{'msg'},
507 ### TODO: put bad nick into a list and don't do it again!
508 &FIXME("Should never happen! (nick => $nick)") if !$retval;
510 delete $seencache{$nick};
514 &DEBUG("seenFlush: NO VALID FACTOID SUPPORT?");
517 &status("Flushed $flushed seen entries.") if ($flushed);
518 &VERB(sprintf(" new seen: %03.01f%% (%d/%d)",
519 $stats{'new'}*100/($stats{'count_old'} || 1),
520 $stats{'new'}, $stats{'count_old'} ), 2) if ($stats{'new'});
521 &VERB(sprintf(" now seen: %3.1f%% (%d/%d)",
522 $stats{'old'}*100/&countKeys("seen"),
523 $stats{'old'}, &countKeys("seen") ), 2) if ($stats{'old'});
525 &WARN("scalar keys seenflush != 0!") if (scalar keys %seenflush);
533 &ScheduleThis(240, "leakCheck");
534 return if ($_[0] eq "2");
536 delete $sched{"leakCheck"}{RUNNING};
540 foreach $blah1 (keys %flood) {
541 foreach $blah2 (keys %{$flood{$blah1}}) {
542 $count += scalar(keys %{$flood{$blah1}{$blah2}});
545 &VERB("\%flood has $count total keys.",2);
548 foreach $chan (grep /[A-Z]/, keys %channels) {
549 &DEBUG("leak: chan => '$chan'.");
551 foreach $i (keys %{$channels{$chan}}) {
552 foreach (keys %{$channels{$chan}{$i}}) {
553 &DEBUG("leak: \$channels{$chan}{$i}{$_} ...");
559 foreach (keys %nuh) {
560 next if (&IsNickInAnyChan($_));
561 next if (exists $dcc{CHAT}{$_});
567 &status("leakC: $delete nuh{} items deleted; now have ".
568 scalar(keys %nuh) ) if ($delete);
573 &ScheduleThis(60, "ignoreCheck");
574 return if ($_[0] eq "2"); # defer.
576 delete $sched{"ignoreCheck"}{RUNNING};
582 foreach (keys %ignore) {
585 foreach (keys %{ $ignore{$chan} }) {
586 my @array = @{ $ignore{$chan}{$_} };
588 next unless ($array[0] and $time > $array[0]);
590 delete $ignore{$chan}{$_};
591 &status("ignore: $_/$chan has expired.");
595 &VERB("ignore: $count items deleted.",2);
601 &ScheduleThis(60, "ircCheck");
602 return if ($_[0] eq "2"); # defer.
604 delete $sched{"ircCheck"}{RUNNING};
607 my @array = grep !/^_default$/, keys %chanconf;
608 my $iconf = scalar(@array);
609 my $inow = scalar(keys %channels);
610 if ($iconf > 2 and $inow * 2 <= $iconf) {
611 &FIXME("ircCheck: current channels * 2 <= config channels. FIXME.");
615 foreach ( &ChanConfList("chanServ_ops") ) {
616 next if (exists $channels{$chan}{'o'}{$ident});
618 &status("ChanServ ==> Requesting ops for $chan.");
619 &rawout("PRIVMSG ChanServ :OP $chan $ident");
622 if (!$conn->connected or time - $msgtime > 3600) {
623 # todo: shouldn't we use cache{connect} somewhere?
624 if (exists $cache{connect}) {
625 &WARN("ircCheck: no msg for 3600 and disco'd! reconnecting!");
626 $msgtime = time(); # just in case.
628 delete $cache{connect};
630 &DEBUG("possible lost in space; checking.");
631 &msg($ident, "TEST");
632 $cache{connect} = time();
636 if ($ident !~ /^\Q$param{ircNick}\E$/) {
637 &WARN("ircCheck: ident($ident) != param{ircNick}($param{IrcNick}).");
638 if (! &IsNickInAnyChan( $param{ircNick} ) ) {
639 &DEBUG("$param{ircNick} not in use... changing!");
640 &nick( $param{ircNick} );
642 &WARN("$param{ircNick} is still in use...");
647 # if scalar @joinnext => join more channels
648 # else check for chanserv.
650 if (grep /^\s*$/, keys %channels) {
651 &WARN("we have a NULL chan in hash channels? removing!");
652 delete $channels{''};
654 &DEBUG("channels now:");
655 foreach (keys %channels) {
659 &DEBUG("channels END");
663 if ($utime_userfile > $wtime_userfile and time() - $wtime_userfile > 3600) {
665 $wtime_userfile = time();
668 if ($utime_chanfile > $wtime_chanfile and time() - $wtime_chanfile > 3600) {
670 $wtime_chanfile = time();
676 &ScheduleThis(240, "miscCheck");
677 return if ($_[0] eq "2"); # defer.
679 delete $sched{"miscCheck"}{RUNNING};
684 if ( -x "/usr/bin/ipcs") {
685 @ipcs = `/usr/bin/ipcs`;
687 &WARN("ircCheck: no 'ipcs' binary.");
691 # shmid stale remove.
695 # key, shmid, owner, perms, bytes, nattch
696 next unless (/^(0x\d+) (\d+)\s+(\S+)\s+(\d+)\s+(\d+)\s+/);
698 my ($shmid, $size) = ($2,$5);
699 next unless ($shmid != $shm and $size == 2000);
700 my $z = &shmRead($shmid);
701 if ($z =~ /^(\d+): /) {
703 next if (time() - $time < 60*60);
706 &DEBUG("shm: $shmid is not ours or old blootbot => ($z)");
710 &status("SHM: nuking shmid $shmid");
711 CORE::system("/usr/bin/ipcrm shm $shmid >/dev/null");
715 opendir(DEBIAN, "$bot_base_dir/debian");
716 foreach ( grep /gz$/, readdir(DEBIAN) ) {
717 my $exit = CORE::system("gzip -t $bot_base_dir/debian/$_");
720 &status("debian: unlinking file => $_");
721 unlink "$bot_base_dir/debian/$_";
725 # user/chan file check.
726 foreach ("chan","users") {
727 my $f = $bot_misc_dir."/blootbot.$_";
731 $backup++ if ( -s $f > -s "$f~");
732 $backup++ if ( (stat $f)[9] - (stat "$f~")[9] > 60*60*24*7);
736 next unless ($backup);
738 ### TODO: do internal copying.
739 &status("Backup: $f to $f~");
740 CORE::system("/bin/cp $f $f~");
743 # flush cache{lobotomy}
744 foreach (keys %{ $cache{lobotomy} }) {
745 next unless (time() - $cache{lobotomy}{$_} > 60*60);
746 delete $cache{lobotomy}{$_};
749 ### check modules if they've been modified. might be evil.
754 return if ($$ != $::bot_pid); # fork protection.
757 &ScheduleThis(5, "shmFlush");
758 return if ($_[0] eq "2");
760 delete $sched{"shmFlush"}{RUNNING};
764 my $shmmsg = &shmRead($shm);
765 $shmmsg =~ s/\0//g; # remove padded \0's.
766 if ($shmmsg =~ s/^(\d+): //) {
770 foreach (split '\|\|', $shmmsg) {
772 &VERB("shm: Processing '$_'.",2);
774 if (/^DCC SEND (\S+) (\S+)$/) {
775 my ($nick,$file) = ($1,$2);
776 if (exists $dcc{'SEND'}{$who}) {
777 &msg($nick, "DCC already active.");
779 &DEBUG("shm: dcc sending $2 to $1.");
780 $conn->new_send($1,$2);
781 $dcc{'SEND'}{$who} = time();
783 } elsif (/^SET FORKPID (\S+) (\S+)/) {
784 $forked{$1}{PID} = $2;
785 } elsif (/^DELETE FORK (\S+)$/) {
787 } elsif (/^EVAL (.*)$/) {
788 &DEBUG("evaling '$1'.");
791 &DEBUG("shm: unknown msg. ($_)");
795 &shmWrite($shm,"") if ($shmmsg ne "");
798 ### this is semi-scheduled
801 &ScheduleThis(30, "getNickInUse");
802 return if ($_[0] eq "2"); # defer.
804 delete $sched{"getNickInUse"}{RUNNING};
807 if ($ident eq $param{'ircNick'}) {
808 &status("okay, got my nick back.");
812 &status("Trying to get my nick back.");
813 &nick( $param{'ircNick'} );
817 return unless &IsChanConf("uptime");
820 &ScheduleThis(60, "uptimeLoop");
821 return if ($_[0] eq "2"); # defer.
823 delete $sched{"uptimeLoop"}{RUNNING};
832 &ScheduleThis(60, "slashdotLoop");
833 return if ($_[0] eq "2");
835 delete $sched{"slashdotLoop"}{RUNNING};
838 my @chans = &ChanConfList("slashdotAnnounce");
839 return unless (scalar @chans);
841 &Forker("slashdot", sub {
842 my $line = &Slashdot::slashdotAnnounce();
843 return unless (defined $line);
846 next unless (&::validChan($_));
848 &::status("sending slashdot update to $_.");
849 ¬ice($_, "Slashdot: $line");
856 &ScheduleThis(60, "freshmeatLoop");
857 return if ($_[0] eq "2");
859 delete $sched{"freshmeatLoop"}{RUNNING};
862 my @chans = &ChanConfList("freshmeatAnnounce");
863 return unless (scalar @chans);
865 &Forker("freshmeat", sub {
866 my $data = &Freshmeat::freshmeatAnnounce();
869 next unless (&::validChan($_));
871 &::status("sending freshmeat update to $_.");
879 &ScheduleThis(240, "kernelLoop");
880 return if ($_[0] eq "2");
882 delete $sched{"kernelLoop"}{RUNNING};
885 my @chans = &ChanConfList("kernelAnnounce");
886 return unless (scalar @chans);
888 &Forker("kernel", sub {
889 my @data = &Kernel::kernelAnnounce();
892 next unless (&::validChan($_));
894 &::status("sending kernel update to $_.");
897 ¬ice($c, "Kernel: $_");
904 return unless &IsChanConf("wingate");
906 ### FILE CACHE OF OFFENDING WINGATES.
907 foreach (grep /^$host$/, @wingateBad) {
908 &status("Wingate: RUNNING ON $host BY $who");
909 &ban("*!*\@$host", "") if &IsChanConf("wingateBan");
911 my $reason = &getChanConf("wingateKick");
913 next unless ($reason);
914 &kick($who, "", $reason)
917 ### RUN CACHE OF TRIED WINGATES.
918 if (grep /^$host$/, @wingateCache) {
919 push(@wingateNow, $host); # per run.
920 push(@wingateCache, $host); # cache per run.
922 &DEBUG("Already scanned $host. good.");
925 my $interval = &getChanConfDefault("wingateInterval", 60); # seconds.
926 return if (defined $forked{'wingate'});
927 return if (time() - $wingaterun <= $interval);
928 return unless (scalar(keys %wingateToDo));
930 $wingaterun = time();
932 &Forker("wingate", sub { &Wingate::Wingates(keys %wingateToDo); } );
937 sub wingateWriteFile {
939 &ScheduleThis(60, "wingateWriteFile");
940 return if ($_[0] eq "2"); # defer.
942 delete $sched{"wingateWriteFile"}{RUNNING};
945 return unless (scalar @wingateCache);
947 my $file = "$bot_base_dir/$param{'ircUser'}.wingate";
948 if ($bot_pid != $$) {
949 &DEBUG("wingateWriteFile: Reorganising!");
954 push(@wingateNow, $_);
959 my %hash = map { $_ => 1 } @wingateNow;
960 @wingateNow = sort keys %hash;
963 &DEBUG("wingateWF: writing...");
965 foreach (@wingateNow) {
974 &ScheduleThis(1440, "factoidCheck");
975 return if ($_[0] eq "2"); # defer.
977 delete $sched{"factoidCheck"}{RUNNING};
980 my @list = &searchTable("factoids", "factoid_key", "factoid_key", " #DEL#");
981 my $stale = &getChanConfDefault("factoidDeleteDelay", 30) *60*60*24;
985 my $age = &getFactInfo($_, "modified_time");
986 if (!defined $age or $age !~ /^\d+$/) {
987 &WARN("age == NULL or not numeric.");
991 next unless ($time - $age > $stale);
994 $fix =~ s/ #DEL#$//g;
995 &DEBUG("safedel: Removing $fix ($_) for good.");
1003 return unless (scalar keys %{ $dcc{CHAT} });
1006 &ScheduleThis(10, "dccStatus");
1007 return if ($_[0] eq "2"); # defer.
1009 delete $sched{"dccStatus"}{RUNNING};
1012 my $time = strftime("%H:%M", localtime(time()) );
1015 foreach (keys %channels) {
1017 my $users = keys %{ $channels{$c}{''} };
1018 my $chops = keys %{ $channels{$c}{o} };
1019 my $bans = keys %{ $channels{$c}{b} };
1021 my $txt = "[$time] $c: $users members ($chops chops), $bans bans";
1022 foreach (keys %{ $dcc{'CHAT'} }) {
1023 next unless (exists $channels{$c}{''}{lc $_});
1024 $conn->privmsg($dcc{'CHAT'}{$_}, $txt);
1037 foreach (keys %{ $irc->{_queue} }) {
1041 foreach (keys %sched) {
1042 next unless ($q eq $sched{$_});
1047 my $time = $irc->{_queue}->{$q}->[0] - time();
1049 if (defined $sched) {
1050 &DEBUG(" $sched($q): ".&Time2String($time) );
1052 &DEBUG(" NULL($q): ".&Time2String($time) );
1056 &DEBUG("end of sList.");
1059 sub getChanConfDefault {
1060 my($what, $default, $chan) = @_;
1062 if (exists $param{$what}) {
1063 if (!exists $cache{config}{$what}) {
1064 &status("conf: backward-compat: found param{$what} ($param{$what}) instead.");
1065 $cache{config}{$what} = 1;
1068 return $param{$what};
1071 my $val = &getChanConf($what, $chan);
1076 $param{$what} = $default;
1077 &status("conf: auto-setting param{$what} = $default");
1078 $cache{config}{$what} = 1;