3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-24 11:42:36 +01:00

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" ],
"ignorable": true
"ignorable": true,
"outputPrefix": "\u00039spotify\u000f"
}

View File

@ -29,7 +29,6 @@ var spotify = function(dbot) {
if(!error && response.statusCode == 200) {
if(_.has(body, 'track')) {
event.reply(dbot.t('track', {
's': this.spotifyText,
'artist': _.map(body.track.artists,
function(a) { return a.name }).join(', '),
'album': body.track.album.name,
@ -37,13 +36,11 @@ var spotify = function(dbot) {
}));
} else if(_.has(body, 'album')) {
event.reply(dbot.t('album', {
's': this.spotifyText,
'artist': body.album.artist,
'album': body.album.name
}));
} else if(_.has(body, 'artist')) {
event.reply(dbot.t('artist', {
's': this.spotifyText,
'artist': body.artist.name
}));
}
@ -78,7 +75,6 @@ var spotify = function(dbot) {
this.api.spotifySearch(query, function(body, t) {
if(body) {
event.reply(dbot.t('found', {
's': this.spotifyText,
'artist': _.map(body.tracks[0].artists, function(a) {
return a.name }).join(', '),
'album': body.tracks[0].album.name,
@ -86,7 +82,7 @@ var spotify = function(dbot) {
'url': t
}));
} else {
event.reply(dbot.t('not-found', { 's': this.spotifyText }));
event.reply(dbot.t('not-found'));
}
}.bind(this));
},
@ -103,7 +99,6 @@ var spotify = function(dbot) {
this.api.spotifySearch(name, function(body, t) {
if(body) {
event.reply(dbot.t('found', {
's': this.spotifyText,
'artist': _.map(body.tracks[0].artists,
function(a) { return a.name }).join(', '),
'album': body.tracks[0].album.name,
@ -111,7 +106,7 @@ var spotify = function(dbot) {
'url': t
}));
} else {
event.reply('No results');
event.reply(dbot.t('not-found'));
}
}.bind(this));
}.bind(this));

View File

@ -1,19 +1,19 @@
{
"artist": {
"en": "{s} [artist] {artist}"
"en": "[artist] {artist}"
},
"album": {
"en": "{s} [album] {artist} {album}"
"en": "[album] {artist} {album}"
},
"track": {
"en": "{s} [track] {artist} {track} (from {album})"
"en": "[track] {artist} {track} (from {album})"
},
"found": {
"en": "{s} [{url}] {artist} {track} (from {album})"
"en": "[{url}] {artist} {track} (from {album})"
},
"not-found": {
"en": "{s} No results.",
"na'vi": "{s}, Oel ke tsun rivum ayuoti.",
"nl": "{s} Geen resultaten."
"en": "No results.",
"na'vi": "Oel ke tsun rivum ayuoti.",
"nl": "Geen resultaten."
}
}

25
run.js
View File

@ -99,7 +99,12 @@ DBot.prototype.t = function(string, formatData) {
}
if(_.has(this.strings[string], lang)) {
var module = this.stringMap[string];
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.commands = {};
this.api = {};
<<<<<<< HEAD
=======
this.stringMap = {};
>>>>>>> 36d40f65a309f6911bae95bf0428d332c32a496a
this.usage = {};
try {
@ -212,6 +221,7 @@ DBot.prototype.reloadModules = function() {
}
}
<<<<<<< HEAD
process.nextTick(function() {
_.each(moduleNames, function(name) {
try {
@ -225,6 +235,21 @@ DBot.prototype.reloadModules = function() {
console.log('Error loading module: ' + err + ' ' + stack);
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.db = this.ddb.databanks[name];