Developer Interface¶
Main Interface¶
-
class
chump.Application(token)[source]¶ The Pushover application in use.
Parameters: token (string) – The application’s API token. -
limit= None¶ If a message has been sent, an
intof the application’s monthly message limit, otherwiseNone.
-
remaining= None¶ If a message has been sent, an
intof the application’s remaining message allotment, otherwiseNone.
-
reset= None¶ If a message has been sent,
datetimeof when the application’s monthly message limit will reset, otherwiseNone.
-
get_user(token)[source]¶ Returns a
Userattached to theApplicationinstance.Parameters: token (string) – User API token. Return type: A User.
-
-
class
chump.User(app, token)[source]¶ A Pushover user. The user is tied to a specific
Application, which can be changed later by settingapp.Parameters: - app (
Application) – The Pushover application to send messages with. - token (string) – The user’s API token.
-
app= None¶ The Pushover application to send messages with.
-
create_message(message, html=False, title=None, timestamp=None, url=None, url_title=None, device=None, priority=0, callback=None, retry=30, expire=86400, sound=None)[source]¶ Creates a message to the User with
app.Parameters: - message (string) – Body for the message.
- html (bool) – Whether the message should be formatted as HTML.
Defaults to
False. - title (string) – (optional) Title for the message. Defaults
to
None. - timestamp (
datetimeorint) – (optional) Date and time to give the message. Defaults to the time the message was created. - url (string) – (optional) URL to include in the message. Defaults
to
None. - device (string) – (optional) device from
devicesto send to. Defaults to all of the user’s devices. - priority (int) – (optional) priority for the message. The
constants
LOWEST,LOW,NORMAL,HIGH, andEMERGENCYmay be used for convenience. Defaults toNORMAL. - callback (string) – (optional) If priority is
EMERGENCY, the URL to ping when the message is acknowledged. Defaults toNone. - retry (int) – (optional) If priority is
EMERGENCY, the number of seconds to wait between re-alerting the user. Must be greater than 30. Defaults to 30. - expire (int) – (optional) If priority is
EMERGENCY, the number of seconds to retry before giving up on alerting the user. Must be less than 86400. Defaults to 86400. - sound (string) – (optional) The sound from
app.soundsto play when the message is received. Defaults to the user’s default sound.
Returns: An unsent message.
Return type: A
MessageorEmergencyMessage.
-
send_message(message, html=False, title=None, timestamp=None, url=None, url_title=None, device=None, priority=0, callback=None, retry=30, expire=86400, sound=None)[source]¶ Does the same as
create_message(), but then sends the message withapp.Returns: A sent message. Return type: A MessageorEmergencyMessage.
- app (
Lower-Level Classes¶
-
class
chump.Message(user, message, html=False, title=None, timestamp=None, url=None, url_title=None, device=None, priority=0, sound=None)[source]¶ A Pushover message. The message is tied to a specific
Application, andUser. All parameters are exposed as attributes on the message, for convenience.Parameters: user ( User) – The user to send the message to.All other arguments are the same as in
User.create_message().
-
class
chump.EmergencyMessage(user, message, html=False, title=None, timestamp=None, url=None, url_title=None, device=None, sound=None, callback=None, retry=30, expire=86400)[source]¶ Bases:
chump.MessageAn emergency Pushover message, (that is, a message with the priority of
EMERGENCY).All arguments are the same as in
Message, with the additions ofcallback,retry, andtimeout, which are all, too, as defined inUser.create_message().-
acknowledged_by= None¶ A
Userof the first user to have acknowledged the notification, otherwiseNone.
-
send()[source]¶ Sends the message. If called after the message has been sent, resends it.
Returns: A boolindicating if the message was successfully sent.Return type: A bool.
-
Exceptions¶
Constants¶
-
chump.LOWEST= -2¶ Message priority: No sound, no vibration, no banner.
-
chump.LOW= -1¶ Message priority: No sound, no vibration, banner.
-
chump.NORMAL= 0¶ Message priority: Sound, vibration, and banner if outside of user’s quiet hours.
-
chump.HIGH= 1¶ Message priority: Sound, vibration, and banner regardless of user’s quiet hours.
-
chump.EMERGENCY= 2¶ Message priority: Sound, vibration, and banner regardless of user’s quiet hours, and re-alerts until acknowledged.