forked from GitHub/dbot
Add provisional flashy module which doesnt work yet
This commit is contained in:
parent
05cd889a4e
commit
cecfd781d6
35
modules/flashy/flashy.js
Normal file
35
modules/flashy/flashy.js
Normal file
@ -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);
|
||||
};
|
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': text
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
return pages(dbot);
|
||||
};
|
8
views/flashy/flashy.jade
Normal file
8
views/flashy/flashy.jade
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user