commit dd5b28e6c5ea21aac50ebd8a565e2f5202ff5960 from: noodle date: Wed Jun 18 17:24:27 2025 UTC simplify http link regex commit - 3f948ae7aa2915c2dcb6a69adf9c15ded9c31f86 commit + dd5b28e6c5ea21aac50ebd8a565e2f5202ff5960 blob - edb8128e08eb00e4ce23892872234fbf66dccc76 blob + 45b0b0c08f124a5c3bd7e95cfaf8a172707ee9bf --- mata_bot.pl +++ 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); blob - 0aef1a7214738afaee2a1a4947a2bb578193f694 blob + 511825896c9e8f14f71bb16b3ae607724734f14c --- matabot.8 +++ 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!!