Software /
code /
prosody
Changeset
12868:d5cb86b84d12
mod_admin_shell: Use tables to present MUC users
Tables are awesome!
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 29 Jan 2023 18:31:25 +0100 |
parents | 12867:2defb0fc2be9 |
children | 12869:70ee82579076 |
files | plugins/mod_admin_shell.lua |
diffstat | 1 files changed, 18 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_admin_shell.lua Sun Jan 29 17:55:56 2023 +0100 +++ b/plugins/mod_admin_shell.lua Sun Jan 29 18:31:25 2023 +0100 @@ -1401,11 +1401,19 @@ end local print = self.session.print; + local row = format_table({ + { title = "Role"; width = #"participant"; key = "role" }; -- longest role name + { title = "JID"; width = "75%"; key = "bare_jid" }; + { title = "Nickname"; width = "25%"; key = "nick"; mapper = jid_resource }; + }, self.session.width); local total, displayed = 0, 0; for nick_jid, occupant in room_obj:each_occupant() do + if total == 0 then + print(row()); + end local nick = jid_resource(nick_jid); if filter == nil or occupant.role == filter or nick:find(filter, 1, true) then - print(occupant.role, nick); + print(row(occupant)); displayed = displayed + 1; end total = total + 1 @@ -1425,10 +1433,18 @@ end local print = self.session.print; + local row = format_table({ + { title = "Affiliation"; width = #"outcast" }; -- longest affiliation name + { title = "JID"; width = "75%" }; + { title = "Nickname"; width = "25%"; key = "reserved_nickname" }; + }, self.session.width); local total, displayed = 0, 0; for affiliated_jid, affiliation, affiliation_data in room_obj:each_affiliation() do + if total == 0 then + print(row()); + end if filter == nil or affiliation == filter or affiliated_jid:find(filter, 1, true) then - print(affiliation, affiliated_jid, affiliation_data and affiliation_data.reserved_nickname or "") + print(row(setmetatable({ affiliation; affiliated_jid }, { __index = affiliation_data }))) displayed = displayed + 1; end total = total + 1