evennia.comms.models

Models for the in-game communication system.

The comm system could take the form of channels, but can also be adopted for storing tells or in-game mail.

The comsystem’s main component is the Message (Msg), which carries the actual information between two parties. Msgs are stored in the database and usually not deleted. A Msg always have one sender (a user), but can have any number targets, both users and channels.

For non-persistent (and slightly faster) use one can also use the TempMsg, which mimics the Msg API but without actually saving to the database.

Channels are central objects that act as targets for Msgs. Accounts can connect to channels by use of a ChannelConnect object (this object is necessary to easily be able to delete connections on the fly).

class evennia.comms.models.Msg(*args, **kwargs)[source]

Bases: evennia.utils.idmapper.models.SharedMemoryModel

A 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 senders (defined as string names)

  • db_receivers_accounts: Receiving accounts

  • db_receivers_objects: Receiving objects

  • db_receivers_scripts: Receiveing scripts

  • db_receivers_channels: Receiving channels

  • 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_hide_from_channels: list of channels objects to hide message from

  • db_lock_storage: Internal storage of lock strings.

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_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_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_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_receivers_channels

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_header

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_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_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_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_hide_from_channels

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.

objects = <evennia.comms.managers.MsgManager object>
__init__(*args, **kwargs)[source]

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

locks[source]
tags[source]
property senders

Getter. Allows for value = self.sender

remove_sender(senders)[source]

Remove a single sender or a list of senders.

Parameters

senders (Account, Object, str or list) – Senders to remove.

property receivers

Getter. Allows for value = self.receivers. Returns four lists of receivers: accounts, objects, scripts and channels.

remove_receiver(receivers)[source]

Remove a single receiver or a list of receivers.

Parameters

receivers (Account, Object, Script, Channel or list) – Receiver to remove.

property channels

Getter. Allows for value = self.channels. Returns a list of channels.

property hide_from

Getter. Allows for value = self.hide_from. Returns 3 lists of accounts, objects and channels

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.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

property date_created

A wrapper for getting database field db_date_created.

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.

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.

path = 'evennia.comms.models.Msg'
property sender_external

A wrapper for getting database field db_sender_external.

typename = 'SharedMemoryModelBase'
class evennia.comms.models.TempMsg(senders=None, receivers=None, channels=None, message='', header='', type='', lockstring='', hide_from=None)[source]

Bases: object

This is a non-persistent object for sending temporary messages that will not be stored. It mimics the “real” Msg object, but doesn’t require sender to be given.

__init__(senders=None, receivers=None, channels=None, message='', header='', type='', lockstring='', hide_from=None)[source]

Creates the temp message.

Parameters
  • senders (any or list, optional) – Senders of the message.

  • receivers (Account, Object, Channel or list, optional) – Receivers of this message.

  • channels (Channel or list, optional) – Channels to send to.

  • message (str, optional) – Message to send.

  • header (str, optional) – Header of message.

  • type (str, optional) – Message class, if any.

  • lockstring (str, optional) – Lock for the message.

  • hide_from (Account, Object, Channel or list, optional) – Entities to hide this message from.

locks[source]
remove_sender(sender)[source]

Remove a sender or a list of senders.

Parameters

sender (Object, Account, str or list) – Senders to remove.

remove_receiver(receiver)[source]

Remove a receiver or a list of receivers

Parameters

receiver (Object, Account, Channel, str or list) – Receivers to remove.

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.

class evennia.comms.models.ChannelDB(*args, **kwargs)[source]

Bases: evennia.typeclasses.models.TypedObject

This is the basis of a comm channel, only implementing the very basics of distributing messages.

The Channel class defines the following database fields beyond the ones inherited from TypedObject:

  • db_account_subscriptions: The Account subscriptions.

  • db_object_subscriptions: The Object subscriptions.

db_account_subscriptions

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_object_subscriptions

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.

objects = <evennia.comms.managers.ChannelDBManager object>
subscriptions[source]
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

channel_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.

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_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)
hide_from_channels_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.

path = 'evennia.comms.models.ChannelDB'
typename = 'SharedMemoryModelBase'