Message Stanza

1.4 Documentation

«  Root Stanza   ::   Contents   ::   Presence Stanza  »

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.
chat()[source]

Set the message type to ‘chat’.

del_mucnick()[source]

Dummy method to prevent deletion.

del_mucroom()[source]

Dummy method to prevent deletion.

del_parent_thread()[source]

Delete the message thread’s parent reference.

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_parent_thread()[source]

Return the message thread’s parent thread.

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
normal()[source]

Set the message type to ‘normal’.

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:

Message

set_mucnick(value)[source]

Dummy method to prevent modification.

set_mucroom(value)[source]

Dummy method to prevent modification.

set_parent_thread(value)[source]

Add or change the message thread’s parent thread.

Parameters:value (str) – identifier of the thread

«  Root Stanza   ::   Contents   ::   Presence Stanza  »

From &yet