mirror of
https://github.com/caronc/apprise.git
synced 2024-11-07 08:44:17 +01:00
PushMe Support Added (#928)
This commit is contained in:
parent
5fd568fa35
commit
31caff1ac9
@ -36,6 +36,7 @@ from .NotifyBase import NotifyBase
|
||||
from ..common import NotifyType
|
||||
from ..common import NotifyFormat
|
||||
from ..utils import validate_regex
|
||||
from ..utils import parse_bool
|
||||
from ..AppriseLocale import gettext_lazy as _
|
||||
|
||||
|
||||
@ -82,9 +83,14 @@ class NotifyPushMe(NotifyBase):
|
||||
'push_key': {
|
||||
'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
|
||||
"""
|
||||
@ -98,6 +104,9 @@ class NotifyPushMe(NotifyBase):
|
||||
self.logger.warning(msg)
|
||||
raise TypeError(msg)
|
||||
|
||||
# Set Status type
|
||||
self.status = status
|
||||
|
||||
return
|
||||
|
||||
def send(self, body, title='', notify_type=NotifyType.INFO, **kwargs):
|
||||
@ -112,7 +121,8 @@ class NotifyPushMe(NotifyBase):
|
||||
# Prepare our payload
|
||||
params = {
|
||||
'push_key': self.token,
|
||||
'title': title,
|
||||
'title': title if not self.status
|
||||
else '{} {}'.format(self.asset.ascii(notify_type), title),
|
||||
'content': body,
|
||||
'type': 'markdown'
|
||||
if self.notify_format == NotifyFormat.MARKDOWN else 'text'
|
||||
@ -170,8 +180,13 @@ class NotifyPushMe(NotifyBase):
|
||||
Returns the URL built dynamically based on specified arguments.
|
||||
"""
|
||||
|
||||
# Our URL parameters
|
||||
params = self.url_parameters(privacy=privacy, *args, **kwargs)
|
||||
# Define any URL parameters
|
||||
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
|
||||
return '{schema}://{token}/?{params}'.format(
|
||||
@ -203,4 +218,8 @@ class NotifyPushMe(NotifyBase):
|
||||
# Support 'push_key' if specified
|
||||
results['token'] = NotifyPushMe.unquote(results['qsd']['push_key'])
|
||||
|
||||
# Get status switch
|
||||
results['status'] = \
|
||||
parse_bool(results['qsd'].get('status', True))
|
||||
|
||||
return results
|
||||
|
@ -55,14 +55,28 @@ apprise_url_tests = (
|
||||
'privacy_url': 'pushme://a...a/',
|
||||
}),
|
||||
# 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,
|
||||
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'pushme://b...b/',
|
||||
}),
|
||||
# Token specified
|
||||
('pushme://?push_key=%s' % ('p' * 6), {
|
||||
('pushme://?push_key=%s&status=no' % ('p' * 6), {
|
||||
'instance': NotifyPushMe,
|
||||
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
|
Loading…
Reference in New Issue
Block a user