From e02940dab4c1d802c15f884b559f7c543033c715 Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Tue, 9 Oct 2018 21:22:20 -0400 Subject: [PATCH] finished applying meta data for details() function; refs #21 --- apprise/Apprise.py | 21 +++++++++++++++++-- apprise/plugins/NotifyIFTTT.py | 15 ++++++++++--- apprise/plugins/NotifyJSON.py | 6 ++++++ apprise/plugins/NotifyJoin.py | 9 ++++++++ apprise/plugins/NotifyMatterMost.py | 9 ++++++++ apprise/plugins/NotifyProwl.py | 9 ++++++++ apprise/plugins/NotifyPushBullet.py | 9 ++++++++ apprise/plugins/NotifyPushalot.py | 9 ++++++++ .../plugins/NotifyPushjet/NotifyPushjet.py | 9 ++++++++ apprise/plugins/NotifyPushover.py | 9 ++++++++ apprise/plugins/NotifyRocketChat.py | 9 ++++++++ apprise/plugins/NotifySlack.py | 9 ++++++++ apprise/plugins/NotifyStride.py | 8 +++++++ apprise/plugins/NotifyTelegram.py | 8 +++++++ apprise/plugins/NotifyToasty.py | 9 ++++++++ .../plugins/NotifyTwitter/NotifyTwitter.py | 9 ++++++++ apprise/plugins/NotifyWindows.py | 6 ++++++ apprise/plugins/NotifyXBMC.py | 9 ++++++++ apprise/plugins/NotifyXML.py | 6 ++++++ test/test_api.py | 8 +++++-- 20 files changed, 179 insertions(+), 7 deletions(-) diff --git a/apprise/Apprise.py b/apprise/Apprise.py index bd81f5d5..73adf629 100644 --- a/apprise/Apprise.py +++ b/apprise/Apprise.py @@ -55,6 +55,9 @@ def __load_matrix(): # Get our plugin plugin = getattr(plugins, entry) + if not hasattr(plugin, 'app_id'): # pragma: no branch + # Filter out non-notification modules + continue # Load protocol(s) if defined proto = getattr(plugin, 'protocol', None) @@ -299,13 +302,27 @@ class Apprise(object): # Get our plugin plugin = getattr(plugins, entry) + if not hasattr(plugin, 'app_id'): # pragma: no branch + # Filter out non-notification modules + continue + + # Standard protocol(s) should be None or a tuple + protocols = getattr(plugin, 'protocol', None) + if compat_is_basestring(protocols): + protocols = (protocols, ) + + # Secure protocol(s) should be None or a tuple + secure_protocols = getattr(plugin, 'secure_protocol', None) + if compat_is_basestring(secure_protocols): + secure_protocols = (secure_protocols, ) # Build our response object response['schemas'].append({ 'service_name': getattr(plugin, 'service_name', None), 'service_url': getattr(plugin, 'service_url', None), - 'protocol': getattr(plugin, 'protocol', None), - 'secure_protocol': getattr(plugin, 'secure_protocol', None), + 'setup_url': getattr(plugin, 'setup_url', None), + 'protocols': protocols, + 'secure_protocols': secure_protocols, }) return response diff --git a/apprise/plugins/NotifyIFTTT.py b/apprise/plugins/NotifyIFTTT.py index 1569df44..4a28f5ff 100644 --- a/apprise/plugins/NotifyIFTTT.py +++ b/apprise/plugins/NotifyIFTTT.py @@ -43,6 +43,18 @@ class NotifyIFTTT(NotifyBase): """ + # The default descriptive name associated with the Notification + service_name = 'IFTTT' + + # The services URL + service_url = 'https://ifttt.com/' + + # The default protocol + protocol = 'ifttt' + + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_ifttt' + # Even though you'll add 'Ingredients' as {{ Value1 }} to your Applets, # you must use their lowercase value in the HTTP POST. ifttt_default_key_prefix = 'value' @@ -65,9 +77,6 @@ class NotifyIFTTT(NotifyBase): # value1, value2, and value3). ifttt_default_type_key = 'value3' - # The default protocol - protocol = 'ifttt' - # IFTTT uses the http protocol with JSON requests notify_url = 'https://maker.ifttt.com/trigger/{event}/with/key/{apikey}' diff --git a/apprise/plugins/NotifyJSON.py b/apprise/plugins/NotifyJSON.py index 8375610b..280add0e 100644 --- a/apprise/plugins/NotifyJSON.py +++ b/apprise/plugins/NotifyJSON.py @@ -30,12 +30,18 @@ class NotifyJSON(NotifyBase): A wrapper for JSON Notifications """ + # The default descriptive name associated with the Notification + service_name = 'JSON' + # The default protocol protocol = 'json' # The default secure protocol secure_protocol = 'jsons' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_Custom_JSON' + # Allows the user to specify the NotifyImageSize object image_size = NotifyImageSize.XY_128 diff --git a/apprise/plugins/NotifyJoin.py b/apprise/plugins/NotifyJoin.py index 37fbb8cf..173bdf3f 100644 --- a/apprise/plugins/NotifyJoin.py +++ b/apprise/plugins/NotifyJoin.py @@ -64,9 +64,18 @@ class NotifyJoin(NotifyBase): A wrapper for Join Notifications """ + # The default descriptive name associated with the Notification + service_name = 'Join' + + # The services URL + service_url = 'https://joaoapps.com/join/' + # The default protocol protocol = 'join' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_join' + # Join uses the http protocol with JSON requests notify_url = \ 'https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush' diff --git a/apprise/plugins/NotifyMatterMost.py b/apprise/plugins/NotifyMatterMost.py index 9f7ac06b..5dfdb234 100644 --- a/apprise/plugins/NotifyMatterMost.py +++ b/apprise/plugins/NotifyMatterMost.py @@ -37,12 +37,21 @@ class NotifyMatterMost(NotifyBase): A wrapper for MatterMost Notifications """ + # The default descriptive name associated with the Notification + service_name = 'MatterMost' + + # The services URL + service_url = 'https://mattermost.com/' + # The default protocol protocol = 'mmost' # The default secure protocol secure_protocol = 'mmosts' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_mattermost' + # The default Mattermost port default_port = 8065 diff --git a/apprise/plugins/NotifyProwl.py b/apprise/plugins/NotifyProwl.py index 309182d1..50ff8d9a 100644 --- a/apprise/plugins/NotifyProwl.py +++ b/apprise/plugins/NotifyProwl.py @@ -59,9 +59,18 @@ class NotifyProwl(NotifyBase): A wrapper for Prowl Notifications """ + # The default descriptive name associated with the Notification + service_name = 'Prowl' + + # The services URL + service_url = 'https://www.prowlapp.com/' + # The default secure protocol secure_protocol = 'prowl' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_prowl' + # Prowl uses the http protocol with JSON requests notify_url = 'https://api.prowlapp.com/publicapi/add' diff --git a/apprise/plugins/NotifyPushBullet.py b/apprise/plugins/NotifyPushBullet.py index fc73b7fe..0fe1ea23 100644 --- a/apprise/plugins/NotifyPushBullet.py +++ b/apprise/plugins/NotifyPushBullet.py @@ -45,9 +45,18 @@ class NotifyPushBullet(NotifyBase): A wrapper for PushBullet Notifications """ + # The default descriptive name associated with the Notification + service_name = 'Pushbullet' + + # The services URL + service_url = 'https://www.pushbullet.com/' + # The default secure protocol secure_protocol = 'pbul' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_pushbullet' + # PushBullet uses the http protocol with JSON requests notify_url = 'https://api.pushbullet.com/v2/pushes' diff --git a/apprise/plugins/NotifyPushalot.py b/apprise/plugins/NotifyPushalot.py index b3f1dcdf..446ff00d 100644 --- a/apprise/plugins/NotifyPushalot.py +++ b/apprise/plugins/NotifyPushalot.py @@ -40,9 +40,18 @@ class NotifyPushalot(NotifyBase): A wrapper for Pushalot Notifications """ + # The default descriptive name associated with the Notification + service_name = 'Pushalot' + + # The services URL + service_url = 'https://pushalot.com/' + # The default protocol is always secured secure_protocol = 'palot' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_pushalot' + # Pushalot uses the http protocol with JSON requests notify_url = 'https://pushalot.com/api/sendmessage' diff --git a/apprise/plugins/NotifyPushjet/NotifyPushjet.py b/apprise/plugins/NotifyPushjet/NotifyPushjet.py index bea2a2c3..02636936 100644 --- a/apprise/plugins/NotifyPushjet/NotifyPushjet.py +++ b/apprise/plugins/NotifyPushjet/NotifyPushjet.py @@ -32,12 +32,21 @@ class NotifyPushjet(NotifyBase): A wrapper for Pushjet Notifications """ + # The default descriptive name associated with the Notification + service_name = 'Pushjet' + + # The services URL + service_url = 'https://pushjet.io/' + # The default protocol protocol = 'pjet' # The default secure protocol secure_protocol = 'pjets' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_pushjet' + def __init__(self, **kwargs): """ Initialize Pushjet Object diff --git a/apprise/plugins/NotifyPushover.py b/apprise/plugins/NotifyPushover.py index a259de03..e95da1e8 100644 --- a/apprise/plugins/NotifyPushover.py +++ b/apprise/plugins/NotifyPushover.py @@ -68,9 +68,18 @@ class NotifyPushover(NotifyBase): A wrapper for Pushover Notifications """ + # The default descriptive name associated with the Notification + service_name = 'Pushover' + + # The services URL + service_url = 'https://pushover.net/' + # All pushover requests are secure secure_protocol = 'pover' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_pushover' + # Pushover uses the http protocol with JSON requests notify_url = 'https://api.pushover.net/1/messages.json' diff --git a/apprise/plugins/NotifyRocketChat.py b/apprise/plugins/NotifyRocketChat.py index 8b8432f9..5251e344 100644 --- a/apprise/plugins/NotifyRocketChat.py +++ b/apprise/plugins/NotifyRocketChat.py @@ -44,12 +44,21 @@ class NotifyRocketChat(NotifyBase): A wrapper for Notify Rocket.Chat Notifications """ + # The default descriptive name associated with the Notification + service_name = 'Rocket.Chat' + + # The services URL + service_url = 'https://rocket.chat/' + # The default protocol protocol = 'rocket' # The default secure protocol secure_protocol = 'rockets' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_rocketchat' + # Defines the maximum allowable characters in the title title_maxlen = 200 diff --git a/apprise/plugins/NotifySlack.py b/apprise/plugins/NotifySlack.py index 72693991..cccb3f32 100644 --- a/apprise/plugins/NotifySlack.py +++ b/apprise/plugins/NotifySlack.py @@ -71,9 +71,18 @@ class NotifySlack(NotifyBase): A wrapper for Slack Notifications """ + # The default descriptive name associated with the Notification + service_name = 'Slack' + + # The services URL + service_url = 'https://slack.com/' + # The default secure protocol secure_protocol = 'slack' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_slack' + # Slack uses the http protocol with JSON requests notify_url = 'https://hooks.slack.com/services' diff --git a/apprise/plugins/NotifyStride.py b/apprise/plugins/NotifyStride.py index 2525c3fe..3ba81983 100644 --- a/apprise/plugins/NotifyStride.py +++ b/apprise/plugins/NotifyStride.py @@ -61,10 +61,18 @@ class NotifyStride(NotifyBase): A wrapper to Stride Notifications """ + # The default descriptive name associated with the Notification + service_name = 'Stride' + + # The services URL + service_url = 'https://www.stride.com/' # The default secure protocol secure_protocol = 'stride' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_stride' + # Stride Webhook notify_url = 'https://api.atlassian.com/site/{cloud_id}/' \ 'conversation/{convo_id}/message' diff --git a/apprise/plugins/NotifyTelegram.py b/apprise/plugins/NotifyTelegram.py index 650ad48e..90fe051f 100644 --- a/apprise/plugins/NotifyTelegram.py +++ b/apprise/plugins/NotifyTelegram.py @@ -81,10 +81,18 @@ class NotifyTelegram(NotifyBase): """ A wrapper for Telegram Notifications """ + # The default descriptive name associated with the Notification + service_name = 'Telegram' + + # The services URL + service_url = 'https://telegram.org/' # The default secure protocol secure_protocol = 'tgram' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_telegram' + # Telegram uses the http protocol with JSON requests notify_url = 'https://api.telegram.org/bot' diff --git a/apprise/plugins/NotifyToasty.py b/apprise/plugins/NotifyToasty.py index 603e5dbb..eab16113 100644 --- a/apprise/plugins/NotifyToasty.py +++ b/apprise/plugins/NotifyToasty.py @@ -34,9 +34,18 @@ class NotifyToasty(NotifyBase): A wrapper for Toasty Notifications """ + # The default descriptive name associated with the Notification + service_name = 'Toasty' + + # The services URL + service_url = 'http://supertoasty.com/' + # The default protocol protocol = 'toasty' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_toasty' + # Toasty uses the http protocol with JSON requests notify_url = 'http://api.supertoasty.com/notify/' diff --git a/apprise/plugins/NotifyTwitter/NotifyTwitter.py b/apprise/plugins/NotifyTwitter/NotifyTwitter.py index db4783d2..b8177237 100644 --- a/apprise/plugins/NotifyTwitter/NotifyTwitter.py +++ b/apprise/plugins/NotifyTwitter/NotifyTwitter.py @@ -26,9 +26,18 @@ class NotifyTwitter(NotifyBase): """ + # The default descriptive name associated with the Notification + service_name = 'Twitter' + + # The services URL + service_url = 'https://twitter.com/' + # The default secure protocol secure_protocol = 'tweet' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_twitter' + # The maximum allowable characters allowed in the body per message # This is used during a Private DM Message Size (not Public Tweets # which are limited to 240 characters) diff --git a/apprise/plugins/NotifyWindows.py b/apprise/plugins/NotifyWindows.py index e2793864..98ff2a91 100644 --- a/apprise/plugins/NotifyWindows.py +++ b/apprise/plugins/NotifyWindows.py @@ -47,9 +47,15 @@ class NotifyWindows(NotifyBase): A wrapper for local Windows Notifications """ + # The default descriptive name associated with the Notification + service_name = 'Windows Notification' + # The default protocol protocol = 'windows' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_windows' + # Allows the user to specify the NotifyImageSize object image_size = NotifyImageSize.XY_128 diff --git a/apprise/plugins/NotifyXBMC.py b/apprise/plugins/NotifyXBMC.py index 8878b646..7d0549e8 100644 --- a/apprise/plugins/NotifyXBMC.py +++ b/apprise/plugins/NotifyXBMC.py @@ -31,12 +31,21 @@ class NotifyXBMC(NotifyBase): A wrapper for XBMC/KODI Notifications """ + # The default descriptive name associated with the Notification + service_name = 'Kodi/XBMC' + + # The services URL + service_url = 'http://kodi.tv/' + # The default protocols protocol = ('xbmc', 'kodi') # The default secure protocols secure_protocol = ('xbmc', 'kodis') + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_kodi' + # XBMC uses the http protocol with JSON requests xbmc_default_port = 8080 diff --git a/apprise/plugins/NotifyXML.py b/apprise/plugins/NotifyXML.py index 9a7df319..4cfa4a2c 100644 --- a/apprise/plugins/NotifyXML.py +++ b/apprise/plugins/NotifyXML.py @@ -30,12 +30,18 @@ class NotifyXML(NotifyBase): A wrapper for XML Notifications """ + # The default descriptive name associated with the Notification + service_name = 'XML' + # The default protocol protocol = 'xml' # The default secure protocol secure_protocol = 'xmls' + # A URL that takes you to the setup/help of the specific protocol + setup_url = 'https://github.com/caronc/apprise/wiki/Notify_Custom_XML' + # Allows the user to specify the NotifyImageSize object image_size = NotifyImageSize.XY_128 diff --git a/test/test_api.py b/test/test_api.py index fddd3159..3f142e22 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -22,6 +22,7 @@ from os import getuid from os.path import dirname from apprise import Apprise from apprise import AppriseAsset +from apprise.utils import compat_is_basestring from apprise.Apprise import SCHEMA_MAP from apprise import NotifyBase from apprise import NotifyType @@ -500,8 +501,6 @@ def test_apprise_details(): assert isinstance(details.get('schemas'), list) # We have an entry per defined plugin - assert len(details.get('schemas')) == len(dir(plugins)) - assert 'asset' in details assert isinstance(details.get('asset'), dict) assert 'app_id' in details['asset'] @@ -511,3 +510,8 @@ def test_apprise_details(): assert 'image_path_mask' in details['asset'] assert 'image_url_mask' in details['asset'] assert 'image_url_logo' in details['asset'] + + # All plugins must have a name defined; the below generates + # a list of entrys that do not have a string defined. + assert(not len([x['service_name'] for x in details['schemas'] + if not compat_is_basestring(x['service_name'])]))