reo7sp / tgbot-cpp

C++ library for Telegram bot API

Home Page:http://reo7sp.github.io/tgbot-cpp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't figure out about editing recently sent messages by bot

Amirhan-Taipovjan-Greatest-I opened this issue · comments

I can't find any possible method to do that in C++.

Example:
I have this part of code:

        bot.getApi().sendMessage(message->chat->id, "|", false, 0, 0, "Markdown", false);
        Sleep(5000);
        bot.getApi().editMessageText("/", message->chat->id, message->messageId, 0, "Markdown", false, 0);

Even if message->messageId isn't zero or something else, I still can't do that code because it sends me to This

The fourth parameter of editMessageText() is a string and not an int:
bot.getApi().editMessageText("/", message->chat->id, message->messageId, "", "Markdown", false, 0);

You are also trying to edit the command message from the user. You can only edit messages from the bot itself. You need to get the message id of the message "|" and then use this id in editMessageText()

You need to get the message id of the message "|" and then use this id in editMessageText()

I can't figure out how I can get it!

Well, the sent message is returned on success with sendMessage()

Message::Ptr sentMessage = bot.getApi().sendMessage(message->chat->id, "|", false, 0, 0, "Markdown", false);
Sleep(5000);
bot.getApi().editMessageText("/", message->chat->id, sentMessage->messageId, "0", "Markdown", false, 0);

Thank you so much, it works!