Allow webhook message setting directly

This commit is contained in:
Matthias
2022-10-07 20:44:47 +02:00
parent 8fcb80df69
commit fb2f2d9a39
4 changed files with 13 additions and 6 deletions

View File

@@ -88,7 +88,7 @@ class RPCManager:
"""
while queue:
msg = queue.popleft()
logger.info('Sending rpc strategy_msg: %s', msg)
for mod in self.registered_modules:
if mod._config.get(mod.name, {}).get('allow_custom_messages', False):
mod.send_msg({

View File

@@ -45,6 +45,7 @@ class Webhook(RPCHandler):
""" Send a message to telegram channel """
try:
whconfig = self._config['webhook']
# Deprecated 2022.10 - only keep generic method.
if msg['type'] in [RPCMessageType.ENTRY]:
valuedict = whconfig.get('webhookentry')
elif msg['type'] in [RPCMessageType.ENTRY_CANCEL]:
@@ -61,6 +62,9 @@ class Webhook(RPCHandler):
RPCMessageType.STARTUP,
RPCMessageType.WARNING):
valuedict = whconfig.get('webhookstatus')
elif msg['type'].value in whconfig:
# Allow all types ...
valuedict = whconfig.get(msg['type'].value)
elif msg['type'] in (
RPCMessageType.PROTECTION_TRIGGER,
RPCMessageType.PROTECTION_TRIGGER_GLOBAL,
@@ -69,8 +73,7 @@ class Webhook(RPCHandler):
RPCMessageType.STRATEGY_MSG):
# Don't fail for non-implemented types
return
else:
raise NotImplementedError('Unknown message type: {}'.format(msg['type']))
if not valuedict:
logger.info("Message type '%s' not configured for webhooks", msg['type'])
return