mirror of
https://github.com/reality/dbot.git
synced 2025-01-11 12:32:36 +01:00
merge with master, command uses nickserv auth in db [#421]
This commit is contained in:
commit
9625f1d316
@ -5,22 +5,24 @@ var api = function(dbot) {
|
|||||||
/**
|
/**
|
||||||
* Does the user have the correct access level to use the command?
|
* Does the user have the correct access level to use the command?
|
||||||
*/
|
*/
|
||||||
'hasAccess': function(user, command) {
|
'hasAccess': function(server, user, command, callback) {
|
||||||
var access = true;
|
|
||||||
var accessNeeded = dbot.commands[command].access;
|
var accessNeeded = dbot.commands[command].access;
|
||||||
|
|
||||||
if(accessNeeded == 'admin') {
|
if(accessNeeded == 'admin' || accessNeeded == 'moderator') {
|
||||||
if(!_.include(dbot.config.admins, user)) {
|
if(!_.include(dbot.config[accessNeeded + 's'], user)) { // lol
|
||||||
access = false;
|
callback(false);
|
||||||
}
|
} else {
|
||||||
} else if(accessNeeded == 'moderator') {
|
if(_.has(dbot.modules, 'nickserv') && this.config.useNickserv == true) {
|
||||||
if(!_.include(dbot.config.moderators, user) &&
|
dbot.api.nickserv.auth(server, user, function(result) {
|
||||||
!_.include(dbot.config.admins, user)) {
|
callback(result);
|
||||||
access = false;
|
});
|
||||||
|
} else {
|
||||||
|
callback(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
callback(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return access;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,9 +5,8 @@
|
|||||||
* ignoring that command.
|
* ignoring that command.
|
||||||
*/
|
*/
|
||||||
var _ = require('underscore')._;
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
var command = function(dbot) {
|
var command = function(dbot) {
|
||||||
this.dbot = dbot;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the appropriate command given the input.
|
* Run the appropriate command given the input.
|
||||||
*/
|
*/
|
||||||
@ -21,40 +20,42 @@ var command = function(dbot) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dbot.api.ignore.isUserIgnoring(event.server, event.user, commandName, function(isIgnoring) {
|
this.api.hasAccess(event.server, event.user, commandName, function(hasAccess) {
|
||||||
dbot.api.ignore.isUserBanned(event.server, event.user, commandName, function(isBanned) {
|
dbot.api.ignore.isUserIgnoring(event.server, event.user, commandName, function(isIgnoring) {
|
||||||
if(isBanned) {
|
dbot.api.ignore.isUserBanned(event.server, event.user, commandName, function(isBanned) {
|
||||||
event.reply(dbot.t('command_ban', {'user': event.user}));
|
if(isBanned) {
|
||||||
} else if(!isIgnoring &&
|
event.reply(dbot.t('command_ban', {'user': event.user}));
|
||||||
this.api.hasAccess(event.user, commandName) &&
|
} else if(!isIgnoring &&
|
||||||
dbot.commands[commandName].disabled !== true) {
|
hasAccess &&
|
||||||
if(this.api.applyRegex(commandName, event)) {
|
dbot.commands[commandName].disabled !== true) {
|
||||||
try {
|
if(this.api.applyRegex(commandName, event)) {
|
||||||
var command = dbot.commands[commandName];
|
try {
|
||||||
var results = command.apply(dbot.modules[command.module], [event]);
|
var command = dbot.commands[commandName];
|
||||||
if(_.has(command, 'hooks') && results !== false) {
|
var results = command.apply(dbot.modules[command.module], [event]);
|
||||||
_.each(command['hooks'], function(hook) {
|
if(_.has(command, 'hooks') && results !== false) {
|
||||||
hook.apply(hook.module, _.values(results));
|
_.each(command['hooks'], function(hook) {
|
||||||
}, this);
|
hook.apply(hook.module, _.values(results));
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
} catch(err) {
|
||||||
|
if(dbot.config.debugMode == true) {
|
||||||
|
event.reply('- Error in ' + commandName + ':');
|
||||||
|
event.reply('- Message: ' + err);
|
||||||
|
event.reply('- Top of stack: ' + err.stack.split('\n')[1].trim());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch(err) {
|
dbot.save();
|
||||||
if(dbot.config.debugMode == true) {
|
} else {
|
||||||
event.reply('- Error in ' + commandName + ':');
|
if(commandName !== '~') {
|
||||||
event.reply('- Message: ' + err);
|
if(_.has(dbot.usage, commandName)) {
|
||||||
event.reply('- Top of stack: ' + err.stack.split('\n')[1].trim());
|
event.reply('Usage: ' + dbot.usage[commandName]);
|
||||||
}
|
} else {
|
||||||
}
|
event.reply(dbot.t('syntax_error'));
|
||||||
dbot.save();
|
}
|
||||||
} else {
|
|
||||||
if(commandName !== '~') {
|
|
||||||
if(_.has(dbot.usage, commandName)) {
|
|
||||||
event.reply('Usage: ' + dbot.usage[commandName]);
|
|
||||||
} else {
|
|
||||||
event.reply(dbot.t('syntax_error'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}.bind(this));
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ignorable": false,
|
"ignorable": false,
|
||||||
"help": "http://github.com/reality/depressionbot/blob/master/modules/command/README.md",
|
"help": "http://github.com/reality/depressionbot/blob/master/modules/command/README.md",
|
||||||
"dependencies": [ "ignore", "users" ]
|
"dependencies": [ "ignore", "users" ],
|
||||||
|
"useNickserv": false
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,18 @@ p#revnum {
|
|||||||
padding:10px;
|
padding:10px;
|
||||||
margin-bottom:0px;
|
margin-bottom:0px;
|
||||||
}
|
}
|
||||||
|
p#branch {
|
||||||
|
border-right:1px solid #ccc;
|
||||||
|
border-left:1px solid #ccc;
|
||||||
|
border-bottom:1px solid #ccc;
|
||||||
|
margin:auto;
|
||||||
|
display:inline-block;
|
||||||
|
padding:10px;
|
||||||
|
margin-top:0px;
|
||||||
|
border-bottom-left-radius:5px;
|
||||||
|
border-bottom-right-radius:5px;
|
||||||
|
|
||||||
|
}
|
||||||
h2 {
|
h2 {
|
||||||
border-bottom: 1px solid #ccc;
|
border-bottom: 1px solid #ccc;
|
||||||
border-top:1px solid #ccc;
|
border-top:1px solid #ccc;
|
||||||
|
15
public/project.js
Normal file
15
public/project.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
$(document).ready(function() {
|
||||||
|
$.get("https://api.github.com/repos/#{repo}/pulls", function(data) {
|
||||||
|
if ($.parseJSON(data).length) { $("#pullreq").show();}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$(document).keypress(function(e) {
|
||||||
|
WebFontConfig={google:{families:["Ubuntu::latin"]}};(function(){var e=document.createElement("script");e.src=("https:"==document.location.protocol?"https":"http")+"://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js";e.type="text/javascript";e.async="true";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})()
|
||||||
|
$('body').css({
|
||||||
|
"background-image":"url('http://i.imgur.com/Yh8V2Oa.jpg')",
|
||||||
|
"font-family": "Ubuntu, \"Source Sans Pro\",sans-serif"
|
||||||
|
});
|
||||||
|
$('a').css("color","#DD4814");
|
||||||
|
$('#title').css("color","white");
|
||||||
|
$('#main').css("border-color","#420432");
|
||||||
|
});
|
@ -223,3 +223,18 @@ div.imgwrap > img {
|
|||||||
.thumbnail:hover > div.imgwrap > span.nicks {
|
.thumbnail:hover > div.imgwrap > span.nicks {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* footer */
|
||||||
|
#footer {
|
||||||
|
margin-top:5px;
|
||||||
|
margin-right:10px;
|
||||||
|
margin-left:10px;
|
||||||
|
}
|
||||||
|
#footer a {
|
||||||
|
float:right;
|
||||||
|
padding-left:2px;
|
||||||
|
padding-right:2px;
|
||||||
|
background-color:#f5f5f5;
|
||||||
|
border-radius:3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
12
run.js
12
run.js
@ -222,10 +222,14 @@ DBot.prototype.reloadModules = function() {
|
|||||||
|
|
||||||
process.nextTick(function() {
|
process.nextTick(function() {
|
||||||
_.each(moduleNames, function(name) {
|
_.each(moduleNames, function(name) {
|
||||||
var moduleDir = './modules/' + name + '/';
|
try {
|
||||||
var rawModule = require(moduleDir + name);
|
var moduleDir = './modules/' + name + '/';
|
||||||
var module = rawModule.fetch(this);
|
var rawModule = require(moduleDir + name);
|
||||||
this.rawModules.push(rawModule);
|
var module = rawModule.fetch(this);
|
||||||
|
this.rawModules.push(rawModule);
|
||||||
|
} catch(err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
|
||||||
module.name = name;
|
module.name = name;
|
||||||
module.db = this.ddb.databanks[name];
|
module.db = this.ddb.databanks[name];
|
||||||
|
@ -14,6 +14,9 @@ html(lang='en')
|
|||||||
a(href='/') #{name} web interface
|
a(href='/') #{name} web interface
|
||||||
div.container#main
|
div.container#main
|
||||||
block content
|
block content
|
||||||
|
div#footer
|
||||||
|
a#project(href='/project') About
|
||||||
|
|
||||||
script(type="text/javascript", src="/bootstrap/js/bootstrap.min.js")
|
script(type="text/javascript", src="/bootstrap/js/bootstrap.min.js")
|
||||||
script(type="text/javascript", src="/d3/d3.v3.min.js")
|
script(type="text/javascript", src="/d3/d3.v3.min.js")
|
||||||
script(type="text/javascript", src="/script.js")
|
script(type="text/javascript", src="/script.js")
|
||||||
|
@ -7,14 +7,7 @@ html(lang='#{curr839}')
|
|||||||
link(rel="stylesheet", type="text/css", href="/bootstrap/css/bootstrap.min.css")
|
link(rel="stylesheet", type="text/css", href="/bootstrap/css/bootstrap.min.css")
|
||||||
link(rel='stylesheet', type='text/css', href='/styles.css')
|
link(rel='stylesheet', type='text/css', href='/styles.css')
|
||||||
link(rel="stylesheet", href="/project.css")
|
link(rel="stylesheet", href="/project.css")
|
||||||
title #{pagetitle}
|
script(src="../project.js")
|
||||||
script
|
|
||||||
$(document).ready(function() {
|
|
||||||
$.get("https://api.github.com/repos/#{repo}/pulls", function(data) {
|
|
||||||
if ($.parseJSON(data).length) { $("#pullreq").show();}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
body
|
body
|
||||||
div.container
|
div.container
|
||||||
div#page
|
div#page
|
||||||
@ -30,6 +23,8 @@ html(lang='#{curr839}')
|
|||||||
#{revnum}
|
#{revnum}
|
||||||
pre#gitdiff
|
pre#gitdiff
|
||||||
#{diff}
|
#{diff}
|
||||||
|
p#branch
|
||||||
|
#{branch}
|
||||||
h3 #{milestonehead}
|
h3 #{milestonehead}
|
||||||
table#milestones.center
|
table#milestones.center
|
||||||
tr
|
tr
|
||||||
@ -50,7 +45,7 @@ html(lang='#{curr839}')
|
|||||||
print #{Math.round(wdth)+"%"}
|
print #{Math.round(wdth)+"%"}
|
||||||
td #{milestone.open_issues}
|
td #{milestone.open_issues}
|
||||||
td #{milestone.closed_issues}
|
td #{milestone.closed_issues}
|
||||||
a(#href="https://github.com/"+repo+"/")
|
a(href="https://github.com/"+repo+"/")
|
||||||
#{propaganda}
|
#{propaganda}
|
||||||
h3 #{languagetranshead}
|
h3 #{languagetranshead}
|
||||||
table#translations
|
table#translations
|
||||||
|
Loading…
Reference in New Issue
Block a user