mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-22 19:50:33 +03:00
command.go: colorizing names according to theme (#205)
This commit is contained in:
parent
0cb58facef
commit
e5883e1ec0
@ -173,9 +173,15 @@ func InitCommands(c *Commands) {
|
||||
Prefix: "/names",
|
||||
Help: "List users who are connected.",
|
||||
Handler: func(room *Room, msg message.CommandMsg) error {
|
||||
// TODO: colorize
|
||||
names := room.NamesPrefix("")
|
||||
body := fmt.Sprintf("%d connected: %s", len(names), strings.Join(names, ", "))
|
||||
names := room.Members.ListPrefix("")
|
||||
colNames := make([]string, len(names))
|
||||
theme := msg.From().Config().Theme
|
||||
|
||||
for i, uname := range names {
|
||||
colNames[i] = theme.ColorName(uname.Value().(*Member).User)
|
||||
}
|
||||
|
||||
body := fmt.Sprintf("%d connected: %s", len(colNames), strings.Join(colNames, ", "))
|
||||
room.Send(message.NewSystemMsg(body, msg.From()))
|
||||
return nil
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user