From 3b945e17f32372589447839fcaf797c0c18a678c Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Tue, 12 Feb 2019 04:37:50 +0530 Subject: [PATCH] Add /weebify --- commands/index.js | 2 ++ commands/weebify.js | 54 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 commands/weebify.js diff --git a/commands/index.js b/commands/index.js index 0691b46..04cf763 100644 --- a/commands/index.js +++ b/commands/index.js @@ -2,6 +2,7 @@ const random = require("./random"); const insults_fun = require("./insult"); const words_fun = require("./words"); const is = require("./is"); +const weebify = require("./weebify"); module.exports = (bot, [ questions, kys, insults, commands_list, words ]) => { bot.command("question", (ctx) => ctx.reply(random(questions)())); @@ -43,5 +44,6 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words ]) => { bot.command("rate", (ctx) => ctx.reply("[Vote for me on Telegram " + "Directory!](https://t.me/tgdrbot?start=quadnite_bot)", {parse_mode: "Markdown"})); + bot.command("weebify", (ctx) => ctx.reply(weebify()(ctx))); }; diff --git a/commands/weebify.js b/commands/weebify.js new file mode 100644 index 0000000..e8ae8d7 --- /dev/null +++ b/commands/weebify.js @@ -0,0 +1,54 @@ +function weebify(text) { + + const dict = { + a : "卂", + b : "乃", + c : "匚", + d : "刀", + e : "乇", + f : "下", + g : "厶", + h : "卄", + i : "工", + j : "丁", + k : "长", + l : "乚", + m : "从", + n : "𠘨", + o : "口", + p : "尸", + q : "㔿", + r : "尺", + s : "丂", + t : "丅", + u : "凵", + v : "リ", + w : "山", + x : "乂", + y : "丫", + z : "乙" + }; + const text_array = text.toLowerCase().split(""); + return text_array.map((character) => + dict[character] ? dict[character] : character) + .join(""); + +} + +module.exports = () => (ctx) => { + + const message = ctx.message.text.replace(/^[^ ]+/, ""); + if (message) { + + return weebify(message); + + } else { + + 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"; + + } + +};