mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-06-06 02:13:07 +03:00
Fixed /reply bug (#230)
This commit is contained in:
parent
7781d5b135
commit
e800c88a56
16
host.go
16
host.go
@ -237,7 +237,13 @@ func (h *Host) AutoCompleteFunction(u *message.User) func(line string, pos int,
|
|||||||
if completed == "/reply" {
|
if completed == "/reply" {
|
||||||
replyTo := u.ReplyTo()
|
replyTo := u.ReplyTo()
|
||||||
if replyTo != nil {
|
if replyTo != nil {
|
||||||
completed = "/msg " + replyTo.Name()
|
name := replyTo.Name()
|
||||||
|
_, found := h.GetUser(name)
|
||||||
|
if found {
|
||||||
|
completed = "/msg " + name
|
||||||
|
} else {
|
||||||
|
u.SetReplyTo(nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -318,10 +324,16 @@ func (h *Host) InitCommands(c *chat.Commands) {
|
|||||||
return errors.New("no message to reply to")
|
return errors.New("no message to reply to")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name := target.Name()
|
||||||
|
_, found := h.GetUser(name)
|
||||||
|
if !found {
|
||||||
|
return errors.New("user not found")
|
||||||
|
}
|
||||||
|
|
||||||
m := message.NewPrivateMsg(strings.Join(args, " "), msg.From(), target)
|
m := message.NewPrivateMsg(strings.Join(args, " "), msg.From(), target)
|
||||||
room.Send(&m)
|
room.Send(&m)
|
||||||
|
|
||||||
txt := fmt.Sprintf("[Sent PM to %s]", target.Name())
|
txt := fmt.Sprintf("[Sent PM to %s]", name)
|
||||||
ms := message.NewSystemMsg(txt, msg.From())
|
ms := message.NewSystemMsg(txt, msg.From())
|
||||||
room.Send(ms)
|
room.Send(ms)
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user