summaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
authoryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-05-27 20:26:48 +0000
committeryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-05-27 20:26:48 +0000
commita4ff0b42f0621fe75ce53b795baace1672bf07de (patch)
tree44e3fb7937f4482b0d169b44a73c8be86c4ca77c /test.py
parent12277dd2d2c3283b074f70ba2f33645ed839e6fb (diff)
downloadomegle-a4ff0b42f0621fe75ce53b795baace1672bf07de.tar.gz
omegle-a4ff0b42f0621fe75ce53b795baace1672bf07de.zip
blah
git-svn-id: http://xapek.org/svn/common/omegle@1015 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
Diffstat (limited to 'test.py')
-rw-r--r--test.py44
1 files changed, 23 insertions, 21 deletions
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)
+