matrx.messages.message.Message¶
-
class
Message
(content, from_id, to_id=None)¶ A simple object representing a communication message. An agent can create such a Message object by stating the content, its own id as the sender and (optional) a receiver. If a receiver is not given it is a message to all agents, including the sender. NOTE: this Message class is also used by the MATRX api
Possible formats for mssg.to_id “agent1” = individual message to agent1 + message to team “agent1” if it exists [“agent1”, “agent2”] = 2 individual messages + 2 team messages if likewise named teams exist “team2” = team message. A team message is sent to everyone in that team ‘[“agent3”, “team4”]’ = team + agent message. Provided as a string via the api None = global message. This message is send to everyone
Methods
regen_id
(self)Regenerates the message ID.
to_json
(self)Make this class JSON serializable, such that it can be sent as JSON via the api
Creates a message
- Parameters
- contentanything
Denotes the content of the message, can be anything: a string, dict, custom object, etc. As long as it is JSON serializable.
- from_idstr
The ID who sent this message.
- to_idstr or list (optional, default, None)
The ID to who to sent this message. If None, the message will be sent to all agents excluding the sender.
Methods
regen_id
(self)Regenerates the message ID.
to_json
(self)Make this class JSON serializable, such that it can be sent as JSON via the api
-
__init__
(self, content, from_id, to_id=None)¶ Creates a message
- Parameters
- contentanything
Denotes the content of the message, can be anything: a string, dict, custom object, etc. As long as it is JSON serializable.
- from_idstr
The ID who sent this message.
- to_idstr or list (optional, default, None)
The ID to who to sent this message. If None, the message will be sent to all agents excluding the sender.
Methods
__init__
(self, content, from_id[, to_id])Creates a message
regen_id
(self)Regenerates the message ID.
to_json
(self)Make this class JSON serializable, such that it can be sent as JSON via the api