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;
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;

View File

@ -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 {

4
data/commands vendored
View File

@ -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"
}