Skip to content

Commit 972090d

Browse files
authored
Add optional /report reason and show it to admins (#171)
1 parent 515e6cd commit 972090d

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Command | Role | Available at | Description
6868
`/staff` | _Everyone_ | _Everywhere_ | Shows a list of admins.
6969
`/link` | _Everyone_ | _Everywhere_ | Shows the current group's link.
7070
`/groups` | _Everyone_ | _Everywhere_ | Shows a list of groups which the bot is admin in.
71-
`/report` | _Everyone_ | _Everywhere_ | Reports the replied-to message to admins.
71+
`/report [reason]` | _Everyone_ | _Everywhere_ | Reports the replied-to message to admins, reason is optional.
7272
`/commands` | _Everyone_ | _In-Bot_ | Shows a list of available commands.
7373
`/help` \| `/start` | _Everyone_ | _In-Bot_ | How to use the bot.
7474

handlers/commands/commands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const userCommands = `\
3737
<code>/staff</code> - Shows a list of admins.
3838
<code>/link</code> - Show the current group's link.
3939
<code>/groups</code> - Show a list of groups which the bot is admin in.
40-
<code>/report</code> - Reports the replied-to message to admins.\n
40+
<code>/report [reason]</code> - Reports the replied-to message to admins, reason is optional.\n
4141
`;
4242
const role = R.prop('role');
4343
const name = R.prop('name');

handlers/commands/report.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,21 @@ const reportHandler = async ctx => {
4141
});
4242
if (chats.report) {
4343
const msg = await ctx.telegram.forwardMessage(chats.report, ctx.chat.id, reply.message_id);
44+
45+
const parts = ctx.message.text.split(/\s+/)
46+
parts.shift();
47+
const reportMessage = parts.join(' ');
48+
let reportReason = ''
49+
if (reportMessage.trim() !== '') {
50+
reportReason = TgHtml.tag`\n\n\nReport reason: <i>${reportMessage}</i>`
51+
}
52+
4453
await ctx.deleteMessage();
4554
await ctx.telegram.sendMessage(
4655
chats.report,
4756
TgHtml.tag`❗️ ${link(ctx.from)} reported <a href="${msgLink(
4857
reply,
49-
)}">a message</a> from ${link(reply.from)} in ${ctx.chat.title}!`,
58+
)}">a message</a> from ${link(reply.from)} in ${ctx.chat.title}!${reportReason}`,
5059
{
5160
parse_mode: 'HTML',
5261
reply_to_message_id: msg.message_id,

0 commit comments

Comments
 (0)