Skip to content

Commit e74bdb4

Browse files
fix main.py for linter
1 parent 5059c52 commit e74bdb4

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

bot/main.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
from telegram import Update
2-
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext
2+
from telegram.ext import (
3+
Updater,
4+
CommandHandler,
5+
MessageHandler,
6+
Filters,
7+
CallbackContext,
8+
)
39
import pytesseract
410
import os
511
from PIL import Image
612
import logging
713
import traceback
814

9-
pytesseract.pytesseract.tesseract_cmd = '/usr/bin/tesseract' # ваш путь до tesseract
15+
pytesseract.pytesseract.tesseract_cmd = "/usr/bin/tesseract" # ваш путь до tesseract
1016

1117

1218
def get_text_from_image(path):
1319
logging.info("getting image")
1420
img = Image.open(path)
1521
logging.info("image opened")
16-
return pytesseract.image_to_string(img, lang="rus+eng",timeout=30)
22+
return pytesseract.image_to_string(img, lang="rus+eng", timeout=30)
23+
1724

1825
def echo_photo(update: Update, context: CallbackContext) -> None:
1926
print(update.message.photo)
@@ -22,7 +29,7 @@ def echo_photo(update: Update, context: CallbackContext) -> None:
2229
result = "Что-то пошло не так, попробуйте позже"
2330
try:
2431
path = "images/photo.jpg"
25-
lst[-1].get_file().download(path, timeout=5);
32+
lst[-1].get_file().download(path, timeout=5)
2633
logging.info("download ok")
2734
result = get_text_from_image(path)
2835
logging.info("getting text ok")
@@ -32,11 +39,12 @@ def echo_photo(update: Update, context: CallbackContext) -> None:
3239
update.message.reply_text(result)
3340
except Exception as e:
3441
update.message.reply_text("Текст не определен")
35-
42+
3643

3744
def echo_no_photo(update: Update, context: CallbackContext) -> None:
3845
update.message.reply_text("Это не фото")
3946

47+
4048
def help(update: Update, context: CallbackContext) -> None:
4149
update.message.reply_text("Пришлите фотографию, текст с которой вам нужен")
4250

@@ -54,6 +62,3 @@ def main():
5462

5563
if __name__ == "__main__":
5664
main()
57-
58-
59-
#/usr/src/app

0 commit comments

Comments
 (0)