go-telegram / bot

Telegram Bot API Go framework
MIT License
502 stars 46 forks source link

LinkPreviewOptions problem #56

Closed brankovitorovic closed 5 months ago

brankovitorovic commented 5 months ago

In the previous version, I used DisableWebPagePreview: true when creating SendMessageParam. and it worked great. Now, with the new version this is replaced with LinkPreviewOptions and when I add&models.LinkPreviewOptions{IsDisabled: &linkPreviewDisabled} I got message {"ok":false,"error_code":400,"description":"Bad Request: field \"url\" must be of type String"}. So I added random text like this LinkPreviewOptions: &models.LinkPreviewOptions{URL: &testURL, IsDisabled: &linkPreviewDisabled}, and it worked.

The problem is why I need to specify some URLs and set them here when I want to disable URL previews. Is there an option to add a check if IsDisabled=true then no URL is required?

negasus commented 5 months ago

Released v1.0.1 with fix. Now

    b.SendMessage(ctx, &bot.SendMessageParams{
        ChatID: update.Message.Chat.ID,
        Text:   "Hello, https://pinterest.com",
        LinkPreviewOptions: &models.LinkPreviewOptions{
            IsDisabled: bot.False(),
        },
    })

works correctly

brankovitorovic commented 5 months ago

Thanks so much for a quick fix. Wish you the best.