'Python asyncio bot with MongoDB
My experience in developing bots is very small and I recently had some problems... I need your help, options. This would be a great experience for me.
- I need to make an asyncio Bot with automatic points for users (about 20000 users) every 10 minutes without lags and stopping the bot. My solution is to use Thread (library threading), but it takes a long time (about 20 minutes).
Question: Is there a better solution than this, since I'm pretty sure it's not the most efficient way to solve my problem?
while True:
# Thread for function to accrual points
pay_users = threading.Thread(
target=pay_function, args=[state, money])
# Thread start
pay_users.start()
while True:
# Check the end of thread
if pay_users.is_alive() is True:
await asyncio.sleep(5)
else:
# If Thread has been completed - join this Thread
pay_users.join()
break
# Every 10 minutes
await asyncio.sleep(600)
- By the way, there is 1 other question that worries me. Let's say each user has a certain bonus that can be used(activated) every 24 hours. After the user has taken the bonus, he can click on the button and check how much time is left to restore the bonus. I want to make it so that when the user's ability to activate the bonus is restored, he will be informed about it. I thought about it and I came up with a trivial solution - at the moment of clicking on the bonus change the date field in the database to the date of the click, but I don't know how to make a notification with this solution about restoring the bonus.
Question: Is there any way to make an individual counter for each user, at the end of which to send a message to the function to notify the user about it?
Thank you very much in advance for your attention and trying to help me!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
