Forums

Telegram bot responds to all commands that were posted while it's off

I'm making a telegram bot using python-telegram-bot, and if i send some commands while the bot isn't running, and after that i run the bot, it's gonna reply to all the commands that were posted. Is there a way to prevent this from happening?

I don't know the Telegram API well, but perhaps there's some kind of timestamp on each message that you receive? If so, you could store the datetime when the bot was started somewhere, and then when it receives a message you could compare it to that time, and discard any messages with an earlier timestamp.

Nice, thanks!