From 5322ec52bf38a5565c2ec8c5b2d2a3432fbaf663 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sun, 21 Apr 2013 20:14:37 +0000 Subject: [PATCH 1/7] Add pull request notification * Add message when there are pull requests with client side javascript * Add string for OAOSIDL, for future usage * Title cased credits * Removed text transform from random quote * Shoved commit count to left * Added lines to top and bottom of ``h2`` * Removed redundant CSS * Added JQuery --- modules/project/pages.js | 1 + modules/project/strings.json | 6 ++++++ public/project.css | 30 ++++++++++++++++++++++++++++++ views/project/project.jade | 21 ++++++++++++--------- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/modules/project/pages.js b/modules/project/pages.js index f248dcd..5578d68 100644 --- a/modules/project/pages.js +++ b/modules/project/pages.js @@ -93,6 +93,7 @@ var pages = function(dbot) { "languageprog": dbot.t("langhead-progress"), "languagetrans": dbot.t("langhead-translations"), "languagetranshead": dbot.t("translations"), + "pullreqs": dbot.t("outstanding-pullreq") }); }, }; diff --git a/modules/project/strings.json b/modules/project/strings.json index 8960da3..be11111 100644 --- a/modules/project/strings.json +++ b/modules/project/strings.json @@ -189,5 +189,11 @@ }, "langhead-native": { "en": "Native" + }, + "outstanding-pullreq": { + "en": "There are outstanding pull requests" + }, + "oaosidl": { + "en": "The Official Aberystwyth Open Source International Development League" } } diff --git a/public/project.css b/public/project.css index 736b633..95ff2d4 100644 --- a/public/project.css +++ b/public/project.css @@ -3,6 +3,10 @@ pre#gitdiff { width:80; margin:auto; text-transform:none; + clear:both; +} +ul#credits { + text-transform:capitalize; } div#main { font-size:18px; @@ -19,6 +23,7 @@ p.intro { border:1px solid #ccc; padding:20px; border-radius:4px; + text-transform:none; } div.progress.open { background-color: #f4fff4; @@ -74,3 +79,28 @@ h3 { #translations td { text-transform:none; } +p#pullreq { + float:right; + border-left:1px solid #ccc; + border-top:1px solid #ccc; + border-top-left-radius:5px; + padding:10px; + margin:5px; + display:none; +} +p#revnum { + float:left; + border-right:1px solid #ccc; + border-top:1px solid #ccc; + border-top-right-radius: 5px; + margin:5px; + padding:10px; + margin-bottom:0px; +} +h2 { + border-bottom: 1px solid #ccc; + border-top:1px solid #ccc; + margin-left:auto; + margin-right:auto; + width:40%; +} diff --git a/views/project/project.jade b/views/project/project.jade index 22d5c93..560de26 100644 --- a/views/project/project.jade +++ b/views/project/project.jade @@ -8,12 +8,13 @@ html(lang='#{curr839}') link(rel='stylesheet', type='text/css', href='/styles.css') link(rel="stylesheet", href="/project.css") title #{pagetitle} - - var mstone = "milestone" - style(type="text/css") - each milestone in milestones - - current = mstone+milestone.number - - wdth = ((milestone.open_issues/(milestone.open_issues + milestone.closed_issues))*100) - .current { width: wdth% } + script + $(document).ready(function() { + $.get("https://api.github.com/repos/#{repo}/pulls", function(data) { + if ($.parseJSON(data).length) { $("#pullreq").show();} + }); + }); + body div.container div#page @@ -23,7 +24,9 @@ html(lang='#{curr839}') #{dquote} section#git h2 #{development} - p.center + p#pullreq + a(href="https://github.com/"+repo+"/pulls") #{pullreqs} + p#revnum #{revnum} pre#gitdiff #{diff} @@ -36,7 +39,7 @@ html(lang='#{curr839}') th #{closedmilestone} each milestone in milestones - var wdth = ((milestone.closed_issues/(milestone.open_issues + milestone.closed_issues))*100) - tr(id=mstone+milestone.number) + tr(id="milestone"+milestone.number) td a(href="https://github.com/"+repo+"/issues?milestone="+milestone.number) #{milestone.title} @@ -79,7 +82,7 @@ html(lang='#{curr839}') td #{language.count} / #{translation.en.count} h3 #{credits} #{thanks} - ul + ul#credits each author in authors li #{author} From af8c11fd86223e3044fc575498f873f70e7f47c2 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sun, 21 Apr 2013 20:28:51 +0000 Subject: [PATCH 2/7] fix missing string --- modules/project/strings.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/project/strings.json b/modules/project/strings.json index be11111..58fb470 100644 --- a/modules/project/strings.json +++ b/modules/project/strings.json @@ -195,5 +195,8 @@ }, "oaosidl": { "en": "The Official Aberystwyth Open Source International Development League" + }, + "link-autotitle": { + "en": "Automatically titling links in channels" } } From 09120f06dbf747a905d8f8bcac84a08d28d92a66 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sun, 21 Apr 2013 20:44:41 +0000 Subject: [PATCH 3/7] add french translations --- modules/project/strings.json | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/modules/project/strings.json b/modules/project/strings.json index 58fb470..daa07b0 100644 --- a/modules/project/strings.json +++ b/modules/project/strings.json @@ -1,7 +1,4 @@ { - "dbotintro": { - "en": "{botname} lorem ipsum dolor sit amet" - }, "dbotspeaks": { "en": "{name} speaks {lang}", "de": "{name} spricht {lang} ({langen})", @@ -10,10 +7,12 @@ "nl": "{name} spreekt {lang} ({langen})" }, "thanks": { - "en": "With thanks to:" + "en": "With thanks to:", + "fr": "Merci à:" }, "credits": { - "en": "Authors" + "en": "Authors", + "fr": "Développeurs" }, "pagetitle": { "en": "{botname} web interface", @@ -115,6 +114,7 @@ }, "milestones": { "en": "Milestones" + "fr": "étapes" }, "milestoneprog": { "en": "Progress", @@ -173,22 +173,32 @@ "en": "{branch}" }, "git": { - "en": "version control" + "en": "version control", + "de": "Versionsverwaltung", + "es": "Control de versiones", + "fr": "Festion de versions", + "it": "Controllo versione", + "nl": "Versiebeheersysteem" }, "langhead-current": { - "en": "Current" + "en": "Current", + "fr": "Courant" }, "langhead-translations": { - "en": "Completion" + "en": "Completion", + "fr": "Achèvement" }, "translations": { - "en": "Translations" + "en": "Translations", + "fr": "Traductions" }, "langhead-progress": { - "en": "Translation Progress" + "en": "Translation Progress", + "fr": "Avancement de la Traduction" }, "langhead-native": { - "en": "Native" + "en": "Native", + "fr": "Natale" }, "outstanding-pullreq": { "en": "There are outstanding pull requests" From e4b543c30259e72de70fbecc8a15190872ab47a7 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 22 Apr 2013 19:36:13 +0000 Subject: [PATCH 4/7] 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 218509b7862bf2cdadb3833fc402018bb1346073 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 23 Apr 2013 17:28:26 +0000 Subject: [PATCH 5/7] fix syntax error in project strings --- modules/project/strings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/project/strings.json b/modules/project/strings.json index daa07b0..5dc8c3e 100644 --- a/modules/project/strings.json +++ b/modules/project/strings.json @@ -113,7 +113,7 @@ "nl": "Debug uitgeschakeld" }, "milestones": { - "en": "Milestones" + "en": "Milestones", "fr": "étapes" }, "milestoneprog": { From c37e9cded733e82dab556205e51a8c472009e29a Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 23 Apr 2013 18:48:41 +0000 Subject: [PATCH 6/7] 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 8475aa46e88ed3442efb6a099ac1c2e8e3ef0c23 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 23 Apr 2013 19:07:23 +0000 Subject: [PATCH 7/7] 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)) {