From 2eeb112c14999b4885d1b7227bc4c5cb938a8af7 Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 26 Sep 2024 17:38:00 +0300 Subject: [PATCH] float-none-fix --- handlers/messages_routing.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/handlers/messages_routing.py b/handlers/messages_routing.py index 850dd87..7396aa9 100644 --- a/handlers/messages_routing.py +++ b/handlers/messages_routing.py @@ -32,6 +32,8 @@ async def messages_routing(msg, state): elif bool(text): mid = msg.get("message_id") if text == '/toxic@welcomecenter_bot': + text = '' + toxic_score = 0 if not reply_msg: scoring_msg_id = mid pattern = f"toxic:{cid}:{uid}:*" @@ -44,14 +46,16 @@ async def messages_routing(msg, state): 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 = 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=text - ) + toxic_score = await redis.get(f"toxic:{cid}:{uid}:{scoring_msg_id}") + if toxic_score: + text = f"{toxic_score}% токсичности" + if text: + await telegram_api( + "sendMessage", + chat_id=cid, + reply_to_message_id=scoring_msg_id, + text=text + ) await telegram_api( "deleteMessage", chat_id=cid,