summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--icq_roombot.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/icq_roombot.py b/icq_roombot.py
new file mode 100644
index 0000000..f5c3147
--- /dev/null
+++ b/icq_roombot.py
@@ -0,0 +1,82 @@
+#!/usr/bin/python
+import struct
+import sys
+import thread
+
+from twisted.words.protocols import oscar
+from twisted.internet import reactor, protocol
+import mh_python
+
+
+uin = '370496181'
+password = 'megahal123'
+
+
+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)
+ self.members = dict()
+
+ 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:
+ self.sendAuthorizationResponse(user.name, True, '')
+
+ print buddylist
+ print 'ICQ-Autoresponder-Bot aktiviert ;-)'
+
+ def receiveMessage( self, user, multiparts, flags ):
+ try:
+ msg = str(multiparts[0][0])
+ if msg in ("leave", "LEAVE"):
+ self.members.pop(user.name)
+ self.sendMessage(user.name, "You leaved")
+ elif msg.startswith("join"):
+ nick = msg.split("join")[-1:][0] or user.name
+ self.sendMessage(user.name, "========= Joined as %s - leave: type >leave<" % nick)
+ self.members.update( ( (user.name, nick), ) )
+
+ for member in self.members.keys():
+ self.sendMessage(member, "======== %s joined" % nick)
+ else:
+ for member in self.members.keys():
+ if member == user.name:
+ continue
+ self.sendMessage(member, "%s: %s"%(self.members[user.name], msg) )
+ 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()
+