Advertisement
cellsheet

metalbot.py

Jul 22nd, 2014
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. import socket, threading, time, random
  2. def ping():
  3.     while True:
  4.         chsocket.send(bytes("\r\n\x00", "utf-8"))
  5.         time.sleep(20)
  6. chsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  7. chsocket.setblocking(True)
  8. chsocket.connect(("sXX.chatango.com", 443)) # replace XX with chatango tagserver number
  9. chsocket.send(bytes("bauth:roomnamehere:"+str(int(random.randrange(10 ** 15, (10 ** 16) - 1)))+":user:password\x00", "utf-8"))
  10. t = threading.Thread(target=ping)
  11. t.daemon = True
  12. t.start()
  13. while True:
  14.     rbuf = b""
  15.     while not rbuf.endswith(b'\x00'):
  16.         rbuf += chsocket.recv(1024)
  17.     for raw in rbuf.split(b'\x00'):
  18.         if raw.decode("latin-1").rstrip("\r\n").split(":")[0] == "b" and raw.decode("latin-1").rstrip("\r\n").split(":")[-1].split(">")[-1] == "metalbot":
  19.             chsocket.send(bytes("bmsg:t12r:<n000/><f x11000=\"0\">"+random.choice(["Hello! I am Metalbot v 1.3", "Yes, Master?", "I don't actually do anything \o/", "How are you today?", "Wanna play?", "Bored?", "Lovely weather isn't it?"]), "utf-8"))
  20.     time.sleep(0.01)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement