aboutsummaryrefslogtreecommitdiffhomepage
path: root/libs/apprise/plugins/NotifyRyver.py
diff options
context:
space:
mode:
Diffstat (limited to 'libs/apprise/plugins/NotifyRyver.py')
-rw-r--r--libs/apprise/plugins/NotifyRyver.py51
1 files changed, 20 insertions, 31 deletions
diff --git a/libs/apprise/plugins/NotifyRyver.py b/libs/apprise/plugins/NotifyRyver.py
index ebc67de1c..b34b56686 100644
--- a/libs/apprise/plugins/NotifyRyver.py
+++ b/libs/apprise/plugins/NotifyRyver.py
@@ -40,14 +40,9 @@ from .NotifyBase import NotifyBase
from ..common import NotifyImageSize
from ..common import NotifyType
from ..utils import parse_bool
+from ..utils import validate_regex
from ..AppriseLocale import gettext_lazy as _
-# Token required as part of the API request
-VALIDATE_TOKEN = re.compile(r'[A-Z0-9]{15}', re.I)
-
-# Organization required as part of the API request
-VALIDATE_ORG = re.compile(r'[A-Z0-9_-]{3,32}', re.I)
-
class RyverWebhookMode(object):
"""
@@ -99,12 +94,14 @@ class NotifyRyver(NotifyBase):
'name': _('Organization'),
'type': 'string',
'required': True,
+ 'regex': (r'^[A-Z0-9_-]{3,32}$', 'i'),
},
'token': {
'name': _('Token'),
'type': 'string',
'required': True,
'private': True,
+ 'regex': (r'^[A-Z0-9]{15}$', 'i'),
},
'user': {
'name': _('Bot Name'),
@@ -135,25 +132,21 @@ class NotifyRyver(NotifyBase):
"""
super(NotifyRyver, self).__init__(**kwargs)
- if not token:
- msg = 'No Ryver token was specified.'
- self.logger.warning(msg)
- raise TypeError(msg)
-
- if not organization:
- msg = 'No Ryver organization was specified.'
+ # API Token (associated with project)
+ self.token = validate_regex(
+ token, *self.template_tokens['token']['regex'])
+ if not self.token:
+ msg = 'An invalid Ryver API Token ' \
+ '({}) was specified.'.format(token)
self.logger.warning(msg)
raise TypeError(msg)
- if not VALIDATE_TOKEN.match(token.strip()):
- msg = 'The Ryver token specified ({}) is invalid.'\
- .format(token)
- self.logger.warning(msg)
- raise TypeError(msg)
-
- if not VALIDATE_ORG.match(organization.strip()):
- msg = 'The Ryver organization specified ({}) is invalid.'\
- .format(organization)
+ # Organization (associated with project)
+ self.organization = validate_regex(
+ organization, *self.template_tokens['organization']['regex'])
+ if not self.organization:
+ msg = 'An invalid Ryver Organization ' \
+ '({}) was specified.'.format(organization)
self.logger.warning(msg)
raise TypeError(msg)
@@ -167,12 +160,6 @@ class NotifyRyver(NotifyBase):
self.logger.warning(msg)
raise TypeError(msg)
- # The organization associated with the account
- self.organization = organization.strip()
-
- # The token associated with the account
- self.token = token.strip()
-
# Place an image inline with the message body
self.include_image = include_image
@@ -193,6 +180,8 @@ class NotifyRyver(NotifyBase):
re.IGNORECASE,
)
+ return
+
def send(self, body, title='', notify_type=NotifyType.INFO, **kwargs):
"""
Perform Ryver Notification
@@ -279,7 +268,7 @@ class NotifyRyver(NotifyBase):
return True
- def url(self):
+ def url(self, privacy=False, *args, **kwargs):
"""
Returns the URL built dynamically based on specified arguments.
"""
@@ -304,7 +293,7 @@ class NotifyRyver(NotifyBase):
schema=self.secure_protocol,
botname=botname,
organization=NotifyRyver.quote(self.organization, safe=''),
- token=NotifyRyver.quote(self.token, safe=''),
+ token=self.pprint(self.token, privacy, safe=''),
args=NotifyRyver.urlencode(args),
)
@@ -363,7 +352,7 @@ class NotifyRyver(NotifyBase):
result = re.match(
r'^https?://(?P<org>[A-Z0-9_-]+)\.ryver\.com/application/webhook/'
r'(?P<webhook_token>[A-Z0-9]+)/?'
- r'(?P<args>\?[.+])?$', url, re.I)
+ r'(?P<args>\?.+)?$', url, re.I)
if result:
return NotifyRyver.parse_url(