diff --git a/apprise/plugins/NotifyZulip.py b/apprise/plugins/NotifyZulip.py index 66ffb9d1..54fe2d06 100644 --- a/apprise/plugins/NotifyZulip.py +++ b/apprise/plugins/NotifyZulip.py @@ -163,6 +163,9 @@ class NotifyZulip(NotifyBase): 'to': { 'alias_of': 'targets', }, + 'token': { + 'alias_of': 'token', + }, }) # The default hostname to append to a defined organization @@ -377,21 +380,24 @@ class NotifyZulip(NotifyBase): # The botname results['botname'] = NotifyZulip.unquote(results['user']) - # The first token is stored in the hostname + # The organization is stored in the hostname results['organization'] = NotifyZulip.unquote(results['host']) - # Now fetch the remaining tokens - try: - results['token'] = \ - NotifyZulip.split_path(results['fullpath'])[0] + # Store our targets + results['targets'] = NotifyZulip.split_path(results['fullpath']) - except IndexError: + if 'token' in results['qsd'] and len(results['qsd']['token']): + # Store our token if specified + results['token'] = NotifyZulip.unquote(results['qsd']['token']) + + elif results['targets']: + # First item is the token + results['token'] = results['targets'].pop(0) + + else: # no token results['token'] = None - # Get unquoted entries - results['targets'] = NotifyZulip.split_path(results['fullpath'])[1:] - # Support the 'to' variable so that we can support rooms this way too # The 'to' makes it easier to use yaml configuration if 'to' in results['qsd'] and len(results['qsd']['to']): diff --git a/test/test_plugin_zulip.py b/test/test_plugin_zulip.py index 2e86e2e2..68187720 100644 --- a/test/test_plugin_zulip.py +++ b/test/test_plugin_zulip.py @@ -84,6 +84,10 @@ apprise_url_tests = ( ('zulip://botname@apprise/{}/?to=channel1/channel2'.format('a' * 32), { 'instance': NotifyZulip, }), + # Test token= + ('zulip://botname@apprise/?token={}&to=channel1'.format('a' * 32), { + 'instance': NotifyZulip, + }), # Valid everything - 2 emails specified ('zulip://botname@apprise/{}/user@example.com/user2@example.com'.format( 'a' * 32), {