Update telegram.py

This commit is contained in:
Kamontat Chantrachirathumrong 2021-05-26 17:21:52 +07:00 committed by GitHub
parent f8f65a1ad5
commit 51794f68ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -238,14 +238,16 @@ class Telegram(RPCHandler):
msg_type = msg['type'] msg_type = msg['type']
noti = '' noti = ''
if msg_type == RPCMessageType.SELL: if msg_type == RPCMessageType.SELL:
sell_noti = self._config['telegram'].get('notification_settings', {}).get(str(msg_type), {}) sell_noti = self._config['telegram'] \
.get('notification_settings', {}).get(str(msg_type), {})
# For backward compatibility sell still be string # For backward compatibility sell still be string
if isinstance(noti, str): if isinstance(noti, str):
noti = sell_noti noti = sell_noti
else: else:
noti = sell_noti.get(str(msg['sell_reason']), default_noti) noti = sell_noti.get(str(msg['sell_reason']), default_noti)
else: else:
noti = self._config['telegram'].get('notification_settings', {}).get(str(msg_type), default_noti) noti = self._config['telegram'] \
.get('notification_settings', {}).get(str(msg_type), default_noti)
if noti == 'off': if noti == 'off':
logger.info(f"Notification '{msg_type}' not sent.") logger.info(f"Notification '{msg_type}' not sent.")