How to create timer for bot to reply

Viewed 33

I am writing a bot that will take a note and the time after which it will need to be sent back. How can I implement the timer mechanism. Here are the functions:

@bot.message_handler(commands=["note"])
def make_notion(message):
    bot.send_message(message.chat.id, "What do you want me to remind you of?")
    bot.register_next_step_handler(message, reg_note)


def reg_note(message):
    global note
    note = message.text
    bot.send_message(
        message.chat.id,
        f"Get it, wheh do I need to remind you that you have to {note} . Send me time if format : 15 30",
    )
    bot.register_next_step_handler(message, get_time)


def get_time(message):
    global times
    times = message.text
    bot.send_message(message.chat.id, "Ok, I'm goint to sleep waiting till this time")
    time.sleep(
        (int(times[0:2]) + datetime.now().hour) * 360
        + (int(times[3:5]) + datetime.now().minute) * 60
    )
    bot.send_message(message.chat.id, f"You have to {note}!")

I created not working timer :(

0 Answers
Related