diff --git a/host.go b/host.go index 85ce495..c666377 100644 --- a/host.go +++ b/host.go @@ -425,23 +425,29 @@ 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") - } - - motd := "" args := msg.Args() - if len(args) > 0 { - motd = strings.Join(args, " ") - } + user := msg.From() + motd := h.motd - h.motd = motd - body := fmt.Sprintf("New message of the day set by %s:", msg.From().Name()) - room.Send(message.NewAnnounceMsg(body)) - if motd != "" { - room.Send(message.NewAnnounceMsg(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, " ") + } + + h.motd = motd + body := fmt.Sprintf("New message of the day set by %s:", msg.From().Name()) + room.Send(message.NewAnnounceMsg(body)) + if motd != "" { + room.Send(message.NewAnnounceMsg(motd)) + } + } return nil }, })