From d156c108555c13ee68f6f619d40e1c5c3b7e9d14 Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 27 Sep 2024 13:26:38 +0300 Subject: [PATCH] stability-patch --- handlers/messages_routing.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/handlers/messages_routing.py b/handlers/messages_routing.py index d87e5bd..3e7f5d2 100644 --- a/handlers/messages_routing.py +++ b/handlers/messages_routing.py @@ -49,10 +49,12 @@ async def messages_routing(msg, state): reply_to_msg_id = reply_msg.get("message_id") if not reply_to_msg_id and latest_toxic_message_id: reply_to_msg_id = int(latest_toxic_message_id) - - # count average between all of messages - toxic_pattern = f"toxic:{cid}:{uid}:*" - toxic_score = await get_average_pattern(toxic_pattern) + try: + # count average between all of messages + toxic_pattern = f"toxic:{cid}:{uid}:*" + toxic_score = await get_average_pattern(toxic_pattern) + except: + pass # current mesasage toxicity if reply_to_msg_id: @@ -70,7 +72,9 @@ async def messages_routing(msg, state): if toxic_score > 20 else "😇" ) - text = f"{int(one_score)}% токсичности\nСредняя токсичность сообщений: {toxic_score}% {emoji}" + text = f"{int(one_score)}% токсичности\n" + if toxic_score: + text += "Средняя токсичность сообщений: {toxic_score}% {emoji}" await telegram_api( "sendMessage", chat_id=cid,