BoShurik/TelegramBotBundle

Cannot edit MessageMedia

MyZik opened this issue · 2 comments

MyZik commented

Hi everyone!

I'm trying to edit message photo. I have written a method editMessageMedia (https://core.telegram.org/bots/api#editmessagemedia) in vendor/telegram-bot/src/BotApi.php:

class BotApi
{
    ...
    public function editMessageMedia(
        $chatId,
        $messageId,
        InputMedia $media,
        $inlineMessageId = null,
        $replyMarkup = null
    ) {
        return Message::fromResponse($this->call('editMessageMedia'), [
            'chat_id' => $chatId,
            'message_id' => $messageId,
            'inline_message_id' => $inlineMessageId,
            'media' => $media->toJson(),
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
        ]);
    }
}

And I use it so:

class MyCommand extends AbstractCommand implements PublicCommandInterface {
    ...
    
    public function execute(BotApi $api, Update $update)
    {
        $data['photo'] = 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png';

        $photo = new InputMedia();
        $photo->setType('photo');
        $photo->setMedia($data['photo']);

        $api->editMessageMedia(
            $data['chatId'],
            $data['messageId'],
            $photo,
            $data['inlineMessageId'] ?? null,
            $data['replyMarkup'] ?? null
        );
    }
}

And I'm getting an error:
Bad Request: can't parse InputMedia: Media is not specified
I have tried everything... Hoe can I fix this problem and edit photo in message?

Thanks in advance.

Please submit the issue to telegram-bot/api

I did not faced with such problem, there you likely find the solution