Answer the question
In order to leave comments, you need to log in
How to force value to be reset on the timer?
I made a game bot for VK, I decided to add a daily bonus using the time library and the sleep command
def timer(id, level, time):
global users
for user in users:
if user.id == id:
if time == 24:
sleep(24)
user.random_bonus = 0
sender(id, 'Ежедневный бонус доступен', lv1_menu_key)
elif msg == 'бонус':
if user.random_bonus == 2:
sender(id, 'Сегодня вы уже использовали ежедневый бонус', lv1_menu_key)
if user.random_bonus == 0:
user.random_bonus = (random.randint(50,800))
user.coins += user.random_bonus
sender(id, f'Вы получили ежедневый бонус в размере: {user.random_bonus} монет', lv1_menu_key)
user.random_bonus = 2
Thread(target = timer(id, user.level, 24)).start()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question