mirror of https://github.com/caronc/apprise
discord:// now supports the kwarg of 'botname' (#1261)
parent
11f38999f2
commit
0a9f3382a6
|
@ -596,13 +596,19 @@ class NotifyDiscord(NotifyBase):
|
||||||
if self.thread_id:
|
if self.thread_id:
|
||||||
params['thread'] = self.thread_id
|
params['thread'] = self.thread_id
|
||||||
|
|
||||||
|
# Ensure our botname is set
|
||||||
|
botname = f'{self.user}@' if self.user else ''
|
||||||
|
|
||||||
# Extend our parameters
|
# Extend our parameters
|
||||||
params.update(self.url_parameters(privacy=privacy, *args, **kwargs))
|
params.update(self.url_parameters(privacy=privacy, *args, **kwargs))
|
||||||
|
|
||||||
return '{schema}://{webhook_id}/{webhook_token}/?{params}'.format(
|
return '{schema}://{botname}{webhook_id}/{webhook_token}/?{params}' \
|
||||||
|
.format(
|
||||||
schema=self.secure_protocol,
|
schema=self.secure_protocol,
|
||||||
|
botname=botname,
|
||||||
webhook_id=self.pprint(self.webhook_id, privacy, safe=''),
|
webhook_id=self.pprint(self.webhook_id, privacy, safe=''),
|
||||||
webhook_token=self.pprint(self.webhook_token, privacy, safe=''),
|
webhook_token=self.pprint(
|
||||||
|
self.webhook_token, privacy, safe=''),
|
||||||
params=NotifyDiscord.urlencode(params),
|
params=NotifyDiscord.urlencode(params),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -668,6 +674,11 @@ class NotifyDiscord(NotifyBase):
|
||||||
results['include_image'] = parse_bool(results['qsd'].get(
|
results['include_image'] = parse_bool(results['qsd'].get(
|
||||||
'image', NotifyDiscord.template_args['image']['default']))
|
'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
|
# Extract avatar url if it was specified
|
||||||
if 'avatar_url' in results['qsd']:
|
if 'avatar_url' in results['qsd']:
|
||||||
results['avatar_url'] = \
|
results['avatar_url'] = \
|
||||||
|
|
|
@ -89,10 +89,11 @@ apprise_url_tests = (
|
||||||
'instance': NotifyDiscord,
|
'instance': NotifyDiscord,
|
||||||
'requests_response_code': requests.codes.no_content,
|
'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), {
|
'i' * 24, 't' * 64), {
|
||||||
'instance': NotifyDiscord,
|
'instance': NotifyDiscord,
|
||||||
'requests_response_code': requests.codes.no_content,
|
'requests_response_code': requests.codes.no_content,
|
||||||
|
'privacy_url': 'discord://jack@i...i/t...t/',
|
||||||
}),
|
}),
|
||||||
('https://discord.com/api/webhooks/{}/{}'.format(
|
('https://discord.com/api/webhooks/{}/{}'.format(
|
||||||
'0' * 10, 'B' * 40), {
|
'0' * 10, 'B' * 40), {
|
||||||
|
@ -113,6 +114,14 @@ apprise_url_tests = (
|
||||||
# Native URL Support with arguments
|
# Native URL Support with arguments
|
||||||
'instance': NotifyDiscord,
|
'instance': NotifyDiscord,
|
||||||
'requests_response_code': requests.codes.no_content,
|
'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' % (
|
('discord://%s/%s?format=markdown&avatar=No&footer=No' % (
|
||||||
'i' * 24, 't' * 64), {
|
'i' * 24, 't' * 64), {
|
||||||
|
|
Loading…
Reference in New Issue