2016-08-21 16:00:05 +02:00
|
|
|
var fs = require('fs');
|
|
|
|
var builder = require('botbuilder');
|
|
|
|
|
2016-08-21 13:53:33 +02:00
|
|
|
var helper = require('./helper.js');
|
|
|
|
|
|
|
|
exports.ping = function(session) {
|
|
|
|
session.send("pong");
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var text = {};
|
|
|
|
text.stuff = [
|
|
|
|
"Plug.dj: https://plug.dj/don-t-starve-1"
|
|
|
|
];
|
|
|
|
|
|
|
|
exports.stuff = function(session) {
|
|
|
|
helper.send(session, text.stuff);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
text.games = [
|
|
|
|
"Minecraft Survival Server: dandellion.xyz",
|
|
|
|
"Minecraft World map (Updates every 24h): https://dandellion.xyz/minecraft/map"
|
|
|
|
]
|
|
|
|
|
|
|
|
exports.games = function(session) {
|
|
|
|
helper.send(session, text.games);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
text.about = [
|
|
|
|
"I am a general purpose bot created by Daniel, written with nodejs and the skype bot framework.",
|
|
|
|
"You can find my sourcecode at https://github.com/dali99/Misc-small-projects/tree/master/dodsorfas/Skypebot"
|
|
|
|
];
|
|
|
|
|
|
|
|
exports.about = function(session) {
|
|
|
|
helper.send(session, text.about);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
text.help = [
|
|
|
|
"Hey there! My available commands are:",
|
|
|
|
"about - Gives you information about the bot",
|
|
|
|
"ping - pong!",
|
|
|
|
"stuff - Information about different services we use",
|
2016-08-21 18:27:11 +02:00
|
|
|
"games - IPs and other related information about game servers we use",
|
|
|
|
"meme - meme <meme.png> posts the relevant meme",
|
|
|
|
"memes - lists all available memes"
|
2016-08-21 13:53:33 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
exports.help = function(session) {
|
|
|
|
helper.send(session, text.help);
|
2016-08-21 16:00:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// 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) {
|
2016-08-22 21:59:20 +02:00
|
|
|
var file;
|
2016-08-21 16:00:05 +02:00
|
|
|
var memewhitelist = fs.readdirSync("/usr/src/app/memes/");
|
2016-08-22 21:59:20 +02:00
|
|
|
if (session.message.text.match(helper.regex("meme random")) != null) {
|
2016-08-22 22:12:31 +02:00
|
|
|
var image = Math.floor(Math.random() * 1000000) % memewhitelist.length;
|
2016-08-22 21:59:20 +02:00
|
|
|
file=(memewhitelist[image]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
file = session.message.text.replace(helper.regex("meme "), "");
|
|
|
|
}
|
2016-08-21 16:00:05 +02:00
|
|
|
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
|
|
|
|
}]);
|
2016-08-22 22:12:31 +02:00
|
|
|
session.send("This meme is called: " + file);
|
2016-08-21 16:00:05 +02:00
|
|
|
session.send(msg);
|
|
|
|
}
|
|
|
|
|
2016-08-21 18:27:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.memes = function(session) {
|
|
|
|
var memes = fs.readdirSync("/usr/src/app/memes/");
|
|
|
|
helper.send(session, ["My available memes are:", memes.join(", ")]);
|
2016-08-21 16:00:05 +02:00
|
|
|
}
|