Mercurial > repo
comparison lib/dcc @ 996:859f9b4339e6
<Gregor> tar xf egobot.tar.xz
author | HackBot |
---|---|
date | Sun, 09 Dec 2012 19:30:08 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
995:6883f5911eb7 | 996:859f9b4339e6 |
---|---|
1 #!/bin/bash | |
2 | |
3 # Configuration: | |
4 | |
5 # IP of the host, must be in the stupid long integer form | |
6 DCC_IP="1077849409" | |
7 | |
8 # Port range | |
9 DCC_PORT_MIN="10000" | |
10 DCC_PORT_RANGE="100" | |
11 | |
12 # Library: | |
13 | |
14 # Get a DCC port | |
15 dcc_port() { | |
16 echo $(( DCC_PORT_MIN + (RANDOM % DCC_PORT_RANGE) )) | |
17 } | |
18 | |
19 # Start a DCC chat to $1 | |
20 dcc_chat() { | |
21 DCC_PORT=`dcc_port` | |
22 ( | |
23 sleep 1 | |
24 echo -e 'PRIVMSG '$1' :\x01DCC CHAT chat '$DCC_IP' '$DCC_PORT'\x01' | | |
25 socat STDIN UNIX-SENDTO:$IRC_SOCK | |
26 ) & | |
27 socat -T30 - TCP4-LISTEN:$DCC_PORT,crnl | |
28 } | |
29 | |
30 # Start a DCC SEND of $2 to $1 | |
31 dcc_send() { | |
32 DCC_PORT=`dcc_port` | |
33 ( | |
34 sleep 1 | |
35 echo -e 'PRIVMSG '$1' :\x01DCC SEND '$2' '$DCC_IP' '$DCC_PORT'\x01' | | |
36 socat STDIN UNIX-SENDTO:$IRC_SOCK | |
37 ) & | |
38 socat -T30 - TCP4-LISTEN:$DCC_PORT | |
39 } |