X
X
xexplosive2018-08-16 12:46:49
API
xexplosive, 2018-08-16 12:46:49

How to return an event from vk api?

I am writing a bot for VKontakte on node js, there was a need to invite him to conversations. How to get an event that the community was invited to a conversation and messages from the same conversation? Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladlen Hellsite, 2018-08-16
@xexplosive

import { VK } from 'vk-io';

const MY_GROUP_ID = 123456;

const vk = new VK({
    // ...
    pollingGroupId: MY_GROUP_ID
});

vk.updates.on('chat_invite_user', async (context, next) => {
    const { eventMemberId } = context;
    
    if (eventMemberId === -MY_GROUP_ID) {
        console.log('It\'s invited my group!');
        
        // ...
        return;
    }
    
    console.log('Other invited', eventMemberId);
});

vk.updates.startPolling().catch(console.error);

A
alihang, 2018-08-16
@alihang

No, VK does not provide information about inviting a bot to a conversation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question