From 2e4ce56cf50682786e2ae52b9917e247c74e0011 Mon Sep 17 00:00:00 2001 From: Metroid_Skittles Date: Fri, 6 Feb 2026 18:37:19 +0100 Subject: [PATCH] Update torchlight_changes_unloze/torchlight3/Torchlight/Commands.py --- .../torchlight3/Torchlight/Commands.py | 62 +++++++++++++++++-- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/torchlight_changes_unloze/torchlight3/Torchlight/Commands.py b/torchlight_changes_unloze/torchlight3/Torchlight/Commands.py index 5ee7697..d32821e 100755 --- a/torchlight_changes_unloze/torchlight3/Torchlight/Commands.py +++ b/torchlight_changes_unloze/torchlight3/Torchlight/Commands.py @@ -596,12 +596,62 @@ class Access(BaseCommand): args = message[1].strip() if len(message) > 1 and message[1] else "" if args: - player_level = self._get_player_level(player) - if player_level >= 6: - admin_cmd = AdminAccess(self.Torchlight) - return await admin_cmd._modify_access(args, player, tl) - tl.SayPrivate(player, "[ACCESS] Admin level required to modify access") - return 1 + is_set = False + if " as " in args: + is_set = True + else: + parts = args.rsplit(" ", 1) + if len(parts) == 2: + last = parts[1].strip() + if last == "revoke" or last.lstrip('-').isdigit(): + is_set = True + + if is_set: + player_level = self._get_player_level(player) + if player_level >= 6: + admin_cmd = AdminAccess(self.Torchlight) + return await admin_cmd._modify_access(args, player, tl) + tl.SayPrivate(player, "[ACCESS] Admin level required to modify access") + return 1 + + # Lookup access for a named player + search_term = args.lower() + count = 0 + max_results = 3 + + if args.startswith('#') and args[1:].isdigit(): + p = tl.Players.FindUserID(int(args[1:])) + if p: + tl.SayChat(format_player_access(tl, p)) + return 0 + + for p in tl.Players: + if search_term in p.Name.lower(): + tl.SayChat(format_player_access(tl, p)) + count += 1 + if count >= max_results: + return 0 + + try: + for unique_id, access_info in tl.Access: + try: + if search_term in access_info["name"].lower(): + tl.SayChat( + f'#{unique_id} "{access_info["name"]}"({unique_id}) ' + f'is level {access_info["level"]} and currently offline.' + ) + count += 1 + if count >= max_results: + return 0 + except (KeyError, TypeError): + continue + except Exception as e: + self.Logger.error(f"Error iterating Access list in !access: {e}") + tl.SayPrivate(player, f"[ACCESS] Error: {str(e)}") + + if count == 0: + tl.SayPrivate(player, f"[ACCESS] No matches for: {args}") + return 0 tl.SayChat(format_player_access(tl, player), player) return 0