Add download methods

This commit is contained in:
Sam
2020-03-12 00:48:26 -04:00
parent 21b141b7a1
commit ef7a20a94b

29
chat.go
View File

@ -583,21 +583,26 @@ func (k *Keybase) UploadToConversation(conv chat1.ConvIDStr, title string, filen
return k.SendMessage("attach", opts) return k.SendMessage("attach", opts)
} }
// Download downloads a file from a conversation // DownloadFromChannel downloads a file from a channel
func (c Chat) Download(messageID int, filepath string) (ChatAPI, error) { func (k *Keybase) DownloadFromChannel(channel chat1.ChatChannel, msgID chat1.MessageID, filename string) (chat1.SendRes, error) {
m := ChatAPI{ opts := SendMessageOptions{
Params: &params{}, Channel: channel,
MessageID: msgID,
Filename: filename,
} }
m.Method = "download"
m.Params.Options.Channel = &c.Channel
m.Params.Options.Output = filepath
m.Params.Options.MessageID = messageID
r, err := chatAPIOut(c.keybase, m) return k.SendMessage("download", opts)
if err != nil { }
return r, err
// DownloadFromConversation downloads a file from a conversation
func (k *Keybase) DownloadFromConversation(conv chat1.ConvIDStr, msgID chat1.MessageID, filename string) (chat1.SendRes, error) {
opts := SendMessageOptions{
ConversationID: conv,
MessageID: msgID,
Filename: filename,
} }
return r, nil
return k.SendMessage("download", opts)
} }
// LoadFlip returns the results of a flip // LoadFlip returns the results of a flip