From 4938b29dc9bb07df288bb0b5bb5e545227b6e233 Mon Sep 17 00:00:00 2001 From: timriker Date: Sat, 27 Mar 2004 23:06:00 +0000 Subject: [PATCH] mynick git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@931 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/IRC/Irc.pl | 7 ++--- src/IRC/IrcHooks.pl | 12 ++++---- src/IRC/Schedulers.pl | 66 ++++++++++++++++++------------------------- 3 files changed, 35 insertions(+), 50 deletions(-) diff --git a/src/IRC/Irc.pl b/src/IRC/Irc.pl index 9a18748..5baabaf 100644 --- a/src/IRC/Irc.pl +++ b/src/IRC/Irc.pl @@ -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. diff --git a/src/IRC/IrcHooks.pl b/src/IRC/IrcHooks.pl index 01fc692..f3dcba7 100644 --- a/src/IRC/IrcHooks.pl +++ b/src/IRC/IrcHooks.pl @@ -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 { diff --git a/src/IRC/Schedulers.pl b/src/IRC/Schedulers.pl index f32f317..298b037 100644 --- a/src/IRC/Schedulers.pl +++ b/src/IRC/Schedulers.pl @@ -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 { -- 2.39.5