A
A
Alexander Arkhangelsky2021-07-07 12:27:46
JavaScript
Alexander Arkhangelsky, 2021-07-07 12:27:46

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

1 answer(s)
E
Eugene, 2021-07-07
@Nc_Soft

move all logic inside users.map

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question