- Added Send Animation Method

pull/216/head
AliMVP 7 years ago
parent b4ac20a08e
commit b8a42150a2
  1. 41
      configs.go
  2. 16
      helpers.go

@ -240,6 +240,47 @@ func (config ForwardConfig) method() string {
return "forwardMessage"
}
// AnimationConfig contains information about a SendAnimation request.
type AnimationConfig struct {
BaseFile
Caption string
}
// Params returns a map[string]string representation of AnimationConfig.
func (config AnimationConfig) params() (map[string]string, error) {
params, _ := config.BaseFile.params()
if config.Caption != "" {
params["caption"] = config.Caption
}
return params, nil
}
// Values returns a url.Values representation of AnimationConfig.
func (config AnimationConfig) values() (url.Values, error) {
v, err := config.BaseChat.values()
if err != nil {
return v, err
}
v.Add(config.name(), config.FileID)
if config.Caption != "" {
v.Add("caption", config.Caption)
}
return v, nil
}
// name returns the field name for the Animation.
func (config AnimationConfig) name() string {
return "animation"
}
// method returns Telegram API method name for sending Animation.
func (config PhotoConfig) Animation() string {
return "sendAnimation"
}
// PhotoConfig contains information about a SendPhoto request.
type PhotoConfig struct {
BaseFile

@ -51,6 +51,22 @@ func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig {
}
}
// NewAnimationUpload creates a new animation 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 NewAnimationUpload(chatID int64, file interface{}) AnimationConfig {
return AnimationConfig{
BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID},
File: file,
UseExisting: false,
},
}
}
// NewPhotoUpload creates a new photo uploader.
//
// chatID is where to send it, file is a string path to the file,