+}
+
+sub factoidCheck {
+ if (@_) {
+ &ScheduleThis(720, "factoidCheck");
+ return if ($_[0] eq "2"); # defer.
+ }
+
+ my @list = &searchTable("factoids", "factoid_key", "factoid_key", " #DEL#");
+ my $stale = &getChanConfDefault("factoidDeleteDelay", 14) *60*60*24;
+ if ($stale < 1) {
+ # disable it since it's "illegal".
+ return;
+ }
+
+ my $time = time();
+
+ foreach (@list) {
+ my $age = &getFactInfo($_, "modified_time");
+
+ if (!defined $age or $age !~ /^\d+$/) {
+ if (scalar @list > 50) {
+ if (!$cache{warnDel}) {
+ &WARN("list is over 50 (".scalar(@list)."... giving it a miss.");
+ $cache{warnDel} = 1;
+ last;
+ }
+ }
+
+ &WARN("del factoid: old cruft (no time): $_");
+ &delFactoid($_);
+ next;
+ }
+
+ next unless ($time - $age > $stale);
+
+ my $fix = $_;
+ $fix =~ s/ #DEL#$//g;
+ my $agestr = &Time2String($time - $age);
+ &status("safedel: Removing '$_' for good. [$agestr old]");
+
+ &delFactoid($_);
+ }
+}
+
+sub dccStatus {
+ return unless (scalar keys %{ $dcc{CHAT} });
+
+ if (@_) {
+ &ScheduleThis(10, "dccStatus");
+ return if ($_[0] eq "2"); # defer.
+ }
+
+ my $time = strftime("%H:%M", localtime(time()) );
+
+ my $c;
+ foreach (keys %channels) {
+ my $c = $_;
+ my $users = keys %{ $channels{$c}{''} };
+ my $chops = keys %{ $channels{$c}{o} };
+ my $bans = keys %{ $channels{$c}{b} };
+
+ my $txt = "[$time] $c: $users members ($chops chops), $bans bans";
+ foreach (keys %{ $dcc{'CHAT'} }) {
+ next unless (exists $channels{$c}{''}{lc $_});
+ $conn->privmsg($dcc{'CHAT'}{$_}, $txt);
+ }
+ }
+}
+
+sub scheduleList {
+ ###
+ # custom:
+ # a - time == now.
+ # b - weird time.
+ ###
+
+ &DEBUG("sched:");
+ foreach (keys %{ $irc->{_queue} }) {
+ my $q = $_;
+
+ my $sched;
+ foreach (keys %sched) {
+ next unless ($q eq $sched{$_});
+ $sched = $_;
+ last;
+ }
+
+ my $time = $irc->{_queue}->{$q}->[0] - time();
+
+ if (defined $sched) {
+ &DEBUG(" $sched($q): ".&Time2String($time) );
+ } else {
+ &DEBUG(" NULL($q): ".&Time2String($time) );
+ }
+ }
+
+ &DEBUG("end of sList.");
+}
+
+sub getChanConfDefault {
+ my($what, $default, $chan) = @_;
+
+ if (exists $param{$what}) {
+ if (!exists $cache{config}{$what}) {
+ &status("conf: backward-compat: found param{$what} ($param{$what}) instead.");
+ $cache{config}{$what} = 1;
+ }
+
+ return $param{$what};
+ }
+
+ my $val = &getChanConf($what, $chan);
+ if (defined $val) {
+ return $val;
+ }
+
+ $param{$what} = $default;
+ &status("conf: auto-setting param{$what} = $default");
+ $cache{config}{$what} = 1;
+
+ return $default;
+}
+
+sub mkBackup {
+ my($file, $time) = @_;
+ my $backup = 0;
+
+ if (! -f $file) {
+ &VERB("mkB: file '$file' does not exist.",2);
+ return;
+ }
+
+ my $age = "New";
+ if ( -e "$file~" ) {
+ $backup++ if ((stat $file)[9] - (stat "$file~")[9] > $time);
+ my $delta = time() - (stat "$file~")[9];
+ $age = &Time2String($delta);
+ } else {
+ $backup++;
+ }
+
+ return unless ($backup);