Add upload and download methods to chat
This commit is contained in:
32
chat.go
32
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
|
||||
}
|
||||
|
||||
5
types.go
5
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 {
|
||||
|
||||
Reference in New Issue
Block a user