diff options
-rw-r--r-- | megahal_icq.py | 49 | ||||
-rw-r--r-- | omegle.py | 7 | ||||
-rw-r--r-- | omegle_icq.py | 114 |
3 files changed, 146 insertions, 24 deletions
diff --git a/megahal_icq.py b/megahal_icq.py index f9afeaa..8ae3dd6 100644 --- a/megahal_icq.py +++ b/megahal_icq.py @@ -1,6 +1,7 @@ #!/usr/bin/python import struct import sys +import thread from twisted.words.protocols import oscar from twisted.internet import reactor, protocol @@ -11,30 +12,31 @@ uin = '370496181' print "Enter icq password(megahal...): ", password = sys.stdin.readline().strip() -mh_python.initbrain() +def fill_hal(): + mh_python.initbrain() -conn = pyPgSQL.PgSQL.connect(database="omegle") -cur = conn.cursor() + conn = pyPgSQL.PgSQL.connect(database="omegle") + cur = conn.cursor() -cur.execute(""" -SELECT message from omegle_messages WHERE LENGTH(message) BETWEEN 3 AND 30 -AND NOT ( message ILIKE '%www.%' - OR message ILIKE '%http%' - OR message ILIKE '%@%.%') -""") -messages = cur.fetchall() -c=0 -for message in messages: - c+=1 - if c%500==0: - print "%s%s/%s" % ("\033[2K\033[E",c,len(messages)), - #XXX pass massage[0] to mh and end with a fucked up python - mh_python.learn("%s " % (message[0])) + cur.execute(""" + SELECT message from omegle_messages WHERE LENGTH(message) BETWEEN 3 AND 30 + AND NOT ( message ILIKE '%www.%' + OR message ILIKE '%http%' + OR message ILIKE '%@%.%') + """) + messages = cur.fetchall() + c=0 + for message in messages: + c+=1 + if c%500==0: + print "%s%s/%s" % ("\033[2K\033[E",c,len(messages)), + #XXX pass massage[0] to mh and end with a fucked up python + mh_python.learn("%s " % (message[0])) -print "%s%s/%s" % ("\033[2K\033[E",len(messages),len(messages)) -cur.close() -conn.close() -del messages + print "%s%s/%s" % ("\033[2K\033[E",len(messages),len(messages)) + cur.close() + conn.close() + del messages @@ -56,6 +58,8 @@ class icqBot( oscar.BOSConnection ): self.setProfile("Forget ICQ, MSN, Yahoo and the other shitty protocols! Use Jabber!") self.setIdleTime( 0 ) self.clientReady() + for user in buddylist[0][0].users: + self.sendAuthorizationResponse(user.name, True, '') print buddylist print 'ICQ-Autoresponder-Bot aktiviert ;-)' @@ -89,7 +93,8 @@ class icqBot( oscar.BOSConnection ): class OscarCrap( oscar.OscarAuthenticator ): BOSClass = icqBot - + +thread.start_new_thread(fill_hal,()) protocol.ClientCreator( reactor, OscarCrap, uin, password, icq=1 ).connectTCP( 'login.icq.com', 5238 ) reactor.run() @@ -34,6 +34,7 @@ class Timer(Thread): self.logger.debug("self.running == False") def stop(self): + """ XXX break func() ? """ self.running = False self.event.set() @@ -65,9 +66,10 @@ class RESTClient(object): class OmegleChat(RESTClient): def __init__(self,poll_interval=0.5,name="",host="omegle.com"): self.name = name + self.poll_interval=poll_interval RESTClient.__init__(self,host) - self.timer = Timer(self._events, poll_interval) + self.timer = Timer(self._events, poll_interval) self.logger = logging.getLogger(__name__ + "." + self.__class__.__name__ + name) self.is_confirmed = False #after getting a connection confirm self.is_connected = False #after having self.id @@ -86,8 +88,9 @@ class OmegleChat(RESTClient): self.id = id[1] self.logger.info("Connected id=%s" % self.id) #start /events polling - self.timer.start() self.is_connected = True + self.timer = Timer(self._events, self.poll_interval) + self.timer.start() else: self.logger.error("Bad response: %s" % body) raise Exception("Bad response: %s" % body) diff --git a/omegle_icq.py b/omegle_icq.py new file mode 100644 index 0000000..bd38526 --- /dev/null +++ b/omegle_icq.py @@ -0,0 +1,114 @@ +#!/usr/bin/python +import struct +import sys +import thread + +from twisted.words.protocols import oscar +from twisted.internet import reactor, protocol +from twisted.python import log + +from omegle import OmegleChat + + +randoms = [['370496181', 'megahal123'], ['446323989','gagaga']] +i=0 +uin = randoms[i][0] +password = randoms[i][1] + +class OmegleICQChat(OmegleChat): + def __init__(self,icqconn,user): + self.user = user + self.icqconn = icqconn + OmegleChat.__init__(self,name="("+user.name+")") + def on_message(self,message): + print "got message %s" % message + self.send_icqconn( message ) + + def send_icqconn(self,message): + reactor.callFromThread(self.icqconn.sendMessage, self.user.name, str(message) ) + + def on_connect(self): + print "connected" + self.send_icqconn( "== Stranger CONNECTED (type disconnect to disconnect) ==" ) + def on_disconnect(self): + print "disconnecteed" + self.send_icqconn( "==Stranger Disconnected ==" ) + + +class icqBot( oscar.BOSConnection ): + capabilities = [oscar.CAP_CHAT] + + def initDone( self ): + self.requestSelfInfo() + self.requestSSI().addCallback(self.gotBuddyList) + + self.omegleConns = {} + + def shutdown( self ): + for conn in self.omegleConns: + if conn.is_connected: + conn.disconnect() + + def updateBuddy(self, user): + print "Update buddy %s" % user + + def gotBuddyList( self, buddylist ): + self.activateSSI() + self.setProfile("Forget ICQ, MSN, Yahoo and the other shitty protocols! Use Jabber!") + self.setIdleTime( 0 ) + self.clientReady() + for user in buddylist[0][0].users: + print "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) + if not self.omegleConns.has_key(user.name): + self.omegleConns[user.name] = OmegleICQChat(self,user) + + try: + message = str(multiparts[0][0]) + if not self.omegleConns[user.name].is_connected: + if message == "connect": + self.omegleConns[user.name].start() + 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 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) + + 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: + packet += struct.pack("b", 1) + else: + packet += struct.pack("b", 0) + packet += struct.pack(">H", len(responsString)) + responsString + self.sendSNACnr(0x13, 0x1a, packet) + + +class OscarCrap( oscar.OscarAuthenticator ): + BOSClass = icqBot + + +log.startLogging(sys.stdout) +protocol.ClientCreator( reactor, OscarCrap, uin, password, icq=1 ).connectTCP( 'login.icq.com', 5238 ) +reactor.run() + |