separate-latest-toxic
This commit is contained in:
parent
a78c752e4d
commit
d71a6e00ec
|
@ -9,7 +9,7 @@ from handlers.handle_private import handle_private
|
|||
logger = logging.getLogger('handlers.messages_routing')
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
latest_toxic = 0
|
||||
latest_toxic = {}
|
||||
|
||||
async def messages_routing(msg, state):
|
||||
cid = msg["chat"]["id"]
|
||||
|
@ -33,15 +33,17 @@ async def messages_routing(msg, state):
|
|||
|
||||
elif bool(text):
|
||||
mid = msg.get("message_id")
|
||||
if text == '/score':
|
||||
if text.startswith('/score'):
|
||||
await telegram_api(
|
||||
"sendMessage",
|
||||
chat_id=cid,
|
||||
reply_to=mid,
|
||||
text=f"{latest_toxic}%"
|
||||
text=f"{latest_toxic.get(cid, 0)}%"
|
||||
)
|
||||
toxic_score = detector(text)
|
||||
logger.info(f'\ntext: {text}\ntoxic: {math.floor(toxic_score*100)}%')
|
||||
toxic_perc = math.floor(toxic_score*100)
|
||||
latest_toxic[cid] = toxic_perc
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user