D
D
Danil2019-10-10 13:47:00
In contact with
Danil, 2019-10-10 13:47:00

Vkontakte bot, buttons and nodejs?

Hello everyone, I use the node-vk-bot-api library, but it is not supported. The
buttons that can be used there are buttons with the text type, but VK is being updated and the location, vkpay, open_app

buttons have appeared. The buttons are declared as follows:

let keyboard_toster = Markup.keyboard([
  [
    Markup.button('Первая кнопка', 'positive')
  ],
  [
    Markup.button('Вторая кнопка', 'negative')
  ]
])

The file that is responsible for the keyboard:
markup.js
const KEYBOARD_COLUMNS_MAX = 4;
 
class Markup {
  keyboard(buttons, options = { columns: KEYBOARD_COLUMNS_MAX }) {
    this.__keyboard = {
      buttons: Array.isArray(buttons[0])
        ? buttons
        : buttons.reduce((array, label) => {
          const button = Markup.button(label);
          const buttons = array.length ? array[array.length - 1] : array[0];
 
          if (buttons && buttons.length < options.columns) {
            buttons.push(button);
          } else {
            array.push([button]);
          }
 
          return array;
        }, []),
    };
 
    return this;
  }
 
  oneTime(value = true) {
    this.__keyboard.one_time = value;
 
    return this;
  }
 
  toJSON() {
    return JSON.stringify(this.__keyboard);
  }
 
  static keyboard(keyboard, options) {
    return new Markup().keyboard(keyboard, options);
  }
 
  static button(label, color = 'default', payload = { button: label }) {
    if (typeof label === 'object') {
      return label;
    }
 
    return {
      action: {
        type: 'text',
        payload: JSON.stringify(payload),
        label,
      },
      color,
    };
  }
}
 
module.exports = Markup;


I need to somehow add support for at least open_app to this library
. This is not for commercial purposes, so I ask for help from people from the toaster, help me :c

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question