toxic-debug3

This commit is contained in:
2024-09-26 20:28:16 +03:00
parent 21a366abe1
commit a51e936f67
3 changed files with 22 additions and 10 deletions

View File

@@ -19,3 +19,18 @@ async def get_all_removed(uid):
texts.append(value.encode('utf-8'))
return texts
async def get_average_toxic(msg):
uid = msg['from']['id']
cid = msg['chat']['id']
pattern = f"toxic:{cid}:{uid}:*"
scores = []
scoring_msg_id = 0
async for key in redis.scan_iter(pattern):
scr = await redis.get(key)
if isinstance(scr, int):
scores.append(scr)
logger.debug(f'found {len(scores)} messages')
toxic_score = math.floor(sum(scores)/len(scores)) if scores else 0
return toxic_score