diff --git a/handlers/messages_routing.py b/handlers/messages_routing.py index 19382de..409cc1e 100644 --- a/handlers/messages_routing.py +++ b/handlers/messages_routing.py @@ -113,18 +113,19 @@ async def messages_routing(msg, state): segmented_text = segment_text(normalized_text) toxic_score = detector(segmented_text) toxic_perc = math.floor(toxic_score * 100) + logger.info(f"\ntext: {text}\ntoxic: {toxic_perc}%") nospaces_text = text.replace(' ', '') logger.info(f're-check this one: {nospaces_text}') nospaces_text_score = detector(nospaces_text) nospaces_text_perc = math.floor(toxic_score * 100) logger.info(f'no spaces text toxic: {nospaces_text_perc}%') + if (nospaces_text != text and nospaces_text_score > toxic_score) or nospaces_text_perc > 95: text_perc = nospaces_text_perc await redis.set(f"toxic:{cid}", mid) await redis.set(f"toxic:{cid}:{uid}:{mid}", toxic_perc, ex=60 * 60 * 24 * 3) - logger.info(f"\ntext: {text}\ntoxic: {toxic_perc}%") if toxic_score > 0.81: if toxic_score > 0.90: await redis.set(f"removed:{uid}:{cid}:{mid}", text)