protoncr / tourmaline

Simple Telegram bot library for Crystal
https://tourmaline.dev
MIT License
158 stars 38 forks source link

Bug, switch_to_current_chat_button is not generated correctly #42

Closed dammer closed 3 years ago

dammer commented 3 years ago

Hi Chris, in sample:

MY_MENU = Tourmaline::RoutedMenu.build do
  route "/" do
    content "Welcome"
    buttons(columns: 1) do
      switch_to_current_chat_button("txt", "test")
    end
  end
end

@[Command("help")]
def start_command(ctx)
  ctx.message.respond_with_menu(MY_MENU)
end

Tourmaline prodroguce that:

web          |  ▸ sending ►► sendMessage({
web          |   "chat_id": 302869059,
web          |   "text": "Welcome",
web          |   "parse_mode": null,
web          |   "entities": [],
web          |   "disable_web_page_preview": true,
web          |   "disable_notification": false,
web          |   "reply_to_message_id": null,
web          |   "allow_sending_without_reply": false,
web          |   "reply_markup": "{\"inline_keyboard\":[[{\"text\":\"txt\"}]]}"
web          | })

and receive error from tg:

web          |  ▸ receiving ◄◄ {
web          |   "ok": false,
web          |   "error_code": 400,
web          |   "description": "Bad Request: can't parse inline keyboard button: Text buttons are unallowed in the inline keyboard"
web          | }

same time if i change switch_to_current_chat_button to switch_to_chat_button with same params Tourmaline prodroguce good keyboard

web          |  ▸ Handled by Bot::Webhooks::Create
web          |  ▸ Sent 200 OK (3.44ms)
web          |  ▸ sending ►► sendMessage({
web          |   "chat_id": 302869059,
web          |   "text": "Welcome",
web          |   "parse_mode": null,
web          |   "entities": [],
web          |   "disable_web_page_preview": true,
web          |   "disable_notification": false,
web          |   "reply_to_message_id": null,
web          |   "allow_sending_without_reply": false,
web          |   "reply_markup": "{\"inline_keyboard\":[[{\"text\":\"txt\",\"switch_inline_query\":\"test\"}]]}"
web          | })

and receive ok from tg:

web          |  ▸ Performing request
web          |  ▸ receiving ◄◄ {
web          |   "ok": true,
web          |   "result": {
web          |     "message_id": 59,
---skipped-------------------------------
web          |     "date": 1614956741,
web          |     "text": "Welcome",
web          |     "reply_markup": {
web          |       "inline_keyboard": [
web          |         [
web          |           {
web          |             "text": "txt",
web          |             "switch_inline_query": "test"
web          |           }
web          |         ]
web          |       ]
web          |     }
web          |   }
web          | }

I see deep in code but can't find the error( Any variants with button("txt", switch_inline_query_current_chat: "test") etc does not help.

dammer commented 3 years ago

update: i found where is error, i will commit fix after checking.