Add /absurdify

This commit is contained in:
Ceda EI 2019-02-12 04:45:02 +05:30
parent 3b945e17f3
commit 54f1e9a73b
3 changed files with 31 additions and 1 deletions

27
commands/absurdify.js Normal file
View File

@ -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";
}
};

View File

@ -3,6 +3,7 @@ const insults_fun = require("./insult");
const words_fun = require("./words"); const words_fun = require("./words");
const is = require("./is"); const is = require("./is");
const weebify = require("./weebify"); const weebify = require("./weebify");
const absurdify = require("./absurdify");
module.exports = (bot, [ questions, kys, insults, commands_list, words ]) => { module.exports = (bot, [ questions, kys, insults, commands_list, words ]) => {
bot.command("question", (ctx) => ctx.reply(random(questions)())); 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: + "Directory!](https://t.me/tgdrbot?start=quadnite_bot)", {parse_mode:
"Markdown"})); "Markdown"}));
bot.command("weebify", (ctx) => ctx.reply(weebify()(ctx))); bot.command("weebify", (ctx) => ctx.reply(weebify()(ctx)));
bot.command("absurdify", (ctx) => ctx.reply(absurdify()(ctx)));
}; };

View File

@ -47,7 +47,8 @@ module.exports = () => (ctx) => {
if (ctx.message.reply_to_message) if (ctx.message.reply_to_message)
return weebify(ctx.message.reply_to_message.text); return weebify(ctx.message.reply_to_message.text);
else 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";
} }