Update main.py
Browse files
main.py
CHANGED
|
@@ -31,6 +31,7 @@ from app.gm_crate import GmailLogic
|
|
| 31 |
from app.gs_daily import GSDailyApp
|
| 32 |
from app.invite_logic import DiscordInviteLogic
|
| 33 |
from app.noi_tu import NoiTuApp
|
|
|
|
| 34 |
|
| 35 |
xs_app = XoSoApp()
|
| 36 |
lq_app = ClLqApp()
|
|
@@ -445,4 +446,23 @@ async def get_xsmn(type: str = Query("latest"), date: Optional[str] = Query(None
|
|
| 445 |
if not res["ok"]:
|
| 446 |
raise HTTPException(status_code=400, detail=res["error"])
|
| 447 |
return res
|
| 448 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
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()
|
|
|
|
| 446 |
if not res["ok"]:
|
| 447 |
raise HTTPException(status_code=400, detail=res["error"])
|
| 448 |
return res
|
| 449 |
+
|
| 450 |
+
panel_app = PanelManager(
|
| 451 |
+
ws_url="wss://stratos.pikamc.vn:8080/api/servers/45feca4d-3f79-4bcc-ae11-114335a1c77e/ws",
|
| 452 |
+
origin="https://cp.pikamc.vn"
|
| 453 |
+
)
|
| 454 |
+
|
| 455 |
+
@app.post("/api/v1/panel/token")
|
| 456 |
+
async def update_token(token: str = Body(..., embed=True), x_api_key: str = Header(None)):
|
| 457 |
+
if x_api_key != API_KEY: raise HTTPException(status_code=403)
|
| 458 |
+
panel_app.update_token(token)
|
| 459 |
+
return {"ok": True, "message": "Token updated successfully"}
|
| 460 |
+
|
| 461 |
+
@app.post("/api/v1/panel/control")
|
| 462 |
+
async def control_panel(data: PanelActionRequest, x_api_key: str = Header(None)):
|
| 463 |
+
if x_api_key != API_KEY: raise HTTPException(status_code=403)
|
| 464 |
+
|
| 465 |
+
res = await panel_app.send_and_get_stats(command=data.command, action=data.action)
|
| 466 |
+
if not res["ok"]:
|
| 467 |
+
raise HTTPException(status_code=500, detail=res["error"])
|
| 468 |
+
return res
|