wrxck / telegram-bot-lua

A simple yet extensive Lua library for the Telegram bot API.
GNU General Public License v3.0
178 stars 34 forks source link

[question] how to create keyboard? #23

Closed mb6ockatf closed 1 year ago

mb6ockatf commented 1 year ago

here's my attempt:

local api = require("telegram-bot-lua.core").configure(TOKEN)

function api.on_message(message)
    if message.text and message.text:match("ping") then
        local keyboard = api.keyboard():row(
            api.row():url_button(
                "aboba",
                "https://google.com"
            )
        )
        api.send_message(
            message.chat.id,
            "pong", keyboard)
    end
end

i get this error:

Bad Request: unsupported parse_mode [400]

Payload: {
  "text":"pong",
  "disable_web_page_preview":"true",
  "parse_mode":"table: 0x55a6af6324a0",
  "chat_id":"5210725684"
}
mb6ockatf commented 1 year ago

ok, i fixed it with this code:

api.send_message(
    message.chat.id,
    "pong",
    nil,
    true,
    false,
    nil,
    keyboard)