mirror of
https://github.com/caronc/apprise.git
synced 2025-02-02 03:19:18 +01:00
discord:// now supports the kwarg of 'botname' (#1261)
This commit is contained in:
parent
11f38999f2
commit
0a9f3382a6
@ -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'] = \
|
||||
|
@ -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), {
|
||||
|
Loading…
Reference in New Issue
Block a user