Git Product home page Git Product logo

dubapi's People

Contributors

al3366 avatar anjanms avatar dakoenig avatar fuechschen avatar thedark1337 avatar zolfax avatar

Stargazers

 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

dubapi's Issues

queueMedia by YouTube or SoundCloud id

queueMedia works, but you need to use the Dubtrack song id which I haven't found a good way to look up easily. It's much easier to find YouTube or SoundCloud ids when using external track search APIs like EchoNest.

Would it be possible to add a feature where you can use queueMedia with the YouTube id (i.e. the {id} in youtube.com/watch?v={id}) or the SoundCloud song id?

pubnub?

Why are you using pubnub?

Room playlist history

Was wondering if you could add fetching Room playlist history with the option of choosing how many pages of history (with max limit of course)

This is the API endpoint for retrieving Room history
https://api.dubtrack.fm/room/%RID%/playlist/history?page=##

Each page returns an array of 20 length

It would be cool if I could so something like this:

bot.getRoomHistory(5, callback); // because it would be very very async of course

and that would return 5 pages of history, so an array of 100 length.

14 pages of history is about ~24 hours of playlist history in a room where everyone is playing average 3-6min songs. (array length of 280)

not super important, just something that would be nice

rank/unrank

is it possible to add rank and unrank methods to the API? more bothered about the unranking more than anything. use case is if a VIP becomes toxic and you need to get them out the room, need to derank them before you're able to ban them

Issue with updub

For some reason the bot is throwing this error when the updub method is passed. Any idea why?

events.js:141
throw er; // Unhandled 'error' event
^
DubAPIRequestError: Response 404 from room/55fc4c06c59e310300fd650d/playlist/5696fb3d066e0d2c00f6cb7b/dubs
at Error.DubAPIRequestError (/home/ubuntu/node_modules/dubapi/lib/errors/requestError.js:4:11)
at Request. (/home/ubuntu/node_modules/dubapi/lib/requestHandler.js:114:70)
at emitTwo (events.js:92:20)
at Request.emit (events.js:172:7)
at Request. (/home/ubuntu/node_modules/dubapi/node_modules/request/request.js:1035:10)
at emitOne (events.js:82:20)
at Request.emit (events.js:169:7)
at IncomingMessage. (/home/ubuntu/node_modules/dubapi/node_modules/request/request.js:962:12)
at emitNone (events.js:72:20)
at IncomingMessage.emit (events.js:166:7)

Where is unqueueMedia?

So, I am using a youtube API that pulls videos in for the bot to queue up which sometimes queues videos that are not really what I am looking for.. Am I not seeing unqueueMedia for individual queued songs by the bot or is this not a feature yet; is it possible to Implement? I know I could just skip the song once it plays but that is not very fancy x).

TypeError for PlayModel

TypeError: Cannot read property '_id' of undefined
    at new PlayModel (/var/plug/charlotte/node_modules/dubapi/lib/models/playModel.js:6:19)
    at Object.callback (/var/plug/charlotte/node_modules/dubapi/lib/actionHandler.js:71:23)
    at Request.<anonymous> (/var/plug/charlotte/node_modules/dubapi/lib/requestHandler.js:109:65)
    at emitTwo (events.js:92:20)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/var/plug/charlotte/node_modules/request/request.js:1035:10)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/var/plug/charlotte/node_modules/request/request.js:962:12)
    at emitNone (events.js:72:20)

Not sure how this happened but I got this quite a bit earlier. Seems there needs to be a check if the _id exists or not ๐Ÿ‘

Support for uppercase in usernames

Dubtrack apparently now supports uppercase letters in usernames - constructs like this will no longer work:
var user = bot.getUserByName(input.toLowerCase());

Removing toLowerCase() is a partial fix, but still requires the user to enter the case as an exact match.

Any thoughts on either:

  • Adjusting bot.getUserByName() to do a case-insensitive search on the user list (probably needing a mixin for underscore) OR
  • Storing all usernames in the user list in lowercase by default so that findWhere() works as expected

I think bot.getUserByName() is the only place this will apply in the DubAPI code, but you may be able to correct me if I'm wrong.

Upgrade to [email protected] because of security reasons

below info is taken from this report:
https://snyk.io/test/npm/dubapi/1.6.8?severity=high&severity=medium&severity=low

high severity

Denial of Service (DoS)

Vulnerable module: ws
Introduced through: [email protected] โ€บ [email protected] โ€บ [email protected]
Remediation: Upgrade to [email protected]

Affected versions of the package are vulnerable to Denial of Service (DoS) attacks. A specially crafted value of the Sec-WebSocket-Extensions header that used Object.prototype property names as extension or parameter names could be used to make a ws server crash.

