From 4ccaf4c45ad80f81f73486a6a64ac0b5efa7f44b Mon Sep 17 00:00:00 2001
From: Sam <dxb@keybase.io>
Date: Wed, 9 Oct 2019 21:41:46 -0400
Subject: [PATCH] Add Reply()

---
 chat.go  | 21 +++++++++++++++++++++
 types.go |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/chat.go b/chat.go
index d27f3d0..b0a0317 100644
--- a/chat.go
+++ b/chat.go
@@ -178,6 +178,27 @@ func (c Chat) Send(message ...string) (ChatAPI, error) {
 	return r, nil
 }
 
+// Reply sends a reply to a chat message
+func (c Chat) Reply(replyTo int, message ...string) (ChatAPI, error) {
+	m := ChatAPI{
+		Params: &params{},
+	}
+	m.Params.Options = options{
+		Message: &mesg{},
+	}
+
+	m.Method = "send"
+	m.Params.Options.Channel = &c.Channel
+	m.Params.Options.ReplyTo = replyTo
+	m.Params.Options.Message.Body = strings.Join(message, " ")
+
+	r, err := chatAPIOut(c.keybase, m)
+	if err != nil {
+		return ChatAPI{}, err
+	}
+	return r, nil
+}
+
 // Edit edits a previously sent chat message
 func (c Chat) Edit(messageID int, message ...string) (ChatAPI, error) {
 	m := ChatAPI{
diff --git a/types.go b/types.go
index ad279a1..89f7690 100644
--- a/types.go
+++ b/types.go
@@ -239,6 +239,7 @@ type options struct {
 	ConversationID     string      `json:"conversation_id,omitempty"`
 	FlipConversationID string      `json:"flip_conversation_id,omitempty"`
 	MsgID              int         `json:"msg_id,omitempty"`
+	ReplyTo            int         `json:"reply_to,omitempty"`
 	GameID             string      `json:"game_id,omitempty"`
 
 	Name        string `json:"name,omitempty"`
@@ -538,6 +539,7 @@ type chat interface {
 	Edit(messageID int, message ...string) (ChatAPI, error)
 	React(messageID int, reaction string) (ChatAPI, error)
 	Send(message ...string) (ChatAPI, error)
+	Reply(replyTo int, message ...string) (ChatAPI, error)
 	Upload(title string, filepath string) (ChatAPI, error)
 	Download(messageID int, filepath string) (ChatAPI, error)
 	LoadFlip(messageID int, conversationID string, flipConversationID string, gameID string) (ChatAPI, error)