N
N
Nikita228Gym2021-04-01 00:22:49
Python
Nikita228Gym, 2021-04-01 00:22:49

A game bot with a database for conversations in VK in Python, can you help with the creation?

you can help with the creation of a bot for a conversation in VK with a database

, the essence of the bot is that each user would receive the nth amount of game currency every 15 minutes, there was also a pumping store.

please help me with this, well, or explain how it can be implemented, please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MinTnt, 2021-04-01
@MinTnt

Since the check every 15 seconds of the balance, and the very constant addition of the balance to absolutely all users will be very heavy. It is better to do this: add the parameter of the last balance check to the database. time.time(), and then, when the user enters the balance command again, the corresponding value is set in the database at that moment;
money( Money recorded in the database ) + (time.time() - int( Time of the last balance update recorded in the database )) // 15
This will reduce the load, and create the illusion that money is added every 15 seconds.
Cons - if the user constantly checks the balance or so on, he may not be charged every 15 seconds, since the time between requests will be constantly updated.
The solution is to store in the database only the time when

money + (time.time() - int(update_balance_time)) // 15

Is greater than zero, if less, then do not update the value in the database

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question