3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-29 23:39:24 +01:00

EventQueue: improve usage message; .* and * both work in remove

This commit is contained in:
Pragmatic Software 2021-06-22 13:56:15 -07:00
parent 883a62920d
commit db3320195e

View File

@ -33,7 +33,7 @@ sub initialize {
sub cmd_eventqueue { sub cmd_eventqueue {
my ($self, $context) = @_; my ($self, $context) = @_;
my $usage = "Usage: eventqueue list [filter regex] | add <relative time> <command> [-repeat] | remove <event>"; my $usage = "Usage: eventqueue list [filter regex] | add <relative time> <command> [-repeat] | remove <regex>";
my $command = $self->{pbot}->{interpreter}->shift_arg($context->{arglist}); my $command = $self->{pbot}->{interpreter}->shift_arg($context->{arglist});
@ -119,8 +119,8 @@ sub cmd_eventqueue {
if ($command eq 'remove') { if ($command eq 'remove') {
my ($regex) = $self->{pbot}->{interpreter}->split_args($context->{arglist}, 1); my ($regex) = $self->{pbot}->{interpreter}->split_args($context->{arglist}, 1);
return "Usage: eventqueue remove <event>" if not defined $regex; return "Usage: eventqueue remove <regex>" if not defined $regex;
$regex =~ s/\*/.*?/g; $regex =~ s/(?<!\.)\*/.*?/g;
return $self->dequeue_event($regex); return $self->dequeue_event($regex);
} }
@ -264,6 +264,7 @@ sub dequeue_event {
return $result; return $result;
} }
# invoke and remove all events matching regex
sub execute_and_dequeue_event { sub execute_and_dequeue_event {
my ($self, $id) = @_; my ($self, $id) = @_;
return $self->dequeue_event($id, 1); return $self->dequeue_event($id, 1);