Message Stanza¶
-
class
slixmpp.stanza.
Message
(*args, **kwargs)[source]¶ XMPP’s <message> stanzas are a “push” mechanism to send information to other XMPP entities without requiring a response.
Chat clients will typically use <message> stanzas that have a type of either “chat” or “groupchat”.
When handling a message event, be sure to check if the message is an error response.
Example <message> stanzas:
<message to="user1@example.com" from="user2@example.com"> <body>Hi!</body> </message> <message type="groupchat" to="room@conference.example.com"> <body>Hi everyone!</body> </message>
- Stanza Interface:
- body: The main contents of the message.
- subject: An optional description of the message’s contents.
- mucroom: (Read-only) The name of the MUC room that sent the message.
- mucnick: (Read-only) The MUC nickname of message’s sender.
- Attributes:
- types: May be one of: normal, chat, headline, groupchat, or error.
-
get_mucnick
()[source]¶ Return the nickname of the MUC user that sent the message.
Read-only stanza interface.
Return type: str
-
get_mucroom
()[source]¶ Return the name of the MUC room where the message originated.
Read-only stanza interface.
Return type: str
-
get_type
()[source]¶ Return the message type.
Overrides default stanza interface behavior.
Returns ‘normal’ if no type attribute is present.
Return type: str
-
reply
(body=None, clear=True)[source]¶ Create a message reply.
Overrides StanzaBase.reply.
Sets proper ‘to’ attribute if the message is from a MUC, and adds a message body if one is given.
Parameters: - body (str) – Optional text content for the message.
- clear (bool) – Indicates if existing content should be removed before replying. Defaults to True.
Return type: