def webhook(): bot.remove_webhook() bot.set_webhook(url='https://lizatish-telegram-bot.herokuapp.com/' + app.config['TELEGRAM_TOKEN']) # bot.set_webhook(url='https://7308fa93b393.ngrok.io/' + app.config['TELEGRAM_TOKEN']) return "!", 200
def webhook(): try: bot.remove_webhook() time.sleep(0.4) bot.set_webhook(Config.URL + Config.secret) print("webhook set") except Exception as e: bot.send_message(message.chat.id, text="Ошибка " + str(e)) return "Ошибка ", e return "!", 200
def set_webhook(): bot.remove_webhook() if DEBUG: res = bot.set_webhook(f'{NGROK_DEPLOY_DOMAIN}/{TOKEN}') else: res = bot.set_webhook(f'{HEROKU_DEPLOY_DOMAIN}/{TOKEN}') if res: return "webhook setup ok" else: return "webhook setup failed"
def web_hook(): bot.remove_webhook() bot.set_webhook(url=config.URL + config.TOKEN) return "!", 200
def webhook(): """Установка webhook'a """ bot.remove_webhook() bot.set_webhook(url=current_app.config["WEB_HOOK_URL"] + "setwebhook") return "!", 200
#!/usr/bin/env python3 from config import sys_log, SERVER_FLAG from server import serv_start from app import bot if __name__ == "__main__": if SERVER_FLAG: serv_start(bot) sys_log.info('Running in server mode') else: bot.remove_webhook() sys_log.info('Running in poll mode') bot.polling(none_stop=True)
def webhook(): bot.remove_webhook() bot.set_webhook(url='https://python-review-test-bot.herokuapp.com/' + BOT_TOKEN) return "!", 200
import time from app import bot, WEBHOOK_HOST, WEBHOOK_PATH webhook_url = WEBHOOK_HOST + WEBHOOK_PATH print(bot.remove_webhook()) time.sleep(3) print('Webhook set to', webhook_url) print(bot.set_webhook(url=webhook_url))
if (expert.ActiveUserId > 0): bot.send_message(expert.UserChatId, message.text) else: bot.reply_to(message, "First wait a question!") # if message from user than send message to expert else: experts1 = models.Users.query.filter_by(ActiveUserId=message.from_user.id) if (experts1.count() > 0): expert1 = experts1.first() bot.send_message(expert1.ExpertChatId, message.text) else: bot.reply_to(message, "First find the expert!") """ #bot.polling() # Remove webhook, it fails sometimes the set if there is a previous webhook bot.remove_webhook() bot.set_webhook(url=WEBHOOK_URL_BASE+WEBHOOK_URL_PATH, certificate=open(WEBHOOK_SSL_CERT, 'r')) #print WEBHOOK_SSL_CERT #print WEBHOOK_SSL_PRIV # Start flask server if __name__ == "__main__": app.run() # app.run(host=WEBHOOK_LISTEN, # port=WEBHOOK_PORT, # ssl_context=(WEBHOOK_SSL_CERT, WEBHOOK_SSL_PRIV), # debug=True)