score_msg_id

This commit is contained in:
Untone 2024-09-26 16:43:10 +03:00
parent 960260ee9f
commit 6bffb8039b

View File

@ -31,21 +31,21 @@ async def messages_routing(msg, state):
elif bool(text): elif bool(text):
mid = msg.get("message_id") mid = msg.get("message_id")
if text == '/toxic@welcomecenter_bot': latest_toxic_message_id = await redis.get(f"toxic:{cid}")
latest_toxic_message_id = await redis.get(f"toxic:{cid}") if text == '/toxic@welcomecenter_bot' and latest_toxic_message_id:
if latest_toxic_message_id: scoring_msg_id = reply_msg.get("message_id") or latest_toxic_message_id
rmsg = reply_msg.get("message_id") or latest_toxic_message_id toxic_score = await redis.get(f"toxic:{cid}:{scoring_msg_id}")
await telegram_api( await telegram_api(
"sendMessage", "sendMessage",
chat_id=cid, chat_id=cid,
reply_to_message_id=rmsg, reply_to_message_id=scoring_msg_id,
text=f"{latest_toxic.get(f"{cid}:{rmsg}", 0)}% токсичности" text=f"{toxic_score}% токсичности"
) )
await telegram_api( await telegram_api(
"deleteMessage", "deleteMessage",
chat_id=cid, chat_id=cid,
message_id=mid message_id=mid
) )
else: else:
toxic_score = detector(text) toxic_score = detector(text)
toxic_perc = math.floor(toxic_score*100) toxic_perc = math.floor(toxic_score*100)