mirror of
https://github.com/Noettore/lagomareGateKeeperBot.git
synced 2025-10-15 03:26:40 +02:00
Refactor and start implementing inline keyboards
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user