mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-22 01:49:29 +00:00
feat: noReportChatDeletion
This commit is contained in:
parent
4d8ed6cf42
commit
efcd382f1c
@ -21,7 +21,7 @@
|
||||
"prettier"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/ban-ts-ignore": "warn",
|
||||
"@typescript-eslint/ban-ts-comment": "warn",
|
||||
"@typescript-eslint/camelcase": "off",
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/no-floating-promises": "error",
|
||||
|
@ -42,10 +42,11 @@ const config = {
|
||||
|
||||
|
||||
chats: {
|
||||
|
||||
/**
|
||||
* @type {(number | false)}
|
||||
* Chat to send member (un)ban/(un)warn/report notifications and relevant messages to.
|
||||
* Pass false to disable this feature.
|
||||
* Chat to send member (un)ban/(un)warn/report notifications and
|
||||
* relevant messages to. Pass false to disable this feature.
|
||||
*/
|
||||
adminLog: false,
|
||||
|
||||
@ -62,6 +63,13 @@ const config = {
|
||||
* Pass false to disable this feature.
|
||||
*/
|
||||
report: false,
|
||||
|
||||
/**
|
||||
* @type {(true | false)}
|
||||
* Disable whether clicking on `[Report handled]` deletes the
|
||||
* report chat message.
|
||||
*/
|
||||
noReportChatDeletion: false,
|
||||
},
|
||||
|
||||
/**
|
||||
@ -73,7 +81,7 @@ const config = {
|
||||
|
||||
deleteCustom: {
|
||||
longerThan: 450, // UTF-16 characters
|
||||
after: '20 minutes'
|
||||
after: '20 minutes',
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1,19 +1,28 @@
|
||||
import { CallbackQuery, Update } from "telegraf/types";
|
||||
import { CallbackQuery, Message, Update } from "telegraf/types";
|
||||
import { config } from "../../utils/config";
|
||||
import type { ExtendedContext } from "../../typings/context";
|
||||
|
||||
export = (ctx: ExtendedContext<Update.CallbackQueryUpdate<CallbackQuery.DataQuery>>) => {
|
||||
export = async (
|
||||
ctx: ExtendedContext<Update.CallbackQueryUpdate<CallbackQuery.DataQuery>>,
|
||||
) => {
|
||||
if (ctx.from?.status !== "admin") {
|
||||
return ctx.answerCbQuery("✋ Not permitted!", { cache_time: 600 });
|
||||
}
|
||||
|
||||
const [, chatId, msgId] = ctx.match!;
|
||||
// @ts-expect-error ctx.match is available but not registered in this callback type
|
||||
const [, chatId, msgId] = (ctx.match as string[])!;
|
||||
|
||||
// delete the report in the actual chat
|
||||
await ctx.telegram.deleteMessage(+chatId, +msgId);
|
||||
|
||||
if (config.chats?.noReportChatDeletion) return null;
|
||||
return Promise.all([
|
||||
// delete the report in the report chat
|
||||
ctx.deleteMessage(),
|
||||
// delete the forwarded contextual message in report chat
|
||||
ctx.deleteMessage(ctx.callbackQuery.message?.reply_to_message?.message_id),
|
||||
// delete the report in the actual chat
|
||||
ctx.telegram.deleteMessage(+chatId, +msgId),
|
||||
ctx.deleteMessage(
|
||||
(ctx.callbackQuery.message as Message.TextMessage)?.reply_to_message
|
||||
?.message_id,
|
||||
),
|
||||
]);
|
||||
};
|
||||
|
6
typings/config.d.ts
vendored
6
typings/config.d.ts
vendored
@ -38,6 +38,12 @@ export interface Config {
|
||||
* Pass false to disable this feature.
|
||||
*/
|
||||
report?: number | false;
|
||||
|
||||
/**
|
||||
* Disable whether clicking on `[Report handled]` deletes the
|
||||
* report chat message.
|
||||
*/
|
||||
noReportChatDeletion: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user