anjanms / dubapi Goto Github PK
View Code? Open in Web Editor NEWA Node.js API for creating queup.net bots.
License: MIT License
A Node.js API for creating queup.net bots.
License: MIT License
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?
Why are you using pubnub?
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
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
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)
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: 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 ๐
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:
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.
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
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.
is this possible? I couldn't exactly find an api endpoint for it, but I could be missing something important.
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]
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.
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.
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
For some reason, the function is not working for me, even if the bot-user is co-owner.
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});
}
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.
looks like songs with undefined
as name are possible https://i.gyazo.com/85fc60c4453ef836d5d3634b304961fc.png
This seems to be a Dubtrack bug, but until it's fixed, it might be worth considering fixing it in DubAPI, too.
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>
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.
It would be great to have the ability to remove users from the queue, especially for blacklisting.
The url for this would be "https://api.dubtrack.fm/room/{roomid}/queue/user/{userid}" performing a delete request.
Also for blacklisting, it would be great to have the possibility to check the queue for blacklisted songs.
The endpoints for this would be:
The problem about the second one is, that you need to be logged in to request in, so you can't really get it out of the bot script.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.