0
async def send_message(chat_id: int):
    image_files = get_image_files()
    if not image_files:
        try:
            await app.send_message(chat_id, "1")
            logger.info(f"Бот успешно отправил сообщение в чат: {chat_id}")
        except Exception as e:
            logger.error(f"Ошибка при отправке сообщения в чате {chat_id}: {e}")
    else:
        for index, image_file in enumerate(image_files):
            with open("images/" + image_file, "rb") as file:
                media_group = []
                if index == 0:
                    media_group.append(InputMediaPhoto(file, caption="photo caption"))
                else:
                    media_group.append(InputMediaPhoto(file))
                try:
                    await app.send_media_group(chat_id, media_group)
                    logger.info(f"Бот успешно отправил медиа-группу в чат: {chat_id}")
                except Exception as e:
                    logger.error(f"Ошибка при отправке медиа-группы в чате {chat_id}: {e}")

Here is the code. don't pay attention to the logging info text - look at code. The bottom line: send the media group. All the functions used return the correct data. I add files to the media group - there are no errors. But at some point everything freezes on the moment:

2023-07-30 10:39:53,767 - INFO - PingTask started PingTask started

I tried to change the code - in all cases, such garbage. waiting for a message to be sent

frexget
  • 1
  • 1

1 Answers1

0

Perhaps, the problem with paths? Try using absolute paths instead of relative ones.

If it's not the case, please add Minimal, Reproducible Example

elebur
  • 465
  • 1
  • 5