plugged is a (v|f)ast JavaScript API for the plug.dj service.
npm install plugged
plugged is relatively easy to use. Most functions are exposed via events, thus it's easy to check for certain data.
To start with a simple bot, do this:
var Plugged = require("plugged");
var plug = new Plugged();
// log into the service
plug.login({ email: "[email protected]", password: "examplepassword" });
plug.on(plug.LOGIN_SUCCESS, function _loginSuccess() {
plug.cacheChat(true);
plug.connect("exampleroom");
});
plug.on(plug.JOINED_ROOM, function _joinedRoom() {
plug.on(plug.ADVANCE, function() {
//WOOT!
plug.woot();
});
});
Most functionality is exposed via Events. The wiki describes how to use what events when.
Sometimes you need to call data from the server, for example if you want to get your current playlist, add a new media file or get a certain list of rooms based on a search string. All Server calls are described in the wiki