Example #1
0
    def run_command_hooks(self, message, private):
        """Run command hooks"""
        for mod_name, f, cmd in plugin.hook_get_commands():
            self.addressed = False

            if private:
                m = re.search("^%s$|^%s\s(.*)$" % (cmd, cmd), message, re.I)
                if m:
                    self.run_hook_command(mod_name, f, m.group(1),
                                          private=private,
                                          addressed=self.addressed,
                                          full_message=message)

            if message.startswith(self.command_prefix):
                # Strip off command prefix
                msg_rest = message[len(self.command_prefix):]
            else:
                # Check for command starting with nick being addressed
                msg_start_upper = message[:len(self.nick) + 1].upper()
                if msg_start_upper == self.nick.upper() + ':':
                    # Get rest of string after "nick:" and white spaces
                    msg_rest = re.sub("^\s+", "",
                                      message[len(self.nick) + 1:])
                else:
                    continue

                self.addressed = True

            m = re.search("^%s$|^%s\s(.*)$" % (cmd, cmd), msg_rest, re.I)
            if m:
                self.run_hook_command(mod_name, f, m.group(1), private=private,
                                      addressed=self.addressed,
                                      full_message=message)
Example #2
0
    def _find_doc_string(self, params):
        """Find the doc string for a command or keyword hook"""
        for _, cmd_hook, cmd in plugin.hook_get_commands():
            if cmd.upper() == params.upper():
                return cmd_hook.__doc__

        for _, kw_hook, kw in plugin.hook_get_keywords():
            if kw.upper() == params.upper():
                return kw_hook.__doc__

        return None
Example #3
0
    def _find_doc_string(self, params):
        """Find the doc string for a plugin, command or keyword hook"""
        for p in plugin.active_plugin_classes():
            if p.__name__.upper() == params.upper():
                return p.__doc__

        for _, cmd_hook, cmd in plugin.hook_get_commands():
            if cmd.upper() == params.upper():
                return cmd_hook.__doc__

        for _, kw_hook, kw in plugin.hook_get_keywords():
            if kw.upper() == params.upper():
                return kw_hook.__doc__

        return None
Example #4
0
    def _find_doc_string(self, params):
        """Find the doc string for a plugin, command or keyword hook"""
        for p in plugin.active_plugin_classes():
            if p.__name__.upper() == params.upper():
                return p.__doc__

        for _, cmd_hook, cmd in plugin.hook_get_commands():
            if cmd.upper() == params.upper():
                return cmd_hook.__doc__

        for _, kw_hook, kw in plugin.hook_get_keywords():
            if kw.upper() == params.upper():
                return kw_hook.__doc__

        return None