forked from GitHub/dbot
Support for config.outputPrefix [#462]
This commit is contained in:
parent
0daa08b401
commit
36d40f65a3
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"dependencies": [ "command" ],
|
"dependencies": [ "command" ],
|
||||||
"ignorable": true
|
"ignorable": true,
|
||||||
|
"outputPrefix": "\u00039spotify\u000f"
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ var spotify = function(dbot) {
|
|||||||
if(!error && response.statusCode == 200) {
|
if(!error && response.statusCode == 200) {
|
||||||
if(_.has(body, 'track')) {
|
if(_.has(body, 'track')) {
|
||||||
event.reply(dbot.t('track', {
|
event.reply(dbot.t('track', {
|
||||||
's': this.spotifyText,
|
|
||||||
'artist': _.map(body.track.artists,
|
'artist': _.map(body.track.artists,
|
||||||
function(a) { return a.name }).join(', '),
|
function(a) { return a.name }).join(', '),
|
||||||
'album': body.track.album.name,
|
'album': body.track.album.name,
|
||||||
@ -37,13 +36,11 @@ var spotify = function(dbot) {
|
|||||||
}));
|
}));
|
||||||
} else if(_.has(body, 'album')) {
|
} else if(_.has(body, 'album')) {
|
||||||
event.reply(dbot.t('album', {
|
event.reply(dbot.t('album', {
|
||||||
's': this.spotifyText,
|
|
||||||
'artist': body.album.artist,
|
'artist': body.album.artist,
|
||||||
'album': body.album.name
|
'album': body.album.name
|
||||||
}));
|
}));
|
||||||
} else if(_.has(body, 'artist')) {
|
} else if(_.has(body, 'artist')) {
|
||||||
event.reply(dbot.t('artist', {
|
event.reply(dbot.t('artist', {
|
||||||
's': this.spotifyText,
|
|
||||||
'artist': body.artist.name
|
'artist': body.artist.name
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -78,7 +75,6 @@ var spotify = function(dbot) {
|
|||||||
this.api.spotifySearch(query, function(body, t) {
|
this.api.spotifySearch(query, function(body, t) {
|
||||||
if(body) {
|
if(body) {
|
||||||
event.reply(dbot.t('found', {
|
event.reply(dbot.t('found', {
|
||||||
's': this.spotifyText,
|
|
||||||
'artist': _.map(body.tracks[0].artists, function(a) {
|
'artist': _.map(body.tracks[0].artists, function(a) {
|
||||||
return a.name }).join(', '),
|
return a.name }).join(', '),
|
||||||
'album': body.tracks[0].album.name,
|
'album': body.tracks[0].album.name,
|
||||||
@ -86,7 +82,7 @@ var spotify = function(dbot) {
|
|||||||
'url': t
|
'url': t
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
event.reply(dbot.t('not-found', { 's': this.spotifyText }));
|
event.reply(dbot.t('not-found'));
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
@ -103,7 +99,6 @@ var spotify = function(dbot) {
|
|||||||
this.api.spotifySearch(name, function(body, t) {
|
this.api.spotifySearch(name, function(body, t) {
|
||||||
if(body) {
|
if(body) {
|
||||||
event.reply(dbot.t('found', {
|
event.reply(dbot.t('found', {
|
||||||
's': this.spotifyText,
|
|
||||||
'artist': _.map(body.tracks[0].artists,
|
'artist': _.map(body.tracks[0].artists,
|
||||||
function(a) { return a.name }).join(', '),
|
function(a) { return a.name }).join(', '),
|
||||||
'album': body.tracks[0].album.name,
|
'album': body.tracks[0].album.name,
|
||||||
@ -111,7 +106,7 @@ var spotify = function(dbot) {
|
|||||||
'url': t
|
'url': t
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
event.reply('No results');
|
event.reply(dbot.t('not-found'));
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"artist": {
|
"artist": {
|
||||||
"en": "{s} [artist] {artist}"
|
"en": "[artist] {artist}"
|
||||||
},
|
},
|
||||||
"album": {
|
"album": {
|
||||||
"en": "{s} [album] {artist} – {album}"
|
"en": "[album] {artist} – {album}"
|
||||||
},
|
},
|
||||||
"track": {
|
"track": {
|
||||||
"en": "{s} [track] {artist} – {track} (from {album})"
|
"en": "[track] {artist} – {track} (from {album})"
|
||||||
},
|
},
|
||||||
"found": {
|
"found": {
|
||||||
"en": "{s} [{url}] {artist} – {track} (from {album})"
|
"en": "[{url}] {artist} – {track} (from {album})"
|
||||||
},
|
},
|
||||||
"not-found": {
|
"not-found": {
|
||||||
"en": "{s} No results.",
|
"en": "{No results.",
|
||||||
"na'vi": "{s}, Oel ke tsun rivum ayuoti.",
|
"na'vi": "{s}, Oel ke tsun rivum ayuoti.",
|
||||||
"nl": "{s} Geen resultaten."
|
"nl": "Geen resultaten."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
run.js
12
run.js
@ -95,7 +95,12 @@ DBot.prototype.t = function(string, formatData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(_.has(this.strings[string], lang)) {
|
if(_.has(this.strings[string], lang)) {
|
||||||
|
var module = this.stringMap[string];
|
||||||
formattedString = this.strings[string][lang].format(formatData);
|
formattedString = this.strings[string][lang].format(formatData);
|
||||||
|
if(this.config[module].outputPrefix) {
|
||||||
|
formattedString = '[' + this.config[module].outputPrefix + '] ' +
|
||||||
|
formattedString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +132,7 @@ DBot.prototype.reloadModules = function() {
|
|||||||
this.modules = {};
|
this.modules = {};
|
||||||
this.commands = {};
|
this.commands = {};
|
||||||
this.api = {};
|
this.api = {};
|
||||||
this.commandMap = {}; // Map of which commands belong to which modules
|
this.stringMap = {};
|
||||||
this.usage = {};
|
this.usage = {};
|
||||||
|
|
||||||
// Load config changes
|
// Load config changes
|
||||||
@ -219,6 +224,11 @@ DBot.prototype.reloadModules = function() {
|
|||||||
propertyData = JSON.parse(fs.readFileSync(moduleDir + property + '.json', 'utf-8'));
|
propertyData = JSON.parse(fs.readFileSync(moduleDir + property + '.json', 'utf-8'));
|
||||||
} catch(err) {};
|
} catch(err) {};
|
||||||
_.extend(this[property], propertyData);
|
_.extend(this[property], propertyData);
|
||||||
|
if(property == 'strings') {
|
||||||
|
_.each(_.keys(propertyData), function(string) {
|
||||||
|
this.stringMap[string] = name;
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// Load the module itself
|
// Load the module itself
|
||||||
|
Loading…
Reference in New Issue
Block a user