initial commit

This commit is contained in:
D3h 2025-02-27 12:19:23 +03:00
commit ab9cfb6248
4 changed files with 47 additions and 0 deletions

9
Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM python:3.11
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "main.py"]

36
main.py Normal file
View File

@ -0,0 +1,36 @@
import logging, requests, telebot, json, os, base64, easyocr
API_TOKEN = '7543408818:AAEzpQfRy1f5HwgOi_-FVq_s-8kuxU_Oup0'
reader = easyocr.Reader(['ru', 'en'])
logger = telebot.logger
telebot.logger.setLevel(logging.INFO)
bot = telebot.TeleBot(API_TOKEN, threaded=False)
def process_event(event):
request_body_dict = json.loads(event['body'])
update = telebot.types.Update.de_json(request_body_dict)
bot.process_new_updates([update])
@bot.message_handler(commands=['help', 'start'])
def send_welcome(message):
bot.reply_to(message,
"Отправьте картинку с текстом. В ответ получите текст, распознанный с этой картинки")
@bot.message_handler(func=lambda message: True, content_types=['photo'])
def echo_photo(message):
file_id = message.photo[-1].file_id
file_info = bot.get_file(file_id)
downloaded_file = bot.download_file(file_info.file_path)
responce = reader.readtext(downloaded_file, detail=0, paragraph=True)
text = ''
for par in responce:
text += par + '\n'
bot.reply_to(message, text)
bot.infinity_polling()

BIN
ocr-bot.tar.gz Normal file

Binary file not shown.

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
telebot
easyocr