evennia.commands.default.comms¶
Communication commands:
channel
page
irc/rss/grapevine/discord linking
- class evennia.commands.default.comms.CmdChannel(**kwargs)[source]¶
Bases:
MuxCommandUse and manage in-game channels.
- Usage:
channel channelname <msg> channel channel name = <msg> channel (show all subscription) channel/all (show available channels) channel/alias channelname = alias[;alias…] channel/unalias alias channel/who channelname channel/history channelname [= index] channel/sub channelname [= alias[;alias…]] channel/unsub channelname[,channelname, …] channel/mute channelname[,channelname,…] channel/unmute channelname[,channelname,…]
channel/create channelname[;alias;alias[:typeclass]] [= description] channel/destroy channelname [= reason] channel/desc channelname = description channel/lock channelname = lockstring channel/unlock channelname = lockstring channel/ban channelname (list bans) channel/ban[/quiet] channelname[, channelname, …] = subscribername [: reason] channel/unban[/quiet] channelname[, channelname, …] = subscribername channel/boot[/quiet] channelname[,channelname,…] = subscribername [: reason]
subtopics¶
sending¶
- Usage: channel channelname msg
channel channel name = msg (with space in channel name)
This sends a message to the channel. Note that you will rarely use this command like this; instead you can use the alias
channelname <msg> channelalias <msg>
For example
public Hello World pub Hello World
(this shortcut doesn’t work for aliases containing spaces)
See channel/alias for help on setting channel aliases.
alias and unalias¶
- Usage: channel/alias channel = alias[;alias[;alias…]]
channel/unalias alias channel - this will list your subs and aliases to each channel
Set one or more personal aliases for referencing a channel. For example:
channel/alias warrior’s guild = warrior;wguild;warchannel;warrior guild
You can now send to the channel using all of these:
warrior’s guild Hello warrior Hello wguild Hello warchannel Hello
Note that this will not work if the alias has a space in it. So the ‘warrior guild’ alias must be used with the channel command:
channel warrior guild = Hello
Channel-aliases can be removed one at a time, using the ‘/unalias’ switch.
who¶
Usage: channel/who channelname
List the channel’s subscribers. Shows who are currently offline or are muting the channel. Subscribers who are ‘muting’ will not see messages sent to the channel (use channel/mute to mute a channel).
history¶
Usage: channel/history channel [= index]
This will display the last |c20|n lines of channel history. By supplying an index number, you will step that many lines back before viewing those 20 lines.
For example:
channel/history public = 35
will go back 35 lines and show the previous 20 lines from that point (so lines -35 to -55).
sub and unsub¶
- Usage: channel/sub channel [=alias[;alias;…]]
channel/unsub channel
This subscribes you to a channel and optionally assigns personal shortcuts for you to use to send to that channel (see aliases). When you unsub, all your personal aliases will also be removed.
mute and unmute¶
- Usage: channel/mute channelname
channel/unmute channelname
Muting silences all output from the channel without actually un-subscribing. Other channel members will see that you are muted in the /who list. Sending a message to the channel will automatically unmute you.
create and destroy¶
- Usage: channel/create channelname[;alias;alias[:typeclass]] [= description]
channel/destroy channelname [= reason]
Creates a new channel (or destroys one you control). You will automatically join the channel you create and everyone will be kicked and loose all aliases to a destroyed channel.
lock and unlock¶
- Usage: channel/lock channelname = lockstring
channel/unlock channelname = lockstring
Note: this is an admin command.
A lockstring is on the form locktype:lockfunc(). Channels understand three locktypes:
listen - who may listen or join the channel. send - who may send messages to the channel control - who controls the channel. This is usually the one creating
the channel.
Common lockfuncs are all() and perm(). To make a channel everyone can listen to but only builders can talk on, use this:
listen:all() send: perm(Builders)
boot and ban¶
- Usage:
channel/boot[/quiet] channelname[,channelname,…] = subscribername [: reason] channel/ban channelname[, channelname, …] = subscribername [: reason] channel/unban channelname[, channelname, …] = subscribername channel/unban channelname channel/ban channelname (list bans)
Booting will kick a named subscriber from channel(s) temporarily. The ‘reason’ will be passed to the booted user. Unless the /quiet switch is used, the channel will also be informed of the action. A booted user is still able to re-connect, but they’ll have to set up their aliases again.
Banning will blacklist a user from (re)joining the provided channels. It will then proceed to boot them from those channels if they were connected. The ‘reason’ and /quiet works the same as for booting.
Example
boot mychannel1 = EvilUser : Kicking you to cool down a bit. ban mychannel1,mychannel2= EvilUser : Was banned for spamming.
- key = '@channel'¶
- aliases = ['@channels', '@chan']¶
- help_category = 'comms'¶
- locks = 'cmd:not pperm(channel_banned);admin:all();manage:all();changelocks:perm(Admin)'¶
- switch_options = ('list', 'all', 'history', 'sub', 'unsub', 'mute', 'unmute', 'alias', 'unalias', 'create', 'destroy', 'desc', 'lock', 'unlock', 'boot', 'ban', 'unban', 'who')¶
- account_caller = True¶
- search_channel(channelname, exact=False, handle_errors=True)[source]¶
Helper function for searching for a single channel with some error handling.
- Parameters:
channelname (str) – Name, alias #dbref or partial name/alias to search for.
exact (bool, optional) – If an exact or fuzzy-match of the name should be done. Note that even for a fuzzy match, an exactly given, unique channel name will always be returned.
handle_errors (bool) – If true, use self.msg to report errors if there are non/multiple matches. If so, the return will always be a single match or None.
- Returns:
object, list or None –
- If handle_errors is True, this is either a found Channel
or None. Otherwise it’s a list of zero, one or more channels found.
Notes
The ‘listen’ and ‘control’ accesses are checked before returning.
- msg_channel(channel, message, **kwargs)[source]¶
Send a message to a given channel. This will check the ‘send’ permission on the channel.
- Parameters:
channel (Channel) – The channel to send to.
message (str) – The message to send.
**kwargs – Unused by default. These kwargs will be passed into all channel messaging hooks for custom overriding.
- get_channel_history(channel, start_index=0)[source]¶
View a channel’s history.
- Parameters:
channel (Channel) – The channel to access.
message (str) – The message to send.
**kwargs – Unused by default. These kwargs will be passed into all channel messaging hooks for custom overriding.
- sub_to_channel(channel)[source]¶
Subscribe to a channel. Note that all permissions should be checked before this step.
- Parameters:
channel (Channel) – The channel to access.
- Returns:
bool, str –
- True, None if connection failed. If False,
the second part is an error string.
- unsub_from_channel(channel, **kwargs)[source]¶
Un-Subscribe to a channel. Note that all permissions should be checked before this step.
- Parameters:
channel (Channel) – The channel to unsub from.
**kwargs – Passed on to nick removal.
- Returns:
bool, str –
- True, None if un-connection succeeded. If False,
the second part is an error string.
- add_alias(channel, alias, **kwargs)[source]¶
Add a new alias (nick) for the user to use with this channel.
- Parameters:
channel (Channel) – The channel to alias.
alias (str) – The personal alias to use for this channel.
**kwargs – If given, passed into nicks.add.
Note
We add two nicks - one is a plain alias -> channel.key that we need to be able to reference this channel easily. The other is a templated nick to easily be able to send messages to the channel without needing to give the full channel command. The structure of this nick is given by self.channel_msg_pattern and self.channel_msg_nick_replacement. By default it maps alias <msg> -> channel <channelname> = <msg>, so that you can for example just write pub Hello to send a message.
The alias created is alias $1 -> channel channel = $1, to allow for sending to channel using the main channel command.
- remove_alias(alias, **kwargs)[source]¶
Remove an alias from a channel.
- Parameters:
alias (str, optional) – The alias to remove. The channel will be reverse-determined from the alias, if it exists.
- Returns:
bool, str –
- True, None if removal succeeded. If False,
the second part is an error string.
**kwargs: If given, passed into nicks.get/add.
Note
This will remove two nicks - the plain channel alias and the templated nick used for easily sending messages to the channel.
- get_channel_aliases(channel)[source]¶
Get a user’s aliases for a given channel. The user is retrieved through self.caller.
- Parameters:
channel (Channel) – The channel to act on.
- Returns:
list – A list of zero, one or more alias-strings.
- mute_channel(channel)[source]¶
Temporarily mute a channel.
- Parameters:
channel (Channel) – The channel to alias.
- Returns:
bool, str –
- True, None if muting successful. If False,
the second part is an error string.
- unmute_channel(channel)[source]¶
Unmute a channel.
- Parameters:
channel (Channel) – The channel to alias.
- Returns:
bool, str –
- True, None if unmuting successful. If False,
the second part is an error string.
- create_channel(name, description, typeclass=None, aliases=None)[source]¶
Create a new channel. Its name must not previously exist (case agnostic) (users can alias as needed). Will also connect to the new channel.
- Parameters:
name (str) – The new channel name/key.
description (str) – This is used in listings.
aliases (list) – A list of strings - alternative aliases for the channel (not to be confused with per-user aliases; these are available for everyone).
- Returns:
channel, str –
- new_channel, “” if creation successful. If False,
the second part is an error string.
- destroy_channel(channel, message=None)[source]¶
Destroy an existing channel. Access should be checked before calling this function.
- Parameters:
channel (Channel) – The channel to alias.
message (str, optional) – Final message to send onto the channel before destroying it. If not given, a default message is used. Set to the empty string for no message.
- if typeclass:
pass
- set_lock(channel, lockstring)[source]¶
Set a lockstring on a channel. Permissions must have been checked before this call.
- Parameters:
channel (Channel) – The channel to operate on.
lockstring (str) – A lockstring on the form ‘type:lockfunc();…’
- Returns:
bool, str –
- True, None if setting lock was successful. If False,
the second part is an error string.
- unset_lock(channel, lockstring)[source]¶
Remove locks in a lockstring on a channel. Permissions must have been checked before this call.
- Parameters:
channel (Channel) – The channel to operate on.
lockstring (str) – A lockstring on the form ‘type:lockfunc();…’
- Returns:
bool, str –
- True, None if setting lock was successful. If False,
the second part is an error string.
- set_desc(channel, description)[source]¶
Set a channel description. This is shown in listings etc.
- Parameters:
caller (Object or Account) – The entity performing the action.
channel (Channel) – The channel to operate on.
description (str) – A short description of the channel.
- Returns:
bool, str –
- True, None if setting lock was successful. If False,
the second part is an error string.
- boot_user(channel, target, quiet=False, reason='')[source]¶
Boot a user from a channel, with optional reason. This will also remove all their aliases for this channel.
- Parameters:
channel (Channel) – The channel to operate on.
target (Object or Account) – The entity to boot.
quiet (bool, optional) – Whether or not to announce to channel.
reason (str, optional) – A reason for the boot.
- Returns:
bool, str –
- True, None if setting lock was successful. If False,
the second part is an error string.
- ban_user(channel, target, quiet=False, reason='')[source]¶
Ban a user from a channel, by locking them out. This will also boot them, if they are currently connected.
- Parameters:
channel (Channel) – The channel to operate on.
target (Object or Account) – The entity to ban
quiet (bool, optional) – Whether or not to announce to channel.
reason (str, optional) – A reason for the ban
- Returns:
bool, str –
- True, None if banning was successful. If False,
the second part is an error string.
- unban_user(channel, target)[source]¶
Un-Ban a user from a channel. This will not reconnect them to the channel, just allow them to connect again (assuming they have the suitable ‘listen’ lock like everyone else).
- Parameters:
channel (Channel) – The channel to operate on.
target (Object or Account) – The entity to unban
- Returns:
bool, str –
- True, None if unbanning was successful. If False,
the second part is an error string.
- channel_list_bans(channel)[source]¶
Show a channel’s bans.
- Parameters:
channel (Channel) – The channel to operate on.
- Returns:
list – A list of strings, each the name of a banned user.
- channel_list_who(channel)[source]¶
Show a list of online people is subscribing to a channel. This will check the ‘control’ permission of caller to determine if only online users should be returned or everyone.
- Parameters:
channel (Channel) – The channel to operate on.
- Returns:
list –
- A list of prepared strings, with name + markers for if they are
muted or offline.
- list_channels(channelcls=<class 'evennia.comms.comms.DefaultChannel'>)[source]¶
Return a available channels.
- Parameters:
channelcls (Channel, optional) – The channel-class to query on. Defaults to the default channel class from settings.
- Returns:
tuple –
- A tuple (subbed_chans, available_chans) with the channels
currently subscribed to, and those we have ‘listen’ access to but don’t actually sub to yet.
- display_subbed_channels(subscribed)[source]¶
Display channels subscribed to.
- Parameters:
subscribed (list) – List of subscribed channels
- Returns:
EvTable – Table to display.
- display_all_channels(subscribed, available)[source]¶
Display all available channels
- Parameters:
subscribed (list) – List of subscribed channels
- Returns:
EvTable – Table to display.
- lock_storage = 'cmd:not pperm(channel_banned);admin:all();manage:all();changelocks:perm(Admin)'¶
- search_index_entry = {'aliases': '@channels @chan', 'category': 'comms', 'key': '@channel', 'no_prefix': 'channel channels chan', 'tags': '', 'text': "\nUse and manage in-game channels.\n\nUsage:\n channel channelname <msg>\n channel channel name = <msg>\n channel (show all subscription)\n channel/all (show available channels)\n channel/alias channelname = alias[;alias...]\n channel/unalias alias\n channel/who channelname\n channel/history channelname [= index]\n channel/sub channelname [= alias[;alias...]]\n channel/unsub channelname[,channelname, ...]\n channel/mute channelname[,channelname,...]\n channel/unmute channelname[,channelname,...]\n\n channel/create channelname[;alias;alias[:typeclass]] [= description]\n channel/destroy channelname [= reason]\n channel/desc channelname = description\n channel/lock channelname = lockstring\n channel/unlock channelname = lockstring\n channel/ban channelname (list bans)\n channel/ban[/quiet] channelname[, channelname, ...] = subscribername [: reason]\n channel/unban[/quiet] channelname[, channelname, ...] = subscribername\n channel/boot[/quiet] channelname[,channelname,...] = subscribername [: reason]\n\n# subtopics\n\n## sending\n\nUsage: channel channelname msg\n channel channel name = msg (with space in channel name)\n\nThis sends a message to the channel. Note that you will rarely use this\ncommand like this; instead you can use the alias\n\n channelname <msg>\n channelalias <msg>\n\nFor example\n\n public Hello World\n pub Hello World\n\n(this shortcut doesn't work for aliases containing spaces)\n\nSee channel/alias for help on setting channel aliases.\n\n## alias and unalias\n\nUsage: channel/alias channel = alias[;alias[;alias...]]\n channel/unalias alias\n channel - this will list your subs and aliases to each channel\n\nSet one or more personal aliases for referencing a channel. For example:\n\n channel/alias warrior's guild = warrior;wguild;warchannel;warrior guild\n\nYou can now send to the channel using all of these:\n\n warrior's guild Hello\n warrior Hello\n wguild Hello\n warchannel Hello\n\nNote that this will not work if the alias has a space in it. So the\n'warrior guild' alias must be used with the `channel` command:\n\n channel warrior guild = Hello\n\nChannel-aliases can be removed one at a time, using the '/unalias' switch.\n\n## who\n\nUsage: channel/who channelname\n\nList the channel's subscribers. Shows who are currently offline or are\nmuting the channel. Subscribers who are 'muting' will not see messages sent\nto the channel (use channel/mute to mute a channel).\n\n## history\n\nUsage: channel/history channel [= index]\n\nThis will display the last |c20|n lines of channel history. By supplying an\nindex number, you will step that many lines back before viewing those 20 lines.\n\nFor example:\n\n channel/history public = 35\n\nwill go back 35 lines and show the previous 20 lines from that point (so\nlines -35 to -55).\n\n## sub and unsub\n\nUsage: channel/sub channel [=alias[;alias;...]]\n channel/unsub channel\n\nThis subscribes you to a channel and optionally assigns personal shortcuts\nfor you to use to send to that channel (see aliases). When you unsub, all\nyour personal aliases will also be removed.\n\n## mute and unmute\n\nUsage: channel/mute channelname\n channel/unmute channelname\n\nMuting silences all output from the channel without actually\nun-subscribing. Other channel members will see that you are muted in the /who\nlist. Sending a message to the channel will automatically unmute you.\n\n## create and destroy\n\nUsage: channel/create channelname[;alias;alias[:typeclass]] [= description]\n channel/destroy channelname [= reason]\n\nCreates a new channel (or destroys one you control). You will automatically\njoin the channel you create and everyone will be kicked and loose all aliases\nto a destroyed channel.\n\n## lock and unlock\n\nUsage: channel/lock channelname = lockstring\n channel/unlock channelname = lockstring\n\nNote: this is an admin command.\n\nA lockstring is on the form locktype:lockfunc(). Channels understand three\nlocktypes:\n listen - who may listen or join the channel.\n send - who may send messages to the channel\n control - who controls the channel. This is usually the one creating\n the channel.\n\nCommon lockfuncs are all() and perm(). To make a channel everyone can\nlisten to but only builders can talk on, use this:\n\n listen:all()\n send: perm(Builders)\n\n## boot and ban\n\nUsage:\n channel/boot[/quiet] channelname[,channelname,...] = subscribername [: reason]\n channel/ban channelname[, channelname, ...] = subscribername [: reason]\n channel/unban channelname[, channelname, ...] = subscribername\n channel/unban channelname\n channel/ban channelname (list bans)\n\nBooting will kick a named subscriber from channel(s) temporarily. The\n'reason' will be passed to the booted user. Unless the /quiet switch is\nused, the channel will also be informed of the action. A booted user is\nstill able to re-connect, but they'll have to set up their aliases again.\n\nBanning will blacklist a user from (re)joining the provided channels. It\nwill then proceed to boot them from those channels if they were connected.\nThe 'reason' and `/quiet` works the same as for booting.\n\nExample:\n boot mychannel1 = EvilUser : Kicking you to cool down a bit.\n ban mychannel1,mychannel2= EvilUser : Was banned for spamming.\n\n"}¶
- class evennia.commands.default.comms.CmdObjectChannel(**kwargs)[source]¶
Bases:
CmdChannelUse and manage in-game channels.
- Usage:
channel channelname <msg> channel channel name = <msg> channel (show all subscription) channel/all (show available channels) channel/alias channelname = alias[;alias…] channel/unalias alias channel/who channelname channel/history channelname [= index] channel/sub channelname [= alias[;alias…]] channel/unsub channelname[,channelname, …] channel/mute channelname[,channelname,…] channel/unmute channelname[,channelname,…]
channel/create channelname[;alias;alias[:typeclass]] [= description] channel/destroy channelname [= reason] channel/desc channelname = description channel/lock channelname = lockstring channel/unlock channelname = lockstring channel/ban channelname (list bans) channel/ban[/quiet] channelname[, channelname, …] = subscribername [: reason] channel/unban[/quiet] channelname[, channelname, …] = subscribername channel/boot[/quiet] channelname[,channelname,…] = subscribername [: reason]
subtopics¶
sending¶
- Usage: channel channelname msg
channel channel name = msg (with space in channel name)
This sends a message to the channel. Note that you will rarely use this command like this; instead you can use the alias
channelname <msg> channelalias <msg>
For example
public Hello World pub Hello World
(this shortcut doesn’t work for aliases containing spaces)
See channel/alias for help on setting channel aliases.
alias and unalias¶
- Usage: channel/alias channel = alias[;alias[;alias…]]
channel/unalias alias channel - this will list your subs and aliases to each channel
Set one or more personal aliases for referencing a channel. For example:
channel/alias warrior’s guild = warrior;wguild;warchannel;warrior guild
You can now send to the channel using all of these:
warrior’s guild Hello warrior Hello wguild Hello warchannel Hello
Note that this will not work if the alias has a space in it. So the ‘warrior guild’ alias must be used with the channel command:
channel warrior guild = Hello
Channel-aliases can be removed one at a time, using the ‘/unalias’ switch.
who¶
Usage: channel/who channelname
List the channel’s subscribers. Shows who are currently offline or are muting the channel. Subscribers who are ‘muting’ will not see messages sent to the channel (use channel/mute to mute a channel).
history¶
Usage: channel/history channel [= index]
This will display the last |c20|n lines of channel history. By supplying an index number, you will step that many lines back before viewing those 20 lines.
For example:
channel/history public = 35
will go back 35 lines and show the previous 20 lines from that point (so lines -35 to -55).
sub and unsub¶
- Usage: channel/sub channel [=alias[;alias;…]]
channel/unsub channel
This subscribes you to a channel and optionally assigns personal shortcuts for you to use to send to that channel (see aliases). When you unsub, all your personal aliases will also be removed.
mute and unmute¶
- Usage: channel/mute channelname
channel/unmute channelname
Muting silences all output from the channel without actually un-subscribing. Other channel members will see that you are muted in the /who list. Sending a message to the channel will automatically unmute you.
create and destroy¶
- Usage: channel/create channelname[;alias;alias[:typeclass]] [= description]
channel/destroy channelname [= reason]
Creates a new channel (or destroys one you control). You will automatically join the channel you create and everyone will be kicked and loose all aliases to a destroyed channel.
lock and unlock¶
- Usage: channel/lock channelname = lockstring
channel/unlock channelname = lockstring
Note: this is an admin command.
A lockstring is on the form locktype:lockfunc(). Channels understand three locktypes:
listen - who may listen or join the channel. send - who may send messages to the channel control - who controls the channel. This is usually the one creating
the channel.
Common lockfuncs are all() and perm(). To make a channel everyone can listen to but only builders can talk on, use this:
listen:all() send: perm(Builders)
boot and ban¶
- Usage:
channel/boot[/quiet] channelname[,channelname,…] = subscribername [: reason] channel/ban channelname[, channelname, …] = subscribername [: reason] channel/unban channelname[, channelname, …] = subscribername channel/unban channelname channel/ban channelname (list bans)
Booting will kick a named subscriber from channel(s) temporarily. The ‘reason’ will be passed to the booted user. Unless the /quiet switch is used, the channel will also be informed of the action. A booted user is still able to re-connect, but they’ll have to set up their aliases again.
Banning will blacklist a user from (re)joining the provided channels. It will then proceed to boot them from those channels if they were connected. The ‘reason’ and /quiet works the same as for booting.
Example
boot mychannel1 = EvilUser : Kicking you to cool down a bit. ban mychannel1,mychannel2= EvilUser : Was banned for spamming.
- account_caller = False¶
- aliases = ['@channels', '@chan']¶
- help_category = 'comms'¶
- key = '@channel'¶
- lock_storage = 'cmd:not pperm(channel_banned);admin:all();manage:all();changelocks:perm(Admin)'¶
- search_index_entry = {'aliases': '@channels @chan', 'category': 'comms', 'key': '@channel', 'no_prefix': 'channel channels chan', 'tags': '', 'text': "\nUse and manage in-game channels.\n\nUsage:\n channel channelname <msg>\n channel channel name = <msg>\n channel (show all subscription)\n channel/all (show available channels)\n channel/alias channelname = alias[;alias...]\n channel/unalias alias\n channel/who channelname\n channel/history channelname [= index]\n channel/sub channelname [= alias[;alias...]]\n channel/unsub channelname[,channelname, ...]\n channel/mute channelname[,channelname,...]\n channel/unmute channelname[,channelname,...]\n\n channel/create channelname[;alias;alias[:typeclass]] [= description]\n channel/destroy channelname [= reason]\n channel/desc channelname = description\n channel/lock channelname = lockstring\n channel/unlock channelname = lockstring\n channel/ban channelname (list bans)\n channel/ban[/quiet] channelname[, channelname, ...] = subscribername [: reason]\n channel/unban[/quiet] channelname[, channelname, ...] = subscribername\n channel/boot[/quiet] channelname[,channelname,...] = subscribername [: reason]\n\n# subtopics\n\n## sending\n\nUsage: channel channelname msg\n channel channel name = msg (with space in channel name)\n\nThis sends a message to the channel. Note that you will rarely use this\ncommand like this; instead you can use the alias\n\n channelname <msg>\n channelalias <msg>\n\nFor example\n\n public Hello World\n pub Hello World\n\n(this shortcut doesn't work for aliases containing spaces)\n\nSee channel/alias for help on setting channel aliases.\n\n## alias and unalias\n\nUsage: channel/alias channel = alias[;alias[;alias...]]\n channel/unalias alias\n channel - this will list your subs and aliases to each channel\n\nSet one or more personal aliases for referencing a channel. For example:\n\n channel/alias warrior's guild = warrior;wguild;warchannel;warrior guild\n\nYou can now send to the channel using all of these:\n\n warrior's guild Hello\n warrior Hello\n wguild Hello\n warchannel Hello\n\nNote that this will not work if the alias has a space in it. So the\n'warrior guild' alias must be used with the `channel` command:\n\n channel warrior guild = Hello\n\nChannel-aliases can be removed one at a time, using the '/unalias' switch.\n\n## who\n\nUsage: channel/who channelname\n\nList the channel's subscribers. Shows who are currently offline or are\nmuting the channel. Subscribers who are 'muting' will not see messages sent\nto the channel (use channel/mute to mute a channel).\n\n## history\n\nUsage: channel/history channel [= index]\n\nThis will display the last |c20|n lines of channel history. By supplying an\nindex number, you will step that many lines back before viewing those 20 lines.\n\nFor example:\n\n channel/history public = 35\n\nwill go back 35 lines and show the previous 20 lines from that point (so\nlines -35 to -55).\n\n## sub and unsub\n\nUsage: channel/sub channel [=alias[;alias;...]]\n channel/unsub channel\n\nThis subscribes you to a channel and optionally assigns personal shortcuts\nfor you to use to send to that channel (see aliases). When you unsub, all\nyour personal aliases will also be removed.\n\n## mute and unmute\n\nUsage: channel/mute channelname\n channel/unmute channelname\n\nMuting silences all output from the channel without actually\nun-subscribing. Other channel members will see that you are muted in the /who\nlist. Sending a message to the channel will automatically unmute you.\n\n## create and destroy\n\nUsage: channel/create channelname[;alias;alias[:typeclass]] [= description]\n channel/destroy channelname [= reason]\n\nCreates a new channel (or destroys one you control). You will automatically\njoin the channel you create and everyone will be kicked and loose all aliases\nto a destroyed channel.\n\n## lock and unlock\n\nUsage: channel/lock channelname = lockstring\n channel/unlock channelname = lockstring\n\nNote: this is an admin command.\n\nA lockstring is on the form locktype:lockfunc(). Channels understand three\nlocktypes:\n listen - who may listen or join the channel.\n send - who may send messages to the channel\n control - who controls the channel. This is usually the one creating\n the channel.\n\nCommon lockfuncs are all() and perm(). To make a channel everyone can\nlisten to but only builders can talk on, use this:\n\n listen:all()\n send: perm(Builders)\n\n## boot and ban\n\nUsage:\n channel/boot[/quiet] channelname[,channelname,...] = subscribername [: reason]\n channel/ban channelname[, channelname, ...] = subscribername [: reason]\n channel/unban channelname[, channelname, ...] = subscribername\n channel/unban channelname\n channel/ban channelname (list bans)\n\nBooting will kick a named subscriber from channel(s) temporarily. The\n'reason' will be passed to the booted user. Unless the /quiet switch is\nused, the channel will also be informed of the action. A booted user is\nstill able to re-connect, but they'll have to set up their aliases again.\n\nBanning will blacklist a user from (re)joining the provided channels. It\nwill then proceed to boot them from those channels if they were connected.\nThe 'reason' and `/quiet` works the same as for booting.\n\nExample:\n boot mychannel1 = EvilUser : Kicking you to cool down a bit.\n ban mychannel1,mychannel2= EvilUser : Was banned for spamming.\n\n"}¶
- class evennia.commands.default.comms.CmdPage(**kwargs)[source]¶
Bases:
MuxCommandsend a private message to another account
- Usage:
page <account> <message> page[/switches] [<account>,<account>,… = <message>] tell ‘’ page <number>
- Switches:
last - shows who you last messaged list - show your last <number> of tells/pages (default)
Send a message to target user (if online). If no argument is given, you will get a list of your latest messages. The equal sign is needed for multiple targets or if sending to target with space in the name.
- key = 'page'¶
- aliases = ['tell']¶
- switch_options = ('last', 'list')¶
- locks = 'cmd:not pperm(page_banned)'¶
- help_category = 'comms'¶
- account_caller = True¶
- lock_storage = 'cmd:not pperm(page_banned)'¶
- search_index_entry = {'aliases': 'tell', 'category': 'comms', 'key': 'page', 'no_prefix': ' tell', 'tags': '', 'text': "\nsend a private message to another account\n\nUsage:\n page <account> <message>\n page[/switches] [<account>,<account>,... = <message>]\n tell ''\n page <number>\n\nSwitches:\n last - shows who you last messaged\n list - show your last <number> of tells/pages (default)\n\nSend a message to target user (if online). If no argument is given, you\nwill get a list of your latest messages. The equal sign is needed for\nmultiple targets or if sending to target with space in the name.\n\n"}¶
- class evennia.commands.default.comms.CmdIRC2Chan(**kwargs)[source]¶
Bases:
MuxCommandLink an evennia channel to an external IRC channel
- Usage:
irc2chan[/switches] <evennia_channel> = <ircnetwork> <port> <#irchannel> <botname>[:typeclass] irc2chan/delete botname|#dbid
- Switches:
- /delete
this will delete the bot and remove the irc connection
to the channel. Requires the botname or #dbid as input.
- /remove
alias to /delete
/disconnect - alias to /delete /list - show all irc<->evennia mappings /ssl - use an SSL-encrypted connection
Example
irc2chan myircchan = irc.dalnet.net 6667 #mychannel evennia-bot irc2chan public = irc.freenode.net 6667 #evgaming #evbot:accounts.mybot.MyBot
This creates an IRC bot that connects to a given IRC network and channel. If a custom typeclass path is given, this will be used instead of the default bot class. The bot will relay everything said in the evennia channel to the IRC channel and vice versa. The bot will automatically connect at server start, so this command need only be given once. The /disconnect switch will permanently delete the bot. To only temporarily deactivate it, use the |wservices|n command instead. Provide an optional bot class path to use a custom bot.
- key = 'irc2chan'¶
- switch_options = ('delete', 'remove', 'disconnect', 'list', 'ssl')¶
- locks = 'cmd:serversetting(IRC_ENABLED) and pperm(Developer)'¶
- help_category = 'comms'¶
- aliases = []¶
- lock_storage = 'cmd:serversetting(IRC_ENABLED) and pperm(Developer)'¶
- search_index_entry = {'aliases': '', 'category': 'comms', 'key': 'irc2chan', 'no_prefix': ' ', 'tags': '', 'text': '\nLink an evennia channel to an external IRC channel\n\nUsage:\n irc2chan[/switches] <evennia_channel> = <ircnetwork> <port> <#irchannel> <botname>[:typeclass]\n irc2chan/delete botname|#dbid\n\nSwitches:\n /delete - this will delete the bot and remove the irc connection\n to the channel. Requires the botname or #dbid as input.\n /remove - alias to /delete\n /disconnect - alias to /delete\n /list - show all irc<->evennia mappings\n /ssl - use an SSL-encrypted connection\n\nExample:\n irc2chan myircchan = irc.dalnet.net 6667 #mychannel evennia-bot\n irc2chan public = irc.freenode.net 6667 #evgaming #evbot:accounts.mybot.MyBot\n\nThis creates an IRC bot that connects to a given IRC network and\nchannel. If a custom typeclass path is given, this will be used\ninstead of the default bot class.\nThe bot will relay everything said in the evennia channel to the\nIRC channel and vice versa. The bot will automatically connect at\nserver start, so this command need only be given once. The\n/disconnect switch will permanently delete the bot. To only\ntemporarily deactivate it, use the |wservices|n command instead.\nProvide an optional bot class path to use a custom bot.\n'}¶
- class evennia.commands.default.comms.CmdIRCStatus(**kwargs)[source]¶
Bases:
MuxCommandCheck and reboot IRC bot.
- Usage:
ircstatus [#dbref ping | nicklist | reconnect]
If not given arguments, will return a list of all bots (like irc2chan/list). The ‘ping’ argument will ping the IRC network to see if the connection is still responsive. The ‘nicklist’ argument (aliases are ‘who’ and ‘users’) will return a list of users on the remote IRC channel. Finally, ‘reconnect’ will force the client to disconnect and reconnect again. This may be a last resort if the client has silently lost connection (this may happen if the remote network experience network issues). During the reconnection messages sent to either channel will be lost.
- key = 'ircstatus'¶
- locks = 'cmd:serversetting(IRC_ENABLED) and perm(ircstatus) or perm(Builder))'¶
- help_category = 'comms'¶
- aliases = []¶
- lock_storage = 'cmd:serversetting(IRC_ENABLED) and perm(ircstatus) or perm(Builder))'¶
- search_index_entry = {'aliases': '', 'category': 'comms', 'key': 'ircstatus', 'no_prefix': ' ', 'tags': '', 'text': "\nCheck and reboot IRC bot.\n\nUsage:\n ircstatus [#dbref ping | nicklist | reconnect]\n\nIf not given arguments, will return a list of all bots (like\nirc2chan/list). The 'ping' argument will ping the IRC network to\nsee if the connection is still responsive. The 'nicklist' argument\n(aliases are 'who' and 'users') will return a list of users on the\nremote IRC channel. Finally, 'reconnect' will force the client to\ndisconnect and reconnect again. This may be a last resort if the\nclient has silently lost connection (this may happen if the remote\nnetwork experience network issues). During the reconnection\nmessages sent to either channel will be lost.\n\n"}¶
- class evennia.commands.default.comms.CmdRSS2Chan(**kwargs)[source]¶
Bases:
MuxCommandlink an evennia channel to an external RSS feed
- Usage:
rss2chan[/switches] <evennia_channel> = <rss_url>
- Switches:
- /disconnect - this will stop the feed and remove the connection to the
channel.
- /remove
“
- /list
show all rss->evennia mappings
Example
rss2chan rsschan = http://code.google.com/feeds/p/evennia/updates/basic
This creates an RSS reader that connects to a given RSS feed url. Updates will be echoed as a title and news link to the given channel. The rate of updating is set with the RSS_UPDATE_INTERVAL variable in settings (default is every 10 minutes).
When disconnecting you need to supply both the channel and url again so as to identify the connection uniquely.
- key = 'rss2chan'¶
- switch_options = ('disconnect', 'remove', 'list')¶
- locks = 'cmd:serversetting(RSS_ENABLED) and pperm(Developer)'¶
- help_category = 'comms'¶
- aliases = []¶
- lock_storage = 'cmd:serversetting(RSS_ENABLED) and pperm(Developer)'¶
- search_index_entry = {'aliases': '', 'category': 'comms', 'key': 'rss2chan', 'no_prefix': ' ', 'tags': '', 'text': '\nlink an evennia channel to an external RSS feed\n\nUsage:\n rss2chan[/switches] <evennia_channel> = <rss_url>\n\nSwitches:\n /disconnect - this will stop the feed and remove the connection to the\n channel.\n /remove - "\n /list - show all rss->evennia mappings\n\nExample:\n rss2chan rsschan = http://code.google.com/feeds/p/evennia/updates/basic\n\nThis creates an RSS reader that connects to a given RSS feed url. Updates\nwill be echoed as a title and news link to the given channel. The rate of\nupdating is set with the RSS_UPDATE_INTERVAL variable in settings (default\nis every 10 minutes).\n\nWhen disconnecting you need to supply both the channel and url again so as\nto identify the connection uniquely.\n'}¶
- class evennia.commands.default.comms.CmdGrapevine2Chan(**kwargs)[source]¶
Bases:
MuxCommandLink an Evennia channel to an external Grapevine channel
- Usage:
grapevine2chan[/switches] <evennia_channel> = <grapevine_channel> grapevine2chan/disconnect <connection #id>
- Switches:
- /list
(or no switch): show existing grapevine <-> Evennia
mappings and available grapevine chans
- /remove
alias to disconnect
- /delete
alias to disconnect
Example
grapevine2chan mygrapevine = gossip
This creates a link between an in-game Evennia channel and an external Grapevine channel. The game must be registered with the Grapevine network (register at https://grapevine.haus) and the GRAPEVINE_* auth information must be added to game settings.
- key = 'grapevine2chan'¶
- switch_options = ('disconnect', 'remove', 'delete', 'list')¶
- locks = 'cmd:serversetting(GRAPEVINE_ENABLED) and pperm(Developer)'¶
- help_category = 'comms'¶
- aliases = []¶
- lock_storage = 'cmd:serversetting(GRAPEVINE_ENABLED) and pperm(Developer)'¶
- search_index_entry = {'aliases': '', 'category': 'comms', 'key': 'grapevine2chan', 'no_prefix': ' ', 'tags': '', 'text': '\nLink an Evennia channel to an external Grapevine channel\n\nUsage:\n grapevine2chan[/switches] <evennia_channel> = <grapevine_channel>\n grapevine2chan/disconnect <connection #id>\n\nSwitches:\n /list - (or no switch): show existing grapevine <-> Evennia\n mappings and available grapevine chans\n /remove - alias to disconnect\n /delete - alias to disconnect\n\nExample:\n grapevine2chan mygrapevine = gossip\n\nThis creates a link between an in-game Evennia channel and an external\nGrapevine channel. The game must be registered with the Grapevine network\n(register at https://grapevine.haus) and the GRAPEVINE_* auth information\nmust be added to game settings.\n'}¶
- class evennia.commands.default.comms.CmdDiscord2Chan(**kwargs)[source]¶
Bases:
MuxCommandLink an Evennia channel to an external Discord channel
- Usage:
discord2chan[/switches] discord2chan[/switches] <evennia_channel> [= <discord_channel_id>]
- Switches:
- /list
(or no switch) show existing Evennia <-> Discord links
- /remove
remove an existing link by link ID
- /delete
alias to remove
- /guild
toggle the Discord server tag on/off
/channel - toggle the Evennia/Discord channel tags on/off /start - tell the bot to start, in case it lost its connection
Example
discord2chan mydiscord = 555555555555555
This creates a link between an in-game Evennia channel and an external Discord channel. You must have a valid Discord bot application ( https://discord.com/developers/applications ) and your DISCORD_BOT_TOKEN must be added to settings. (Please put it in secret_settings !)
- key = 'discord2chan'¶
- aliases = ['discord']¶
- switch_options = ('channel', 'delete', 'guild', 'list', 'remove', 'start')¶
- locks = 'cmd:serversetting(DISCORD_ENABLED) and pperm(Developer)'¶
- help_category = 'comms'¶
- lock_storage = 'cmd:serversetting(DISCORD_ENABLED) and pperm(Developer)'¶
- search_index_entry = {'aliases': 'discord', 'category': 'comms', 'key': 'discord2chan', 'no_prefix': ' discord', 'tags': '', 'text': '\nLink an Evennia channel to an external Discord channel\n\nUsage:\n discord2chan[/switches]\n discord2chan[/switches] <evennia_channel> [= <discord_channel_id>]\n\nSwitches:\n /list - (or no switch) show existing Evennia <-> Discord links\n /remove - remove an existing link by link ID\n /delete - alias to remove\n /guild - toggle the Discord server tag on/off\n /channel - toggle the Evennia/Discord channel tags on/off\n /start - tell the bot to start, in case it lost its connection\n\nExample:\n discord2chan mydiscord = 555555555555555\n\nThis creates a link between an in-game Evennia channel and an external\nDiscord channel. You must have a valid Discord bot application\n( https://discord.com/developers/applications ) and your DISCORD_BOT_TOKEN\nmust be added to settings. (Please put it in secret_settings !)\n'}¶
- class evennia.commands.default.comms.AccountDB(*args, **kwargs)[source]¶
Bases:
TypedObject,AbstractUserThis is a special model using Django’s ‘profile’ functionality and extends the default Django User model. It is defined as such by use of the variable AUTH_PROFILE_MODULE in the settings. One accesses the fields/methods. We try use this model as much as possible rather than User, since we can customize this to our liking.
The TypedObject supplies the following (inherited) properties:
key - main name
typeclass_path - the path to the decorating typeclass
typeclass - auto-linked typeclass
date_created - time stamp of object creation
permissions - perm strings
dbref - #id of object
db - persistent attribute storage
ndb - non-persistent attribute storage
The AccountDB adds the following properties:
is_connected - If any Session is currently connected to this Account
name - alias for user.username
sessions - sessions connected to this account
is_superuser - bool if this account is a superuser
is_bot - bool if this account is a bot and not a real account
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- account_subscription_set¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- property cmdset_storage¶
Getter. Allows for value = self.name. Returns a list of cmdset_storage.
- date_joined¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- db_attributes¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- db_cmdset_storage¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- db_date_created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- db_is_bot¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- db_is_connected¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- db_key¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- db_lock_storage¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- db_tags¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- db_typeclass_path¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- email¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- first_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)¶
- get_next_by_db_date_created(*, field=<django.db.models.fields.DateTimeField: db_date_created>, is_next=True, **kwargs)¶
- get_previous_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)¶
- get_previous_by_db_date_created(*, field=<django.db.models.fields.DateTimeField: db_date_created>, is_next=False, **kwargs)¶
- groups¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- hide_from_accounts_set¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_active¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property is_bot¶
A wrapper for getting database field db_is_bot.
- property is_connected¶
A wrapper for getting database field db_is_connected.
- is_staff¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_superuser¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property key¶
- last_login¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- last_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- logentry_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
**Parent.children** is a **ReverseManyToOneDescriptor** instance.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- property name¶
- objectdb_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
**Parent.children** is a **ReverseManyToOneDescriptor** instance.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- objects = <evennia.accounts.manager.AccountDBManager object>¶
- password¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- path = 'evennia.accounts.models.AccountDB'¶
- receiver_account_set¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- scriptdb_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
**Parent.children** is a **ReverseManyToOneDescriptor** instance.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- sender_account_set¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- typename = 'SharedMemoryModelBase'¶
- property uid¶
Getter. Retrieves the user id
- user_permissions¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- username¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- evennia.commands.default.comms.CHANNEL_DEFAULT_TYPECLASS¶
alias of
DefaultChannel
- evennia.commands.default.comms.COMMAND_DEFAULT_CLASS¶
alias of
MuxCommand
- class evennia.commands.default.comms.DefaultChannel(*args, **kwargs)[source]¶
Bases:
ChannelDBThis is the base class for all Channel Comms. Inherit from this to create different types of communication channels.
Class-level variables: - send_to_online_only (bool, default True) - if set, will only try to
send to subscribers that are actually active. This is a useful optimization.
log_file (str, default “channel_{channelname}.log”). This is the log file to which the channel history will be saved. The {channelname} tag will be replaced by the key of the Channel. If an Attribute ‘log_file’ is set, this will be used instead. If this is None and no Attribute is found, no history will be saved.
channel_prefix_string (str, default “[{channelname} ]”) - this is used as a simple template to get the channel prefix with .channel_prefix(). It is used in front of every channel message; use {channelmessage} token to insert the name of the current channel. Set to None if you want no prefix (or want to handle it in a hook during message generation instead.
channel_msg_nick_pattern**(str, default **”{alias}s*?|{alias}s+?(?P<arg1>.+?)”) - this is what used when a channel subscriber gets a channel nick assigned to this channel. The nickhandler uses the pattern to pick out this channel’s name from user input. The **{alias} token will get both the channel’s key and any set/custom aliases per subscriber. You need to allow for an <arg1> regex group to catch any message that should be send to the channel. You usually don’t need to change this pattern unless you are changing channel command-style entirely.
channel_msg_nick_replacement (str, default “channel {channelname} = $1” - this is used by the nickhandler to generate a replacement string once the nickhandler (using the channel_msg_nick_pattern) identifies that the channel should be addressed to send a message to it. The <arg1> regex pattern match from channel_msg_nick_pattern will end up at the $1 position in the replacement. Together, this allows you do e.g. ‘public Hello’ and have that become a mapping to channel public = Hello. By default, the account-level channel command is used. If you were to rename that command you must tweak the output to something like yourchannelcommandname {channelname} = $1.
- Properties:
mutelist banlist wholist
- Working methods:
get_log_filename() set_log_filename(filename) has_connection(account) - check if the given account listens to this channel connect(account) - connect account to this channel disconnect(account) - disconnect account from channel access(access_obj, access_type=’listen’, default=False) - check the
access on this channel (default access_type is listen)
create(key, creator=None, *args, **kwargs) delete() - delete this channel message_transform(msg, emit=False, prefix=True,
sender_strings=None, external=False) - called by the comm system and triggers the hooks below
- msg(msgobj, header=None, senders=None, sender_strings=None,
- persistent=None, online=False, emit=False, external=False) - main
send method, builds and sends a new message to channel.
- tempmsg(msg, header=None, senders=None) - wrapper for sending non-persistent
messages.
- distribute_message(msg, online=False) - send a message to all
connected accounts on channel, optionally sending only to accounts that are currently online (optimized for very large sends)
mute(subscriber, **kwargs) unmute(subscriber, **kwargs) ban(target, **kwargs) unban(target, **kwargs) add_user_channel_alias(user, alias, **kwargs) remove_user_channel_alias(user, alias, **kwargs)
- Useful hooks:
at_channel_creation() - called once, when the channel is created basetype_setup() at_init() at_first_save() channel_prefix() - how the channel should be
prefixed when returning to user. Returns a string
- format_senders(senders) - should return how to display multiple
senders to a channel
- pose_transform(msg, sender_string) - should detect if the
sender is posing, and if so, modify the string
- format_external(msg, senders, emit=False) - format messages sent
from outside the game, like from IRC
- format_message(msg, emit=False) - format the message body before
displaying it to the user. ‘emit’ generally means that the message should not be displayed with the sender’s name.
channel_prefix()
pre_join_channel(joiner) - if returning False, abort join post_join_channel(joiner) - called right after successful join pre_leave_channel(leaver) - if returning False, abort leave post_leave_channel(leaver) - called right after successful leave at_pre_msg(message, **kwargs) at_post_msg(message, **kwargs) web_get_admin_url() web_get_create_url() web_get_detail_url() web_get_update_url() web_get_delete_url()
- exception DoesNotExist¶
Bases:
DoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- access(accessing_obj, access_type='listen', default=False, no_superuser_bypass=False, **kwargs)[source]¶
Determines if another object has permission to access.
- Parameters:
accessing_obj (Object) – Object trying to access this one.
access_type (str, optional) – Type of access sought.
default (bool, optional) – What to return if no lock of access_type was found
no_superuser_bypass (bool, optional) – Turns off superuser lock bypass. Be careful with this one.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
- Returns:
return (bool) – Result of lock check.
- add_user_channel_alias(user, alias, **kwargs)[source]¶
Add a personal user-alias for this channel to a given subscriber.
- Parameters:
user (Object or Account) – The one to alias this channel.
alias (str) – The desired alias.
Note
This is tightly coupled to the default channel command. If you change that, you need to change this as well.
We add two nicks - one is a plain alias -> channel.key that users need to be able to reference this channel easily. The other is a templated nick to easily be able to send messages to the channel without needing to give the full channel command. The structure of this nick is given by self.channel_msg_nick_pattern and self.channel_msg_nick_replacement. By default it maps alias <msg> -> channel <channelname> = <msg>, so that you can for example just write pub Hello to send a message.
The alias created is alias $1 -> channel channel = $1, to allow for sending to channel using the main channel command.
- at_first_save()[source]¶
Called by the typeclass system the very first time the channel is saved to the database. Generally, don’t overload this but the hooks called by this method.
- at_init()[source]¶
Hook method. This is always called whenever this channel is initiated – that is, whenever it its typeclass is cached from memory. This happens on-demand first time the channel is used or activated in some way after being created but also after each server restart or reload.
- at_post_msg(message, **kwargs)[source]¶
This is called after sending to all valid recipients. It is normally used for logging/channel history.
- Parameters:
message (str) – The message sent.
**kwargs (any) – Keywords passed on from msg, including senders.
- at_pre_msg(message, **kwargs)[source]¶
Called before the starting of sending the message to a receiver. This is called before any hooks on the receiver itself. If this returns None/False, the sending will be aborted.
- Parameters:
message (str) – The message to send.
**kwargs (any) – Keywords passed on from .msg. This includes senders.
- Returns:
str, False or None –
- Any custom changes made to the message. If
falsy, no message will be sent.
- ban(target, **kwargs)[source]¶
Ban a given user from connecting to the channel. This will not stop users already connected, so the user must be booted for this to take effect.
- Parameters:
target (Object or Account) – The entity to unmute. This need not be a subscriber.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
- Returns:
bool –
- True if banning was successful, False if target was already
banned.
- property banlist¶
- channel_msg_nick_pattern = '{alias}\\s*?|{alias}\\s+?(?P<arg1>.+?)'¶
- channel_msg_nick_replacement = '@channel {channelname} = $1'¶
- channel_prefix()[source]¶
Hook method. How the channel should prefix itself for users.
- Returns:
str – The channel prefix.
- channel_prefix_string = '[{channelname}] '¶
- connect(subscriber, **kwargs)[source]¶
Connect the user to this channel. This checks access.
- Parameters:
subscriber (Account or Object) – the entity to subscribe to this channel.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
- Returns:
success (bool) –
- Whether or not the addition was
successful.
- classmethod create(key, creator=None, *args, **kwargs)[source]¶
Creates a basic Channel with default parameters, unless otherwise specified or extended.
Provides a friendlier interface to the utils.create_channel() function.
- Parameters:
key (str) – This must be unique.
creator (Account or Object) – Entity to associate with this channel (used for tracking)
- Keyword Arguments:
aliases (list of str) – List of alternative (likely shorter) keynames.
description (str) – A description of the channel, for use in listings.
locks (str) – Lockstring.
keep_log (bool) – Log channel throughput.
typeclass (str or class) – The typeclass of the Channel (not often used).
ip (str) – IP address of creator (for object auditing).
- Returns:
channel (Channel) – A newly created Channel. errors (list): A list of errors in string form, if any.
- delete()[source]¶
Deletes channel.
- Returns:
bool –
- If deletion was successful. Only time it can fail would be
if channel was already deleted. Even if it were to fail, all subscribers will be disconnected.
- disconnect(subscriber, **kwargs)[source]¶
Disconnect entity from this channel.
- Parameters:
subscriber (Account of Object) – the entity to disconnect.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
- Returns:
success (bool) –
- Whether or not the removal was
successful.
- get_absolute_url()¶
Returns the URI path for a View that allows users to view details for this object.
ex. Oscar (Character) = ‘/characters/oscar/1/’
For this to work, the developer must have defined a named view somewhere in urls.py that follows the format ‘modelname-action’, so in this case a named view of ‘channel-detail’ would be referenced by this method.
ex.
url(r'channels/(?P<slug>[\w\d\-]+)/$', ChannelDetailView.as_view(), name='channel-detail')
If no View has been created and defined in urls.py, returns an HTML anchor.
This method is naive and simply returns a path. Securing access to the actual view and limiting who can view this object is the developer’s responsibility.
- Returns:
path (str) – URI path to object detail page, if defined.
- get_log_filename()[source]¶
File name to use for channel log.
- Returns:
str –
- The filename to use (this is always assumed to be inside
settings.LOG_DIR)
- has_connection(subscriber)[source]¶
Checks so this account is actually listening to this channel.
- Parameters:
subscriber (Account or Object) – Entity to check.
- Returns:
has_sub (bool) –
- Whether the subscriber is subscribing to
this channel or not.
Notes
- This will first try Account subscribers and only try Object
if the Account fails.
- log_file = 'channel_{channelname}.log'¶
- msg(message, senders=None, bypass_mute=False, **kwargs)[source]¶
Send message to channel, causing it to be distributed to all non-muted subscribed users of that channel.
- Parameters:
message (str) – The message to send.
senders (Object, Account or list, optional) – If not given, there is no way to associate one or more senders with the message (like a broadcast message or similar).
bypass_mute (bool, optional) – If set, always send, regardless of individual mute-state of subscriber. This can be used for global announcements or warnings/alerts.
**kwargs (any) – This will be passed on to all hooks. Use no_prefix to exclude the channel prefix.
Notes
The call hook calling sequence is:
msg = channel.at_pre_msg(message, **kwargs) (aborts for all if return None)
msg = receiver.at_pre_channel_msg(msg, channel, **kwargs) (aborts for receiver if return None)
receiver.at_channel_msg(msg, channel, **kwargs)
receiver.at_post_channel_msg(msg, channel, **kwargs)**
Called after all receivers are processed: - channel.at_post_all_msg(message, **kwargs)
(where the senders/bypass_mute are embedded into **kwargs for later access in hooks)
- mute(subscriber, **kwargs)[source]¶
Adds an entity to the list of muted subscribers. A muted subscriber will no longer see channel messages, but may use channel commands.
- Parameters:
subscriber (Object or Account) – Subscriber to mute.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
- Returns:
bool –
- True if muting was successful, False if we were already
muted.
- property mutelist¶
- objects = <evennia.comms.managers.ChannelManager object>¶
- path = 'evennia.comms.comms.DefaultChannel'¶
- post_join_channel(joiner, **kwargs)[source]¶
Hook method. Runs right after an object or account joins a channel.
- Parameters:
joiner (object) – The joining object.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
Notes
By default this adds the needed channel nicks to the joiner.
- post_leave_channel(leaver, **kwargs)[source]¶
Hook method. Runs right after an object or account leaves a channel.
- Parameters:
leaver (object) – The leaving object.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
- pre_join_channel(joiner, **kwargs)[source]¶
Hook method. Runs right before a channel is joined. If this returns a false value, channel joining is aborted.
- Parameters:
joiner (object) – The joining object.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
- Returns:
should_join (bool) – If False, channel joining is aborted.
- pre_leave_channel(leaver, **kwargs)[source]¶
Hook method. Runs right before a user leaves a channel. If this returns a false value, leaving the channel will be aborted.
- Parameters:
leaver (object) – The leaving object.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
- Returns:
should_leave (bool) – If False, channel parting is aborted.
- classmethod remove_user_channel_alias(user, alias, **kwargs)[source]¶
Remove a personal channel alias from a user.
- Parameters:
user (Object or Account) – The user to remove an alias from.
alias (str) – The alias to remove.
**kwargs – Unused by default. Can be used to pass extra variables into a custom implementation.
Notes
The channel-alias actually consists of two aliases - one channel-based one for searching channels with the alias and one inputline one for doing the ‘channelalias msg’ - call.
This is a classmethod because it doesn’t actually operate on the channel instance.
It sits on the channel because the nick structure for this is pretty complex and needs to be located in a central place (rather on, say, the channel command).
- send_to_online_only = True¶
- set_log_filename(filename)[source]¶
Set a custom log filename.
- Parameters:
filename (str) – The filename to set. This is a path starting from inside the settings.LOG_DIR location.
- typename = 'DefaultChannel'¶
- unban(target, **kwargs)[source]¶
Un-Ban a given user. This will not reconnect them - they will still have to reconnect and set up aliases anew.
- Parameters:
target (Object or Account) – The entity to unmute. This need not be a subscriber.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
- Returns:
bool –
- True if unbanning was successful, False if target was not
previously banned.
- unmute(subscriber, **kwargs)[source]¶
Removes an entity from the list of muted subscribers. A muted subscriber will no longer see channel messages, but may use channel commands.
- Parameters:
subscriber (Object or Account) – The subscriber to unmute.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
- Returns:
bool –
- True if unmuting was successful, False if we were already
unmuted.
- web_get_admin_url()[source]¶
Returns the URI path for the Django Admin page for this object.
ex. Account#1 = ‘/admin/accounts/accountdb/1/change/’
- Returns:
path (str) – URI path to Django Admin page for object.
- classmethod web_get_create_url()[source]¶
Returns the URI path for a View that allows users to create new instances of this object.
ex. Chargen = ‘/characters/create/’
For this to work, the developer must have defined a named view somewhere in urls.py that follows the format ‘modelname-action’, so in this case a named view of ‘channel-create’ would be referenced by this method.
ex. url(r’channels/create/’, ChannelCreateView.as_view(), name=’channel-create’)
If no View has been created and defined in urls.py, returns an HTML anchor.
This method is naive and simply returns a path. Securing access to the actual view and limiting who can create new objects is the developer’s responsibility.
- Returns:
path (str) – URI path to object creation page, if defined.
- web_get_delete_url()[source]¶
Returns the URI path for a View that allows users to delete this object.
ex. Oscar (Character) = ‘/characters/oscar/1/delete/’
For this to work, the developer must have defined a named view somewhere in urls.py that follows the format ‘modelname-action’, so in this case a named view of ‘channel-delete’ would be referenced by this method.
ex. url(r’channels/(?P<slug>[wd-]+)/(?P<pk>[0-9]+)/delete/$’,
ChannelDeleteView.as_view(), name=’channel-delete’)
If no View has been created and defined in urls.py, returns an HTML anchor.
This method is naive and simply returns a path. Securing access to the actual view and limiting who can delete this object is the developer’s responsibility.
- Returns:
path (str) – URI path to object deletion page, if defined.
- web_get_detail_url()[source]¶
Returns the URI path for a View that allows users to view details for this object.
ex. Oscar (Character) = ‘/characters/oscar/1/’
For this to work, the developer must have defined a named view somewhere in urls.py that follows the format ‘modelname-action’, so in this case a named view of ‘channel-detail’ would be referenced by this method.
ex.
url(r'channels/(?P<slug>[\w\d\-]+)/$', ChannelDetailView.as_view(), name='channel-detail')
If no View has been created and defined in urls.py, returns an HTML anchor.
This method is naive and simply returns a path. Securing access to the actual view and limiting who can view this object is the developer’s responsibility.
- Returns:
path (str) – URI path to object detail page, if defined.
- web_get_update_url()[source]¶
Returns the URI path for a View that allows users to update this object.
ex. Oscar (Character) = ‘/characters/oscar/1/change/’
For this to work, the developer must have defined a named view somewhere in urls.py that follows the format ‘modelname-action’, so in this case a named view of ‘channel-update’ would be referenced by this method.
ex.
url(r'channels/(?P<slug>[\w\d\-]+)/(?P<pk>[0-9]+)/change/$', ChannelUpdateView.as_view(), name='channel-update')
If no View has been created and defined in urls.py, returns an HTML anchor.
This method is naive and simply returns a path. Securing access to the actual view and limiting who can modify objects is the developer’s responsibility.
- Returns:
path (str) – URI path to object update page, if defined.
- property wholist¶
- exception evennia.commands.default.comms.LockException[source]¶
Bases:
ExceptionRaised during an error in a lock.
- class evennia.commands.default.comms.Msg(*args, **kwargs)[source]¶
Bases:
SharedMemoryModelA single message. This model describes all ooc messages sent in-game, both to channels and between accounts.
The Msg class defines the following database fields (all accessed via specific handler methods):
db_sender_accounts: Account senders
db_sender_objects: Object senders
db_sender_scripts: Script senders
db_sender_external: External sender (defined as string name)
db_receivers_accounts: Receiving accounts
db_receivers_objects: Receiving objects
db_receivers_scripts: Receiveing scripts
db_receiver_external: External sender (defined as string name)
db_header: Header text
db_message: The actual message text
db_date_created: time message was created / sent
db_hide_from_sender: bool if message should be hidden from sender
db_hide_from_receivers: list of receiver objects to hide message from
db_lock_storage: Internal storage of lock strings.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- access(accessing_obj, access_type='read', default=False)[source]¶
Checks lock access.
- Parameters:
accessing_obj (Object or Account) – The object trying to gain access.
access_type (str, optional) – The type of lock access to check.
default (bool) – Fallback to use if access_type lock is not defined.
- Returns:
result (bool) – If access was granted or not.
- property date_created¶
Return the field in localized time based on settings.TIME_ZONE.
- db_date_created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- db_header¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- db_hide_from_accounts¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- db_hide_from_objects¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- db_lock_storage¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- db_message¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- db_receiver_external¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- db_receivers_accounts¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- db_receivers_objects¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- db_receivers_scripts¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- db_sender_accounts¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- db_sender_external¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- db_sender_objects¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- db_sender_scripts¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- db_tags¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
**Pizza.toppings** and **Topping.pizzas** are **ManyToManyDescriptor** instances.
Most of the implementation is delegated to a dynamically defined manager class built by **create_forward_many_to_many_manager()** defined below.
- get_next_by_db_date_created(*, field=<django.db.models.fields.DateTimeField: db_date_created>, is_next=True, **kwargs)¶
- get_previous_by_db_date_created(*, field=<django.db.models.fields.DateTimeField: db_date_created>, is_next=False, **kwargs)¶
- property header¶
A wrapper for getting database field db_header.
- property hide_from¶
Getter. Allows for value = self.hide_from. Returns two lists of accounts and objects.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property lock_storage¶
A wrapper for getting database field db_lock_storage.
- property message¶
A wrapper for getting database field db_message.
- objects = <evennia.comms.managers.MsgManager object>¶
- path = 'evennia.comms.models.Msg'¶
- property receiver_external¶
A wrapper for getting database field db_receiver_external.
- property receivers¶
Getter. Allows for value = self.receivers. Returns four lists of receivers: accounts, objects, scripts and
external_receivers.
- remove_receiver(receivers)[source]¶
Remove a single receiver, a list of receivers, or a single extral receiver.
- Parameters:
receivers (Account, Object, Script, list or str) – Receiver to remove. A string removes the external receiver.
- remove_sender(senders)[source]¶
Remove a single sender or a list of senders.
- Parameters:
senders (Account, Object, str or list) – Senders to remove. If a string, removes the external sender.
- property sender_external¶
A wrapper for getting database field db_sender_external.
- property senders¶
Getter. Allows for value = self.senders
- typename = 'SharedMemoryModelBase'¶
- class evennia.commands.default.comms.Q(*args, _connector=None, _negated=False, **kwargs)[source]¶
Bases:
NodeEncapsulate filters as objects that can then be combined logically (using & and |).
- AND = 'AND'¶
- OR = 'OR'¶
- XOR = 'XOR'¶
- __init__(*args, _connector=None, _negated=False, **kwargs)[source]¶
Construct a new Node. If no connector is given, use the default.
- check(against, using='default')[source]¶
Do a database query to check if the expressions of the Q instance matches against the expressions.
- conditional = True¶
- default = 'AND'¶
- identity¶
- referenced_base_fields¶
Retrieve all base fields referenced directly or through F expressions excluding any fields referenced through joins.
- evennia.commands.default.comms.ask_yes_no(caller, prompt='Yes or No {options}?', yes_action='Yes', no_action='No', default=None, allow_abort=False, session=None, *args, **kwargs)[source]¶
A helper function for asking a simple yes/no question. This will cause the system to pause and wait for input from the player.
- Parameters:
caller (Object) – The entity being asked.
prompt (str) – The yes/no question to ask. This takes an optional formatting marker {options} which will be filled with ‘Y/N’, ‘[Y]/N’ or ‘Y/[N]’ depending on the setting of default. If allow_abort is set, then the ‘A(bort)’ option will also be available.
yes_action (callable or str) – If a callable, this will be called with (caller, *args, **kwargs) when the Yes-choice is made. If a string, this string will be echoed back to the caller.
no_action (callable or str) – If a callable, this will be called with (caller, *args, **kwargs) when the No-choice is made. If a string, this string will be echoed back to the caller.
default (str optional) – This is what the user will get if they just press the return key without giving any input. One of ‘N’, ‘Y’, ‘A’ or None for no default (an explicit choice must be given). If ‘A’ (abort) is given, allow_abort kwarg is ignored and assumed set.
allow_abort (bool, optional) – If set, the ‘A(bort)’ option is available (a third option meaning neither yes or no but just exits the prompt).
session (Session, optional) – This allows to specify the session to send the prompt to. It’s usually only needed if caller is an Account in multisession modes greater than 2. The session is then updated by the command and is available (for example in callbacks) through caller.ndb._yes_no_question.session.
*args – Additional arguments passed on into callables.
**kwargs – Additional keyword args passed on into callables.
- Raises:
RuntimeError, FooError – If default and allow_abort clashes.
Example
# just returning strings ask_yes_no(caller, "Are you happy {options}?", "you answered yes", "you answered no") # trigger callables ask_yes_no(caller, "Are you sad {options}?", _callable_yes, _callable_no, allow_abort=True)
- evennia.commands.default.comms.class_from_module(path, defaultpaths=None, fallback=None)[source]¶
Return a class from a module, given the class’ full python path. This is primarily used to convert db_typeclass_path:s to classes.
- Parameters:
path (str) – Full Python dot-path to module.
defaultpaths (iterable, optional) – If a direct import from path fails, try subsequent imports by prepending those paths to path.
fallback (str) – If all other attempts fail, use this path as a fallback. This is intended as a last-resort. In the example of Evennia loading, this would be a path to a default parent class in the evennia repo itself.
- Returns:
class (Class) – An uninstantiated class recovered from path.
- Raises:
ImportError – If all loading failed.
- evennia.commands.default.comms.strip_unsafe_input(txt, session=None, bypass_perms=None)[source]¶
Remove ‘unsafe’ text codes from text; these are used to elimitate exploits in user-provided data, such as html-tags, line breaks etc.
- Parameters:
txt (str) – The text to clean.
session (Session, optional) – A Session in order to determine if the check should be bypassed by permission (will be checked with the ‘perm’ lock, taking permission hierarchies into account).
bypass_perms (list, optional) – Iterable of permission strings to check for bypassing the strip. If not given, use settings.INPUT_CLEANUP_BYPASS_PERMISSIONS.
- Returns:
str – The cleaned string.
Notes
The INPUT_CLEANUP_BYPASS_PERMISSIONS list defines what account permissions are required to bypass this strip.
- evennia.commands.default.comms.tail_log_file(filename, offset, nlines, callback=None)[source]¶
Return the tail of the log file.
- Parameters:
filename (str) – The name of the log file, presumed to be in the Evennia log dir.
offset (int) – The line offset from the end of the file to start reading from. 0 means to start at the latest entry.
nlines (int) – How many lines to return, counting backwards from the offset. If file is shorter, will get all lines.
callback (callable, optional) – A function to manage the result of the asynchronous file access. This will get a list of lines. If unset, the tail will happen synchronously.
- Returns:
lines (deferred or list) –
- This will be a deferred if callable is given,
otherwise it will be a list with The nline entries from the end of the file, or all if the file is shorter than nlines.