Вот кусок скрипта:
var menu = {
reply_markup: {
inline_keyboard: [[],[],[],[],[],[],[]],
}
};
if (command === 'IObroker меню') command = menuUp;
log (command);
if (command === 'Меню') first_tap = true;
if (command === '↩️ Назад') command = menuUp;
if (command === 'ℹ️') command = menuUp;
var but1 = getButtonArray(button, 'name', command).toString();
if (but1.length > 0) { // проверяем, что строка не пустая
var but2 = but1.split(','); //преобразуем в массив
menuUp = but2.pop(); //вырезаем последний элемент
if (but2.length > 0) { // проверяем что массив не пуст
var index = 0;
for (var i=0, len=but2.length; i<len; i++) {
menu.reply_markup.inline_keyboard[index].push({ text: but2[i], callback_data: but2[i]});
if ((i%3 >= 2)&&(index < 6)) index = ++index;
}
var topText = funcTopText(command);
topTextGlobal = command;
menu_current = menu.reply_markup;
if (first_tap) {
sendTo('telegram.0', {user: user, text: topText, parse_mode: 'markdown', reply_markup: menu.reply_markup});
first_tap = false;
} else {
updateMenuButton(user, topText, menu.reply_markup);