commit cde208a02d810ec84081ab5d18f2c2cd732ad002
parent 4983457d819e8acfb0876ac8ef72b4aeefc19621
Author: boredpasta <boredpasta@tutanota.com>
Date: Mon, 17 Mar 2025 00:28:42 +0200
add a toggle `-j join' for choosing the chan to join (local testing :)
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/mata_bot.pl b/mata_bot.pl
@@ -11,9 +11,9 @@ my $CHUNK_LENGTH = 1024;
my $NICK = 'mata_bot';
my $USER = 'mata_bot_beta4';
my $REAL = 'death to technomage!!';
-my $CHAN = '#unix_surrealism';
my $MOTHER = 'anelli';
+my $chan = '#unix_surrealism';
my $host = 'irc.libera.chat';
my $logging = 0;
my $port = '6697';
@@ -34,7 +34,7 @@ sub out {
sub msg {
my ($sock, $message) = @_;
- out($sock, "PRIVMSG $CHAN :$message");
+ out($sock, "PRIVMSG $chan :$message");
}
# respond to channel
@@ -128,7 +128,8 @@ sub respond {
}
# process args
-getopts('h:lp:t', \my %opts);
+getopts('h:j:lp:t', \my %opts);
+$chan = $opts{'j'} if ($opts{'j'});
$host = $opts{'h'} if ($opts{'h'});
$logging = 1 if ($opts{'l'});
$port = $opts{'p'} if ($opts{'p'});
@@ -156,7 +157,7 @@ if ($tls) {
# set user, real, and nick, then join
out($sock, "USER $USER * * :$REAL");
out($sock, "NICK $NICK");
-out($sock, "JOIN $CHAN");
+out($sock, "JOIN $chan");
# evasdrop
my $buffer = '';
@@ -196,7 +197,7 @@ while (1) {
if ($message =~ /^PING :([^\000\r\n\ ]+)$/) {
# if we got a ping, pong back
out($sock, "PONG :$1");
- } elsif ($message =~ /^:([^\000\r\n\#\&\ ][^\000\r\n\ ]*)![^\000\r\n\ ]+@[^\000\r\n\ ]+ PRIVMSG ${CHAN} :([^\000\r\n]*)$/) {
+ } elsif ($message =~ /^:([^\000\r\n\#\&\ ][^\000\r\n\ ]*)![^\000\r\n\ ]+@[^\000\r\n\ ]+ PRIVMSG ${chan} :([^\000\r\n]*)$/) {
# if we got a message to our chan. read and act accordingly
my $sender_nick = $1;
my $sender_message = $2;