evennia.comms.managers

These managers define helper methods for accessing the database from Comm system components.

exception evennia.comms.managers.CommError[source]

Bases: Exception

Raised by comm system, to allow feedback to player when caught.

evennia.comms.managers.identify_object(inp)[source]

Helper function. Identifies if an object is an account or an object; return its database model

Parameters

inp (any) – Entity to be idtified.

Returns

identified (tuple)

This is a tuple with (inp, identifier)

where identifier is one of “account”, “object”, “channel”, “string”, “dbref” or None.

evennia.comms.managers.to_object(inp, objtype='account')[source]

Locates the object related to the given accountname or channel key. If input was already the correct object, return it.

Parameters
  • inp (any) – The input object/string

  • objtype (str) – Either ‘account’ or ‘channel’.

Returns

obj (object) – The correct object related to inp.

class evennia.comms.managers.MsgManager(*args, **kwargs)[source]

Bases: evennia.typeclasses.managers.TypedObjectManager

This MsgManager implements methods for searching and manipulating Messages directly from the database.

These methods will all return database objects (or QuerySets) directly.

A Message represents one unit of communication, be it over a Channel or via some form of in-game mail system. Like an e-mail, it always has a sender and can have any number of receivers (some of which may be Channels).

identify_object(inp)[source]

Wrapper to identify_object if accessing via the manager directly.

Parameters

inp (any) – Entity to be idtified.

Returns

identified (tuple)

This is a tuple with (inp, identifier)

where identifier is one of “account”, “object”, “channel”, “string”, “dbref” or None.

get_message_by_id(idnum)[source]

Retrieve message by its id.

Parameters

idnum (int or str) – The dbref to retrieve.

Returns

message (Msg) – The message.

get_messages_by_sender(sender)[source]

Get all messages sent by one entity - this could be either a account or an object

Parameters

sender (Account or Object) – The sender of the message.

Returns

QuerySet – Matching messages.

Raises

CommError – For incorrect sender types.

get_messages_by_receiver(recipient)[source]

Get all messages sent to one given recipient.

Parameters

recipient (Object, Account or Channel) – The recipient of the messages to search for.

Returns

Queryset – Matching messages.

Raises

CommError – If the recipient is not of a valid type.

search_message(sender=None, receiver=None, freetext=None, dbref=None)[source]

Search the message database for particular messages. At least one of the arguments must be given to do a search.

Parameters
  • sender (Object, Account or Script, optional) – Get messages sent by a particular sender.

  • receiver (Object, Account or Channel, optional) – Get messages received by a certain account,object or channel

  • freetext (str) – Search for a text string in a message. NOTE: This can potentially be slow, so make sure to supply one of the other arguments to limit the search.

  • dbref (int) – The exact database id of the message. This will override all other search criteria since it’s unique and always gives only one match.

Returns

Queryset – Message matches.

Search the message database for particular messages. At least one of the arguments must be given to do a search.

Parameters
  • sender (Object, Account or Script, optional) – Get messages sent by a particular sender.

  • receiver (Object, Account or Channel, optional) – Get messages received by a certain account,object or channel

  • freetext (str) – Search for a text string in a message. NOTE: This can potentially be slow, so make sure to supply one of the other arguments to limit the search.

  • dbref (int) – The exact database id of the message. This will override all other search criteria since it’s unique and always gives only one match.

Returns

Queryset – Message matches.

class evennia.comms.managers.ChannelDBManager(*args, **kwargs)[source]

Bases: evennia.typeclasses.managers.TypedObjectManager

This ChannelManager implements methods for searching and manipulating Channels directly from the database.

These methods will all return database objects (or QuerySets) directly.

A Channel is an in-game venue for communication. It’s essentially representation of a re-sender: Users sends Messages to the Channel, and the Channel re-sends those messages to all users subscribed to the Channel.

get_all_channels()[source]

Get all channels.

Returns

channels (list) – All channels in game.

get_channel(channelkey)[source]

Return the channel object if given its key. Also searches its aliases.

Parameters

channelkey (str) – Channel key to search for.

Returns

channel (Channel or None) – A channel match.

get_subscriptions(subscriber)[source]

Return all channels a given entity is subscribed to.

Parameters

subscriber (Object or Account) – The one subscribing.

Returns

subscriptions (list) – Channel subscribed to.

search_channel(ostring, exact=True)[source]

Search the channel database for a particular channel.

Parameters
  • ostring (str) – The key or database id of the channel.

  • exact (bool, optional) – Require an exact (but not case sensitive) match.

Search the channel database for a particular channel.

Parameters
  • ostring (str) – The key or database id of the channel.

  • exact (bool, optional) – Require an exact (but not case sensitive) match.

class evennia.comms.managers.ChannelManager(*args, **kwargs)[source]

Bases: evennia.comms.managers.ChannelDBManager, evennia.typeclasses.managers.TypeclassManager

Wrapper to group the typeclass manager to a consistent name.