Browse Source

Add ability to send reactions

main
Sam 6 years ago
parent
commit
f61f08daf4
  1. 2
      api/api.go
  2. 37
      api/chatOut.go

2
api/api.go

@ -13,6 +13,8 @@ type Keybase struct {
type keybase interface { type keybase interface {
ChatSendText(user string, message ...string) (chatOutResultResult, error) ChatSendText(user string, message ...string) (chatOutResultResult, error)
ChatSendTextTeam(team, channel, 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) ChatList() ([]chatOutResultConversations, error)
LoggedIn() bool LoggedIn() bool
Username() string Username() string

37
api/chatOut.go

@ -20,8 +20,9 @@ type chatOutMessage struct {
Body string `json:"body"` Body string `json:"body"`
} }
type chatOutOptions struct { type chatOutOptions struct {
Channel chatOutChannel `json:"channel"` Channel chatOutChannel `json:"channel"`
Message chatOutMessage `json:"message"` MessageID int `json:"message_id"`
Message chatOutMessage `json:"message"`
} }
type chatOutParams struct { type chatOutParams struct {
Options chatOutOptions `json:"options"` Options chatOutOptions `json:"options"`
@ -110,6 +111,38 @@ func (k Keybase) ChatSendTextTeam(team, channel string, message ...string) (chat
return r.Result, nil 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. // ChatList() returns a list of all conversations.
func (k Keybase) ChatList() ([]chatOutResultConversations, error) { func (k Keybase) ChatList() ([]chatOutResultConversations, error) {
m := chatOut{} m := chatOut{}

Loading…
Cancel
Save