Add chat.Edit()
This commit is contained in:
20
chatOut.go
20
chatOut.go
@ -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
|
||||||
|
|||||||
@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user