mirror of
https://github.com/reality/dbot.git
synced 2024-11-30 16:09:27 +01:00
soundcloud command [#524]
This commit is contained in:
parent
291bff50da
commit
8688ee05ba
@ -8,6 +8,33 @@ var _ = require('underscore')._,
|
|||||||
var soundcloud = function(dbot) {
|
var soundcloud = function(dbot) {
|
||||||
this.ApiRoot = 'http://api.soundcloud.com';
|
this.ApiRoot = 'http://api.soundcloud.com';
|
||||||
|
|
||||||
|
this.commands = {
|
||||||
|
'~soundcloud': function(event) {
|
||||||
|
var query = event.input[1];
|
||||||
|
request.get(this.ApiRoot + '/tracks.json', {
|
||||||
|
'qs': {
|
||||||
|
'client_id': this.config.client_id,
|
||||||
|
'q': query
|
||||||
|
},
|
||||||
|
'json': true
|
||||||
|
}, function(error, response, body) {
|
||||||
|
if(body.length != 0) {
|
||||||
|
body = body[0];
|
||||||
|
event.reply(dbot.t('sc_track', {
|
||||||
|
'title': body.title,
|
||||||
|
'artist': body.user.username,
|
||||||
|
'genre': body.genre.trim(),
|
||||||
|
'plays': body.playback_count,
|
||||||
|
'favs': body.favoritings_count
|
||||||
|
}) + ' — ' + body.permalink_url);
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('sc_notrack'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.commands['~soundcloud'].regex = [/^~soundcloud (.+)$/, 2];
|
||||||
|
|
||||||
this.onLoad = function() {
|
this.onLoad = function() {
|
||||||
dbot.api.link.addHandler(this.name,
|
dbot.api.link.addHandler(this.name,
|
||||||
/https?:\/\/(www\.)?soundcloud\.com\//,
|
/https?:\/\/(www\.)?soundcloud\.com\//,
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"sc_track": {
|
"sc_track": {
|
||||||
"en": "[{title} by {artist} — {genre} — \u000312▶\u000f{plays} \u000304♥\u000f{favs}]"
|
"en": "[{title} by {artist} — {genre} — \u000312▶\u000f{plays} \u000304♥\u000f{favs}]"
|
||||||
|
},
|
||||||
|
"sc_notrack": {
|
||||||
|
"en": "No results found."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user