mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-06-04 01:21:04 +03:00
/motd: Fixed set message and actual motd coming out of order.
Fixes #165
This commit is contained in:
parent
f6e022548c
commit
cfa86b3e2e
16
host.go
16
host.go
@ -104,7 +104,7 @@ func (h *Host) Connect(term *sshd.Terminal) {
|
|||||||
|
|
||||||
// Send MOTD
|
// Send MOTD
|
||||||
if motd != "" {
|
if motd != "" {
|
||||||
go user.Send(message.NewAnnounceMsg(motd))
|
user.Send(message.NewAnnounceMsg(motd))
|
||||||
}
|
}
|
||||||
|
|
||||||
member, err := h.Join(user)
|
member, err := h.Join(user)
|
||||||
@ -445,7 +445,10 @@ func (h *Host) InitCommands(c *chat.Commands) {
|
|||||||
Handler: func(room *chat.Room, msg message.CommandMsg) error {
|
Handler: func(room *chat.Room, msg message.CommandMsg) error {
|
||||||
args := msg.Args()
|
args := msg.Args()
|
||||||
user := msg.From()
|
user := msg.From()
|
||||||
|
|
||||||
|
h.mu.Lock()
|
||||||
motd := h.motd
|
motd := h.motd
|
||||||
|
h.mu.Unlock()
|
||||||
|
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
room.Send(message.NewSystemMsg(motd, user))
|
room.Send(message.NewSystemMsg(motd, user))
|
||||||
@ -455,16 +458,11 @@ func (h *Host) InitCommands(c *chat.Commands) {
|
|||||||
return errors.New("must be OP to modify the MOTD")
|
return errors.New("must be OP to modify the MOTD")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) > 0 {
|
|
||||||
motd = strings.Join(args, " ")
|
motd = strings.Join(args, " ")
|
||||||
}
|
h.SetMotd(motd)
|
||||||
|
fromMsg := fmt.Sprintf("New message of the day set by %s:", msg.From().Name())
|
||||||
|
room.Send(message.NewAnnounceMsg(fromMsg + message.Newline + "-> " + 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))
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user