Add UploadToChannel and UploadToConversation
This commit is contained in:
32
chat.go
32
chat.go
@ -559,22 +559,28 @@ func (c Chat) ReadMessage(messageID int) (*ChatAPI, error) {
|
|||||||
return &r, nil
|
return &r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload attaches a file to a conversation
|
// UploadToChannel attaches a file to a channel
|
||||||
// The filepath must be an absolute path
|
// The filename must be an absolute path
|
||||||
func (c Chat) Upload(title string, filepath string) (ChatAPI, error) {
|
func (k *Keybase) UploadToChannel(channel chat1.ChatChannel, title string, filename string) (chat1.SendRes, error) {
|
||||||
m := ChatAPI{
|
opts := SendMessageOptions{
|
||||||
Params: ¶ms{},
|
Channel: channel,
|
||||||
|
Title: title,
|
||||||
|
Filename: filename,
|
||||||
}
|
}
|
||||||
m.Method = "attach"
|
|
||||||
m.Params.Options.Channel = &c.Channel
|
|
||||||
m.Params.Options.Filename = filepath
|
|
||||||
m.Params.Options.Title = title
|
|
||||||
|
|
||||||
r, err := chatAPIOut(c.keybase, m)
|
return k.SendMessage("attach", opts)
|
||||||
if err != nil {
|
|
||||||
return r, err
|
|
||||||
}
|
}
|
||||||
return r, nil
|
|
||||||
|
// UploadToConversation attaches a file to a conversation
|
||||||
|
// The filename must be an absolute path
|
||||||
|
func (k *Keybase) UploadToConversation(conv chat1.ConvIDStr, title string, filename string) (chat1.SendRes, error) {
|
||||||
|
opts := SendMessageOptions{
|
||||||
|
ConversationID: conv,
|
||||||
|
Title: title,
|
||||||
|
Filename: filename,
|
||||||
|
}
|
||||||
|
|
||||||
|
return k.SendMessage("attach", opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download downloads a file from a conversation
|
// Download downloads a file from a conversation
|
||||||
|
|||||||
Reference in New Issue
Block a user