less-norm

This commit is contained in:
Untone 2024-09-27 14:02:48 +03:00
parent a2545217e8
commit 5606c69035

View File

@ -57,33 +57,36 @@ async def messages_routing(msg, state):
if one_score: if one_score:
logger.debug(one_score) logger.debug(one_score)
reply_text += f"{int(one_score)}% токсичности\n" reply_text += f"{int(one_score)}% токсичности\n"
try:
# count average between all of messages
toxic_pattern = f"toxic:{cid}:{uid}:*"
toxic_score = await get_average_pattern(toxic_pattern)
# count average between all of messages if toxic_score:
toxic_pattern = f"toxic:{cid}:{uid}:*" emoji = (
toxic_score = await get_average_pattern(toxic_pattern) "😳"
if toxic_score > 90
if toxic_score: else "😟"
emoji = ( if toxic_score > 80
"😳" else "😏"
if toxic_score > 90 if toxic_score > 60
else "😟" else "🙂"
if toxic_score > 80 if toxic_score > 20
else "😏" else "😇"
if toxic_score > 60 )
else "🙂" reply_text += (
if toxic_score > 20 f"Средняя токсичность сообщений: {toxic_score}% {emoji}"
else "😇" )
) except Exception:
reply_text += ( pass
f"Средняя токсичность сообщений: {toxic_score}% {emoji}" finally:
) if reply_text:
if reply_text: 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=reply_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)
except Exception: except Exception: