This commit is contained in:
2024-09-28 10:06:04 +03:00
parent 98b842ef18
commit 32ce2e17c4
4 changed files with 49 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ from bot.config import FEEDBACK_CHAT_ID
from handlers.handle_private import handle_private
from nlp.toxicity_detector import detector
from nlp.normalize import normalize
from nlp.ocr import ocr_recognize
logger = logging.getLogger("handlers.messages_routing")
@@ -14,7 +15,15 @@ logger = logging.getLogger("handlers.messages_routing")
async def messages_routing(msg, state):
cid = msg["chat"]["id"]
uid = msg["from"]["id"]
text = msg.get("text", msg.get("caption"))
text = msg.get("caption", msg.get("text", ""))
for photo in msg.get("photo", [])
file_id = photo.get("file_id")
if file_id:
async for temp_file_path in download_file(file_id):
text += ocr_recognize(temp_file_path)
text += '\n'
reply_msg = msg.get("reply_to_message")
if cid == uid: