ProfessorCEO commited on
Commit
e7616df
·
verified ·
1 Parent(s): 3737dd0

Upload gateway.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. gateway.py +2 -2
gateway.py CHANGED
@@ -591,14 +591,14 @@ def devos_webhook(payload: DevOSWebhookPayload):
591
  # -------------------------------------------------------------
592
  @app.post("/api/telegram")
593
  @app.post("/telegram")
594
- async def telegram_webhook(request: Request):
595
  bot_token = os.environ.get("TELEGRAM_BOT_TOKEN", "").strip()
596
  if not bot_token:
597
  return {"status": "skipped", "reason": "TELEGRAM_BOT_TOKEN not set"}
598
  try:
599
  body = await request.json()
600
  import telegram_bot
601
- telegram_bot.handle_update(body, bot_token)
602
  return {"status": "ok"}
603
  except Exception as e:
604
  print(f"❌ Telegram Webhook error: {e}", flush=True)
 
591
  # -------------------------------------------------------------
592
  @app.post("/api/telegram")
593
  @app.post("/telegram")
594
+ async def telegram_webhook(request: Request, background_tasks: BackgroundTasks):
595
  bot_token = os.environ.get("TELEGRAM_BOT_TOKEN", "").strip()
596
  if not bot_token:
597
  return {"status": "skipped", "reason": "TELEGRAM_BOT_TOKEN not set"}
598
  try:
599
  body = await request.json()
600
  import telegram_bot
601
+ background_tasks.add_task(telegram_bot.handle_update, body, bot_token)
602
  return {"status": "ok"}
603
  except Exception as e:
604
  print(f"❌ Telegram Webhook error: {e}", flush=True)