feat: add /user command (#5)
All checks were successful
Build / Upload to production (push) Successful in 1m43s

Reviewed-on: #5
Co-authored-by: mctaylors <cantsendmails@mctaylors.ru>
Co-committed-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2025-06-08 10:59:52 +03:00 committed by Forgejo
parent 6ccf2ace4a
commit 86e9c04e1e
Signed by: Forgejo
GPG key ID: F2B3CB736682B201
3 changed files with 271 additions and 4 deletions

View file

@ -1,7 +1,7 @@
import re
import requests
from typing import Any
from typing import Any, Optional
from config import app
@ -57,8 +57,12 @@ def format_status(data) -> str:
return " ".join(status)
def get_json(pathname: str) -> Any | None:
r = requests.get(f"http://{app.host}/{pathname}.json")
def get_json(pathname: str, query: Optional[list] = None) -> Any | None:
url = [f"http://{app.host}/{pathname}.json"]
if query is not None:
url.append("?")
url.append("&".join(query))
r = requests.get("".join(url))
if r.status_code != 200:
return None