go-telegram-bot-api / telegram-bot-api

Golang bindings for the Telegram Bot API
https://go-telegram-bot-api.dev
MIT License
5.7k stars 879 forks source link

undefined: tgbotapi.FileURL, bot.SendMediaGroup undefined, #551

Closed Alehap closed 2 years ago

Alehap commented 2 years ago

Hi, I'm trying with https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/bot_test.go, func TestSendWithMediaGroupPhotoVideo This is my code

            mediaInterface := []interface{}{tgbotapi.NewInputMediaPhoto(tgbotapi.FileURL(AdObj.ThumbnailImage))}
            limitPhoto := 0
            for _, url := range AdObj.Images {
                if limitPhoto >= 9 {
                    break
                }
                limitPhoto++
                mediaInterface = append([]interface{}{tgbotapi.NewInputMediaPhoto(tgbotapi.FileURL(url))}, mediaInterface...)
            }
            cfg := tgbotapi.NewMediaGroup(tgChatId, mediaInterface)
            messages, err := bot.SendMediaGroup(cfg)
            if err != nil {
                log.Fatal(err)
            }
            if messages == nil {
                log.Println("No received messages")
            }
            if len(messages) != len(cfg.Media) {
                log.Println("Different number of messages: %d", len(messages))
            }

And I got error: ./main.go:1519:86: undefined: tgbotapi.FileURL ./main.go:1526:96: undefined: tgbotapi.FileURL ./main.go:1531:38: bot.SendMediaGroup undefined (type *tgbotapi.BotAPI has no field or method SendMediaGroup) ./main.go:1540:45: cfg.Media undefined (type tgbotapi.MediaGroupConfig has no field or method Media)

I had ran go get -u github.com/go-telegram-bot-api/telegram-bot-api/v5 already.

Can you please help me solve this problem?