mirror of
https://github.com/Noettore/lagomareGateKeeperBot.git
synced 2025-10-15 03:26:40 +02:00
First commit. Lot to do...
This commit is contained in:
27
gates.py
Normal file
27
gates.py
Normal file
@@ -0,0 +1,27 @@
|
||||
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
|
Reference in New Issue
Block a user