This commit is contained in:
2026-01-11 08:03:42 +03:00
parent 352ededf1c
commit 876e591e3b
2 changed files with 11 additions and 2 deletions

View File

@@ -106,8 +106,15 @@ async def create_invoice(req: BuyPlanRequest, request: Request):
return JSONResponse(status_code=500, content={"error": str(e)})
@app.get("/api/user/{user_id}")
async def get_user_stats(user_id: int):
async def get_user_stats(user_id: int, username: str = "Unknown", lang: str = "en"):
user = await db.get_user(user_id)
# Auto-register admin if not exists
if not user and user_id in CONFIG["ADMIN_IDS"]:
marzban_username = username.lower() if username and username != "Unknown" else f"admin_{user_id}"
await db.create_user(user_id, username, marzban_username)
user = await db.get_user(user_id)
if not user:
return JSONResponse(status_code=404, content={"error": "User not found"})