The Message class represents an incoming XMPP message.
Message is provided by the
The Message class constructor takes as an argument a dict-like object with data representing an incoming XMPP message. The keys of the dict must be
body. For most web application frameworks, the dict can be an object the framework provides that represents form fields parsed from the HTTP POST request initiated by App Engine.
Here is a simple example using the webapp2 framework:
import webapp2 from google.appengine.api import xmpp class XMPPHandler(webapp2.RequestHandler): def post(self): message = xmpp.Message(self.request.POST) if message.body[0:5].lower() == 'hello': message.reply("Greetings!") app = webapp2.WSGIApplication([('/_ah/xmpp/message/chat/', XMPPHandler)], debug=True)
The constructor of the Message class is defined as follows:
- class Message(vars)
An incoming XMPP message.
A dict-like object containing the message data, such as an object representing the fields of the POST request for an incoming message. The object must have the following members:
from: the XMPP address of the sender
to: the XMPP address of the recipient (an address for the application)
body: the body content of the XMPP message
The Message class provides the following read-only properties:
The XMPP address of the sender of the message.
The XMPP address of the recipient of the message, an address for the application.
The body content of the XMPP message.
google.appengine.ext.webapp.xmpp_handlers: the "command" of the XMPP message.
google.appengine.ext.webapp.xmpp_handlers: the "command" argument.
Message instances have the following method:
- reply(body, message_type=MESSAGE_TYPE_CHAT, raw_xml=False)
Reply to this message. This is similar to calling the send_message() function using the Message's sender as the sole recipient of the reply, and the Message's recipient address as the sender.
- The body content of the message.
True, the body is expected to be valid XML that is included verbatim in the XMPP message stanza. If
False, the body is treated as plain text (XML characters are escaped before being inserted into the XMPP message).
Returns a status value. See send_message() for more information on possible status values.