evennia.commands package

This sub-package contains Evennia’s command system. It handles everything related to parsing input from the account, building cmdsets and executing the code associated with a found command class.

commands.default contains all the default “mux-like” commands of Evennia.

Submodules

evennia.commands.cmdhandler module

Command handler

This module contains the infrastructure for accepting commands on the command line. The processing of a command works as follows:

  1. The calling object (caller) is analyzed based on its callertype.

  2. Cmdsets are gathered from different sources: - channels: all available channel names are auto-created into a cmdset, to allow

    for giving the channel name and have the following immediately sent to the channel. The sending is performed by the CMD_CHANNEL system command.

    • object cmdsets: all objects at caller’s location are scanned for non-empty cmdsets. This includes cmdsets on exits.

    • caller: the caller is searched for its own currently active cmdset.

    • account: lastly the cmdsets defined on caller.account are added.

  3. The collected cmdsets are merged together to a combined, current cmdset.

  4. If the input string is empty -> check for CMD_NOINPUT command in current cmdset or fallback to error message. Exit.

  5. The Command Parser is triggered, using the current cmdset to analyze the input string for possible command matches.

  6. If multiple matches are found -> check for CMD_MULTIMATCH in current cmdset, or fallback to error message. Exit.

  7. If no match was found -> check for CMD_NOMATCH in current cmdset or fallback to error message. Exit.

  8. A single match was found. If this is a channel-command (i.e. the ommand name is that of a channel), –> check for CMD_CHANNEL in current cmdset or use channelhandler default. Exit.

  9. At this point we have found a normal command. We assign useful variables to it that will be available to the command coder at run-time.

  1. We have a unique cmdobject, primed for use. Call all hooks:

at_pre_cmd(), cmdobj.parse(), cmdobj.func() and finally at_post_cmd().

  1. Return deferred that will fire with the return from cmdobj.func() (unused by default).

evennia.commands.cmdhandler.cmdhandler(called_by, raw_string, _testing=False, callertype='session', session=None, cmdobj=None, cmdobj_key=None, **kwargs)[source]

This is the main mechanism that handles any string sent to the engine.

Parameters
  • called_by (Session, Account or Object) – Object from which this command was called. which this was called from. What this is depends on the game state.

  • raw_string (str) – The command string as given on the command line.

  • _testing (bool, optional) – Used for debug purposes and decides if we should actually execute the command or not. If True, the command instance will be returned.

  • callertype (str, optional) – One of “session”, “account” or “object”. These are treated in decending order, so when the Session is the caller, it will merge its own cmdset into cmdsets from both Account and eventual puppeted Object (and cmdsets in its room etc). An Account will only include its own cmdset and the Objects and so on. Merge order is the same order, so that Object cmdsets are merged in last, giving them precendence for same-name and same-prio commands.

  • session (Session, optional) – Relevant if callertype is “account” - the session will help retrieve the correct cmdsets from puppeted objects.

  • cmdobj (Command, optional) – If given a command instance, this will be executed using called_by as the caller, raw_string representing its arguments and (optionally) cmdobj_key as its input command name. No cmdset lookup will be performed but all other options apply as normal. This allows for running a specific Command within the command system mechanism.

  • cmdobj_key (string, optional) – Used together with cmdobj keyword to specify which cmdname should be assigned when calling the specified Command instance. This is made available as self.cmdstring when the Command runs. If not given, the command will be assumed to be called as cmdobj.key.

Kwargs:
kwargs (any): other keyword arguments will be assigned as named variables on the

retrieved command object before it is executed. This is unused in default Evennia but may be used by code to set custom flags or special operating conditions for a command as it executes.

Returns

This deferred is fired with the return value of the command’s func method. This is not used in default Evennia.

Return type

deferred (Deferred)

exception evennia.commands.cmdhandler.InterruptCommand[source]

Bases: Exception

Cleanly interrupt a command.

evennia.commands.cmdparser module

The default command parser. Use your own by assigning settings.COMMAND_PARSER to a Python path to a module containing the replacing cmdparser function. The replacement parser must accept the same inputs as the default one.

evennia.commands.cmdparser.build_matches(raw_string, cmdset, include_prefixes=False)[source]

Build match tuples by matching raw_string against available commands.

Parameters
  • raw_string (str) – Input string that can look in any way; the only assumption is that the sought command’s name/alias must be first in the string.

  • cmdset (CmdSet) – The current cmdset to pick Commands from.

  • include_prefixes (bool) – If set, include prefixes like @, ! etc (specified in settings) in the match, otherwise strip them before matching.

Returns

matches (list) A list of match tuples created by cmdparser.create_match.

evennia.commands.cmdparser.cmdparser(raw_string, cmdset, caller, match_index=None)[source]

This function is called by the cmdhandler once it has gathered and merged all valid cmdsets valid for this particular parsing.

Parameters
  • raw_string (str) – The unparsed text entered by the caller.

  • cmdset (CmdSet) – The merged, currently valid cmdset

  • caller (Session, Account or Object) – The caller triggering this parsing.

  • match_index (int, optional) – Index to pick a given match in a list of same-named command matches. If this is given, it suggests this is not the first time this function was called: normally the first run resulted in a multimatch, and the index is given to select between the results for the second run.

Returns

This is a list of match-tuples as returned by create_match.

If no matches were found, this is an empty list.

Return type

matches (list)

Notes

