From bdf52331b1546c39562273bd41a6b7703633fb09 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Tue, 16 Apr 2024 19:15:54 +0530 Subject: [PATCH] Add username in feedback --- commands/feedback.js | 17 ++++++++++++++--- commands/index.js | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/commands/feedback.js b/commands/feedback.js index 0519261..2ffba13 100644 --- a/commands/feedback.js +++ b/commands/feedback.js @@ -1,14 +1,25 @@ -module.exports = (feedback_id) => (ctx) => { +module.exports = (bot, feedback_id) => (ctx) => { const message = ctx.message.text.replace(/^[^ ]+/, ""); if (message) { + const from = ctx.message.from; + let contactable = "The developer might contact you regarding your feedback."; + if (from.username) { + + bot.telegram.sendMessage(feedback_id, `Feedback from: @${from.username}`); + + } else { + + contactable = "The developer might not be able to contact you due to lack of your username."; + + } ctx.forwardMessage(feedback_id); - return "Thanks for the feedback"; + return `Thanks for the feedback! ${contactable}`; } else { - return "To send feedback type in /feedback followed by the feedback"; + return "To send feedback type in /feedback followed by the feedback. Note that developers may contact you regarding the feedback."; } diff --git a/commands/index.js b/commands/index.js index af8427c..994660b 100644 --- a/commands/index.js +++ b/commands/index.js @@ -55,7 +55,7 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words, roleplay "Markdown"})); bot.command("weebify", (ctx) => ctx.reply(weebify()(ctx))); bot.command("absurdify", (ctx) => ctx.reply(absurdify()(ctx))); - bot.command("feedback", (ctx) => ctx.reply(feedback(feedback_id)(ctx))); + bot.command("feedback", (ctx) => ctx.reply(feedback(bot, feedback_id)(ctx))); bot.command("wiki", (ctx) => media_wiki(axios, "https://en.wikipedia.org/w/api.php")(ctx).then(x => ctx.reply(x, {parse_mode: "HTML"})));