]> git.donarmstrong.com Git - infobot.git/commitdiff
mynick
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 27 Mar 2004 23:06:00 +0000 (23:06 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 27 Mar 2004 23:06:00 +0000 (23:06 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@931 c11ca15a-4712-0410-83d8-924469b57eb5

src/IRC/Irc.pl
src/IRC/IrcHooks.pl
src/IRC/Schedulers.pl

index 9a1874858f10a6a9a085fbb1782bb684eafe8a63..5baabaf4525804bae537e62ccfc17c3d9b9683ed 100644 (file)
@@ -663,10 +663,10 @@ sub invite {
 
 # Usage: &joinNextChan();
 sub joinNextChan {
-    my @join = getJoinChans(1);
     my $mynick = "UNDEF";
-
     $mynick = $conn->nick() if $conn;
+    my @join = getJoinChans(1);
+
     if (scalar @join) {
        my $chan = shift @join;
        &joinchan($chan);
@@ -674,7 +674,6 @@ sub joinNextChan {
        if (my $i = scalar @join) {
            &status("joinNextChan: $mynick $i chans to join.");
        }
-
        return;
     }
 
@@ -686,7 +685,7 @@ sub joinNextChan {
        my $rate        = sprintf("%.1f", $delta / 10);
        delete $cache{joinTime};
 
-       &status("time taken to join all chans: $timestr; rate: $rate sec/join");
+       &status("time taken for $mynick to join all chans: $timestr; rate: $rate sec/join");
     }
 
     # chanserv check: global channels, in case we missed one.
index 01fc6926ffee7f9b968b7a070bcbc70cd6d827fb..f3dcba71a8a99d635aa7d53651578db8416ab74a 100644 (file)
@@ -365,8 +365,9 @@ sub on_disconnect {
     my ($event) = @_;
     my $from = $event->from();
     my $what = ($event->args)[0];
+    my $mynick=$conn->nick();
 
-    &status("disconnect from $from ($what).");
+    &status("$mynick disconnect from $from ($what).");
     $ircstats{'DisconnectTime'}                = time();
     $ircstats{'DisconnectReason'}      = $what;
     $ircstats{'DisconnectCount'}++;
@@ -385,12 +386,9 @@ sub on_disconnect {
        return;
     }
 
-    if (!$conn->connect()) {
-       &DEBUG("on_disconnect: 3");
-       &WARN("not connected? help me. gonna call ircCheck() in 60s");
-       &clearIRCVars();
-       &ScheduleThis(1, "ircCheck");
-    }
+    &WARN("scheduling call ircCheck() in 60s");
+    &clearIRCVars();
+    &ScheduleThis(1, "ircCheck");
 }
 
 sub on_endofnames {
index f32f3170dba432703cfa6e861b1775d6d1787d3a..298b0371816ddd51800458a126ac8e1ae0a6faff 100644 (file)
@@ -697,19 +697,6 @@ sub ircCheck {
        }
     }
 
-    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...");
-       }
-    }
-
     if (grep /^\s*$/, keys %channels) {
        &WARN('ircCheck: we have a NULL chan in hash channels? removing!');
        if (!exists $channels{''}) {
@@ -748,6 +735,20 @@ sub miscCheck {
        return;
     }
 
+    # 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);
+
+    # flush cache{lobotomy}
+    foreach (keys %{ $cache{lobotomy} }) {
+       next unless (time() - $cache{lobotomy}{$_} > 60*60);
+       delete $cache{lobotomy}{$_};
+    }
+
+    ### check modules if they've been modified. might be evil.
+    &reloadAllModules();
+
     # shmid stale remove.
     foreach (@ipcs) {
        chop;
@@ -766,7 +767,7 @@ sub miscCheck {
            # FIXME remove not-pid shm if parent process dead
            next if ($pid == $bot_pid);
            # don't touch other bots, if they're running.
-           next unless ($param{ircNick} =~ /^\Q$n\E$/);
+           next unless ($param{ircUser} =~ /^\Q$n\E$/);
        } else {
            &DEBUG("shm: $shmid is not ours or old blootbot => ($z)");
            next;
@@ -775,20 +776,6 @@ sub miscCheck {
        &status("SHM: nuking shmid $shmid");
        CORE::system("/usr/bin/ipcrm shm $shmid >/dev/null");
     }
-
-    # 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);
-
-    # flush cache{lobotomy}
-    foreach (keys %{ $cache{lobotomy} }) {
-       next unless (time() - $cache{lobotomy}{$_} > 60*60);
-       delete $cache{lobotomy}{$_};
-    }
-
-    ### check modules if they've been modified. might be evil.
-    &reloadAllModules();
 }
 
 sub miscCheck2 {
@@ -832,17 +819,18 @@ sub miscCheck2 {
 
 ### this is semi-scheduled
 sub getNickInUse {
-    if ($ident eq $param{'ircNick'}) {
-       &status("okay, got my nick back.");
-       return;
-    }
-
-    if (@_) {
-       &ScheduleThis(30, "getNickInUse");
-       return if ($_[0] eq "2");       # defer.
-    }
-
-    &nick( $param{'ircNick'} );
+# FIXME: broken for multiple connects
+#    if ($ident eq $param{'ircNick'}) {
+#      &status("okay, got my nick back.");
+#      return;
+#    }
+#
+#    if (@_) {
+#      &ScheduleThis(30, "getNickInUse");
+#      return if ($_[0] eq "2");       # defer.
+#    }
+#
+#    &nick( $param{'ircNick'} );
 }
 
 sub uptimeLoop {