The cmdparser understand the following command combinations (where [] marks optional parts.

` [cmdname[ cmdname2 cmdname3 ...] [the rest] `

A command may consist of any number of space-separated words of any length, and contain any character. It may also be empty.

The parser makes use of the cmdset to find command candidates. The parser return a list of matches. Each match is a tuple with its first three elements being the parsed cmdname (lower case), the remaining arguments, and the matched cmdobject from the cmdset.

evennia.commands.cmdparser.create_match(cmdname, string, cmdobj, raw_cmdname)[source]

Builds a command match by splitting the incoming string and evaluating the quality of the match.

Parameters
  • cmdname (str) – Name of command to check for.

  • string (str) – The string to match against.

  • cmdobj (str) – The full Command instance.

  • raw_cmdname (str, optional) – If CMD_IGNORE_PREFIX is set and the cmdname starts with one of the prefixes to ignore, this contains the raw, unstripped cmdname, otherwise it is None.

Returns

This is on the form (cmdname, args, cmdobj, cmdlen, mratio, raw_cmdname),

where cmdname is the command’s name and args is the rest of the incoming string, without said command name. cmdobj is the Command instance, the cmdlen is the same as len(cmdname) and mratio is a measure of how big a part of the full input string the cmdname takes up - an exact match would be 1.0. Finally, the raw_cmdname is the cmdname unmodified by eventual prefix-stripping.

Return type

match (tuple)

evennia.commands.cmdparser.try_num_prefixes(raw_string)[source]

Test if user tried to separate multi-matches with a number separator (default 1-name, 2-name etc). This is usually called last, if no other match was found.

Parameters

raw_string (str) – The user input to parse.

Returns

If a multimatch-separator was detected,

this is stripped out as an integer to separate between the matches. The new_raw_string is the result of stripping out that identifier. If no such form was found, returns (None, None).

Return type

mindex, new_raw_string (tuple)

Example

In the default configuration, entering 2-ball (e.g. in a room will more than one ‘ball’ object), will lead to a multimatch and this function will parse “2-ball” and return (2, “ball”).

evennia.commands.cmdset module

A Command Set (CmdSet) holds a set of commands. The Cmdsets can be merged and combined to create new sets of commands in a non-destructive way. This makes them very powerful for implementing custom game states where different commands (or different variations of commands) are available to the accounts depending on circumstance.

The available merge operations are partly borrowed from mathematical Set theory.

  • Union The two command sets are merged so that as many commands as

    possible of each cmdset ends up in the merged cmdset. Same-name commands are merged by priority. This is the most common default. Ex: A1,A3 + B1,B2,B4,B5 = A1,B2,A3,B4,B5

  • Intersect - Only commands found in both cmdsets (i.e. which have

    same names) end up in the merged cmdset, with the higher-priority cmdset replacing the lower one. Ex: A1,A3 + B1,B2,B4,B5 = A1

  • Replace - The commands of this cmdset completely replaces the

    lower-priority cmdset’s commands, regardless of if same-name commands exist. Ex: A1,A3 + B1,B2,B4,B5 = A1,A3

  • Remove - This removes the relevant commands from the

    lower-priority cmdset completely. They are not replaced with anything, so this in effects uses the high-priority cmdset as a filter to affect the low-priority cmdset. Ex: A1,A3 + B1,B2,B4,B5 = B2,B4,B5

class evennia.commands.cmdset.CmdSet(cmdsetobj=None, key=None)[source]

Bases: object

This class describes a unique cmdset that understands priorities. CmdSets can be merged and made to perform various set operations on each other. CmdSets have priorities that affect which of their ingoing commands gets used.

In the examples, cmdset A always have higher priority than cmdset B.

key - the name of the cmdset. This can be used on its own for game operations

mergetype (partly from Set theory):

Union - The two command sets are merged so that as many

commands as possible of each cmdset ends up in the merged cmdset. Same-name commands are merged by priority. This is the most common default. Ex: A1,A3 + B1,B2,B4,B5 = A1,B2,A3,B4,B5

Intersect - Only commands found in both cmdsets

(i.e. which have same names) end up in the merged cmdset, with the higher-priority cmdset replacing the lower one. Ex: A1,A3 + B1,B2,B4,B5 = A1

Replace - The commands of this cmdset completely replaces

the lower-priority cmdset’s commands, regardless of if same-name commands exist. Ex: A1,A3 + B1,B2,B4,B5 = A1,A3

Remove - This removes the relevant commands from the

lower-priority cmdset completely. They are not replaced with anything, so this in effects uses the high-priority cmdset as a filter to affect the low-priority cmdset. Ex: A1,A3 + B1,B2,B4,B5 = B2,B4,B5

Note: Commands longer than 2 characters and starting

with double underscrores, like ‘__noinput_command’ are considered ‘system commands’ and are excempt from all merge operations - they are ALWAYS included across mergers and only affected if same-named system commands replace them.

priority- All cmdsets are always merged in pairs of two so that

the higher set’s mergetype is applied to the lower-priority cmdset. Default commands have priority 0, high-priority ones like Exits and Channels have 10 and 9. Priorities can be negative as well to give default commands preference.

duplicates - determines what happens when two sets of equal

priority merge. Default has the first of them in the merger (i.e. A above) automatically taking precedence. But if allow_duplicates is true, the result will be a merger with more than one of each name match. This will usually lead to the account receiving a multiple-match error higher up the road, but can be good for things like cmdsets on non-account objects in a room, to allow the system to warn that more than one ‘ball’ in the room has the same ‘kick’ command defined on it, so it may offer a chance to select which ball to kick … Allowing duplicates only makes sense for Union and Intersect, the setting is ignored for the other mergetypes.

key_mergetype (dict) - allows the cmdset to define a unique

mergetype for particular cmdsets. Format is {CmdSetkeystring:mergetype}. Priorities still apply. Example: {‘Myevilcmdset’,’Replace’} which would make sure for this set to always use ‘Replace’ on Myevilcmdset no matter what overall mergetype this set has.

no_objs - don’t include any commands from nearby objects

when searching for suitable commands

no_exits - ignore the names of exits when matching against

commands

no_channels - ignore the name of channels when matching against

commands (WARNING- this is dangerous since the account can then not even ask staff for help if something goes wrong)

__init__(cmdsetobj=None, key=None)[source]

Creates a new CmdSet instance.

Parameters
  • cmdsetobj (Session, Account, Object, optional) – This is the database object to which this particular instance of cmdset is related. It is often a character but may also be a regular object, Account or Session.

  • key (str, optional) – The idenfier for this cmdset. This helps if wanting to selectively remov cmdsets.

_duplicate()[source]

Returns a new cmdset with the same settings as this one (no actual commands are copied over)

Returns

A copy of the current cmdset.

Return type

cmdset (Cmdset)

_instantiate(cmd)[source]

checks so that object is an instantiated command and not, say a cmdclass. If it is, instantiate it. Other types, like strings, are passed through.

Parameters

cmd (any) – Entity to analyze.

Returns

An instantiated Command or the input unmodified.

Return type

result (any)

_intersect(cmdset_a, cmdset_b)[source]

Merge two sets using intersection merger

Parameters
  • cmdset_a (Cmdset) – Cmdset given higher priority in the case of a tie.

  • cmdset_b (Cmdset) – Cmdset given lower priority in the case of a tie.

Returns

The result of A (intersect) B operation.

Return type

cmdset_c (Cmdset)

Notes

Intersection, C = A (intersect) B, means that C only gets the

parts of A and B that are the same (that is, the commands of each set having the same name. Only the one of these having the higher prio ends up in C).

_remove(cmdset_a, cmdset_b)[source]

Filter a set by another.

Parameters
  • cmdset_a (Cmdset) – Cmdset acting as a removal filter.

  • cmdset_b (Cmdset) – Cmdset to filter

Returns

B, with all matching commands from A removed.

Return type

cmdset_c (Cmdset)

Notes

C = B - A, where A is used to remove the commands of B.

_replace(cmdset_a, cmdset_b)[source]

Replace the contents of one set with another

Parameters
  • cmdset_a (Cmdset) – Cmdset replacing

  • cmdset_b (Cmdset) – Cmdset to replace

Returns

This is indentical to cmdset_a.

Return type

cmdset_c (Cmdset)

Notes

C = A, where B is ignored.

_union(cmdset_a, cmdset_b)[source]

Merge two sets using union merger

Parameters
  • cmdset_a (Cmdset) – Cmdset given higher priority in the case of a tie.

  • cmdset_b (Cmdset) – Cmdset given lower priority in the case of a tie.

Returns

The result of A U B operation.

Return type

cmdset_c (Cmdset)

Notes

Union, C = A U B, means that C gets all elements from both A and B.

add(cmd)[source]

Add a new command or commands to this CmdSetcommand, a list of commands or a cmdset to this cmdset. Note that this is not a merge operation (that is handled by the + operator).

Parameters

cmd (Command, list, Cmdset) – This allows for adding one or more commands to this Cmdset in one go. If another Cmdset is given, all its commands will be added.

Notes

If cmd already exists in set, it will replace the old one (no priority checking etc happens here). This is very useful when overloading default commands).

If cmd is another cmdset class or -instance, the commands of that command set is added to this one, as if they were part of the original cmdset definition. No merging or priority checks are made, rather later added commands will simply replace existing ones to make a unique set.

at_cmdset_creation()[source]

Hook method - this should be overloaded in the inheriting class, and should take care of populating the cmdset by use of self.add().

count()[source]

Number of commands in set.

Returns

Number of commands in this Cmdset.

Return type

N (int)

duplicates = None
errmessage = ''
get(cmd)[source]

Get a command from the cmdset. This is mostly useful to check if the command is part of this cmdset or not.

Parameters

cmd (Command or str) – Either the Command object or its key.

Returns

The first matching Command in the set.

Return type

cmd (Command)

get_all_cmd_keys_and_aliases(caller=None)[source]

Collects keys/aliases from commands

Parameters

caller (Object, optional) – If set, this is used to check access permissions on each command. Only commands that pass are returned.

Returns

A list of all command keys and aliases in this cmdset. If caller

was given, this list will only contain commands to which caller passed the call locktype check.

Return type

names (list)

get_system_cmds()[source]

Get system commands in cmdset

Returns

The system commands in the set.

Return type

sys_cmds (list)

Notes

As far as the Cmdset is concerned, system commands are any commands with a key starting with double underscore __. These are excempt from merge operations.

key = 'Unnamed CmdSet'
key_mergetypes = {}
make_unique(caller)[source]

Remove duplicate command-keys (unsafe)

Parameters

caller (object) – Commands on this object will get preference in the duplicate removal.

Notes

This is an unsafe command meant to clean out a cmdset of doublet commands after it has been created. It is useful for commands inheriting cmdsets from the cmdhandler where obj-based cmdsets always are added double. Doublets will be weeded out with preference to commands defined on caller, otherwise just by first-come-first-served.

mergetype = 'Union'
no_channels = None
no_exits = None
no_objs = None
path = 'evennia.commands.cmdset.CmdSet'
permanent = False
priority = 0
remove(cmd)[source]

Remove a command instance from the cmdset.

Parameters

cmd (Command or str) – Either the Command object to remove or the key of such a command.

to_duplicate = ('key', 'cmdsetobj', 'no_exits', 'no_objs', 'no_channels', 'permanent', 'mergetype', 'priority', 'duplicates', 'errmessage')

evennia.commands.cmdsethandler module

CmdSethandler

The Cmdsethandler tracks an object’s ‘Current CmdSet’, which is the current merged sum of all CmdSets added to it.

A CmdSet constitues a set of commands. The CmdSet works as a special intelligent container that, when added to other CmdSet make sure that same-name commands are treated correctly (usually so there are no doublets). This temporary but up-to-date merger of CmdSet is jointly called the Current Cmset. It is this Current CmdSet that the commandhandler looks through whenever an account enters a command (it also adds CmdSets from objects in the room in real-time). All account objects have a ‘default cmdset’ containing all the normal in-game mud commands (look etc).

So what is all this cmdset complexity good for?

