commands.typed module¶
- exception commands.typed.ArgumentError(message='', language=None, **tokens)[source]¶
Bases:
ValidationError
- exception commands.typed.ArgumentNumberMismatch(message='', language=None, **tokens)[source]¶
Bases:
ArgumentError
- exception commands.typed.InvalidArgumentValue(message='', language=None, **tokens)[source]¶
Bases:
ArgumentError
- exception commands.typed.SubCommandError(message='', language=None, **tokens)[source]¶
Bases:
ValidationError
- exception commands.typed.SubCommandExpectedError(message='', language=None, **tokens)[source]¶
Bases:
SubCommandError
- exception commands.typed.SubCommandNotFound(message='', language=None, **tokens)[source]¶
Bases:
SubCommandError
- exception commands.typed.ValidationError(message='', language=None, **tokens)[source]¶
Bases:
Exception
- 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.
- reply(msg, language=None, **tokens)[source]¶
Reply to the command issuer.
- Parameters:
msg (str/TranslationStrings) – Message to send.
language (str) – Language to be used.
tokens – Translation tokens for message.
- property auto_command_return¶
Determine the probably most desired
CommandReturn
value.For server commands it will always return
CommandReturn.CONTINUE
. Client commands will always useCommandReturn.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. OtherwiseCommandReturn.CONTINUE
is used.- Return type:
- class commands.typed.CommandNode(commands, params, callback, description, permission, fail_callback, requires_registration)[source]¶
Bases:
Node
- class commands.typed.CommandParser(commands=None, description=None)[source]¶
Bases:
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:
- clean_command(command, args)[source]¶
Clean a command and its passed arguments.
- Parameters:
command (CommandNode)
args (iterable) – The arguments to clean.
- Return type:
- 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:
See also
- 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:
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:
- 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.TypedClientCommand(*args, **kwargs)[source]¶
Bases:
_TypedPlayerCommand
Decorator class to create typed client commands.
- classmethod get_auto_command_return(info)[source]¶
Return the most desired
CommandReturn
value.- Return type:
- manager = <commands.client._ClientCommandManager object>¶
- parser = {}¶
- class commands.typed.TypedSayCommand(*args, **kwargs)[source]¶
Bases:
_TypedPlayerCommand
Decorator class to create typed say commands.
- classmethod get_auto_command_return(info)[source]¶
Return the most desired
CommandReturn
value.- Return type:
- manager = <commands.say._SayCommandManager object>¶
- parser = {}¶
- class commands.typed.TypedServerCommand(*args, **kwargs)[source]¶
Bases:
_TypedCommand
Decorator class to create typed server commands.
- classmethod get_auto_command_return(info)[source]¶
Return the most desired
CommandReturn
value.- Return type:
- manager = <commands.server._ServerCommandManager object>¶
- parser = {'sp': {'auth': {'backend': {'list': <commands.typed.CommandNode object>, 'set': <commands.typed.CommandNode object>}, 'permission': {'parent': {'add': <commands.typed.CommandNode object>, 'add_parent': <commands.typed.CommandNode object>, 'list': <commands.typed.CommandNode object>, 'remove': <commands.typed.CommandNode object>, 'remove_parent': <commands.typed.CommandNode object>}, 'player': {'add': <commands.typed.CommandNode object>, 'add_parent': <commands.typed.CommandNode object>, 'remove': <commands.typed.CommandNode object>, 'remove_parent': <commands.typed.CommandNode object>, 'test': <commands.typed.CommandNode object>}}}, 'credits': <commands.typed.CommandNode object>, 'delay': <commands.typed.CommandNode object>, 'docs': {'build': <commands.typed.CommandNode object>, 'create': <commands.typed.CommandNode object>, 'generate': <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>}, 'help': <commands.typed.CommandNode object>, 'info': <commands.typed.CommandNode object>, 'plugin': {'list': <commands.typed.CommandNode object>, 'load': <commands.typed.CommandNode object>, 'reload': <commands.typed.CommandNode object>, 'unload': <commands.typed.CommandNode object>}, 'update': <commands.typed.CommandNode object>}}¶