add middleware to expose common functionality for multiple rpc implementations

This commit is contained in:
gcarq
2017-11-18 21:30:31 +01:00
parent 4a91ecd91a
commit 3ab14dfe39
5 changed files with 150 additions and 62 deletions

View File

@@ -1 +1,34 @@
from . import telegram
REGISTERED_MODULES = []
def init(config: dict) -> None:
"""
Initializes all enabled rpc modules
:param config: config to use
:return: None
"""
if config['telegram'].get('enabled', False):
REGISTERED_MODULES.append('telegram')
telegram.init(config)
def cleanup() -> None:
"""
Stops all enabled rpc modules
:return: None
"""
if 'telegram' in REGISTERED_MODULES:
telegram.cleanup()
def send_msg(msg: str) -> None:
"""
Send given markdown message to all registered rpc modules
:param msg: message
:return: None
"""
if 'telegram' in REGISTERED_MODULES:
telegram.send_msg(msg)