|
| 1 | +Multi-Channel Webhook Notifications |
| 2 | +=================================== |
| 3 | + |
| 4 | +The built-in ``notify`` is desktop-toast only, and ChatOps shipped Slack as the |
| 5 | +only transport — but unattended runs want to alert Microsoft Teams, Discord, or a |
| 6 | +generic incoming webhook too. Each is a simple JSON POST with a transport-shaped |
| 7 | +payload (Slack and a Teams MessageCard use ``text``, Discord uses ``content``); |
| 8 | +``notify_webhook`` builds the right body and POSTs it through the egress-guarded |
| 9 | +HTTP client. |
| 10 | + |
| 11 | +The transport is injectable (a ``poster`` callable or a module-level default), |
| 12 | +so sending is unit-testable with no network. Pure standard library; imports no |
| 13 | +``PySide6``. |
| 14 | + |
| 15 | +Headless API |
| 16 | +------------ |
| 17 | + |
| 18 | +.. code-block:: python |
| 19 | +
|
| 20 | + from je_auto_control import notify_webhook, WebhookChannel |
| 21 | +
|
| 22 | + notify_webhook("https://hooks.slack.com/...", "Run finished", transport="slack") |
| 23 | + notify_webhook("https://discord.com/api/webhooks/...", "Build broke", |
| 24 | + transport="discord", title="CI") |
| 25 | + notify_webhook("https://prod.webhook.office.com/...", "Deploy done", |
| 26 | + transport="teams", title="Release") |
| 27 | +
|
| 28 | + chan = WebhookChannel("https://hooks.example.com/x", transport="raw") |
| 29 | + result = chan.send("hello") # -> WebhookResult(ok, status, transport) |
| 30 | +
|
| 31 | +``transport`` is ``slack`` / ``discord`` / ``teams`` / ``raw``; the result's |
| 32 | +``ok`` reflects a 2xx status. Pass a ``poster(url, payload) -> status`` to |
| 33 | +``WebhookChannel`` / ``notify_webhook`` (or install one with |
| 34 | +``set_default_poster``) to route through a custom transport or a test fake. |
| 35 | + |
| 36 | +Executor command |
| 37 | +---------------- |
| 38 | + |
| 39 | +``AC_notify_webhook`` takes ``url``, ``text`` (+ optional ``transport`` / |
| 40 | +``title``) and returns ``{ok, status, transport}``. The same operation is exposed |
| 41 | +as the MCP tool ``ac_notify_webhook`` and as a Script Builder command under |
| 42 | +**Tools**. |
0 commit comments