summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2016-01-10 10:52:46 +0100
committerYorhel <git@yorhel.nl>2016-01-10 10:52:46 +0100
commit48bbb8d0c3b121568c580dfd7c78f9dd0528cd8a (patch)
treec96ae4459d69f5031227eec1755db62dc4b224fd /lib
parent2a62230db34e26ea8c4182754470252b872131bd (diff)
Multi::IRC: Make sure we keep our nick
Diffstat (limited to 'lib')
-rw-r--r--lib/Multi/IRC.pm18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Multi/IRC.pm b/lib/Multi/IRC.pm
index f1096f08..d9101362 100644
--- a/lib/Multi/IRC.pm
+++ b/lib/Multi/IRC.pm
@@ -50,6 +50,7 @@ my %O = (
throt_sameid => [ 60, 0 ], # spamming the same vndbid
throt_vndbid => [ 5, 5 ], # spamming vndbids in general
throt_cmd => [ 10, 2 ], # handling commands from a single user
+ nick_check_interval => 600,
);
@@ -63,6 +64,23 @@ sub run {
set_quotew($_) for (0..$#{$O{channels}});
set_notify();
ircconnect();
+
+ # Watchdog to see if we still have our nick.
+ push_watcher schedule 0, $O{nick_check_interval}, sub {
+ return if !$irc->is_connected() || $irc->is_my_nick($O{nick});
+ $irc->send_msg(PRIVMSG => NickServ => "GHOST $O{nick} $O{pass}");
+ my $t; $t = AE::timer 5, 0, sub {
+ undef $t;
+ return if !$irc->is_connected() || $irc->is_my_nick($O{nick});
+ AE::log warn => 'Lost our nick, trying to reclaim.';
+ $irc->send_msg(NICK => $O{nick});
+ $t = AE::timer 5, 0, sub {
+ undef $t;
+ return if !$irc->is_connected() || !$irc->is_my_nick($O{nick});
+ $irc->send_msg(PRIVMSG => NickServ => "IDENTIFY $O{pass}");
+ };
+ };
+ } if $O{pass};
}