mirror of
https://github.com/Noettore/lagomareGateKeeperBot.git
synced 2025-10-14 19:16:40 +02:00
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
import requests
|
|
import pprint
|
|
|
|
BASE_URL = "https://www.avconnect.it"
|
|
|
|
class AVConnectAPI:
|
|
def __init__(self, username: str, password: str):
|
|
self.username = username
|
|
self.password = password
|
|
self.session = requests.Session()
|
|
self.authenticated = False
|
|
|
|
def authenticate(self) -> bool:
|
|
login_url = f"{BASE_URL}/loginone.php"
|
|
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
|
|
return False
|
|
|
|
def exec_gate_macro(self, id_macro) -> requests.Response:
|
|
if not self.authenticated and not self.authenticate():
|
|
raise Exception("Authentication failed.")
|
|
|
|
exec_url = f"{BASE_URL}/exemacrocom.php"
|
|
headers = {
|
|
"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 |