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

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

ReplyMarkup not work when use with MediaGroupConfig #254

Closed zitn closed 5 years ago

zitn commented 5 years ago

it's my code

package main

import (
    "github.com/go-telegram-bot-api/telegram-bot-api"
    "log"
)

func main() {
    bot, err := tgbotapi.NewBotAPI("TOKEN")
    if err != nil {
        log.Panic(err)
    }

    bot.Debug = true

    log.Printf("Authorized on account %s", bot.Self.UserName)

    u := tgbotapi.NewUpdate(0)
    u.Timeout = 60

    updates, err := bot.GetUpdatesChan(u)

    numericKeyboard := tgbotapi.NewInlineKeyboardMarkup(
        tgbotapi.NewInlineKeyboardRow(
            tgbotapi.NewInlineKeyboardButtonData("test", "test"),
        ),
    )

    for update := range updates {

        if update.Message != nil {

            var medias []interface{}
            media1 := tgbotapi.NewInputMediaPhoto("http://example.com/test1.jpg")
            media2 := tgbotapi.NewInputMediaPhoto("http://example.com/test2.jpg")

            medias = append(medias, media1)
            medias = append(medias, media2)
            msg := tgbotapi.MediaGroupConfig{
                BaseChat: tgbotapi.BaseChat{
                    ChatID: update.Message.Chat.ID,
                    //ReplyMarkup:numericKeyboard,      not work too.

                },
                InputMedia: medias,
            }

            msg.ReplyMarkup = numericKeyboard

            bot.Send(msg)
        }
    }
}

and logs and response here

2019/07/27 22:37:51 Authorized on account ***
2019/07/27 22:38:01 getUpdates resp: {"ok":true,"result":[{"update_id":***,
"message":{"message_id":168,"from":{"id":***,"is_bot":false,"first_name":"***","username":"***","language_code":"***"},"chat":{"id":***,"first_name":"***","username":"***","type":"private"},"date":1564238281,"text":"q"}}]}
2019/07/27 22:38:01 getUpdates req : map[timeout:[60]]
2019/07/27 22:38:01 getUpdates resp: [{UpdateID:*** Message:0xc0002e8140 EditedMessage:<nil> ChannelPost:<nil> EditedChannelPost:<nil> InlineQuery:<nil> ChosenInlineResult:<nil> CallbackQuery:<nil> ShippingQuery:<nil> PreCheckoutQuery:<nil>}]
2019/07/27 22:38:04 sendMediaGroup resp: {"ok":true,"result":[{"message_id":169,"from":{"id":***,"is_bot":true,"first_name":"***","username":"***"},"chat":{"id":***,"first_name":"***","username":"***","type":"private"},"date":***,"media_group_id":"***","photo":[{"file_id":"AgADBAADY6kxG0uv1FF-9ftFBRwgFLjsIRsABAz7t6mYeqj6eZAHAAEC","file_size":880,"width":67,"height":90},{"file_id":"AgADBAADY6kxG0uv1FF-9ftFBRwgFLjsIRsABB8K_GHl2HYoepAHAAEC","file_size":8242,"width":240,"height":320},{"file_id":"AgADBAADY6kxG0uv1FF-9ftFBRwgFLjsIRsABOBBRPJUMFk4e5AHAAEC","file_size":35462,"width":600,"height":800}]},{"message_id":170,"from":{"id":***,"is_bot":true,"first_name":"***","username":"***"},"chat":{"id":***,"first_name":"***","username":"***","type":"private"},"date":***,"media_group_id":"***","photo":[{"file_id":"AgADBAADY6kxG0uv1FF-9ftFBRwgFLjsIRsABAz7t6mYeqj6eZAHAAEC","file_size":880,"width":67,"height":90},{"file_id":"AgADBAADY6kxG0uv1FF-9ftFBRwgFLjsIRsABB8K_GHl2HYoepAHAAEC","file_size":8242,"width":240,"height":320},{"file_id":"AgADBAADY6kxG0uv1FF-9ftFBRwgFLjsIRsABOBBRPJUMFk4e5AHAAEC","file_size":35462,"width":600,"height":800}]}]}
2019/07/27 22:38:04 sendMediaGroup req : map[chat_id:[***] disable_notification:[false] media:[[{"type":"photo","media":"http://example.com/test1.jpg","caption":"","parse_mode":""},{"type":"photo","media":"http://example.com/test2.jpg","caption":"","parse_mode":""}]] reply_markup:[{"inline_keyboard":[[{"text":"test","callback_data":"test"}]]}]]
2019/07/27 22:38:04 sendMediaGroup resp: {MessageID:0 From:<nil> Date:0 Chat:<nil> ForwardFrom:<nil> ForwardFromChat:<nil> ForwardFromMessageID:0 ForwardDate:0 ReplyToMessage:<nil> EditDate:0 Text: Entities:<nil> Audio:<nil> Document:<nil> Animation:<nil> Game:<nil> Photo:<nil> Sticker:<nil> Video:<nil> VideoNote:<nil> Voice:<nil> Caption: Contact:<nil> Location:<nil> Venue:<nil> NewChatMembers:<nil> LeftChatMember:<nil> NewChatTitle: NewChatPhoto:<nil> DeleteChatPhoto:false GroupChatCreated:false SuperGroupChatCreated:false ChannelChatCreated:false MigrateToChatID:0 MigrateFromChatID:0 PinnedMessage:<nil> Invoice:<nil> SuccessfulPayment:<nil> PassportData:<nil>}

in telegram, the button not show. if it's my mistake, please tell me correct usegae.

thanks for your time :)

njittam commented 5 years ago

looking at docs of sendMediagroup and inputMediaInfo, it seems that replymarkup is not supported by telegram for these kinds of messages. So MediaGroupConfig.ReplyMarkup should not exist in telegram-bot-api. What you can do is after you sent the media. you can send a message with your reply markup.

zitn commented 5 years ago

looking at docs of sendMediagroup and inputMediaInfo, it seems that replymarkup is not supported by telegram for these kinds of messages. So MediaGroupConfig.ReplyMarkup should not exist in telegram-bot-api. What you can do is after you sent the media. you can send a message with your reply markup.

got it, same as I thought, thanks a lot, I will close this issue.