A
A
amdma2021-12-29 23:04:26
Node.js
amdma, 2021-12-29 23:04:26

How to display buttons in one message?

How to display buttons in one message?
To make it not so:
61ccbf291dd24534999750.png
but displayed in 1 message
, here is the code:

if(text == "/buttons"){
        connection.query("SELECT * FROM `buttons`", async function(err, results){
            for(let i in results){
                bot.sendMessage(chatId, "Кнопки: ", {reply_markup: {inline_keyboard: }})
            }
        });
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2021-12-30
@shurshur

What for in a cycle on each button to send the separate message? You must first form a keyboard in a loop, and then send one message.

spoiler
С node.js не умею, вот простейший пример на python для понимания принципа:
keyboard = types.InlineKeyboardMarkup()
for b in buttons:
  keyboard.add(types.InlineKeyboardButton(text=b, callback_data=b))
bot.send_message(message.chat.id, "Кнопачки", reply_markup=keyboard)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question