def test_output(self):
        response = cmd_help.execute(self.cmd, self.uid, self.bot)
        text = [x.replace('`', '').replace('-', '').strip()
                for x in response[0].split('\n')[1:-1]]

        assert response[0].startswith(
            "Here are all the commands I know how to execute:\n")
        assert len(text) == len(COMMANDS)

        for cmd in list(COMMANDS.values()):
            assert cmd in text
Beispiel #2
0
def parse_command(line):
    """
    Determine the command and dispatch the proper handler function.
    """
    tokens = line.split()
    cmd, args = tokens[0], tokens[1:]
    try:
        log.info("%s: %s", cmd, args)
        return COMMANDS.get(cmd, default_cmd)(args)
    except Exception as e:
        log.error("%s: %s", cmd, e)
        return 'error'
Beispiel #3
0
def parse_command(line):
    """
    Determine the command and dispatch the proper handler function.
    """
    tokens = line.split()
    cmd, args = tokens[0].decode('utf-8'), tokens[1:]
    try:
        log.info("%s: %s", cmd, args)
        result = COMMANDS.get(cmd, default_cmd)(args)
        if isinstance(result, bytes):
            return result.decode('utf-8')
        else:
            return result
    except Exception as e:
        log.error("%s: %s", cmd, e)
        return 'error'