summaryrefslogtreecommitdiffstats
path: root/skripti/irc_antispam.sh
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-10-07 14:27:44 +0200
committerAnton Luka Šijanec <anton@sijanec.eu>2023-10-07 14:27:44 +0200
commit69e576308aefd92d8af7a5bcb060e5929d7becb7 (patch)
tree38bb6a9e6274eaef64e6155f74f90023a7919b58 /skripti/irc_antispam.sh
parentponastavi update (diff)
downloadr-69e576308aefd92d8af7a5bcb060e5929d7becb7.tar
r-69e576308aefd92d8af7a5bcb060e5929d7becb7.tar.gz
r-69e576308aefd92d8af7a5bcb060e5929d7becb7.tar.bz2
r-69e576308aefd92d8af7a5bcb060e5929d7becb7.tar.lz
r-69e576308aefd92d8af7a5bcb060e5929d7becb7.tar.xz
r-69e576308aefd92d8af7a5bcb060e5929d7becb7.tar.zst
r-69e576308aefd92d8af7a5bcb060e5929d7becb7.zip
Diffstat (limited to 'skripti/irc_antispam.sh')
-rwxr-xr-xskripti/irc_antispam.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/skripti/irc_antispam.sh b/skripti/irc_antispam.sh
new file mode 100755
index 0000000..4e7a513
--- /dev/null
+++ b/skripti/irc_antispam.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+set -uexo pipefail
+p=`rev <<<$0 | cut -d/ -f1 | rev`
+umask 0007
+d=`mktemp -p "" -d $p.XXX`
+trap "rm -r $d" EXIT
+mkfifo $d/s
+mkfifo $d/c
+tail -f $d/s | nc $1 6667 > $d/c &
+u=dont_send_me_msg_
+echo "USER $u `hostname` $1 :IRC Antispam bot. Do not PM, you will get G-Lined." > $d/s
+echo "NICK antispam" > $d/s
+echo "OPER $OPER" > $d/s
+c="antispam_chan_dont_join_youll_get_gline_"
+j="$c$RANDOM"
+echo "JOIN #$j" > $d/s
+while read l
+do
+ echo "$l"
+ case `cut -d\ -f2 <<<"$l"` in
+ 433)
+ echo "NICK bot$RANDOM" > $d/s
+ echo "OPER $OPER" > $d/s
+ echo "PART #$j" > $d/s
+ j="$c$RANDOM"
+ echo "JOIN #$j" > $d/s
+ ;;
+ PRIVMSG|JOIN|PART)
+ if grep -v $u <<<"$l"
+ then
+ i=`cut -d\ -f1 <<<"$l" | cut -d@ -f2`
+ echo "GLINE *@$i 13376969 :You were G-Lined for spamming. Appeal via email to anton@sijanec.eu" > $d/s
+ fi
+ ;;
+ esac
+ case `cut -d\ -f1 <<<"$l"` in
+ PING)
+ echo "PONG `cut -d\ -f2 <<<$l`" > $d/s
+ echo "PART #$j" > $d/s
+ j="$c$RANDOM"
+ echo "JOIN #$j" > $d/s
+ ;;
+ esac
+done < $d/c