Skip to content

How to add an inline buttons to an album? #786

@jokaorgua

Description

@jokaorgua

Hello. I'm tyring to add InlineKeyboard to an album.

The code is the following

type Alert struct {
	Body     string
	Receiver string
	Images   []Image
	Buttons  [][]Button
}

var markup *tb.ReplyMarkup


markup = &tb.ReplyMarkup{}
var inlineKeyboard [][]tb.InlineButton

for _, rowButtons := range alert.Buttons {
	var row []tb.InlineButton
	for _, btnData := range rowButtons {
		btn := tb.InlineButton{
			Text: btnData.Text,
		}
		if btnData.URL != "" {
			btn.URL = btnData.URL
		} else if btnData.Data != "" {
			btn.Unique = btnData.Data
			btn.Data = btnData.Data
		}
		row = append(row, btn)
	}
	inlineKeyboard = append(inlineKeyboard, row)
}
markup.InlineKeyboard = inlineKeyboard


sendOpts := &tb.SendOptions{
	ParseMode:   tb.ModeHTML,
	ReplyMarkup: markup,
}

album := tb.Album{}
for _, image := range alert.Images {
	photo := &tb.Photo{
		File: tb.FromReader(bytes.NewReader(image.Body)),
	}

	album = append(album, photo)
}

album.SetCaption(alert.Body)

_, err := telegramBot.SendAlbum(&receiver, album, sendOpts)
if err != nil {
	log.Errorf("Error sending alert with images: %v", err)
}

after this code the inline keyboard does not appear.

Thanks for the hints.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions