@solarkaaa

Error sending photo: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: IMAGE_PROCESS_FAILED?

query = f"SELECT product_name, product_price, product_description, product_picture FROM Accessories WHERE id>=1 and user_id != {message.from_user.id}"
    cursor.execute(query)
    result = cursor.fetchall()

    if result:
        for row in result:
            product_name, product_price, product_description, product_picture = row

            if product_picture:
                product_picture = product_picture.strip()
                padding = len(product_picture) % 4
                product_picture += '=' * padding

                try:
                    image_data = base64.b64decode(product_picture)
                    image_file = io.BytesIO(image_data)
                    image_file.seek(0)

                    bot.send_photo(message.chat.id, image_file,
                                   caption=f"Name: {product_name}, Price: {product_price}, Description: {product_description}")
                except Exception as e:
                    print("Error sending photo:", e)
            else:
                if all([product_name, product_price, product_description]):
                    response_message = f"Name: {product_name}, Price: {product_price}, Description: {product_description}"
                    bot.send_message(message.chat.id, response_message)
                else:
                    continue
    else:
        bot.send_message(message.chat.id, "No data")
        bot.register_next_step_handler(message, handle_skip)
  • Вопрос задан
  • 374 просмотра
Пригласить эксперта
Ответы на вопрос 1
@chemdev
Твои манипуляции с картинкой делают ее нечитаемой.

P.S. А если ответить на вопрос
Error sending photo: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: IMAGE_PROCESS_FAILED?

Да.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы