3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 22:39:26 +01:00

Used access parameter on all elevated access commadns I can think of [#124]

This commit is contained in:
reality 2013-01-12 09:49:41 +00:00
parent f8d4896eb6
commit 6b903407ed
3 changed files with 62 additions and 64 deletions

View File

@ -22,17 +22,17 @@ var js = function(dbot) {
// Run JS code un-sandboxed, with access to DBot memory (admin-only). // Run JS code un-sandboxed, with access to DBot memory (admin-only).
'~ajs': function(event) { '~ajs': function(event) {
if(dbot.config.admins.include(event.user) ) { var ret = eval(event.input[1]);
var ret = eval(event.input[1]); if(ret !== undefined) {
if(ret !== undefined) { event.reply(ret);
event.reply(ret);
}
} }
} }
}; };
commands['~js'].regex = [/^~js (.*)/, 2]; commands['~js'].regex = [/^~js (.*)/, 2];
commands['~ajs'].regex = [/^~ajs (.*)/, 2]; commands['~ajs'].regex = [/^~ajs (.*)/, 2];
commands['~ajs'].access = 'admin';
return { return {
'name': 'js', 'name': 'js',
'ignorable': true, 'ignorable': true,

View File

@ -93,28 +93,24 @@ var quotes = function(dbot) {
}, },
'~rmconfirm': function(event) { '~rmconfirm': function(event) {
if(dbot.config.admins.include(event.user)) { var rmCacheCount = rmCache.length;
var rmCacheCount = rmCache.length; rmCache.length = 0;
rmCache.length = 0; event.reply(dbot.t('quote_cache_cleared',
event.reply(dbot.t('quote_cache_cleared', { 'count': rmCacheCount }));
{ 'count': rmCacheCount }));
}
}, },
'~rmdeny': function(event) { '~rmdeny': function(event) {
if(dbot.config.admins.include(event.user)) { var rmCacheCount = rmCache.length;
var rmCacheCount = rmCache.length; for(var i=0;i<rmCacheCount;i++) {
for(var i=0;i<rmCacheCount;i++) { if(!quotes.hasOwnProperty(rmCache[i].key)) {
if(!quotes.hasOwnProperty(rmCache[i].key)) { quotes[rmCache[i].key] = [];
quotes[rmCache[i].key] = [];
}
quotes[rmCache[i].key].push(rmCache[i].quote);
} }
rmCache.length = 0; quotes[rmCache[i].key].push(rmCache[i].quote);
event.reply(dbot.t('quote_cache_reinstated',
{ 'count': rmCacheCount }));
} }
rmCache.length = 0;
event.reply(dbot.t('quote_cache_reinstated',
{ 'count': rmCacheCount }));
}, },
@ -271,6 +267,9 @@ var quotes = function(dbot) {
commands['~rmlast'].regex = [/^~rmlast ([\d\w\s-]*)/, 2]; commands['~rmlast'].regex = [/^~rmlast ([\d\w\s-]*)/, 2];
commands['~qadd'].regex = [/^~qadd ([\d\w\s-]+?)[ ]?=[ ]?(.+)$/, 3]; commands['~qadd'].regex = [/^~qadd ([\d\w\s-]+?)[ ]?=[ ]?(.+)$/, 3];
commands['~rmconfirm'].access = 'moderator';
commands['~rmdeny'].access = 'moderator';
var pages = { var pages = {
// Lists quotes in a category // Lists quotes in a category
'/quotes/:key': function(req, res) { '/quotes/:key': function(req, res) {

View File

@ -95,63 +95,62 @@ var users = function(dbot) {
}, },
'~setaliasparent': function(event) { '~setaliasparent': function(event) {
if(dbot.config.admins.include(event.user)) { var knownUsers = getServerUsers(event.server);
var knownUsers = getServerUsers(event.server); var newParent = event.params[1];
var newParent = event.params[1];
if(knownUsers.aliases.hasOwnProperty(newParent)) { if(knownUsers.aliases.hasOwnProperty(newParent)) {
var newAlias = knownUsers.aliases[newParent]; var newAlias = knownUsers.aliases[newParent];
// Replace users entry with new primary user // Replace users entry with new primary user
var usersIndex = knownUsers.users.indexOf(newAlias); var usersIndex = knownUsers.users.indexOf(newAlias);
knownUsers.users.splice(usersIndex, 1); knownUsers.users.splice(usersIndex, 1);
knownUsers.users.push(newParent); knownUsers.users.push(newParent);
// Replace channels entries with new primary user // Replace channels entries with new primary user
updateChannels(event, newAlias, newParent); updateChannels(event, newAlias, newParent);
// Remove alias for new parent & add alias for new alias // Remove alias for new parent & add alias for new alias
delete knownUsers.aliases[newParent]; delete knownUsers.aliases[newParent];
knownUsers.aliases[newAlias] = newParent; knownUsers.aliases[newAlias] = newParent;
// Update aliases to point to new primary user // Update aliases to point to new primary user
updateAliases(event, newAlias, newParent); updateAliases(event, newAlias, newParent);
event.reply(dbot.t('aliasparentset', { 'newParent': newParent, event.reply(dbot.t('aliasparentset', { 'newParent': newParent,
'newAlias': newAlias })); 'newAlias': newAlias }));
dbot.api.stats.fixStats(event.server, newAlias); dbot.api.stats.fixStats(event.server, newAlias);
} else { } else {
event.reply(dbot.t('unknown_alias', { 'alias': newParent})); event.reply(dbot.t('unknown_alias', { 'alias': newParent}));
}
} }
}, },
'~mergeusers': function(event) { '~mergeusers': function(event) {
if(dbot.config.admins.include(event.user)) { var knownUsers = getServerUsers(event.server);
var knownUsers = getServerUsers(event.server); var primaryUser = event.params[1];
var primaryUser = event.params[1]; var secondaryUser = event.params[2];
var secondaryUser = event.params[2];
if(knownUsers.users.include(primaryUser) && knownUsers.users.include(secondaryUser)) { if(knownUsers.users.include(primaryUser) && knownUsers.users.include(secondaryUser)) {
knownUsers.users.splice(knownUsers.users.indexOf(secondaryUser), 1); knownUsers.users.splice(knownUsers.users.indexOf(secondaryUser), 1);
knownUsers.aliases[secondaryUser] = primaryUser; knownUsers.aliases[secondaryUser] = primaryUser;
updateAliases(event, secondaryUser, primaryUser); updateAliases(event, secondaryUser, primaryUser);
updateChannels(event, secondaryUser, primaryUser); updateChannels(event, secondaryUser, primaryUser);
event.reply(dbot.t('merged_users', { event.reply(dbot.t('merged_users', {
'old_user': secondaryUser, 'old_user': secondaryUser,
'new_user': primaryUser 'new_user': primaryUser
})); }));
dbot.api.stats.fixStats(event.server, secondaryUser); dbot.api.stats.fixStats(event.server, secondaryUser);
} else { } else {
event.reply(dbot.t('unprimary_error')); event.reply(dbot.t('unprimary_error'));
} }
} }
}
}; };
commands['~setaliasparent'].access = 'moderator';
commands['~mergeusers'].access = 'moderator';
return { return {
'name': 'users', 'name': 'users',
'ignorable': false, 'ignorable': false,