ocr
This commit is contained in:
@@ -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:
|
||||
|
Reference in New Issue
Block a user