mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Integrated blocking into polling + updated docs
This commit is contained in:
@ -136,7 +136,7 @@ class TeleBot:
|
||||
else:
|
||||
listener(new_messages)
|
||||
|
||||
def polling(self, none_stop=False, interval=0):
|
||||
def polling(self, none_stop=False, interval=0, block=True):
|
||||
"""
|
||||
This function creates a new Thread that calls an internal __polling function.
|
||||
This allows the bot to retrieve Updates automagically and notify listeners and message handlers accordingly.
|
||||
@ -155,6 +155,10 @@ class TeleBot:
|
||||
self.polling_thread.daemon = True
|
||||
self.polling_thread.start()
|
||||
|
||||
if block:
|
||||
self.__stop_polling.wait()
|
||||
|
||||
|
||||
def __polling(self, none_stop, interval):
|
||||
logger.info('TeleBot: Started polling.')
|
||||
while not self.__stop_polling.wait(interval):
|
||||
|
Reference in New Issue
Block a user