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

Method unblockMember

clean/clean.ts:408–474  ·  view source on GitHub ↗
(client: any, msg: Api.Message, includeAll: boolean = false)

Source from the content-addressed store, hash-verified

406
407 // 群组解封
408 private async unblockMember(client: any, msg: Api.Message, includeAll: boolean = false): Promise<void> {
409 if (!msg.isChannel && !msg.isGroup) {
410 await this.sendError(msg, "此命令只能在群组中使用");
411 return;
412 }
413
414 await this.editMessage(msg, "🔓 正在获取被封禁实体列表...");
415
416 const me = await safeGetMe(client);
417 if (!me) {
418 await this.sendError(msg, "无法获取当前账号信息");
419 return;
420 }
421 const myId = Number(me.id);
422 const chatEntity = msg.peerId;
423
424 let bannedUsers = await getBannedUsers(client, chatEntity);
425 if (!includeAll) {
426 bannedUsers = bannedUsers.filter((u: any) => u.kickedBy === myId);
427 }
428
429 if (bannedUsers.length === 0) {
430 await this.editMessage(msg, "ℹ️ 没有找到需要解封的实体");
431 await sleep(3000);
432 await this.safeDelete(msg);
433 return;
434 }
435
436 await this.editMessage(msg, `⚡ 正在解封 ${bannedUsers.length} 个实体...`);
437
438 const entityStats = { users: 0, channels: 0, chats: 0 };
439 bannedUsers.forEach((entity: any) => {
440 if (entity.type === 'user') entityStats.users++;
441 else if (entity.type === 'channel') entityStats.channels++;
442 else if (entity.type === 'chat') entityStats.chats++;
443 });
444
445 let successCount = 0, failedCount = 0;
446 const failedEntities: string[] = [];
447
448 for (const entity of bannedUsers) {
449 const success = await unbanUser(client, chatEntity, entity.id);
450 if (success) {
451 successCount++;
452 } else {
453 failedCount++;
454 const displayName = entity.type === 'user'
455 ? `${entity.firstName}(${entity.id})`
456 : `${entity.title || entity.firstName}[${entity.type}](${entity.id})`;
457 failedEntities.push(displayName);
458 }
459 await sleep(500);
460 }
461
462 let statsText = "";
463 if (entityStats.users > 0) statsText += `👤 用户: ${entityStats.users} `;
464 if (entityStats.channels > 0) statsText += `📢 频道: ${entityStats.channels} `;
465 if (entityStats.chats > 0) statsText += `💬 群组: ${entityStats.chats}`;

Callers 1

handleBlockedCleanMethod · 0.95

Calls 4

sendErrorMethod · 0.95
editMessageMethod · 0.95
safeDeleteMethod · 0.95
sleepFunction · 0.70

Tested by

no test coverage detected