freqtrade_origin/freqtrade/rpc/__init__.py

43 lines
880 B
Python
Raw Normal View History

2017-11-18 20:43:21 +00:00
import logging
from . import telegram
2017-11-18 20:43:21 +00:00
logger = logging.getLogger(__name__)
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):
2017-11-18 20:43:21 +00:00
logger.info('Enabling rpc.telegram ...')
REGISTERED_MODULES.append('telegram')
telegram.init(config)
def cleanup() -> None:
"""
Stops all enabled rpc modules
:return: None
"""
if 'telegram' in REGISTERED_MODULES:
2017-11-18 20:43:21 +00:00
logger.debug('Cleaning up rpc.telegram ...')
telegram.cleanup()
def send_msg(msg: str) -> None:
"""
Send given markdown message to all registered rpc modules
:param msg: message
:return: None
"""
2017-11-18 20:43:21 +00:00
logger.info(msg)
if 'telegram' in REGISTERED_MODULES:
telegram.send_msg(msg)