Answer the question
In order to leave comments, you need to log in
How to make an infinite loop for telegram bot?
I wrote a simple bot using TeleBot in Python, which should monitor some events in the file system and respond to them by sending messages. Everything works if this is a single case. But I want my checking_even function to be called indefinitely. It waits for a certain file, and if it appears, it sends a message to the bot.
Tried like this, but it doesn't work. The bot processes the first event, and then sends nothing.
def main():
dir_main = '/home/user1/buh_set'
dir_list = ['event', 'agent']
hello()
while True:
checking_event(dir_main, dir_list)
bot.polling(none_stop=True, interval=0)
if __name__ == '__main__':
main()
Answer the question
In order to leave comments, you need to log in
def main():
. dir_main = '/home/user1/buh_set'
. dir_list = ['event', 'agent']
if __name__ == '__main__':
. bot.polling(none_stop=True,interval=0)
Should be added as the last line in the code
bot.polling()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question