Merge branch 'implement_markdown_rendering'
This commit is contained in:
commit
9c072b0e8e
|
|
@ -2,6 +2,7 @@ import asyncio
|
|||
from html import escape
|
||||
import json
|
||||
from typing import Any, Dict, Tuple, List, Awaitable, Callable
|
||||
import markdown
|
||||
|
||||
from aiohttp import ClientTimeout
|
||||
from maubot import MessageEvent, Plugin
|
||||
|
|
@ -639,9 +640,11 @@ class NtfyBot(Plugin):
|
|||
if click and not title:
|
||||
html_content += "%s<a href=\"%s\">%s</a>" % (
|
||||
emoji, escape(click),
|
||||
escape(body).replace("\n", "<br />"))
|
||||
markdown.markdown(escape(body))
|
||||
.replace("\n", "<br />"))
|
||||
else:
|
||||
html_content += emoji + escape(body).replace("\n", "<br />")
|
||||
html_content += (emoji + markdown.markdown(escape(body))
|
||||
.replace("\n", "<br />"))
|
||||
|
||||
# add non-emoji tags
|
||||
if tags:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
class SubscriptionError(Exception):
|
||||
"""Raised when an error occurs while subscribing to a ntfy topic."""
|
||||
|
||||
def __init__(self, http_response: dict) -> None:
|
||||
self._http_message = http_response
|
||||
self.message = self._http_message.get("error")
|
||||
self.code = self._http_message.get("code")
|
||||
super().__init__(self.message)
|
||||
Loading…
Reference in New Issue