blob: cabd69e2c41b33aecef2cca48a4c3c17db0d94ba (
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
45
46
|
#!/usr/pkg/bin/python3.3
import time
import socket
import os
import fcntl
import sys
s=socket.create_connection(("127.0.0.1",6667))
fcntl.fcntl(sys.stdin.fileno(),fcntl.F_SETFL,os.O_NONBLOCK)
fcntl.fcntl(s.fileno(),fcntl.F_SETFL,os.O_NONBLOCK)
s.send(b"NICK pipboy\r\nUSER a b c d\r\nJOIN #pipe\r\n")
b=b""
c=b""
while 1:
try:
i=s.recv(16)
except:
pass
else:
b+=i
try:
j=sys.stdin.read(16)
except:
pass
else:
c+=j.encode()
if(b"\n" in c):
q=c.split(b'\n')
c=b'\n'.join(q[1:])
s.send(b'PRIVMSG #pipe :' + q[0] + b'\r\n')
if(b"\r\n" in b):
p=b.split(b'\r\n')
b=b"\r\n".join(p[1:])
a=p[0].split(b' ')
try:
who=a[0].split(b':')[1].split(b'!')[0]
except:
who=b"#cmd"
if(a[0] == b'ERROR'):
quit()
if(a[0] == b'PING'):
s.send(b'PONG ' + a[1] + b'\r\n')
if(a[1] == b'PRIVMSG'):
if(a[2] == b'#pipe'):
print((b" ".join(a[3:])[1:]).decode())
sys.stdout.flush()
time.sleep(.01)
|