From dea44fb4053a6c4c8b647a0498e7bc348ecbcf5f Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 30 Jun 2019 17:54:08 -0700 Subject: [PATCH] Fix and clean up factadd -url (todo: forking) --- PBot/FactoidCommands.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PBot/FactoidCommands.pm b/PBot/FactoidCommands.pm index 3de27cfc..de8353b3 100644 --- a/PBot/FactoidCommands.pm +++ b/PBot/FactoidCommands.pm @@ -964,7 +964,11 @@ sub factadd { $self->{pbot}->{interpreter}->shift_arg(\@arglist); # the URL is the remaining arguments - ($url) = $self->{pbot}->{interpreter}->split_args(\@arglist, 1); + my ($url) = $self->{pbot}->{interpreter}->split_args(\@arglist, 1); + + if ($url !~ m/^https?:\/\/(?:sprunge.us|ix.io)\/\w+$/) { + return "Invalid URL: acceptable URLs are: https://sprunge.us, https://ix.io"; + } # create a UserAgent my $ua = LWP::UserAgent->new(timeout => 10); @@ -990,7 +994,7 @@ sub factadd { } if (not defined $from_chan or not defined $text or not defined $keyword) { - return "Usage: factadd [-f] [channel] ; -f to force overwrite"; + return "Usage: factadd [-f] [channel] ( | -url ); -f to force overwrite; -url to download from paste site"; } $from_chan = '.*' if $from_chan !~ /^#/;