Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.73 KB | None | 0 0
  1. import socket
  2. import threading
  3.  
  4. #Maed by megaloler
  5.  
  6. cons = []
  7.  
  8. HOST = '72.172.232.90'
  9. PORT = 443
  10.  
  11. USER = raw_input("Username: ")
  12. PASS = raw_input("Password: ")
  13.  
  14. ROOM = raw_input("Room: ")
  15.  
  16. COLOR = '6A0'
  17. SIZE = '13'
  18. NAMECOLOR = '8F0'
  19. FONT = "0"
  20.  
  21. curroom = 0
  22.    
  23. class RecvThread (threading.Thread):
  24.     def run(self):
  25.         ss = self.ss
  26.         while 1:
  27.             data = ss[0].recv(1024)
  28.             if data == "": break
  29.             datas = data.split(":")
  30.             if datas[0] == "b":
  31.                 name = datas[2]
  32.                 mes = ":".join(datas[9:])
  33.                 if mes[0:2] == "<n":
  34.                     name = mes[0:7] + name
  35.                     mes = mes [7:]
  36.                 print ss[1] + ": " + name + ": " + mes
  37.  
  38. def con(room):
  39.     print "Connecting..."
  40.  
  41.     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  42.     s.connect((HOST, PORT))
  43.  
  44.     s.send("v" + chr(0))
  45.  
  46.     data = s.recv(1024)
  47.  
  48.     print "Connected!"
  49.     print "Logging in..."
  50.  
  51.     s.send("bauth:"+room+":7202053138505182:"+USER+":"+PASS + chr(0))
  52.  
  53.     t = RecvThread()
  54.     t.ss = (s,room)
  55.     t.start()
  56.     cons.append((s,room))
  57.  
  58.     print "Welcome to " + ROOM + "!"
  59.  
  60. con(ROOM)
  61.  
  62. while 1:
  63.     ddd = raw_input("")
  64.     if ddd == "": break
  65.     if ddd[0] == "/":
  66.         ddd = ddd[1:]
  67.         ddds = ddd.split(" ")
  68.         if len(ddds) == 1:
  69.             print "Set to what?"
  70.         else:
  71.             if ddds[0] == "name":
  72.                 NAMECOLOR = ddds[1]
  73.                 if len(NAMECOLOR) < 3:
  74.                     NAMECOLOR = "0" + NAMECOLOR
  75.                 if len(NAMECOLOR) < 3:
  76.                     NAMECOLOR = "0" + NAMECOLOR
  77.                 if len(NAMECOLOR) < 3:
  78.                     NAMECOLOR = "0" + NAMECOLOR
  79.                 print "Name color set to " + NAMECOLOR
  80.             elif ddds[0] == "color":
  81.                 COLOR = ddds[1]
  82.                 if len(COLOR) < 3:
  83.                     COLOR = "0" + COLOR
  84.                 if len(COLOR) < 3:
  85.                     COLOR = "0" + COLOR
  86.                 if len(COLOR) < 3:
  87.                     COLOR = "0" + COLOR
  88.                 print "Color set to " + COLOR
  89.             elif ddds[0] == "size":
  90.                 SIZE = ddds[1]
  91.                 if len(SIZE) == 1:
  92.                     SIZE = "0" + SIZE
  93.                 print "Size set to " + SIZE
  94.             elif ddds[0] == "font":
  95.                 FONT = ddds[1]
  96.                 if FONT == "":
  97.                     FONT = "0"
  98.                 print "Font set to " + FONT
  99.     else:
  100.         ppp = "bmsg:<n"+NAMECOLOR+"/><f x"+SIZE+COLOR+"=\""+FONT+"\">" + ddd + chr(13) + chr(10) + chr(0)
  101.         cons[curroom][0].send(ppp)
  102.  
  103. print "Disconnecting..."
  104.    
  105. for s in cons:
  106.     s[0].close()
  107.  
  108. print "Bye!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement