MultiServer: Support location name groups in !missing and !checked commands (#2538)

This commit is contained in:
NewSoupVi 2024-04-14 20:22:12 +02:00 committed by GitHub
parent f1765899c4
commit 7c44d749d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 2 deletions

View File

@ -1345,6 +1345,7 @@ class ClientMessageProcessor(CommonCommandProcessor):
"Sorry, !remaining requires you to have beaten the game on this server") "Sorry, !remaining requires you to have beaten the game on this server")
return False return False
@mark_raw
def _cmd_missing(self, filter_text="") -> bool: def _cmd_missing(self, filter_text="") -> bool:
"""List all missing location checks from the server's perspective. """List all missing location checks from the server's perspective.
Can be given text, which will be used as filter.""" Can be given text, which will be used as filter."""
@ -1354,6 +1355,10 @@ class ClientMessageProcessor(CommonCommandProcessor):
if locations: if locations:
names = [self.ctx.location_names[location] for location in locations] names = [self.ctx.location_names[location] for location in locations]
if filter_text: if filter_text:
location_groups = self.ctx.location_name_groups[self.ctx.games[self.client.slot]]
if filter_text in location_groups: # location group name
names = [name for name in names if name in location_groups[filter_text]]
else:
names = [name for name in names if filter_text in name] names = [name for name in names if filter_text in name]
texts = [f'Missing: {name}' for name in names] texts = [f'Missing: {name}' for name in names]
if filter_text: if filter_text:
@ -1365,6 +1370,7 @@ class ClientMessageProcessor(CommonCommandProcessor):
self.output("No missing location checks found.") self.output("No missing location checks found.")
return True return True
@mark_raw
def _cmd_checked(self, filter_text="") -> bool: def _cmd_checked(self, filter_text="") -> bool:
"""List all done location checks from the server's perspective. """List all done location checks from the server's perspective.
Can be given text, which will be used as filter.""" Can be given text, which will be used as filter."""
@ -1374,6 +1380,10 @@ class ClientMessageProcessor(CommonCommandProcessor):
if locations: if locations:
names = [self.ctx.location_names[location] for location in locations] names = [self.ctx.location_names[location] for location in locations]
if filter_text: if filter_text:
location_groups = self.ctx.location_name_groups[self.ctx.games[self.client.slot]]
if filter_text in location_groups: # location group name
names = [name for name in names if name in location_groups[filter_text]]
else:
names = [name for name in names if filter_text in name] names = [name for name in names if filter_text in name]
texts = [f'Checked: {name}' for name in names] texts = [f'Checked: {name}' for name in names]
if filter_text: if filter_text: