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