A
A
Anatoly Lityanin2019-05-10 10:36:14
JavaScript
Anatoly Lityanin, 2019-05-10 10:36:14

How to use new_wall_post vk api event?

Hello, tell me how to make some text appear in the console when new entries are made?
Module: vk-io
Language: node.js

const fs = require("fs")
const VK = require('vk-io')
const vk = new VK()

vk.setToken("Токен")
vk.longpoll.start()
console.log("gg!");

vk.longpoll.on("wall_post_new", (context) => {
  console.log("анеме!");
  });

This code works with "message" event, but not with this event(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladlen Hellsite, 2019-05-10
@TOLY_a

Because the 3.2 library doesn't support the Bots Long Poll/Callback API. Here is an example for the latest version 4.0.

const { VK } = require('vk-io');

const vk = new VK({
  token: 'Токен'
});

vk.updates.on('wall_post', (context) => {
  console.log("анеме!");
});

vk.updates.start();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question