-
Notifications
You must be signed in to change notification settings - Fork 11
multi bot on one file
chris larosa edited this page Jun 9, 2013
·
5 revisions
var Bot = require('ttapi');
global.bots = []; //keeps track of the bots after creation
//specifies bots to be created
global.login = [
{
auth: 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
userid: 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
},
{
auth: 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
userid: 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
},
{
auth: 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
userid: 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
}
]
//creates new bots
global.logbot = function(auth, userid, roomid)
{
bots.push(new Bot(auth,userid,roomid));
};
//room to go to
var roomid = '50805b63eb35c1398d000061';
for(var i = 0; i < login.length; i++)
{
//creates the bots
logbot(login[i].auth, login[i].userid, roomid);
}
//each bot has its own event listener
bots[0].on('roomChanged', function(call)
{
console.log('this is bot 1; users in room: ' + call.users.length);
});
bots[1].on('roomChanged', function(call)
{
console.log('this is bot 2; users in room: ' + call.users.length);
});
bots[2].on('roomChanged', function(call)
{
console.log('this is bot 3; users in room: ' + call.users.length);
});