Module documentation for Admin module [#75]

* Also removed lock functionality from quotes and admin modules.
This commit is contained in:
reality 2012-12-30 17:26:04 +00:00
parent 5bf5b257f8
commit 1746a9c7b8
4 changed files with 74 additions and 32 deletions

57
modules/admin/README.md Normal file
View File

@ -0,0 +1,57 @@
## Admin
Administrator functionality.
### Description
Various administration functionality such as banning users, hot-reloading the
code and ordering him to talk. Note that commands added here are handled with
their own listener, rather than being part of the command logic which is handled
by the Command module. Functionality in this module can be slightly unsafe as
not everything is thoroughly sanity checked.
### Commands
#### join [#channel]
Join the given channel.
#### part [#channel]
Leave the given channel.
#### opme [#channel]
Gives the caller ops in a given channel if possible. If called without a
channel, it will attempt to give the caller ops in the current channel.
#### greload
Perform a git pull, and then execute the 'reload' command. Saves a lot of time
updating!
#### reload
Reload all of the modules currently in use by DBot. By using this, all module
functionality should be reloadable and replaceable without having to restart the
bot or interrupt the connection to the server.
#### say [#channel] [message]
Have DBot post the given message in the given channel (uses the server from
which you are sending the message). You may replace channel with '@' to have him
post the message in the current channel. Channel may also be replaced with a
nick on the server.
#### load [module]
Load a new module. This works by adding a module name to the roster and then
triggering a reload of all modules, at which point the new module is actually
loaded by the standard DBot process.
#### unload [module]
Unload a currently loaded module. This removes the module, and then triggers a
reload of all modules.
#### ban [user] [command]
Ban a user from using a command. Command may be replaced with '\*,' which will
ban a user from use of all commands. Users banned from all commands will still
be subject to module listeners.
#### unban [user] [command]
Unban a user from using a given command. If a user was previously banned using
the '\*' wildcard, they may also be unbanned from such by replacing command with
an asterisk here as well.

View File

@ -116,13 +116,6 @@ var admin = function(dbot) {
} else { } else {
event.reply(dbot.t('unban_error', {'user': username})); event.reply(dbot.t('unban_error', {'user': username}));
} }
},
// Lock quote category so quotes can't be removed
'lock': function(event) {
var category = event.params[1];
dbot.db.locks.push(category);
event.reply(dbot.t('qlock', {'category': category}));
} }
}; };

View File

@ -1,3 +1,3 @@
{ {
"dbKeys": [ "bans", "locks" ] "dbKeys": [ "bans" ]
} }

View File

@ -157,17 +157,13 @@ var quotes = function(dbot) {
if(rmAllowed == true || dbot.config.admins.include(event.user)) { if(rmAllowed == true || dbot.config.admins.include(event.user)) {
var key = event.input[1].trim().toLowerCase(); var key = event.input[1].trim().toLowerCase();
if(quotes.hasOwnProperty(key)) { if(quotes.hasOwnProperty(key)) {
if(!dbot.db.locks.include(key) || dbot.config.admins.include(event.user)) { var quote = quotes[key].pop();
var quote = quotes[key].pop(); if(quotes[key].length === 0) {
if(quotes[key].length === 0) { delete quotes[key];
delete quotes[key];
}
resetRemoveTimer(event, key, quote);
event.reply(dbot.t('removed_from', {'quote': quote, 'category': key}));
} else {
event.reply(dbot.t('locked_category', {'category': q[1]}));
} }
resetRemoveTimer(event, key, quote);
event.reply(dbot.t('removed_from', {'quote': quote, 'category': key}));
} else { } else {
event.reply(dbot.t('no_quotes', {'category': q[1]})); event.reply(dbot.t('no_quotes', {'category': q[1]}));
} }
@ -182,22 +178,18 @@ var quotes = function(dbot) {
var quote = event.input[2]; var quote = event.input[2];
if(quotes.hasOwnProperty(key)) { if(quotes.hasOwnProperty(key)) {
if(!dbot.db.locks.include(key)) { var category = quotes[key];
var category = quotes[key]; var index = category.indexOf(quote);
var index = category.indexOf(quote); if(index !== -1) {
if(index !== -1) { category.splice(index, 1);
category.splice(index, 1); if(category.length === 0) {
if(category.length === 0) { delete quotes[key];
delete quotes[key];
}
resetRemoveTimer(event, key, quote);
event.reply(dbot.t('removed_from', {'category': key, 'quote': quote}));
} else {
event.reply(dbot.t('q_not_exist_under', {'category': key, 'quote': quote}));
} }
resetRemoveTimer(event, key, quote);
event.reply(dbot.t('removed_from', {'category': key, 'quote': quote}));
} else { } else {
event.reply(dbot.t('locked_category', {'category': key})); event.reply(dbot.t('q_not_exist_under', {'category': key, 'quote': quote}));
} }
} else { } else {
event.reply(dbot.t('category_not_found', {'category': key})); event.reply(dbot.t('category_not_found', {'category': key}));