Last active
March 15, 2021 13:23
-
-
Save caronc/eb3f62e7882551c0da0da3897844a006 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Send 'HTML' content to Slack via Apprise. | |
# At this time (Mar 12th, 2021), Apprise can not convert HTML -> Markdown | |
# but luckily there are lots of tools that can do this for you: | |
# here is one; Requirement: | |
# > pip install html2markdown | |
import html2markdown | |
import apprise | |
# convert your HTML code to it's markdown equivalent: | |
md_body = html2markdown.convert('<h2>Test Header</h2>\r\n<p>Message Body</p>') | |
# Create an Apprise instance | |
apobj = apprise.Apprise() | |
# Add at least one service you want to notify | |
apobj.add('slack://auth-details?format=markdown') | |
# Send your message | |
apobj.notify( | |
title='Title', | |
body=md_body, | |
body_format='markdown', | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment