commands.typed module

exception commands.typed.ArgumentError(message='')[source]

Bases: commands.typed.ValidationError

exception commands.typed.ArgumentNumberMismatch(message='')[source]

Bases: commands.typed.ArgumentError

exception commands.typed.InvalidArgumentValue(message='')[source]

Bases: commands.typed.ArgumentError

exception commands.typed.SubCommandError(message='')[source]

Bases: commands.typed.ValidationError

exception commands.typed.SubCommandExpectedError(message='')[source]

Bases: commands.typed.SubCommandError

exception commands.typed.SubCommandNotFound(message='')[source]

Bases: commands.typed.SubCommandError

exception commands.typed.ValidationError(message='')[source]

Bases: Exception

__init__(message='')[source]
class commands.typed.CommandInfo(command, typed_command_cls, index=None, team_only=None)[source]

Bases: object

Stores command information for typed commands.

__init__(command, typed_command_cls, index=None, team_only=None)[source]

Initializes the instance.

Parameters:
  • command (Command) – The actual Command instance.
  • typed_command_cls (_TypedCommand) – Command this instance belongs to.
  • index (int) – The index of the player that issued the command. None, if it’s a server command.
  • team_only (bool) – Indicates whether the command was issued in team chat. None, if it’s a server or client command.
is_private_command()[source]

Return True if it’s a private command.

Return type:bool
reply(msg)[source]

Reply to the command issuer.

Parameters:msg (str) – Message to send.
auto_command_return

Determine the probably most desired CommandReturn value.

For server commands it will always return CommandReturn.CONTINUE. Client commands will always use CommandReturn.BLOCK. For say commands it’s determined by checking the prefix. If the command starts with a slash (/) it’s handled as a private command. Thus, CommandReturn.BLOCK is returned. Otherwise CommandReturn.CONTINUE is used.

Return type:CommandReturn
class commands.typed.CommandNode(commands, params, callback, description, permission, fail_callback, requires_registration)[source]

Bases: commands.typed.Node

__init__(commands, params, callback, description, permission, fail_callback, requires_registration)[source]

Initialize the object.

signature

Return the full signature of a command.

Return type:str
class commands.typed.CommandParser(commands=None, description=None)[source]

Bases: commands.typed.Store

add_command(commands, params, callback, description=None, permission=None, fail_callback=None)[source]

Add a command to the parser.

Parameters:
  • commands (str/list/tuple) – Command to register.
  • params (iterable) – Parameters of the command.
  • callback (callable) – The callback for the command.
  • description (str) – Description of the command.
  • permission (str) – Required permission to use the command.
  • fail_callback (callable) – Callback that gets called if authorization failed.
Return type:

CommandNode

clean_command(command, args)[source]

Clean a command and its passed arguments.

Parameters:
  • command (CommandNode) –
  • args (iterable) – The arguments to clean.
Return type:

list

Raises:
  • InvalidArgumentValue – Raised if the value is invalid for an argument.
  • ArgumentNumberMismatch – Raised if too many/less arguments have been passed.
get_command(commands)[source]

Return a command.

Parameters:str/list/tuple – Command to search.
Return type:CommandNode

See also

get_node()

get_node(commands)[source]

Return a node.

Parameters:str/list/tuple – Node to seach.
Raises:ValueError – Raised if the node does not exist.
Return type:Node

See also

_validate_command()

parse_command(command)[source]

Parse a Command object.

Splits the command into the actual command and its arguments.

Parameters:

command (Command) – A command to parse.

Raises:
  • SubCommandNotFound – Raised if a sub command was not found.
  • SubCommandExpected – Raised if a sub command was expected, but more arguments have been passed.
Return type:

tuple

remove_command(commands)[source]

Remove a command.

Parameters:str/list/tuple – Command to remove.

See also

_remove_command()

See also

_validate_commands()

set_node_description(commands, description)[source]

Set the description of a node.

Parameters:str/list/tuple – Node to seach.
Raises:ValueError – Raised if the node does not exist.
class commands.typed.Node(commands, description)[source]

Bases: object

__init__(commands, description)[source]
signature

Return the signature of the node.

Return type:str
class commands.typed.Store(commands=None, description=None)[source]

Bases: commands.typed.Node, dict

__init__(commands=None, description=None)[source]
help_text

Return the help text of the node.

Return type:str
signature

Return the signature of the node.

Return type:str
class commands.typed.TypedClientCommand(commands, permission=None, fail_callback=None)[source]

Bases: commands.typed._TypedPlayerCommand

Decorator class to create typed client commands.

classmethod get_auto_command_return(info)[source]
static send_message(command_info, message)[source]
manager = <commands.client._ClientCommandManager object>
parser = {}
class commands.typed.TypedSayCommand(commands, permission=None, fail_callback=None)[source]

Bases: commands.typed._TypedPlayerCommand

Decorator class to create typed say commands.

classmethod get_auto_command_return(info)[source]
static send_message(command_info, message)[source]
manager = <commands.say._SayCommandManager object>
parser = {}
class commands.typed.TypedServerCommand(commands, permission=None, fail_callback=None)[source]

Bases: commands.typed._TypedCommand

Decorator class to create typed server commands.

classmethod get_auto_command_return(info)[source]
static send_message(command_info, message)[source]
manager = <commands.server._ServerCommandManager object>
parser = {'sp': {'delay': <commands.typed.CommandNode object>, 'credits': <commands.typed.CommandNode object>, 'help': <commands.typed.CommandNode object>, 'info': <commands.typed.CommandNode object>, 'update': <commands.typed.CommandNode object>, 'auth': {'backend': {'set': <commands.typed.CommandNode object>, 'list': <commands.typed.CommandNode object>}, 'permission': {'player': {'add': <commands.typed.CommandNode object>, 'remove': <commands.typed.CommandNode object>, 'add_parent': <commands.typed.CommandNode object>, 'remove_parent': <commands.typed.CommandNode object>, 'test': <commands.typed.CommandNode object>}, 'parent': {'add': <commands.typed.CommandNode object>, 'remove': <commands.typed.CommandNode object>, 'add_parent': <commands.typed.CommandNode object>, 'remove_parent': <commands.typed.CommandNode object>, 'list': <commands.typed.CommandNode object>}}}, 'docs': {'create': <commands.typed.CommandNode object>, 'generate': <commands.typed.CommandNode object>, 'build': <commands.typed.CommandNode object>}, 'dump': {'class_info': <commands.typed.CommandNode object>, 'convars': <commands.typed.CommandNode object>, 'datamaps': <commands.typed.CommandNode object>, 'server_classes': <commands.typed.CommandNode object>, 'string_tables': <commands.typed.CommandNode object>, 'weapon_scripts': <commands.typed.CommandNode object>}, 'plugin': {'load': <commands.typed.CommandNode object>, 'unload': <commands.typed.CommandNode object>, 'reload': <commands.typed.CommandNode object>, 'list': <commands.typed.CommandNode object>}}}
commands.typed.filter_str(expr)[source]