diff options
-rw-r--r-- | proxy.py | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -1,11 +1,14 @@ from omegle import OmegleChat import sys, logging, time - +from threading import Lock colors = {"default":0, "black":30, "red":31, "green":32, "yellow":33, "blue":34,"magenta":35, "cyan":36, "white":37, "black":38, "black":39} #33[%colors%m # color_string = "\033[%dm\033[1m" % colors[color] + +chat_lock = Lock() + class OmegleProxyChat(OmegleChat): def __init__(self,name,color=0): OmegleChat.__init__(self) @@ -34,9 +37,11 @@ class OmegleProxyChat(OmegleChat): self.partner.stopped_typing() def on_disconnect(self): print self.c("%s [EVT] %s disconnect" % (time.strftime("%H:%M:%S"), self.name)) + chat_lock.release() logging.basicConfig(level=logging.DEBUG) +print "press ctrl-c to abort" A=OmegleProxyChat("A",colors['red']) B=OmegleProxyChat("B",colors['blue']) @@ -46,9 +51,13 @@ B.set_partner(A) A.start() B.start() -print "press enter to abort" +chat_lock.acquire() try: - sys.stdin.readline() + while True: + if chat_lock.acquire(0): + break + else: + time.sleep(0.5) except KeyboardInterrupt: pass |