From 2ce5f8688dec27ae2e1b8fe5d81ef18be8144818 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 14 Feb 2020 22:42:15 -0800 Subject: [PATCH] Commands now check for `execute-process` metadata --- PBot/Commands.pm | 16 +++++++++++++--- Plugins/Wttr.pm | 3 +-- data/commands | 4 ++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/PBot/Commands.pm b/PBot/Commands.pm index d327d450..75967404 100644 --- a/PBot/Commands.pm +++ b/PBot/Commands.pm @@ -121,9 +121,19 @@ sub interpreter { } $stuff->{no_nickoverride} = 1; - my $result = &{ $ref->{subref} }($stuff->{from}, $stuff->{nick}, $stuff->{user}, $stuff->{host}, $stuff->{arguments}, $stuff); - return undef if $stuff->{referenced} and $result =~ m/(?:usage:|no results)/i; - return $result; + if ($self->get_meta($keyword, 'execute-process')) { + my $timeout = $self->{pbot}->{registry}->get_value('processmanager', 'default_timeout'); + $self->{pbot}->{process_manager}->execute_process( + $stuff, + sub { $stuff->{result} = $ref->{subref}->($stuff->{from}, $stuff->{nick}, $stuff->{user}, $stuff->{host}, $stuff->{arguments}, $stuff) }, + $timeout + ); + return ""; + } else { + my $result = $ref->{subref}->($stuff->{from}, $stuff->{nick}, $stuff->{user}, $stuff->{host}, $stuff->{arguments}, $stuff); + return undef if $stuff->{referenced} and $result =~ m/(?:usage:|no results)/i; + return $result; + } } } return undef; diff --git a/Plugins/Wttr.pm b/Plugins/Wttr.pm index 3d6fef11..cf93a38f 100644 --- a/Plugins/Wttr.pm +++ b/Plugins/Wttr.pm @@ -99,8 +99,7 @@ sub wttrcmd { delete $options{default}; } - $self->{pbot}->{process_manager}->execute_process($stuff, sub { $stuff->{result} = $self->get_wttr($arguments, %options) }); - return ""; + return $self->get_wttr($arguments, %options); } sub get_wttr { diff --git a/data/commands b/data/commands index 0d0a6c76..7a4395aa 100644 --- a/data/commands +++ b/data/commands @@ -175,6 +175,7 @@ }, "export" : { "_name" : "export", + "execute-process" : "1", "help" : "Exports specified list to HTML file. See https://github.com/pragma-/pbot/blob/master/doc/Admin.md#export", "requires_cap" : 1 }, @@ -400,6 +401,7 @@ }, "recall" : { "_name" : "recall", + "execute-process" : "1", "help" : "Recalls previous chat history for a channel. See https://github.com/pragma-/pbot/blob/master/doc/Commands.md#recall", "requires_cap" : 0 }, @@ -562,11 +564,13 @@ }, "weather" : { "_name" : "weather", + "execute-process" : "1", "help" : "Fetches and displays weather data. You may set `!my location ...` to remember your location.", "requires_cap" : 0 }, "wttr" : { "_name" : "wttr", + "execute-process" : "1", "help" : "", "requires_cap" : "0" }