toxic-debug3
This commit is contained in:
15
store.py
15
store.py
@@ -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
|
Reference in New Issue
Block a user