From 6aad5cbfbde778e52febdba6ea447c186f081cd6 Mon Sep 17 00:00:00 2001 From: epochqwert Date: Sat, 2 Dec 2017 11:28:30 +0000 Subject: added a bot for sending data through an IRC channel --- nocompile/bin/pipboy.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 nocompile/bin/pipboy.py diff --git a/nocompile/bin/pipboy.py b/nocompile/bin/pipboy.py new file mode 100755 index 0000000..cabd69e --- /dev/null +++ b/nocompile/bin/pipboy.py @@ -0,0 +1,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) -- cgit v1.2.3