Changed on_nick, on_quit, on_part, and on_kick source hashrefs to include server, removing svr.

This commit is contained in:
Matthew Barksdale committed 2011-03-02 17:37:27 -05:00
1 parent 4e0384d645
commit 0e46850a65
4 files changed
+21 -13

No files matched your search

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