List contacts alphabetically

This commit is contained in:
Andrew Ferrazzutti 2021-07-22 03:16:20 -04:00
parent f39781cdcc
commit 0dd2cf60b1
1 changed files with 1 additions and 0 deletions

View File

@ -26,6 +26,7 @@ SECTION_CHATS = HelpSection("Contacts & Chats", 40, "")
async def list_contacts(evt: CommandEvent) -> None:
# TODO Use a generator if it's worth it
puppets = await pu.Puppet.get_all()
puppets.sort(key=lambda puppet: puppet.name)
results = "".join(f"* [{puppet.name}](https://matrix.to/#/{puppet.default_mxid})\n"
for puppet in puppets)
if results: