Exemplo n.º 1
0
    def _help(self, data, connection):
        """
        Command to provide in-game help with commands.

        If invoked with no arguments, lists all commands available to a player.
        When invoked with a trailing command, provides usage details for the
        command.

        :param data: The packet containing the command.
        :param connection: The connection which sent the command.
        :return: Null.
        """
        if not data:
            commands = []
            for c, f in self.commands.items():
                if connection.player.perm_check(f.perm):
                    commands.append(c)
            send_message(connection,
                         "Available commands: {}".format(" ".join(
                             [command for command in sorted(commands)])))
        else:
            try:
                docstring = self.commands[data[0]].__doc__
                send_message(connection,
                             "Help for {}: {}".format(data[0], docstring),
                             get_syntax(data[0],
                                        self.commands[data[0]],
                                        self.command_prefix))
            except KeyError:
                self.logger.error("Help failed on command {}.".format(data[0]))
                send_message(connection,
                             "Unknown command {}.".format(data[0]))
Exemplo n.º 2
0
    def _help(self, data, connection):
        """
        Command to provide in-game help with commands.

        If invoked with no arguments, lists all commands available to a player.
        When invoked with a trailing command, provides usage details for the
        command.

        :param data: The packet containing the command.
        :param connection: The connection which sent the command.
        :return: Null.
        """
        if not data:
            commands = []
            for c, f in self.commands.items():
                if connection.player.perm_check(f.perm):
                    commands.append(c)
            send_message(
                connection, "Available commands: {}".format(" ".join(
                    [command for command in sorted(commands)])))
        else:
            try:
                docstring = self.commands[data[0]].__doc__
                send_message(
                    connection, "Help for {}: {}".format(data[0], docstring),
                    get_syntax(data[0], self.commands[data[0]],
                               self.command_prefix))
            except KeyError:
                self.logger.error("Help failed on command {}.".format(data[0]))
                send_message(connection, "Unknown command {}.".format(data[0]))
Exemplo n.º 3
0
    def _send_syntax_error(self, command, error, connection):
        """
        Sends a syntax error to the user regarding a command.

        :param command: The command name
        :param error: The error (a string or an exception)
        :param connection: The player connection.
        :return: None.
        """
        send_message(
            connection, "Syntax error: {}".format(error),
            get_syntax(command, self.commands[command],
                       self.plugin_config.command_prefix))
        return None
Exemplo n.º 4
0
    def _send_syntax_error(self, command, error, connection):
        """
        Sends a syntax error to the user regarding a command.

        :param command: The command name
        :param error: The error (a string or an exception)
        :param connection: The player connection.
        :return: None.
        """
        send_message(connection,
                     "Syntax error: {}".format(error),
                     get_syntax(command,
                                self.commands[command],
                                self.plugin_config.command_prefix))
        return None