friendly
This commit is contained in:
parent
51cd4ae65b
commit
2909e3b905
|
@ -43,13 +43,18 @@ async def messages_routing(msg, state):
|
||||||
scr = int(await redis.get(key))
|
scr = int(await redis.get(key))
|
||||||
scores.append(scr)
|
scores.append(scr)
|
||||||
toxic_score = math.floor(sum(scores)/len(scores)) if scores else 0
|
toxic_score = math.floor(sum(scores)/len(scores)) if scores else 0
|
||||||
text = f"Средняя токсичность сообщений: {toxic_score}%"
|
text = f"Доброе утро! Средняя токсичность твоих сообщений: {toxic_score}%"
|
||||||
else:
|
else:
|
||||||
latest_toxic_message_id = await redis.get(f"toxic:{cid}")
|
latest_toxic_message_id = await redis.get(f"toxic:{cid}")
|
||||||
scoring_msg_id = reply_msg.get("message_id") or 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}:{uid}:{scoring_msg_id}")
|
toxic_score = await redis.get(f"toxic:{cid}:{uid}:{scoring_msg_id}")
|
||||||
if toxic_score:
|
if toxic_score:
|
||||||
text = f"{int(toxic_score)}% токсичности"
|
text = f"{int(toxic_score)}% токсичности"
|
||||||
|
await telegram_api(
|
||||||
|
"deleteMessage",
|
||||||
|
chat_id=cid,
|
||||||
|
message_id=mid
|
||||||
|
)
|
||||||
if text:
|
if text:
|
||||||
await telegram_api(
|
await telegram_api(
|
||||||
"sendMessage",
|
"sendMessage",
|
||||||
|
@ -57,11 +62,6 @@ async def messages_routing(msg, state):
|
||||||
reply_to_message_id=scoring_msg_id,
|
reply_to_message_id=scoring_msg_id,
|
||||||
text=text
|
text=text
|
||||||
)
|
)
|
||||||
await telegram_api(
|
|
||||||
"deleteMessage",
|
|
||||||
chat_id=cid,
|
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user