Making a Python-Telegram-Bot persistent

大兔子大兔子 提交于 2021-02-10 04:10:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!