diff --git a/chat.go b/chat.go index ae436a6..fba2dfb 100644 --- a/chat.go +++ b/chat.go @@ -273,3 +273,35 @@ func (c *ChatAPI) Previous(count ...int) (*ChatAPI, error) { c.keybase = k return c, nil } + +func (c Chat) Upload(title string, filepath string) (ChatAPI, error) { + m := ChatAPI{ + Params: ¶ms{}, + } + m.Method = "attach" + m.Params.Options.Channel = c.Channel + m.Params.Options.Filename = filepath + m.Params.Options.Title = title + + r, err := chatAPIOut(c.keybase.Path, m) + if err != nil { + return ChatAPI{}, err + } + return r, nil +} + +func (c Chat) Download(messageID int, filepath string) (ChatAPI, error) { + m := ChatAPI{ + Params: ¶ms{}, + } + m.Method = "download" + m.Params.Options.Channel = c.Channel + m.Params.Options.Output = filepath + m.Params.Options.MessageID = messageID + + r, err := chatAPIOut(c.keybase.Path, m) + if err != nil { + return ChatAPI{}, err + } + return r, nil +} diff --git a/types.go b/types.go index f681bdb..921c506 100644 --- a/types.go +++ b/types.go @@ -200,6 +200,9 @@ type options struct { MessageID int `json:"message_id"` Message message `json:"message"` Pagination pagination `json:"pagination"` + Filename string `json:"filename,omitempty"` + Title string `json:"title,omitempty"` + Output string `json:"output,omitempty"` } type params struct { Options options `json:"options"` @@ -416,6 +419,8 @@ type chat interface { Edit(messageID int, message ...string) (ChatAPI, error) React(messageID int, reaction string) (ChatAPI, error) Send(message ...string) (ChatAPI, error) + Upload(title string, filepath string) (ChatAPI, error) + Download(messageID int, filepath string) (ChatAPI, error) } type chatAPI interface {