Celeskry commited on
Commit
04c5a2e
·
verified ·
1 Parent(s): ad3c6b3

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +25 -1
main.py CHANGED
@@ -32,6 +32,7 @@ from app.gs_daily import GSDailyApp
32
  from app.invite_logic import DiscordInviteLogic
33
  from app.noi_tu import NoiTuApp
34
  from app.panel_svc import PanelManager, PanelActionRequest
 
35
 
36
  xs_app = XoSoApp()
37
  lq_app = ClLqApp()
@@ -465,4 +466,27 @@ async def control_panel(data: PanelActionRequest, x_api_key: str = Header(None))
465
  res = await panel_app.execute(command=data.command, action=data.action)
466
  if not res["ok"]:
467
  raise HTTPException(status_code=500, detail=res["error"])
468
- return res
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  from app.invite_logic import DiscordInviteLogic
33
  from app.noi_tu import NoiTuApp
34
  from app.panel_svc import PanelManager, PanelActionRequest
35
+ from app.panel_login import PanelLogin
36
 
37
  xs_app = XoSoApp()
38
  lq_app = ClLqApp()
 
466
  res = await panel_app.execute(command=data.command, action=data.action)
467
  if not res["ok"]:
468
  raise HTTPException(status_code=500, detail=res["error"])
469
+ return res
470
+
471
+ PANEL_USER = os.getenv("PANEL_USER")
472
+ PANEL_PASS = os.getenv("PANEL_PASS")
473
+ SERVER_UUID = "45feca4d-3f79-4bcc-ae11-114335a1c77e"
474
+
475
+ @app.get("/api/v1/panel/refresh")
476
+ async def refresh_panel_token(x_api_key: str = Header(None)):
477
+ if x_api_key != API_KEY: raise HTTPException(403)
478
+
479
+ login_svc = PanelLogin(PANEL_USER, PANEL_PASS, SERVER_UUID)
480
+ result = await login_svc.fetch_ws_credentials()
481
+
482
+ if result["ok"]:
483
+ panel_app.update_token(result["token"])
484
+ return {"ok": True, "message": "Token refreshed"}
485
+ else:
486
+ return {"ok": False, "detail": result["error"]}
487
+
488
+ @app.get("/api/v1/panel/debug-img")
489
+ async def get_debug_img():
490
+ if os.path.exists("debug_screenshot.png"):
491
+ return FileResponse("debug_screenshot.png")
492
+ return {"error": "No debug image found"}