C
C
Cellahar2021-10-05 18:22:11
Python
Cellahar, 2021-10-05 18:22:11

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


Tell me how to call the checking_even function together with the bot.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Nikitin, 2021-10-05
@pydroider3

def main():
. dir_main = '/home/user1/buh_set'
. dir_list = ['event', 'agent']
if __name__ == '__main__':
. bot.polling(none_stop=True,interval=0)

I
InternetMaster, 2021-10-08
@InternetMaster

Should be added as the last line in the code
bot.polling()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question