commands.typed module¶
-
exception
commands.typed.
ArgumentNumberMismatch
(message='', language=None, **tokens)[source]¶ Bases:
commands.typed.ArgumentError
-
exception
commands.typed.
InvalidArgumentValue
(message='', language=None, **tokens)[source]¶ Bases:
commands.typed.ArgumentError
-
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.
-
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: CommandReturn
-
-
class
commands.typed.
CommandNode
(commands, params, callback, description, permission, fail_callback, requires_registration)[source]¶ Bases:
commands.typed.Node
-
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:
-
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: CommandNode 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: 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:
-
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.
Store
(commands=None, description=None)[source]¶ Bases:
commands.typed.Node
,dict
-
class
commands.typed.
TypedClientCommand
(commands, permission=None, fail_callback=None)[source]¶ Bases:
commands.typed._TypedPlayerCommand
Decorator class to create typed client commands.
-
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.
-
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.
-
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>}}}¶
-