From 11da9c9ba25346335a5b29872a55bbae23a4b9ab Mon Sep 17 00:00:00 2001 From: Wojciech Pawlik Date: Thu, 6 Feb 2020 12:35:04 +0100 Subject: [PATCH] Add "report handled" button --- handlers/commands/report.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/handlers/commands/report.js b/handlers/commands/report.js index 088eef4..2c0a0cb 100644 --- a/handlers/commands/report.js +++ b/handlers/commands/report.js @@ -22,15 +22,6 @@ const reportHandler = async ctx => { replyOptions ).then(scheduleDeletion()); } - if (chats.report) { - ctx.tg.sendMessage( - chats.report, - `❗️ Report in ` + - escapeHtml(msg.chat.title) + - '!', - replyOptions - ); - } const admins = (await ctx.getChatAdministrators()) .filter(member => member.status === 'creator' || @@ -45,9 +36,24 @@ const reportHandler = async ctx => { const adminsMention = adminObjects.map(link).join(''); const s = `❗️${link(ctx.from)} reported the message to the admins.` + `${adminsMention}`; - return ctx.replyWithHTML(s, { + const report = await ctx.replyWithHTML(s, { reply_to_message_id: msg.reply_to_message.message_id }); + if (chats.report) { + await ctx.tg.sendMessage( + chats.report, + `❗️ Report in ` + + escapeHtml(msg.chat.title) + + '!', + { ...replyOptions, + reply_markup: { inline_keyboard: [ [ { + text: '✔️ Handled', + // eslint-disable-next-line max-len + callback_data: `/del -chat_id=${report.chat.id} -msg_id=${report.message_id} Report handled` + } ] ] } } + ); + } + return null; }; module.exports = reportHandler;