Browse Source

Add Reply()

main
Sam 5 years ago
parent
commit
4ccaf4c45a
  1. 21
      chat.go
  2. 2
      types.go

21
chat.go

@ -178,6 +178,27 @@ func (c Chat) Send(message ...string) (ChatAPI, error) { @@ -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{

2
types.go

@ -239,6 +239,7 @@ type options struct { @@ -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 { @@ -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)

Loading…
Cancel
Save