#####
sub readUserFile {
- if (!open IN,"$bot_misc_dir/blootbot.users") {
+ my $f = "$bot_misc_dir/blootbot.users";
+
+ if ( -f $f and -f "$f~") {
+ my $s1 = -s $f;
+ my $s2 = -s "$f~";
+
+ if ($s2 > $s1*3) {
+ &DEBUG("rUF: backup file bigger than current file. FIXME");
+ }
+ }
+
+ if (!open IN, $f) {
&ERROR("cannot read userfile.");
&closeLog();
exit 1;
}
sub writeUserFile {
+ if (!scalar keys %users) {
+ &DEBUG("wUF: nothing to write.");
+ return;
+ }
+
if (!open OUT,">$bot_misc_dir/blootbot.users") {
&ERROR("cannot write to userfile.");
return;
#####
sub readChanFile {
- if (!open IN,"$bot_misc_dir/blootbot.chan") {
+ my $f = "$bot_misc_dir/blootbot.chan";
+ if ( -f $f and -f "$f~") {
+ my $s1 = -s $f;
+ my $s2 = -s "$f~";
+
+ if ($s2 > $s1*3) {
+ &DEBUG("rCF: backup file bigger than current file. FIXME");
+ }
+ }
+
+ if (!open IN, $f) {
&ERROR("cannot erad chanfile.");
return;
}
}
sub writeChanFile {
+ if (!scalar keys %chanconf) {
+ &DEBUG("wCF: nothing to write.");
+ return;
+ }
+
if (!open OUT,">$bot_misc_dir/blootbot.chan") {
&ERROR("cannot write chanfile.");
return;
if (scalar @joinchan) { # remaining channels to join.
&joinNextChan();
+ } else {
+ &DEBUG("running ircCheck to get chanserv ops.");
+ &ircCheck();
}
return unless (&IsChanConf("chanServ_ops") > 0);
### todo: check if we have ops.
### todo: if not, check if nickserv/chanserv is avail.
### todo: unify code with chanlimitcheck()
- if ($delta > 3) {
- &WARN("clc: nowl($nowl) > l($l) - 3");
+ if ($delta > 5) {
+ &status("clc: big change in limit; changing.");
&rawout("MODE $chan +l ".($nowl+$plus) );
}
}
next unless (time() > $t);
# todo: show how old it was.
- &DEBUG("delete $chan/'$item'.");
delete $::news{$chan}{$item};
+ &VERB("NEWS: deleted '$item'", 2);
$delete++;
}
}
}
}
- &News::writeNews();
-
# &VERB("NEWS deleted $delete seen entries.",2);
- &status("NEWS deleted $delete news entries; $duser user cache.");
+ &status("NEWS deleted: $delete news entries; $duser user cache.");
+
+ &News::writeNews();
}
sub chanlimitCheck {
next unless (!defined $limit or $limit != $newlimit);
if (!exists $channels{$chan}{'o'}{$ident}) {
- &ERROR("chanlimitcheck: dont have ops on $chan.") unless (exists $cache{warn}{chanlimit}{$chan});
+ &status("ChanLimit: dont have ops on $chan.") unless (exists $cache{warn}{chanlimit}{$chan});
$cache{warn}{chanlimit}{$chan} = 1;
### TODO: check chanserv?
next;
delete $cache{warn}{chanlimit}{$chan};
if (!defined $limit) {
- &DEBUG("setting limit for first time or from netsplit for $chan");
+ &status("ChanLimit: setting for first time or from netsplit, for $chan");
}
&rawout("MODE $chan +l $newlimit");
### where items is:
# Time - when it was added (used for sorting)
# Author - Who by.
-# Expire - Time to expire
+# Expire - Time to expire.
# Text - Actual text.
###
# todo: add commands to output file.
my $c = 0;
my($cc,$ci,$cu) = (0,0,0);
+
open(NEWS, ">$file");
foreach $chan (sort keys %::news) {
$c = scalar keys %{ $::news{$chan} };
if (&::getChanConfList("newsKeepRead")) {
# old users are removed in newsFlush(), perhaps it should be
# done here.
- &::DEBUG("newsuser cache...");
+
foreach $chan (sort keys %::newsuser) {
- &::DEBUG("newsuser cache: chan => $chan");
+
foreach (sort keys %{ $::newsuser{$chan} }) {
- &::DEBUG("newsuser cache: user => $_");
print NEWS "U $chan $_ $::newsuser{$chan}{$_}\n";
$cu++;
}
my $agestr = &::Time2String($::news{$chan}{$str}{Expire} - time() );
my $item = &getNewsItem($str);
+ if ($item eq $str) {
+ &::DEBUG("item eq str ($item): should never happen.");
+ }
&::msg($::who, "Added '\037$str\037' at [".localtime(time).
"] by \002$::who\002 for item #\002$item\002.");
&::msg($::who, "Now do 'news text $item <your_description>'");
&::msg($::who, "This item will expire at \002".
- localtime($::news{$chan}{$str}{Expire})."\002 [$agestr] "
+ localtime($::news{$chan}{$str}{Expire})."\002 [$agestr from now] "
);
}
my $t = $::news{$chan}{$_}{Time};
$newest = $t if ($t > $newest);
}
- &::msg($::who, "|= Last updated ".
- &::Time2String(time() - $newest). " ago.");
+ my $timestr = &::Time2String(time() - $newest);
+ &::msg($::who, "|= Last updated $timestr ago.");
&::msg($::who, " \037No\037 \037Item ".(" "x40)." \037");
my $i = 1;
$i, $subtopic));
$i++;
}
+
&::msg($::who, "|= End of News.");
&::msg($::who, "use 'news read <#>' or 'news read <keyword>'");
-
- &::DEBUG("news cache => ".scalar(keys %::newsuser) );
}
sub read {
exit 1;
}
- &status("Loading CORE modules...");
-
my @mods;
while (defined(my $file = readdir DIR)) {
next unless $file =~ /\.pl$/;
push(@mods, $file);
}
closedir DIR;
- &DEBUG("mods: ".scalar(@mods)." to be loaded...");
+ &status("Loading ".scalar(@mods)." CORE modules...");
foreach (sort @mods) {
my $mod = "$bot_src_dir/$_";
- ### TODO: use eval and exit gracefully?
eval "require \"$mod\"";
if ($@) {
&ERROR("lCM => $@");