mirror of https://github.com/caronc/apprise
PushMe Support Added (#928)
parent
5fd568fa35
commit
31caff1ac9
|
@ -36,6 +36,7 @@ from .NotifyBase import NotifyBase
|
||||||
from ..common import NotifyType
|
from ..common import NotifyType
|
||||||
from ..common import NotifyFormat
|
from ..common import NotifyFormat
|
||||||
from ..utils import validate_regex
|
from ..utils import validate_regex
|
||||||
|
from ..utils import parse_bool
|
||||||
from ..AppriseLocale import gettext_lazy as _
|
from ..AppriseLocale import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,9 +83,14 @@ class NotifyPushMe(NotifyBase):
|
||||||
'push_key': {
|
'push_key': {
|
||||||
'alias_of': 'token',
|
'alias_of': 'token',
|
||||||
},
|
},
|
||||||
|
'status': {
|
||||||
|
'name': _('Show Status'),
|
||||||
|
'type': 'bool',
|
||||||
|
'default': True,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
def __init__(self, token, **kwargs):
|
def __init__(self, token, status=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Initialize PushMe Object
|
Initialize PushMe Object
|
||||||
"""
|
"""
|
||||||
|
@ -98,6 +104,9 @@ class NotifyPushMe(NotifyBase):
|
||||||
self.logger.warning(msg)
|
self.logger.warning(msg)
|
||||||
raise TypeError(msg)
|
raise TypeError(msg)
|
||||||
|
|
||||||
|
# Set Status type
|
||||||
|
self.status = status
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def send(self, body, title='', notify_type=NotifyType.INFO, **kwargs):
|
def send(self, body, title='', notify_type=NotifyType.INFO, **kwargs):
|
||||||
|
@ -112,7 +121,8 @@ class NotifyPushMe(NotifyBase):
|
||||||
# Prepare our payload
|
# Prepare our payload
|
||||||
params = {
|
params = {
|
||||||
'push_key': self.token,
|
'push_key': self.token,
|
||||||
'title': title,
|
'title': title if not self.status
|
||||||
|
else '{} {}'.format(self.asset.ascii(notify_type), title),
|
||||||
'content': body,
|
'content': body,
|
||||||
'type': 'markdown'
|
'type': 'markdown'
|
||||||
if self.notify_format == NotifyFormat.MARKDOWN else 'text'
|
if self.notify_format == NotifyFormat.MARKDOWN else 'text'
|
||||||
|
@ -170,8 +180,13 @@ class NotifyPushMe(NotifyBase):
|
||||||
Returns the URL built dynamically based on specified arguments.
|
Returns the URL built dynamically based on specified arguments.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Our URL parameters
|
# Define any URL parameters
|
||||||
params = self.url_parameters(privacy=privacy, *args, **kwargs)
|
params = {
|
||||||
|
'status': 'yes' if self.status else 'no',
|
||||||
|
}
|
||||||
|
|
||||||
|
# Extend our parameters
|
||||||
|
params.update(self.url_parameters(privacy=privacy, *args, **kwargs))
|
||||||
|
|
||||||
# Official URLs are easy to assemble
|
# Official URLs are easy to assemble
|
||||||
return '{schema}://{token}/?{params}'.format(
|
return '{schema}://{token}/?{params}'.format(
|
||||||
|
@ -203,4 +218,8 @@ class NotifyPushMe(NotifyBase):
|
||||||
# Support 'push_key' if specified
|
# Support 'push_key' if specified
|
||||||
results['token'] = NotifyPushMe.unquote(results['qsd']['push_key'])
|
results['token'] = NotifyPushMe.unquote(results['qsd']['push_key'])
|
||||||
|
|
||||||
|
# Get status switch
|
||||||
|
results['status'] = \
|
||||||
|
parse_bool(results['qsd'].get('status', True))
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
|
@ -55,14 +55,28 @@ apprise_url_tests = (
|
||||||
'privacy_url': 'pushme://a...a/',
|
'privacy_url': 'pushme://a...a/',
|
||||||
}),
|
}),
|
||||||
# Token specified
|
# Token specified
|
||||||
('pushme://?token=%s' % ('b' * 6), {
|
('pushme://?token=%s&status=yes' % ('b' * 6), {
|
||||||
|
'instance': NotifyPushMe,
|
||||||
|
|
||||||
|
# Our expected url(privacy=True) startswith() response:
|
||||||
|
'privacy_url': 'pushme://b...b/',
|
||||||
|
}),
|
||||||
|
# Status setting
|
||||||
|
('pushme://?token=%s&status=no' % ('b' * 6), {
|
||||||
|
'instance': NotifyPushMe,
|
||||||
|
|
||||||
|
# Our expected url(privacy=True) startswith() response:
|
||||||
|
'privacy_url': 'pushme://b...b/',
|
||||||
|
}),
|
||||||
|
# Status setting
|
||||||
|
('pushme://?token=%s&status=True' % ('b' * 6), {
|
||||||
'instance': NotifyPushMe,
|
'instance': NotifyPushMe,
|
||||||
|
|
||||||
# Our expected url(privacy=True) startswith() response:
|
# Our expected url(privacy=True) startswith() response:
|
||||||
'privacy_url': 'pushme://b...b/',
|
'privacy_url': 'pushme://b...b/',
|
||||||
}),
|
}),
|
||||||
# Token specified
|
# Token specified
|
||||||
('pushme://?push_key=%s' % ('p' * 6), {
|
('pushme://?push_key=%s&status=no' % ('p' * 6), {
|
||||||
'instance': NotifyPushMe,
|
'instance': NotifyPushMe,
|
||||||
|
|
||||||
# Our expected url(privacy=True) startswith() response:
|
# Our expected url(privacy=True) startswith() response:
|
||||||
|
|
Loading…
Reference in New Issue