3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 20:39:25 +01:00
This commit is contained in:
reality 2013-05-17 07:40:46 +00:00
commit 9d03364a23
5 changed files with 29 additions and 38 deletions

View File

@ -17,5 +17,6 @@
"language": "en",
"debugMode": false,
"debugLevel": 1,
"repoRoot": "https://github.com/reality/depressionbot/",
"version": "Depressionbot IRC bot 0.4-dev - Lovingly crafted by The DepressionBot Foundation (a charity arm of the Official Aberystwyth Open Source International Development League)."
}

View File

@ -1,4 +1,5 @@
var _ = require('underscore')._;
var _ = require('underscore')._,
request = require('request');
var commands = function(dbot) {
return {
@ -18,41 +19,27 @@ var commands = function(dbot) {
'~help': function(event) {
var moduleName = event.params[1];
if(!moduleName) {
helpfulModules = _.filter(dbot.modules, function(element, index, array) {
return _.has(dbot.config[element], 'help');
});
if(!moduleName || !_.has(dbot.modules, moduleName)) {
event.reply(dbot.t('usage', {
'command': '~help',
'usage': '~help [module]'
}));
event.reply(dbot.t('loaded_modules_with_help', {
'modules': helpfulModules.join(', ')
}));
return;
}
if(!_.has(dbot.modules, moduleName)) {
if(_.has(dbot.commands, moduleName)) {
var moduleName = dbot.commands[moduleName].module;
} else {
var moduleName = undefined;
}
}
if(moduleName && _.has(dbot.config[moduleName], 'help')) {
var help = dbot.config[moduleName].help;
event.reply(dbot.t('help_link', {
'module': moduleName,
'link': help
event.reply(dbot.t('loaded_modules', {
'modules': _.keys(dbot.modules).join(', ')
}));
} else {
if(!moduleName) {
moduleName = event.params[1];
var helpLink = dbot.config.repoRoot +
'blob/master/modules/' + moduleName + '/README.md';
if(dbot.config[moduleName].help) {
helpLink = dbot.config[moduleName].help;
}
event.reply(dbot.t('no_help', { 'module': moduleName }))
}
// TODO: Check it exists
event.reply(dbot.t('help_link', {
'module': moduleName,
'link': helpLink
}));
}
}
};
};

View File

@ -33,8 +33,8 @@
"na'vi": "Fì{module}ìri oel ke tsun run srungit",
"nl": "Geen hulp gevonden voor {module}."
},
"loaded_modules_with_help": {
"en": "Loaded modules with help information: {modules}.",
"nl": "Geladen modules die hulpinformatie bevatten: {modules}."
"loaded_modules": {
"en": "Loaded modules: {modules}.",
"nl": "Geladen modules: {modules}."
}
}

View File

@ -2,5 +2,6 @@
"dbType": "redis",
"dependencies": [ "users", "event" ],
"rmLimit": 10,
"ignorable": true
"ignorable": true,
"quotesOnJoin": false
}

View File

@ -156,11 +156,13 @@ var quotes = function(dbot) {
});
}
} else if(event.action == 'JOIN') {
var userQuote = this.api.getQuote(event.user, function(quote) {
if(quote) {
event.reply(event.user + ': ' + quote);
}
});
if(this.config.quotesOnJoin == true) {
this.api.getQuote(event.user, function(quote) {
if(quote) {
event.reply(event.user + ': ' + quote);
}
});
}
}
}.bind(this);
this.on = ['PRIVMSG', 'JOIN'];