3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-01 00:19:29 +01:00

Merge git://github.com/reality/depressionbot into database

This commit is contained in:
reality 2013-04-09 22:55:35 +00:00
commit 86492e3efb
6 changed files with 101 additions and 2 deletions

View File

@ -59,7 +59,9 @@ var dent = function(dbot) {
this.onLoad = function() { this.onLoad = function() {
if(dbot.config.dent.dentQuotes === true && _.has(dbot.modules, 'quotes')) { if(dbot.config.dent.dentQuotes === true && _.has(dbot.modules, 'quotes')) {
dbot.api.command.addHook('~qadd', function(key, text) { 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));
} }
}.bind(this); }.bind(this);

42
modules/flashy/flashy.js Normal file
View File

@ -0,0 +1,42 @@
/**
* Module Name: Flashy
* Description: Makes pages with flashing text and that innit.
*/
var _ = require('underscore')._;
var flashy = function(dbot) {
this.colourMap = {
'white': 'FFFFFF',
'red': 'FF0000',
'green': '00FF00',
'blue': '0000FF',
'yellow': 'FFFF00',
'magenta': 'FF00FF',
'cyan': '00FFFF'
};
this.commands = {
'~flashy': function(event) {
var colour = event.input[1];
var text = event.input[2].trim().toUpperCase();
if(_.has(this.colourMap, colour)) {
event.reply(dbot.t('url', {
'host': dbot.config.web.webHost,
'port': dbot.config.web.webPort,
'path': 'flashy/' + colour + '/' + encodeURIComponent(text)
}));
} else {
var possibleColours = _.keys(this.colourMap).join(', ') + '.';
event.reply('No such colour, brah. Available colours are: ' + possibleColours);
}
}
};
this.commands['~flashy'].regex = [/^~flashy ([^ ]+) (.+)$/, 3];
};
exports.fetch = function(dbot) {
return new flashy(dbot);
};

21
modules/flashy/pages.js Normal file
View File

@ -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': req.params.text
});
}
};
};
exports.fetch = function(dbot) {
return pages(dbot);
};

View File

@ -11,7 +11,7 @@ var link = function(dbot) {
this.urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; this.urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
this.links = {}; this.links = {};
this.fetchTitle = function(event, link) { this.fetchTitle = function(event, link) {
var limit = 250 * 1000, var limit = 1000000,
size = 0, size = 0,
page = request(link, function(error, response, body) { page = request(link, function(error, response, body) {
if(!error && response.statusCode == 200) { if(!error && response.statusCode == 200) {

23
public/flash.css Normal file
View File

@ -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;
}

11
views/flashy/flashy.jade Normal file
View File

@ -0,0 +1,11 @@
!!! 5
html(lang='en')
head
meta(charset='utf-8')
link(rel='stylesheet', type='text/css', href='/flash.css')
title #{name} web interface
body
div.container
div.stamp [
span.flash(style='color: #'+colour+';') #{text}
]