A package to facilitate the use of a slack webhook for notifications.
Setup of a webhook in Slack is required. See https://api.slack.com/messaging/webhooks
- requires python >=3.7
pip install https://github.com/huit/pyslack/archive/v1.0.4.tar.gz
from pyslack.notify import NotificationService
ns = NotificationService(webhook="<unique_id_for_slack_webhook>", username="<notification_username>", icon_emoji="<emoji>")
ns.success("SUCCESS TITLE") # only title required for success message
ns.info(title="INFO TITLE", message="informational message")
ns.warning(title="WARNING TITLE", message="warning message")
ns.error(title="ERROR TITLE", message="error message", link="https://www.example.com", link_title="Example.com")
- <unique_id_for_slack_webhook> must be supplied by slack, and will be appended to "https://hooks.slack.com/services/"
- <notification_username> can be any string, not necessarily an existing slack user
- must be a valid slack emoji name - do not include any ':' as it will automatically be wrapped "::" NOTE: 'icon_emoji' has been deprecated; in the shift to new slack applications it is configured in the app
- title -> REQUIRED
- message -> REQUIRED ( defaults to 'Success!' for .success() )
- link -> OPTIONAL ( must be a fully formed URL, e.g., https://www.example.com )
- link_title -> OPTIONAL ( if link parameter is supplied but not link_title, link_title defaults to 'link' )