From 43386da0c74f0fc68dca86bba7f5a4c8cd3210a5 Mon Sep 17 00:00:00 2001 From: Flummi Date: Fri, 1 Dec 2017 16:31:26 +0100 Subject: [PATCH] .witz --- src/inc/trigger/useless_nxy.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/inc/trigger/useless_nxy.js b/src/inc/trigger/useless_nxy.js index c91b396..55fbb03 100644 --- a/src/inc/trigger/useless_nxy.js +++ b/src/inc/trigger/useless_nxy.js @@ -227,10 +227,10 @@ module.exports = bot => { } })); - bot._trigger.set("joke", new bot.trigger({ - call: /^(\.|\/)joke$/i, + bot._trigger.set("witz", new bot.trigger({ + call: /^(\.|\/)witz$/i, f: e => { - rp("http://www.funny4you.at/webmasterprogramm/zufallswitz.php") + rp("http://www.funny4you.at/webmasterprogramm/zufallswitz.php?id=312") .then(res => { res = res .split("
").join("") @@ -241,7 +241,7 @@ module.exports = bot => { .split("ü").join("ü") .split("Ä").join("Ä") .split("Ö").join("Ö") - .split("&Üuml;").join("Ü") + .split("Ü").join("Ü") .split("ß").join("ß") .split(""").join("\"") .replace(/\ { }); } })); + + bot._trigger.set("joke", new bot.trigger({ + call: /^(\.|\/)joke$/i, + f: e => { + rp("https://icanhazdadjoke.com/slack", { json: true }) + .then(res => { + res = res.attachments[0].text; + + if(e.network !== "Telegram") { + res + .match(/.{1,450}/g) + .map(e.reply); + } + else + e.reply(res); + }) + .catch(err => { + console.log(err); + }); + } + })); }; \ No newline at end of file