From 38d9c86984b7a07ed93582d861c85883ac71389c Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 25 Dec 2022 18:17:14 -0800 Subject: [PATCH] Factoids: add more pastebin URLs for `factadd -url`; update `help` URL to point at TOC --- lib/PBot/Core/Commands/Factoids.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/PBot/Core/Commands/Factoids.pm b/lib/PBot/Core/Commands/Factoids.pm index 32479585..b0575b58 100644 --- a/lib/PBot/Core/Commands/Factoids.pm +++ b/lib/PBot/Core/Commands/Factoids.pm @@ -689,6 +689,14 @@ sub cmd_add_regex { return "/say $keyword added."; } +# FIXME: use registry array instead +my @valid_pastesites = ( + 'https?://sprunge.us', + 'https?://ix.io', + 'https?://dpaste.com', + 'https?://0x0.st', +); + sub cmd_factadd { my ($self, $context) = @_; @@ -728,8 +736,8 @@ sub cmd_factadd { my ($url) = $self->{pbot}->{interpreter}->split_args(\@arglist, 1); # FIXME: move this to registry - if ($url !~ m/^https?:\/\/(?:sprunge.us|ix.io)\/\w+$/) { - return "Invalid URL: acceptable URLs are: http://sprunge.us, http://ix.io"; + if (not grep { $url =~ m/^$_/i } @valid_pastesites) { + return "Invalid URL: acceptable URLs are: " . join(', ', sort @valid_pastesites); } # create a UserAgent @@ -1314,7 +1322,9 @@ sub cmd_factchange { if (defined $url) { # FIXME: move this to registry - if ($url !~ m/^https?:\/\/(?:sprunge.us|ix.io)\/\w+$/) { return "Invalid URL: acceptable URLs are: http://sprunge.us, http://ix.io"; } + if (not grep { $url =~ m/^$_/i } @valid_pastesites) { + return "Invalid URL: acceptable URLs are: " . join(', ', sort @valid_pastesites); + } my $ua = LWP::UserAgent->new(timeout => 10); my $response = $ua->get($url);