tipfy.ext.xmpp¶
This module provides handler classes for XMPP bots, including both basic messaging functionality and a command handler for commands such as “/foo bar”.
See the extension wiki page.
Handler classes¶
- class tipfy.ext.xmpp.BaseHandler(app, request)¶
A webapp baseclass for XMPP handlers.
Implements a straightforward message delivery pattern. When a message is received, message_received() is called with a Message object that encapsulates the relevant details. Users can reply using the standard XMPP API, or the convenient reply() method on the Message object.
- message_received(message)¶
Called when a message is sent to the XMPP bot.
Parameters: - message – The message that was sent by the user.
- class tipfy.ext.xmpp.CommandHandlerMixin¶
A command handler for XMPP bots.
Implements a command handler pattern. XMPP messages are processed by calling message_received. Message objects handled by this class are annotated with command and arg fields.
On receipt of a message starting with a forward or backward slash, the handler calls a method named after the command - e.g., if the user sends /foo bar, the handler will call foo_command(message).
If no handler method matches, unhandled_command() is called. The default behaviour of unhandled_command() is to send the message “Unknown command” back to the sender.
If the user sends a message not prefixed with a slash, text_message(message) is called.
- message_received(message)¶
Called when a message is sent to the XMPP bot.
Parameters: - message – The message that was sent by the user.
- text_message(message)¶
Called when a message not prefixed by a /command is sent to the XMPP bot.
Parameters: - message – The message that was sent by the user.
- unhandled_command(message)¶
Called when an unknown command is sent to the XMPP bot.
Parameters: - message – The message that was sent by the user.
