下午好。我正在ESP32上为智能温室编写一个机器人。我目前使用的是bool sendMessageWithInlineKeyboard(Stringchat_id, String text, String parse_mode, String Keyboard)
,但每次都会发送一条新消息。相反,我想更新现有消息,以便机器人不会发送大量消息。我该如何操作?
{
if (text == ("LAMP"))
{ // Команды от кнопки (Включение/выключение)
if (isLightTurned == 0)
{
fill_solid(leds, NUM_LEDS, CRGB(255, 255, 255));
isLightTurned = 1;
FastLED.show();
String keyboardJson = "[[{ \"text\" : \"⏪ Назад\", \"callback_data\" : \"TEPLISA\" }]]";
bot.sendMessageWithInlineKeyboard(chat_id, "⚪ Освещение включено", "", keyboardJson);
}
else if (isLightTurned == 1)
{
}
字符串
1条答案
按热度按时间gwo2fgha1#
我假设你正在使用Universal-Arduino-Telegram-Bot库。
虽然README上的主要参考页面没有提到如何做到这一点,但提供的一个示例(UpdateInlineKeyboard.ino)显示您可以向
sendMessageWithInlineKeyboard
传递第五个参数,其中包含您想要更新的消息的消息ID:字符串
在UniversalTelegramBot.h中,您还可以看到
sendMessageWithInlineKeyboard
方法的完整签名是:型
因此,在您的场景中,您应该获取要更新的消息的
message_id
,并在调用sendMessageWithInlineKeyboard
时使用它。