Browse Source

Add UploadToChannel and UploadToConversation

main
Sam 4 years ago
parent
commit
21b141b7a1
  1. 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: &params{}, 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
// 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 r, nil
return k.SendMessage("attach", opts)
} }
// Download downloads a file from a conversation // Download downloads a file from a conversation

Loading…
Cancel
Save