Giter Site home page Giter Site logo

plugapi's Introduction

plugAPI Build Status npm version npm downloads NPM David Discord Server

About

A generic NodeJS API for creating plug.dj bots.

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

How to use

Run the following:

npm install plugapi

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

Sync:

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

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

bot.on(PlugAPI.events.ROOM_JOIN, (room) => {
    console.log(`Joined ${room}`);
});

Async:

const PlugAPI = require('plugapi');

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

        bot.on(PlugAPI.events.ROOM_JOIN, (room) => {
            console.log(`Joined ${room}`);
        });
    } else {
        console.log(`Error initializing plugAPI: ${err}`);
    }
});

New features in V5.0.0

Guest login is now possible if no userdata is passed into plugAPI or guest is set to true

Guest:

const PlugAPI = require('plugapi');
const bot = new PlugAPI();
// OR
const bot = new PlugAPI({
    guest: true
});

Facebook login is now possible. Easiest way to obtain the Access Token and user ID is to login via fb on plug and view the request data.

Facebook:

const PlugAPI = require('plugapi');
const bot = new PlugAPI({
    facebook: {
        accessToken: 'xxxxxxxx',
        userID: 'xxxxxxxx'
    }
});

PlugAPI now uses tough-cookie to store cookies. Refer to the wiki for more information.


Examples

Here are some bots that are using this API.

