3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-24 04:49:25 +01:00

Added ~help command [#89]

This commit is contained in:
reality 2012-12-30 20:15:48 +00:00
parent 2416a82f45
commit c06f754b8f
2 changed files with 37 additions and 4 deletions

View File

@ -57,10 +57,34 @@ var command = function(dbot) {
'~usage': function(event) { '~usage': function(event) {
var commandName = event.params[1]; var commandName = event.params[1];
if(dbot.usage.hasOwnProperty(commandName)) { if(dbot.usage.hasOwnProperty(commandName)) {
event.reply('Usage for ' + commandName + ': ' + event.reply(dbot.t('usage', {
dbot.usage[commandName]); 'command': commandName,
'usage': dbot.usage[commandName]
}));
} else { } else {
event.reply('No usage information for ' + commandName); event.reply(dbot.t('no_usage_info', {
'command': commandName
}));
}
},
'~help': function(event) {
var moduleName = event.params[1];
if(!dbot.modules.hasOwnProperty(moduleName)) {
var moduleName = dbot.commandMap[moduleName];
}
if(moduleName && dbot.config[moduleName].hasOwnProperty('help')) {
var help = dbot.config[modulename].help;
event.reply(dbot.t('help_link', {
'module': moduleName,
'link': help
}));
} else {
if(!moduleName) {
moduleName = event.params[1];
}
event.reply(dbot.t('no_help', { 'module': moduleName }))
} }
} }
}, },

View File

@ -11,7 +11,16 @@
"na'vi": "Ngeyä pamrel keyawr lu. Nga skxawng lu.", "na'vi": "Ngeyä pamrel keyawr lu. Nga skxawng lu.",
"welsh": "Cystrawen annilys. Cychwyn orfflosgiad" "welsh": "Cystrawen annilys. Cychwyn orfflosgiad"
}, },
"usage": {
"english": "Usage for {command}: {usage}."
},
"no_usage_info": { "no_usage_info": {
"No usage information found for {command}." "english": "No usage information found for {command}."
},
"help_link": {
"english": "Help for {module}: {link}."
},
"no_help": {
"english": "No help found for {module}."
} }
} }