Reduce function complexity by extracting message sending

This commit is contained in:
Matthias 2022-08-06 09:21:11 +02:00
parent 2687633941
commit f8f1ade163

View File

@ -587,15 +587,24 @@ class Telegram(RPCHandler):
lines.append("*Stoploss distance:* `{stoploss_current_dist:.8f}` "
"`({stoploss_current_dist_ratio:.2%})`")
if r['open_order']:
if r['exit_order_status']:
lines.append("*Open Order:* `{open_order}` - `{exit_order_status}`")
else:
lines.append("*Open Order:* `{open_order}`")
lines.append(
"*Open Order:* `{open_order}`"
+ "- `{exit_order_status}`" if r['exit_order_status'] else "")
lines_detail = self._prepare_order_details(
r['orders'], r['quote_currency'], r['is_open'])
lines.extend(lines_detail if lines_detail else "")
self.__send_status_msg(lines, r)
except RPCException as e:
self._send_msg(str(e))
def __send_status_msg(self, lines: List[str], r: Dict[str, Any]) -> None:
"""
Send status message.
"""
msg = ''
for line in lines:
if line:
if (len(msg) + len(line) + 1) < MAX_MESSAGE_LENGTH:
@ -606,9 +615,6 @@ class Telegram(RPCHandler):
self._send_msg(msg.format(**r))
except RPCException as e:
self._send_msg(str(e))
@authorized_only
def _status_table(self, update: Update, context: CallbackContext) -> None:
"""