commit dd5b28e6c5ea21aac50ebd8a565e2f5202ff5960
parent 3f948ae7aa2915c2dcb6a69adf9c15ded9c31f86
Author: noodle <noodle@pastanoggin.com>
Date: Wed, 18 Jun 2025 20:24:27 +0300
simplify http link regex
Diffstat:
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/mata_bot.pl b/mata_bot.pl
@@ -207,8 +207,8 @@ sub respond {
} else {
msg($sock, "failed to get title of video ${video_id} ${MATA_DEAD} (no videos matching ID $video_id!)");
}
- } elsif ($message =~ m,(https?://[^\000\r\n ]+),) {
- my $url = $1;
+ } elsif ($message =~ m,https?://[^ ]+,) {
+ my $url = $&;
# get in it's HEAD to check if it's text/html
my $response = HTTP::Tiny->new->head($url);
unless ($response->{success}) {
@@ -244,6 +244,7 @@ sub respond {
} else {
msg($sock, "No title found (GET ${url} ${MATA_DEAD}");
}
+ # TODO: this part should use [^ ] and .* instead but i'm scared of .*
} elsif ($message =~ /^ *${NICK_RE}[:, ] *([^\000\r\n ][^\000\r\n]*)$/
or $message =~ /^ *([^\000\r\n ][^\000\r\n]*)[, ] *${NICK_RE}\W*$/) {
respond_command($sock, $sender_nick, $1);
diff --git a/matabot.8 b/matabot.8
@@ -69,6 +69,7 @@ He reads out youtube video titles for you.
is outside the range of valid characters for a youtube video ID, okay?).
.It ...http://what.ever/idk#lol... or ...https://what.ever/idk#lol...
He reads out website titles or the content-type for you.
+(Make sure the character after the end of your link is a space)
.It mata_bot ...${number1}d${number2}...
Ask him to roll ${number1} of ${number2}-sided dice.
He's a dungeon master too!!