Skip to content

Commit

Permalink
Правки по feat: Добавлена поддержка отправки фото от Модератора #55
Browse files Browse the repository at this point in the history
Получше условие сделал
Исправил requirments
  • Loading branch information
Tr1zel committed Mar 2, 2025
1 parent ee7a870 commit c5c4b69
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 30 deletions.
2 changes: 1 addition & 1 deletion core/filters/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def __init__(self):

class StudentFilter(RoleFilter):
def __init__(self):
super().__init__(Role.STUDENT)
super().__init__(Role.STUDENT)
35 changes: 17 additions & 18 deletions core/handlers/moderator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
20 changes: 10 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit c5c4b69

Please sign in to comment.