mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-29 13:17:56 +00:00
Improve /del
This commit is contained in:
parent
11da9c9ba2
commit
096d8fe1ff
@ -52,6 +52,7 @@ Command | Role | Available at | Description
|
||||
`/leave <name\|id>` | _Master_ | _Everywhere_ | Make the bot to leave the group cleanly.
|
||||
`/hidegroup` | _Master_ | _Groups_ | Revoke invite link and hide the group from `/groups` list.
|
||||
`/showgroup` | _Master_ | _Groups_ | Make the group accessible via `/groups` list.
|
||||
`/del [reason]` | _Admin_ | _Everywhere_ | Deletes replied-to message.
|
||||
`/warn <reason>` | _Admin_ | _Groups_ | Warns the user.
|
||||
`/unwarn` | _Admin_ | _Everywhere_ | Removes the last warn from the user.
|
||||
`/nowarns` | _Admin_ | _Everywhere_ | Clears warns for the user.
|
||||
|
@ -21,6 +21,7 @@ const masterCommands = `\
|
||||
|
||||
const adminCommands = `\
|
||||
<b>Admin commands</b>:
|
||||
<code>/del [reason]</code> - Deletes replied-to message.
|
||||
<code>/warn <reason></code> - Warns the user.
|
||||
<code>/unwarn</code> - Removes the last warn from the user.
|
||||
<code>/nowarns</code> - Clears warns for the user.
|
||||
|
@ -1,8 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
const { parse } = require('../../utils/parse');
|
||||
const html = require('tg-html');
|
||||
const R = require('ramda');
|
||||
|
||||
const { scheduleDeletion } = require('../../utils/tg');
|
||||
const { parse } = require('../../utils/parse');
|
||||
const { link, scheduleDeletion } = require('../../utils/tg');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (ctx.from.status !== 'admin') return;
|
||||
@ -21,6 +23,11 @@ module.exports = async (ctx) => {
|
||||
);
|
||||
|
||||
if (reason) {
|
||||
await ctx.reply(`🗑 ${reason}`);
|
||||
const emoji = link({
|
||||
id: R.path([ 'message', 'reply_to_message', 'from', 'id' ], ctx),
|
||||
first_name: '🗑',
|
||||
});
|
||||
await ctx.replyWithHTML(html`${emoji} ${reason}`)
|
||||
.then(scheduleDeletion());
|
||||
}
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
const millisecond = require('millisecond');
|
||||
const { telegram } = require('../bot');
|
||||
|
||||
const html = require('tg-html');
|
||||
const R = require('ramda');
|
||||
|
||||
const isCommand = R.pipe(
|
||||
@ -22,17 +23,17 @@ const msgLink = msg =>
|
||||
`https://t.me/c/${msg.chat.id.toString().slice(4)}/${msg.message_id}`;
|
||||
|
||||
const link = ({ id, first_name }) =>
|
||||
`<a href="tg://user?id=${id}">${escapeHtml(first_name)}</a>`;
|
||||
html`<a href="tg://user?id=${id}">${first_name}</a>`;
|
||||
|
||||
const quietLink = (user) =>
|
||||
user.username
|
||||
? `<a href="t.me/${user.username}">${escapeHtml(user.first_name)}</a>`
|
||||
? html`<a href="t.me/${user.username}">${user.first_name}</a>`
|
||||
: link(user);
|
||||
|
||||
const displayUser = user =>
|
||||
user.first_name
|
||||
? link(user)
|
||||
: `an user with id <code>${user.id}</code>`;
|
||||
: html`an user with id <code>${user.id}</code>`;
|
||||
|
||||
/**
|
||||
* @param {number} ms
|
||||
|
Loading…
x
Reference in New Issue
Block a user