diff options
Diffstat (limited to 'skripti/irc_antispam.sh')
-rwxr-xr-x | skripti/irc_antispam.sh | 44 |
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 |