H
H
Herben2021-08-21 09:22:56
Python
Herben, 2021-08-21 09:22:56

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()


For example, I set 24, but after the timer starts, the bot refuses to respond to commands until the timer expires

612099649226e460588593.png

. How to make the bot can be used while the timer is running?
Forgive me if this is a stupid question, how much Google did not find anything Thanks in advance

!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
HemulGM, 2021-08-21
@HemulGM

You need to google like this "Python Basics"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question