Giter VIP home page Giter VIP logo

plugapi's Introduction

#plugAPI Build Status npm version npm downloads NPM David Slack Status

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:

npm install plugapi --production

You can choose to instantiate plugAPI with either Sync or Async

Sync:

var PlugAPI = require('plugapi');
var bot = new PlugAPI({
    email: '',
    password: ''
});

bot.connect('roomslug'); // The part after https://plug.dj

bot.on('roomJoin', function(room) {
    console.log("Joined " + room);
});

Async 3.5.0 and Below:

var PlugAPI = require('plugapi');

new PlugAPI({
    email: '',
    password: ''
}, function(bot) {
    bot.connect('roomslug'); // The part after https://plug.dj

    bot.on('roomJoin', function(room) {
        console.log("Joined " + room);
    });
});

Async 4.0.0:

var PlugAPI = require('plugapi');

new PlugAPI({
    email: '',
    password: ''
}, function(err, bot) {
    if (!err) {
        bot.connect('roomslug'); // The part after https://plug.dj

        bot.on('roomJoin', function(room) {
            console.log("Joined " + room);
        });
    } else {
        console.log('Error initializing plugAPI: ' + err);
    }
});

Examples

Here are some bots that are using this API.

Botname Room
AuntJackie Mix-N-Mash
BeavisBot I <3 the 80's and 90's
-DnB- Drum & Bass
FlavorBar Flavorz
FoxBot Approaching Nirvana
TFLBot The F**k Off Lounge | TFL
QBot EDM Qluster
Holly Refbots Connect The Songs (Read Info!)
DRPG Discord Dungeons

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 nicely
bot.on('chat', function(data) {
    if (data.type == 'emote')
        console.log(data.from + data.message);
    else
        console.log(data.from + "> " + data.message);
});

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

var reconnect = function() { bot.connect(ROOM); };

bot.on('close', reconnect);
bot.on('error', reconnect);

API

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

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 npm test to make sure all tests pass.
  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:

var bot = new PlugAPI(auth);

bot.deleteAllChat = false; // Set to true to enable deletion of chat regardless of role . Default is false
bot.multiLine = true; // Set to true to enable multi line chat. Default is false
bot.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.

plugapi's People

Contributors

tatdk avatar thedark1337 avatar chrisinajar avatar anjanms avatar backus avatar avatarkava avatar mnme avatar atomjack avatar xpapla avatar nthitz avatar void-i avatar chrishayesmu avatar jtbrinkmann avatar revanace avatar ronaldb avatar au2001 avatar purechaose avatar saneki avatar xbytez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.