new getFile and File types from Telegram Bot API update
parent
3ce6dbabe0
commit
1bceea1ca5
28
methods.go
28
methods.go
|
@ -156,6 +156,11 @@ type UserProfilePhotosConfig struct {
|
|||
Limit int
|
||||
}
|
||||
|
||||
// FileConfig has information about a file hosted on Telegram
|
||||
type FileConfig struct {
|
||||
FileID string
|
||||
}
|
||||
|
||||
// UpdateConfig contains information about a GetUpdates request.
|
||||
type UpdateConfig struct {
|
||||
Offset int
|
||||
|
@ -946,6 +951,29 @@ func (bot *BotAPI) GetUserProfilePhotos(config UserProfilePhotosConfig) (UserPro
|
|||
return profilePhotos, nil
|
||||
}
|
||||
|
||||
// GetFile returns a file_id required to download a file.
|
||||
//
|
||||
// Requires FileID.
|
||||
func (bot *BotAPI) GetFile(config FileConfig) (File, error) {
|
||||
v := url.Values{}
|
||||
v.Add("file_id", config.FileID)
|
||||
|
||||
resp, err := bot.MakeRequest("getFile", v)
|
||||
if err != nil {
|
||||
return File{}, err
|
||||
}
|
||||
|
||||
var file File
|
||||
json.Unmarshal(resp.Result, &file)
|
||||
|
||||
if bot.Debug {
|
||||
log.Printf("getFile req : %+v\n", v)
|
||||
log.Printf("getFile resp: %+v\n", file)
|
||||
}
|
||||
|
||||
return file, nil
|
||||
}
|
||||
|
||||
// GetUpdates fetches updates.
|
||||
// If a WebHook is set, this will not return any data!
|
||||
//
|
||||
|
|
7
types.go
7
types.go
|
@ -171,6 +171,13 @@ type UserProfilePhotos struct {
|
|||
Photos []PhotoSize `json:"photos"`
|
||||
}
|
||||
|
||||
// File contains information about a file to download from Telegram
|
||||
type File struct {
|
||||
FileID string `json:"file_id"`
|
||||
FileSize int `json:"file_size"`
|
||||
FilePath string `json:"file_path"`
|
||||
}
|
||||
|
||||
// ReplyKeyboardMarkup allows the Bot to set a custom keyboard.
|
||||
type ReplyKeyboardMarkup struct {
|
||||
Keyboard [][]string `json:"keyboard"`
|
||||
|
|
Loading…
Reference in New Issue