discord:// now supports the kwarg of 'botname' (#1261)

This commit is contained in:
Chris Caron 2024-12-19 21:19:53 -05:00 committed by GitHub
parent 11f38999f2
commit 0a9f3382a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 7 deletions

View File

@ -596,15 +596,21 @@ class NotifyDiscord(NotifyBase):
if self.thread_id:
params['thread'] = self.thread_id
# Ensure our botname is set
botname = f'{self.user}@' if self.user else ''
# Extend our parameters
params.update(self.url_parameters(privacy=privacy, *args, **kwargs))
return '{schema}://{webhook_id}/{webhook_token}/?{params}'.format(
schema=self.secure_protocol,
webhook_id=self.pprint(self.webhook_id, privacy, safe=''),
webhook_token=self.pprint(self.webhook_token, privacy, safe=''),
params=NotifyDiscord.urlencode(params),
)
return '{schema}://{botname}{webhook_id}/{webhook_token}/?{params}' \
.format(
schema=self.secure_protocol,
botname=botname,
webhook_id=self.pprint(self.webhook_id, privacy, safe=''),
webhook_token=self.pprint(
self.webhook_token, privacy, safe=''),
params=NotifyDiscord.urlencode(params),
)
@property
def url_identifier(self):
@ -668,6 +674,11 @@ class NotifyDiscord(NotifyBase):
results['include_image'] = parse_bool(results['qsd'].get(
'image', NotifyDiscord.template_args['image']['default']))
if 'botname' in results['qsd']:
# Alias to User
results['user'] = \
NotifyDiscord.unquote(results['qsd']['botname'])
# Extract avatar url if it was specified
if 'avatar_url' in results['qsd']:
results['avatar_url'] = \

View File

@ -89,10 +89,11 @@ apprise_url_tests = (
'instance': NotifyDiscord,
'requests_response_code': requests.codes.no_content,
}),
('discord://%s/%s?format=markdown&footer=Yes&image=Yes' % (
('discord://jack@%s/%s?format=markdown&footer=Yes&image=Yes' % (
'i' * 24, 't' * 64), {
'instance': NotifyDiscord,
'requests_response_code': requests.codes.no_content,
'privacy_url': 'discord://jack@i...i/t...t/',
}),
('https://discord.com/api/webhooks/{}/{}'.format(
'0' * 10, 'B' * 40), {
@ -113,6 +114,14 @@ apprise_url_tests = (
# Native URL Support with arguments
'instance': NotifyDiscord,
'requests_response_code': requests.codes.no_content,
'privacy_url': 'discord://0...0/B...B/',
}),
('https://discordapp.com/api/webhooks/{}/{}?footer=yes&botname=joe'.format(
'0' * 10, 'B' * 40), {
# Native URL Support with arguments
'instance': NotifyDiscord,
'requests_response_code': requests.codes.no_content,
'privacy_url': 'discord://joe@0...0/B...B/',
}),
('discord://%s/%s?format=markdown&avatar=No&footer=No' % (
'i' * 24, 't' * 64), {