plugCubed/plugAPI

2 bots

Closed this issue · 9 comments

Is there a way to run 2 bots at once?

well, you can try it out?

var PlugAPI = require('plugapi');
var bot = new PlugAPI({
    email: '',
    password: ''
});
var bot2 = new PlugAPI({
    email: '',
    password: ''
});

bot.connect('roomslug'); // The part after https://plug.dj
bot2.connect('roomslug'); // The part after https://plug.dj
});

Well I tried this and it didn't work.
Is there another way ?

I once got it to work by having them in different directories, using different bot.js files and different plugapi files.

It works if I create 2 different bot.js files but is there a way to run 2 bots with single js file?

Isn't this because they both share either cookie data or something else?

Alex probably needs to fix this if this does not work as this is breaking expected behaviour

did you use a different accounts for each bot? @Botanistt

As Hunchmun said, instances of PlugAPI relies on _cookie file, if you've installed your plugAPI globally ( -g option with npm ) all your instances will share the same file, at the moment you should be able to run the same bot with one "global" file, but you'll need to put the room as start argument for example, have two different plugDJ accounts and install "locally" a plugAPI module for each bot you'll run.

So you could end up with something like that:

/usr/local/lib/nodejs/bot1/nodejs_modules/plugapi
/usr/local/lib/nodejs/bot1/nodejs/bot.js*

/usr/local/lib/nodejs/bot2/nodejs_modules/plugapi
/usr/local/lib/nodejs/bot2/nodejs/bot.js*

(*): /usr/local/lib/nodejs/bot.js

bot.js could be a symlink to a global bot.js file in order to modify your bot once and apply it to every instances.

That should do the trick since you'll run two different instances of PlugAPI module in separated folders.

@JTBrinkmann Yes I did.

This should be fixed in version 5 of PlugAPI which is currently being worked on.