diff --git a/dodsorfas/Skypebot/app.js b/dodsorfas/Skypebot/app.js index 8dcfd27..972da8d 100644 --- a/dodsorfas/Skypebot/app.js +++ b/dodsorfas/Skypebot/app.js @@ -35,6 +35,7 @@ bot.dialog('/', new builder.IntentDialog() .matches(helper.regex("games"), function(s) {cmd.games(s)}) .matches(helper.regex("about"), function(s) {cmd.about(s)}) .matches(helper.regex("help"), function(s) {cmd.help(s)}) + .matches(helper.regex("meme \\w+"), function(s) {cmd.meme(s)}) .onDefault(function(session) { session.send("I didn't understand. Say 'help' to get a list of commands!"); })); diff --git a/dodsorfas/Skypebot/commands.js b/dodsorfas/Skypebot/commands.js index f58c22c..3e5c316 100644 --- a/dodsorfas/Skypebot/commands.js +++ b/dodsorfas/Skypebot/commands.js @@ -1,3 +1,6 @@ +var fs = require('fs'); +var builder = require('botbuilder'); + var helper = require('./helper.js'); exports.ping = function(session) { @@ -45,4 +48,26 @@ text.help = [ exports.help = function(session) { helper.send(session, text.help); -}; \ No newline at end of file +}; + +// This application runs in a docker container, the memes folder on my web server is mounted inside this path as well. +// Bad solution, but it'll work. -- Note to future self, maybe put a real webserver to serve the image files instead... +exports.meme = function(session) { + var memewhitelist = fs.readdirSync("/usr/src/app/memes/"); + var file = session.message.text.replace(helper.regex("meme "), ""); + console.log(file); + + if (!memewhitelist.includes(file)) { + session.send("That meme isnt added to my folder :( Contact dan to add it :D"); + } + else { + var msg = new builder.Message(session) + .attachments([{ + contentType: "image/png", + contentUrl: "http://dandellion.xyz/dodsorfas/memes/" + file + }]); + + session.send(msg); + } + +} \ No newline at end of file