diff --git a/core/filters/role.py b/core/filters/role.py index 3c45948..a6cf224 100644 --- a/core/filters/role.py +++ b/core/filters/role.py @@ -37,4 +37,4 @@ def __init__(self): class StudentFilter(RoleFilter): def __init__(self): - super().__init__(Role.STUDENT) \ No newline at end of file + super().__init__(Role.STUDENT) diff --git a/core/handlers/moderator.py b/core/handlers/moderator.py index a8bab04..91b425a 100644 --- a/core/handlers/moderator.py +++ b/core/handlers/moderator.py @@ -39,24 +39,23 @@ async def send_moderator_answer(album, message: Message, store: Storage, ticket_ except MessageNotFoundException: logger.info(f"Message {reply_to_id} to reply not found") - if message.content_type == ContentType.PHOTO: - if message.media_group_id is None: # если одиночное фото - file_id = message.photo[-1].file_id - file_caption = message.caption - sent = await bot.send_photo(ticket.owner_chat_id, photo=file_id, reply_to_message_id=reply_to_id, - parse_mode=ParseMode.HTML, caption=file_caption) - else: # если медиа групп - if album: - media = [] - for obj in album: - if obj.photo: - file_id = obj.photo[-1].file_id - if obj == album[0]: - media.append(InputMediaPhoto(media=file_id, caption=message.caption)) - else: - media.append(InputMediaPhoto(media=file_id)) - sent = await bot.send_media_group(chat_id=ticket.owner_chat_id, media=media) - else: # если текстовое сообщение + if message.content_type == ContentType.PHOTO and message.media_group_id is None: # если одиночное фото + file_id = message.photo[-1].file_id + file_caption = message.caption + sent = await bot.send_photo(ticket.owner_chat_id, photo=file_id, reply_to_message_id=reply_to_id, + parse_mode=ParseMode.HTML, caption=file_caption) + if message.content_type == ContentType.PHOTO and message.media_group_id: # если медиа групп + if album: + media = [] + for obj in album: + if obj.photo: + file_id = obj.photo[-1].file_id + if obj == album[0]: + media.append(InputMediaPhoto(media=file_id, caption=message.caption)) + else: + media.append(InputMediaPhoto(media=file_id)) + sent = await bot.send_media_group(chat_id=ticket.owner_chat_id, media=media) + if message.content_type == ContentType.TEXT: # если текстовое сообщение sent = await bot.send_message( ticket.owner_chat_id, texts.ticket.moderator_answer(ticket.id, answer), diff --git a/poetry.lock b/poetry.lock index 0db5df5..96f396e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -258,6 +258,17 @@ files = [ [package.extras] dev = ["backports.zoneinfo", "freezegun (>=1.0,<2.0)", "jinja2 (>=3.0)", "pytest (>=6.0)", "pytest-cov", "pytz", "setuptools", "tzdata"] +[[package]] +name = "cachetools" +version = "5.5.2" +description = "Extensible memoizing collections and decorators" +optional = false +python-versions = ">=3.7" +files = [ + {file = "cachetools-5.5.2-py3-none-any.whl", hash = "sha256:d26a22bcc62eb95c3beabd9f1ee5e820d3d2704fe2967cbe350e20c8ffcd3f0a"}, + {file = "cachetools-5.5.2.tar.gz", hash = "sha256:1a661caa9175d26759571b2e19580f9d6393969e5dfca11fdb1f947a23e640d4"}, +] + [[package]] name = "certifi" version = "2025.1.31" @@ -907,4 +918,4 @@ propcache = ">=0.2.0" [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "d97d348fb4af95bf3d2a5f5e71ba5985f869333a4ebc08b102d1b03f86dfce76" +content-hash = "0acbf92958218bbb6ee242c57872bdd0c1d98a8322b94aa788f5d31bf7fbccaf" diff --git a/pyproject.toml b/pyproject.toml index fd5fe28..9a2f89f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ sqlalchemy = "^2.0.36" python-dotenv = "^1.0.1" asyncpg = "^0.30.0" pybars3 = "^0.9.7" +cachetools = "^5.5.2" [build-system] diff --git a/requirements.txt b/requirements.txt index 02b794a..cfc921d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,21 +1,21 @@ aiogram==2.15 ; python_version >= "3.10" and python_version < "4.0" aiohappyeyeballs==2.4.4 ; python_version >= "3.10" and python_version < "4.0" -aiohttp==3.11.8 ; python_version >= "3.10" and python_version < "4.0" -aiosignal==1.3.1 ; python_version >= "3.10" and python_version < "4.0" +aiohttp==3.11.12 ; python_version >= "3.10" and python_version < "4.0" +aiosignal==1.3.2 ; python_version >= "3.10" and python_version < "4.0" async-timeout==5.0.1 ; python_version >= "3.10" and python_version < "3.11.0" asyncpg==0.30.0 ; python_version >= "3.10" and python_version < "4.0" -attrs==24.2.0 ; python_version >= "3.10" and python_version < "4.0" -babel==2.16.0 ; python_version >= "3.10" and python_version < "4.0" -certifi==2024.8.30 ; python_version >= "3.10" and python_version < "4.0" +attrs==25.1.0 ; python_version >= "3.10" and python_version < "4.0" +babel==2.17.0 ; python_version >= "3.10" and python_version < "4.0" +cachetools==5.5.2 ; python_version >= "3.10" and python_version < "4.0" +certifi==2025.1.31 ; python_version >= "3.10" and python_version < "4.0" frozenlist==1.5.0 ; python_version >= "3.10" and python_version < "4.0" -greenlet==3.1.1 ; python_version < "3.13" and (platform_machine == "aarch64" or platform_machine == "ppc64le" or platform_machine == "x86_64" or platform_machine == "amd64" or platform_machine == "AMD64" or platform_machine == "win32" or platform_machine == "WIN32") and python_version >= "3.10" +greenlet==3.1.1 ; python_version < "3.14" and (platform_machine == "aarch64" or platform_machine == "ppc64le" or platform_machine == "x86_64" or platform_machine == "amd64" or platform_machine == "AMD64" or platform_machine == "win32" or platform_machine == "WIN32") and python_version >= "3.10" idna==3.10 ; python_version >= "3.10" and python_version < "4.0" multidict==6.1.0 ; python_version >= "3.10" and python_version < "4.0" -propcache==0.2.0 ; python_version >= "3.10" and python_version < "4.0" +propcache==0.2.1 ; python_version >= "3.10" and python_version < "4.0" pybars3==0.9.7 ; python_version >= "3.10" and python_version < "4.0" pymeta3==0.5.1 ; python_version >= "3.10" and python_version < "4.0" python-dotenv==1.0.1 ; python_version >= "3.10" and python_version < "4.0" -sqlalchemy==2.0.36 ; python_version >= "3.10" and python_version < "4.0" +sqlalchemy==2.0.38 ; python_version >= "3.10" and python_version < "4.0" typing-extensions==4.12.2 ; python_version >= "3.10" and python_version < "4.0" -yarl==1.18.0 ; python_version >= "3.10" and python_version < "4.0" -cachetools~=5.5.2 +yarl==1.18.3 ; python_version >= "3.10" and python_version < "4.0"