In its simplest form, a CmdSet has no commands, only a key name. In this case the cmdset’s use is up to each individual game - it can be used by an AI module for example (mobs in cmdset ‘roam’ move from room to room, in cmdset ‘attack’ they enter combat with accounts).

Defining commands in cmdsets offer some further powerful game-design consequences however. Here are some examples:

As mentioned above, all accounts always have at least the Default CmdSet. This contains the set of all normal-use commands in-game, stuff like look and @desc etc. Now assume our players end up in a dark room. You don’t want the player to be able to do much in that dark room unless they light a candle. You could handle this by changing all your normal commands to check if the player is in a dark room. This rapidly goes unwieldly and error prone. Instead you just define a cmdset with only those commands you want to be available in the ‘dark’ cmdset - maybe a modified look command and a ‘light candle’ command - and have this completely replace the default cmdset.

Another example: Say you want your players to be able to go fishing. You could implement this as a ‘fish’ command that fails whenever the account has no fishing rod. Easy enough. But what if you want to make fishing more complex - maybe you want four-five different commands for throwing your line, reeling in, etc? Most players won’t (we assume) have fishing gear, and having all those detailed commands is cluttering up the command list. And what if you want to use the ‘throw’ command also for throwing rocks etc instead of ‘using it up’ for a minor thing like fishing?

So instead you put all those detailed fishing commands into their own CommandSet called ‘Fishing’. Whenever the player gives the command ‘fish’ (presumably the code checks there is also water nearby), only THEN this CommandSet is added to the Cmdhandler of the account. The ‘throw’ command (which normally throws rocks) is replaced by the custom ‘fishing variant’ of throw. What has happened is that the Fishing CommandSet was merged on top of the Default ones, and due to how we defined it, its command overrules the default ones.

When we are tired of fishing, we give the ‘go home’ command (or whatever) and the Cmdhandler simply removes the fishing CommandSet so that we are back at defaults (and can throw rocks again).

Since any number of CommandSets can be piled on top of each other, you can then implement separate sets for different situations. For example, you can have a ‘On a boat’ set, onto which you then tack on the ‘Fishing’ set. Fishing from a boat? No problem!

evennia.commands.cmdsethandler.import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False)[source]

This helper function is used by the cmdsethandler to load a cmdset instance from a python module, given a python_path. It’s usually accessed through the cmdsethandler’s add() and add_default() methods. path - This is the full path to the cmdset object on python dot-form

Parameters
  • path (str) – The path to the command set to load.

  • cmdsetobj (CmdSet) – The database object/typeclass on which this cmdset is to be assigned (this can be also channels and exits, as well as accounts but there will always be such an object)

  • emit_to_obj (Object, optional) – If given, error is emitted to this object (in addition to logging)

  • no_logging (bool, optional) – Don’t log/send error messages. This can be useful if import_cmdset is just used to check if this is a valid python path or not.

Returns

The imported command set. If an error was

encountered, commands.cmdsethandler._ErrorCmdSet is returned for the benefit of the handler.

Return type

cmdset (CmdSet)

class evennia.commands.cmdsethandler.CmdSetHandler(obj, init_true=True)[source]

Bases: object

The CmdSetHandler is always stored on an object, this object is supplied as an argument.

The ‘current’ cmdset is the merged set currently active for this object. This is the set the game engine will retrieve when determining which commands are available to the object. The cmdset_stack holds a history of all CmdSets to allow the handler to remove/add cmdsets at will. Doing so will re-calculate the ‘current’ cmdset.

__init__(obj, init_true=True)[source]

This method is called whenever an object is recreated.

Parameters
  • obj (Object) – An reference to the game object this handler belongs to.

  • init_true (bool, optional) – Set when the handler is initializing and loads the current cmdset.

_import_cmdset(cmdset_path, emit_to_obj=None)[source]

Method wrapper for import_cmdset; Loads a cmdset from a module.

Parameters
  • cmdset_path (str) – The python path to an cmdset object.

  • emit_to_obj (Object) – The object to send error messages to

Returns

The imported cmdset.

Return type

cmdset (Cmdset)

add(cmdset, emit_to_obj=None, permanent=False, default_cmdset=False)[source]

Add a cmdset to the handler, on top of the old ones, unless it is set as the default one (it will then end up at the bottom of the stack)

Parameters
  • cmdset (CmdSet or str) – Can be a cmdset object or the python path to such an object.

  • emit_to_obj (Object, optional) – An object to receive error messages.

  • permanent (bool, optional) – This cmdset will remain across a server reboot.

  • default_cmdset (Cmdset, optional) – Insert this to replace the default cmdset position (there is only one such position, always at the bottom of the stack).

Notes

An interesting feature of this method is if you were to send it an already instantiated cmdset (i.e. not a class), the current cmdsethandler’s obj attribute will then not be transferred over to this already instantiated set (this is because it might be used elsewhere and can cause strange effects). This means you could in principle have the handler launch command sets tied to a different object than the handler. Not sure when this would be useful, but it’s a ‘quirk’ that has to be documented.

add_default(cmdset, emit_to_obj=None, permanent=True)[source]

Shortcut for adding a default cmdset.

Parameters
  • cmdset (Cmdset) – The Cmdset to add.

  • emit_to_obj (Object, optional) – Gets error messages

  • permanent (bool, optional) – The new Cmdset should survive a server reboot.

all()

Get all cmdsets.

Returns

All the command sets currently in the handler.

Return type

cmdsets (list)

clear()[source]

Removes all Command Sets from the handler except the default one (use self.remove_default to remove that).

delete(cmdset=None, default_cmdset=False)

Remove a cmdset from the handler.

Parameters
  • cmdset (CommandSet or str, optional) – This can can be supplied either as a cmdset-key, an instance of the CmdSet or a python path to the cmdset. If no key is given, the last cmdset in the stack is removed. Whenever the cmdset_stack changes, the cmdset is updated. If default_cmdset is set, this argument is ignored.

  • default_cmdset (bool, optional) – If set, this will remove the default cmdset (at the bottom of the stack).

delete_default()

This explicitly deletes only the default cmdset.

get()[source]

Get all cmdsets.

Returns

All the command sets currently in the handler.

Return type

cmdsets (list)

has(cmdset, must_be_default=False)[source]

checks so the cmdsethandler contains a given cmdset

Parameters
  • cmdset (str or Cmdset) – Cmdset key, pythonpath or Cmdset to check the existence for.

  • must_be_default (bool, optional) – Only return True if the checked cmdset is the default one.

Returns

Whether or not the cmdset is in the handler.

Return type

has_cmdset (bool)

has_cmdset(cmdset, must_be_default=False)

checks so the cmdsethandler contains a given cmdset

Parameters
  • cmdset (str or Cmdset) – Cmdset key, pythonpath or Cmdset to check the existence for.

  • must_be_default (bool, optional) – Only return True if the checked cmdset is the default one.

Returns

Whether or not the cmdset is in the handler.

Return type

has_cmdset (bool)

remove(cmdset=None, default_cmdset=False)[source]

Remove a cmdset from the handler.

Parameters
  • cmdset (CommandSet or str, optional) – This can can be supplied either as a cmdset-key, an instance of the CmdSet or a python path to the cmdset. If no key is given, the last cmdset in the stack is removed. Whenever the cmdset_stack changes, the cmdset is updated. If default_cmdset is set, this argument is ignored.

  • default_cmdset (bool, optional) – If set, this will remove the default cmdset (at the bottom of the stack).

remove_default()[source]

This explicitly deletes only the default cmdset.

reset()[source]

Force reload of all cmdsets in handler. This should be called after _CACHED_CMDSETS have been cleared (normally this is handled automatically by @reload).

update(init_mode=False)[source]

Re-adds all sets in the handler to have an updated current set.

Parameters

init_mode (bool, optional) – Used automatically right after this handler was created; it imports all permanent cmdsets from the database.

evennia.commands.command module

The base Command class.

All commands in Evennia inherit from the ‘Command’ class in this module.

class evennia.commands.command.Command(**kwargs)[source]

Bases: object

Base command

Usage:

command [args]

This is the base command class. Inherit from this to create new commands.

The cmdhandler makes the following variables available to the command methods (so you can always assume them to be there): self.caller - the game object calling the command self.cmdstring - the command name used to trigger this command (allows

you to know which alias was used, for example)

cmd.args - everything supplied to the command following the cmdstring

(this is usually what is parsed in self.parse())

cmd.cmdset - the cmdset from which this command was matched (useful only

seldomly, notably for help-type commands, to create dynamic help entries and lists)

cmd.obj - the object on which this command is defined. If a default command,

this is usually the same as caller.

cmd.rawstring - the full raw string input, including any args and no parsing.

The following class properties can/should be defined on your child class:

