diff options
author | yvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd> | 2009-05-27 20:40:05 +0000 |
---|---|---|
committer | yvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd> | 2009-05-27 20:40:05 +0000 |
commit | 66203bf1383ef3df1ec38840e49799329c4d49e4 (patch) | |
tree | f9113f606440fc8d034d549a8ed6d2747bbdbed5 | |
parent | a4ff0b42f0621fe75ce53b795baace1672bf07de (diff) | |
download | omegle-66203bf1383ef3df1ec38840e49799329c4d49e4.tar.gz omegle-66203bf1383ef3df1ec38840e49799329c4d49e4.zip |
cool
git-svn-id: http://xapek.org/svn/common/omegle@1016 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
-rw-r--r-- | omegle.py (renamed from test.py) | 7 | ||||
-rw-r--r-- | proxy.py | 41 |
2 files changed, 46 insertions, 2 deletions
@@ -32,7 +32,7 @@ class OmegleChat(object): def __init__(self,poll_interval=0.5): self.conn = httplib.HTTPConnection('www.omegle.com') -# self.conn.set_debuglevel(100) +# self.conn.set_debuglevel(1) self.conn_lock = Lock() @@ -90,7 +90,7 @@ class OmegleChat(object): if body != "win": raise Exception("/send; Bad response %s" % body) - def typing(self,msg): + def typing(self): self.conn_lock.acquire() self.conn.request("POST", "/typing", @@ -106,6 +106,9 @@ class OmegleChat(object): def dispatch_event(self,conn,body): try: data_set=json.read(body) + if not data_set: + print "No Data received" + return for data in data_set: if data[0] == "typing": self.on_typing() diff --git a/proxy.py b/proxy.py new file mode 100644 index 0000000..5c37bb7 --- /dev/null +++ b/proxy.py @@ -0,0 +1,41 @@ +from omegle import OmegleChat +import sys + + +class OmegleProxyChat(OmegleChat): + def __init__(self,name): + OmegleChat.__init__(self) + self.name = name + + def set_partner(self,partner): + self.partner = partner + + def on_message(self,message): + print "%s: %s" %(self.name, message) + self.partner.send(message) + def on_connect(self): + print "%s Connected" % self.name + def on_typing(self): + print "%s is typing" % self.name + self.partner.typing() + def on_disconnect(self): + print "%s disconnect" % self.name + self.partner.disconnect() + +A=OmegleProxyChat("A") +B=OmegleProxyChat("B") + +A.set_partner(B) +B.set_partner(A) + +A.start() +B.start() + +print "press enter to abort" +sys.stdin.readline() + +A.disconnect() +B.disconnect() + + + |