Add Msg.db_receiver_external field. Resolve #2193.

This commit is contained in:
Griatch 2021-05-15 09:12:42 +02:00
parent cbfb1276bf
commit 954213e16f
4 changed files with 35 additions and 23 deletions

View file

@ -1,4 +1,4 @@
# Msg
# Msg
The [Msg](api:evennia.comms.models.Msg) object represents a database-saved
piece of communication. Think of it as a discrete piece of email - it contains
@ -29,10 +29,10 @@ good uses for `Msg` objects:
Channels dropped Msg-support. Now only used in `page` command by default.
```
## Msg in code
## Msg in code
The Msg is intended to be used exclusively in code, to build other game systems. It is _not_
a [Typeclassed](./Typeclasses) entity, which means it cannot (easily) be overridden. It
a [Typeclassed](./Typeclasses) entity, which means it cannot (easily) be overridden. It
doesn't support Attributes (but it _does_ support [Tags](./Tags)). It tries to be lean
and small since a new one is created for every message.
@ -40,7 +40,7 @@ You create a new message with `evennia.create_message`:
```python
from evennia import create_message
message = create_message(senders, message, receivers,
message = create_message(senders, message, receivers,
locks=..., tags=..., header=...)
```
@ -61,22 +61,26 @@ You can search for `Msg` objects in various ways:
### Properties on Msg
- `senders` - there must always be at least one sender. This is one of [Account](./Accounts), [Object](./Objects), [Script](./Scripts)
or _external_ - which is a string uniquely identifying the sender. The latter can be used by
a sender-system that doesn't fit into Evennia's normal typeclass-system.
While most systems expect a single sender, it's possible to have any number of them.
- `receivers` - these are the ones to see the Msg. These are again one of
[Account](./Accounts), [Object](./Objects) or [Script](./Scripts). It's in principle possible to have
zero receivers but most usages of Msg expects one or more.
- `header` - this is an optional text field that can contain meta-information about the message. For
an email-like system it would be the subject line. This can be independently searched, making
- `senders` - there must always be at least one sender. This is a set of
- [Account](./Accounts), [Object](./Objects), [Script](./Scripts)
or `str` in any combination (but usually a message only targets one type).
Using a `str` for a sender indicates it's an 'external' sender and
and can be used to point to a sender that is not a typeclassed entity. This is not used by default
and what this would be depends on the system (it could be a unique id or a
python-path, for example). While most systems expect a single sender, it's
possible to have any number of them.
- `receivers` - these are the ones to see the Msg. These are again any combination of
[Account](./Accounts), [Object](./Objects) or [Script](./Scripts) or `str` (an 'external' receiver).
It's in principle possible to have zero receivers but most usages of Msg expects one or more.
- `header` - this is an optional text field that can contain meta-information about the message. For
an email-like system it would be the subject line. This can be independently searched, making
this a powerful place for quickly finding messages.
- `message` - the actual text being sent.
- `date_sent` - this is auto-set to the time the Msg was created (and thus presumably sent).
- `locks` - the Evennia [lock handler](./Locks). Use with `locks.add()` etc and check locks with `msg.access()`
like for all other lockable entities. This can be used to limit access to the contents
of the Msg. The default lock-type to check is `'read'`.
- `hide_from` - this is an optional list of [Accounts](./Accounts) or [Objects](./Objects) that
- `hide_from` - this is an optional list of [Accounts](./Accounts) or [Objects](./Objects) that
will not see this Msg. This relationship is available mainly for optimization
reasons since it allows quick filtering of messages not intended for a given
target.