示例#1
0
文件: message.py 项目: bmess/montybot
    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())
示例#2
0
 def _match_command(self, user, channel, msg):
     try:
         self.commands[msg].__call__(user, channel)
     except KeyError:
         self.msg(channel, smartass_reply())