]> git.donarmstrong.com Git - infobot.git/blobdiff - src/IRC/Schedulers.pl
* Fix NULL chan being created in %channels
[infobot.git] / src / IRC / Schedulers.pl
index a59c939c7a8e5e3d591f6ea443b009d0b1d44ca1..2e6bc8f877589260222b2b2595218b3e598c114e 100644 (file)
@@ -134,7 +134,7 @@ sub randomQuote {
     foreach ( &ChanConfList('randomQuote') ) {
        next unless (&validChan($_));
 
-       my $line = &getRandomLineFromFile($bot_data_dir. "/blootbot.randtext");
+       my $line = &getRandomLineFromFile($bot_data_dir. "/infobot.randtext");
        if (!defined $line) {
            &ERROR("random Quote: weird error?");
            return;
@@ -489,9 +489,10 @@ sub netsplitCheck {
     }
 
     # yet another hack.
-    foreach (keys %channels) {
-       my $i = $cache{maxpeeps}{$chan} || 0;
-       my $j = scalar(keys %{ $channels{$chan} });
+    # FIXED: $ch should be used rather than $chan since it creates NULL channels in the hash
+    foreach my $ch (keys %channels) {
+       my $i = $cache{maxpeeps}{$ch} || 0;
+       my $j = scalar(keys %{ $channels{$ch} });
        next unless ($i > 10 and 0.25*$i > $j);
 
        &DEBUG("netsplit: 0.25*max($i) > current($j); possible netsplit?");
@@ -702,14 +703,24 @@ sub ircCheck {
                $cache{connect} = time();
            }
        }
+    }
 
-       if (grep /^\s*$/, keys %channels) {
-           &WARN('ircCheck: we have a NULL chan in hash channels? removing!');
-           if (!exists $channels{''}) {
-               &DEBUG('ircCheck: this should never happen!');
-           }
-
-           delete $channels{''};
+        if (grep /^\s*$/, keys %channels) {
+            &WARN('ircCheck: we have a NULL chan in hash channels? removing!');
+            if (!exists $channels{''}) {
+                &DEBUG('ircCheck: this should never happen!');
+            }
+       }
+     if ($ident !~ /^\Q$param{ircNick}\E$/) {
+       # this does not work unfortunately.
+       &WARN("ircCheck: ident($ident) != param{ircNick}($param{ircNick}).");
+
+       # this check is misleading... perhaps we should do a notify.
+       if (! &IsNickInAnyChan( $param{ircNick} ) ) {
+           &DEBUG("$param{ircNick} not in use... changing!");
+           &nick( $param{ircNick} );
+       } else {
+           &WARN("$param{ircNick} is still in use...");
        }
     }
 
@@ -743,9 +754,9 @@ sub miscCheck {
     }
 
     # make backup of important files.
-    &mkBackup( $bot_state_dir."/blootbot.chan", 60*60*24*3);
-    &mkBackup( $bot_state_dir."/blootbot.users", 60*60*24*3);
-    &mkBackup( $bot_base_dir."/blootbot-news.txt", 60*60*24*1);
+    &mkBackup( $bot_state_dir."/infobot.chan", 60*60*24*3);
+    &mkBackup( $bot_state_dir."/infobot.users", 60*60*24*3);
+    &mkBackup( $bot_base_dir."/infobot-news.txt", 60*60*24*1);
 
     # flush cache{lobotomy}
     foreach (keys %{ $cache{lobotomy} }) {
@@ -776,7 +787,7 @@ sub miscCheck {
            # don't touch other bots, if they're running.
            next unless ($param{ircUser} =~ /^\Q$n\E$/);
        } else {
-           &DEBUG("shm: $shmid is not ours or old blootbot => ($z)");
+           &DEBUG("shm: $shmid is not ours or old infobot => ($z)");
            next;
        }