From 12869de13b20cde6833553ed763be930ed232cc4 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 30 May 2019 00:14:11 -0400 Subject: [PATCH] Add ability to delete messages --- api/api.go | 2 ++ api/chatOut.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/api/api.go b/api/api.go index 489c629..7516795 100644 --- a/api/api.go +++ b/api/api.go @@ -15,6 +15,8 @@ type keybase interface { ChatSendTextTeam(team, channel, message string) (chatOutResultResult, error) ChatSendReaction(user, reaction string, messageId int) (chatOutResultResult, error) ChatSendReactionTeam(team, channel, reaction string, messageId int) (chatOutResultResult, error) + ChatDeleteMessage(user string, messageId int) (chatOutResultResult, error) + ChatDeleteMessageTeam(team, channel string, messageId int) (chatOutResultResult, error) ChatList() ([]chatOutResultConversations, error) LoggedIn() bool Username() string diff --git a/api/chatOut.go b/api/chatOut.go index f612d99..bab1c7e 100644 --- a/api/chatOut.go +++ b/api/chatOut.go @@ -143,6 +143,36 @@ func (k Keybase) ChatSendReactionTeam(team, channel, reaction string, messageId return r.Result, nil } +// ChatDeleteMessage() deletes a message from a one-on-one conversation. +func (k Keybase) ChatDeleteMessage(user string, messageId int) (chatOutResultResult, error) { + m := chatOut{} + m.Method = "delete" + m.Params.Options.Channel.Name = user + m.Params.Options.MessageID = messageId + + r, err := chatAPIOut(k.path, m) + if err != nil { + return chatOutResultResult{}, err + } + return r.Result, nil +} + +// ChatDeleteMessageTeam() deletes a message from a team conversation. +func (k Keybase) ChatDeleteMessageTeam(team, channel string, messageId int) (chatOutResultResult, error) { + m := chatOut{} + m.Method = "delete" + m.Params.Options.Channel.Name = team + m.Params.Options.Channel.MembersType = "team" + m.Params.Options.Channel.TopicName = channel + m.Params.Options.MessageID = messageId + + 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{}