# shutdown on SIGINT to allow quit by Ctrl-C (usally just causes requests.exceptions.ConnectionError exception)
def signal_handler(sig, frame):
print ("Shutdown bot...")
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
while True:
try:
bot.polling()
except requests.exceptions.ConnectionError:
print (" ConnectionError exception occured while polling, restart in 1 second...")
sleep(1)
continue
except telebot.apihelper.ApiException:
print (" ApiException exception occured while polling, restart in 1 second...")
sleep(1)
continue
except requests.exceptions.ReadTimeout:
print (" ReadTimeout exception occured while polling, restart in 1 second...")
sleep(1)
continue