thp / urlwatch

Watch (parts of) webpages and get notified when something changes via e-mail, on your phone or via other means. Highly configurable.
https://thp.io/2008/urlwatch/
Other
2.82k stars 351 forks source link

SlackReporter with preformatted rich text #776

Closed vimagick closed 10 months ago

vimagick commented 10 months ago
$ urlwatch --test-reporter slack

Slack will receive a message:

===========================================================================
01. NEW: Newly Added
02. CHANGED: Something Changed
03. ERROR: Error Reporting
===========================================================================

---------------------------------------------------------------------------
NEW: Newly Added ( http://example.com/new )
---------------------------------------------------------------------------

---------------------------------------------------------------------------
CHANGED: Something Changed ( http://example.com/changed )
---------------------------------------------------------------------------
--- @   Thu, 16 Nov 2023 13:42:21 +0000
+++ @   Thu, 16 Nov 2023 13:42:21 +0000
@@ -1,5 +1,5 @@

         Unchanged Line
-        Previous Content
+        Updated Content
         Another Unchanged Line

---------------------------------------------------------------------------

---------------------------------------------------------------------------
ERROR: Error Reporting ( http://example.com/error )
---------------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/urlwatch/command.py", line 314, in set_error
    raise ValueError(message)
ValueError: Oh Noes!
---------------------------------------------------------------------------

Slack API Doc: https://api.slack.com/reference/block-kit/blocks#rich_text