Browse Source

Add ability to send reactions

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

2
api/api.go

@ -13,6 +13,8 @@ type Keybase struct { @@ -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

33
api/chatOut.go

@ -21,6 +21,7 @@ type chatOutMessage struct { @@ -21,6 +21,7 @@ type chatOutMessage struct {
}
type chatOutOptions struct {
Channel chatOutChannel `json:"channel"`
MessageID int `json:"message_id"`
Message chatOutMessage `json:"message"`
}
type chatOutParams struct {
@ -110,6 +111,38 @@ func (k Keybase) ChatSendTextTeam(team, channel string, message ...string) (chat @@ -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{}

Loading…
Cancel
Save