Skip to content

Repository files navigation

#plugAPI

Status

NPMNPM

NPMDavid

About

A generic NodeJS API for creating plug.dj bots.

Originally by Chris Vickery, now maintained by TAT and The plug³ Team.

NOTE: Currently not supporting facebook login.

How to use

Run the following:

npminstallplugapi--production

You can choose to instantiate plugAPI with either Sync or Async

Sync:

varPlugAPI=require('plugapi');varbot=newPlugAPI({email: '',password: ''});bot.connect('roomslug');// The part after https://plug.djbot.on('roomJoin',function(room){console.log("Joined "+room);});

Async:

varPlugAPI=require('plugapi');newPlugAPI({email: '',password: ''},function(bot){bot.connect('roomslug');// The part after https://plug.djbot.on('roomJoin',function(room){console.log("Joined "+room);});});

Examples

Here are some bots that are using this API.

BotnameRoom
AuntJackieMix-N-Mash
BeavisBotI <3 the 80's and 90's
-DnB-Drum & Bass
FlavorBarFlavorz
FoxBotApproaching Nirvana
TFLBotThe F**k Off Lounge | TFL

Have a bot that uses the API? Let us know!

EventListener

You can listen on essentially any event that plug emits.

// basic chat handler to show incoming chats formatted nicelybot.on('chat',function(data){if(data.type=='emote')console.log(data.from+data.message);elseconsole.log(data.from+"> "+data.message);});

Here's an example for automatic reconnecting on errors / close events!

varreconnect=function(){bot.connect(ROOM);};bot.on('close',reconnect);bot.on('error',reconnect);

API

Please Refer to the Wiki for both the Events and Actions.

Troubleshooting

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.

Contribute

  1. Clone repository to empty folder.
  2. Cd to the folder containing the repository.
  3. Run npm install to set up the environment.
  4. Edit your changes in the code, and make sure it follows our Style Guidelines.
  5. Run grunt to compile the code and test your changes.
  6. After it's bug free, you may submit it as a Pull Request to this repo.

Misc

Multi line chat

Since Plug.dj cuts off chat messages at 250 characters, you can choose to have your bot split up chat messages into multiple lines:

varbot=newPlugAPI(auth);bot.multiLine=true;// Set to true to enable multi line chat. Default is falsebot.multiLineLimit=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.

TCP Server

You can start up a TCP server the bot will listen to, for remote administration

Example:

bot.tcpListen(6666,'localhost');bot.on('tcpConnect',function(socket){// executed when someone telnets into localhost port 6666});bot.on('tcpMessage',function(socket,msg){// 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});

About

A generic API for creating plug.dj bots

Resources

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages