From c681a5c1d7f1285a2df7bb5ef0154aabbc332ba7 Mon Sep 17 00:00:00 2001 From: Hosein Date: Thu, 8 Jan 2026 13:12:34 +0330 Subject: [PATCH] fixed issue not responding to callback updates --- main.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index 235ac42..0854136 100644 --- a/main.py +++ b/main.py @@ -17,26 +17,24 @@ async def telegram_webhook(request: Request): try: import telebot from bot.bot import get_bot - + bot = get_bot() json_data = await request.json() - + logger.info(f"Received update: {json_data}") - + update = telebot.types.Update.de_json(json_data) - - # Process the update directly instead of using process_new_updates - if update.message: - try: - # Call your message handlers directly - bot.process_new_updates([update]) - except Exception as e: - logger.error(f"Error processing update: {e}") - # Still return 200 to Telegram to acknowledge receipt - return JSONResponse(content={"ok": True}, status_code=200) - + + # Process ALL types of updates (messages, callback queries, etc.) + try: + bot.process_new_updates([update]) + except Exception as e: + logger.error(f"Error processing update: {e}") + # Still return 200 to Telegram to acknowledge receipt + return JSONResponse(content={"ok": True}, status_code=200) + return JSONResponse(content={"ok": True}, status_code=200) - + except Exception as e: logger.error(f"Webhook error: {e}") # Return 200 even on error to prevent Telegram from retrying @@ -54,4 +52,4 @@ def read_root(): if __name__ == "__main__": import uvicorn - uvicorn.run("main:app", host="0.0.0.0", port=5001, reload=True) \ No newline at end of file + uvicorn.run("main:app", host="0.0.0.0", port=5001, reload=True)