evennia.comms.channelhandler¶
The channel handler, accessed from this module as CHANNEL_HANDLER is a singleton that handles the stored set of channels and how they are represented against the cmdhandler.
If there is a channel named ‘newbie’, we want to be able to just write
newbie Hello!
For this to work, ‘newbie’, the name of the channel, must be identified by the cmdhandler as a command name. The channelhandler stores all channels as custom ‘commands’ that the cmdhandler can import and look through.
> Warning - channel names take precedence over command names, so make sure to not pick clashing channel names.
Unless deleting a channel you normally don’t need to bother about the channelhandler at all - the create_channel method handles the update.
To delete a channel cleanly, delete the channel object, then call update() on the channelhandler. Or use Channel.objects.delete() which does this for you.
-
class
evennia.comms.channelhandler.
ChannelCommand
(**kwargs)[source]¶ Bases:
evennia.commands.default.muxcommand.MuxCommand
{channelkey} channel
{channeldesc}
- Usage:
{lower_channelkey} <message> {lower_channelkey}/history [start] {lower_channelkey} off - mutes the channel {lower_channelkey} on - unmutes the channel
- Switch:
- history: View 20 previous messages, either from the end or
from <start> number of messages from the end.
Example
{lower_channelkey} Hello World! {lower_channelkey}/history {lower_channelkey}/history 30
-
is_channel
= True¶
-
key
= 'general'¶
-
help_category
= 'channel names'¶
-
obj
= None¶
-
arg_regex
= re.compile('\\s.*?|/history.*?', re.IGNORECASE)¶
-
get_extra_info
(caller, **kwargs)[source]¶ Let users know that this command is for communicating on a channel.
- Parameters
caller (TypedObject) – A Character or Account who has entered an ambiguous command.
- Returns
A string with identifying information to disambiguate the object, conventionally with a preceding space.
-
aliases
= []¶
-
lock_storage
= 'cmd:all();'¶
-
class
evennia.comms.channelhandler.
ChannelHandler
[source]¶ Bases:
object
The ChannelHandler manages all active in-game channels and dynamically creates channel commands for users so that they can just give the channel’s key or alias to write to it. Whenever a new channel is created in the database, the update() method on this handler must be called to sync it with the database (this is done automatically if creating the channel with evennia.create_channel())
-
add
(channel)[source]¶ Add an individual channel to the handler. This is called whenever a new channel is created.
- Parameters
channel (Channel) – The channel to add.
Notes
To remove a channel, simply delete the channel object and run self.update on the handler. This should usually be handled automatically by one of the deletion methos of the Channel itself.
-
add_channel
(channel)¶ Add an individual channel to the handler. This is called whenever a new channel is created.
- Parameters
channel (Channel) – The channel to add.
Notes
To remove a channel, simply delete the channel object and run self.update on the handler. This should usually be handled automatically by one of the deletion methos of the Channel itself.
-
remove
(channel)[source]¶ Remove channel from channelhandler. This will also delete it.
- Parameters
channel (Channel) – Channel to remove/delete.
-
update
()[source]¶ Updates the handler completely, including removing old removed Channel objects. This must be called after deleting a Channel.
-