commands.manager module

Provides a base class for registering commands and filters.

class commands.manager._BaseCommandManager[source]

Bases: object

Class used to (un)register commands.

__init__()[source]

Initialize the command manager.

_get_command_proxy(callback)[source]

Return the command proxy for the given callback.

Parameters:callback (callable) – The callback that should be used to search the proxy.
Raises:ValueError – Raised if the proxy wasn’t found.
_prepare_command_names(names)[source]

Validate and prepare the given command names.

Parameters:names (str/list/tuple) – A single command or multiple commands that should be validated.
Raises:TypeError – Raised if names is not a str, list or class:tuple.
Return type:tuple
_register_command(name, callback, *args, **kwargs)[source]

Register a command.

Parameters:
  • name (str) – A single command name that should be registred.
  • callback (callable) – The callback that should get called when the command has been issued.
  • args – Additional arguments passed from register_commands().
  • kwargs – Additional keywords passed from register_commands().
register_commands(names, callback, *args, **kwargs)[source]

Register the given commands to the given callback.

Parameters:
  • names (str/list/tuple) – Command names that should be registered.
  • callback (callable) – A callback that should get called when one of the commands were issued.
  • args – Additional arguments that get passed to the proxy (if existant) and to _register_command().
  • kwargs – Additional keywords that get passed to the proxy (if existant) and to _register_command().
unregister_commands(names, callback)[source]

Unregister the given commands from the given callback.

Parameters:
  • names (str/list/tuple) – Command names to unregister.
  • callback (callable) – The callback that was registered for the commands.
_callback_proxy = None