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

Commands now check for execute-process metadata

This commit is contained in:
Pragmatic Software 2020-02-14 22:42:15 -08:00
parent 7d2a746c2c
commit 2ce5f8688d
3 changed files with 18 additions and 5 deletions

View File

@ -121,9 +121,19 @@ sub interpreter {
} }
$stuff->{no_nickoverride} = 1; $stuff->{no_nickoverride} = 1;
my $result = &{ $ref->{subref} }($stuff->{from}, $stuff->{nick}, $stuff->{user}, $stuff->{host}, $stuff->{arguments}, $stuff); if ($self->get_meta($keyword, 'execute-process')) {
return undef if $stuff->{referenced} and $result =~ m/(?:usage:|no results)/i; my $timeout = $self->{pbot}->{registry}->get_value('processmanager', 'default_timeout');
return $result; $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; return undef;

View File

@ -99,8 +99,7 @@ sub wttrcmd {
delete $options{default}; delete $options{default};
} }
$self->{pbot}->{process_manager}->execute_process($stuff, sub { $stuff->{result} = $self->get_wttr($arguments, %options) }); return $self->get_wttr($arguments, %options);
return "";
} }
sub get_wttr { sub get_wttr {

4
data/commands vendored
View File

@ -175,6 +175,7 @@
}, },
"export" : { "export" : {
"_name" : "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", "help" : "Exports specified list to HTML file. See https://github.com/pragma-/pbot/blob/master/doc/Admin.md#export",
"requires_cap" : 1 "requires_cap" : 1
}, },
@ -400,6 +401,7 @@
}, },
"recall" : { "recall" : {
"_name" : "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", "help" : "Recalls previous chat history for a channel. See https://github.com/pragma-/pbot/blob/master/doc/Commands.md#recall",
"requires_cap" : 0 "requires_cap" : 0
}, },
@ -562,11 +564,13 @@
}, },
"weather" : { "weather" : {
"_name" : "weather", "_name" : "weather",
"execute-process" : "1",
"help" : "Fetches and displays weather data. You may set `!my location ...` to remember your location.", "help" : "Fetches and displays weather data. You may set `!my location ...` to remember your location.",
"requires_cap" : 0 "requires_cap" : 0
}, },
"wttr" : { "wttr" : {
"_name" : "wttr", "_name" : "wttr",
"execute-process" : "1",
"help" : "", "help" : "",
"requires_cap" : "0" "requires_cap" : "0"
} }