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

@@ -13,7 +13,7 @@ class AccessControl:
return json.load(f)
except FileNotFoundError:
return {}
def _save_access(self):
with open(self._ACCESS_FILE, "w") as f:
json.dump(self._access, f)
@@ -21,12 +21,12 @@ class AccessControl:
def get_grantor(self, user_id: str, gate: str) -> str:
access = self._access.get(user_id, {})
entry = access.get(gate) or access.get("all")
return entry.get("grantor", "")
return entry.get("grantor", "") if entry else ""
def can_open_gate(self, user_id: str, gate: str) -> bool:
access = self._access.get(user_id, {})
entry = access.get(gate) or access.get("all")
if not entry or entry["type"] != "timed":
if not entry or entry.get("type") != "timed":
return False
if datetime.now(timezone.utc) < datetime.fromisoformat(entry["expires_at"].replace("Z", "+00:00")):
return True