3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 02:49:49 +01:00

Factoids: usage metadata now understands $0 for keyword

This commit is contained in:
Pragmatic Software 2019-06-03 08:01:52 -07:00
parent 4ad1eab596
commit 563f8da40f
2 changed files with 9 additions and 4 deletions

View File

@ -989,7 +989,7 @@ sub factadd {
my $factoids = $self->{pbot}->{factoids}->{factoids}->hash;
if ($factoids->{$channel}->{$trigger}->{'locked'}) {
return "/say $trigger is locked; unlock before overwriting.";
return "/say $keyword_text is locked; unlock before overwriting.";
}
my ($owner) = $factoids->{$channel}->{$trigger}->{'owner'} =~ m/([^!]+)/;
@ -997,7 +997,7 @@ sub factadd {
if ((lc $nick ne lc $owner) and (not $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host"))) {
$self->{pbot}->{logger}->log("$nick!$user\@$host attempted to overwrite $trigger [not owner]\n");
my $chan = ($channel eq '.*' ? 'the global channel' : $channel);
return "You are not the owner of $trigger for $chan; cannot overwrite";
return "You are not the owner of $keyword_text for $chan; cannot overwrite";
}
}
}

View File

@ -843,7 +843,9 @@ sub interpreter {
if (exists $self->{factoids}->hash->{$channel}->{$keyword}->{usage} and not length $stuff->{arguments}) {
$stuff->{alldone} = 1;
return $self->{factoids}->hash->{$channel}->{$keyword}->{usage};
my $usage = $self->{factoids}->hash->{$channel}->{$keyword}->{usage};
$usage =~ s/\$0/$keyword/g;
return $usage;
}
if (exists $stuff->{pipe_result}) {
@ -867,7 +869,9 @@ sub interpreter {
if (exists $self->{factoids}->hash->{$channel}->{$keyword}->{usage} and not length $stuff->{arguments}) {
$stuff->{alldone} = 1;
return $self->{factoids}->hash->{$channel}->{$keyword}->{usage};
my $usage = $self->{factoids}->hash->{$channel}->{$keyword}->{usage};
$usage =~ s/\$0/$keyword/g;
return $usage;
}
$stuff->{lang} = $lang;
@ -934,6 +938,7 @@ sub handle_action {
# no arguments supplied, replace $args with $nick/$tonick, etc
if (exists $self->{factoids}->hash->{$channel}->{$keyword}->{usage}) {
$action = "/say " . $self->{factoids}->hash->{$channel}->{$keyword}->{usage};
$action =~ s/\$0/$keyword/g;
$stuff->{alldone} = 1;
} else {
if ($self->{factoids}->hash->{$channel}->{$keyword}->{'allow_empty_args'}) {