Skip to content

Commit

Permalink
Show admins report reason if any
Browse files Browse the repository at this point in the history
  • Loading branch information
C0rn3j committed Oct 19, 2023
1 parent 32bc5a6 commit d4db1d7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions handlers/commands/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
msgLink,
scheduleDeletion,
} = require('../../utils/tg');

const { logError } = require('../../utils/log');
const { chats = {} } = require('../../utils/config').config;

const isQualified = member => member.status === 'creator' ||
Expand Down Expand Up @@ -41,12 +41,21 @@ const reportHandler = async ctx => {
});
if (chats.report) {
const msg = await ctx.telegram.forwardMessage(chats.report, ctx.chat.id, reply.message_id);

const parts = ctx.message.text.split(/\s+/)
parts.shift();
const reportMessage = parts.join(' ');
let reportReason = ''
if (reportMessage.trim() !== '') {
reportReason = `\nReport reason: ${reportMessage}`
}

await ctx.deleteMessage();
await ctx.telegram.sendMessage(
chats.report,
TgHtml.tag`❗️ ${link(ctx.from)} reported <a href="${msgLink(
reply,
)}">a message</a> from ${link(reply.from)} in ${ctx.chat.title}!`,
)}">a message</a> from ${link(reply.from)} in ${ctx.chat.title}!<i>${reportReason}</i>`,
{
parse_mode: 'HTML',
reply_to_message_id: msg.message_id,
Expand Down

0 comments on commit d4db1d7

Please sign in to comment.