Subject: | Make BasicBot handle quit messages |
Hi,
I'd like to propose the attached patch. It registers a callback for quit
messages, which updates the channel data and emits a chanpart state for
every channel the user was on.
Maybe it could also (or instead?) emit a quit message, but I didn't need
that for my use case.
AFAICT, this should also fix the nick tracking (at least I can't think
of any other bug with it).
Rolf.
Subject: | bot.patch |
--- BasicBot.pm 2009-01-21 21:12:20.000000000 +0100
+++ BasicBot.pm.patched 2009-01-21 21:59:08.000000000 +0100
@@ -135,6 +135,7 @@ sub run {
irc_kick => "irc_kicked_state",
irc_nick => "irc_nick_state",
irc_mode => "irc_mode_state",
+ irc_quit => "irc_quit_state",
fork_close => "fork_close_state",
fork_error => "fork_error_state",
@@ -1101,6 +1102,26 @@ sub irc_mode_state {
}
}
+=head2 irc_quit_state
+
+=cut
+
+sub irc_quit_state {
+ my ($self, $kernel, $nick, $message) = @_[OBJECT, KERNEL, ARG0, ARG1];
+ $nick = $_[OBJECT]->nick_strip($nick);
+ if ($self->nick eq $nick) {
+ $kernel->delay('reconnect', 1 );
+ return;
+ }
+ for my $channel (keys( %{ $self->{channel_data} } )) {
+ if (defined( $self->{channel_data}{$channel}{$nick}) ) {
+ $_[OBJECT]->_remove_from_channel( $channel, $nick );
+ @_[ARG1, ARG2] = ($channel, $message);
+ irc_chan_received_state( 'chanpart', 'say', @_ );
+ }
+ }
+}
+
=head2 irc_said_state
Called if we recieve a private or public message. This