There are 3 more less severe issues all related to engine.io-client as well so once you upgrade engine.io-client it should fix the other 3 issues as well

Callback to sendChat()

This would be useful, for example, to send a message after the first one is sent or getting the chatid of the message just sent to remove it after some time has passed.

Throw Ably errors when found

One of the main reasons my bot hangs is because of Ably errors that don't necessarily throw and stop my main node process but it just hangs and stops working. I'm wondering if there was a better way to catch and throw these type of errors in your lib

Bellow is what my PM2 logs show, it finally just gave up at that last line and I had to manually restart it.

They seem to be coming from this file or this file in the Ably lib. Not sure what could be done but figured I'd mention it in case you have any ideas.

thanks!

0|bot      | Ably: ConnectionManager.activateTransport(): error = [ErrorInfo: Unable to recover connection: not found (7uFB9Y-us_z3QmhI); statusCode=400; code=80008]
0|bot      | Ably: ConnectionManager.activateTransport(): error = [ErrorInfo: Unable to recover connection: not found (DtP2d1cAiJK8nEO5); statusCode=400; code=80008]
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1006
0|bot      | Ably: ConnectionManager.activateTransport(): error = [ErrorInfo: Unable to recover connection: not found (3L6sCLGEKMzIDtt7); statusCode=400; code=80008]
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1008
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1008
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1008
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1008
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1008
0|bot      | Ably: ConnectionManager.activateTransport(): error = [ErrorInfo: Unable to recover connection: not found (HtVQ1vVzULg_ibwD); statusCode=400; code=80008]
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1008
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1008
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1008
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1008
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1008
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1008
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1008
0|bot      | Ably: WebSocketTransport.onWsClose(): Unclean disconnection of WebSocket ; code = 1008
0|bot      | Ably: ConnectionManager.activateTransport(): error = [ErrorInfo: Unable to recover connection: not found (65i7UBlwUnePNTXj); statusCode=400; code=80008]

Control the bot's playlists and queue

Is it possible to add methods to control the bot's playlists and ability to join the queue.
Use case would be automatic music playing for events or when the room queue is empty.

Deep copies or another approach to allow hasPermission()?

On plug I used to use an approach similar to user.role > 1 to say people have bouncer access or higher. Since roles are strings now, that's not possible. I could use something like user.isVIP() || user.isMod || .... but that requires a long string of function checks every time.

I did see that you have a hasPermission() function that doesn't come across when using functions like getUser() and getSelf() because they aren't set to do a deep copy of the object.

Any thoughts about either making those functions deep copies or setting up an alternate function that will grab it as needed? Currently I'm using something similar to bot._.room.users.findWhere({id: data.user.id}).hasPermission('skip') to access the property.

I can set up a PR for this if you think it's a good idea.

user-join and user-leave events

The user-join event only seems to trigger every now and then
But the user-leave event doesn't seem to get triggered at all

disconnect TypeError

I'm seeing this error happen often when it tries to disconnect:

    /home/user/www/DerpyBot/node_modules/dubapi/index.js:128
    0|bot      |     this._.sokHandler.detachChannel('room:' + this._.room.id);
    0|bot      |                                                          ^
    0|bot      | TypeError: Cannot read property 'id' of undefined
    0|bot      |     at DubAPI.disconnect (/home/user/www/DerpyBot/node_modules/dubapi/index.js:128:58)
    0|bot      |     at process.disconnect (/home/ciscog/www/DerpyBot/bot/index.js:46:13)

Happens at this line.

Maybe move that line inside the conditional block right below it like this?

    if (this._.room) {
        this._.sokHandler.detachChannel('room:' + this._.room.id);
        clearTimeout(this._.room.playTimeout);
        this._.reqHandler.queue({method: 'DELETE', url: endpoints.roomUsers});
    }

queueMedia works, but does not join queue

Dubtrack recently added a "feature" where users are not automatically added to the room queue even if they have tracks in their room playlist. You either have to click the "Join Queue" button below the video or the "You are not in the room queue, click here to join :]" notification in the queue list.

The new queueMedia method does work! However, the bot doesn't join the queue due to the above. joinQueue and leaveQueue methods and functionality will need to be added.

queuePlaylist error

I keep getting a 503 Service Unavailable when I try to use the queuePlaylist.

I get this:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Application Error</title>
<style media="screen">html,body,iframe{margin:0;padding:0;}html,body{height:100%;overflow:hidden;}iframe{width:100%;height:100%;border:0;}</style>
</head>
<body>
<iframe src="//www.herokucdn.com/error-pages/application-error.html"></iframe>
</body>
</html>

User doesn't update correctly

It seems like usernames doesn't update if they are changed while the bot is in the room.

This could maybe come from listening to 'user-update' instead of listening to 'user_update_{userid}' like dubtrack-frontend does.

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.