mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-22 11:40:32 +03:00
host.go: Fixing bug with /reply
This commit is contained in:
parent
7781d5b135
commit
cc71e4f097
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" {
|
||||
replyTo := u.ReplyTo()
|
||||
if replyTo != nil {
|
||||
completed = "/msg " + replyTo.Name()
|
||||
name := replyTo.Name()
|
||||
_, found := h.GetUser(name)
|
||||
if found {
|
||||
completed = "/msg " + name
|
||||
} else {
|
||||
u.SetReplyTo(nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -318,10 +324,16 @@ func (h *Host) InitCommands(c *chat.Commands) {
|
||||
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)
|
||||
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())
|
||||
room.Send(ms)
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user