mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 12:32:37 +01:00
Factoids: add usage
metadata to show usage message if no arguments supplied
This commit is contained in:
parent
63b523dbc7
commit
f87e3c7cd8
@ -945,6 +945,11 @@ sub interpreter {
|
||||
|
||||
if ($action =~ m{^/code\s+([^\s]+)\s+(.+)$}i) {
|
||||
my ($lang, $code) = ($1, $2);
|
||||
|
||||
if (exists $self->{factoids}->hash->{$channel}->{$keyword}->{usage} and not length $stuff->{arguments}) {
|
||||
return $self->{factoids}->hash->{$channel}->{$keyword}->{usage};
|
||||
}
|
||||
|
||||
$stuff->{lang} = $lang;
|
||||
$stuff->{code} = $code;
|
||||
$self->execute_code_factoid($stuff);
|
||||
@ -1007,10 +1012,14 @@ sub handle_action {
|
||||
}
|
||||
} else {
|
||||
# no arguments supplied, replace $args with $nick/$tonick, etc
|
||||
if ($self->{factoids}->hash->{$channel}->{$keyword}->{'allow_empty_args'}) {
|
||||
$action = $self->expand_action_arguments($action, undef, '');
|
||||
if (exists $self->{factoids}->hash->{$channel}->{$keyword}->{usage}) {
|
||||
$action = "/say " . $self->{factoids}->hash->{$channel}->{$keyword}->{usage};
|
||||
} else {
|
||||
$action = $self->expand_action_arguments($action, undef, $stuff->{nick});
|
||||
if ($self->{factoids}->hash->{$channel}->{$keyword}->{'allow_empty_args'}) {
|
||||
$action = $self->expand_action_arguments($action, undef, '');
|
||||
} else {
|
||||
$action = $self->expand_action_arguments($action, undef, $stuff->{nick});
|
||||
}
|
||||
}
|
||||
$stuff->{no_nickoverride} = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user