def callback_message(self, conn, mess): #if mess.getBody(): # logging.debug(u'Received message %s' % mess.getBody()) if mess.getType() in ('groupchat', 'chat'): try: username = get_jid_from_message(mess) if username in CHATROOM_RELAY: logging.debug('Message to relay from %s.' % username) body = mess.getBody() rooms = CHATROOM_RELAY[username] for room in rooms: self.send(room, body, message_type='groupchat') except Exception, e: logging.exception('crashed in callback_message %s' % e)
def admin_only(mess): if mess.getType() == 'groupchat': raise Exception('You cannot administer the bot from a chatroom, message the bot directly') usr = get_jid_from_message(mess) if usr not in BOT_ADMINS: raise Exception('You cannot administer the bot from this user %s.' % usr)