Implement lexicon-player-list

This commit is contained in:
Tim Van Baak 2020-01-19 07:43:41 -08:00
parent 851f08b5f3
commit 3c62acc975
2 changed files with 20 additions and 8 deletions

View File

@ -179,7 +179,25 @@ def command_player_list(args):
"""
List all players in a lexicon
"""
raise NotImplementedError() # TODO
import json
# Module imports
from lexicon import LexiconModel
from user import UserModel
# Verify arguments
lex = LexiconModel.by(name=args.lexicon)
if lex is None:
logger.error("Could not find lexicon '{}'".format(args.lexicon))
return -1
# Internal call
players = []
for uid in lex.join.joined:
u = UserModel.by(uid=uid)
players.append(u.username)
print(json.dumps(players, indent=2))
@requires_lexicon
@requires_username

View File

@ -155,10 +155,4 @@ def remove_player(lex, player):
if player.id in cfg.join.joined:
cfg.join.joined.remove(player.id)
# TODO Reassign the player's characters to the editor
def list_players(lex):
"""
"""
pass
# TODO Reassign the player's characters to the editor