Answer the question
In order to leave comments, you need to log in
How to run multiple VK accounts?
Hello. I need to run several VKontakte accounts in one process. I use the VK-IO library to work with the VKontakte api and tried to do this (code below), but only the last account from the array starts. Help me decide...
const { VK, getRandomId } = require('vk-io');
const { HearManager } = require('@vk-io/hear');
const users = require("./database/tokenUsers.json");
let vk;
users.map(user => {
console.log(user)
vk = new VK({
token: user.token
})
});
const bot = new HearManager();
vk.updates.on('message_new', bot.middleware);
bot.hear(/^!start/, ctx => {
if(ctx.senderId !== id) return;
vk.api.messages.send({ chat_id: ctx.chatId, message: "Hi", random_id: getRandomId() })
});
vk.updates.start().catch(console.error);
console.log("Bot has been started!");
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question