..
This commit is contained in:
parent
497e8f3eb3
commit
a78c752e4d
|
@ -9,6 +9,7 @@ from handlers.handle_private import handle_private
|
||||||
logger = logging.getLogger('handlers.messages_routing')
|
logger = logging.getLogger('handlers.messages_routing')
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
|
latest_toxic = 0
|
||||||
|
|
||||||
async def messages_routing(msg, state):
|
async def messages_routing(msg, state):
|
||||||
cid = msg["chat"]["id"]
|
cid = msg["chat"]["id"]
|
||||||
|
@ -32,6 +33,13 @@ async def messages_routing(msg, state):
|
||||||
|
|
||||||
elif bool(text):
|
elif bool(text):
|
||||||
mid = msg.get("message_id")
|
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)
|
toxic_score = detector(text)
|
||||||
logger.info(f'\ntext: {text}\ntoxic: {math.floor(toxic_score*100)}%')
|
logger.info(f'\ntext: {text}\ntoxic: {math.floor(toxic_score*100)}%')
|
||||||
if toxic_score > 0.81:
|
if toxic_score > 0.81:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user