mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-13 07:37:17 +03:00
command.go: modifying Theme command to show all available themes (#232)
command.go: modifying Theme command to show all available themes
This commit is contained in:
parent
e800c88a56
commit
227dad7492
@ -3,6 +3,7 @@ package chat
|
||||
// FIXME: Would be sweet if we could piggyback on a cli parser or something.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
@ -180,7 +181,7 @@ func InitCommands(c *Commands) {
|
||||
c.Add(Command{
|
||||
Prefix: "/theme",
|
||||
PrefixHelp: "[colors|...]",
|
||||
Help: "Set your color theme. (More themes: solarized, mono, hacker)",
|
||||
Help: "Set your color theme.",
|
||||
Handler: func(room *Room, msg message.CommandMsg) error {
|
||||
user := msg.From()
|
||||
args := msg.Args()
|
||||
@ -190,8 +191,16 @@ func InitCommands(c *Commands) {
|
||||
if cfg.Theme != nil {
|
||||
theme = cfg.Theme.ID()
|
||||
}
|
||||
body := fmt.Sprintf("Current theme: %s", theme)
|
||||
room.Send(message.NewSystemMsg(body, user))
|
||||
var output bytes.Buffer
|
||||
fmt.Fprintf(&output, "Current theme: %s%s", theme, message.Newline)
|
||||
fmt.Fprintf(&output, " Themes available: ")
|
||||
for i, t := range message.Themes {
|
||||
fmt.Fprintf(&output, t.ID())
|
||||
if i < len(message.Themes)-1 {
|
||||
fmt.Fprintf(&output, ", ")
|
||||
}
|
||||
}
|
||||
room.Send(message.NewSystemMsg(output.String(), user))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user