A
A
ahmedes2022-04-02 13:40:18
In contact with
ahmedes, 2022-04-02 13:40:18

How to handle message_event in vk-io and show context in console?

The matter is that message_event is not processed, neither from phone, not from the browser. I send after any message an inline keyboard with callback buttons, after which I click on them and nothing happens, although in fact a notification should come to the console.

vk.updates.on('message_event', async (context, next) => {
  console.log(context)
  return next
});


vk.updates.on('message_new', (context, next) => {
  if (context.isOutbox) {
    return
  } else {

    const builder = Keyboard.builder() 
      .inline()
      .callbackButton({
        label: 'Callback: miner',
        color: Keyboard.PRIMARY_COLOR,
        payload: 'miner',
      })
      .row()
      .inline()
      .callbackButton({
        label: 'Callback: shop',
        color: Keyboard.NEGATIVE_COLOR,
        payload: 'shop',
      }) 
      .inline()
      .callbackButton({
        label: 'Callback: profile',
        color: Keyboard.POSITIVE_COLOR,
        payload: 'profile',
      }) 
      .row()
      .inline()
      .callbackButton({
        label: 'Callback: trans',
        color: Keyboard.SECONDARY_COLOR,
        payload: 'trans',
      }) 
      
  

    
  
  context.send({
    message: "Улучшите свое положение шикарным статусом", keyboard: builder });
    return next
  }

})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
ahmedes, 2022-04-02
@ahmedes

It worked, I changed vk.updates.startPolling at the bottom to vk.updates.start

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question