Public Member Functions | |
def | __init__ (self, type, data=None, context=None) |
def | publish (self, type, data, context=None) |
def | reply (self, type, data=None, context=None) |
def | response (self, data=None, context=None) |
def | serialize (self) |
def | utterance_remainder (self) |
Static Public Member Functions | |
def | deserialize (value) |
Public Attributes | |
context | |
data | |
type | |
Holds and manipulates data sent over the websocket Message objects will be used to send information back and forth between processes of Mycroft. Attributes: type (str): type of data sent within the message. data (dict): data sent within the message context: info about the message not part of data such as source, destination or domain.
Definition at line 20 of file message.py.
def mycroft.messagebus.message.Message.__init__ | ( | self, | |
type, | |||
data = None , |
|||
context = None |
|||
) |
Used to construct a message object Message objects will be used to send information back and fourth bettween processes of mycroft service, voice, skill and cli
Definition at line 33 of file message.py.
|
static |
This takes a string and constructs a message object. This makes it easy to take strings from the websocket and create a message object. This uses json loads to get the info and generate the message object. Args: value(str): This is the json string received from the websocket Returns: Message: message object constructed from the json string passed int the function. value(str): This is the string received from the websocket
Definition at line 59 of file message.py.
def mycroft.messagebus.message.Message.publish | ( | self, | |
type, | |||
data, | |||
context = None |
|||
) |
Copy the original context and add passed in context. Delete any target in the new context. Return a new message object with passed in data and new context. Type remains unchanged. Args: type (str): type of message data (dict): date to send with message context: context added to existing context Returns: Message: Message object to publish
Definition at line 127 of file message.py.
def mycroft.messagebus.message.Message.reply | ( | self, | |
type, | |||
data = None , |
|||
context = None |
|||
) |
Construct a reply message for a given message This will take the same parameters as a message object but use the current message object as a reference. It will copy the context from the existing message object and add any context passed in to the function. Check for a target passed in to the function from the data object and add that to the context as a target. If the context has a client name then that will become the target in the context. The new message will then have data passed in plus the new context generated. Args: type (str): type of message data (dict): data for message context: intented context for new message Returns: Message: Message object to be used on the reply to the message
Definition at line 79 of file message.py.
def mycroft.messagebus.message.Message.response | ( | self, | |
data = None , |
|||
context = None |
|||
) |
Construct a response message for the message Constructs a reply with the data and appends the expected ".response" to the message Args: data (dict): message data context (dict): message context Returns (Message) message with the type modified to match default response
Definition at line 111 of file message.py.
def mycroft.messagebus.message.Message.serialize | ( | self | ) |
This returns a string of the message info. This makes it easy to send over a websocket. This uses json dumps to generate the string with type, data and context Returns: str: a json string representation of the message.
Definition at line 43 of file message.py.
def mycroft.messagebus.message.Message.utterance_remainder | ( | self | ) |
For intents get the portion not consumed by Adapt. For example: if they say 'Turn on the family room light' and there are entity matches for "turn on" and "light", then it will leave behind " the family room " which is then normalized to "family room". Returns: str: Leftover words or None if not an utterance.
Definition at line 151 of file message.py.
mycroft.messagebus.message.Message.context |
Definition at line 41 of file message.py.
mycroft.messagebus.message.Message.data |
Definition at line 40 of file message.py.
mycroft.messagebus.message.Message.type |
Definition at line 39 of file message.py.