add setChatPhoto method
parent
6e69f99d11
commit
57be988011
12
bot.go
12
bot.go
|
@ -922,3 +922,15 @@ func (bot *BotAPI) SetChatDescription(config SetChatDescriptionConfig) (APIRespo
|
||||||
|
|
||||||
return bot.MakeRequest(config.method(), v)
|
return bot.MakeRequest(config.method(), v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetChatPhoto change photo of chat.
|
||||||
|
func (bot *BotAPI) SetChatPhoto(config SetChatPhotoConfig) (APIResponse, error) {
|
||||||
|
params, err := config.params()
|
||||||
|
if err != nil {
|
||||||
|
return APIResponse{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
file := config.getFile()
|
||||||
|
|
||||||
|
return bot.UploadFile(config.method(), params, config.name(), file)
|
||||||
|
}
|
||||||
|
|
15
configs.go
15
configs.go
|
@ -1111,3 +1111,18 @@ func (config SetChatDescriptionConfig) values() (url.Values, error) {
|
||||||
|
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetChatPhotoConfig contains information for change chat photo
|
||||||
|
type SetChatPhotoConfig struct {
|
||||||
|
BaseFile
|
||||||
|
}
|
||||||
|
|
||||||
|
// name returns the field name for the Photo.
|
||||||
|
func (config SetChatPhotoConfig) name() string {
|
||||||
|
return "photo"
|
||||||
|
}
|
||||||
|
|
||||||
|
// method returns Telegram API method name for sending Photo.
|
||||||
|
func (config SetChatPhotoConfig) method() string {
|
||||||
|
return "setChatPhoto"
|
||||||
|
}
|
||||||
|
|
31
helpers.go
31
helpers.go
|
@ -653,3 +653,34 @@ func NewInvoice(chatID int64, title, description, payload, providerToken, startP
|
||||||
Currency: currency,
|
Currency: currency,
|
||||||
Prices: prices}
|
Prices: prices}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewSetChatPhotoUpload creates a new chat photo uploader.
|
||||||
|
//
|
||||||
|
// chatID is where to send it, file is a string path to the file,
|
||||||
|
// FileReader, or FileBytes.
|
||||||
|
//
|
||||||
|
// Note that you must send animated GIFs as a document.
|
||||||
|
func NewSetChatPhotoUpload(chatID int64, file interface{}) SetChatPhotoConfig {
|
||||||
|
return SetChatPhotoConfig{
|
||||||
|
BaseFile: BaseFile{
|
||||||
|
BaseChat: BaseChat{ChatID: chatID},
|
||||||
|
File: file,
|
||||||
|
UseExisting: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSetChatPhotoShare shares an existing photo.
|
||||||
|
// You may use this to reshare an existing photo without reuploading it.
|
||||||
|
//
|
||||||
|
// chatID is where to send it, fileID is the ID of the file
|
||||||
|
// already uploaded.
|
||||||
|
func NewSetChatPhotoShare(chatID int64, fileID string) SetChatPhotoConfig {
|
||||||
|
return SetChatPhotoConfig{
|
||||||
|
BaseFile: BaseFile{
|
||||||
|
BaseChat: BaseChat{ChatID: chatID},
|
||||||
|
FileID: fileID,
|
||||||
|
UseExisting: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue