diff --git a/handlers/messages_routing.py b/handlers/messages_routing.py index 608d354..1b1ab3c 100644 --- a/handlers/messages_routing.py +++ b/handlers/messages_routing.py @@ -113,14 +113,15 @@ async def messages_routing(msg, state): normalized_text = normalize(text) toxic_score = detector(normalized_text) - toxic_perc = math.floor(toxic_score * 100) - if toxic_score < 0.9 and text != text.replace(' ', ''): + toxic_perc = toxic_score * 100 + logger.info(f'original toxic: {toxic_perc}') + if toxic_score < 0.91: logger.info('re-check without spaces') toxic_perc += check_stopwords(normalized_text) logger.info(f"text: {normalized_text}\ntoxic: {toxic_perc}%") await redis.set(f"toxic:{cid}", mid) - await redis.set(f"toxic:{cid}:{uid}:{mid}", toxic_perc, ex=60 * 60 * 24 * 3) + await redis.set(f"toxic:{cid}:{uid}:{mid}", math.floor(toxic_perc), ex=60 * 60 * 24 * 3) if toxic_score > 0.75: if toxic_score > 0.90: await redis.set(f"removed:{uid}:{cid}:{mid}", text)