Skip to content

Commit

Permalink
Фикс отправки стикеров в случае поломанного кэша.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zensonaton committed Dec 5, 2023
1 parent 3c738b2 commit 09ee4f1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/services/vk/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,17 @@ async def handle_message_events() -> None:
attachment_cache_name
)

# TODO: Сделать отдельный метод для загрузки данных стикера.
# Достаём URL анимации стикера, либо статичное изображение-"превью" этого стикера.
sticker_url = attachment.get("animation_url") if is_animated else attachment["images"][-1]["url"]

# Загружаем стикер.
async with aiohttp.ClientSession() as client:
async with client.get(sticker_url) as response:
assert response.status == 200, f"Не удалось загрузить стикер с ID {attachment_cache_name}"

sticker_bytes = await response.read()

msg = await subgroup.send_sticker(
sticker=BufferedInputFile(
file=cast(bytes, sticker_bytes),
Expand Down

0 comments on commit 09ee4f1

Please sign in to comment.