mirror of
https://github.com/caronc/apprise.git
synced 2024-12-29 10:09:10 +01:00
Discord bugfix to better handle provided markdown (#718)
This commit is contained in:
parent
b3cca772f6
commit
17202e2fa3
@ -580,7 +580,7 @@ class NotifyDiscord(NotifyBase):
|
||||
if description:
|
||||
# Strip description from our string since it has been handled
|
||||
# now.
|
||||
markdown = re.sub(description, '', markdown, count=1)
|
||||
markdown = re.sub(re.escape(description), '', markdown, count=1)
|
||||
|
||||
regex = re.compile(
|
||||
r'\s*#[# \t\v]*(?P<name>[^\n]+)(\n|\s*$)'
|
||||
|
@ -362,6 +362,43 @@ def test_plugin_discord_general(mock_post):
|
||||
body='body', title='title', notify_type=NotifyType.INFO) is True
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_discord_markdown_extra(mock_post):
|
||||
"""
|
||||
NotifyDiscord() Markdown Extra Checks
|
||||
|
||||
"""
|
||||
|
||||
# Initialize some generic (but valid) tokens
|
||||
webhook_id = 'A' * 24
|
||||
webhook_token = 'B' * 64
|
||||
|
||||
# Prepare Mock
|
||||
mock_post.return_value = requests.Request()
|
||||
mock_post.return_value.status_code = requests.codes.ok
|
||||
|
||||
# Reset our apprise object
|
||||
a = Apprise()
|
||||
|
||||
# We want to further test our markdown support to accomodate bug rased on
|
||||
# 2022.10.25; see https://github.com/caronc/apprise/issues/717
|
||||
assert a.add(
|
||||
'discord://{webhook_id}/{webhook_token}/'
|
||||
'?format=markdown&footer=Yes'.format(
|
||||
webhook_id=webhook_id,
|
||||
webhook_token=webhook_token)) is True
|
||||
|
||||
test_markdown = "[green-blue](https://google.com)"
|
||||
|
||||
# This call includes an image with it's payload:
|
||||
assert a.notify(body=test_markdown, title='title',
|
||||
notify_type=NotifyType.INFO,
|
||||
body_format=NotifyFormat.TEXT) is True
|
||||
|
||||
assert a.notify(
|
||||
body='body', title='title', notify_type=NotifyType.INFO) is True
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_discord_attachments(mock_post):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user