//Модули
const {VK, Keyboard} = require('vk-io');
const vk = new VK();
const commands = [];
const {updates} = vk;
vk.updates.use(async (mes, next) => {
if(mes.type == 'message' && (mes.isOutbox || mes.senderid < 0)) return;
if (mes.senderid === undefined || mes.senderType != 'user') return;
try {
await next();
} catch (e) {
console.log(e);
}
});
//Команды
vk.updates.hear(/(привет)/ui, async (mes) => {
return mes.send({
message: 'Кнопки появились',
keyboard: Keyboard([
[
Keyboard.textButton({
label: 'Красная',
color: 'negative'
})
],
[
Keyboard.textButton({
label: 'Cиняя',
color: 'primary'
}),
Keyboard.textButton({
label: 'Зеленая',
color:'positive'
})
],
[
Keyboard.textButton({
label: 'Cерая',
color: 'defaulte'
})
]
])
});
});
async function polling () {
vk.setOptions({
token: "63d09ea68cf98347f1d08cef77ca7c6973d6b73c70e1313126d421a424280eb25fb31872b8a5a4bfa10d5",
apiMode: "parallel",
pollingGroupId: 197372877
});
console.log('BOT STARTING...');
await vk.updates.startPolling();
console.log('BOT STARTED')
}
polling().catch(console.error);