summaryrefslogtreecommitdiff
path: root/megahal_icq.py
diff options
context:
space:
mode:
Diffstat (limited to 'megahal_icq.py')
-rw-r--r--megahal_icq.py95
1 files changed, 95 insertions, 0 deletions
diff --git a/megahal_icq.py b/megahal_icq.py
new file mode 100644
index 0000000..f9afeaa
--- /dev/null
+++ b/megahal_icq.py
@@ -0,0 +1,95 @@
+#!/usr/bin/python
+import struct
+import sys
+
+from twisted.words.protocols import oscar
+from twisted.internet import reactor, protocol
+import mh_python
+import pyPgSQL.PgSQL
+
+uin = '370496181'
+print "Enter icq password(megahal...): ",
+password = sys.stdin.readline().strip()
+
+mh_python.initbrain()
+
+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]))
+
+print "%s%s/%s" % ("\033[2K\033[E",len(messages),len(messages))
+cur.close()
+conn.close()
+del messages
+
+
+
+
+
+class icqBot( oscar.BOSConnection ):
+ capabilities = [oscar.CAP_CHAT]
+# oscar.CAP_SEND_FILE,oscar.CAP_GET_FILE]
+
+ def initDone( self ):
+ self.requestSelfInfo()
+ self.requestSSI().addCallback(self.gotBuddyList)
+
+ 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()
+
+ print buddylist
+ print 'ICQ-Autoresponder-Bot aktiviert ;-)'
+
+ def receiveMessage( self, user, multiparts, flags ):
+ try:
+ sss = str(multiparts[0][0])
+ reply = mh_python.doreply(sss)
+ self.sendMessage(user.name, reply )
+ print "from: " + user.name+':', multiparts[0][0]
+ print " to: " + user.name+':',reply
+ self.sendAuthorizationResponse(user.name, True, '')
+ 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
+
+protocol.ClientCreator( reactor, OscarCrap, uin, password, icq=1 ).connectTCP( 'login.icq.com', 5238 )
+reactor.run()
+