def callback_message( self, conn, mess): """Messages sent to the bot will arrive here. Command handling + routing is done in this function.""" type=mess.getType() if type == "chat": JabberBot.callback_message(self,conn,mess) elif type == "groupchat": print unicode(mess.getFrom())+ ': '+ unicode(mess.getBody()) text = mess.getBody() if not text: return if ' ' in text: command, args = text.split(' ',1) else: command, args = text,'' cmd=command.lower() if self.commands.has_key(cmd): reply=self.commands[cmd](mess,args) else: reply='' if reply: self.send(room_name, reply, mess)
def __init__(self, username, password, res=None, debug=False): self.start_time = time.localtime() self.msg = EventThread(self) self.msg.start() JabberBot.__init__(self, username, password, res, debug)
def __init__(self, jid, passwd, res = None): """Initializes the jabber bot and sets up commands.""" #super(jid, password, res=res) JabberBot.__init__(self,jid,passwd,res= res) self.comid={'ping':{},'version':{}}