|
|
@ -77,12 +77,12 @@ ZULIP_HTTP_ERROR_MAP = {
|
|
|
|
401: 'Unauthorized - Invalid Token.',
|
|
|
|
401: 'Unauthorized - Invalid Token.',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Used to break path apart into list of channels
|
|
|
|
# Used to break path apart into list of streams
|
|
|
|
TARGET_LIST_DELIM = re.compile(r'[ \t\r\n,#\\/]+')
|
|
|
|
TARGET_LIST_DELIM = re.compile(r'[ \t\r\n,#\\/]+')
|
|
|
|
|
|
|
|
|
|
|
|
# Used to detect a channel
|
|
|
|
# Used to detect a streams
|
|
|
|
IS_VALID_TARGET_RE = re.compile(
|
|
|
|
IS_VALID_TARGET_RE = re.compile(
|
|
|
|
r'#?(?P<channel>[A-Z0-9_]{1,32})', re.I)
|
|
|
|
r'#?(?P<stream>[A-Z0-9_]{1,32})', re.I)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NotifyZulip(NotifyBase):
|
|
|
|
class NotifyZulip(NotifyBase):
|
|
|
@ -142,8 +142,8 @@ class NotifyZulip(NotifyBase):
|
|
|
|
'type': 'string',
|
|
|
|
'type': 'string',
|
|
|
|
'map_to': 'targets',
|
|
|
|
'map_to': 'targets',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'target_channel': {
|
|
|
|
'target_stream': {
|
|
|
|
'name': _('Target Channel'),
|
|
|
|
'name': _('Target Stream'),
|
|
|
|
'type': 'string',
|
|
|
|
'type': 'string',
|
|
|
|
'map_to': 'targets',
|
|
|
|
'map_to': 'targets',
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -164,8 +164,8 @@ class NotifyZulip(NotifyBase):
|
|
|
|
# if one isn't defined in the apprise url
|
|
|
|
# if one isn't defined in the apprise url
|
|
|
|
default_hostname = 'zulipchat.com'
|
|
|
|
default_hostname = 'zulipchat.com'
|
|
|
|
|
|
|
|
|
|
|
|
# The default channel to notify if no targets are specified
|
|
|
|
# The default stream to notify if no targets are specified
|
|
|
|
default_notification_channel = 'general'
|
|
|
|
default_notification_stream = 'general'
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, botname, organization, token, targets=None, **kwargs):
|
|
|
|
def __init__(self, botname, organization, token, targets=None, **kwargs):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -218,8 +218,8 @@ class NotifyZulip(NotifyBase):
|
|
|
|
|
|
|
|
|
|
|
|
self.targets = parse_list(targets)
|
|
|
|
self.targets = parse_list(targets)
|
|
|
|
if len(self.targets) == 0:
|
|
|
|
if len(self.targets) == 0:
|
|
|
|
# No channels identified, use default
|
|
|
|
# No streams identified, use default
|
|
|
|
self.targets.append(self.default_notification_channel)
|
|
|
|
self.targets.append(self.default_notification_stream)
|
|
|
|
|
|
|
|
|
|
|
|
def send(self, body, title='', notify_type=NotifyType.INFO, **kwargs):
|
|
|
|
def send(self, body, title='', notify_type=NotifyType.INFO, **kwargs):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|