mata_bot

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

commit 772f93146a99b5428143b2323fb7daae8c14a182
parent 985f69561ab9b6eacef6a5c0348b777abaa24df6
Author: boredpasta <boredpasta@tutanota.com>
Date:   Sun, 16 Mar 2025 01:54:13 +0200

fix bot thinking it's being "commanded" on $NICK(:|,) with nothing afterwards

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

diff --git a/mata_bot.pl b/mata_bot.pl @@ -1,5 +1,4 @@ use v5.38; -use re 'strict'; use POSIX qw(strftime); use IO::Socket qw(AF_INET SOCK_STREAM); use IO::Socket::SSL; @@ -35,13 +34,15 @@ sub msg { sub respond { my ($sock, $sender_nick, $message) = @_; # if no triggers found, check for mentions - if ($message =~ /^${NICK}(:|,)/) { + if ($message =~ /^${NICK}(:|,) *[^\000\r\n\ ]+/) { + # we got a command if ($sender_nick =~ /^${SULTANA}$/) { msg($sock, "Done, Your Majesty, Sultana ${sender_nick}! <[^_^]>"); } else { msg($sock, "${sender_nick}: BSOD!! <[x~x]>"); } } elsif ($message =~ /${NICK}/) { + # we got mentioned if ($sender_nick =~ /^${SULTANA}$/) { msg($sock, "Yes, Your Majesty, Sultana ${sender_nick}? <[^_^]>"); } else { @@ -70,7 +71,6 @@ my $chunk = ''; my $message = ''; while (1) { # buffer up - #$sock->recv($chunk, $CHUNK_LENGTH); $chunk = <$sock>; $chunk =~ /^([^\r\n]+)(\r\n)?([^\r\n]+)?$/; # keep reading if chunk is empty