diff --git a/apprise/plugins/discord.py b/apprise/plugins/discord.py index d2eb7541d..d7a9beefd 100644 --- a/apprise/plugins/discord.py +++ b/apprise/plugins/discord.py @@ -596,15 +596,21 @@ def url(self, privacy=False, *args, **kwargs): 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 @@ def parse_url(url): 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'] = \ diff --git a/test/test_plugin_discord.py b/test/test_plugin_discord.py index 96cd8eb67..e2641097a 100644 --- a/test/test_plugin_discord.py +++ b/test/test_plugin_discord.py @@ -89,10 +89,11 @@ '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 @@ # 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), {