Answer the question
In order to leave comments, you need to log in
How to display buttons in one message?
How to display buttons in one message?
To make it not so:
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
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.
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 questionAsk a Question
731 491 924 answers to any question