From 610fadefcc3bc7eb502897b44206c725b34fca13 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Tue, 12 Feb 2019 23:58:22 +0530 Subject: [PATCH] Add /info --- commands/index.js | 2 ++ commands/info.js | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 commands/info.js diff --git a/commands/index.js b/commands/index.js index 7ef817f..4cca973 100644 --- a/commands/index.js +++ b/commands/index.js @@ -6,6 +6,7 @@ const weebify = require("./weebify"); const absurdify = require("./absurdify"); const feedback = require("./feedback"); const media_wiki = require("./media_wiki"); +const info = require("./info"); module.exports = (bot, [ questions, kys, insults, commands_list, words ], feedback_id, axios) => { @@ -58,5 +59,6 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words ], bot.command("arch_wiki", (ctx) => media_wiki(axios, "https://wiki.archlinux.org/api.php")(ctx).then(x => ctx.reply(x, {parse_mode: "HTML"}))); + bot.command("info", (ctx) => ctx.reply(info()(ctx), {parse_mode: "Markdown"})); }; diff --git a/commands/info.js b/commands/info.js new file mode 100644 index 0000000..76b558f --- /dev/null +++ b/commands/info.js @@ -0,0 +1,36 @@ +module.exports = () => (ctx) => { + + let text = ""; + const msg = ctx.message; + text += `Message ID: \`${msg.message_id}\`\n`; + text += `Chat ID: \`${msg.chat.id}\`\n`; + text += `User ID: \`${msg.from.id}\`\n`; + if (msg.reply_to_message) { + + const reply = msg.reply_to_message; + text += "\n*Reply to*\n"; + text += `Message ID: \`${reply.message_id}\`\n`; + text += `Chat ID: \`${reply.chat.id}\`\n`; + text += `User ID: \`${reply.from.id}\`\n`; + + if (reply.forward_from || reply.forward_from_chat) { + + const forward = reply.forward_from ? reply.forward_from + :reply.forward_from_chat; + text += "\n*Forward from*\n"; + if (reply.forward_from) + text += "User ID: "; + else + text += "Channel ID: "; + text += `\`${forward.id}\`\n`; + text += "Message Date: `"; + const date = new Date(reply.forward_date); + text += date.toUTCString(); + text += "`"; + + } + + } + return text; + +};