3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-01-11 20:42:38 +01:00

Unregister timers by id instead of subref

This commit is contained in:
Pragmatic Software 2016-01-29 12:59:07 -08:00
parent 6e4c7853f2
commit 4c5227b351

View File

@ -164,17 +164,15 @@ sub register {
sub unregister { sub unregister {
my $self = shift; my $self = shift;
my $ref; my $id;
if(@_) { if(@_) {
$ref = shift; $id = shift;
} else { } else {
Carp::croak("Must pass subroutine reference to unregister()"); Carp::croak("Must pass timer id to unregister()");
} }
# print "-- Removing timer $ref\n"; @{ $self->{handlers} } = grep { $_->{id} ne $id } @{ $self->{handlers} };
@{ $self->{handlers} } = grep { $_->{subref} != $ref } @{ $self->{handlers} };
} }
sub update_interval { sub update_interval {