summaryrefslogtreecommitdiff
path: root/icq_roombot.py
diff options
context:
space:
mode:
Diffstat (limited to 'icq_roombot.py')
-rw-r--r--icq_roombot.py60
1 files changed, 40 insertions, 20 deletions
diff --git a/icq_roombot.py b/icq_roombot.py
index f5c3147..ebb700c 100644
--- a/icq_roombot.py
+++ b/icq_roombot.py
@@ -1,26 +1,25 @@
#!/usr/bin/python
import struct
-import sys
-import thread
from twisted.words.protocols import oscar
from twisted.internet import reactor, protocol
-import mh_python
-
+from random import randint
uin = '370496181'
password = 'megahal123'
-
+CAP_TYPING = '\x56\x3f\xc8\x09\x0b\x6f\x41\xbd\x9f\x79\x42\x26\x09\xdf\xa2\xf3'
class icqBot( oscar.BOSConnection ):
- capabilities = [oscar.CAP_CHAT]
-# oscar.CAP_SEND_FILE,oscar.CAP_GET_FILE]
+ capabilities = [oscar.CAP_CHAT,CAP_TYPING]
def initDone( self ):
self.requestSelfInfo()
self.requestSSI().addCallback(self.gotBuddyList)
self.members = dict()
+ def oscar_04_14(self,snac):
+ pass #TODO: handle typing event - see omegle_icq.py
+
def updateBuddy(self, user):
print "Update buddy %s" % user
@@ -33,32 +32,50 @@ class icqBot( oscar.BOSConnection ):
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"):
+ if msg.strip() 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), ) )
-
+ self.sendMessage(user.name, "You left")
for member in self.members.keys():
- self.sendMessage(member, "======== %s joined" % nick)
- else:
+ self.sendMessage(user.name, "%s(%s) left"%(member,self.members[member]))
+ elif msg.strip().startswith("/list"):
+ names = ", ".join(
+ map(lambda key: "%s(%s)"%(self.members[key],key), self.members.keys()))
+ self.sendMessage(user.name, "Connected to: " + names)
+ elif msg.strip().startswith("/join"):
+ nick = msg.split("/join")[-1:][0] or user.name
+ self.sendMessage(user.name, "========= Joined as %s - to leave type >/leave<" % nick)
+ self.sendMessage(user.name, "Connected to: " + ", ".join(self.members.values()))
for member in self.members.keys():
- if member == user.name:
- continue
- self.sendMessage(member, "%s: %s"%(self.members[user.name], msg) )
+ self.sendMessage(member, "======== %s(%s) (re-)joined" % (nick,user.name))
+ self.members.update( ( (user.name, nick), ) )
+ elif user.name in self.members.keys():
+ if msg.strip().startswith("/invite"):
+ who = msg.split("/invite")[-1:][0] or False
+ if who:
+ self.sendMessage(who, "%s invite you to join this room" % user.name)
+ self.sendMessage(user.name, "Invitation sent to %s" % who)
+ else:
+ for member in self.members.keys():
+ if member == user.name:
+ continue
+ self.sendMessage(member, "%s: %s"%(self.members[user.name], msg) )
+ else:
+ if randint(0,5) == 3:
+ self.sendMessage(user.name, "Use '/join NICKNAME', '/list' and '/leave'")
+
self.sendAuthorizationResponse(user.name, True, '')
except Exception,e:
print "error: %s %s\n%s" % (user,multiparts,e)
+ except:
+ pass
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
@@ -72,6 +89,9 @@ class icqBot( oscar.BOSConnection ):
packet += struct.pack(">H", len(responsString)) + responsString
self.sendSNACnr(0x13, 0x1a, packet)
+ def connectionLost(self,*args,**kwargs):
+ print "Connection lost"
+
class OscarCrap( oscar.OscarAuthenticator ):
BOSClass = icqBot