shurillu / CTBot

A simple (and easy to use) Arduino Telegram BOT Library for ESP8266/ESP32
MIT License
147 stars 34 forks source link

added editMessageText possibility #63

Closed ivan140 closed 3 years ago

ivan140 commented 3 years ago

Description

This pull request adds the possibility to edit messages from the bot. Very usefull to change the layout of an InlineKeyboard without the necessity to send a new one.

Example usage

CTBotInlineKeyboard onKbd;
CTBotInlineKeyboard offKbd;

//setup
onKbd.addButton("ON", "ON", CTBotKeyboardButtonQuery);
offKbd.addButton("OFF", "OFF", CTBotKeyboardButtonQuery);

//loop
if (m.callbackQueryData.equals("ON")) {
        digitalWrite(DIGITAL_PIN, HIGH);
        bot.editMessageText(m.group.id, m.messageID, "My Switch", offKbd);
} else if (m.callbackQueryData.equals("OFF")) {
        digitalWrite(DIGITAL_PIN, LOW);
        bot.editMessageText(m.group.id, m.messageID, "My Switch", onKbd);
} 
shurillu commented 3 years ago

Hello Ivan, thanks for your contribute! I edited this message, just merging your pull request now!

Thanks again!