mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-29 05:07:49 +00:00
feat: noReportChatDeletion
This commit is contained in:
parent
4d8ed6cf42
commit
efcd382f1c
@ -21,7 +21,7 @@
|
|||||||
"prettier"
|
"prettier"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/ban-ts-ignore": "warn",
|
"@typescript-eslint/ban-ts-comment": "warn",
|
||||||
"@typescript-eslint/camelcase": "off",
|
"@typescript-eslint/camelcase": "off",
|
||||||
"@typescript-eslint/explicit-function-return-type": "off",
|
"@typescript-eslint/explicit-function-return-type": "off",
|
||||||
"@typescript-eslint/no-floating-promises": "error",
|
"@typescript-eslint/no-floating-promises": "error",
|
||||||
|
@ -42,10 +42,11 @@ const config = {
|
|||||||
|
|
||||||
|
|
||||||
chats: {
|
chats: {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {(number | false)}
|
* @type {(number | false)}
|
||||||
* Chat to send member (un)ban/(un)warn/report notifications and relevant messages to.
|
* Chat to send member (un)ban/(un)warn/report notifications and
|
||||||
* Pass false to disable this feature.
|
* relevant messages to. Pass false to disable this feature.
|
||||||
*/
|
*/
|
||||||
adminLog: false,
|
adminLog: false,
|
||||||
|
|
||||||
@ -62,6 +63,13 @@ const config = {
|
|||||||
* Pass false to disable this feature.
|
* Pass false to disable this feature.
|
||||||
*/
|
*/
|
||||||
report: false,
|
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: {
|
deleteCustom: {
|
||||||
longerThan: 450, // UTF-16 characters
|
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";
|
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") {
|
if (ctx.from?.status !== "admin") {
|
||||||
return ctx.answerCbQuery("✋ Not permitted!", { cache_time: 600 });
|
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([
|
return Promise.all([
|
||||||
// delete the report in the report chat
|
// delete the report in the report chat
|
||||||
ctx.deleteMessage(),
|
ctx.deleteMessage(),
|
||||||
// delete the forwarded contextual message in report chat
|
// delete the forwarded contextual message in report chat
|
||||||
ctx.deleteMessage(ctx.callbackQuery.message?.reply_to_message?.message_id),
|
ctx.deleteMessage(
|
||||||
// delete the report in the actual chat
|
(ctx.callbackQuery.message as Message.TextMessage)?.reply_to_message
|
||||||
ctx.telegram.deleteMessage(+chatId, +msgId),
|
?.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.
|
* Pass false to disable this feature.
|
||||||
*/
|
*/
|
||||||
report?: number | false;
|
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