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)
parse()[source]

Simple parser

func()[source]

Create a new message and send it to channel, using the already formatted input.

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())

__init__()[source]

Initializes the channel handler’s internal state.

clear()[source]

Reset the cache storage.

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.

get(channelname=None)[source]

Get a channel from the handler, or all channels

Parameters

channelame (str, optional) – Channel key, case insensitive.

Returns
channels (list): The matching channels in a list, or all

channels in the handler.

get_cmdset(source_object)[source]

Retrieve cmdset for channels this source_object has access to send to.

Parameters

source_object (Object) – An object subscribing to one or more channels.

Returns

cmdsets (list)

The Channel-Cmdsets source_object has

access to.