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

Function deleteInSavedMessages

dme/dme.ts:611–651  ·  view source on GitHub ↗

* 收藏夹直接按数量删除(不做媒体编辑)

(
  client: TelegramClient,
  chatEntity: any,
  userRequestedCount: number
)

Source from the content-addressed store, hash-verified

609 const targetCount =
610 userRequestedCount === CONFIG.UNLIMITED_REQUEST_COUNT ? Infinity : userRequestedCount;
611 let offsetId = 0;
612 let collected = 0;
613 let deleted = 0;
614 const batchLimit = 100;
615
616 while (collected < targetCount) {
617 const limit =
618 targetCount === Infinity ? batchLimit : Math.min(batchLimit, targetCount - collected);
619 const history = await client.invoke(
620 new Api.messages.GetHistory({
621 peer: chatEntity,
622 offsetId,
623 offsetDate: 0,
624 addOffset: 0,
625 limit,
626 maxId: 0,
627 minId: 0,
628 hash: 0 as any,
629 })
630 );
631 const msgs: any[] = (history as any).messages || [];
632 const justMsgs = msgs.filter((m: any) => m.className === "Message");
633 if (justMsgs.length === 0) break;
634
635 offsetId = justMsgs[justMsgs.length - 1].id;
636 const ids = justMsgs.map((m: any) => m.id);
637 const result = await deleteMessagesUniversal(client, chatEntity, ids);
638 deleted += result;
639 collected += ids.length;
640 await sleep(CONFIG.DELAYS.BATCH);
641 }
642
643 return { processedCount: deleted, actualCount: collected, editedCount: 0 };
644}
645
646/**
647 * 检测群组是否禁止转发和复制(受限群组)
648 */
649async function isRestrictedGroup(client: TelegramClient, chatEntity: any): Promise<boolean> {
650 try {
651 // 获取聊天信息以检查限制
652 if (chatEntity.className === "Channel") {
653 // 对于频道/超级群,检查noforwards属性
654 return (chatEntity as any).noforwards === true;

Callers 1

Calls 2

deleteMessagesUniversalFunction · 0.85
sleepFunction · 0.70

Tested by

no test coverage detected