Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question