Refactor and start implementing inline keyboards

This commit is contained in:
2025-05-19 23:58:17 +02:00
parent 4a3d2746fb
commit 020b5e0193
7 changed files with 291 additions and 274 deletions

View File

@@ -1,5 +1,4 @@
import requests
import pprint
from fake_useragent import UserAgent
from commons import Credential
@@ -15,12 +14,9 @@ class AVConnectAPI:
def _authenticate(self) -> bool:
login_url = f"{self._BASE_URL}/loginone.php"
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
payload = f"userid={self._username}&password={self._password}&entra=Login"
response = self._session.post(login_url, data=payload, headers=headers)
if response.ok and "PHPSESSID" in self._session.cookies:
self._authenticated = True
return True
@@ -29,18 +25,13 @@ class AVConnectAPI:
def exec_gate_macro(self, id_macro) -> bool:
if not self._authenticated and not self._authenticate():
raise Exception("Authentication failed.")
exec_url = f"{self._BASE_URL}/exemacrocom.php"
headers = {
"User-Agent": self._ua,
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
}
payload = f"idmacrocom={id_macro}&nome=16"
response = self._session.prepare_request(requests.Request("POST", exec_url, data=payload, headers=headers))
pprint.pprint(response.headers)
return True
#response = self._session.post(exec_url, data=payload, headers=headers)
#if response.ok:
# return True
#return False
# Uncomment for real request:
# response = self._session.post(exec_url, data=payload, headers=headers)
# return response.ok
return True # For testing