H
H
hey_umbrella2021-07-17 00:07:19
Python
hey_umbrella, 2021-07-17 00:07:19

How to add a function immediately at the start of the telebot bot?

I need to add a function where an infinite loop immediately to the start of the bot, how to do this? Add to if __name__ == '__main__'?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexa2007, 2021-07-17
@hey_umbrella

class Mybot(telebot.TeleBot):
    def __init__(self,arg, *args, **kwargs):
        super().__init__(arg, *args, **kwargs)

    def loop_poop(self):
        while True:
            time.sleep(15)
            print(time.ctime())

    def polling(self, *args, **kwargs):
        thread = threading.Thread(target=self.loop_poop)
        thread.start()
        super().polling(*args, **kwargs)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question