From a78c752e4dee8aaf2f7255486122fc808cd2f911 Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 26 Sep 2024 15:28:22 +0300 Subject: [PATCH] .. --- handlers/messages_routing.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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: