-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed as not planned
Closed as not planned
Copy link
Labels
📋 stalework status: stalework status: stale
Description
Issue I am facing
python-telegram-bot + flask + gunicorn
webserice start success
webhook url register success
update passed to webhook success
update put in update_queue success
the problem is commandHandler never get triggered!
what i do wrong?
btw, my app is deployed on render webservice, i start the application by call gunicorn setup:web_app
Traceback to the issue
No response
Related part of your code
web_app = Flask(__name__)
application = None
telegram_bot_token = "h5s"
url = "https://botify-uncx.onrender.com"
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
print('response start') # never got triggered
user = update.effective_user
await update.message.reply_html(
rf"Hi {user.mention_html()}!",
reply_markup=ForceReply(selective=True),
)
def init_web_server():
@web_app.route('/telegram', methods=['GET', 'POST'])
async def telegram():
global application
if request.method == 'POST':
print(request.json)
await application.update_queue.put(
Update.de_json(data= request.json , bot=application.bot)
)
print("queue updated")
return Response('ok', status=200)
else:
return "<h1>Welcome!</h1>"
@web_app.route('/')
def hello_world():
return 'Hello, Worldd!'
# web_app.run(debug=True) this line is comment out because app is started by [gunicorn setup:web_app],setup is my python filename ,web_app is the flask app
async def init_application():
global application
application = Application.builder().token(telegram_bot_token).build()
application.add_handler(CommandHandler("start", start))
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, echo))
await application.bot.set_webhook(url=f"{url}/telegram")
async with application:
await application.start()
await application.stop()
async def main():
await init_application()
init_web_server()
# if __name__ == "__main__":
asyncio.run(main())Operating System
Linux
Version of Python, python-telegram-bot & dependencies
python-telegram-bot v20.xMetadata
Metadata
Assignees
Labels
📋 stalework status: stalework status: stale