Add chat.Edit()

This commit is contained in:
Sam
2019-06-08 16:01:46 -04:00
parent 003ba3a4e0
commit efd8dab359
2 changed files with 20 additions and 1 deletions

View File

@ -99,8 +99,26 @@ func (c Chat) Send(message ...string) (ChatOut, error) {
return r.Result, nil 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. // 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 := chatOut{}
m.Method = "reaction" m.Method = "reaction"
m.Params.Options.Channel.Name = c.Name m.Params.Options.Channel.Name = c.Name

View File

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