Generic API for building plug.dj bots
A generic NodeJS API for creating plug.dj bots.
NOTE: Currently not supporting facebook login.
Run the following:
npm install plugapi --production
You can choose to instantiate plugAPI with either Sync or Async
var PlugAPI = require'plugapi';var bot =email: ''password: '';botconnect'roomslug'; // The part afterboton'roomJoin'console.log"Joined " + room;;
var PlugAPI = require'plugapi';email: ''password: ''botconnect'roomslug'; // The part afterboton'roomJoin'console.log"Joined " + room;;;
Here are some bots that are using this API.
|BeavisBot||I <3 the 80's and 90's|
|-DnB-||Drum & Bass|
|TFLBot||The F**k Off Lounge | TFL|
|Holly Refbots||Connect The Songs (Read Info!)|
Have a bot that uses the API? Let us know!
You can listen on essentially any event that plug emits.
// basic chat handler to show incoming chats formatted nicelyboton'chat'if datatype == 'emote'console.logdatafrom + datamessage;elseconsole.logdatafrom + "> " + datamessage;;
Here's an example for automatic reconnecting on errors / close events!
var botconnectROOM; ;boton'close' reconnect;boton'error' reconnect;
Please Refer to the Wiki for both the Events and Actions.
If you are having issues connecting, please check if cookies.tmp exists in node_modules/plugapi, if it does delete that and try to connect again.
Please note that at this current time only one account may be used per plugAPI installation due to the cookies.tmp file.
npm installto set up the environment.
gruntto compile the code and test your changes.
Since Plug.dj cuts off chat messages at 250 characters, you can choose to have your bot split up chat messages into multiple lines:
var bot = auth;botmultiLine = true; // Set to true to enable multi line chat. Default is falsebotmultiLineLimit = 5; // Set to the maximum number of lines the bot should split messages up into. Any text beyond this number will just be omitted. Default is 5.
You can start up a TCP server the bot will listen to, for remote administration
bottcpListen6666 'localhost';boton'tcpConnect'// executed when someone telnets into localhost port 6666;boton'tcpMessage'// Use socket.write, for example, to send output back to the telnet session// 'msg' is whatever was entered by the user in the telnet session;