A
A
a4sick2020-07-26 21:56:03
JavaScript
a4sick, 2020-07-26 21:56:03

The bot in VK does not work, what should I do?

in the group, I installed the newest version of the API -5.120 I wrote a script, I run it through the console, it says that the bot is working, but it does not work, what did I do wrong?

spoiler
//Модули
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);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alekosh Akhosh, 2020-07-27
@Akhosh

Maybe I made a mistake somewhere? Maybe a gap is needed somewhere, or something to close?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question