From 563f8da40f8c544a44ce1867fbedcbd3b5492e6f Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Mon, 3 Jun 2019 08:01:52 -0700 Subject: [PATCH] Factoids: usage metadata now understands $0 for keyword --- PBot/FactoidCommands.pm | 4 ++-- PBot/Factoids.pm | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/PBot/FactoidCommands.pm b/PBot/FactoidCommands.pm index 3474f816..21e386a9 100644 --- a/PBot/FactoidCommands.pm +++ b/PBot/FactoidCommands.pm @@ -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"; } } } diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index 3871ae94..bdca2195 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -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'}) {