Animation type support added
parent
75244dc4f7
commit
0343f9ec27
53
configs.go
53
configs.go
|
@ -497,6 +497,59 @@ func (config VideoConfig) method() string {
|
||||||
return "sendVideo"
|
return "sendVideo"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AnimationConfig contains information about a SendAnimation request.
|
||||||
|
type AnimationConfig struct {
|
||||||
|
BaseFile
|
||||||
|
Duration int
|
||||||
|
Caption string
|
||||||
|
ParseMode string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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.Duration != 0 {
|
||||||
|
v.Add("duration", strconv.Itoa(config.Duration))
|
||||||
|
}
|
||||||
|
if config.Caption != "" {
|
||||||
|
v.Add("caption", config.Caption)
|
||||||
|
if config.ParseMode != "" {
|
||||||
|
v.Add("parse_mode", config.ParseMode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
if config.ParseMode != "" {
|
||||||
|
params["parse_mode"] = config.ParseMode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return params, 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 AnimationConfig) method() string {
|
||||||
|
return "sendAnimation"
|
||||||
|
}
|
||||||
|
|
||||||
// VideoNoteConfig contains information about a SendVideoNote request.
|
// VideoNoteConfig contains information about a SendVideoNote request.
|
||||||
type VideoNoteConfig struct {
|
type VideoNoteConfig struct {
|
||||||
BaseFile
|
BaseFile
|
||||||
|
|
29
helpers.go
29
helpers.go
|
@ -200,6 +200,35 @@ func NewVideoShare(chatID int64, fileID string) VideoConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewAnimationUpload creates a new animation uploader.
|
||||||
|
//
|
||||||
|
// chatID is where to send it, file is a string path to the file,
|
||||||
|
// FileReader, or FileBytes.
|
||||||
|
func NewAnimationUpload(chatID int64, file interface{}) AnimationConfig {
|
||||||
|
return AnimationConfig{
|
||||||
|
BaseFile: BaseFile{
|
||||||
|
BaseChat: BaseChat{ChatID: chatID},
|
||||||
|
File: file,
|
||||||
|
UseExisting: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAnimationShare shares an existing animation.
|
||||||
|
// You may use this to reshare an existing animation without reuploading it.
|
||||||
|
//
|
||||||
|
// chatID is where to send it, fileID is the ID of the animation
|
||||||
|
// already uploaded.
|
||||||
|
func NewAnimationShare(chatID int64, fileID string) AnimationConfig {
|
||||||
|
return AnimationConfig{
|
||||||
|
BaseFile: BaseFile{
|
||||||
|
BaseChat: BaseChat{ChatID: chatID},
|
||||||
|
FileID: fileID,
|
||||||
|
UseExisting: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NewVideoNoteUpload creates a new video note uploader.
|
// NewVideoNoteUpload creates a new video note uploader.
|
||||||
//
|
//
|
||||||
// chatID is where to send it, file is a string path to the file,
|
// chatID is where to send it, file is a string path to the file,
|
||||||
|
|
13
types.go
13
types.go
|
@ -144,6 +144,7 @@ type Message struct {
|
||||||
Entities *[]MessageEntity `json:"entities"` // optional
|
Entities *[]MessageEntity `json:"entities"` // optional
|
||||||
Audio *Audio `json:"audio"` // optional
|
Audio *Audio `json:"audio"` // optional
|
||||||
Document *Document `json:"document"` // optional
|
Document *Document `json:"document"` // optional
|
||||||
|
Animation *ChatAnimation `json:"animation"` // optional
|
||||||
Game *Game `json:"game"` // optional
|
Game *Game `json:"game"` // optional
|
||||||
Photo *[]PhotoSize `json:"photo"` // optional
|
Photo *[]PhotoSize `json:"photo"` // optional
|
||||||
Sticker *Sticker `json:"sticker"` // optional
|
Sticker *Sticker `json:"sticker"` // optional
|
||||||
|
@ -293,6 +294,18 @@ type Sticker struct {
|
||||||
SetName string `json:"set_name"` // optional
|
SetName string `json:"set_name"` // optional
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChatAnimation contains information about an animation.
|
||||||
|
type ChatAnimation struct {
|
||||||
|
FileID string `json:"file_id"`
|
||||||
|
Width int `json:"width"`
|
||||||
|
Height int `json:"height"`
|
||||||
|
Duration int `json:"duration"`
|
||||||
|
Thumbnail *PhotoSize `json:"thumb"` // optional
|
||||||
|
FileName string `json:"file_name"` // optional
|
||||||
|
MimeType string `json:"mime_type"` // optional
|
||||||
|
FileSize int `json:"file_size"` // optional
|
||||||
|
}
|
||||||
|
|
||||||
// Video contains information about a video.
|
// Video contains information about a video.
|
||||||
type Video struct {
|
type Video struct {
|
||||||
FileID string `json:"file_id"`
|
FileID string `json:"file_id"`
|
||||||
|
|
Loading…
Reference in New Issue