go-telegram / bot

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

Fix error parsing inline keyboard button click reply message #30

Closed xeptore closed 1 year ago

xeptore commented 1 year ago

First of all, thank you for the great work. I'm actively developing a Telegram bot, and recently migrated from https://github.com/go-telegram-bot-api/telegram-bot-api to this package, and I'm pleased using your packge. Great work in the simple, and fluent API design!

Bug Report

After upgrading to v0.7.7, I'm seeing duplicate error logs on receiving updates containing inline keyboard button reply messages similar to the following:

2023/04/26 10:53:09 [TGBOT] [ERROR] error get updates, error decode response result for method getUpdates, json: cannot unmarshal object into Go struct field Message.callback_query.message.reply_markup of type models.ReplyMarkup
2023/04/26 10:53:09 [TGBOT] [ERROR] error get updates, error decode response result for method getUpdates, json: cannot unmarshal object into Go struct field Message.callback_query.message.reply_markup of type models.ReplyMarkup
2023/04/26 10:53:10 [TGBOT] [ERROR] error get updates, error decode response result for method getUpdates, json: cannot unmarshal object into Go struct field Message.callback_query.message.reply_markup of type models.ReplyMarkup
2023/04/26 10:53:10 [TGBOT] [ERROR] error get updates, error decode response result for method getUpdates, json: cannot unmarshal object into Go struct field Message.callback_query.message.reply_markup of type models.ReplyMarkup
2023/04/26 10:53:11 [TGBOT] [ERROR] error get updates, error decode response result for method getUpdates, json: cannot unmarshal object into Go struct field Message.callback_query.message.reply_markup of type models.ReplyMarkup
2023/04/26 10:53:13 [TGBOT] [ERROR] error get updates, error decode response result for method getUpdates, json: cannot unmarshal object into Go struct field Message.callback_query.message.reply_markup of type models.ReplyMarkup
2023/04/26 10:53:16 [TGBOT] [ERROR] error get updates, error decode response result for method getUpdates, json: cannot unmarshal object into Go struct field Message.callback_query.message.reply_markup of type models.ReplyMarkup

Steps to Reproduce

  1. Set proper Telegram Bot Token in the EXAMPLE_TELEGRAM_BOT_TOKEN environment variable
  2. Run the inline_keyboard example package: go run ./examples/inline_keyboard/
  3. Send message with "button" text to the robot
  4. You'll see bunch of repetitive error logs in your terminal

How I Fixed

There are two points to mention that I considered for this fix:

I hope that this makes sense. Please let me know if there are any concerns, or issues that I forgot.

Cheers

negasus commented 1 year ago

Thanks for the kind words and your contribution. Use ReplyMarkup for field Message.ReplyMarkup is, of course, a bug.