<commit_before>## plugAPI  [![Build Status](https://img.shields.io/travis/plugCubed/plugAPI.svg)](https://travis-ci.org/plugCubed/plugAPI) [![npm version](http://img.shields.io/npm/v/plugapi.svg)](https://npmjs.org/package/plugapi) [![npm downloads](https://img.shields.io/npm/dm/plugapi.svg)](https://npmjs.org/package/plugapi) [![NPM](https://img.shields.io/npm/l/plugapi.svg)](https://github.com/plugCubed/plugAPI/blob/master/LICENSE.md) [![David](https://img.shields.io/david/plugcubed/plugapi.svg)](https://david-dm.org/plugcubed/plugapi) [![Slack Status](https://slack.plugcubed.net/badge.svg)](https://slack.plugcubed.net)


## About


A generic NodeJS API for creating plug.dj bots.

Originally by [<NAME>](https://github.com/chrisinajar), now maintained by [TAT](https://github.com/TATDK) and [The plug³ Team](https://github.com/plugCubed).

**NOTE:** Currently not supporting Facebook login.

## How to use
Run the following:

``` javascript
npm install plugapi --production
```

You can choose to instantiate plugAPI with either Sync or Async:

**Sync:**

```javascript
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:**

```javascript
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:**

```javascript
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](https://plug.dj/mix-n-mash-2)                      |
| [BeavisBot](https://github.com/AvatarKava/BeavisBot) | [I <3 the 80's and 90's](https://plug.dj/i-the-80-s-and-90-s-1) |
| -DnB-                                                | [Drum & Bass](https://plug.dj/drum-bass)                        |
| FlavorBar                                            | [Flavorz](https://plug.dj/flavorz)                              |
| FoxBot                                               | [Approaching Nirvana](https://plug.dj/approachingnirvana)       |
| TFLBot                                               | [The F**k Off Lounge \| TFL](https://plug.dj/thedark1337)       |
| [KawaiiBot](https://twitter.com/IAmKawaiiBot)        | [AnimeMusic.me](http://www.animemusic.me)                       | 
| QBot                                                 | [EDM Qluster](https://plug.dj/qluster)                          |
| Holly Refbots                                        | [Connect The Songs (Read Info!)](https://plug.dj/connect-the-songs-read-info/) |
| prehibicja                                           | [[PL] Prohibicja.xyz ANY GENRE](https://plug.dj/prohibicja) |
| DRPG                                                 | [Discord Dungeons](https://plug.dj/discorddungeons)             |
| brainbot                                             | [5M4R7](https://plug.dj/5m4r7)                                  |
| [Toaster-chan](https://git.io/vDTfR)                 | [☆ ♥ Nightcore-331 ♥ ☆](https://plug.dj/nightcore-331)         |
| [F!shtank](https://github.com/botnation/fishtank)    | [SWaQ Hanger](https://plug.dj/swaq-hanger/)                     |

Have a bot that uses the API? [**Let us know!**](https://github.com/plugCubed/plugAPI/issues/new)

## EventListener
You can listen on essentially any event that plug emits.
```javascript
// 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!
```javascript
var reconnect = function() { bot.connect(ROOM); };<commit_msg>Added BotX/ Nightcore Fanclub (#132)<commit_after>## plugAPI  [![Build Status](https://img.shields.io/travis/plugCubed/plugAPI.svg)](https://travis-ci.org/plugCubed/plugAPI) [![npm version](http://img.shields.io/npm/v/plugapi.svg)](https://npmjs.org/package/plugapi) [![npm downloads](https://img.shields.io/npm/dm/plugapi.svg)](https://npmjs.org/package/plugapi) [![NPM](https://img.shields.io/npm/l/plugapi.svg)](https://github.com/plugCubed/plugAPI/blob/master/LICENSE.md) [![David](https://img.shields.io/david/plugcubed/plugapi.svg)](https://david-dm.org/plugcubed/plugapi) [![Slack Status](https://slack.plugcubed.net/badge.svg)](https://slack.plugcubed.net)


## About


A generic NodeJS API for creating plug.dj bots.

Originally by [<NAME>](https://github.com/chrisinajar), now maintained by [TAT](https://github.com/TATDK) and [The plug³ Team](https://github.com/plugCubed).

**NOTE:** Currently not supporting Facebook login.

## How to use
Run the following:

``` javascript
npm install plugapi --production
```

You can choose to instantiate plugAPI with either Sync or Async:

**Sync:**

```javascript
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:**

```javascript
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:**

```javascript
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](https://plug.dj/mix-n-mash-2)                      |
| [BeavisBot](https://github.com/AvatarKava/BeavisBot) | [I <3 the 80's and 90's](https://plug.dj/i-the-80-s-and-90-s-1) |
| -DnB-                                                | [Drum & Bass](https://plug.dj/drum-bass)                        |
| FlavorBar                                            | [Flavorz](https://plug.dj/flavorz)                              |
| FoxBot                                               | [Approaching Nirvana](https://plug.dj/approachingnirvana)       |
| TFLBot                                               | [The F**k Off Lounge \| TFL](https://plug.dj/thedark1337)       |
| [KawaiiBot](https://twitter.com/IAmKawaiiBot)        | [AnimeMusic.me](http://www.animemusic.me)                       | 
| QBot                                                 | [EDM Qluster](https://plug.dj/qluster)                          |
| Holly Refbots                                        | [Connect The Songs (Read Info!)](https://plug.dj/connect-the-songs-read-info/) |
| prehibicja                                           | [[PL] Prohibicja.xyz ANY GENRE](https://plug.dj/prohibicja) |
| DRPG                                                 | [Discord Dungeons](https://plug.dj/discorddungeons)             |
| brainbot                                             | [5M4R7](https://plug.dj/5m4r7)                                  |
| [Toaster-chan](https://git.io/vDTfR)                 | [☆ ♥ Nightcore-331 ♥ ☆](https://plug.dj/nightcore-331)         |
| [F!shtank](https://github.com/botnation/fishtank)    | [SWaQ Hanger](https://plug.dj/swaq-hanger/)                     |
| BotX                                                 | [NightCore Fanclub] (https://plug.dj/nightcore-fanclub          |

Have a bot that uses the API? [**Let us know!**](https://github.com/plugCubed/plugAPI/issues/new)

## EventListener
You can listen on essentially any event that plug emits.
```javascript
// 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!
```javascript
var reconnect = function() { bot.connect(ROOM); };
{'fraction_non_alphanumeric': 0.18616005094459775, 'fraction_numerical': 0.007323285926554872, 'mean_word_length': 1.7674008810572688, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 71, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 54, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '152126', 'n_tokens_mistral': 2971, 'n_tokens_neox': 2782, 'n_words': 512}