|
|
@ -50,6 +50,7 @@ func (a *Audio) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
|
|
|
|
"caption": a.Caption,
|
|
|
|
"caption": a.Caption,
|
|
|
|
"performer": a.Performer,
|
|
|
|
"performer": a.Performer,
|
|
|
|
"title": a.Title,
|
|
|
|
"title": a.Title,
|
|
|
|
|
|
|
|
"file_name": a.FileName,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b.embedSendOptions(params, opt)
|
|
|
|
b.embedSendOptions(params, opt)
|
|
|
|
|
|
|
|
|
|
|
@ -57,7 +58,7 @@ func (a *Audio) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
|
|
|
|
params["duration"] = strconv.Itoa(a.Duration)
|
|
|
|
params["duration"] = strconv.Itoa(a.Duration)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
msg, err := b.sendObject(a.MediaFile(), "audio", params, thumbnailToFilemap(a.Thumbnail))
|
|
|
|
msg, err := b.sendObject(&a.File, "audio", params, thumbnailToFilemap(a.Thumbnail))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -79,8 +80,9 @@ func (a *Audio) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
|
|
|
|
// Send delivers media through bot b to recipient.
|
|
|
|
// Send delivers media through bot b to recipient.
|
|
|
|
func (d *Document) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
|
|
|
|
func (d *Document) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
|
|
|
|
params := map[string]string{
|
|
|
|
params := map[string]string{
|
|
|
|
"chat_id": to.Recipient(),
|
|
|
|
"chat_id": to.Recipient(),
|
|
|
|
"caption": d.Caption,
|
|
|
|
"caption": d.Caption,
|
|
|
|
|
|
|
|
"file_name": d.FileName,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b.embedSendOptions(params, opt)
|
|
|
|
b.embedSendOptions(params, opt)
|
|
|
|
|
|
|
|
|
|
|
@ -88,7 +90,7 @@ func (d *Document) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error
|
|
|
|
params["file_size"] = strconv.Itoa(d.FileSize)
|
|
|
|
params["file_size"] = strconv.Itoa(d.FileSize)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
msg, err := b.sendObject(d.MediaFile(), "document", params, thumbnailToFilemap(d.Thumbnail))
|
|
|
|
msg, err := b.sendObject(&d.File, "document", params, thumbnailToFilemap(d.Thumbnail))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -121,8 +123,9 @@ func (s *Sticker) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)
|
|
|
|
// Send delivers media through bot b to recipient.
|
|
|
|
// Send delivers media through bot b to recipient.
|
|
|
|
func (v *Video) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
|
|
|
|
func (v *Video) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
|
|
|
|
params := map[string]string{
|
|
|
|
params := map[string]string{
|
|
|
|
"chat_id": to.Recipient(),
|
|
|
|
"chat_id": to.Recipient(),
|
|
|
|
"caption": v.Caption,
|
|
|
|
"caption": v.Caption,
|
|
|
|
|
|
|
|
"file_name": v.FileName,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b.embedSendOptions(params, opt)
|
|
|
|
b.embedSendOptions(params, opt)
|
|
|
|
|
|
|
|
|
|
|
@ -139,7 +142,7 @@ func (v *Video) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
|
|
|
|
params["supports_streaming"] = "true"
|
|
|
|
params["supports_streaming"] = "true"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
msg, err := b.sendObject(v.MediaFile(), "video", params, thumbnailToFilemap(v.Thumbnail))
|
|
|
|
msg, err := b.sendObject(&v.File, "video", params, thumbnailToFilemap(v.Thumbnail))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -164,8 +167,9 @@ func (v *Video) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
|
|
|
|
// @see https://core.telegram.org/bots/api#sendanimation
|
|
|
|
// @see https://core.telegram.org/bots/api#sendanimation
|
|
|
|
func (a *Animation) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
|
|
|
|
func (a *Animation) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
|
|
|
|
params := map[string]string{
|
|
|
|
params := map[string]string{
|
|
|
|
"chat_id": to.Recipient(),
|
|
|
|
"chat_id": to.Recipient(),
|
|
|
|
"caption": a.Caption,
|
|
|
|
"caption": a.Caption,
|
|
|
|
|
|
|
|
"file_name": a.FileName,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b.embedSendOptions(params, opt)
|
|
|
|
b.embedSendOptions(params, opt)
|
|
|
|
|
|
|
|
|
|
|
@ -179,12 +183,12 @@ func (a *Animation) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, erro
|
|
|
|
params["height"] = strconv.Itoa(a.Height)
|
|
|
|
params["height"] = strconv.Itoa(a.Height)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Without the FileName GIF sends as a document.
|
|
|
|
// file_name is required, without file_name GIFs sent as document
|
|
|
|
if a.FileName == "" && a.File.OnDisk() {
|
|
|
|
if params["file_name"] == "" && a.File.OnDisk() {
|
|
|
|
a.FileName = filepath.Base(a.File.FileLocal)
|
|
|
|
params["file_name"] = filepath.Base(a.File.FileLocal)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
msg, err := b.sendObject(a.MediaFile(), "animation", params, nil)
|
|
|
|
msg, err := b.sendObject(&a.File, "animation", params, nil)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|