Skip to content

Commit 4da84b9

Browse files
authored
Replacing an error message 415 (#42)
1 parent b40ada2 commit 4da84b9

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

migrations/versions/75dab872e82b_init.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Create Date: 2023-02-25 19:05:46.473426
66
77
"""
8+
89
import sqlalchemy as sa
910
from alembic import op
1011

src/answers.py

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class Answers:
6060

6161
warn_filesize = '⚠️ Файл слишком большой. Мы принимаем файлы размером ДО 3 МБ'
6262
warn_many_files = '⚠️ Файлов слишком много. Прикрепите только один файл pdf.'
63+
warn_unreadable_file = '⚠️ Я не смог прочитать файл. Проверьте его целостность и формат, я работаю только с pdf.'
6364
warn_only_pdfs = '⚠️ Я умею печатать только документы в формате pdf.'
6465

6566
send_to_print = '✅ Файл "{}" успешно загружен. Для печати подойдите к принтеру и введите PIN: \n\n{}'

src/handlers.py

+10
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ def order_print(user: vk.EventUser, db_requisites):
178178
status_code=r.status_code,
179179
description='File is too big',
180180
)
181+
elif r.status_code == 415:
182+
vk.send(user, ans.warn_unreadable_file)
183+
marketing.print_exc_other(
184+
vk_id=vk_id,
185+
surname=surname,
186+
number=number,
187+
pin=pin,
188+
status_code=r.status_code,
189+
description='Unsupported Media Type',
190+
)
181191
else:
182192
vk.send(user, ans.err_print)
183193
marketing.print_exc_other(

src/vk.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44

55
from vk_api import VkApi
6-
from vk_api.bot_longpoll import VkBotEvent, VkBotLongPoll, VkBotEventType
6+
from vk_api.bot_longpoll import VkBotEvent, VkBotEventType, VkBotLongPoll
77
from vk_api.keyboard import VkKeyboard
88
from vk_api.utils import get_random_id
99

@@ -40,7 +40,9 @@ def __init__(self, event: VkBotEvent):
4040
r = vk.method('users.get', {'user_ids': self.user_id})
4141
self.first_name = r[0]['first_name']
4242
self.last_name = r[0]['last_name']
43-
logging.info(f"[{self.user_id} {self.first_name} {self.last_name}]: {repr(self.message)} {repr(self.attachments)}")
43+
logging.info(
44+
f"[{self.user_id} {self.first_name} {self.last_name}]: {repr(self.message)} {repr(self.attachments)}"
45+
)
4446

4547

4648
def send(user: EventUser, message: str, keyboard: VkKeyboard | None = None):

0 commit comments

Comments
 (0)