3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-24 19:52:36 +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).
'~ajs': function(event) {
if(dbot.config.admins.include(event.user) ) {
var ret = eval(event.input[1]);
if(ret !== undefined) {
event.reply(ret);
}
var ret = eval(event.input[1]);
if(ret !== undefined) {
event.reply(ret);
}
}
};
commands['~js'].regex = [/^~js (.*)/, 2];
commands['~ajs'].regex = [/^~ajs (.*)/, 2];
commands['~ajs'].access = 'admin';
return {
'name': 'js',
'ignorable': true,

View File

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

View File

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