stability-patch2

This commit is contained in:
Untone 2024-09-27 13:28:31 +03:00
parent d156c10855
commit eff5cdb394

View File

@ -59,8 +59,11 @@ async def messages_routing(msg, state):
# current mesasage toxicity # current mesasage toxicity
if reply_to_msg_id: if reply_to_msg_id:
one_score = await redis.get(f"toxic:{cid}:{uid}:{reply_to_msg_id}") one_score = await redis.get(f"toxic:{cid}:{uid}:{reply_to_msg_id}")
reply_text = ''
if one_score: if one_score:
logger.debug(one_score) logger.debug(one_score)
reply_text += f"{int(one_score)}% токсичности\n"
if toxic_score:
emoji = ( emoji = (
"😳" "😳"
if toxic_score > 90 if toxic_score > 90
@ -72,14 +75,13 @@ async def messages_routing(msg, state):
if toxic_score > 20 if toxic_score > 20
else "😇" else "😇"
) )
text = f"{int(one_score)}% токсичности\n" reply_text += "Средняя токсичность сообщений: {toxic_score}% {emoji}"
if toxic_score: if reply_text:
text += "Средняя токсичность сообщений: {toxic_score}% {emoji}"
await telegram_api( await telegram_api(
"sendMessage", "sendMessage",
chat_id=cid, chat_id=cid,
reply_to_message_id=reply_to_msg_id, reply_to_message_id=reply_to_msg_id,
text=text, text=reply_text,
) )
try: try:
await telegram_api("deleteMessage", chat_id=cid, message_id=mid) await telegram_api("deleteMessage", chat_id=cid, message_id=mid)