diff options
author | yvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd> | 2009-07-03 20:43:51 +0000 |
---|---|---|
committer | yvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd> | 2009-07-03 20:43:51 +0000 |
commit | f743a0c7e71cf4cf152144a76a2041b731c95919 (patch) | |
tree | 5051e107a5b4a25be9399dff8dcec3be3031dd04 | |
parent | 55ff032856b22aa5e91a3416b83f69f577f732d3 (diff) | |
download | omegle-f743a0c7e71cf4cf152144a76a2041b731c95919.tar.gz omegle-f743a0c7e71cf4cf152144a76a2041b731c95919.zip |
icq up
git-svn-id: http://xapek.org/svn/common/omegle@1175 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
-rw-r--r-- | omegle.py | 2 | ||||
-rw-r--r-- | omegle_icq.py | 31 |
2 files changed, 21 insertions, 12 deletions
@@ -100,7 +100,7 @@ class OmegleChat(RESTClient): self.logger.debug("disconnect()") self.is_confirmed = False self.timer.stop() - if self.is_confirmed: + if self.is_connected: r = RESTClient.request(self,"POST", "/disconnect", urllib.urlencode({'id': self.id})) body = r.read() self.logger.debug("/disconnect sent. Read: %s" % body) diff --git a/omegle_icq.py b/omegle_icq.py index bd38526..82c8c04 100644 --- a/omegle_icq.py +++ b/omegle_icq.py @@ -21,17 +21,18 @@ class OmegleICQChat(OmegleChat): self.icqconn = icqconn OmegleChat.__init__(self,name="("+user.name+")") def on_message(self,message): - print "got message %s" % message + print "%s: 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) ) def on_connect(self): - print "connected" + print "%s: connected" % self.user.name self.send_icqconn( "== Stranger CONNECTED (type disconnect to disconnect) ==" ) def on_disconnect(self): - print "disconnecteed" + print "%s: disconnecteed" % self.user.name self.send_icqconn( "==Stranger Disconnected ==" ) @@ -65,6 +66,12 @@ class icqBot( oscar.BOSConnection ): def receiveMessage( self, user, multiparts, flags ): print "receiveMessage(%s,%s,%s)" % (user,multiparts,flags) + if "auto" in flags: + print "'auto' message, abort" + return + + self.sendAuthorizationResponse(user.name, True, '') + if not self.omegleConns.has_key(user.name): self.omegleConns[user.name] = OmegleICQChat(self,user) @@ -76,13 +83,15 @@ class icqBot( oscar.BOSConnection ): self.sendMessage(user.name, "Connecting you to omegle") else: self.sendMessage(user.name, "Not connected, type >connect<") + elif self.omegleConns[user.name].is_connected and message == "disconnect": + try: + self.omegleConns[user.name].disconnect() + except Exception,e: + self.sendMessage(user.name, str(e)) + self.sendMessage(user.name, "Disconnecting") 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") - elif self.omegleConns[user.name].is_confirmed and message == "disconnect": - self.omegleConns[user.name].disconnect() - self.sendMessage(user.name, "Disconnecting") else: - print "Send: %s" % message self.omegleConns[user.name].send(message) except Exception,e: print "error: %s %s\n%s" % (user,multiparts,e) @@ -90,10 +99,6 @@ class icqBot( oscar.BOSConnection ): def chatReceiveMessage( self, chat, user, message ): self.receiveMessage( self, user, message, 0 ) - def receiveSendFileRequest(self, *args): -# def receiveSendFileRequest(self, user, file, description, cookie): - print args - def sendAuthorizationResponse(self, uin, success, responsString): packet = struct.pack("b", len(uin)) + uin if success: @@ -102,6 +107,10 @@ class icqBot( oscar.BOSConnection ): packet += struct.pack("b", 0) 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 ): |