From 9dbf3b16642c7db2f6a7ad92eed8cb59db7a0941 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 21 Sep 2019 11:20:56 -0400 Subject: [PATCH] Add Pin and Unpin methods to Chat --- chat.go | 31 +++++++++++++++++++++++++++++++ types.go | 2 ++ 2 files changed, 33 insertions(+) diff --git a/chat.go b/chat.go index 1cf1521..97b47e6 100644 --- a/chat.go +++ b/chat.go @@ -332,3 +332,34 @@ func (c Chat) LoadFlip(messageID int, conversationID string, flipConversationID } return r, nil } + +// Pin pins a message to a channel +func (c Chat) Pin(messageID int) (ChatAPI, error) { + m := ChatAPI{ + Params: ¶ms{}, + } + m.Method = "pin" + m.Params.Options.Channel = c.Channel + m.Params.Options.MessageID = messageID + + r, err := chatAPIOut(c.keybase, m) + if err != nil { + return ChatAPI{}, err + } + return r, nil +} + +// Unpin clears any pinned messages from a channel +func (c Chat) Unpin() (ChatAPI, error) { + m := ChatAPI{ + Params: ¶ms{}, + } + m.Method = "unpin" + m.Params.Options.Channel = c.Channel + + r, err := chatAPIOut(c.keybase, m) + if err != nil { + return ChatAPI{}, err + } + return r, nil +} diff --git a/types.go b/types.go index 4121a90..0a84229 100644 --- a/types.go +++ b/types.go @@ -468,6 +468,8 @@ type chat interface { Upload(title string, filepath string) (ChatAPI, error) Download(messageID int, filepath string) (ChatAPI, error) LoadFlip(messageID int, conversationID string, flipConversationID string, gameID string) (ChatAPI, error) + Pin(messageID int) (ChatAPI, error) + Unpin() (ChatAPI, error) } type chatAPI interface {