@@ -557,7 +557,6 @@ func (b *Bot) ProcessUpdate(upd Update) {
557557
558558 return
559559 }
560-
561560}
562561
563562func (b * Bot ) handle (end string , m * Message ) bool {
@@ -645,6 +644,8 @@ func (b *Bot) SendAlbum(to Recipient, a Album, options ...interface{}) ([]Messag
645644 return nil , ErrBadRecipient
646645 }
647646
647+ sendOpts := extractOptions (options )
648+
648649 media := make ([]string , len (a ))
649650 files := make (map [string ]File )
650651
@@ -670,15 +671,15 @@ func (b *Bot) SendAlbum(to Recipient, a Album, options ...interface{}) ([]Messag
670671 switch y := x .(type ) {
671672 case * Photo :
672673 data , _ = json .Marshal (struct {
673- Type string `json:"type"`
674- Media string `json:"media"`
675- Caption string `json:"caption,omitempty"`
676- ParseMode ParseMode `json:"parse_mode,omitempty"`
674+ Type string `json:"type"`
675+ Media string `json:"media"`
676+ Caption string `json:"caption,omitempty"`
677+ ParseMode string `json:"parse_mode,omitempty"`
677678 }{
678679 Type : "photo" ,
679680 Media : repr ,
680681 Caption : y .Caption ,
681- ParseMode : y .ParseMode ,
682+ ParseMode : sendOpts .ParseMode ,
682683 })
683684 case * Video :
684685 data , _ = json .Marshal (struct {
@@ -689,6 +690,7 @@ func (b *Bot) SendAlbum(to Recipient, a Album, options ...interface{}) ([]Messag
689690 Height int `json:"height,omitempty"`
690691 Duration int `json:"duration,omitempty"`
691692 SupportsStreaming bool `json:"supports_streaming,omitempty"`
693+ ParseMode string `json:"parse_mode,omitempty"`
692694 }{
693695 Type : "video" ,
694696 Caption : y .Caption ,
@@ -697,6 +699,37 @@ func (b *Bot) SendAlbum(to Recipient, a Album, options ...interface{}) ([]Messag
697699 Height : y .Height ,
698700 Duration : y .Duration ,
699701 SupportsStreaming : y .SupportsStreaming ,
702+ ParseMode : sendOpts .ParseMode ,
703+ })
704+ case * Audio :
705+ data , _ = json .Marshal (struct {
706+ Type string `json:"type"`
707+ Media string `json:"media"`
708+ Caption string `json:"caption,omitempty"`
709+ Duration int `json:"duration,omitempty"`
710+ Performer string `json:"performer,omitempty"`
711+ Title string `json:"title,omitempty"`
712+ ParseMode string `json:"parse_mode,omitempty"`
713+ }{
714+ Type : "audio" ,
715+ Media : repr ,
716+ Caption : y .Caption ,
717+ Duration : y .Duration ,
718+ Performer : y .Performer ,
719+ Title : y .Title ,
720+ ParseMode : sendOpts .ParseMode ,
721+ })
722+ case * Document :
723+ data , _ = json .Marshal (struct {
724+ Type string `json:"type"`
725+ Media string `json:"media"`
726+ Caption string `json:"caption,omitempty"`
727+ ParseMode string `json:"parse_mode,omitempty"`
728+ }{
729+ Type : "document" ,
730+ Media : repr ,
731+ Caption : y .Caption ,
732+ ParseMode : sendOpts .ParseMode ,
700733 })
701734 default :
702735 return nil , errors .Errorf ("telebot: album entry #%d is not valid" , i )
@@ -709,8 +742,6 @@ func (b *Bot) SendAlbum(to Recipient, a Album, options ...interface{}) ([]Messag
709742 "chat_id" : to .Recipient (),
710743 "media" : "[" + strings .Join (media , "," ) + "]" ,
711744 }
712-
713- sendOpts := extractOptions (options )
714745 b .embedSendOptions (params , sendOpts )
715746
716747 data , err := b .sendFiles ("sendMediaGroup" , files , params )
@@ -727,12 +758,18 @@ func (b *Bot) SendAlbum(to Recipient, a Album, options ...interface{}) ([]Messag
727758
728759 for attachName := range files {
729760 i , _ := strconv .Atoi (attachName )
761+ r := resp .Result [i ]
730762
731763 var newID string
732- if resp .Result [i ].Photo != nil {
733- newID = resp .Result [i ].Photo .FileID
734- } else {
735- newID = resp .Result [i ].Video .FileID
764+ switch {
765+ case r .Photo != nil :
766+ newID = r .Photo .FileID
767+ case r .Video != nil :
768+ newID = r .Video .FileID
769+ case r .Audio != nil :
770+ newID = r .Audio .FileID
771+ case r .Document != nil :
772+ newID = r .Document .FileID
736773 }
737774
738775 a [i ].MediaFile ().FileID = newID
0 commit comments