From 54f1e9a73bfe75a6a44f6561fb6c7863051b85a0 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Tue, 12 Feb 2019 04:45:02 +0530 Subject: [PATCH] Add /absurdify --- commands/absurdify.js | 27 +++++++++++++++++++++++++++ commands/index.js | 2 ++ commands/weebify.js | 3 ++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 commands/absurdify.js diff --git a/commands/absurdify.js b/commands/absurdify.js new file mode 100644 index 0000000..a6493d1 --- /dev/null +++ b/commands/absurdify.js @@ -0,0 +1,27 @@ +function absurdify(text) { + + const text_array = text.split(""); + return text_array.map((character) => + Math.random() > 0.5 ? character.toLowerCase(): character.toUpperCase()) + .join(""); + +} + +module.exports = () => (ctx) => { + + const message = ctx.message.text.replace(/^[^ ]+/, ""); + if (message) { + + return absurdify(message); + + } else { + + if (ctx.message.reply_to_message) + return absurdify(ctx.message.reply_to_message.text); + else + return "Need text to absurdify. Send /absurdify text or reply to a" + + "message with /absurdify"; + + } + +}; diff --git a/commands/index.js b/commands/index.js index 04cf763..03d15b6 100644 --- a/commands/index.js +++ b/commands/index.js @@ -3,6 +3,7 @@ const insults_fun = require("./insult"); const words_fun = require("./words"); const is = require("./is"); const weebify = require("./weebify"); +const absurdify = require("./absurdify"); module.exports = (bot, [ questions, kys, insults, commands_list, words ]) => { bot.command("question", (ctx) => ctx.reply(random(questions)())); @@ -45,5 +46,6 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words ]) => { + "Directory!](https://t.me/tgdrbot?start=quadnite_bot)", {parse_mode: "Markdown"})); bot.command("weebify", (ctx) => ctx.reply(weebify()(ctx))); + bot.command("absurdify", (ctx) => ctx.reply(absurdify()(ctx))); }; diff --git a/commands/weebify.js b/commands/weebify.js index e8ae8d7..22cf36a 100644 --- a/commands/weebify.js +++ b/commands/weebify.js @@ -47,7 +47,8 @@ module.exports = () => (ctx) => { if (ctx.message.reply_to_message) return weebify(ctx.message.reply_to_message.text); else - return "Need text to weebify. Send /weebify text or reply to a message with /weebify"; + return "Need text to weebify. Send /weebify text or reply to a " + + "message with /weebify"; }