matrx.messages.message

Module Contents

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

to_json(self)

Make this class JSON serializable, such that it can be sent as JSON via the api

regen_id(self)

Regenerates the message ID. When someone copies this message, by default the message_id is not changed. To avoid duplicate mssg IDs, this message can be called to change the regen the ID of a message.

Examples

>>> print(mssg.message_id) # output: 242523098cb176b4
>>> mssg.regen_id()
>>> print(mssg.message_id) # output: 484de0a68fed7579