]> git.donarmstrong.com Git - infobot.git/commitdiff
More clean ups, forgotten what they were, heh.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 3 Apr 2001 12:06:08 +0000 (12:06 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 3 Apr 2001 12:06:08 +0000 (12:06 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@427 c11ca15a-4712-0410-83d8-924469b57eb5

src/DynaConfig.pl
src/IRC/IrcHooks.pl
src/IRC/Schedulers.pl
src/Modules/News.pl
src/modules.pl

index 2a78ebf249848e976c6579a2dacfd15f3d0e9185..d121937995b8280e1f10f5c9f1de2b3ac30cf895 100644 (file)
@@ -13,7 +13,18 @@ if (&IsParam("useStrict")) { use strict; }
 #####
 
 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;
@@ -96,6 +107,11 @@ sub readUserFile {
 }
 
 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;
@@ -200,7 +216,17 @@ sub writeUserFile {
 #####
 
 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;
     }
@@ -256,6 +282,11 @@ sub readChanFile {
 }
 
 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;
index 0fce62ed03aa2c61cb1d2f38daa1e9e535b6954c..006f106ad59d6d8af340c22e896fb171b23d4329 100644 (file)
@@ -359,6 +359,9 @@ sub on_endofnames {
 
     if (scalar @joinchan) {    # remaining channels to join.
        &joinNextChan();
+    } else {
+       &DEBUG("running ircCheck to get chanserv ops.");
+       &ircCheck();
     }
 
     return unless (&IsChanConf("chanServ_ops") > 0);
@@ -1222,8 +1225,8 @@ sub chanLimitVerify {
        ### 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) );
        }
     }
index 2abf5eaa6815b30f5bb019da243e9e4150402ff5..1bdba62e9e450fb9353b53b2aa2cda606966a034 100644 (file)
@@ -310,8 +310,8 @@ sub newsFlush {
 
            next unless (time() > $t);
            # todo: show how old it was.
-           &DEBUG("delete $chan/'$item'.");
            delete $::news{$chan}{$item};
+           &VERB("NEWS: deleted '$item'", 2);
            $delete++;
        }
     }
@@ -333,10 +333,10 @@ sub newsFlush {
        }
     }
 
-    &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 {
@@ -364,7 +364,7 @@ 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;
@@ -372,7 +372,7 @@ sub chanlimitCheck {
        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");
index c21799aa363bce36347936d41adf1eea397c1142..28ca58a933f417d3c6d1f9e57c819164b02f31ff 100644 (file)
@@ -11,7 +11,7 @@
 ### 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.
 ###
 
@@ -140,6 +140,7 @@ sub writeNews {
     # 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} };
@@ -163,11 +164,10 @@ sub writeNews {
     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++;
            }
@@ -204,11 +204,14 @@ sub add {
 
     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] "
     );
 }
 
@@ -297,8 +300,8 @@ sub list {
        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;
@@ -316,10 +319,9 @@ sub list {
                                $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 {
index d06ec19ce7c960a08843a112aed99d998c0bd68f..ee86c3817fef38e694fb188978b37e1b0c275360 100644 (file)
@@ -59,8 +59,6 @@ sub loadCoreModules {
        exit 1;
     }
 
-    &status("Loading CORE modules...");
-
     my @mods;
     while (defined(my $file = readdir DIR)) {
        next unless $file =~ /\.pl$/;
@@ -68,12 +66,11 @@ sub loadCoreModules {
        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 => $@");