Botname Room
AuntJackie Mix-N-Mash
BotX NightCore Fanclub
BeavisBot I <3 the 80's and 90's
brainbot 5M4R7
Charlotte Youtunes
-DnB- Drum & Bass
DRPG Discord Dungeons
Ekko EDT
F!shtank SWaQ Hanger
FlavorBar Flavorz
FoxBot Approaching Nirvana
Holly Refbots Connect The Songs (Read Info!)
KawaiiBot AnimeMusic
prehibicja [PL] Prohibicja.xyz ANY GENRE
QBot EDM Qluster
Skynet Cubed PlugCubed
TFLBot The F**k Off Lounge | TFL
Toaster-chan ☆ ♥ Nightcore-331 ♥ ☆
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(PlugAPI.events.CHAT, (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

const reconnect = () => { bot.connect(ROOM); };

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

API Documentation

For V4 documentation, the Wiki is the best resource.

For V5 documentation, please refer to the Docs for documentation on methods and events. The documentation is written in JSDoc in the respective files found in the lib/ folder. If there are changes to be made, edit the JSDoc and run the followng command:

npm run docs

Submit a pull request and wait for review


Contribute

  1. Clone repository to an 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 codestyle.
  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 repository.

Misc Options

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.

Delete Message Blocks

With how plug currently works, deleting messages deletes the entire group of messages from the same user. Set this option to disallow that.

Delete All Chat

PlugAPI mimics plug's behavior in disallowing deletion of chat of users above the bot's rank. Setting this option to true will bypass that check.

var bot = new PlugAPI(auth);
bot.deleteMessageBlocks = false; //set to true if you want the bot to not delete grouped messages. Default is false.
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

anjanms avatar atomjack avatar au2001 avatar avatarkava avatar backus avatar chrishayesmu avatar chrisinajar avatar dazzuh avatar jtbrinkmann avatar mnme avatar mogery avatar mortenn avatar nthitz avatar ownsideup avatar purechaose avatar revanace avatar ronaldb avatar saneki avatar talos51 avatar tatdk avatar thebanhammer avatar thedark1337 avatar tnws avatar uricorn avatar void-i avatar xbytez avatar xpapla avatar xsidewinderx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plugapi's Issues

Random bot crash

Hello there TATDK,

The bot randomly crashes at this point, I don't know how to reproduce this bug but it randomly happens.

/home/bot/PlugAPI/node_modules/plugapi/bin/client.js:60
RATE_STAFF:for(var b in a.data.users)room.staff[a.data.users[b].user.id]=a.dat
^
TypeError: Cannot read property 'id' of undefined
at messageHandler (/home/bot/PlugAPI/node_modules/plugapi/bin/client.js:60:191)
at EventEmitter.dataHandler (/home/bot/PlugAPI/node_modules/plugapi/bin/client.js:59:114)
at EventEmitter.emit (events.js:117:20)
at Object.XHRStreaming.emitData (/home/bot/PlugAPI/node_modules/plugapi/node_modules/sockjs-client/lib/sockjs-client.js:313:30)
at Object.XHRStreaming.running (/home/bot/PlugAPI/node_modules/plugapi/node_modules/sockjs-client/lib/sockjs-client.js:284:26)
at Object.StateMachine.invoke (/home/bot/PlugAPI/node_modules/plugapi/node_modules/sockjs-client/lib/sockjs-client.js:349:29)
at Object. (/home/bot/PlugAPI/node_modules/plugapi/node_modules/sockjs-client/lib/sockjs-client.js:378:29)
at IncomingMessage.EventEmitter.emit (events.js:95:17)
at IncomingMessage. (_stream_readable.js:746:14)
at IncomingMessage.EventEmitter.emit (events.js:92:17)

getUsers

it seems to me that bot.getUsers() doesn't update when users leave. There are currently 13 in my room but when i call bot.getUsers().length its 20. It goes up and doesn't update.

lastPlay.dj not populated on 'advance' when user has left the room

When a user leaves the room while spinning (either kicked/banned or just closes out the window), the song continues playing.

In this case, when the 'advance' event is emitted on the start of the next song, the lastPlay container is filled for media and score, but the dj is null.

Is it possible to grab this data at the start of the song and maybe overwrite it at the end (in case the user's info has been updated) - this should ensure that lastPlay is always either null or fully populated.

API not receiving events after initial login?

After last night's plug.dj update, the API doesn't seem to receive any events after logging in. My bot connects, the advance event fires to get the initial data (current DJ, dj list, lastPlay, media, startTime, etc.), and then nothing.

I assume something changed in the API interface with plug. The weird thing is plugCubed seems to receive all events no questions asked... But I don't see any changes in plugCubed other than the plug version updated.

Anyone else experiencing this?

this.getUser() returns null

getting this error:

pe.moderateLockBooth=function(a,b,c){if(!this.roomId||this.getUser().permissio
^
TypeError: Cannot read property 'permission' of null
at PlugAPI.moderateLockBooth (/home/wouter/node_modules/plugapi/bin/client.js:79:255)
at PlugAPI.moderateLockWaitList (/home/wouter/node_modules/plugapi/bin/client.js:78:475)

getAdmins() not working

The getAdmin action from the API doesn't seem to function. I've looked at the room.js file and it doesn't seem to have a getAdmins() function.

Error: stream.push() after EOF

I seem to be getting this error quite often now and It appears at random.

26 Jun 07:54:23 [Socket Server] Closed
Error: stream.push() after EOF
    at readableAddChunk (_stream_readable.js:142:15)
    at IncomingMessage.Readable.push (_stream_readable.js:123:10)
    at HTTPParser.parserOnBody (_http_common.js:132:22)
    at TLSSocket.socketOnData (_http_client.js:277:20)
    at TLSSocket.EventEmitter.emit (events.js:101:17)
    at readableAddChunk (_stream_readable.js:156:16)
    at TLSSocket.Readable.push (_stream_readable.js:123:10)
    at TCP.onread (net.js:509:20)

No checking for muted users

Well, I didn't want to post it her, but here I go.

So, as the title says, PlugAPI does not check for muted users. What I mean by this is that if a user some how manages to send a message while muted with a script like this then PlugAPI registers the message like normal and doesn't know that the user was even meant to be muted. Therefore, with that script you are able to send multiple messages to a bot like BeavisBot and make the bots spam for you. Which will eventually lead to problem if multiple users do it and is it done once every second with sometime like a setInterval which will eventually lead to the bot spamming the room and the bot getting banned temporarily.

What happens "client-side"? Well basically, if you remove yourself from the muted array which is contained within' your client, you are still able to send messages to the socket and the socket * will * re-broadcast them. The other clients won't register the message in chat because they have the same object array which you do, except that you are still in it. Therefore PlugAPI doesn't have that object array and therefore has no damn clue.

I agree that is mostly plugs problem for being dumbasses and checking everything client-side, but that is besides the point. Plug won't patch this up for a while, if ever. So, it'd be great if you could remove my temptation to give Beavis hell.

Thanks for reading,
Thomas

Auth token

How do you get the auth token? I've searched and cannot find this. Thanks!

API keeps making the bot crash <html>

undefined:1
<html>
^
SyntaxError: Unexpected token <
    at Object.parse (native)
    at Request._callback (/home/animecafe/bot/node_modules/plugapi/src/client.js
:213:21)
    at Request.init.self.callback (/home/animecafe/bot/node_modules/plugapi/node
_modules/request/request.js:121:22)
    at Request.EventEmitter.emit (events.js:99:17)
    at Request.onResponse (/home/animecafe/bot/node_modules/plugapi/node_modules
/request/request.js:978:14)
    at Request.EventEmitter.emit (events.js:126:20)
    at IncomingMessage.Request.onResponse.buffer (/home/animecafe/bot/node_modul
es/plugapi/node_modules/request/request.js:929:12)
    at IncomingMessage.EventEmitter.emit (events.js:126:20)
    at IncomingMessage._emitEnd (http.js:366:10)
    at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23
)

Unicode not working?

Hi. Just starting out with this so sorry if this is a basic question. Can you tell me what I need to change in order to make this code work?

bot.on('chat', function(data) {
if (data.message === '!face')
bot.sendChat("◜◦﹏ु◦◝");
});

I'm saving my repl.js as UTF-8 but in the plug.dj chat I'm getting "﹏ु" or worse jumble. Thanks!

Interest in automated smoke tests

Hello,

I'm having a problem with the latest version not pulling playlists. I've not confirmed yet the exact source of the problem but I don't see any automated smoke tests.

Would you be interested in accepting a pull request that adds automated smoke tests? What I'm imagining is a series of tests that require that you configure sample credentials that then hits the actual plug API end points to verify which ones work and which ones have changed. I imagine this would simplify keeping up with API changes by the plug team.

Would you be interested in something like this?

p.s. I'm not an experienced javascript developer so I don't have any strong opinions on frameworks, etc.

Error: No Method 'chat'

I am getting this:
17 Apr 18:56:41 [GATEWAY ERROR] [TypeError: Object [object Object] has no method 'chat']
Any idea why?

Short example of the code:
bot.on('chat', userChat);
function userChat(data) {
bla bla bla
}

Problem getting bot to join room properly

I'm trying to convert from atomjack's fork of plugapi to this version. I know there's some differences and I thought I'd accounted for all of them, but I'm still having trouble with the bot connecting properly to the room. For lack of a better explanation, the bot "half joins" the room - it's not visible in the userlist and the roomJoin event never fires, but it does see people joining and will respond to their commands. With atomjack's version, that usually meant the update code was wrong, but that's clearly not the case in this API.

Any idea what I might be missing?

Move user in waitlist

Hello, is there function which move user to determined position?
Something like moderateMoveUser(userID,Position)

Constant errors and reconnect attempts

I copied the basic code for connecting to a room, but am getting constant errors with reconnect attempts.

The log looks like this:

9 Apr 14:24:38 [Socket Server] Error: [ '[object Object]' ]
9 Apr 14:24:38 [Socket Server] Reconnecting
9 Apr 14:24:38 [Socket Server] Error: [ '[object Object]' ]
9 Apr 14:24:38 [Socket Server] Reconnecting
9 Apr 14:24:38 [Chat Server] Connected
9 Apr 14:24:38 [Chat Server] Closed with code 1000
9 Apr 14:24:38 [Chat Server] Reconnecting
9 Apr 14:24:38 [Socket Server] Error: [ '[object Object]' ]
9 Apr 14:24:38 [Socket Server] Reconnecting
9 Apr 14:24:38 [Socket Server] Error: [ '[object Object]' ]
9 Apr 14:24:38 [Socket Server] Reconnecting
9 Apr 14:24:38 [Chat Server] Connected
9 Apr 14:24:38 [Chat Server] Closed with code 1000
9 Apr 14:24:38 [Chat Server] Reconnecting
9 Apr 14:24:38 [Socket Server] Error: [ '[object Object]' ]
9 Apr 14:24:38 [Socket Server] Reconnecting
9 Apr 14:24:38 [Socket Server] Error: [ '[object Object]' ]
9 Apr 14:24:38 [Socket Server] Reconnecting
9 Apr 14:24:39 [Chat Server] Connected
9 Apr 14:24:39 [Chat Server] Closed with code 1000
9 Apr 14:24:39 [Chat Server] Reconnecting

Request for comments: Moving into The plug³ Team

I have been thinking for a while if I should move plugAPI under The plug³ Team.

The reasons

I believe plugAPI falls under the idea "Adding a new dimension to plug.dj"

Because it's adds more to plug.dj; a whole new way of moderating and another way of connecting. I can see and have seen plugAPI being used for other things than moderating because of the possibilities plugAPI give.

Possibility of having a expandable team behind

Currently as it is, I can add contributors to this repository, but I don't believe that's a good way of expanding a possible team behind plugAPI.
By going under The plug³ Team there is a better way of having an expandable team.
That also makes sure that the coding quality and style in both plug³ and plugAPI is the same.

plug³'s new system

plug³ is working on a big change in the backend and it's going to include a bot running on plugAPI.

Colors

For those working with the develop branch, have probably noticed the addition of colors to the console.
I mainly added it to make it easier to see errors while working on updating the code, but maybe it's something that should stay.

I could make it an optional dependency and then use the colors if the colors module is installed.

What are your thoughts on the subject?

Advance event triggers upon binding

Whenever I respond to the advance event, it triggers automatically as soon as I bind the event. Besides that, it works fine everytime the song changes.
Is that intended behaviour?

bot.on('advance', function(){
    var now = new Date();
    console.log(now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds(), 'event triggered');
});

This is what my terminal looks like:

29 Dec 05:49:03 [INFO]     [plugAPI]  Running plugAPI v.3.0.0
29 Dec 05:49:05 [SUCCESS]  [plugAPI]  [Socket Server] Connected
5:49:7 event triggered

Bot crashes on advance event (every song)

/home/mburke/Projects/BeavisBot/node_modules/plugapi/src/room.js:417
    if (songHistory.length < 1) {
                   ^
TypeError: Cannot read property 'length' of null
    at Room.advance (/home/mburke/Projects/BeavisBot/node_modules/plugapi/src/room.js:417:20)
    at WebSocket.messageHandler (/home/mburke/Projects/BeavisBot/node_modules/plugapi/src/client.js:807:18)
    at WebSocket.emit (events.js:117:20)
    at WebSocket.<anonymous> (/home/mburke/Projects/BeavisBot/node_modules/plugapi/src/client.js:692:24)
    at WebSocket.emit (events.js:98:17)
    at Receiver.ontext (/home/mburke/Projects/BeavisBot/node_modules/plugapi/node_modules/ws/lib/WebSocket.js:741:10)
    at Receiver.opcodes.1.finish (/home/mburke/Projects/BeavisBot/node_modules/plugapi/node_modules/ws/lib/Receiver.js:391:14)
    at Receiver.expectHandler (/home/mburke/Projects/BeavisBot/node_modules/plugapi/node_modules/ws/lib/Receiver.js:378:31)
    at Receiver.add (/home/mburke/Projects/BeavisBot/node_modules/plugapi/node_modules/ws/lib/Receiver.js:87:24)
    at CleartextStream.firstHandler (/home/mburke/Projects/BeavisBot/node_modules/plugapi/node_modules/ws/lib/WebSocket.js:718:22)

Method to getWaitList() in order?

There's probably a nice JS workaround for this, but I'm not aware of it - or maybe I have a code issue that I'm not seeing.

getWaitList() and getDJs() return an array of user objects. It seems that NodeJS orders these arbitrarily when iterating over the list using forEach(). Since the wait list position isn't provided in the plug API from these calls, iterating over the returned array can have unpredictable results... or does for me, at least.

Calls to getWaitList() on consecutive songs give me the same ordering of objects inside the array, but using forEach() to loop over them results in a completely different ordering.

Is there an "easy" way to get the waitlist in an order that can be looped over? Do I need to call getWaitListPosition() on each ID and then push the results into a re-indexed array? Something else I'm overlooking?

plugapi not working. could be updateCode

Hi,

My bot was working fine yesterday but when I came to turn it on today I get the following:

D:\Chill Bot>node bot
connecting to the Chill Bot Database...
13 Jun 10:40:48 Running plugAPI v.2.2.3
13 Jun 10:40:49 [Socket Server] Connected
Connected to the Chill Bot Database!
Chill Bot Database Opened!
13 Jun 10:40:49 [Chat Server] Connected

D:\Chill Bot\node_modules\plugapi\bin\client.js:42
nown error");setTimeout(function(){joinRoom(a,b)},1E3);return}throw Error("Wro
^
Error: Wrong updateCode
at Error ()
at Object.callback (D:\Chill Bot\node_modules\plugapi\bin\client.js:42:253)
at EventEmitter.dataHandler (D:\Chill Bot\node_modules\plugapi\bin\client.js
:59:298)
at EventEmitter.emit (events.js:117:20)
at Object.XHRStreaming.emitData (D:\Chill Bot\node_modules\plugapi\node_modu
les\sockjs-client\lib\sockjs-client.js:313:30)
at Object.XHRStreaming.running (D:\Chill Bot\node_modules\plugapi\node_modul
es\sockjs-client\lib\sockjs-client.js:284:26)
at Object.StateMachine.invoke (D:\Chill Bot\node_modules\plugapi\node_module
s\sockjs-client\lib\sockjs-client.js:349:29)
at Object. (D:\Chill Bot\node_modules\plugapi\node_modules\sockjs
-client\lib\sockjs-client.js:378:29)
at IncomingMessage.EventEmitter.emit (events.js:95:17)
at IncomingMessage. (_stream_readable.js:745:14)

Wrong updateCode

After installing plugapi, and creating the sample program that just logs in, I get an error message "Wrong updateCode".

The updatecode.txt file the client.js retrieves contains h90. Is this the correct code, and am I missing something, or has the magic key changed (once again)?

PlugAPI don't work

Hello, i tried to use plugapi on new version of plug.dj but it's don't work.

Can someone help me?
It said this http://pbrd.co/1CMBbtJ

My code is
// -- BOT CORE --
var PlugAPI = require('plugapi');
var bot = new PlugAPI({
"email": "EMAIL",
"password": "PASSWORD"
});

// -- BOT CONNECT --
bot.connect('ROOMNAME');
bot.on('roomJoin', function(room) {
console.log("Joined " + room);
});

Joining the waitlist

I'm using the develop branch (it's working quite well so far), and I'm attempting to join the waitlist. However, I can't seem to find an action for it. Am I just looking in the wrong place?

"Closed with code 1000"

After a while, the API disconnects and cannot reconnect. The output is as follows

6 Sep 10:15:23 [WARNING]  [PlugAPI]  [Socket Server] Closed with code 1000
26 Sep 10:15:23 [INFO]     [PlugAPI]  [Socket Server] Reconnecting
26 Sep 10:15:34 [ERROR]    [PlugAPI]  [Socket Server] Error: { [Error: socket hang up] code: 'ECONNRESET', sslError: undefined }
26 Sep 10:15:34 [INFO]     [PlugAPI]  [Socket Server] Reconnecting
26 Sep 10:15:41 [ERROR]    [PlugAPI]  [Socket Server] Error: { [Error: socket hang up] code: 'ECONNRESET', sslError: undefined }
26 Sep 10:15:41 [INFO]     [PlugAPI]  [Socket Server] Reconnecting
26 Sep 10:15:49 [SUCCESS]  [PlugAPI]  [Socket Server] Connected
26 Sep 10:15:52 [WARNING]  [PlugAPI]  [Socket Server] Closed with code 1000
26 Sep 10:15:52 [INFO]     [PlugAPI]  [Socket Server] Reconnecting
26 Sep 10:16:08 [ERROR]    [PlugAPI]  [Socket Server] Error: { [Error: socket hang up] code: 'ECONNRESET', sslError: undefined }
26 Sep 10:16:08 [INFO]     [PlugAPI]  [Socket Server] Reconnecting
26 Sep 10:16:28 [ERROR]    [PlugAPI]  [Socket Server] Error: { [Error: socket hang up] code: 'ECONNRESET', sslError: undefined }
26 Sep 10:16:28 [INFO]     [PlugAPI]  [Socket Server] Reconnecting
26 Sep 10:16:40 [ERROR]    [PlugAPI]  [Socket Server] Error: { [Error: socket hang up] code: 'ECONNRESET', sslError: undefined }
26 Sep 10:16:40 [INFO]     [PlugAPI]  [Socket Server] Reconnecting
26 Sep 10:16:51 [SUCCESS]  [PlugAPI]  [Socket Server] Connected
26 Sep 11:17:05 [WARNING]  [PlugAPI]  [Socket Server] Closed with code 1000
26 Sep 11:17:05 [INFO]     [PlugAPI]  [Socket Server] Reconnecting
26 Sep 11:17:09 [SUCCESS]  [PlugAPI]  [Socket Server] Connected

And it wont reconnect until its restarted

NPM package is broken

animemusic@ns3300024:~$ npm install plugapi --production
npm ERR! Error: Invalid Package: expected sockjs-client-node but found sockjs-cl ient
npm ERR! at /home/animemusic/local/lib/node_modules/npm/lib/cache/add-local- tarball.js:161:14
npm ERR! at process._tickCallback (node.js:419:13)
npm ERR! If you need help, you may report this entire log,
npm ERR! including the npm and node versions, at:
npm ERR! http://github.com/npm/npm/issues

npm ERR! System Linux 3.10.23-xxxx-std-ipv6-64
npm ERR! command "node" "/home/animemusic/local/bin/npm" "install" "plugapi" "-- production"
npm ERR! cwd /home/animemusic
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.20
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/animemusic/npm-debug.log
npm ERR! not ok code 0

Unknown Endpoint

I am constantly receiving an unknown endpoint error. The PlugAPI successfully authenticates me (It kicks my current connection) but after I receive the Socket and Chat Server connected messages the log gets 8 unknown endpoint messages then fails to continue:

9 Jun 10:35:16 Running plugAPI v.2.2.2
9 Jun 10:35:16 [Socket Server] Connected
[+] Connected to server
9 Jun 10:35:17 [Chat Server] Connected
9 Jun 10:35:17 Unknown endpoint
9 Jun 10:35:18 Unknown endpoint
9 Jun 10:35:18 Unknown endpoint
9 Jun 10:35:19 Unknown endpoint
9 Jun 10:35:20 Unknown endpoint
9 Jun 10:35:20 Unknown endpoint
9 Jun 10:35:21 Unknown endpoint
9 Jun 10:35:22 Unknown endpoint

getWaitListPosition() errors out when wait list is empty

in /node_modules/plugapi/src/room.js:511
    var pos = booth.waitingDJs.indexOf(uid);
                               ^
TypeError: Cannot call method 'indexOf' of undefined
    at Room.getWaitListPosition (/node_modules/plugapi/src/room.js:511:32)
    at PlugAPI.getWaitListPosition (/node_modules/plugapi/src/client.js:1464:17)

djAdvance returns different data on initial load

It seems like the initial emission of the 'djAdvance' event (on init of the bot and room join) returns a different structure from that of a normal 'djAdvance' event when a spin ends.

It's easy enough to get the user data via the id supplied in currentDJ, but is this inconsistency intentional? (edit: I know it's inconsistent in the official Plug API as well)

30 Apr 00:28:51 Running plugAPI v.2.0.3
30 Apr 00:28:51 [Socket Server] Connected
30 Apr 00:28:52 [Chat Server] Connected
30 Apr 00:28:52 djAdvance:  {
  "currentDJ": "528fc340877b923909b6009c",
  "djs": [],
  "media": {
    "title": "My Bologna",
    "format": "1",
    "author": "\"Weird Al\" Yankovic",
    "cid": "LMeu3R0RdqI",
    "duration": 127,
    "id": "1:LMeu3R0RdqI"
  },
  "mediaStartTime": "2014-04-30 05:28:21.425000",
  "historyID": "536089f530ea866454d0b727"
}
30 Apr 00:28:52 [INIT] Joined room: Test

djAdvance not working

Hey again.
I think this funkction is not working.
My code is:
bot.on("djAdvance", function() {
console.log("lipsum");
});

Other functions working well but this not. Is it bug?

Request For Comments/Feedback : EventObjectTypes

I have just committed a change for the event objects and I would like some feedback.
Commit: 8b12f89

The idea is simply to convert plug.dj socket objects to easier to read objects.
So for example, the advance contains a d variable, which this system converts to djs.
Thereby, the messagehandler doesn't need to contain code for this and simply break to the end (emitting the event) instead of emitting the created object inside the switch and returning.

Calm yourselves, gentlemen, you have some more time to develop

Hey!

Just passing by to let you know that current issues that are connection and / or chat related will be fixed soon, for the old chat server will be coming back until developers can fix the new server's problems;
This means that any changes to adapt to the new server might be useless soon. Keep your eye out for the update! And have backups ;)

Thanks for being awesome!

Beta Tester
Brand Ambassador

moderateMuteUser() - Object #<Object> has no method 'indexOf'

/Users/anthony-jr/git/fimbot/node_modules/plugapi-develop/src/client.js:2053
        if (PlugAPI.MUTE.indexOf(duration) < 0) return false;
                         ^

Also:

/Users/anthony-jr/git/fimbot/node_modules/plugapi-develop/src/client.js:2058
        if (PlugAPI.MUTE_REASON.indexOf(reason) < 0) return false;
                                ^

Stuck on reconnecting.

Every few hours it gets kicked from the socket and gets stuck on reconnecting. It's still attached to the chat server though but it can't do any moderation.

Random bot crash, username of null

Hello, i created bot but sometimes it randomly crash.
Error is like "Cannot read 'username' of null".
I try user google but nothing, i think it's bug.

Not reconnecting on error 1000.

15 Oct 02:32:16 [WARNING]  [PlugAPI]  [Socket Server] Closed with code 1000
15 Oct 02:32:16 [INFO]     [PlugAPI]  [Socket Server] Reconnecting
15 Oct 02:32:17 [SUCCESS]  [PlugAPI]  [Socket Server] Connected

Although it says it has reconnected, no events go through.

Data type issue on this.vote in User object

In room.js:

that.votes[data.id] === 'woot' - I think it's always set to an integer value now as opposed to a string.

As a result, getWaitList() will return -1 in the vote field if the user has voted at all.

    this.User = function(data) {
        this.avatarID = data.avatarID ? data.avatarID : '';
        this.badge = data.badge ? data.badge : 0;
        this.blurb = data.blurb ? data.blurb : '';
        this.curated = that.grabs[data.id] === true;
        this.ep = data.ep ? data.ep : 0;
        this.gRole = data.gRole ? data.gRole : 0;
        this.id = data.id ? data.id : -1;
        this.ignores = data.ignores ? data.ignores : undefined;
        this.joined = data.joined ? data.joined : '';
        this.language = data.language ? data.language : '';
        this.level = data.level ? data.level : 0;
        this.notifications = data.notifications ? data.notifications : undefined;
        this.pVibes = data.pVibes ? data.pVibes : undefined;
        this.pw = data.pw ? data.pw : false;
        this.slug = data.slug ? data.slug : '';
        this.status = data.status ? data.status : 0;
        this.username = data.username ? data.username : '';
        this.vote = that.votes[data.id] !== undefined ? that.votes[data.id] === 'woot' ? 1 : -1 : 0;
        this.xp = data.xp ? data.xp : 0;
    };

ETA?

Is there an ETA for this API to finally be out of the development branch and finished up?

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.