diff --git a/doc/CHANGELOG b/doc/CHANGELOG index dc1a1f0..a2b8373 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -4,6 +4,7 @@ Auto IRC Bot 3.0: Change Log 3.0 Indev =============================================================================== * Fixed the arguments on_whoreply passes. + * Changed on_nick, on_quit, on_part, and on_kick source hashrefs to include server, removing svr. 3.0 Alpha 6 =============================================================================== diff --git a/lib/Core/IRC.pm b/lib/Core/IRC.pm index 7e53e1e..9c6a714 100644 --- a/lib/Core/IRC.pm +++ b/lib/Core/IRC.pm @@ -28,12 +28,12 @@ hook_add("on_uprivmsg", "ctcp_version_reply", sub { # QUIT hook; delete user from chanusers. hook_add("on_quit", "quit_update_chanusers", sub { - my (($svr, $src, undef)) = @_; + my (($src, undef)) = @_; my %src = %{ $src }; # Delete the user from all channels. - foreach my $ccu (keys %{ $Proto::IRC::chanusers{$svr} }) { - if (defined $Proto::IRC::chanusers{$svr}{$ccu}{$src{nick}}) { delete $Proto::IRC::chanusers{$svr}{$ccu}{$src{nick}}; } + foreach my $ccu (keys %{ $Proto::IRC::chanusers{$src{svr}}}) { + if (defined $Proto::IRC::chanusers{$src{svr}}{$ccu}{$src{nick}}) { delete $Proto::IRC::chanusers{$src{svr}}{$ccu}{$src{nick}}; } } return 1; diff --git a/lib/Proto/IRC.pm b/lib/Proto/IRC.pm index 386a49d..d12092f 100644 --- a/lib/Proto/IRC.pm +++ b/lib/Proto/IRC.pm @@ -386,7 +386,9 @@ sub cjoin { # Parse: KICK sub kick { my ($svr, @ex) = @_; + my %src = API::IRC::usrc(substr($ex[0], 1)); + $src{svr} = $svr; # Update chanusers. delete $chanusers{$svr}{$ex[2]}{$ex[3]} if defined $chanusers{$svr}{$ex[2]}{$ex[3]}; @@ -422,7 +424,7 @@ sub kick { else { # We weren't. Update chanusers and trigger on_kick. if (defined $chanusers{$svr}{$ex[2]}{$ex[3]}) { delete $chanusers{$svr}{$ex[2]}{$ex[3]}; } - API::Std::event_run("on_kick", ($svr, \%src, $ex[2], $ex[3], $msg)); + API::Std::event_run("on_kick", (\%src, $ex[2], $ex[3], $msg)); } return 1; @@ -523,7 +525,8 @@ sub nick { $nex =~ s/^://gxsm; my %src = API::IRC::usrc(substr($uex, 1)); - + $src{svr} = $svr; + # Check if this is coming from ourselves. if ($src{nick} eq $botinfo{$svr}{nick}) { # It is. Update bot nick hash. @@ -538,7 +541,7 @@ sub nick { delete $chanusers{$svr}{$chk}{$src{nick}}; } } - API::Std::event_run("on_nick", ($svr, \%src, $nex)); + API::Std::event_run("on_nick", (\%src, $nex)); } return 1; @@ -567,7 +570,9 @@ sub notice { # Parse: PART sub part { my ($svr, @ex) = @_; + 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}}; @@ -584,7 +589,7 @@ sub part { } # Trigger on_part. - API::Std::event_run("on_part", ($svr, \%src, $ex[2], $msg)); + API::Std::event_run("on_part", (\%src, $ex[2], $msg)); return 1; } @@ -719,7 +724,9 @@ sub privmsg { # Parse: QUIT sub quit { my ($svr, @ex) = @_; + my %src = API::IRC::usrc(substr($ex[0], 1)); + $src{svr} = $svr; # Set $msg to the quit message. my $msg = 0; @@ -733,7 +740,7 @@ sub quit { } # Trigger on_quit. - API::Std::event_run("on_quit", ($svr, \%src, $msg)); + API::Std::event_run("on_quit", (\%src, $msg)); return 1; } diff --git a/modules/UNO.pm b/modules/UNO.pm index e6d5359..49d1713 100644 --- a/modules/UNO.pm +++ b/modules/UNO.pm @@ -1194,7 +1194,7 @@ sub _gameover { # Subroutine for when someone changes their nick. sub on_nick { - my (($svr, $src, $newnick)) = @_; + my (($src, $newnick)) = @_; # Check if a game is currently running. if ($UNO or $UNOW) { @@ -1227,7 +1227,7 @@ sub on_nick { # Subroutine for when someone disconnects. sub on_quit { - my (($svr, $src, undef)) = @_; + my (($src, undef)) = @_; # Check if a game is currently running. if ($UNO or $UNOW) { @@ -1246,7 +1246,7 @@ sub on_quit { # Subroutine for when someone parts. sub on_part { - my (($svr, $src, $chan, undef)) = @_; + my (($src, $chan, undef)) = @_; # Check if a game is currently running. if ($UNO or $UNOW) { @@ -1254,7 +1254,7 @@ sub on_part { # Check if this is the channel UNO is in. my ($net, $uchan) = split '/', $UNOCHAN; - if ($svr eq $net and lc $chan eq $uchan) { + if ($src->{svr} eq $net and lc $chan eq $uchan) { # Check if the user is playing. if (defined $PLAYERS{lc $src->{nick}}) { privmsg($net, $uchan, "\2$src->{nick}\2 left the game."); @@ -1268,7 +1268,7 @@ sub on_part { # Subroutine for when someone is kicked. sub on_kick { - my (($svr, undef, $chan, $user, undef)) = @_; + my (($src, $chan, $user, undef)) = @_; # Check if a game is currently running. if ($UNO or $UNOW) { @@ -1276,7 +1276,7 @@ sub on_kick { # Check if this is the channel UNO is in. my ($net, $uchan) = split '/', $UNOCHAN; - if ($svr eq $net and lc $chan eq $uchan) { + if ($src->{svr} eq $net and lc $chan eq $uchan) { # Check if the user is playing. if (defined $PLAYERS{lc $user}) { privmsg($net, $uchan, "\2$user\2 left the game.");