Browse Source

Add chat.Edit()

main
Sam 5 years ago
parent
commit
efd8dab359
  1. 20
      chatOut.go
  2. 1
      keybase.go

20
chatOut.go

@ -99,8 +99,26 @@ func (c Chat) Send(message ...string) (ChatOut, error) { @@ -99,8 +99,26 @@ func (c Chat) Send(message ...string) (ChatOut, error) {
return r.Result, nil
}
// Edit() edits a previously sent chat message
func (c Chat) Edit(messageId int, message ...string) (ChatOut, error) {
m := chatOut{}
m.Method = "edit"
m.Params.Options.Channel.Name = c.Name
m.Params.Options.Channel.Public = c.Public
m.Params.Options.Channel.MembersType = c.MembersType
m.Params.Options.Channel.TopicName = c.TopicName
m.Params.Options.Message.Body = strings.Join(message, " ")
m.Params.Options.MessageID = messageId
r, err := chatAPIOut(c.keybase.Path, m)
if err != nil {
return ChatOut{}, err
}
return r.Result, nil
}
// React() sends a reaction to a message.
func (c Chat) React(reaction string, messageId int) (ChatOut, error) {
func (c Chat) React(messageId int, reaction string) (ChatOut, error) {
m := chatOut{}
m.Method = "reaction"
m.Params.Options.Channel.Name = c.Name

1
keybase.go

@ -40,6 +40,7 @@ type Chat struct { @@ -40,6 +40,7 @@ type Chat struct {
type chat interface {
Send(message ...string) (ChatOut, error)
Edit(messageId int, message ...string) (ChatOut, error)
React(messageId int, reaction string) (ChatOut, error)
Delete(messageId int) (ChatOut, error)
}

Loading…
Cancel
Save