Answer the question
In order to leave comments, you need to log in
How to save the state of a telegram bot user?
I am writing a Telegram bot in Python for educational purposes without using third-party libraries. The bot implements vocabulary cards for learning a foreign language. Work algorithm: there is a set of 100 words, the bot simultaneously trains 10 words from the set until the user marks any word as learned, then this word is removed from the trained ones and a new one is added from the remaining 90. Question: how to implement the possibility of using bot by several users? I'm thinking of connecting an SQlite database and recording the state after each change. But changes can be too frequent and the database will have to be read every time the user interacts. Isn't it too expensive for the performance of the bot?
Answer the question
In order to leave comments, you need to log in
Take a normal base. MySQL or Postges for example. It is possible some other, but not sqlite
Take ordinary txt files. The database of users will be written to one, and one belongs to each user, where the current state of it is stored. With each request, check if there is a user in the first file, if there is, then the current state is being checked. It will always be possible to transfer everything to the database later, so as not to spend a lot of time studying now.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question