Skip to content

Commit

Permalink
Replacing an error message 415 (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
iskomir authored Apr 20, 2024
1 parent b40ada2 commit 4da84b9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions migrations/versions/75dab872e82b_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-02-25 19:05:46.473426
"""

import sqlalchemy as sa
from alembic import op

Expand Down
1 change: 1 addition & 0 deletions src/answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Answers:

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

send_to_print = '✅ Файл "{}" успешно загружен. Для печати подойдите к принтеру и введите PIN: \n\n{}'
Expand Down
10 changes: 10 additions & 0 deletions src/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ def order_print(user: vk.EventUser, db_requisites):
status_code=r.status_code,
description='File is too big',
)
elif r.status_code == 415:
vk.send(user, ans.warn_unreadable_file)
marketing.print_exc_other(
vk_id=vk_id,
surname=surname,
number=number,
pin=pin,
status_code=r.status_code,
description='Unsupported Media Type',
)
else:
vk.send(user, ans.err_print)
marketing.print_exc_other(
Expand Down
6 changes: 4 additions & 2 deletions src/vk.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging

from vk_api import VkApi
from vk_api.bot_longpoll import VkBotEvent, VkBotLongPoll, VkBotEventType
from vk_api.bot_longpoll import VkBotEvent, VkBotEventType, VkBotLongPoll
from vk_api.keyboard import VkKeyboard
from vk_api.utils import get_random_id

Expand Down Expand Up @@ -40,7 +40,9 @@ def __init__(self, event: VkBotEvent):
r = vk.method('users.get', {'user_ids': self.user_id})
self.first_name = r[0]['first_name']
self.last_name = r[0]['last_name']
logging.info(f"[{self.user_id} {self.first_name} {self.last_name}]: {repr(self.message)} {repr(self.attachments)}")
logging.info(
f"[{self.user_id} {self.first_name} {self.last_name}]: {repr(self.message)} {repr(self.attachments)}"
)


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

0 comments on commit 4da84b9

Please sign in to comment.