From 4361c61f6e3422cef509ff83bd51880242639b3f Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Wed, 24 Apr 2013 09:27:12 +0000 Subject: [PATCH 1/5] Added branch notification Added current branch to note underneath last-diff. For the purposes of licensing, this commit is licensed under copyleft-next, version 0.1.0 or later. Therefore, this commit is compatible with any version of the GNU General Public License as published by the Free Software Foundation. --- public/project.css | 12 ++++++++++++ views/project/project.jade | 2 ++ 2 files changed, 14 insertions(+) diff --git a/public/project.css b/public/project.css index 95ff2d4..3e743e7 100644 --- a/public/project.css +++ b/public/project.css @@ -97,6 +97,18 @@ p#revnum { padding:10px; 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 { border-bottom: 1px solid #ccc; border-top:1px solid #ccc; diff --git a/views/project/project.jade b/views/project/project.jade index d2dfb42..29f56ea 100644 --- a/views/project/project.jade +++ b/views/project/project.jade @@ -30,6 +30,8 @@ html(lang='#{curr839}') #{revnum} pre#gitdiff #{diff} + p#branch + #{branch} h3 #{milestonehead} table#milestones.center tr From 388adda383a20e424e1e088054786062174aa960 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 22 Apr 2013 19:36:13 +0000 Subject: [PATCH 2/5] GPL --- LICENCE | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/LICENCE b/LICENCE index 627898c..205b8c1 100644 --- a/LICENCE +++ b/LICENCE @@ -1,18 +1,14 @@ Copyright (c) 2012-2013 Luke Slater (tinmachin3@gmail.com) -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +You should have received a copy of the GNU General Public License +along with this program. If not, see . From b9a9866e5e65b0acafe8fd9add2298c041d1766c Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 23 Apr 2013 18:48:41 +0000 Subject: [PATCH 3/5] nickserv module in master --- modules/nickserv/config.json | 9 +++++++++ modules/nickserv/nickserv.js | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 modules/nickserv/config.json create mode 100644 modules/nickserv/nickserv.js diff --git a/modules/nickserv/config.json b/modules/nickserv/config.json new file mode 100644 index 0000000..3bcaece --- /dev/null +++ b/modules/nickserv/config.json @@ -0,0 +1,9 @@ +{ + "servers": { + "nc": { + "matcher": "STATUS ([^ ]+) (\\d)$", + "acceptableState": 3, + "infoCommand": "status" + } + } +} diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js new file mode 100644 index 0000000..28f20ae --- /dev/null +++ b/modules/nickserv/nickserv.js @@ -0,0 +1,37 @@ +var nickserv = function(dbot) { + this.authStack = {}; + + this.api = { + 'auth': function(server, nick, callback) { + var nickserv = dbot.config.servers[server].nickserv, + infoCommand = this.config.servers[server].infoCommand; + + if(!_.has(this.authStack, server)) this.authStack[server] = {}; + this.authStack[server][nick] = callback; + + dbot.say(server, nickserv, infoCommand + ' ' + nick); + } + }; + + this.listener = function(event) { + var nickserv = dbot.config.servers[event.server].nickserv, + statusRegex = this.config.servers[event.server].matcher, + acceptableState = this.config.servers[event.server].acceptableState; + + if(event.user == nickserv) { + var info = event.params.match(statusRegex); + if(info && _.has(this.authStack, event.server)) { + if(info[2] == acceptableState ) { + this.authStack[event.server][info[1]](true); + } else { + this.authStack[event.server][info[1]](false); + } + } + } + }.bind(this); + this.on = 'NOTICE'; +}; + +exports.fetch = function(dbot) { + return new nickserv(dbot); +}; From f129c36f5e7effb26f5d8f3db4fad04886b34c26 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 23 Apr 2013 19:07:23 +0000 Subject: [PATCH 4/5] command can use nickserv [#421] --- modules/command/api.js | 26 ++++++++-------- modules/command/command.js | 59 +++++++++++++++++++----------------- modules/command/config.json | 1 + modules/nickserv/nickserv.js | 1 + 4 files changed, 47 insertions(+), 40 deletions(-) diff --git a/modules/command/api.js b/modules/command/api.js index da718d3..4abaa9b 100644 --- a/modules/command/api.js +++ b/modules/command/api.js @@ -17,22 +17,24 @@ var api = function(dbot) { /** * Does the user have the correct access level to use the command? */ - 'hasAccess': function(user, command) { - var access = true; + 'hasAccess': function(server, user, command, callback) { var accessNeeded = dbot.commands[command].access; - if(accessNeeded == 'admin') { - if(!_.include(dbot.config.admins, user)) { - access = false; - } - } else if(accessNeeded == 'moderator') { - if(!_.include(dbot.config.moderators, user) && - !_.include(dbot.config.admins, user)) { - access = false; + if(accessNeeded == 'admin' || accessNeeded == 'moderator') { + if(!_.include(dbot.config[accessNeeded + 's'], user)) { // lol + callback(false); + } else { + if(_.has(dbot.modules, 'nickserv') && this.config.useNickserv == true) { + dbot.api.nickserv.auth(server, user, function(result) { + callback(result); + }); + } else { + callback(true); + } } + } else { + callback(true); } - - return access; }, /** diff --git a/modules/command/command.js b/modules/command/command.js index 935f6e0..670f5e3 100644 --- a/modules/command/command.js +++ b/modules/command/command.js @@ -20,41 +20,44 @@ var command = function(dbot) { return; } } - + if(this.api.isBanned(event.user, commandName)) { event.reply(dbot.t('command_ban', {'user': event.user})); } else { - if(!this.api.isIgnoring(event.user, commandName) && - !this.api.isIgnoring(event.channel, commandName) && - this.api.hasAccess(event.user, commandName) && - dbot.commands[commandName].disabled !== true) { - if(this.api.applyRegex(commandName, event)) { - try { - var command = dbot.commands[commandName]; - var results = command.apply(dbot.modules[command.module], [event]); - if(_.has(command, 'hooks') && results !== false) { - _.each(command['hooks'], function(hook) { - 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()); - } - } - dbot.save(); - } else { - if(commandName !== '~') { - if(_.has(dbot.usage, commandName)) { - event.reply('Usage: ' + dbot.usage[commandName]); + this.api.hasAccess(event.server, event.user, commandName, function(result) { + if(result) { + if(!this.api.isIgnoring(event.user, commandName) && + !this.api.isIgnoring(event.channel, commandName) && + dbot.commands[commandName].disabled !== true) { + if(this.api.applyRegex(commandName, event)) { + try { + var command = dbot.commands[commandName]; + var results = command.apply(dbot.modules[command.module], [event]); + if(_.has(command, 'hooks') && results !== false) { + _.each(command['hooks'], function(hook) { + 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()); + } + } + dbot.save(); } else { - event.reply(dbot.t('syntax_error')); + if(commandName !== '~') { + if(_.has(dbot.usage, commandName)) { + event.reply('Usage: ' + dbot.usage[commandName]); + } else { + event.reply(dbot.t('syntax_error')); + } + } } } } - } + }.bind(this)); } }.bind(this); this.on = 'PRIVMSG'; diff --git a/modules/command/config.json b/modules/command/config.json index bace93b..b27be88 100644 --- a/modules/command/config.json +++ b/modules/command/config.json @@ -1,5 +1,6 @@ { "ignorable": false, "help": "http://github.com/reality/depressionbot/blob/master/modules/command/README.md", + "useNickserv": false, "dbKeys": [ "ignores", "bans" ] } diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 28f20ae..e489878 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -18,6 +18,7 @@ var nickserv = function(dbot) { statusRegex = this.config.servers[event.server].matcher, acceptableState = this.config.servers[event.server].acceptableState; + if(event.user == nickserv) { var info = event.params.match(statusRegex); if(info && _.has(this.authStack, event.server)) { From 9114ee25a9879d9ebe611f72a858e51b12cfc786 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Wed, 24 Apr 2013 09:41:51 +0000 Subject: [PATCH 5/5] Move project scripts to an external file. * Add link to ``project.js`` on project webpage. * Move scripts to ``project.js``. * Very definitely not do anything else. --- public/project.js | 15 +++++++++++++++ views/project/project.jade | 9 +-------- 2 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 public/project.js diff --git a/public/project.js b/public/project.js new file mode 100644 index 0000000..697c5f6 --- /dev/null +++ b/public/project.js @@ -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"); +}); diff --git a/views/project/project.jade b/views/project/project.jade index 29f56ea..5dca431 100644 --- a/views/project/project.jade +++ b/views/project/project.jade @@ -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='/styles.css') link(rel="stylesheet", href="/project.css") - title #{pagetitle} - script - $(document).ready(function() { - $.get("https://api.github.com/repos/#{repo}/pulls", function(data) { - if ($.parseJSON(data).length) { $("#pullreq").show();} - }); - }); - + script(src="../project.js") body div.container div#page