Answer the question
In order to leave comments, you need to log in
INLINE buttons for VK-Bot on NODE.JS?
How to make INLINE buttons using the node-vk-bot library,
note that this is not node-vk-bot-api, but node-vk-bot.
If anyone knows, please write)
Answer the question
In order to leave comments, you need to log in
Read the node-vk-bot documentation, the documentation is in Russian. This library does not support sending inline keyboards. You can dig into the source code and tweak it a bit to add this feature. It's ugly, but if you need it to solve a problem, it's acceptable.
Here, I already did it for you. Change the Keyboard.ts code to this:
export enum KeyboardColor {
PRIMARY = 'primary',
DEFAULT = 'default',
NEGATIVE = 'negative',
POSITIVE = 'positive'
}
/**
* Класс для создания клавиатуры для бота
*/
export default class Keyboard {
private obj: any
constructor(oneTime = false, inline = false) { this.obj = { one_time: oneTime, inline: inline, buttons: [] } }
addButton(label: string, color: string = KeyboardColor.DEFAULT, payload = null) {
if (!this.obj.buttons.length) this.obj.buttons.push([])
let lastRow = this.obj.buttons[this.obj.buttons.length - 1]
if (lastRow.length === 4) throw new Error('Maximum amount of buttons in one row = 4')
lastRow.push({ action: { type: 'text', label, payload }, color })
return this
}
addRow() {
if (this.obj.buttons.length === 10) throw new Error('Maximum amount of rows = 10')
this.obj.buttons.push([])
return this
}
toString() { return JSON.stringify(this.obj) }
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question