From 9b0e692a8ffc40efd3d67cb0bfcd42fb7096e2c8 Mon Sep 17 00:00:00 2001 From: Elijah Perrault Date: Fri, 4 Mar 2011 21:48:21 -0700 Subject: [PATCH] Fixed a bug where incoming PART's from ourselves were not parsed. --- NEWS | 1 + doc/CHANGELOG | 1 + lib/API/IRC.pm | 2 -- lib/Proto/IRC.pm | 38 ++++++++++++++++++++++++-------------- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/NEWS b/NEWS index 01dcf82..0b5dbe4 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,7 @@ In this alpha7 release, we have added: Bug fixes: * Fixed a bug where a CAP entry for a network was not recreated on a reconnect. +* Fixed a bug where incoming PART's from ourselves were not parsed. Incompatibilities: diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 031e5c0..799f3ec 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log 3.0 Indev =============================================================================== + * Fixed a bug where incoming PART's from ourselves were not parsed. * Our usermodes are now tracked in Proto::IRC::umodes. * Added events on_cmode and on_umode. * Added event on_myinfo for RPL_MYINFO (numeric 004). diff --git a/lib/API/IRC.pm b/lib/API/IRC.pm index d779704..0e95ad3 100644 --- a/lib/API/IRC.pm +++ b/lib/API/IRC.pm @@ -69,8 +69,6 @@ sub cpart Auto::socksnd($svr, "PART $chan :Leaving"); } - if (defined $Proto::IRC::botchans{$svr}{$chan}) { delete $Proto::IRC::botchans{$svr}{$chan}; } - return 1; } diff --git a/lib/Proto/IRC.pm b/lib/Proto/IRC.pm index e8a3528..965aa50 100644 --- a/lib/Proto/IRC.pm +++ b/lib/Proto/IRC.pm @@ -38,7 +38,7 @@ our %RAWC = ( ); # Variables for various functions. -our (%got_001, %botinfo, %botchans, %csprefix, %chanusers, %chanmodes, %cap); +our (%got_001, %botinfo, %botchans, %csprefix, %chanusers, %chanmodes, %cap, %umodes); # Events. API::Std::event_add('on_capack'); @@ -54,6 +54,7 @@ API::Std::event_add('on_namesreply'); API::Std::event_add('on_nick'); API::Std::event_add('on_notice'); API::Std::event_add('on_part'); +API::Std::event_add('on_upart'); API::Std::event_add('on_cprivmsg'); API::Std::event_add('on_uprivmsg'); API::Std::event_add('on_quit'); @@ -597,23 +598,32 @@ sub part { my %src = API::IRC::usrc(substr($ex[0], 1)); $src{svr} = $svr; - - # Delete them from chanusers. - delete $chanusers{$svr}{$ex[2]}{$src{nick}} if defined $chanusers{$svr}{$ex[2]}{$src{nick}}; - # Set $msg to the part message. - my $msg = 0; - if (defined $ex[3]) { - $msg = substr($ex[3], 1); - if (defined $ex[4]) { - for (my $i = 4; $i < scalar(@ex); $i++) { - $msg .= " ".$ex[$i]; + # Check if it's from us or someone else. + if ($src{nick} eq $botinfo{$svr}{nick}) { + # Delete this channel from botchans. + if ($botchans{$svr}{$ex[2]}) { delete $botchans{$svr}{$ex[2]}; } + # Trigger on_upart. + API::Std::event_run('on_upart', ($svr, $ex[2])); + } + else { + # Delete them from chanusers. + delete $chanusers{$svr}{$ex[2]}{$src{nick}} if defined $chanusers{$svr}{$ex[2]}{$src{nick}}; + + # Set $msg to the part message. + my $msg = 0; + if (defined $ex[3]) { + $msg = substr($ex[3], 1); + if (defined $ex[4]) { + for (my $i = 4; $i < scalar(@ex); $i++) { + $msg .= " ".$ex[$i]; + } } } - } - # Trigger on_part. - API::Std::event_run("on_part", (\%src, $ex[2], $msg)); + # Trigger on_part. + API::Std::event_run("on_part", (\%src, $ex[2], $msg)); + } return 1; }