From 4a2703630735a5c1c411e49d072aa814a6a10a1d Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 5 Apr 2013 13:30:47 +0300 Subject: [PATCH 01/11] fix #335 by making req limit higher --- modules/link/link.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/link/link.js b/modules/link/link.js index fe19117..12adf09 100644 --- a/modules/link/link.js +++ b/modules/link/link.js @@ -11,7 +11,7 @@ var link = function(dbot) { this.urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; this.links = {}; this.fetchTitle = function(event, link) { - var limit = 250 * 1000, + var limit = 1000000, size = 0, page = request(link, function(error, response, body) { if(!error && response.statusCode == 200) { From 05cd889a4e99d163a1c797ddf121943e968ee01c Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 8 Apr 2013 23:51:28 +0000 Subject: [PATCH 02/11] Don't dent new quote additions if it includes interpolation notation. --- modules/dent/dent.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/dent/dent.js b/modules/dent/dent.js index 311d9d0..fcbb8a4 100644 --- a/modules/dent/dent.js +++ b/modules/dent/dent.js @@ -59,7 +59,9 @@ var dent = function(dbot) { this.onLoad = function() { if(dbot.config.dent.dentQuotes === true && _.has(dbot.modules, 'quotes')) { dbot.api.command.addHook('~qadd', function(key, text) { - this.api.post(key + ': ' + text); + if(text.indexOf('~~') == -1) { + this.api.post(key + ': ' + text); + } }.bind(this)); } }.bind(this); From cecfd781d61d02b06c509fb0465590148cbade68 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 9 Apr 2013 15:20:07 +0000 Subject: [PATCH 03/11] Add provisional flashy module which doesnt work yet --- modules/flashy/flashy.js | 35 +++++++++++++++++++++++++++++++++++ modules/flashy/pages.js | 21 +++++++++++++++++++++ views/flashy/flashy.jade | 8 ++++++++ 3 files changed, 64 insertions(+) create mode 100644 modules/flashy/flashy.js create mode 100644 modules/flashy/pages.js create mode 100644 views/flashy/flashy.jade diff --git a/modules/flashy/flashy.js b/modules/flashy/flashy.js new file mode 100644 index 0000000..407dba0 --- /dev/null +++ b/modules/flashy/flashy.js @@ -0,0 +1,35 @@ +/** + * Module Name: Flashy + * Description: Makes pages with flashing text and that innit. + */ + +var _ = require('underscore')._; + +var flashy = function(dbot) { + this.colourMap = { + 'red': 'FF0000' + }; + + this.commands = { + '~flashy': function(event) { + var colour = event.params[1]; + var text = event.params[2]; + + if(_.has(this.colourMap, colour)) { + dbot.t('url', { + 'host': dbot.config.web.webHost, + 'port': dbot.config.web.webPort, + 'path': 'flashy/' + colour + '/' + encodeURIComponent(text) + }); + } else { + event.reply('no such colour brah'); + } + } + }; + + this.commands['~flashy'].regex = [/^~qadd ([\d\w-]+[\d\w\s-]*)[ ]?=[ ]?(.+)$/, 3]; +}; + +exports.fetch = function(dbot) { + return new flashy(dbot); +}; diff --git a/modules/flashy/pages.js b/modules/flashy/pages.js new file mode 100644 index 0000000..5b09dd8 --- /dev/null +++ b/modules/flashy/pages.js @@ -0,0 +1,21 @@ +var _ = require('underscore')._; + +var pages = function(dbot) { + return { + '/flashy/:colour/:text': function(req, res) { + if(!_.has(this.colourMap, req.params.colour)) { + req.params.colour = 'red'; + } + var colour = this.colourMap[req.params.colour]; + res.render('flashy', { + 'name': dbot.config.name, + 'colour': colour, + 'text': text + }); + } + }; +}; + +exports.fetch = function(dbot) { + return pages(dbot); +}; diff --git a/views/flashy/flashy.jade b/views/flashy/flashy.jade new file mode 100644 index 0000000..8a13036 --- /dev/null +++ b/views/flashy/flashy.jade @@ -0,0 +1,8 @@ +!!! 5 +html(lang='en') + head + meta(charset='utf-8') + link(rel='stylesheet', type='text/css', href='/styles.css') + title #{name} web interface + body + div.container From 694e1bf8578bdfce22eb3641b1cf70c88c46498e Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 9 Apr 2013 15:28:56 +0000 Subject: [PATCH 04/11] fix regex and add g and b colour codes --- modules/flashy/flashy.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/flashy/flashy.js b/modules/flashy/flashy.js index 407dba0..840311d 100644 --- a/modules/flashy/flashy.js +++ b/modules/flashy/flashy.js @@ -7,7 +7,9 @@ var _ = require('underscore')._; var flashy = function(dbot) { this.colourMap = { - 'red': 'FF0000' + 'red': 'FF0000', + 'green': '00FF00', + 'blue': '0000FF' }; this.commands = { @@ -27,7 +29,7 @@ var flashy = function(dbot) { } }; - this.commands['~flashy'].regex = [/^~qadd ([\d\w-]+[\d\w\s-]*)[ ]?=[ ]?(.+)$/, 3]; + this.commands['~flashy'].regex = [/^~flashy ([\d\w-]+[\d\w\s-]*)[ ]?=[ ]?(.+)$/, 3]; }; exports.fetch = function(dbot) { From 4d5fa0427799780ca0971a62a74af7088fc683d2 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 9 Apr 2013 15:30:56 +0000 Subject: [PATCH 05/11] fix render to point to text proeprly --- modules/flashy/pages.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/flashy/pages.js b/modules/flashy/pages.js index 5b09dd8..6b46ba5 100644 --- a/modules/flashy/pages.js +++ b/modules/flashy/pages.js @@ -10,7 +10,7 @@ var pages = function(dbot) { res.render('flashy', { 'name': dbot.config.name, 'colour': colour, - 'text': text + 'text': req.params.text }); } }; From 8a9256c8383154bde2e3ab0a4341af178e9bfbe0 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 9 Apr 2013 16:45:11 +0100 Subject: [PATCH 06/11] [rejected] --- modules/flashy/pages.js | 2 +- public/flash.css | 23 +++++++++++++++++++++++ views/flashy/flashy.jade | 5 ++++- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 public/flash.css diff --git a/modules/flashy/pages.js b/modules/flashy/pages.js index 5b09dd8..6b46ba5 100644 --- a/modules/flashy/pages.js +++ b/modules/flashy/pages.js @@ -10,7 +10,7 @@ var pages = function(dbot) { res.render('flashy', { 'name': dbot.config.name, 'colour': colour, - 'text': text + 'text': req.params.text }); } }; diff --git a/public/flash.css b/public/flash.css new file mode 100644 index 0000000..c632405 --- /dev/null +++ b/public/flash.css @@ -0,0 +1,23 @@ +body { background: #000; font-family: sans-serif } + +.stamp { + text-align: center; + color: #FFF; + font-size: 12em; +} + +.flash { + text-decoration: blink; +} + +@-webkit-keyframes blink { + from { opacity: 1.0; } + to { opacity: 0.0; } +} + +.flash { + -webkit-animation-name: blink; + -webkit-animation-iteration-count: infinite; + -webkit-animation-timing-function: cubic-bezier(1.0,0,0,1.0); + -webkit-animation-duration: 1s; +} diff --git a/views/flashy/flashy.jade b/views/flashy/flashy.jade index 8a13036..f05641f 100644 --- a/views/flashy/flashy.jade +++ b/views/flashy/flashy.jade @@ -2,7 +2,10 @@ html(lang='en') head meta(charset='utf-8') - link(rel='stylesheet', type='text/css', href='/styles.css') + link(rel='stylesheet', type='text/css', href='/flash.css') title #{name} web interface body div.container + div.stamp [ + span.flash(style='color: #'+colour+';') #{text} + ] From a129083826028eecfe7b144e0c51d28fa8cdb394 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 9 Apr 2013 22:06:03 +0000 Subject: [PATCH 07/11] input, not params (flashy) --- modules/flashy/flashy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/flashy/flashy.js b/modules/flashy/flashy.js index 840311d..70c31fb 100644 --- a/modules/flashy/flashy.js +++ b/modules/flashy/flashy.js @@ -14,8 +14,8 @@ var flashy = function(dbot) { this.commands = { '~flashy': function(event) { - var colour = event.params[1]; - var text = event.params[2]; + var colour = event.input[1]; + var text = event.input[2]; if(_.has(this.colourMap, colour)) { dbot.t('url', { From 381a78e31134e77074c1edf01d77cb663ced0fd2 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 9 Apr 2013 22:07:11 +0000 Subject: [PATCH 08/11] forgot event.reply (flashy) --- modules/flashy/flashy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/flashy/flashy.js b/modules/flashy/flashy.js index 70c31fb..26b2f07 100644 --- a/modules/flashy/flashy.js +++ b/modules/flashy/flashy.js @@ -18,11 +18,11 @@ var flashy = function(dbot) { var text = event.input[2]; if(_.has(this.colourMap, colour)) { - dbot.t('url', { + event.reply(dbot.t('url', { 'host': dbot.config.web.webHost, 'port': dbot.config.web.webPort, 'path': 'flashy/' + colour + '/' + encodeURIComponent(text) - }); + })); } else { event.reply('no such colour brah'); } From 52d232a2e6099991922d41fc5e30cbe8f5525df0 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 9 Apr 2013 22:14:15 +0000 Subject: [PATCH 09/11] add more colours, automatic upper case and help output --- modules/flashy/flashy.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/flashy/flashy.js b/modules/flashy/flashy.js index 26b2f07..f4ccb30 100644 --- a/modules/flashy/flashy.js +++ b/modules/flashy/flashy.js @@ -7,15 +7,19 @@ var _ = require('underscore')._; var flashy = function(dbot) { this.colourMap = { + 'white': 'FFFFFF', 'red': 'FF0000', 'green': '00FF00', - 'blue': '0000FF' + 'blue': '0000FF', + 'yellow': 'FFFF00', + 'magenta': 'FF00FF', + 'cyan': '00FFFF' }; this.commands = { '~flashy': function(event) { - var colour = event.input[1]; - var text = event.input[2]; + var colour = event.input[1].trim(); + var text = event.input[2].trim().toUpperCase(); if(_.has(this.colourMap, colour)) { event.reply(dbot.t('url', { @@ -24,7 +28,8 @@ var flashy = function(dbot) { 'path': 'flashy/' + colour + '/' + encodeURIComponent(text) })); } else { - event.reply('no such colour brah'); + var possibleColours = _.keys(this.colourMap).join(', ').slice(0, -2) + '.'; + event.reply('No such colour, brah. Available colours are: ' + possibleColours); } } }; From b038ecf63fa3be38303a1cde87acf10ff3cf280e Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 9 Apr 2013 22:15:17 +0000 Subject: [PATCH 10/11] no blank at end --- modules/flashy/flashy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/flashy/flashy.js b/modules/flashy/flashy.js index f4ccb30..8195591 100644 --- a/modules/flashy/flashy.js +++ b/modules/flashy/flashy.js @@ -28,7 +28,7 @@ var flashy = function(dbot) { 'path': 'flashy/' + colour + '/' + encodeURIComponent(text) })); } else { - var possibleColours = _.keys(this.colourMap).join(', ').slice(0, -2) + '.'; + var possibleColours = _.keys(this.colourMap).join(', ') + '.'; event.reply('No such colour, brah. Available colours are: ' + possibleColours); } } From 6638dec85aac0441237be1a652fe94770713fe30 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 9 Apr 2013 22:33:07 +0000 Subject: [PATCH 11/11] remove = from flashy regex since all colours are one word anyway --- modules/flashy/flashy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/flashy/flashy.js b/modules/flashy/flashy.js index 8195591..3122dcb 100644 --- a/modules/flashy/flashy.js +++ b/modules/flashy/flashy.js @@ -18,7 +18,7 @@ var flashy = function(dbot) { this.commands = { '~flashy': function(event) { - var colour = event.input[1].trim(); + var colour = event.input[1]; var text = event.input[2].trim().toUpperCase(); if(_.has(this.colourMap, colour)) { @@ -34,7 +34,7 @@ var flashy = function(dbot) { } }; - this.commands['~flashy'].regex = [/^~flashy ([\d\w-]+[\d\w\s-]*)[ ]?=[ ]?(.+)$/, 3]; + this.commands['~flashy'].regex = [/^~flashy ([^ ]+) (.+)$/, 3]; }; exports.fetch = function(dbot) {