From a4ff0b42f0621fe75ce53b795baace1672bf07de Mon Sep 17 00:00:00 2001 From: yvesf Date: Wed, 27 May 2009 20:26:48 +0000 Subject: blah git-svn-id: http://xapek.org/svn/common/omegle@1015 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd --- test.py | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'test.py') diff --git a/test.py b/test.py index 58daaaf..950ba8d 100644 --- a/test.py +++ b/test.py @@ -75,7 +75,7 @@ class OmegleChat(object): OmegleChat.headers) r=conn.getresponse() body=r.read() - self.on_event(conn,body) + self.dispatch_event(conn,body) conn.close() def send(self,msg): @@ -103,7 +103,7 @@ class OmegleChat(object): raise Exception("/typing; Bad response %s" % body) - def on_event(self,conn,body): + def dispatch_event(self,conn,body): try: data_set=json.read(body) for data in data_set: @@ -128,23 +128,25 @@ class OmegleChat(object): def on_connect(self): print "Connected" def on_typing(self): - print "Stranger typing" + print "Stranger is typing" def on_disconnect(self): - print "Stranger Disconnectect" - -chat = OmegleChat() -chat.start() - -while 1==1: - try: - cmd=sys.stdin.readline().strip() - except KeyboardInterrupt: - chat.disconnect() - sys.exit(0) - if cmd=="quit": - chat.disconnect() - break - else: - print ">>> %s" % cmd - chat.send(cmd) - + print "Stranger Disconnectet" + + +if __name__ == "__main__": + print "Lets chat. Type \"quit\" to disconnect" + chat = OmegleChat() + chat.start() + while 1==1: + try: + cmd=sys.stdin.readline().strip() + except KeyboardInterrupt: + chat.disconnect() + break + if cmd=="quit": + chat.disconnect() + break + else: + print ">>> %s" % cmd + chat.send(cmd) + -- cgit v1.2.1