cotestatnt / AsyncTelegram2

Powerful, flexible and secure Arduino Telegram BOT library. Hardware independent, it can be used with any MCU capable of handling an SSL connection.
MIT License
83 stars 25 forks source link

prevent restart loop #114

Closed sanderkob closed 11 months ago

sanderkob commented 11 months ago

I have implemented a restart command in my bot. When I issue the command /restart, in my code this is interpreted and an ESP.restart()command is issued.
Apparently the message queue is not cleared because after restart the first message received is /restart and again an ESP.restart() command is issued.
This results in an endless loop. I can break the restart loop by sending the command https://api.telegram.org/bot_token/getUpdates in a web browser, noting the update_id, incrementing it by1, then send the command
https://api.telegram.org/bot_token/getUpdates?offset=<update_id+1>
How can I programmatically update the message queue before issuing the ESP.restart() command?
I tried

getNewMessage(msg);
ESP.restart();

but that does not work.

cotestatnt commented 11 months ago

Hi @sanderkob This is the same issue as https://github.com/cotestatnt/AsyncTelegram2/issues/102

sanderkob commented 11 months ago

Correct, my oversight.