log
This commit is contained in:
parent
22ccc579c7
commit
580cb562d9
|
@ -35,13 +35,17 @@ async def messages_routing(msg, state):
|
|||
latest_toxic_message_id = await redis.get(f"toxic:{cid}")
|
||||
pattern = f"toxic:{cid}:{uid}:*"
|
||||
scores = []
|
||||
async for key in redis.scan_iter(pattern):
|
||||
found = await redis.scan_iter(pattern)
|
||||
logger.debug(f'found {len(found) messages}')
|
||||
for key in found:
|
||||
scr = await redis.get(key)
|
||||
if isinstance(scr, int):
|
||||
scores.append(scr)
|
||||
toxic_score = math.floor(sum(scores)/len(scores)) if scores else 0
|
||||
scoring_msg_id = reply_msg.get("message_id", int(latest_toxic_message_id)) if reply_msg else int(latest_toxic_message_id)
|
||||
one_score = await redis.get(f"toxic:{cid}:{uid}:{scoring_msg_id}")
|
||||
msg_toxic_key = f"toxic:{cid}:{uid}:{scoring_msg_id}"
|
||||
logger.debug(msg_toxic_key)
|
||||
one_score = await redis.get(msg_toxic_key)
|
||||
logger.debug(one_score)
|
||||
emoji = '😳' if toxic_score > 90 else '😟' if toxic_score > 80 else '😏' if toxic_score > 60 else '🙂' if toxic_score > 20 else '😇'
|
||||
text = f"{int(one_score or 0)}% токсичности\nСредняя токсичность сообщений: {toxic_score}% {emoji}"
|
||||
|
|
Loading…
Reference in New Issue
Block a user