From d69682efc10edf896d7f27cc239710b591db3995 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Mon, 9 Mar 2020 15:24:47 -0700 Subject: [PATCH] `eventqueue` command now accepts `-repeat` flag --- PBot/Interpreter.pm | 4 ++-- PBot/Timer.pm | 5 ++++- doc/Admin.md | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/PBot/Interpreter.pm b/PBot/Interpreter.pm index 55719507..09b912e2 100644 --- a/PBot/Interpreter.pm +++ b/PBot/Interpreter.pm @@ -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 ); } diff --git a/PBot/Timer.pm b/PBot/Timer.pm index 8900c635..dc167a25 100644 --- a/PBot/Timer.pm +++ b/PBot/Timer.pm @@ -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."; } diff --git a/doc/Admin.md b/doc/Admin.md index 673df014..99a4e649 100644 --- a/doc/Admin.md +++ b/doc/Admin.md @@ -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 | remove ` +Usage: `eventqueue list [filter regex] | add [-repeat] | remove ` For example, to schedule a command to run 1 hour from now: