问题
I recently coded a simple telegram bot using the python-telegram-bot library, and deployed this bot on Heroku. Now i'm looking for an effective way to make the bot persistent, allowing it to store Bot_data and user_data between runs. I took a look at the persistence classes the library offers and i understood that PicklePersistence would not work with heroku's "ephemeral" hard drive. My question is, how can i implement the bot's persistence to make it work on heroku? Should i give up storing the bot_data and change the design to rely on an external database where to store the data i need?
回答1:
I would suggest and try to implement a database for your telegram bot. This will take your bot to a next level, where you would also be able to connect a webapp to the database and add more functionality there.
To start you can try the free tier of MongoDB atlas database. You could use this database to store your data and get it when needed.
You could also look at other database solutions of course.
来源:https://stackoverflow.com/questions/60610369/making-a-python-telegram-bot-persistent