Basic functions for sending notifications via HipChat API (v2)
Project description
HipChat Notifications
This is a very simple library for sending user and room notifications to HipChat via their v2 API.
It contains a couple of generic functions for sending messages to rooms and users within HipChat.
>>> hipchat.notify_room('Customer Service', 'This is a message')
>>> hipchat.notify_user('hugo', 'Hello, Hugo')
It includes some colour-specific helpers for room-only notifications:
>>> hipchat.green('Customer service', 'This is a green message')
The functions support the message_format values:
html - Message is rendered as HTML and receives no special treatment. Must be valid HTML and entities must be escaped (e.g.: ‘&’ instead of ‘&’). May contain basic tags: a, b, i, strong, em, br, img, pre, code, lists, tables.
text - Message is treated just like a message sent by a user. Can include @mentions, emoticons, pastes, and auto-detected URLs (Twitter, YouTube, images, etc).
>>> hipchat.green('Customer service', 'Hello @fred', message_format='text')
The color, notify and from parameters are also supported (from is passed as a kwarg called label):
>>> notify_room(
... 'customer service',
... 'Hey there @Tony',
... color='red',
... label='baz',
... notify=True,
... message_format='text'
... )
Settings
The following settings are read from the environment using os.getenv
HIPCHAT_API_TOKEN
A valid API access token. See the API docs for details on how to generate a token. (Hint: the easiest way is to use a “Personal access token” generated through the site.)
If there is no token set in the environment the notifications will be logged using the ‘hipchat’ logger, with a DEBUG level.
Installation
The library is available on PyPI as ‘hipchat_notifications’.
Tests
The tests can be run using tox:
$ tox
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Hashes for hipchat-notifications-0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 122b8d1f9a33803f07c230d17bd1942832e2dd7025d407cd4c0a5611d2026c33 |
|
MD5 | 37076f70dfa6b71bf2bcfd308b665a40 |
|
BLAKE2b-256 | 0a693fc1ac0c89a4a1375fb8a587514baeaa9ef4d7781d280aae9716e34e1201 |
Hashes for hipchat-notifications-0.2.1.macosx-10.12-intel.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49cfabe55fdc365f2d625611bfd7e0d0b80333b85c31a6cede1b5dad5e3e9793 |
|
MD5 | 30cb420a1e0b6e5f76598ec8fd82c669 |
|
BLAKE2b-256 | 98f5d3fd69a3c4c6fed6f8e0ade89f4c679d8d5d7e4b31ad5fcf9c6d310f461b |