Add download methods
This commit is contained in:
29
chat.go
29
chat.go
@ -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: ¶ms{},
|
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
|
|
||||||
}
|
}
|
||||||
return r, nil
|
|
||||||
|
// 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 k.SendMessage("download", opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadFlip returns the results of a flip
|
// LoadFlip returns the results of a flip
|
||||||
|
|||||||
Reference in New Issue
Block a user