commit 8bd45e7d5623562961dfadff125f318921abb447 from: noodle date: Thu Sep 25 20:14:30 2025 UTC add a bible command and extra sanitization before sending anything out commit - f3609fac601b54d2d303f2588e6ec35858bbaa00 commit + 8bd45e7d5623562961dfadff125f318921abb447 blob - 85bce57dcc1bc20c421341c0f614290892159bf9 blob + ba8bf32c34b0438c0ad01aaf0fc43934df77e256 --- mata_bot.pl +++ mata_bot.pl @@ -8,7 +8,8 @@ use IO::Socket qw(AF_INET SOCK_STREAM); use IO::Socket::SSL; use POSIX qw(strftime); -my $CHUNK_LENGTH = 1024; +my $BIBLE_VERSES = 31102; +my $CHUNK_LENGTH = 512; my $CONNECT_TIMEOUT = 60; my $RECONNECT_TIME = 60; my $SOCK_TIMEOUT = 10; @@ -103,6 +104,15 @@ sub respond_command { yo+ )\b{wb}/ix) { $reply = "$hellos->[rand @$hellos], ${sender_nick}! ${MATA_HAPPY}" + } elsif ($content =~ /g[o-]d+/i) { + my $response = HTTP::Tiny->new->get("http://triapul.cz/files/bible/@{[randint(1, $BIBLE_VERSES)]}"); + $reply = "God is Dead!! ${MATA_CUTE}"; + if ($response->{success}) { + my $body = $response->{content}; + $body =~ tr/\000\r\n//d; + $body = trim($body); + $reply = $body if $body; + } } elsif ($sender_nick eq $MOTHER) { $reply = "Done, mother! ${MATA_HAPPY}" } else { @@ -165,7 +175,7 @@ sub respond { my $body = $response->{content}; if ($body =~ m,([^<]+),i) { my $title = $1; - $title =~ tr/[\000\r\n]//d; + $title =~ tr/\000\r\n//d; $title = trim($title); $reply = "YouTube: ${title}"; } else { @@ -202,7 +212,7 @@ sub respond { my $body = $response->{content}; if ($body =~ m,]*>([^<]+)]*>,i) { my $title = $1; - $title =~ tr/[\000\r\n]//d; + $title =~ tr/\000\r\n//d; $title = trim($title); $reply = "Title: ${title}"; } else { @@ -308,6 +318,10 @@ sub evasdrop { my $sender_nick = $1; my $sender_message = $2; ($subbuffer->{$sender_nick}, $reply) = respond($lists, $subbuffer, $sender_nick, $sender_message); + # sanitize text and and form msg + $reply =~ tr/\000\r\n//d; + $reply = trim($reply); + $reply = substr($reply, 0, $CHUNK_LENGTH-length("PRIVMSG #$opts->{'chan'} :")); $reply = "PRIVMSG $opts->{'chan'} :${reply}" if $reply; } out($sock, $opts, $reply) if $reply;