mirror of
https://github.com/caronc/apprise.git
synced 2024-11-21 23:53:23 +01:00
Discord now supports href= (and alias url=) arguments (#927)
This commit is contained in:
parent
207db69e1a
commit
44576a5ced
@ -152,6 +152,13 @@ class NotifyDiscord(NotifyBase):
|
||||
'name': _('Avatar URL'),
|
||||
'type': 'string',
|
||||
},
|
||||
'href': {
|
||||
'name': _('URL'),
|
||||
'type': 'string',
|
||||
},
|
||||
'url': {
|
||||
'alias_of': 'href',
|
||||
},
|
||||
# Send a message to the specified thread within a webhook's channel.
|
||||
# The thread will automatically be unarchived.
|
||||
'thread': {
|
||||
@ -183,7 +190,8 @@ class NotifyDiscord(NotifyBase):
|
||||
|
||||
def __init__(self, webhook_id, webhook_token, tts=False, avatar=True,
|
||||
footer=False, footer_logo=True, include_image=False,
|
||||
fields=True, avatar_url=None, thread=None, **kwargs):
|
||||
fields=True, avatar_url=None, href=None, thread=None,
|
||||
**kwargs):
|
||||
"""
|
||||
Initialize Discord Object
|
||||
|
||||
@ -232,6 +240,9 @@ class NotifyDiscord(NotifyBase):
|
||||
# dynamically generated avatar url images
|
||||
self.avatar_url = avatar_url
|
||||
|
||||
# A URL to have the title link to
|
||||
self.href = href
|
||||
|
||||
# For Tracking Purposes
|
||||
self.ratelimit_reset = datetime.now(timezone.utc).replace(tzinfo=None)
|
||||
|
||||
@ -287,6 +298,9 @@ class NotifyDiscord(NotifyBase):
|
||||
'color': self.color(notify_type, int),
|
||||
}]
|
||||
|
||||
if self.href:
|
||||
payload['embeds'][0]['url'] = self.href
|
||||
|
||||
if self.footer:
|
||||
# Acquire logo URL
|
||||
logo_url = self.image_url(notify_type, logo=True)
|
||||
@ -540,6 +554,9 @@ class NotifyDiscord(NotifyBase):
|
||||
if self.avatar_url:
|
||||
params['avatar_url'] = self.avatar_url
|
||||
|
||||
if self.href:
|
||||
params['href'] = self.href
|
||||
|
||||
if self.thread_id:
|
||||
params['thread'] = self.thread_id
|
||||
|
||||
@ -611,10 +628,23 @@ class NotifyDiscord(NotifyBase):
|
||||
results['avatar_url'] = \
|
||||
NotifyDiscord.unquote(results['qsd']['avatar_url'])
|
||||
|
||||
# Extract url if it was specified
|
||||
if 'href' in results['qsd']:
|
||||
results['href'] = \
|
||||
NotifyDiscord.unquote(results['qsd']['href'])
|
||||
|
||||
elif 'url' in results['qsd']:
|
||||
results['href'] = \
|
||||
NotifyDiscord.unquote(results['qsd']['url'])
|
||||
# Markdown is implied
|
||||
results['format'] = NotifyFormat.MARKDOWN
|
||||
|
||||
# Extract thread id if it was specified
|
||||
if 'thread' in results['qsd']:
|
||||
results['thread'] = \
|
||||
NotifyDiscord.unquote(results['qsd']['thread'])
|
||||
# Markdown is implied
|
||||
results['format'] = NotifyFormat.MARKDOWN
|
||||
|
||||
return results
|
||||
|
||||
|
@ -132,6 +132,18 @@ apprise_url_tests = (
|
||||
'instance': NotifyDiscord,
|
||||
'requests_response_code': requests.codes.no_content,
|
||||
}),
|
||||
# Test with href (title link)
|
||||
('discord://%s/%s?hmarkdown=true&ref=http://localhost' % (
|
||||
'i' * 24, 't' * 64), {
|
||||
'instance': NotifyDiscord,
|
||||
'requests_response_code': requests.codes.no_content,
|
||||
}),
|
||||
# Test with url (title link) - Alias of href
|
||||
('discord://%s/%s?markdown=true&url=http://localhost' % (
|
||||
'i' * 24, 't' * 64), {
|
||||
'instance': NotifyDiscord,
|
||||
'requests_response_code': requests.codes.no_content,
|
||||
}),
|
||||
# Test with avatar URL
|
||||
('discord://%s/%s?avatar_url=http://localhost/test.jpg' % (
|
||||
'i' * 24, 't' * 64), {
|
||||
|
Loading…
Reference in New Issue
Block a user