google.appengine.api.xmpp package
Summary
XMPP API.
An App Engine application can send and receive chat messages to and from any XMPP-compatible chat messaging service. An app can send and receive chat messages, send chat invites, request a user's chat presence and status, and provide a chat status. Incoming XMPP messages are handled by request handlers, similar to web requests.
Some possible uses of chat messages include automated chat participants ("chat bots"), chat notifications, and chat interfaces to services. A rich client with a connection to an XMPP server can use XMPP to interact with an App Engine application in real time, including receiving messages initiated by the app.
Contents
- exception google.appengine.api.xmpp.Errorsource
-
Bases: exceptions.Exception
Base error class for this module.
- exception google.appengine.api.xmpp.InvalidJidErrorsource
-
Bases: google.appengine.api.xmpp.Error
The JID that was requested is invalid.
- exception google.appengine.api.xmpp.InvalidMessageErrorsource
-
Bases: google.appengine.api.xmpp.Error
The received message was invalid or incomplete.
- exception google.appengine.api.xmpp.InvalidShowErrorsource
-
Bases: google.appengine.api.xmpp.Error
The send presence request contains an invalid show element.
- exception google.appengine.api.xmpp.InvalidStatusErrorsource
-
Bases: google.appengine.api.xmpp.Error
The send presence request contains an invalid status element.
- exception google.appengine.api.xmpp.InvalidTypeErrorsource
-
Bases: google.appengine.api.xmpp.Error
The request type is invalid.
- exception google.appengine.api.xmpp.InvalidXmlErrorsource
-
Bases: google.appengine.api.xmpp.Error
The send message request contains invalid XML.
- class google.appengine.api.xmpp.Message(vars)source
-
Bases: object
Encapsulates an XMPP message that is received by the application.
- arg
-
If your app accepts commands, the arguments specified in the command.
- body
-
The body of a message.
- command
-
If your app accepts commands, the command sent in a message.
- reply(body, message_type='chat', raw_xml=False, send_message=send_message)source
Replies to a message; convenience function.
Parameters-
body -- String; the body of the message.
-
message_type -- As per
send_message. -
raw_xml -- As per
send_message. -
send_message -- Used for testing.
A status code as per
Raisessend_message.See
send_message.-
- sender
-
The sender of a message.
- to
-
The recipient of a message.
- exception google.appengine.api.xmpp.NoBodyErrorsource
-
Bases: google.appengine.api.xmpp.Error
The send message request has no body.
- exception google.appengine.api.xmpp.NondefaultModuleErrorsource
-
Bases: google.appengine.api.xmpp.Error
The XMPP API was used from a non-default module.
- google.appengine.api.xmpp.get_presence(jid, from_jid=None, get_show=False)source
Gets the presence for a Jabber identifier (JID).
Parameters-
jid -- The JID of the contact whose presence is requested. This can also be a list of JIDs, which also implies the
get_showargument. -
from_jid -- The optional custom JID to use. Currently, the default JID is
<appid>@appspot.com. This JID is supported as a value. Custom JIDs can be of the form<anything>@<appid>.appspotchat.com. -
get_show -- If True, this argument returns a tuple of
(is_available, show). If a list of JIDs is given, this argument will always be True.
At minimum, a boolean
is_availablerepresenting whether the requested JID is available is returned.If
get_showis specified, a tuple(is_available, show)will be given.If a list of JIDs is given, a list of tuples will be returned, including
Raisesis_available,show, and an additional boolean indicating if that JID was valid.-
InvalidJidError -- If the specified
jidis invalid. -
Error -- If an unspecified error happens while processing the request.
-
- google.appengine.api.xmpp.send_invite(jid, from_jid=None)source
Sends an invitation to chat to a JID.
Parameters-
jid -- The JID of the contact to invite.
-
from_jid -- The optional custom JID to use. Currently, the default value is
<appid>@appspot.com. This JID is supported as a value. Custom JIDs can be of the form<anything>@<appid>.appspotchat.com.
-
InvalidJidError -- If the specified
jidis invalid. -
Error -- If an unspecified error happens while processing the request.
-
- google.appengine.api.xmpp.send_message(jids, body, from_jid=None, message_type='chat', raw_xml=False)source
Sends a chat message to a list of JIDs.
Parameters-
jids -- At least one JID to send the message to.
-
from_jid -- The optional custom JID to use. Currently, the default value is
<appid>@appspot.com. This JID is supported as a value. Custom JIDs can be of the form<anything>@<appid>.appspotchat.com. -
body -- The body of the message.
-
message_type -- Optional type of the message. Should be one of the types specified in RFC 3921, section 2.1.1. An empty string will result in a message stanza without a
typeattribute. For convenience, all of the valid types are in theMESSAGE_TYPE_*constants in this file. The default isMESSAGE_TYPE_CHAT. Anything else will throw an exception. -
raw_xml -- Optionally specifies that the body should be interpreted as XML. If set to False, the contents of the body will be escaped and placed inside of a body element inside of the message. If set to True, the contents will be made children of the message.
A list of statuses, one for each JID, corresponding to the result of sending the message to that JID. Or, if a single JID was passed in, returns the status directly.
Raises-
InvalidJidError -- If there is no valid JID in the list.
-
InvalidTypeError -- If the
message_typeargument is invalid. -
InvalidXmlError -- If the body is malformed XML and
raw_xmlis set to True. -
NoBodyError -- If the message has no body.
-
Error -- If another error occurs while processing the request.
-
- google.appengine.api.xmpp.send_presence(jid, status=None, from_jid=None, presence_type='', presence_show='')source
Sends a presence to a given JID.
Parameters-
jid -- A JID to send the presence to.
-
status -- The optional status message. Size is limited to 1KB.
-
from_jid -- The optional custom JID to use. Currently, the default value is
<appid>@appspot.com. This JID is supported as a value. Custom JIDs can be of the form<anything>@<appid>.appspotchat.com. -
presence_type -- Optional type of the presence. This accepts a subset of the types specified in RFC 3921, section 2.1.1. An empty string will result in a presence stanza without a type attribute. For convenience, all of the valid types are in the
PRESENCE_TYPE_*constants in this file. The default type isPRESENCE_TYPE_AVAILABLE. Anything else will throw an exception. -
presence_show -- Optional
showvalue for the presence. Should be one of the values specified in RFC 3921, section 2.2.2.1. An empty string will result in a presence stanza without ashowelement. For convenience, all of the valid types are in thePRESENCE_SHOW_*constants in this file. The default type isPRESENCE_SHOW_NONE. Anything else will throw an exception.
-
InvalidJidError -- If the list does not contain a valid JID.
-
InvalidTypeError -- If the
presence_typeargument is invalid. -
InvalidShowError -- If the
presence_showargument is invalid. -
InvalidStatusError -- If the status argument is too large.
-
Error -- If another error occurs while processing the request.
-