mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-15 00:20:37 +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.
|
// FIXME: Would be sweet if we could piggyback on a cli parser or something.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
@ -180,7 +181,7 @@ func InitCommands(c *Commands) {
|
|||||||
c.Add(Command{
|
c.Add(Command{
|
||||||
Prefix: "/theme",
|
Prefix: "/theme",
|
||||||
PrefixHelp: "[colors|...]",
|
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 {
|
Handler: func(room *Room, msg message.CommandMsg) error {
|
||||||
user := msg.From()
|
user := msg.From()
|
||||||
args := msg.Args()
|
args := msg.Args()
|
||||||
@ -190,8 +191,16 @@ func InitCommands(c *Commands) {
|
|||||||
if cfg.Theme != nil {
|
if cfg.Theme != nil {
|
||||||
theme = cfg.Theme.ID()
|
theme = cfg.Theme.ID()
|
||||||
}
|
}
|
||||||
body := fmt.Sprintf("Current theme: %s", theme)
|
var output bytes.Buffer
|
||||||
room.Send(message.NewSystemMsg(body, user))
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user