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.

Returns

A status code as per send_message.

Raises

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_show argument.

  • 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.

Returns

At minimum, a boolean is_available representing whether the requested JID is available is returned.

If get_show is specified, a tuple (is_available, show) will be given.

If a list of JIDs is given, a list of tuples will be returned, including is_available, show, and an additional boolean indicating if that JID was valid.

Raises
  • InvalidJidError -- If the specified jid is 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.

Raises
  • InvalidJidError -- If the specified jid is 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 type attribute. For convenience, all of the valid types are in the MESSAGE_TYPE_* constants in this file. The default is MESSAGE_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.

Returns

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
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 is PRESENCE_TYPE_AVAILABLE. Anything else will throw an exception.

  • presence_show -- Optional show value 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 a show element. For convenience, all of the valid types are in the PRESENCE_SHOW_* constants in this file. The default type is PRESENCE_SHOW_NONE. Anything else will throw an exception.

Raises

Send feedback about...

App Engine standard environment for Python