summaryrefslogtreecommitdiff
path: root/proxy.py
diff options
context:
space:
mode:
Diffstat (limited to 'proxy.py')
-rw-r--r--proxy.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/proxy.py b/proxy.py
index 39c72a4..7faf430 100644
--- a/proxy.py
+++ b/proxy.py
@@ -40,7 +40,16 @@ class OmegleProxyChat(OmegleChat):
self.partner.idlecount = 0
print self.c("%s [MSG] %s: %s" %(time.strftime("%H:%M:%S"), self.name, message.encode("utf-8")),bold=True)
if self.partner.is_connected:
- self.partner.send(message)
+ try:
+ self.partner.send(message)
+ except Exception,e:
+ print e
+ try:
+ self.disconnect()
+ except:
+ pass
+ self.disconnect_event.set()
+
def on_connect(self):
print self.c("%s [EVT] %s Connection confirmed" % (time.strftime("%H:%M:%S"), self.name))
@@ -79,8 +88,11 @@ if __name__ == "__main__":
A.set_partner(B)
B.set_partner(A)
- A.start()
- B.start()
+ try:
+ A.start()
+ B.start()
+ except:
+ sys.exit(255)
try:
while True:
@@ -90,6 +102,12 @@ if __name__ == "__main__":
break
except KeyboardInterrupt:
print "CTRL-C pressed, exiting"
+ try:
+ if A.is_connected: A.disconnect()
+ except:
+ pass
- if A.is_connected: A.disconnect()
- if B.is_connected: B.disconnect()
+ try:
+ if B.is_connected: B.disconnect()
+ except:
+ pass