From c8bb25bf151c95ec4d7254f939d788b84a39cbd2 Mon Sep 17 00:00:00 2001 From: yvesf Date: Thu, 28 May 2009 10:48:00 +0000 Subject: blah git-svn-id: http://xapek.org/svn/common/omegle@1024 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd --- proxy.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/proxy.py b/proxy.py index c995e51..1711198 100644 --- a/proxy.py +++ b/proxy.py @@ -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 -- cgit v1.2.1