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

eventqueue command now accepts -repeat flag

This commit is contained in:
Pragmatic Software 2020-03-09 15:24:47 -07:00
parent e193fc734f
commit d69682efc1
3 changed files with 7 additions and 4 deletions

View File

@ -958,7 +958,7 @@ sub add_message_to_output_queue {
}
sub add_to_command_queue {
my ($self, $channel, $command, $delay) = @_;
my ($self, $channel, $command, $delay, $repeating) = @_;
$self->{pbot}->{timer}->enqueue_event(
sub {
@ -982,7 +982,7 @@ sub add_to_command_queue {
$stuff->{result} = $result;
$self->handle_result($stuff, $result);
},
$delay, "command $channel $command->{command}"
$delay, "command $channel $command->{command}", $repeating
);
}

View File

@ -100,6 +100,9 @@ sub event_queue_cmd {
my ($delay, $error) = $self->{pbot}->{parsedate}->parsedate($duration);
return $error if defined $error;
my $repeating = 0;
$repeating = 1 if $command =~ s/^-repeat\s+|\s+-repeat$//g;
my $cmd = {
nick => $nick,
user => $user,
@ -107,7 +110,7 @@ sub event_queue_cmd {
command => $command,
};
$self->{pbot}->{interpreter}->add_to_command_queue($from, $cmd, $delay);
$self->{pbot}->{interpreter}->add_to_command_queue($from, $cmd, $delay, $repeating);
return "Command added to event queue.";
}

View File

@ -549,7 +549,7 @@ Name | Description
PBot uses an event queue to schedule future tasks or commands. The `eventqueue` command can
be used to list or remove upcoming events. It can also be used to schedule a command.
Usage: `eventqueue list [filter regex] | add <relative time> <command> | remove <event>`
Usage: `eventqueue list [filter regex] | add <relative time> <command> [-repeat] | remove <event>`
For example, to schedule a command to run 1 hour from now: