From 9537d8875b829b347434ae8b63fbd768619fc46c Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 26 Sep 2024 17:01:52 +0300 Subject: [PATCH] fix-fmt --- 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 68fa5ca..850dd87 100644 --- a/handlers/messages_routing.py +++ b/handlers/messages_routing.py @@ -37,18 +37,20 @@ async def messages_routing(msg, state): pattern = f"toxic:{cid}:{uid}:*" scores = [] async for key in client.scan_iter(pattern): - scr = await redis.get(key) + scr = int(await redis.get(key)) scores.append(scr) - toxic_score = sum(scores)/len(scores) + toxic_score = math.floor(sum(scores)/len(scores)) + text = f"Средняя токсичность сообщений: {toxic_score}%" else: latest_toxic_message_id = await redis.get(f"toxic:{cid}") scoring_msg_id = reply_msg.get("message_id") or latest_toxic_message_id - toxic_score = await redis.get(f"toxic:{cid}:{uid}:{scoring_msg_id}") + toxic_score = float(await redis.get(f"toxic:{cid}:{uid}:{scoring_msg_id}")) + text = f"{float(toxic_score)}% токсичности" await telegram_api( "sendMessage", chat_id=cid, reply_to_message_id=scoring_msg_id, - text=f"{toxic_score}% токсичности" + text=text ) await telegram_api( "deleteMessage",