plugAPI icon indicating copy to clipboard operation
plugAPI copied to clipboard

2 bots

Open Botanistt opened this issue 10 years ago • 9 comments

Is there a way to run 2 bots at once?

Botanistt avatar Jun 17 '16 23:06 Botanistt

well, you can try it out?

promise avatar Jun 18 '16 08:06 promise

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 ?

Botanistt avatar Jun 18 '16 08:06 Botanistt

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

Uricorn avatar Jun 18 '16 08:06 Uricorn

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

Botanistt avatar Jun 18 '16 09:06 Botanistt

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

samhmills avatar Jun 18 '16 09:06 samhmills

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

JTBrinkmann avatar Jun 18 '16 11:06 JTBrinkmann

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.

Talos51 avatar Jun 18 '16 12:06 Talos51

@JTBrinkmann Yes I did.

Botanistt avatar Jun 18 '16 12:06 Botanistt

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

TheBanHammer avatar Mar 21 '17 15:03 TheBanHammer