diff --git a/api/api.go b/api/api.go index 953d80f..489c629 100644 --- a/api/api.go +++ b/api/api.go @@ -13,6 +13,8 @@ type Keybase struct { type keybase interface { ChatSendText(user string, message ...string) (chatOutResultResult, error) ChatSendTextTeam(team, channel, message string) (chatOutResultResult, error) + ChatSendReaction(user, reaction string, messageId int) (chatOutResultResult, error) + ChatSendReactionTeam(team, channel, reaction string, messageId int) (chatOutResultResult, error) ChatList() ([]chatOutResultConversations, error) LoggedIn() bool Username() string diff --git a/api/chatOut.go b/api/chatOut.go index 12c4d50..9b1efe7 100644 --- a/api/chatOut.go +++ b/api/chatOut.go @@ -20,8 +20,9 @@ type chatOutMessage struct { Body string `json:"body"` } type chatOutOptions struct { - Channel chatOutChannel `json:"channel"` - Message chatOutMessage `json:"message"` + Channel chatOutChannel `json:"channel"` + MessageID int `json:"message_id"` + Message chatOutMessage `json:"message"` } type chatOutParams struct { Options chatOutOptions `json:"options"` @@ -110,6 +111,38 @@ func (k Keybase) ChatSendTextTeam(team, channel string, message ...string) (chat return r.Result, nil } +// ChatSendReaction() sends a reaction to a user's message. +func (k Keybase) ChatSendReaction(user, reaction string, messageId int) (chatOutResultResult, error) { + m := chatOut{} + m.Method = "reaction" + m.Params.Options.Channel.Name = user + m.Params.Options.MessageID = messageId + m.Params.Options.Message.Body = reaction + + r, err := chatAPIOut(k.path, m) + if err != nil { + return chatOutResultResult{}, err + } + return r.Result, nil +} + +// ChatSendReactionTeam() sends a reaction to a message on a team. +func (k Keybase) ChatSendReactionTeam(team, channel, reaction string, messageId int) (chatOutResultResult, error) { + m := chatOut{} + m.Method = "reaction" + m.Params.Options.Channel.Name = team + m.Params.Options.Channel.MembersType = "team" + m.Params.Options.Channel.TopicName = channel + m.Params.Options.MessageID = messageId + m.Params.Options.Message.Body = reaction + + r, err := chatAPIOut(k.path, m) + if err != nil { + return chatOutResultResult{}, err + } + return r.Result, nil +} + // ChatList() returns a list of all conversations. func (k Keybase) ChatList() ([]chatOutResultConversations, error) { m := chatOut{}