Fix NPMplus enable/disable request method

This commit is contained in:
2026-02-08 02:35:31 +03:00
parent ea6ad1d5b2
commit 857fa86e85

View File

@@ -34,11 +34,12 @@ def _request_json(
headers: dict[str, str], headers: dict[str, str],
data: dict[str, Any] | None, data: dict[str, Any] | None,
verify_tls: bool, verify_tls: bool,
method: str | None = None,
) -> Any: ) -> Any:
body = None body = None
if data is not None: if data is not None:
body = json.dumps(data).encode("utf-8") body = json.dumps(data).encode("utf-8")
req = Request(url, headers=headers, data=body) req = Request(url, headers=headers, data=body, method=method)
context = None context = None
if not verify_tls: if not verify_tls:
@@ -186,7 +187,7 @@ def set_proxy_host(cfg: dict[str, Any], host_id: int, enabled: bool) -> tuple[bo
"User-Agent": "tg-admin-bot", "User-Agent": "tg-admin-bot",
} }
try: try:
payload = _request_json(url, headers, None, verify_tls) payload = _request_json(url, headers, None, verify_tls, method="POST")
except Exception as e: except Exception as e:
return False, str(e) return False, str(e)
if payload is True or (isinstance(payload, dict) and payload.get("success", True)): if payload is True or (isinstance(payload, dict) and payload.get("success", True)):