SlackWebhookClient#
- class safir.slack.webhook.SlackWebhookClient(hook_url, application, logger)#
Bases:
object
Send messages to a Slack webhook.
Provides a simple Slack client to publish structured messages to a Slack channel via an incoming webhook using the Block Kit API. This is a write-only client and cannot be used for prompting or more complex apps.
- Parameters:
hook_url (
str
) – URL of the Slack incoming webhook to use for publishing messages.application (
str
) – Name of the application reporting an error, used by the error reporting methods.logger (
BoundLogger
) – Logger to which to report errors sending messages to Slack.
Methods Summary
post
(message)Post a message to Slack.
post_exception
(exc)Post an alert to Slack about an exception.
Post an alert to Slack about an uncaught webapp exception.
Methods Documentation
- async post(message)#
Post a message to Slack.
Any exceptions encountered while posting the message will be logged but not raised. From the perspective of the caller, the message will silently disappear.
- Parameters:
message (
SlackMessage
) – Message to post.- Return type:
- async post_exception(exc)#
Post an alert to Slack about an exception.
This method intentionally does not provide a way to include the traceback, since it’s hard to ensure that the traceback is entirely free of secrets or other information that should not be disclosed on Slack. Only the exception message is reported.
- Parameters:
exc (
SlackException
) – The exception to report.- Return type: