blob: 4e7a5132538e80086d007eacdbe7566f74174de5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
|