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:
commit
86492e3efb
@ -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);
|
||||
|
42
modules/flashy/flashy.js
Normal file
42
modules/flashy/flashy.js
Normal 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
21
modules/flashy/pages.js
Normal 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);
|
||||
};
|
@ -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) {
|
||||
|
23
public/flash.css
Normal file
23
public/flash.css
Normal 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
11
views/flashy/flashy.jade
Normal 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}
|
||||
]
|
Loading…
Reference in New Issue
Block a user