mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-09-23 03:17:58 -04:00
Print the motd if no parameters are passed
This commit is contained in:
parent
61e8442cf5
commit
5a7db119fa
14
host.go
14
host.go
@ -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
|
||||
},
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user