diff --git a/handlers/messages_routing.py b/handlers/messages_routing.py index 497c0a8..604f979 100644 --- a/handlers/messages_routing.py +++ b/handlers/messages_routing.py @@ -9,6 +9,7 @@ from handlers.handle_private import handle_private logger = logging.getLogger('handlers.messages_routing') logging.basicConfig(level=logging.DEBUG) +latest_toxic = 0 async def messages_routing(msg, state): cid = msg["chat"]["id"] @@ -32,6 +33,13 @@ async def messages_routing(msg, state): elif bool(text): mid = msg.get("message_id") + if text == '/score': + await telegram_api( + "sendMessage", + chat_id=cid, + reply_to=mid, + text=f"{latest_toxic}%" + ) toxic_score = detector(text) logger.info(f'\ntext: {text}\ntoxic: {math.floor(toxic_score*100)}%') if toxic_score > 0.81: