mata_bot

some cheeky bot for #unix_surrealism
git clone https://git.pastanoggin.com/mata_bot.git
Log | Files | Refs | README | LICENSE

commit f9903ae1d7421f5422b5ff6d2a04c5a622ac2fbb
parent 8c7ebe8f11d0d6d1803e7037024e41d52b8f0550
Author: noodle <noodle@pastanoggin.com>
Date:   Sun, 15 Jun 2025 19:33:56 +0300

fix s/// not silincing on wrong regex

also made it so no regexes go into the user's buffer. it helps with
repeatedly iterating over a message with s/// even if the user got the
regex wrong in the middle

Diffstat:
Mmata_bot.pl | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mata_bot.pl b/mata_bot.pl @@ -168,11 +168,12 @@ sub respond { # chat s/// my $toreplace = $1; my $replacement = $2; - eval { $subbuffer{$sender_nick} =~ s/$toreplace/$replacement/ }; - if (not $@ and $subbuffer{$sender_nick}) { + my $match; + eval { $match = $subbuffer{$sender_nick} =~ s/$toreplace/$replacement/ }; + if (not $@ and $match) { msg($sock, "${sender_nick} meant to say: $subbuffer{$sender_nick}"); - return 1; } + return 1; } elsif ($message =~ m,watch\?v=([a-zA-Z0-9_-]+),) { # post youtube video titles from video ID my $video_id = $1;