def _match_command(self): """ Call the command that matches anything in our command dict. If no matches, return a smartass reply. """ commands = [func for command, func in self.bot_instance.commands.items() \ if self._msg_contains_cmd(command)] # if nothing available, send a smartass reply if len(commands) > 0: if len(commands) <= self.MAX_COMMANDS: for cmd in commands: cmd.__call__(self.user, self.channel) else: self.bot_instance.msg(self.channel, greedy_reply()) else: self.bot_instance.msg(self.channel, smartass_reply())
def _match_command(self, user, channel, msg): try: self.commands[msg].__call__(user, channel) except KeyError: self.msg(channel, smartass_reply())