mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-09-24 03:42:32 -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{
|
c.Add(chat.Command{
|
||||||
Op: true,
|
Op: true,
|
||||||
Prefix: "/motd",
|
Prefix: "/motd",
|
||||||
PrefixHelp: "MESSAGE",
|
PrefixHelp: "[MESSAGE]",
|
||||||
Help: "Set the MESSAGE of the day.",
|
Help: "Set a new MESSAGE of the day, print the current motd without parameters.",
|
||||||
Handler: func(room *chat.Room, msg message.CommandMsg) error {
|
Handler: func(room *chat.Room, msg message.CommandMsg) error {
|
||||||
if !room.IsOp(msg.From()) {
|
|
||||||
return errors.New("must be op")
|
|
||||||
}
|
|
||||||
|
|
||||||
motd := ""
|
|
||||||
args := msg.Args()
|
args := msg.Args()
|
||||||
if len(args) > 0 {
|
user := msg.From()
|
||||||
motd = strings.Join(args, " ")
|
motd := h.motd
|
||||||
}
|
|
||||||
|
|
||||||
h.motd = motd
|
if len(args) == 0 {
|
||||||
body := fmt.Sprintf("New message of the day set by %s:", msg.From().Name())
|
room.Send(message.NewSystemMsg(motd, user))
|
||||||
room.Send(message.NewAnnounceMsg(body))
|
} else if !room.IsOp(user) {
|
||||||
if motd != "" {
|
return errors.New("must be OP to modify the MOTD")
|
||||||
room.Send(message.NewAnnounceMsg(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
|
return nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user