Print the motd if no parameters are passed

This commit is contained in:
Aaron 2016-08-02 09:30:21 +03:00
parent 61e8442cf5
commit 5a7db119fa

14
host.go
View File

@ -425,12 +425,18 @@ func (h *Host) InitCommands(c *chat.Commands) {
PrefixHelp: "[MESSAGE]",
Help: "Set a new message of the day, print current motd without parameters",
Handler: func(room *chat.Room, msg message.CommandMsg) error {
if !room.IsOp(msg.From()) {
return errors.New("must be op")
}
args := msg.Args()
user := msg.From()
motd := h.motd
if len(args) == 0 {
room.Send(message.NewSystemMsg(motd, user))
} else if !room.IsOp(user) {
return errors.New("must be OP to modify the MOTD")
} else {
motd := ""
args := msg.Args()
if len(args) > 0 {
motd = strings.Join(args, " ")
}
@ -441,7 +447,7 @@ func (h *Host) InitCommands(c *chat.Commands) {
if motd != "" {
room.Send(message.NewAnnounceMsg(motd))
}
}
return nil
},
})