# 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);
if (my $i = scalar @join) {
&status("joinNextChan: $mynick $i chans to join.");
}
-
return;
}
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.
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'}++;
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 {
}
}
- 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{''}) {
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;
# 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;
&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 {
### 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 {