Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import threading
- import time
- import logging
- import datetime
- import os
- #Made by MegaLoler
- HOST = '72.172.232.90'
- PORT = 443
- USER = raw_input("Username: ")
- PASS = raw_input("Password: ")
- ROOM = raw_input("Room: ")
- running = 1
- s = None
- class IdleThread (threading.Thread):
- def run(self):
- while running:
- time.sleep(30)
- if running:
- s.send(chr(13) + chr(10) + chr(0))
- print "Connecting..."
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.connect((HOST, PORT))
- s.send("v" + chr(0))
- data = s.recv(1024)
- print "Connected!"
- print "Logging in..."
- s.send("bauth:"+ROOM+":7202053138505182:"+USER+":"+PASS + chr(0))
- print "Logged in!"
- IdleThread().start()
- print "Preparing log file..."
- logging.basicConfig(filename=os.curdir+"/chatango.log",level=logging.INFO)
- print "Logging has begun"
- while running:
- data = s.recv(1024)
- MES = ""
- if data[0] == "b":
- aa = data.split(":")
- an = aa[2]
- am = ":".join(aa[9:len(aa)])
- am = am[0:len(am)-3]
- n = am.count("<n")
- nc = "default"
- if n > 0:
- nc = "#" + am[2:5]
- am = am[7:len(am)]
- MES = MES + "[namecolor=" + nc + "/]" + an + ": "
- styles = am.split("<f ")
- for st in styles:
- if st == '':
- continue
- pos = st.split(">")
- std = pos[0]
- st = ">".join(pos[1:len(pos)])
- std = std.split('="')
- d1 = std[0][1:len(std[0])]
- d2 = std[1][0:len(std[1])-1]
- siz = "10"
- col = "#000"
- fon = d2
- if len(d1) == 2:
- siz = int(d1)
- elif len(d1) == 3:
- col = "#" + d1
- elif len(d1) == 5:
- siz = int(d1[0:2])
- col = "#" + d1[2:5]
- elif len(d1) == 6:
- col = "#" + d1
- elif len(d1) == 8:
- siz = int(d1[0:2])
- col = "#" + d1[2:8]
- st = "".join(st.split("</f>"))
- if st.count("<") > 0:
- B = 0
- U = 0
- I = 0
- st2 = st.split("<")
- for st in st2:
- if st == '':
- continue
- op = ""
- if st[1] == ">":
- if st[0].lower() == "b":
- B = B + 1
- if st[0].lower() == "u":
- U = U + 1
- if st[0].lower() == "i":
- I = I + 1
- st = st[2:len(st)]
- elif st[0] == "/" and st[2] == ">":
- if st[1].lower() == "b":
- B = B - 1
- if st[1].lower() == "u":
- U = U - 1
- if st[1].lower() == "i":
- I = I - 1
- st = st[3:len(st)]
- if st == '':
- continue
- if B or U or I:
- B2 = B
- U2 = U
- I2 = I
- if B2 > 1: B2 = 1
- if U2 > 1: U2 = 1
- if I2 > 1: I2 = 1
- bt = (""," bold, ")[B2]
- ut = (""," underline, ")[U2]
- it = (""," italic, ")[I2]
- op = "," + bt + ut + it
- st = st.replace(""","\"")
- st = st.replace("'","'")
- st = st.replace(">",">")
- st = st.replace("<","<")
- MES = MES + "[style font=" + str(fon) + ", size=" + str(siz) + op + "]" + str(st) + "[/style]"
- else:
- st = st.replace(""","\"")
- st = st.replace("'","'")
- st = st.replace(">",">")
- st = st.replace("<","<")
- MES = MES + "[style font=" + str(fon) + ", size=" + str(siz) + "]" + str(st) + "[/style]"
- if MES != "":
- now = str(datetime.datetime.now())
- MES = now + ": " + MES
- print MES
- logging.info(MES + "\n")
- s.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement