def handle(self, *args, **options): print("Started Development Bot Client") try: bot.polling() except Exception as e: print(e) time.sleep(5) self.handle(*args, **options)
def handle(self, *args, **options): bot.polling()
from bot.bot import bot if __name__ == "__main__": bot.polling()
if __name__ == "__main__": args = sys.argv args.pop(0) say = "init" if len(args) > 0: say = "update" # Init Bot init(bot) # Bot settings bot.enable_save_next_step_handlers(delay=2) bot.load_next_step_handlers() say_hello(say) try: while True: # Configure initial data # init_operatives() # Show user message print("Server started") # Run the bot bot.polling(timeout=3000, long_polling_timeout=3000, skip_pending=True, allowed_updates=True) sleep(2) except Exception as e: print("Error:", e)
import telebot from aiohttp import web from bot.bot import bot, config if __name__ == "__main__": if config.APP_RUN_METHOD == 'polling': bot.remove_webhook() bot.polling(none_stop=True, timeout=9999) elif config.APP_RUN_METHOD == 'webhook': app = web.Application() async def handle(request): if request.match_info.get('token') == bot.token: request_body_dict = await request.json() update = telebot.types.Update.de_json(request_body_dict) bot.process_new_updates([update]) return web.Response() else: return web.Response(status=403) app.router.add_post('/{token}/', handle) web.run_app(app, host="0.0.0.0", port=443)
def bot_thread(): bot.polling()
def handle(self, *args, **options): bot.delete_webhook() self.logger.info('Starting local bot...') bot.polling(none_stop=True)