MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / fastDeleteBatch

Function fastDeleteBatch

da/da.ts:245–283  ·  view source on GitHub ↗
(
  client: TelegramClient,
  chatId: bigInt.BigInteger,
  messages: Api.Message[],
  task: DeleteTask
)

Source from the content-addressed store, hash-verified

243 chatId: bigInt.BigInteger,
244 messages: Api.Message[],
245 task: DeleteTask
246): Promise<boolean> => {
247 try {
248 // 直接批量删除,不等待
249 await client.deleteMessages(
250 chatId,
251 messages.map((m) => m.id),
252 { revoke: true }
253 );
254
255 task.deletedMessages += messages.length;
256 await saveTask(task);
257 return true;
258
259 } catch (error: any) {
260 // FLOOD_WAIT处理
261 if (error.message?.includes("FLOOD_WAIT")) {
262 const waitTime = parseInt(error.message.match(/\d+/)?.[0] || "30") * 1000;
263 await sleep(waitTime);
264 return fastDeleteBatch(client, chatId, messages, task); // 重试
265 }
266
267 // 批量失败,逐个删除
268 for (const message of messages) {
269 try {
270 await client.deleteMessages(chatId, [message.id], { revoke: true });
271 task.deletedMessages++;
272 await sleep(50);
273 } catch {}
274 }
275
276 await saveTask(task);
277 return false;
278 }
279};
280
281// 主删除命令
282const da = async (msg: Api.Message) => {
283 // 标准参数解析模式(参考 music.ts)
284 const lines = msg.text?.trim()?.split(/\r?\n/g) || [];
285 const parts = lines?.[0]?.split(/\s+/) || [];
286 const [, ...args] = parts; // 跳过命令本身

Callers 1

daFunction · 0.85

Calls 2

saveTaskFunction · 0.85
sleepFunction · 0.70

Tested by

no test coverage detected