key - identifier for command (e.g. “look”) aliases - (optional) list of aliases (e.g. [“l”, “loo”]) locks - lock string (default is “cmd:all()”) help_category - how to organize this help entry in help system

(default is “General”)

auto_help - defaults to True. Allows for turning off auto-help generation arg_regex - (optional) raw string regex defining how the argument part of

the command should look in order to match for this command (e.g. must it be a space between cmdname and arg?)

(Note that if auto_help is on, this initial string is also used by the system to create the help entry for the command, so it’s a good idea to format it similar to this one). This behavior can be changed by overriding the method ‘get_help’ of a command: by default, this method returns cmd.__doc__ (that is, this very docstring, or the docstring of your command). You can, however, extend or replace this without disabling auto_help.

__init__(**kwargs)[source]

The lockhandler works the same as for objects. optional kwargs will be set as properties on the Command at runtime, overloading evential same-named class properties.

_keyaliases = ('command',)
_matchset = {'command'}
_optimize()[source]

Optimize the key and aliases for lookups.

_render_decoration(header_text=None, fill_character=None, edge_character=None, mode='header', color_header=True, width=None)[source]

Helper for formatting a string into a pretty display, for a header, separator or footer.

Kwargs:

header_text (str): Text to include in header. fill_character (str): This single character will be used to fill the width of the

display.

edge_character (str): This character caps the edges of the display. mode(str): One of ‘header’, ‘separator’ or ‘footer’. color_header (bool): If the header should be colorized based on user options. width (int): If not given, the client’s width will be used if available.

Returns

The decorated and formatted text.

Return type

string (str)

access(srcobj, access_type='cmd', default=False)[source]

This hook is called by the cmdhandler to determine if srcobj is allowed to execute this command. It should return a boolean value and is not normally something that need to be changed since it’s using the Evennia permission system directly.

Parameters
  • srcobj (Object) – Object trying to gain permission

  • access_type (str, optional) – The lock type to check.

  • default (bool, optional) – The fallback result if no lock of matching access_type is found on this Command.

aliases = []
arg_regex = None
at_post_cmd()[source]

This hook is called after the command has finished executing (after self.func()).

at_pre_cmd()[source]

This hook is called before self.parse() on all commands. If this hook returns anything but False/None, the command sequence is aborted.

auto_help = True
client_width()[source]

Get the client screenwidth for the session using this command.

Returns

The width (in characters) of the client window.

Return type

client width (int)

execute_cmd(raw_string, session=None, obj=None, **kwargs)[source]

A shortcut of execute_cmd on the caller. It appends the session automatically.

Parameters
  • raw_string (str) – Execute this string as a command input.

  • session (Session, optional) – If not given, the current command’s Session will be used.

  • obj (Object or Account, optional) – Object or Account on which to call the execute_cmd. If not given, self.caller will be used.

Kwargs:

Other keyword arguments will be added to the found command object instace as variables before it executes. This is unused by default Evennia but may be used to set flags and change operating paramaters for commands at run-time.

func()[source]

This is the actual executing part of the command. It is called directly after self.parse(). See the docstring of this module for which object properties are available (beyond those set in self.parse())

get_command_info()[source]

This is the default output of func() if no func() overload is done. Provided here as a separate method so that it can be called for debugging purposes when making commands.

get_extra_info(caller, **kwargs)[source]

Display some extra information that may help distinguish this command from others, for instance, in a disambiguity prompt.

If this command is a potential match in an ambiguous situation, one distinguishing feature may be its attachment to a nearby object, so we include this if available.

Parameters
  • caller (TypedObject) – The caller who typed an ambiguous

  • handed to the search function. (term) –

Returns

A string with identifying information to disambiguate the object, conventionally with a preceding space.

get_help(caller, cmdset)[source]

Return the help message for this command and this caller.

By default, return self.__doc__ (the docstring just under the class definition). You can override this behavior, though, and even customize it depending on the caller, or other commands the caller can use.

Parameters
  • caller (Object or Account) – the caller asking for help on the command.

  • cmdset (CmdSet) – the command set (if you need additional commands).

Returns

the help text to provide the caller for this command.

Return type

docstring (str)

help_category = 'general'
is_exit = False
key = 'command'
lock_storage = 'cmd:all();'
lockhandler[source]
locks = 'cmd:all();'
match(cmdname)[source]

This is called by the system when searching the available commands, in order to determine if this is the one we wanted. cmdname was previously extracted from the raw string by the system.

Parameters

cmdname (str) – Always lowercase when reaching this point.

Returns

Match result.

Return type

result (bool)

msg(text=None, to_obj=None, from_obj=None, session=None, **kwargs)[source]

This is a shortcut instead of calling msg() directly on an object - it will detect if caller is an Object or an Account and also appends self.session automatically if self.msg_all_sessions is False.

Parameters
  • text (str, optional) – Text string of message to send.

  • to_obj (Object, optional) – Target object of message. Defaults to self.caller.

  • from_obj (Object, optional) – Source of message. Defaults to to_obj.

  • session (Session, optional) – Supply data only to a unique session (ignores the value of self.msg_all_sessions).

Kwargs:

options (dict): Options to the protocol. any (any): All other keywords are interpreted as th

name of send-instructions.

msg_all_sessions = False
parse()[source]

Once the cmdhandler has identified this as the command we want, this function is run. If many of your commands have a similar syntax (for example ‘cmd arg1 = arg2’) you should simply define this once and just let other commands of the same form inherit from this. See the docstring of this module for which object properties are available to use (notably self.args).

save_for_next = False
search_index_entry = {'aliases': '', 'category': 'general', 'key': 'command', 'tags': '', 'text': '\n Base command\n\n Usage:\n command [args]\n\n This is the base command class. Inherit from this\n to create new commands.\n\n The cmdhandler makes the following variables available to the\n command methods (so you can always assume them to be there):\n self.caller - the game object calling the command\n self.cmdstring - the command name used to trigger this command (allows\n you to know which alias was used, for example)\n cmd.args - everything supplied to the command following the cmdstring\n (this is usually what is parsed in self.parse())\n cmd.cmdset - the cmdset from which this command was matched (useful only\n seldomly, notably for help-type commands, to create dynamic\n help entries and lists)\n cmd.obj - the object on which this command is defined. If a default command,\n this is usually the same as caller.\n cmd.rawstring - the full raw string input, including any args and no parsing.\n\n The following class properties can/should be defined on your child class:\n\n key - identifier for command (e.g. "look")\n aliases - (optional) list of aliases (e.g. ["l", "loo"])\n locks - lock string (default is "cmd:all()")\n help_category - how to organize this help entry in help system\n (default is "General")\n auto_help - defaults to True. Allows for turning off auto-help generation\n arg_regex - (optional) raw string regex defining how the argument part of\n the command should look in order to match for this command\n (e.g. must it be a space between cmdname and arg?)\n\n (Note that if auto_help is on, this initial string is also used by the\n system to create the help entry for the command, so it\'s a good idea to\n format it similar to this one). This behavior can be changed by\n overriding the method \'get_help\' of a command: by default, this\n method returns cmd.__doc__ (that is, this very docstring, or\n the docstring of your command). You can, however, extend or\n replace this without disabling auto_help.\n '}
set_aliases(new_aliases)[source]

Replace aliases with new ones.

Parameters

new_aliases (str or list) – Either a ;-separated string or a list of aliases. These aliases will replace the existing ones, if any.

Notes

This is necessary to use to make sure the optimization caches are properly updated as well.

set_key(new_key)[source]

Update key.

Parameters

new_key (str) – The new key.

Notes

This is necessary to use to make sure the optimization caches are properly updated as well.

Create a pretty footer.

styled_header(*args, **kwargs)[source]

Create a pretty header.

styled_separator(*args, **kwargs)[source]

Create a separator.

styled_table(*args, **kwargs)[source]

Create an EvTable styled by on user preferences.

Parameters

*args (str) – Column headers. If not colored explicitly, these will get colors from user options.

Kwargs:
any (str, int or dict): EvTable options, including, optionally a table dict

detailing the contents of the table.

Returns

An initialized evtable entity, either complete (if using table kwarg)

or incomplete and ready for use with .add_row or .add_collumn.

Return type

table (EvTable)

class evennia.commands.command.CommandMeta(*args, **kwargs)[source]

Bases: type

The metaclass cleans up all properties on the class

