From e50196505e05d4563e95bc154ef0942fe2da798a Mon Sep 17 00:00:00 2001 From: Janik Kleinhoff Date: Fri, 3 Apr 2015 21:30:35 +0400 Subject: modules/event.pl: track our own nick As it seems, Net::IRC changes its idea of what our nick is when we *try* to change nicks, not when the server acknowledges the change. This also means it'll miss nick changes not done via ->nick (such as /ns regain or ;sl NICK ...). Therefore we'll have to react to incoming NICK messages manually ... it's still not foolproof (because Net::IRC), but should fix some minor bugs with the bot suffering an identity crisis and acting strangely. Notably, this should hopefully fix the issue with having to ;sync a channel manually if it was ;join'ed while the bot didn't know its nick properly. Maybe it'll fix some other weird crap, too. --- modules/event.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/event.pl b/modules/event.pl index bbc56e1..b1876cd 100644 --- a/modules/event.pl +++ b/modules/event.pl @@ -496,6 +496,12 @@ sub on_nick { push ( @channels, $chan ); } } + + # unfortunately Net::IRC sucks at IRC so we have to implement this ourselves + if ($oldnick eq lc $conn->{_nick}) { + $conn->{_nick} = $event->{args}[0]; + } + $::sn{$newnick} = $::sn{$oldnick} if ($oldnick ne $newnick); $::db->logg( $event ); delete( $::sn{$oldnick}) if ($oldnick ne $newnick); -- cgit v1.2.3