Skip to content

Commit

Permalink
display online user's name instead of number
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrtye committed Mar 20, 2024
1 parent bb26a2f commit 7bbe3d6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apiserver/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import time
import json
import math
import random
import pandas
import yfinance
import requests
Expand Down Expand Up @@ -128,13 +129,17 @@ def bytes_to_speed(bytes, decimal_place=2):
return format_bytes(bytes, decimal_place) + "/s"


def get_xui_status():
def xui_login():
if xui_session.post(XUI_URL + "/panel/inbound/onlines").status_code != 200:
xui_session.post(
XUI_URL + "/login",
data={"username": XUI_USERNAME, "password": XUI_PASSWORD},
)


def get_xui_status():
xui_login()

status = xui_session.post(XUI_URL + "/server/status")
online = xui_session.post(XUI_URL + "/panel/inbound/onlines")

Expand All @@ -145,7 +150,7 @@ def get_xui_status():
"up": bytes_to_speed(status["obj"]["netIO"]["up"]),
"down": bytes_to_speed(status["obj"]["netIO"]["down"]),
"usage": format_bytes(status["obj"]["netTraffic"]["recv"]),
"online": len(online["obj"]) if online["obj"] else 0,
"online": random.choice(online["obj"]) if online["obj"] else '-',
}
return info

Expand Down

0 comments on commit 7bbe3d6

Please sign in to comment.