R
R
Rasul_i2020-04-22 20:20:25
Python
Rasul_i, 2020-04-22 20:20:25

PyTelegrabBotAPI error when editing photo?

tell me where I'm not doing the
id photo correctly, I checked it.

import telebot
from telebot import types

bot = telebot.TeleBot('*************')

foto_1='AgACAgIAAxkBAAIJi16cNHdOWxDWIzTPwdkXZM9Odbn7AAJRrjEb3ZvhSDDlmHwPDBzMuZ3CDwAEAQADAgADeAADhOIGAAEYBA'
foto_2='AgACAgIAAxkBAAIJjF6cNNI-ezbWBWgvj0_aAjggpbrkAAJSrjEb3ZvhSBTYOFlaDaTq1XoAAZIuAAMBAAMCAAN4AAPCawACGAQ'

@bot.message_handler(commands=['start'])
def start(message):
    myrep = types.InlineKeyboardMarkup()
    button = types.InlineKeyboardButton(text='изменить фото', callback_data='opa')
    myrep.add(button)
    bot.send_photo(message.chat.id, foto_1, reply_markup=myrep)

@bot.callback_query_handler(func=lambda call: True)
def sddvsd(call):
    if call.data =='opa':
        bot.edit_message_media(media=foto_2, chat_id=call.message.chat.id, message_id=call.message.message_id  )    ####

bot.polling(none_stop=True)



2020-04-22 22:15:24,301 (util.py:66 WorkerThread1) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body: \n[b\'{"ok":false,"error_code":400,"description":"Bad Request: can\\\'t parse InputMedia: Media is not specified"}\']',)
Traceback ( most recent call last):
File "C:\akfa\venv\lib\site-packages\telebot\util.py", line 60, in run
task(*args, **kwargs)
File "C:/akfa/blabla .py", line 21, in sddvsd
bot.edit_message_media(media=foto_2, chat_id=call.message.chat.id, message_id=call.message.message_id )
File "C:\akfa\venv\lib\site-packages\ telebot\__init__.py", line 1063,in edit_message_media
result = apihelper.edit_message_media(self.token, media, chat_id, message_id, inline_message_id, reply_markup)
File "C:\akfa\venv\lib\site-packages\telebot\apihelper.py", line 693, in edit_message_media
return _make_request( token, method_url, params=payload, files=file, method='post' if file else 'get')
File "C:\akfa\venv\lib\site-packages\telebot\apihelper.py", line 60, in _make_request
return _check_result(method_name, result)['result']
File "C:\akfa\venv\lib\site-packages\telebot\apihelper.py", line 79, in _check_result
raise ApiException(msg, method_name, result)
telebot .apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request.
[b'{"ok":false,"error_code":400,"description":"Bad Request: can\'t parse InputMedia: Media is not specified"}']
"
2020-04-22 22:15:24,302 (__init__.py:420 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:
[b'{"ok":false,"error_code":400,"description":"Bad Request: can\'t parse InputMedia: Media is not specified"}']"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OlegBat, 2020-05-01
@OlegBat

You may need to use a proxy,
I did it myself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question