From eff5cdb394bba4e506e07bc5b7d913ba7cc67377 Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 27 Sep 2024 13:28:31 +0300 Subject: [PATCH] stability-patch2 --- handlers/messages_routing.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/handlers/messages_routing.py b/handlers/messages_routing.py index 3e7f5d2..ce8a916 100644 --- a/handlers/messages_routing.py +++ b/handlers/messages_routing.py @@ -59,8 +59,11 @@ async def messages_routing(msg, state): # current mesasage toxicity if reply_to_msg_id: one_score = await redis.get(f"toxic:{cid}:{uid}:{reply_to_msg_id}") + reply_text = '' if one_score: logger.debug(one_score) + reply_text += f"{int(one_score)}% токсичности\n" + if toxic_score: emoji = ( "😳" if toxic_score > 90 @@ -72,14 +75,13 @@ async def messages_routing(msg, state): if toxic_score > 20 else "😇" ) - text = f"{int(one_score)}% токсичности\n" - if toxic_score: - text += "Средняя токсичность сообщений: {toxic_score}% {emoji}" + reply_text += "Средняя токсичность сообщений: {toxic_score}% {emoji}" + if reply_text: await telegram_api( "sendMessage", chat_id=cid, reply_to_message_id=reply_to_msg_id, - text=text, + text=reply_text, ) try: await telegram_api("deleteMessage", chat_id=cid, message_id=mid)