mirror of
https://github.com/Noettore/lagomareGateKeeperBot.git
synced 2025-10-14 19:16:40 +02:00
28 lines
693 B
Python
28 lines
693 B
Python
import json
|
|
from avconnect import AVConnectAPI
|
|
|
|
GATE_FILE = "./data/gates.json"
|
|
|
|
def load_gates():
|
|
try:
|
|
with open(GATE_FILE, "r") as f:
|
|
return json.load(f)
|
|
except FileNotFoundError:
|
|
return {}
|
|
|
|
def get_name(gate):
|
|
return load_gates().get(str(gate), {}).get("name", "")
|
|
|
|
def open_gate(gate, credentials):
|
|
gate_info = load_gates().get(str(gate), {})
|
|
if not gate_info:
|
|
return False
|
|
gate_id = gate_info["id"]
|
|
|
|
try:
|
|
api = AVConnectAPI(credentials["username"], credentials["password"])
|
|
return api.exec_gate_macro(gate_id)
|
|
except Exception as e:
|
|
print(f"Failed to open gate {gate}: {e}")
|
|
return False
|