mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-09-23 03:17:58 -04:00
Merge 58d26ca479f9bf823d79f9a098e5682c798bf0ef into 13ea34b9121b7b49932e1f87884511577e44eb03
This commit is contained in:
commit
f884a3694c
38
host.go
38
host.go
@ -425,26 +425,32 @@ func (h *Host) InitCommands(c *chat.Commands) {
|
||||
c.Add(chat.Command{
|
||||
Op: true,
|
||||
Prefix: "/motd",
|
||||
PrefixHelp: "MESSAGE",
|
||||
Help: "Set the MESSAGE of the day.",
|
||||
PrefixHelp: "[MESSAGE]",
|
||||
Help: "Set a new MESSAGE of the day, print the 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
|
||||
},
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user