commit - f3609fac601b54d2d303f2588e6ec35858bbaa00
commit + 8bd45e7d5623562961dfadff125f318921abb447
blob - 85bce57dcc1bc20c421341c0f614290892159bf9
blob + ba8bf32c34b0438c0ad01aaf0fc43934df77e256
--- mata_bot.pl
+++ mata_bot.pl
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;
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 {
my $body = $response->{content};
if ($body =~ m,<span class="title"><a href="https://www\.youtube\.com/watch\?v=${video_id}" accesskey="0">([^<]+)</a>,i) {
my $title = $1;
- $title =~ tr/[\000\r\n]//d;
+ $title =~ tr/\000\r\n//d;
$title = trim($title);
$reply = "YouTube: ${title}";
} else {
my $body = $response->{content};
if ($body =~ m,<title[^>]*>([^<]+)</title[^>]*>,i) {
my $title = $1;
- $title =~ tr/[\000\r\n]//d;
+ $title =~ tr/\000\r\n//d;
$title = trim($title);
$reply = "Title: ${title}";
} else {
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;