def privmsg(self, nick, chan, msg):
     msg = msg.decode()
     match = re.match('\!say (.*)', msg)
     if match:
         to_say = match.group(1).strip()
         print('Saying, "%s"' % to_say)
         helpers.msg(self.client, chan, to_say)
Exemple #2
0
    def tryBotCommand(self, prefix, dest, msg):
        """ tests a command to see if its a command for the bot, returns True
        and calls self.processBotCommand(cmd, sender) if its is.
        """
    
        logging.debug("tryBotCommand('%s' '%s' '%s')" % (prefix, dest, msg))

        if dest == self.client.nick:
            dest = parse_nick(prefix)[0]
        elif msg.startswith(self.client.nick):
            msg = msg[len(self.client.nick)+1:]
        else: 
            return False

        msg = msg.strip()

        parts = msg.split(' ', 1)
        command = parts[0]
        arg = parts[1:]

        try:
            self.command_handler.run(command, prefix, dest, *arg)
        except CommandError, e:
            helpers.msg(self.client, dest, str(e))
Exemple #3
0
    def help(self, sender, dest, arg=None):
        """list all available commands or get help on a specific command"""
        logging.info('help sender=%s dest=%s arg=%s' % (sender, dest, arg))
        if not arg:
            commands = self.getVisibleCommands()
            commands.sort()
            helpers.msg(self.client, dest, 
                "available commands: %s" % " ".join(commands))
        else:
            try:
                f = self.get(arg)
            except CommandError, e:
                helpers.msg(self.client, dest, str(e))
                return
                
            doc = f.__doc__.strip() if f.__doc__ else "No help available"

            if not inspect.ismethod(f):
                subcommands = self.getVisibleCommands(f)
                if subcommands:
                    doc += " [sub commands: %s]" % " ".join(subcommands)

            helpers.msg(self.client, dest, "%s: %s" % (arg, doc))