diff --git a/modules/api/api.js b/modules/api/api.js
index 408dc0a..88ed709 100644
--- a/modules/api/api.js
+++ b/modules/api/api.js
@@ -5,8 +5,8 @@
var _ = require('underscore')._;
var api = function(dbot) {
- this.pages = {
- '/api': function(req, res) {
+ this.onLoad = function() {
+ dbot.modules.web.app.get('/api', function(req, res) {
var externalApi = {};
_.each(dbot.api, function(moduleApi, moduleName) {
externalApi[moduleName] = {};
@@ -17,11 +17,9 @@ var api = function(dbot) {
});
});
- res.render('api', { 'name': dbot.config.name, 'api': externalApi });
- }
- };
+ res.render('api/api', { 'name': dbot.config.name, 'api': externalApi });
+ });
- this.onLoad = function() {
dbot.modules.web.app.get('/api/:module/:method', function(req, res) {
var module = req.params.module,
method = req.params.method,
diff --git a/modules/imgur/imgur.js b/modules/imgur/imgur.js
index 3bea45a..92cacde 100644
--- a/modules/imgur/imgur.js
+++ b/modules/imgur/imgur.js
@@ -4,7 +4,8 @@
*/
var _ = require('underscore')._,
- request = require('request');
+ request = require('request'),
+ crypto = require('crypto');
var imgur = function(dbot) {
this.internalAPI = {
@@ -49,7 +50,8 @@ var imgur = function(dbot) {
// 492 is body.length of a removed image
if(!error && response.statusCode == 200 && body.length != 492) {
dbot.db.imgur.totalImages += 1;
- callback(testUrl, testSlug);
+ var hash = crypto.createHash('md5').update(body).digest("hex");
+ callback(testUrl, testSlug,hash);
} else {
this.api.getRandomImage(callback);
}
diff --git a/modules/udp/README.md b/modules/udp/README.md
new file mode 100644
index 0000000..1c2b284
--- /dev/null
+++ b/modules/udp/README.md
@@ -0,0 +1,12 @@
+# UDP
+Prints UDP packets; designed for a [MediaWiki installation](https://www.mediawiki.org/wiki/Manual:$wgRC2UDPAddress).
+
+# Configuration
+## server
+The server name, as configured in the main ``config.json``, that depressionbot will announce packets on.
+## channel
+The channel name, that depressionbot will announce packets on.
+## port
+The port depressionbot will listen for UDP packets on.
+## address
+The address depressionbot will allow UDP packets from. UDP packets sent from a different address will be ignored.
diff --git a/modules/udp/config.json b/modules/udp/config.json
new file mode 100644
index 0000000..4619fcd
--- /dev/null
+++ b/modules/udp/config.json
@@ -0,0 +1,6 @@
+{
+ "port":14628,
+ "address": "127.0.0.1",
+ "server": "freenode",
+ "channel": "#oaosidl"
+}
diff --git a/modules/udp/udp.js b/modules/udp/udp.js
new file mode 100644
index 0000000..b7d9b76
--- /dev/null
+++ b/modules/udp/udp.js
@@ -0,0 +1,22 @@
+/**
+ * Module Name: UDP
+ * Description: Relays UDP packets, intended for
+ * a feed of RecentChanges on a MediaWiki install.
+ */
+var dgram = require('dgram');
+
+var udp = function(dbot) {
+ var server = dgram.createSocket("udp4");
+ server.on("message", function(msg, msginfo) {
+ var message = msg.toString();
+ console.log(message);
+ if (msginfo.address == dbot.config.udp.address) {
+ dbot.say(dbot.config.udp.server, dbot.config.udp.channel, message);
+ }
+ });
+ server.bind(dbot.config.udp.port);
+};
+
+exports.fetch = function(dbot) {
+ return new udp(dbot);
+};
diff --git a/public/imgurr.css b/public/imgurr.css
index f2bbb11..37d6fc7 100644
--- a/public/imgurr.css
+++ b/public/imgurr.css
@@ -106,3 +106,15 @@ html,body {
overflow:auto;
padding:0;
}
+#count2 {
+ bottom:25px;
+ position:absolute;
+ border-radius:5px;
+ display:none;
+ margin;5px;
+ padding:5px;
+ right:25px;
+ background-color:#3b5998;
+ color:white;
+ font-family:'Freight Sans Bold','Lucida Grande',verdana,arial,sans-serif;
+}
diff --git a/public/imgurr.js b/public/imgurr.js
new file mode 100644
index 0000000..5c03f60
--- /dev/null
+++ b/public/imgurr.js
@@ -0,0 +1,76 @@
+function giveMessage(msg) {
+ $('
'+msg+'').prependTo('#history').hide().slideDown();
+}
+
+var lock = false;
+var highscore = 10 + 1;
+var score = highscore;
+var count = 0;
+var count2 = 0;
+
+$('#count').text(score);
+
+function getNewImage() {
+ count += 1;
+ lock = true;
+ $('#loading').fadeIn();
+ $('#loading').text('Loading image ' + count + '...');
+ document.title = 'random imgur (' + count + ')';
+ $('#loading').fadeIn();
+ $('#image').load(function(){});
+ $.get("/api/imgur/getRandomImage", function(d) {
+ $('#image').attr('src', d.data[0]);
+ lock = false;
+ score -= 1;
+ $('#count').text(score);
+ $('#details').text("Fetching info...");
+ giveMessage('' + d.data[0] + '');
+ $.get("/api/imgur/getImageInfoString", { 'slug': d.data[1] }, function(info) {
+ if(info.data[0].indexOf('undefined') == -1) {
+ $("#details").text(count + ': ' + info.data[0]);
+ $('#details').show();
+ } else {
+ $("#details").hide();
+ }
+ $('#loading').fadeOut();
+ }, "json");
+ console.log(d.data[2]);
+ if(d.data[2] == "e49e686582ce3f60cb51d00c10924861") { // 3Tt6N fb guy
+ count2 += 1;
+ if (count2 == 1){
+ $('#count2').text("+ " + count2 + " Facebook Monopoly Man");
+ } else {
+ $('#count2').text("+ " + count2 + " Facebook Monopoly Men");
+ }
+ $('#count2').fadeIn();
+ }
+ }, "json");
+}
+
+$(getNewImage());
+
+$(document).on('keydown', function(e){
+ switch(e.which){
+ case 82: // r
+ score = highscore;
+ $('#count').text(highscore);
+ giveMessage("Score reset.");
+ case 13: // enter
+ case 32: // space
+ if (lock) {
+ $('#loading').text(function(index, text){
+ return text.replace(/.(?=[^.]*$)/, "!");
+ });
+ } else {
+ getNewImage();
+ }
+ break;
+ case 67:
+ $('#count').fadeToggle();
+ $('#count2').fadeToggle();
+ break;
+ case 83: // s
+ $('body').toggleClass('crop');
+ giveMessage("Toggled scrollbars.")
+ };
+});
diff --git a/views/imgur/imgurr.jade b/views/imgur/imgurr.jade
index b3e4436..41d27fe 100644
--- a/views/imgur/imgurr.jade
+++ b/views/imgur/imgurr.jade
@@ -3,73 +3,17 @@ html(lang='en')
head
meta(charset='utf-8')
script(type="text/javascript", src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js")
+ script(type="text/javascript", src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js")
+ script(type="text/javascript", src="/imgurr.js")
link(rel="stylesheet", href="/imgurr.css")
title random imgur
- script
- var count = 0;
- function giveMessage(msg) {
- $(''+msg+'').prependTo('#history').hide().slideDown();
- }
- var lock = false
- var highscore = #{highscore} + 1;
- var score = highscore;
- $('#count').text(score);
- function getNewImage() {
- count += 1;
- lock = true;
- $('#loading').fadeIn();
- $('#loading').text('Loading image ' + count + '...');
- document.title = 'random imgur (' + count + ')';
- $('#loading').fadeIn();
- $('#image').load(function(){});
- $.get("/api/imgur/getRandomImage", function(d) {
- $('#image').attr('src', d.data[0]);
- lock = false;
- score -= 1;
- $('#count').text(score);
- $('#details').text("Fetching info...");
- giveMessage('' + d.data[0] + '');
- $.get("/api/imgur/getImageInfoString", { 'slug': d.data[1] }, function(info) {
- if(info.data[0].indexOf('undefined') == -1) {
- $("#details").text(count + ': ' + info.data[0]);
- $('#details').show();
- } else {
- $("#details").hide();
- }
- $('#loading').fadeOut();
- }, "json");
- }, "json");
- }
- $(getNewImage());
- $(document).on('keydown', function(e){
- switch(e.which){
- case 82: // r
- score = highscore;
- $('#count').text(highscore);
- giveMessage("Score reset.");
- case 13: // enter
- case 32: // space
- if (lock) {
- $('#loading').text(function(index, text){
- return text.replace(/\.(?=[^.]*$)/, "!");
- });
- } else {
- getNewImage();
- }
- break;
- case 67:
- $('#count').fadeToggle();
- break;
- case 83: // s
- $('body').toggleClass('crop');
- giveMessage("Toggled scrollbars.")
- };
- });
body
div#loading Loading image 1...
div#details Press [SPACE] to load a new image
div#count
#{highscore}
+ div#count2
+ ΓΈ
ul#history
li Press [SPACE] for next
div#container