summaryrefslogtreecommitdiff
path: root/omegle_icq.py
diff options
context:
space:
mode:
Diffstat (limited to 'omegle_icq.py')
-rw-r--r--omegle_icq.py87
1 files changed, 76 insertions, 11 deletions
diff --git a/omegle_icq.py b/omegle_icq.py
index 82c8c04..4c4c257 100644
--- a/omegle_icq.py
+++ b/omegle_icq.py
@@ -11,7 +11,7 @@ from omegle import OmegleChat
randoms = [['370496181', 'megahal123'], ['446323989','gagaga']]
-i=0
+i=1
uin = randoms[i][0]
password = randoms[i][1]
@@ -21,24 +21,64 @@ class OmegleICQChat(OmegleChat):
self.icqconn = icqconn
OmegleChat.__init__(self,name="("+user.name+")")
def on_message(self,message):
- print "%s: got message %s" % (self.user.name,message)
+ print "%s: omegle got message %s" % (self.user.name,message)
self.send_icqconn( message )
def send_icqconn(self,message):
- print "%s: send %s" % (self.user.name,message)
- reactor.callFromThread(self.icqconn.sendMessage, self.user.name, str(message) )
+ print "%s: send to icq %s" % (self.user.name,message)
+ reactor.callFromThread(self.icqconn.sendSNAC, 0x04, 0x14, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'+chr(len(self.user.name))+self.user.name+"\x00\x00")
+ reactor.callFromThread(self.icqconn.sendMessage, self.user.name, message.decode('utf8').encode('iso-8859-1') )
+
+ def on_typing(self):
+ """
+ 0x02 begin
+ 0x01 idle
+ 0x00 finish
+ """
+ reactor.callFromThread(self.icqconn.sendSNAC, 0x04, 0x14, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'+chr(len(self.user.name))+self.user.name+"\x00\x02")
+ print "begin typing"
+
+ 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.name))+self.user.name+"\x00\x01")
def on_connect(self):
- print "%s: connected" % self.user.name
+ print "%s: omegle connected" % self.user.name
self.send_icqconn( "== Stranger CONNECTED (type disconnect to disconnect) ==" )
def on_disconnect(self):
- print "%s: disconnecteed" % self.user.name
+ print "%s: omegle disconnecteed" % self.user.name
self.send_icqconn( "==Stranger Disconnected ==" )
+CAP_TYPING = '\x56\x3f\xc8\x09\x0b\x6f\x41\xbd\x9f\x79\x42\x26\x09\xdf\xa2\xf3'
+# [4, 20, 0, 0, 2854066430L, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\t222840035\x00\x02']
class icqBot( oscar.BOSConnection ):
- capabilities = [oscar.CAP_CHAT]
+ capabilities = [oscar.CAP_CHAT,CAP_TYPING]
+ 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"):
+ user = data[11:20]
+ state = data[20:22]
+ if not self.omegleConns.has_key(user):
+ self.omegleConns[user] = OmegleICQChat(self,user)
+
+ if state == "\x00\x00": #finish
+ try:
+ self.omegleConns[user].stopped_typing()
+ except:
+ pass
+ elif state == "\x00\x01": #idle
+ pass
+ elif state == "\x00\x02": #begin
+ try:
+ self.omegleConns[user].typing()
+ except:
+ pass
+ else:
+ print "Unknown state in typing snac\nuser %s\ndata %s\nsnac %s\nstate %X%X" % (user,data,snac,state[0],sate[1])
+ else:
+ print "komisches tpying snac"
+
def initDone( self ):
self.requestSelfInfo()
self.requestSSI().addCallback(self.gotBuddyList)
@@ -92,7 +132,7 @@ 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:
- self.omegleConns[user.name].send(message)
+ self.omegleConns[user.name].send(message.decode(multiparts[0][1]))
except Exception,e:
print "error: %s %s\n%s" % (user,multiparts,e)
@@ -108,16 +148,41 @@ class icqBot( oscar.BOSConnection ):
packet += struct.pack(">H", len(responsString)) + responsString
self.sendSNACnr(0x13, 0x1a, packet)
def connectionLost(self,reason):
- oscar.BOSConnection.connectionLost(self,reason)
print reason
- self.connect()
+
class OscarCrap( oscar.OscarAuthenticator ):
BOSClass = icqBot
+
+from twisted.internet.protocol import Protocol, ReconnectingClientFactory
+
+class OscarClientFactory(ReconnectingClientFactory):
+ def startedConnecting(self, connector):
+ print 'Started to connect.'
+
+ def buildProtocol(self, addr):
+ print 'Connected.'
+ print 'Resetting reconnection delay'
+ self.resetDelay()
+ return protocol.ClientCreator( reactor, OscarCrap, uin, password, icq=1 ).connectTCP( 'login.icq.com', 5238 )
+
+
+ def clientConnectionLost(self, connector, reason):
+ print 'Lost connection. Reason:', reason
+ ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
+
+ def clientConnectionFailed(self, connector, reason):
+ print 'Connection failed. Reason:', reason
+ ReconnectingClientFactory.clientConnectionFailed(self, connector,
+ reason)
+
+
+
log.startLogging(sys.stdout)
-protocol.ClientCreator( reactor, OscarCrap, uin, password, icq=1 ).connectTCP( 'login.icq.com', 5238 )
+#protocol.ClientCreator( reactor, OscarCrap, uin, password, icq=1 ).connectTCP( 'login.icq.com', 5238 )
+reactor.connectTCP('login.icq.com', 5238, OscarClientFactory())
reactor.run()