mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-20 10:59:29 +01:00
Plugins: unregister event handlers on unload
This commit is contained in:
parent
cf9c45f3e9
commit
9f2a0346e0
@ -72,6 +72,12 @@ sub unload {
|
|||||||
$self->dbi_end;
|
$self->dbi_end;
|
||||||
$self->{pbot}->{commands}->unregister('actiontrigger');
|
$self->{pbot}->{commands}->unregister('actiontrigger');
|
||||||
$self->{pbot}->{capabilities}->remove('can-actiontrigger');
|
$self->{pbot}->{capabilities}->remove('can-actiontrigger');
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.public', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.caction', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.join', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.part', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.quit', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.kick', __PACKAGE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub create_database {
|
sub create_database {
|
||||||
|
@ -36,6 +36,12 @@ sub initialize {
|
|||||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.caction', sub { $self->on_action(@_) });
|
$self->{pbot}->{event_dispatcher}->register_handler('irc.caction', sub { $self->on_action(@_) });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub unload {
|
||||||
|
my ($self) = @_;
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.nick', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.caction', __PACKAGE__);
|
||||||
|
}
|
||||||
|
|
||||||
sub on_nickchange {
|
sub on_nickchange {
|
||||||
my ($self, $event_type, $event) = @_;
|
my ($self, $event_type, $event) = @_;
|
||||||
my ($nick, $user, $host, $newnick) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args);
|
my ($nick, $user, $host, $newnick) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args);
|
||||||
|
@ -38,6 +38,12 @@ sub initialize {
|
|||||||
$self->{kicks} = {};
|
$self->{kicks} = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub unload {
|
||||||
|
my ($self) = @_;
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.kick', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.join', __PACKAGE__);
|
||||||
|
}
|
||||||
|
|
||||||
sub on_kick {
|
sub on_kick {
|
||||||
my ($self, $event_type, $event) = @_;
|
my ($self, $event_type, $event) = @_;
|
||||||
my ($nick, $user, $host, $target, $channel, $reason) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->to, $event->{event}->{args}[0], $event->{event}->{args}[1]);
|
my ($nick, $user, $host, $target, $channel, $reason) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->to, $event->{event}->{args}[0], $event->{event}->{args}[1]);
|
||||||
|
@ -35,7 +35,11 @@ sub initialize {
|
|||||||
$self->{nicks} = {};
|
$self->{nicks} = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub unload {}
|
sub unload {
|
||||||
|
my ($self) = @_;
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.public', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.caction', __PACKAGE__);
|
||||||
|
}
|
||||||
|
|
||||||
sub on_action {
|
sub on_action {
|
||||||
my ($self, $event_type, $event) = @_;
|
my ($self, $event_type, $event) = @_;
|
||||||
|
@ -45,6 +45,8 @@ sub initialize {
|
|||||||
sub unload {
|
sub unload {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->{pbot}->{timer}->unregister('antirepeat');
|
$self->{pbot}->{timer}->unregister('antirepeat');
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.public', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.caction', __PACKAGE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub on_public {
|
sub on_public {
|
||||||
|
@ -38,6 +38,11 @@ sub initialize {
|
|||||||
$self->{offenses} = {};
|
$self->{offenses} = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub unload {
|
||||||
|
my ($self) = @_;
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.public', __PACKAGE__);
|
||||||
|
}
|
||||||
|
|
||||||
sub on_public {
|
sub on_public {
|
||||||
my ($self, $event_type, $event) = @_;
|
my ($self, $event_type, $event) = @_;
|
||||||
my ($nick, $user, $host, $channel, $msg) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->{to}[0], $event->{event}->args);
|
my ($nick, $user, $host, $channel, $msg) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->{to}[0], $event->{event}->args);
|
||||||
|
@ -37,6 +37,12 @@ sub initialize {
|
|||||||
$self->{rejoins} = {};
|
$self->{rejoins} = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub unload {
|
||||||
|
my ($self) = @_;
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.kick', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.part', __PACKAGE__);
|
||||||
|
}
|
||||||
|
|
||||||
sub rejoin_channel {
|
sub rejoin_channel {
|
||||||
my ($self, $channel) = @_;
|
my ($self, $channel) = @_;
|
||||||
$self->{rejoins}->{$channel}->{rejoins} = 0 if not exists $self->{rejoins}->{$channel};
|
$self->{rejoins}->{$channel}->{rejoins} = 0 if not exists $self->{rejoins}->{$channel};
|
||||||
|
@ -54,6 +54,9 @@ sub unload {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->{pbot}->{commands}->unregister('battleship');
|
$self->{pbot}->{commands}->unregister('battleship');
|
||||||
$self->{pbot}->{timer}->unregister('battleship timer');
|
$self->{pbot}->{timer}->unregister('battleship timer');
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.part', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.quit', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.kick', __PACKAGE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub on_kick {
|
sub on_kick {
|
||||||
|
@ -48,6 +48,9 @@ sub unload {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->{pbot}->{commands}->unregister('connect4');
|
$self->{pbot}->{commands}->unregister('connect4');
|
||||||
$self->{pbot}->{timer}->unregister('connect4 timer');
|
$self->{pbot}->{timer}->unregister('connect4 timer');
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.part', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.quit', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.kick', __PACKAGE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub on_kick {
|
sub on_kick {
|
||||||
|
@ -52,6 +52,7 @@ sub unload {
|
|||||||
$self->{pbot}->{commands}->unregister('counterlist');
|
$self->{pbot}->{commands}->unregister('counterlist');
|
||||||
$self->{pbot}->{commands}->unregister('countertrigger');
|
$self->{pbot}->{commands}->unregister('countertrigger');
|
||||||
$self->{pbot}->{capabilities}->remove('can-countertrigger');
|
$self->{pbot}->{capabilities}->remove('can-countertrigger');
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.public', __PACKAGE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub create_database {
|
sub create_database {
|
||||||
|
@ -8,7 +8,6 @@ use warnings;
|
|||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
use feature 'unicode_strings';
|
use feature 'unicode_strings';
|
||||||
|
|
||||||
use Carp ();
|
use Carp ();
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@ -28,9 +27,7 @@ sub initialize {
|
|||||||
sub unload {
|
sub unload {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
# perform plugin clean-up here
|
# perform plugin clean-up here
|
||||||
# normally we'd unregister the 'irc.public' event handler; however, the
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.public', __PACKAGE__);
|
||||||
# event dispatcher will do this automatically for us when it sees there
|
|
||||||
# is no longer an existing sub.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub on_public {
|
sub on_public {
|
||||||
|
@ -30,6 +30,7 @@ sub initialize {
|
|||||||
sub unload {
|
sub unload {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->{pbot}->{timer}->unregister('RelayUnreg');
|
$self->{pbot}->{timer}->unregister('RelayUnreg');
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.public', __PACKAGE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub on_public {
|
sub on_public {
|
||||||
|
@ -86,6 +86,9 @@ sub unload {
|
|||||||
$self->{pbot}->{commands}->unregister('spinach');
|
$self->{pbot}->{commands}->unregister('spinach');
|
||||||
$self->{pbot}->{timer}->unregister('spinach timer');
|
$self->{pbot}->{timer}->unregister('spinach timer');
|
||||||
$self->{stats}->end if $self->{stats_running};
|
$self->{stats}->end if $self->{stats_running};
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.part', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.quit', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.kick', __PACKAGE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub on_kick {
|
sub on_kick {
|
||||||
|
@ -38,7 +38,9 @@ sub initialize {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub unload {
|
sub unload {
|
||||||
# nothing to do here
|
my ($self) = @_;
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.public', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.caction', __PACKAGE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub on_public {
|
sub on_public {
|
||||||
|
@ -36,7 +36,11 @@ sub initialize {
|
|||||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.caction', sub { $self->show_url_titles(@_) });
|
$self->{pbot}->{event_dispatcher}->register_handler('irc.caction', sub { $self->show_url_titles(@_) });
|
||||||
}
|
}
|
||||||
|
|
||||||
sub unload {}
|
sub unload {
|
||||||
|
my ($self) = @_;
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.public', __PACKAGE__);
|
||||||
|
$self->{pbot}->{event_dispatcher}->remove_handler('irc.caction', __PACKAGE__);
|
||||||
|
}
|
||||||
|
|
||||||
sub show_url_titles {
|
sub show_url_titles {
|
||||||
my ($self, $event_type, $event) = @_;
|
my ($self, $event_type, $event) = @_;
|
||||||
|
Loading…
Reference in New Issue
Block a user