__init__(*args, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

exception evennia.commands.command.InterruptCommand[source]

Bases: Exception

Cleanly interrupt a command.

evennia.commands.command._init_command(cls, **kwargs)[source]

Helper command. Makes sure all data are stored as lowercase and do checking on all properties that should be in list form. Sets up locks to be more forgiving. This is used both by the metaclass and (optionally) at instantiation time.

If kwargs are given, these are set as instance-specific properties on the command - but note that the Command instance is re-used on a given host object, so a kwarg value set on the instance will remain on the instance for subsequent uses of that Command on that particular object.

evennia.commands.tests module

Unit testing for the Command system itself.

class evennia.commands.tests.AccessableCommand(**kwargs)[source]

Bases: evennia.commands.command.Command

Base command

Usage:

command [args]

This is the base command class. Inherit from this to create new commands.

The cmdhandler makes the following variables available to the command methods (so you can always assume them to be there): self.caller - the game object calling the command self.cmdstring - the command name used to trigger this command (allows

you to know which alias was used, for example)

cmd.args - everything supplied to the command following the cmdstring

(this is usually what is parsed in self.parse())

cmd.cmdset - the cmdset from which this command was matched (useful only

seldomly, notably for help-type commands, to create dynamic help entries and lists)

cmd.obj - the object on which this command is defined. If a default command,

this is usually the same as caller.

cmd.rawstring - the full raw string input, including any args and no parsing.

The following class properties can/should be defined on your child class:

key - identifier for command (e.g. “look”) aliases - (optional) list of aliases (e.g. [“l”, “loo”]) locks - lock string (default is “cmd:all()”) help_category - how to organize this help entry in help system

(default is “General”)

auto_help - defaults to True. Allows for turning off auto-help generation arg_regex - (optional) raw string regex defining how the argument part of

the command should look in order to match for this command (e.g. must it be a space between cmdname and arg?)

(Note that if auto_help is on, this initial string is also used by the system to create the help entry for the command, so it’s a good idea to format it similar to this one). This behavior can be changed by overriding the method ‘get_help’ of a command: by default, this method returns cmd.__doc__ (that is, this very docstring, or the docstring of your command). You can, however, extend or replace this without disabling auto_help.

_keyaliases = ('command',)
_matchset = {'command'}
access(**kwargs)[source]

This hook is called by the cmdhandler to determine if srcobj is allowed to execute this command. It should return a boolean value and is not normally something that need to be changed since it’s using the Evennia permission system directly.

Parameters
  • srcobj (Object) – Object trying to gain permission

  • access_type (str, optional) – The lock type to check.

  • default (bool, optional) – The fallback result if no lock of matching access_type is found on this Command.

aliases = []
help_category = 'general'
key = 'command'
lock_storage = 'cmd:all();'
search_index_entry = {'aliases': '', 'category': 'general', 'key': 'command', 'tags': '', 'text': '\n Base command\n\n Usage:\n command [args]\n\n This is the base command class. Inherit from this\n to create new commands.\n\n The cmdhandler makes the following variables available to the\n command methods (so you can always assume them to be there):\n self.caller - the game object calling the command\n self.cmdstring - the command name used to trigger this command (allows\n you to know which alias was used, for example)\n cmd.args - everything supplied to the command following the cmdstring\n (this is usually what is parsed in self.parse())\n cmd.cmdset - the cmdset from which this command was matched (useful only\n seldomly, notably for help-type commands, to create dynamic\n help entries and lists)\n cmd.obj - the object on which this command is defined. If a default command,\n this is usually the same as caller.\n cmd.rawstring - the full raw string input, including any args and no parsing.\n\n The following class properties can/should be defined on your child class:\n\n key - identifier for command (e.g. "look")\n aliases - (optional) list of aliases (e.g. ["l", "loo"])\n locks - lock string (default is "cmd:all()")\n help_category - how to organize this help entry in help system\n (default is "General")\n auto_help - defaults to True. Allows for turning off auto-help generation\n arg_regex - (optional) raw string regex defining how the argument part of\n the command should look in order to match for this command\n (e.g. must it be a space between cmdname and arg?)\n\n (Note that if auto_help is on, this initial string is also used by the\n system to create the help entry for the command, so it\'s a good idea to\n format it similar to this one). This behavior can be changed by\n overriding the method \'get_help\' of a command: by default, this\n method returns cmd.__doc__ (that is, this very docstring, or\n the docstring of your command). You can, however, extend or\n replace this without disabling auto_help.\n '}
class evennia.commands.tests.TestCmdParser(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_build_matches()[source]
test_cmdparser()[source]
test_create_match()[source]
test_num_prefixes()[source]
class evennia.commands.tests.TestCmdSetMergers(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

Test merging of cmdsets

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_intersect()[source]
test_option_transfer()[source]

Test transfer of cmdset options

test_order()[source]

Merge in reverse- and forward orders, same priorities

test_priority_order()[source]

Merge in reverse- and forward order with well-defined prioritities

test_remove()[source]
test_replace()[source]
test_union()[source]
class evennia.commands.tests.TestGetAndMergeCmdSets(methodName='runTest')[source]

Bases: twisted.trial._asynctest.TestCase, evennia.utils.test_resources.EvenniaTest

Test the cmdhandler.get_and_merge_cmdsets function.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

set_cmdsets(obj, *args)[source]

Set cmdets on obj in the order given in *args

test_autocmdsets()[source]
test_duplicates()[source]
test_from_account()[source]
test_from_object()[source]
test_from_session()[source]
test_multimerge()[source]
class evennia.commands.tests._CmdA(cmdset, *args, **kwargs)[source]

Bases: evennia.commands.command.Command

Base command

Usage:

command [args]

This is the base command class. Inherit from this to create new commands.

The cmdhandler makes the following variables available to the command methods (so you can always assume them to be there): self.caller - the game object calling the command self.cmdstring - the command name used to trigger this command (allows

you to know which alias was used, for example)

cmd.args - everything supplied to the command following the cmdstring

(this is usually what is parsed in self.parse())

cmd.cmdset - the cmdset from which this command was matched (useful only

seldomly, notably for help-type commands, to create dynamic help entries and lists)

cmd.obj - the object on which this command is defined. If a default command,

this is usually the same as caller.

cmd.rawstring - the full raw string input, including any args and no parsing.

The following class properties can/should be defined on your child class:

key - identifier for command (e.g. “look”) aliases - (optional) list of aliases (e.g. [“l”, “loo”]) locks - lock string (default is “cmd:all()”) help_category - how to organize this help entry in help system

(default is “General”)

auto_help - defaults to True. Allows for turning off auto-help generation arg_regex - (optional) raw string regex defining how the argument part of

the command should look in order to match for this command (e.g. must it be a space between cmdname and arg?)

(Note that if auto_help is on, this initial string is also used by the system to create the help entry for the command, so it’s a good idea to format it similar to this one). This behavior can be changed by overriding the method ‘get_help’ of a command: by default, this method returns cmd.__doc__ (that is, this very docstring, or the docstring of your command). You can, however, extend or replace this without disabling auto_help.

__init__(cmdset, *args, **kwargs)[source]

The lockhandler works the same as for objects. optional kwargs will be set as properties on the Command at runtime, overloading evential same-named class properties.

_keyaliases = ('a',)
_matchset = {'a'}
aliases = []
help_category = 'general'
key = 'a'
lock_storage = 'cmd:all();'
search_index_entry = {'aliases': '', 'category': 'general', 'key': 'a', 'tags': '', 'text': '\n Base command\n\n Usage:\n command [args]\n\n This is the base command class. Inherit from this\n to create new commands.\n\n The cmdhandler makes the following variables available to the\n command methods (so you can always assume them to be there):\n self.caller - the game object calling the command\n self.cmdstring - the command name used to trigger this command (allows\n you to know which alias was used, for example)\n cmd.args - everything supplied to the command following the cmdstring\n (this is usually what is parsed in self.parse())\n cmd.cmdset - the cmdset from which this command was matched (useful only\n seldomly, notably for help-type commands, to create dynamic\n help entries and lists)\n cmd.obj - the object on which this command is defined. If a default command,\n this is usually the same as caller.\n cmd.rawstring - the full raw string input, including any args and no parsing.\n\n The following class properties can/should be defined on your child class:\n\n key - identifier for command (e.g. "look")\n aliases - (optional) list of aliases (e.g. ["l", "loo"])\n locks - lock string (default is "cmd:all()")\n help_category - how to organize this help entry in help system\n (default is "General")\n auto_help - defaults to True. Allows for turning off auto-help generation\n arg_regex - (optional) raw string regex defining how the argument part of\n the command should look in order to match for this command\n (e.g. must it be a space between cmdname and arg?)\n\n (Note that if auto_help is on, this initial string is also used by the\n system to create the help entry for the command, so it\'s a good idea to\n format it similar to this one). This behavior can be changed by\n overriding the method \'get_help\' of a command: by default, this\n method returns cmd.__doc__ (that is, this very docstring, or\n the docstring of your command). You can, however, extend or\n replace this without disabling auto_help.\n '}
class evennia.commands.tests._CmdB(cmdset, *args, **kwargs)[source]

Bases: evennia.commands.command.Command

Base command

Usage:

command [args]

This is the base command class. Inherit from this to create new commands.

The cmdhandler makes the following variables available to the command methods (so you can always assume them to be there): self.caller - the game object calling the command self.cmdstring - the command name used to trigger this command (allows

you to know which alias was used, for example)

cmd.args - everything supplied to the command following the cmdstring

(this is usually what is parsed in self.parse())

cmd.cmdset - the cmdset from which this command was matched (useful only

seldomly, notably for help-type commands, to create dynamic help entries and lists)

cmd.obj - the object on which this command is defined. If a default command,

this is usually the same as caller.

cmd.rawstring - the full raw string input, including any args and no parsing.

The following class properties can/should be defined on your child class:

key - identifier for command (e.g. “look”) aliases - (optional) list of aliases (e.g. [“l”, “loo”]) locks - lock string (default is “cmd:all()”) help_category - how to organize this help entry in help system

(default is “General”)

auto_help - defaults to True. Allows for turning off auto-help generation arg_regex - (optional) raw string regex defining how the argument part of

the command should look in order to match for this command (e.g. must it be a space between cmdname and arg?)

(Note that if auto_help is on, this initial string is also used by the system to create the help entry for the command, so it’s a good idea to format it similar to this one). This behavior can be changed by overriding the method ‘get_help’ of a command: by default, this method returns cmd.__doc__ (that is, this very docstring, or the docstring of your command). You can, however, extend or replace this without disabling auto_help.

__init__(cmdset, *args, **kwargs)[source]

The lockhandler works the same as for objects. optional kwargs will be set as properties on the Command at runtime, overloading evential same-named class properties.

_keyaliases = ('b',)
_matchset = {'b'}
aliases = []
help_category = 'general'
key = 'b'
lock_storage = 'cmd:all();'
search_index_entry = {'aliases': '', 'category': 'general', 'key': 'b', 'tags': '', 'text': '\n Base command\n\n Usage:\n command [args]\n\n This is the base command class. Inherit from this\n to create new commands.\n\n The cmdhandler makes the following variables available to the\n command methods (so you can always assume them to be there):\n self.caller - the game object calling the command\n self.cmdstring - the command name used to trigger this command (allows\n you to know which alias was used, for example)\n cmd.args - everything supplied to the command following the cmdstring\n (this is usually what is parsed in self.parse())\n cmd.cmdset - the cmdset from which this command was matched (useful only\n seldomly, notably for help-type commands, to create dynamic\n help entries and lists)\n cmd.obj - the object on which this command is defined. If a default command,\n this is usually the same as caller.\n cmd.rawstring - the full raw string input, including any args and no parsing.\n\n The following class properties can/should be defined on your child class:\n\n key - identifier for command (e.g. "look")\n aliases - (optional) list of aliases (e.g. ["l", "loo"])\n locks - lock string (default is "cmd:all()")\n help_category - how to organize this help entry in help system\n (default is "General")\n auto_help - defaults to True. Allows for turning off auto-help generation\n arg_regex - (optional) raw string regex defining how the argument part of\n the command should look in order to match for this command\n (e.g. must it be a space between cmdname and arg?)\n\n (Note that if auto_help is on, this initial string is also used by the\n system to create the help entry for the command, so it\'s a good idea to\n format it similar to this one). This behavior can be changed by\n overriding the method \'get_help\' of a command: by default, this\n method returns cmd.__doc__ (that is, this very docstring, or\n the docstring of your command). You can, however, extend or\n replace this without disabling auto_help.\n '}
class evennia.commands.tests._CmdC(cmdset, *args, **kwargs)[source]

Bases: evennia.commands.command.Command

Base command

Usage:

command [args]

This is the base command class. Inherit from this to create new commands.

The cmdhandler makes the following variables available to the command methods (so you can always assume them to be there): self.caller - the game object calling the command self.cmdstring - the command name used to trigger this command (allows

you to know which alias was used, for example)

cmd.args - everything supplied to the command following the cmdstring

(this is usually what is parsed in self.parse())

cmd.cmdset - the cmdset from which this command was matched (useful only

seldomly, notably for help-type commands, to create dynamic help entries and lists)

cmd.obj - the object on which this command is defined. If a default command,

this is usually the same as caller.

cmd.rawstring - the full raw string input, including any args and no parsing.

The following class properties can/should be defined on your child class:

key - identifier for command (e.g. “look”) aliases - (optional) list of aliases (e.g. [“l”, “loo”]) locks - lock string (default is “cmd:all()”) help_category - how to organize this help entry in help system

(default is “General”)

auto_help - defaults to True. Allows for turning off auto-help generation arg_regex - (optional) raw string regex defining how the argument part of

the command should look in order to match for this command (e.g. must it be a space between cmdname and arg?)

(Note that if auto_help is on, this initial string is also used by the system to create the help entry for the command, so it’s a good idea to format it similar to this one). This behavior can be changed by overriding the method ‘get_help’ of a command: by default, this method returns cmd.__doc__ (that is, this very docstring, or the docstring of your command). You can, however, extend or replace this without disabling auto_help.

__init__(cmdset, *args, **kwargs)[source]

The lockhandler works the same as for objects. optional kwargs will be set as properties on the Command at runtime, overloading evential same-named class properties.

_keyaliases = ('c',)
_matchset = {'c'}
aliases = []
help_category = 'general'
key = 'c'
lock_storage = 'cmd:all();'
search_index_entry = {'aliases': '', 'category': 'general', 'key': 'c', 'tags': '', 'text': '\n Base command\n\n Usage:\n command [args]\n\n This is the base command class. Inherit from this\n to create new commands.\n\n The cmdhandler makes the following variables available to the\n command methods (so you can always assume them to be there):\n self.caller - the game object calling the command\n self.cmdstring - the command name used to trigger this command (allows\n you to know which alias was used, for example)\n cmd.args - everything supplied to the command following the cmdstring\n (this is usually what is parsed in self.parse())\n cmd.cmdset - the cmdset from which this command was matched (useful only\n seldomly, notably for help-type commands, to create dynamic\n help entries and lists)\n cmd.obj - the object on which this command is defined. If a default command,\n this is usually the same as caller.\n cmd.rawstring - the full raw string input, including any args and no parsing.\n\n The following class properties can/should be defined on your child class:\n\n key - identifier for command (e.g. "look")\n aliases - (optional) list of aliases (e.g. ["l", "loo"])\n locks - lock string (default is "cmd:all()")\n help_category - how to organize this help entry in help system\n (default is "General")\n auto_help - defaults to True. Allows for turning off auto-help generation\n arg_regex - (optional) raw string regex defining how the argument part of\n the command should look in order to match for this command\n (e.g. must it be a space between cmdname and arg?)\n\n (Note that if auto_help is on, this initial string is also used by the\n system to create the help entry for the command, so it\'s a good idea to\n format it similar to this one). This behavior can be changed by\n overriding the method \'get_help\' of a command: by default, this\n method returns cmd.__doc__ (that is, this very docstring, or\n the docstring of your command). You can, however, extend or\n replace this without disabling auto_help.\n '}
class evennia.commands.tests._CmdD(cmdset, *args, **kwargs)[source]

Bases: evennia.commands.command.Command

Base command

Usage:

command [args]

This is the base command class. Inherit from this to create new commands.

The cmdhandler makes the following variables available to the command methods (so you can always assume them to be there): self.caller - the game object calling the command self.cmdstring - the command name used to trigger this command (allows

you to know which alias was used, for example)

cmd.args - everything supplied to the command following the cmdstring

(this is usually what is parsed in self.parse())

cmd.cmdset - the cmdset from which this command was matched (useful only

seldomly, notably for help-type commands, to create dynamic help entries and lists)

cmd.obj - the object on which this command is defined. If a default command,

this is usually the same as caller.

cmd.rawstring - the full raw string input, including any args and no parsing.

The following class properties can/should be defined on your child class:

key - identifier for command (e.g. “look”) aliases - (optional) list of aliases (e.g. [“l”, “loo”]) locks - lock string (default is “cmd:all()”) help_category - how to organize this help entry in help system

(default is “General”)

auto_help - defaults to True. Allows for turning off auto-help generation arg_regex - (optional) raw string regex defining how the argument part of

the command should look in order to match for this command (e.g. must it be a space between cmdname and arg?)

(Note that if auto_help is on, this initial string is also used by the system to create the help entry for the command, so it’s a good idea to format it similar to this one). This behavior can be changed by overriding the method ‘get_help’ of a command: by default, this method returns cmd.__doc__ (that is, this very docstring, or the docstring of your command). You can, however, extend or replace this without disabling auto_help.

__init__(cmdset, *args, **kwargs)[source]

The lockhandler works the same as for objects. optional kwargs will be set as properties on the Command at runtime, overloading evential same-named class properties.

_keyaliases = ('d',)
_matchset = {'d'}
aliases = []
help_category = 'general'
key = 'd'
lock_storage = 'cmd:all();'
search_index_entry = {'aliases': '', 'category': 'general', 'key': 'd', 'tags': '', 'text': '\n Base command\n\n Usage:\n command [args]\n\n This is the base command class. Inherit from this\n to create new commands.\n\n The cmdhandler makes the following variables available to the\n command methods (so you can always assume them to be there):\n self.caller - the game object calling the command\n self.cmdstring - the command name used to trigger this command (allows\n you to know which alias was used, for example)\n cmd.args - everything supplied to the command following the cmdstring\n (this is usually what is parsed in self.parse())\n cmd.cmdset - the cmdset from which this command was matched (useful only\n seldomly, notably for help-type commands, to create dynamic\n help entries and lists)\n cmd.obj - the object on which this command is defined. If a default command,\n this is usually the same as caller.\n cmd.rawstring - the full raw string input, including any args and no parsing.\n\n The following class properties can/should be defined on your child class:\n\n key - identifier for command (e.g. "look")\n aliases - (optional) list of aliases (e.g. ["l", "loo"])\n locks - lock string (default is "cmd:all()")\n help_category - how to organize this help entry in help system\n (default is "General")\n auto_help - defaults to True. Allows for turning off auto-help generation\n arg_regex - (optional) raw string regex defining how the argument part of\n the command should look in order to match for this command\n (e.g. must it be a space between cmdname and arg?)\n\n (Note that if auto_help is on, this initial string is also used by the\n system to create the help entry for the command, so it\'s a good idea to\n format it similar to this one). This behavior can be changed by\n overriding the method \'get_help\' of a command: by default, this\n method returns cmd.__doc__ (that is, this very docstring, or\n the docstring of your command). You can, however, extend or\n replace this without disabling auto_help.\n '}
class evennia.commands.tests._CmdSetA(cmdsetobj=None, key=None)[source]

Bases: evennia.commands.cmdset.CmdSet

at_cmdset_creation()[source]

Hook method - this should be overloaded in the inheriting class, and should take care of populating the cmdset by use of self.add().

key = 'A'
path = 'evennia.commands.tests._CmdSetA'
class evennia.commands.tests._CmdSetB(cmdsetobj=None, key=None)[source]

Bases: evennia.commands.cmdset.CmdSet

at_cmdset_creation()[source]

Hook method - this should be overloaded in the inheriting class, and should take care of populating the cmdset by use of self.add().

key = 'B'
path = 'evennia.commands.tests._CmdSetB'
class evennia.commands.tests._CmdSetC(cmdsetobj=None, key=None)[source]

Bases: evennia.commands.cmdset.CmdSet

at_cmdset_creation()[source]

Hook method - this should be overloaded in the inheriting class, and should take care of populating the cmdset by use of self.add().

key = 'C'
path = 'evennia.commands.tests._CmdSetC'
class evennia.commands.tests._CmdSetD(cmdsetobj=None, key=None)[source]

Bases: evennia.commands.cmdset.CmdSet

at_cmdset_creation()[source]

Hook method - this should be overloaded in the inheriting class, and should take care of populating the cmdset by use of self.add().

key = 'D'
path = 'evennia.commands.tests._CmdSetD'
class evennia.commands.tests._CmdSetTest(cmdsetobj=None, key=None)[source]

Bases: evennia.commands.cmdset.CmdSet

at_cmdset_creation()[source]

Hook method - this should be overloaded in the inheriting class, and should take care of populating the cmdset by use of self.add().

key = 'test_cmdset'
path = 'evennia.commands.tests._CmdSetTest'
class evennia.commands.tests._CmdTest1(**kwargs)[source]

Bases: evennia.commands.tests.AccessableCommand

Base command

Usage:

command [args]

This is the base command class. Inherit from this to create new commands.

The cmdhandler makes the following variables available to the command methods (so you can always assume them to be there): self.caller - the game object calling the command self.cmdstring - the command name used to trigger this command (allows

you to know which alias was used, for example)

cmd.args - everything supplied to the command following the cmdstring

(this is usually what is parsed in self.parse())

cmd.cmdset - the cmdset from which this command was matched (useful only

seldomly, notably for help-type commands, to create dynamic help entries and lists)

cmd.obj - the object on which this command is defined. If a default command,

this is usually the same as caller.

cmd.rawstring - the full raw string input, including any args and no parsing.

The following class properties can/should be defined on your child class:

key - identifier for command (e.g. “look”) aliases - (optional) list of aliases (e.g. [“l”, “loo”]) locks - lock string (default is “cmd:all()”) help_category - how to organize this help entry in help system

(default is “General”)

auto_help - defaults to True. Allows for turning off auto-help generation arg_regex - (optional) raw string regex defining how the argument part of

the command should look in order to match for this command (e.g. must it be a space between cmdname and arg?)

(Note that if auto_help is on, this initial string is also used by the system to create the help entry for the command, so it’s a good idea to format it similar to this one). This behavior can be changed by overriding the method ‘get_help’ of a command: by default, this method returns cmd.__doc__ (that is, this very docstring, or the docstring of your command). You can, however, extend or replace this without disabling auto_help.

_keyaliases = ('test1',)
_matchset = {'test1'}
aliases = []
help_category = 'general'
key = 'test1'
lock_storage = 'cmd:all();'
search_index_entry = {'aliases': '', 'category': 'general', 'key': 'test1', 'tags': '', 'text': '\n Base command\n\n Usage:\n command [args]\n\n This is the base command class. Inherit from this\n to create new commands.\n\n The cmdhandler makes the following variables available to the\n command methods (so you can always assume them to be there):\n self.caller - the game object calling the command\n self.cmdstring - the command name used to trigger this command (allows\n you to know which alias was used, for example)\n cmd.args - everything supplied to the command following the cmdstring\n (this is usually what is parsed in self.parse())\n cmd.cmdset - the cmdset from which this command was matched (useful only\n seldomly, notably for help-type commands, to create dynamic\n help entries and lists)\n cmd.obj - the object on which this command is defined. If a default command,\n this is usually the same as caller.\n cmd.rawstring - the full raw string input, including any args and no parsing.\n\n The following class properties can/should be defined on your child class:\n\n key - identifier for command (e.g. "look")\n aliases - (optional) list of aliases (e.g. ["l", "loo"])\n locks - lock string (default is "cmd:all()")\n help_category - how to organize this help entry in help system\n (default is "General")\n auto_help - defaults to True. Allows for turning off auto-help generation\n arg_regex - (optional) raw string regex defining how the argument part of\n the command should look in order to match for this command\n (e.g. must it be a space between cmdname and arg?)\n\n (Note that if auto_help is on, this initial string is also used by the\n system to create the help entry for the command, so it\'s a good idea to\n format it similar to this one). This behavior can be changed by\n overriding the method \'get_help\' of a command: by default, this\n method returns cmd.__doc__ (that is, this very docstring, or\n the docstring of your command). You can, however, extend or\n replace this without disabling auto_help.\n '}
class evennia.commands.tests._CmdTest2(**kwargs)[source]

Bases: evennia.commands.tests.AccessableCommand

Base command

Usage:

command [args]

This is the base command class. Inherit from this to create new commands.

The cmdhandler makes the following variables available to the command methods (so you can always assume them to be there): self.caller - the game object calling the command self.cmdstring - the command name used to trigger this command (allows

you to know which alias was used, for example)

cmd.args - everything supplied to the command following the cmdstring

(this is usually what is parsed in self.parse())

cmd.cmdset - the cmdset from which this command was matched (useful only

seldomly, notably for help-type commands, to create dynamic help entries and lists)

cmd.obj - the object on which this command is defined. If a default command,

this is usually the same as caller.

cmd.rawstring - the full raw string input, including any args and no parsing.

The following class properties can/should be defined on your child class:

key - identifier for command (e.g. “look”) aliases - (optional) list of aliases (e.g. [“l”, “loo”]) locks - lock string (default is “cmd:all()”) help_category - how to organize this help entry in help system

(default is “General”)

auto_help - defaults to True. Allows for turning off auto-help generation arg_regex - (optional) raw string regex defining how the argument part of

the command should look in order to match for this command (e.g. must it be a space between cmdname and arg?)

(Note that if auto_help is on, this initial string is also used by the system to create the help entry for the command, so it’s a good idea to format it similar to this one). This behavior can be changed by overriding the method ‘get_help’ of a command: by default, this method returns cmd.__doc__ (that is, this very docstring, or the docstring of your command). You can, however, extend or replace this without disabling auto_help.

_keyaliases = ('another command',)
_matchset = {'another command'}
aliases = []
help_category = 'general'
key = 'another command'
lock_storage = 'cmd:all();'
search_index_entry = {'aliases': '', 'category': 'general', 'key': 'another command', 'tags': '', 'text': '\n Base command\n\n Usage:\n command [args]\n\n This is the base command class. Inherit from this\n to create new commands.\n\n The cmdhandler makes the following variables available to the\n command methods (so you can always assume them to be there):\n self.caller - the game object calling the command\n self.cmdstring - the command name used to trigger this command (allows\n you to know which alias was used, for example)\n cmd.args - everything supplied to the command following the cmdstring\n (this is usually what is parsed in self.parse())\n cmd.cmdset - the cmdset from which this command was matched (useful only\n seldomly, notably for help-type commands, to create dynamic\n help entries and lists)\n cmd.obj - the object on which this command is defined. If a default command,\n this is usually the same as caller.\n cmd.rawstring - the full raw string input, including any args and no parsing.\n\n The following class properties can/should be defined on your child class:\n\n key - identifier for command (e.g. "look")\n aliases - (optional) list of aliases (e.g. ["l", "loo"])\n locks - lock string (default is "cmd:all()")\n help_category - how to organize this help entry in help system\n (default is "General")\n auto_help - defaults to True. Allows for turning off auto-help generation\n arg_regex - (optional) raw string regex defining how the argument part of\n the command should look in order to match for this command\n (e.g. must it be a space between cmdname and arg?)\n\n (Note that if auto_help is on, this initial string is also used by the\n system to create the help entry for the command, so it\'s a good idea to\n format it similar to this one). This behavior can be changed by\n overriding the method \'get_help\' of a command: by default, this\n method returns cmd.__doc__ (that is, this very docstring, or\n the docstring of your command). You can, however, extend or\n replace this without disabling auto_help.\n '}
class evennia.commands.tests._CmdTest3(**kwargs)[source]

Bases: evennia.commands.tests.AccessableCommand

Base command

Usage:

command [args]

This is the base command class. Inherit from this to create new commands.

The cmdhandler makes the following variables available to the command methods (so you can always assume them to be there): self.caller - the game object calling the command self.cmdstring - the command name used to trigger this command (allows

you to know which alias was used, for example)

cmd.args - everything supplied to the command following the cmdstring

(this is usually what is parsed in self.parse())

cmd.cmdset - the cmdset from which this command was matched (useful only

seldomly, notably for help-type commands, to create dynamic help entries and lists)

cmd.obj - the object on which this command is defined. If a default command,

this is usually the same as caller.

cmd.rawstring - the full raw string input, including any args and no parsing.

The following class properties can/should be defined on your child class:

key - identifier for command (e.g. “look”) aliases - (optional) list of aliases (e.g. [“l”, “loo”]) locks - lock string (default is “cmd:all()”) help_category - how to organize this help entry in help system

(default is “General”)

auto_help - defaults to True. Allows for turning off auto-help generation arg_regex - (optional) raw string regex defining how the argument part of

the command should look in order to match for this command (e.g. must it be a space between cmdname and arg?)

(Note that if auto_help is on, this initial string is also used by the system to create the help entry for the command, so it’s a good idea to format it similar to this one). This behavior can be changed by overriding the method ‘get_help’ of a command: by default, this method returns cmd.__doc__ (that is, this very docstring, or the docstring of your command). You can, however, extend or replace this without disabling auto_help.

_keyaliases = ('&the third command',)
_matchset = {'&the third command'}
aliases = []
help_category = 'general'
key = '&the third command'
lock_storage = 'cmd:all();'
search_index_entry = {'aliases': '', 'category': 'general', 'key': '&the third command', 'tags': '', 'text': '\n Base command\n\n Usage:\n command [args]\n\n This is the base command class. Inherit from this\n to create new commands.\n\n The cmdhandler makes the following variables available to the\n command methods (so you can always assume them to be there):\n self.caller - the game object calling the command\n self.cmdstring - the command name used to trigger this command (allows\n you to know which alias was used, for example)\n cmd.args - everything supplied to the command following the cmdstring\n (this is usually what is parsed in self.parse())\n cmd.cmdset - the cmdset from which this command was matched (useful only\n seldomly, notably for help-type commands, to create dynamic\n help entries and lists)\n cmd.obj - the object on which this command is defined. If a default command,\n this is usually the same as caller.\n cmd.rawstring - the full raw string input, including any args and no parsing.\n\n The following class properties can/should be defined on your child class:\n\n key - identifier for command (e.g. "look")\n aliases - (optional) list of aliases (e.g. ["l", "loo"])\n locks - lock string (default is "cmd:all()")\n help_category - how to organize this help entry in help system\n (default is "General")\n auto_help - defaults to True. Allows for turning off auto-help generation\n arg_regex - (optional) raw string regex defining how the argument part of\n the command should look in order to match for this command\n (e.g. must it be a space between cmdname and arg?)\n\n (Note that if auto_help is on, this initial string is also used by the\n system to create the help entry for the command, so it\'s a good idea to\n format it similar to this one). This behavior can be changed by\n overriding the method \'get_help\' of a command: by default, this\n method returns cmd.__doc__ (that is, this very docstring, or\n the docstring of your command). You can, however, extend or\n replace this without disabling auto_help.\n '}
class evennia.commands.tests._CmdTest4(**kwargs)[source]

Bases: evennia.commands.tests.AccessableCommand

Base command

Usage:

command [args]

This is the base command class. Inherit from this to create new commands.

The cmdhandler makes the following variables available to the command methods (so you can always assume them to be there): self.caller - the game object calling the command self.cmdstring - the command name used to trigger this command (allows

you to know which alias was used, for example)

cmd.args - everything supplied to the command following the cmdstring

(this is usually what is parsed in self.parse())

cmd.cmdset - the cmdset from which this command was matched (useful only

seldomly, notably for help-type commands, to create dynamic help entries and lists)

cmd.obj - the object on which this command is defined. If a default command,

this is usually the same as caller.

cmd.rawstring - the full raw string input, including any args and no parsing.

The following class properties can/should be defined on your child class:

key - identifier for command (e.g. “look”) aliases - (optional) list of aliases (e.g. [“l”, “loo”]) locks - lock string (default is “cmd:all()”) help_category - how to organize this help entry in help system

(default is “General”)

auto_help - defaults to True. Allows for turning off auto-help generation arg_regex - (optional) raw string regex defining how the argument part of

the command should look in order to match for this command (e.g. must it be a space between cmdname and arg?)

(Note that if auto_help is on, this initial string is also used by the system to create the help entry for the command, so it’s a good idea to format it similar to this one). This behavior can be changed by overriding the method ‘get_help’ of a command: by default, this method returns cmd.__doc__ (that is, this very docstring, or the docstring of your command). You can, however, extend or replace this without disabling auto_help.

_keyaliases = ('test2',)
_matchset = {'test2'}
aliases = []
help_category = 'general'
key = 'test2'
lock_storage = 'cmd:all();'
search_index_entry = {'aliases': '', 'category': 'general', 'key': 'test2', 'tags': '', 'text': '\n Base command\n\n Usage:\n command [args]\n\n This is the base command class. Inherit from this\n to create new commands.\n\n The cmdhandler makes the following variables available to the\n command methods (so you can always assume them to be there):\n self.caller - the game object calling the command\n self.cmdstring - the command name used to trigger this command (allows\n you to know which alias was used, for example)\n cmd.args - everything supplied to the command following the cmdstring\n (this is usually what is parsed in self.parse())\n cmd.cmdset - the cmdset from which this command was matched (useful only\n seldomly, notably for help-type commands, to create dynamic\n help entries and lists)\n cmd.obj - the object on which this command is defined. If a default command,\n this is usually the same as caller.\n cmd.rawstring - the full raw string input, including any args and no parsing.\n\n The following class properties can/should be defined on your child class:\n\n key - identifier for command (e.g. "look")\n aliases - (optional) list of aliases (e.g. ["l", "loo"])\n locks - lock string (default is "cmd:all()")\n help_category - how to organize this help entry in help system\n (default is "General")\n auto_help - defaults to True. Allows for turning off auto-help generation\n arg_regex - (optional) raw string regex defining how the argument part of\n the command should look in order to match for this command\n (e.g. must it be a space between cmdname and arg?)\n\n (Note that if auto_help is on, this initial string is also used by the\n system to create the help entry for the command, so it\'s a good idea to\n format it similar to this one). This behavior can be changed by\n overriding the method \'get_help\' of a command: by default, this\n method returns cmd.__doc__ (that is, this very docstring, or\n the docstring of your command). You can, however, extend or\n replace this without disabling auto_help.\n '}
evennia.commands.tests._mockdelay(time, func, *args, **kwargs)[source]