summaryrefslogtreecommitdiff
path: root/omegle_icq.py
diff options
context:
space:
mode:
Diffstat (limited to 'omegle_icq.py')
-rw-r--r--omegle_icq.py88
1 files changed, 64 insertions, 24 deletions
diff --git a/omegle_icq.py b/omegle_icq.py
index 6100e7b..67861fe 100644
--- a/omegle_icq.py
+++ b/omegle_icq.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+# -*- vim: encoding: utf-8 -*-
import struct
import sys
import thread
@@ -19,17 +20,17 @@ class OmegleICQChat(OmegleChat):
def __init__(self,icqconn,user):
self.user = user
self.icqconn = icqconn
- OmegleChat.__init__(self,name="("+user+")")
+ OmegleChat.__init__(self,name="omegle")
def on_message(self,message):
- print "%s: omegle got message %s" % (self.user,message)
self.send_icqconn( message )
def send_icqconn(self,message):
- print "%s: send to icq %s" % (self.user,message)
#send stopped typing snac
reactor.callFromThread(self.icqconn.sendSNAC, 0x04, 0x14, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'+chr(len(self.user))+self.user+"\x00\x00")
- message = message.decode("utf-8")
- message = message.encode("iso-8859-1")
+ #von omegle kommt immer unicode
+ message = unicode(message) #message.decode("utf-8")
+ message = message.encode("iso-8859-1","replace")
+ print "Omegle->%s: %s" % (self.user,message.__repr__())
reactor.callFromThread(self.icqconn.sendMessage, self.user, message )
def on_typing(self):
@@ -39,16 +40,17 @@ class OmegleICQChat(OmegleChat):
0x00 finish
"""
reactor.callFromThread(self.icqconn.sendSNAC, 0x04, 0x14, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'+chr(len(self.user))+self.user+"\x00\x02")
- print "begin typing"
+ print "Omegle->%s: (begin typing)" % self.user
def on_stopped_typing(self):
reactor.callFromThread(self.icqconn.sendSNAC, 0x04, 0x14, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'+chr(len(self.user))+self.user+"\x00\x01")
def on_connect(self):
- print "%s: omegle connected" % self.user
+ print "Omegle->%s: (connected)" % self.user
self.send_icqconn( "== Sup dawg, we heard u like to meet strangers so we put a Stranger in ur chat so u can chat while u chat (until you type \"disconnect\" without quotes) ==" )
+
def on_disconnect(self):
- print "%s: omegle disconnecteed" % self.user
+ print "Omegle->%s: (disconnected)" % self.user
self.send_icqconn( "==Stranger Disconnected ==" )
CAP_TYPING = '\x56\x3f\xc8\x09\x0b\x6f\x41\xbd\x9f\x79\x42\x26\x09\xdf\xa2\xf3'
@@ -61,6 +63,9 @@ class icqBot( oscar.BOSConnection ):
self.factory = factory
oscar.BOSConnection.__init__(self, s, p,**kwargs)
+ """
+ handles typing SNAC
+ """
def oscar_04_14(self,snac):
data = snac[3]
if len(data) == len("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\t222840035\x00\x02"):
@@ -98,7 +103,7 @@ class icqBot( oscar.BOSConnection ):
conn.disconnect()
def updateBuddy(self, user):
- print "Update buddy %s" % user
+ print "icq: Update buddy %s" % user
def gotBuddyList( self, buddylist ):
self.activateSSI()
@@ -106,28 +111,49 @@ class icqBot( oscar.BOSConnection ):
self.setIdleTime( 0 )
self.clientReady()
for user in buddylist[0][0].users:
- print "Authorize %s" % user.name
+ print "icq: Authorize %s" % user.name
self.sendAuthorizationResponse(user.name, True, '')
- print 'ICQ-Autoresponder-Bot aktiviert ;-)'
-
def receiveMessage( self, user, multiparts, flags ):
- print "receiveMessage(%s,%s,%s)" % (user,multiparts,flags)
+ print "icq: receiveMessage(%s,%s,%s)" % (user,multiparts,flags)
if "auto" in flags:
print "'auto' message, abort"
return
+ # because i cant receive the "budded added signal" i auth on every message
self.sendAuthorizationResponse(user.name, True, '')
if not self.omegleConns.has_key(user.name):
self.omegleConns[user.name] = OmegleICQChat(self,user.name)
try:
- message = str(multiparts[0][0])
+ message = None
+ if len(multiparts[0]) == 2:
+ if multiparts[0][1] == "unicode":
+ message = unicode(multiparts[0][0])
+ else:
+ try:
+ message = multiparts[0][0].decode(multiparts[0][1])
+ except Exception,e:
+ self.sendMessage(user.name,str(e))
+ else:
+ try:
+ message = str(multiparts[0][0])
+ except Exception,e:
+ self.sendMessage(user.name,str(e))
+
+ #filter qip \x00CHAR\x00CHAR - qip sucks at unicode?
+ message_neu = filter(lambda x: x!=u"\x00", message)
+ if len(message_neu) != len(message):
+ client_sucks = True
+ message = message_neu
+
if not self.omegleConns[user.name].is_connected:
- if message == "connect":
+ if message == u"connect":
self.omegleConns[user.name].start()
self.sendMessage(user.name, "Please stand by.....")
+ if client_sucks:
+ self.sendMessage(user.name, "Hey, dein ICQ-Client sendet scheiss")
else:
self.sendMessage(user.name, "Not connected, type >connect<")
elif self.omegleConns[user.name].is_connected and message == "disconnect":
@@ -139,12 +165,21 @@ class icqBot( oscar.BOSConnection ):
elif self.omegleConns[user.name].is_connected and not self.omegleConns[user.name].is_confirmed:
self.sendMessage(user.name, "Wait for connection confirm from omegle")
else:
- if len(multiparts[0]) == 2:
- print "send to omegle: %s" % message.decode(multiparts[0][1])
- self.omegleConns[user.name].send(message.decode(multiparts[0][1]))
- else:
- print "send to omegle: %s" % message
- self.omegleConns[user.name].send(message)
+# if len(multiparts[0]) == 2:
+# print "send to omegle: %s" % message.decode(multiparts[0][1])
+# if multiparts[0][1] == "unicode":
+# self.omegleConns[user.name].send(unicode(message))
+# else:
+ try:
+# self.omegleConns[user.name].send(message.decode(multiparts[0][1]))
+ print "%s->Omegle: %s" % (user.name, message.__repr__())
+ self.omegleConns[user.name].send(message)
+ except Exception,e:
+ print "icq(%s): Error %s" % (user.name,e)
+ self.sendMessage(user.name,str(e))
+# else:
+# print "send to omegle: %s" % message
+# self.omegleConns[user.name].send(message)
except Exception,e:
print "error: %s %s -> %s" % (user,multiparts,e)
@@ -160,7 +195,10 @@ class icqBot( oscar.BOSConnection ):
packet += struct.pack(">H", len(responsString)) + responsString
self.sendSNACnr(0x13, 0x1a, packet)
def connectionLost(self,reason):
- print reason
+ print "connnection los called: %s " % reason
+ print dir(self)
+ self.factory.connectionLost(reason)
+ #self.shutdown()
@@ -194,7 +232,8 @@ class OscarFactory(ClientFactory):
print 'Started to connect to oscar'
def connectionLost(self,reason):
- print "CONECTION LOST"
+ print "CONECTION LOST - start njew factory"
+ reactor.connectTCP('login.icq.com', 5238, OscarFactory(uin,password,icq=1))
class OscarClientFactory(ReconnectingClientFactory):
def startedConnecting(self, connector):
@@ -220,7 +259,8 @@ class OscarClientFactory(ReconnectingClientFactory):
# reason)
-
+import logging
+logging.basicConfig(level=logging.INFO)
log.startLogging(sys.stdout)
#protocol.ClientCreator( reactor, OscarCrap, uin, password, icq=1 ).connectTCP( 'login.icq.com', 5238 )