class TopGunBot(BotPlugin): min_err_version = '1.6.0' __metaclass__ = TopGunBotBuilder def __init__(self): super(BotPlugin, self).__init__() self.topgun = TopGun() @botcmd def mav(self, mess, args): """Alias for maverick""" return self.maverick(mess, args) def callback_message(self, conn, mess): """Listen for TOP GUN mentions and interject random quotes from those characters who were mentioned. """ message = "" if mess.getBody().find("(mav)") != -1: message = "(mav) " + self.topgun.get_random("maverick") else: for character in CHARACTERS: if mess.getBody().find('(%s)' % character) != -1: message = '(%s) ' % character + self.topgun.get_random( character) break if message: self.send(mess.getFrom(), message, message_type=mess.getType())
class TopGunBot(BotPlugin): min_err_version = '1.6.0' __metaclass__ = TopGunBotBuilder def __init__(self): super(BotPlugin, self).__init__() self.topgun = TopGun() @botcmd def mav(self, mess, args): """Alias for maverick""" return self.maverick(mess, args) def callback_message(self, conn, mess): """Listen for TOP GUN mentions and interject random quotes from those characters who were mentioned. """ message = "" if mess.getBody().find("(mav)") != -1: message = "(mav) " + self.topgun.get_random("maverick") else: for character in CHARACTERS: if mess.getBody().find('(%s)' % character) != -1: message = '(%s) ' % character + self.topgun.get_random(character) break if message: self.send(mess.getFrom(), message, message_type=mess.getType())
class TopGunBot(BotPlugin): def activate(self): super(TopGunBot, self).activate() self.topgun_script = TopGun() logging.info(self.topgun_script.CHARACTERS.keys()) @botcmd(split_args_with=' ') def topgun(self, mess, args): character = args[0] if character not in self.topgun_script.CHARACTERS.keys(): character = choice(self.topgun_script.CHARACTERS.keys()) return '%s: "%s"' % ( character, self.topgun_script.get_random(character).strip() )
class TopGunBot(BotPlugin): __metaclass__ = TopGunBotBuilder min_err_version = "1.6.0" def __init__(self): super(BotPlugin, self).__init__() self.topgun = TopGun() def callback_message(self, conn, mess): """Listen for TOP GUN mentions and interject random lines from those characters who were mentioned. """ if (mess.getFrom().getStripped() == config.BOT_IDENTITY["username"]) or (get_sender_username(mess) == config.CHATROOM_FN): logging.debug("Ignore a message from myself") return False message = "" for character in TopGun.CHARACTERS: if mess.getBody().find("(%s)" % character) != -1: message += "(%s) %s " % (character, self.topgun.get_random(character)) if message: self.send(mess.getFrom(), message, message_type=mess.getType())
class TopGunBot(BotPlugin): __metaclass__ = TopGunBotBuilder min_err_version = "1.6.0" def __init__(self): super(BotPlugin, self).__init__() self.topgun = TopGun() def callback_message(self, conn, mess): """Listen for TOP GUN mentions and interject random lines from those characters who were mentioned. """ if (mess.getFrom().getStripped() == config.BOT_IDENTITY["username"] ) or (get_sender_username(mess) == config.CHATROOM_FN): logging.debug("Ignore a message from myself") return False message = "" for character in TopGun.CHARACTERS: if mess.getBody().find("(%s)" % character) != -1: message += "(%s) %s " % (character, self.topgun.get_random(character)) if message: self.send(mess.getFrom(), message, message_type=mess.getType())
def __init__(self): super(BotPlugin, self).__init__() self.topgun = TopGun()
def activate(self): super(TopGunBot, self).activate() self.topgun_script = TopGun() logging.info(self.topgun_script.CHARACTERS.keys())