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):
mid = msg.get("message_id")
if text == '/toxic@welcomecenter_bot':
latest_toxic_message_id = await redis.get(f"toxic:{cid}")
if latest_toxic_message_id:
rmsg = reply_msg.get("message_id") or latest_toxic_message_id
await telegram_api(
"sendMessage",
chat_id=cid,
reply_to_message_id=rmsg,
text=f"{latest_toxic.get(f"{cid}:{rmsg}", 0)}% токсичности"
)
await telegram_api(
"deleteMessage",
chat_id=cid,
message_id=mid
)
latest_toxic_message_id = await redis.get(f"toxic:{cid}")
if text == '/toxic@welcomecenter_bot' and latest_toxic_message_id:
scoring_msg_id = reply_msg.get("message_id") or latest_toxic_message_id
toxic_score = await redis.get(f"toxic:{cid}:{scoring_msg_id}")
await telegram_api(
"sendMessage",
chat_id=cid,
reply_to_message_id=scoring_msg_id,
text=f"{toxic_score}% токсичности"
)
await telegram_api(
"deleteMessage",
chat_id=cid,
message_id=mid
)
else:
toxic_score = detector(text)
toxic_perc = math.floor(toxic_score*100)