fix merge

This commit is contained in:
reality 2013-05-21 17:31:01 +00:00
commit eb4e788b5c
4 changed files with 36 additions and 15 deletions

View File

@ -1,4 +1,5 @@
{ {
"dependencies": [ "link" ], "dependencies": [ "link" ],
"ignorable": true "ignorable": true,
"outputPrefix": "\u00039spotify\u000f"
} }

View File

@ -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));

View File

@ -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": "Oel ke tsun rivum ayuoti.",
"nl": "{s} Geen resultaten." "nl": "Geen resultaten."
} }
} }

25
run.js
View File

@ -99,7 +99,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;
}
} }
} }
@ -131,6 +136,10 @@ DBot.prototype.reloadModules = function() {
this.modules = {}; this.modules = {};
this.commands = {}; this.commands = {};
this.api = {}; this.api = {};
<<<<<<< HEAD
=======
this.stringMap = {};
>>>>>>> 36d40f65a309f6911bae95bf0428d332c32a496a
this.usage = {}; this.usage = {};
try { try {
@ -212,6 +221,7 @@ DBot.prototype.reloadModules = function() {
} }
} }
<<<<<<< HEAD
process.nextTick(function() { process.nextTick(function() {
_.each(moduleNames, function(name) { _.each(moduleNames, function(name) {
try { try {
@ -225,6 +235,21 @@ DBot.prototype.reloadModules = function() {
console.log('Error loading module: ' + err + ' ' + stack); console.log('Error loading module: ' + err + ' ' + stack);
return; return;
} }
=======
// Load string data for the module
_.each([ 'usage', 'strings' ], function(property) {
var propertyData = {};
try {
propertyData = JSON.parse(fs.readFileSync(moduleDir + property + '.json', 'utf-8'));
} catch(err) {};
_.extend(this[property], propertyData);
if(property == 'strings') {
_.each(_.keys(propertyData), function(string) {
this.stringMap[string] = name;
}.bind(this));
}
}, this);
>>>>>>> 36d40f65a309f6911bae95bf0428d332c32a496a
module.name = name; module.name = name;
module.db = this.ddb.databanks[name]; module.db = this.ddb.databanks[name];