aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsaxrobot15
1 files changed, 13 insertions, 2 deletions
diff --git a/saxrobot b/saxrobot
index 3f6fdd9..8a59db6 100755
--- a/saxrobot
+++ b/saxrobot
@@ -10,6 +10,8 @@ use sb_config;
my %config = sb_config::parse_config('bot.conf');
+my $current_nick = $config{nick};
+
# New PoCo-IRC object
my $irc = POE::Component::IRC->spawn(
nick => $config{nick},
@@ -26,7 +28,7 @@ $irc->plugin_add('NickServID', POE::Component::IRC::Plugin::NickServID->new(
POE::Session->create(
package_states => [
- main => [ qw(_default _start irc_001 irc_kick irc_public irc_msg) ],
+ main => [ qw(_default _start irc_001 irc_kick irc_public irc_msg irc_nick) ],
],
heap => { irc => $irc },
);
@@ -51,9 +53,18 @@ sub irc_001 {
return;
}
+sub irc_nick {
+ my ($who, $new_nick) = @_[ARG0 .. ARG1];
+ my $oldnick = (split /!/, $who)[0];
+ if ($oldnick eq $current_nick) {
+ $current_nick = $new_nick;
+ }
+ return;
+}
+
sub irc_kick {
my ($kicker, $channel, $kickee, $reason) = @_[ARG0 .. ARG3];
- if ($kickee eq $config{nick}) {
+ if ($kickee eq $current_nick) {
print "I was kicked by $kicker ($reason). Rejoining now.\n";
$irc->yield(join => $channel);
}