mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 12:32:37 +01:00
FactoidCommands: factshow now accepts -p option to paste contents
This commit is contained in:
parent
dea44fb405
commit
f34cf704cc
@ -1132,16 +1132,38 @@ sub factshow {
|
||||
|
||||
$stuff->{preserve_whitespace} = 1;
|
||||
|
||||
my ($chan, $trig) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
|
||||
my $usage = "Usage: factshow [-p] [channel] <keyword>; -p to paste";
|
||||
return $usage if not $arguments;
|
||||
|
||||
my $getopt_error;
|
||||
local $SIG{__WARN__} = sub {
|
||||
$getopt_error = shift;
|
||||
chomp $getopt_error;
|
||||
};
|
||||
|
||||
my ($paste);
|
||||
my ($ret, $args) = GetOptionsFromString($arguments,
|
||||
'p' => \$paste);
|
||||
|
||||
return "/say $getopt_error -- $usage" if defined $getopt_error;
|
||||
return "Too many arguments -- $usage" if @$args > 2;
|
||||
return "Missing argument -- $usage" if not @$args;
|
||||
|
||||
my ($chan, $trig) = @$args;
|
||||
|
||||
if (not defined $trig) {
|
||||
$trig = $chan;
|
||||
$chan = $from;
|
||||
}
|
||||
|
||||
my ($channel, $trigger) = $self->find_factoid_with_optional_channel($from, $arguments, 'factshow');
|
||||
$args = join(' ', map { $_ = "'$_'" if $_ =~ m/ /; $_; } @$args);
|
||||
|
||||
my ($channel, $trigger) = $self->find_factoid_with_optional_channel($from, $args, 'factshow', usage => $usage);
|
||||
return $channel if not defined $trigger; # if $trigger is not defined, $channel is an error message
|
||||
|
||||
if ($paste) {
|
||||
return $self->{pbot}->{webpaste}->paste($factoids->{$channel}->{$trigger}->{action});
|
||||
}
|
||||
|
||||
my $trigger_text = $trigger =~ / / ? "\"$trigger\"" : $trigger;
|
||||
|
||||
my $result = "$trigger_text: " . $factoids->{$channel}->{$trigger}->{action};
|
||||
@ -1154,7 +1176,6 @@ sub factshow {
|
||||
$chan = 'global' if $chan eq '.*';
|
||||
|
||||
$result = "[$channel] $result" if $channel ne $chan;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user