(client: any, msg: Api.Message, includeAll: boolean = false)
| 406 | if (error.message?.includes('FLOOD_WAIT_')) { |
| 407 | await this.handleFloodWait(msg, error); |
| 408 | continue; |
| 409 | } else { |
| 410 | failed++; |
| 411 | consecutiveErrors++; |
| 412 | await sleep(this.getDynamicDelay(user, includeAll, consecutiveErrors)); |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | // 更新进度 |
| 417 | if (processedUsers % 10 === 0) { |
| 418 | await this.updateBlockedProgress(msg, processedUsers, totalUsers, success, failed, skipped, includeAll); |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | offset += 100; |
| 423 | if (blocked.className === 'contacts.BlockedSlice' && offset >= (blocked as any).count) break; |
| 424 | |
| 425 | // 批次间延迟 |
| 426 | const batchDelay = consecutiveErrors > 0 ? 3000 + (consecutiveErrors * 1000) : 2000; |
| 427 | await sleep(Math.min(batchDelay, 10000)); |
| 428 | |
| 429 | } catch (error: any) { |
| 430 | console.error("获取拉黑列表失败:", error); |
| 431 | if (error.message?.includes('FLOOD_WAIT')) { |
| 432 | await this.handleFloodWait(msg, error); |
| 433 | continue; |
| 434 | } |
| 435 | break; |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | const result = this.buildBlockedResult(success, failed, skipped, totalUsers, includeAll); |
| 440 | await this.editMessage(msg, result); |
| 441 | } |
| 442 | |
| 443 | // 群组解封 |
| 444 | private async unblockMember(client: any, msg: Api.Message, includeAll: boolean = false): Promise<void> { |
| 445 | if (!msg.isChannel && !msg.isGroup) { |
| 446 | await this.sendError(msg, "此命令只能在群组中使用"); |
| 447 | return; |
| 448 | } |
| 449 | |
| 450 | await this.editMessage(msg, "🔓 正在获取被封禁实体列表..."); |
| 451 | |
| 452 | const me = await safeGetMe(client); |
| 453 | if (!me) { |
| 454 | await this.sendError(msg, "无法获取当前账号信息"); |
| 455 | return; |
| 456 | } |
| 457 | const myId = Number(me.id); |
| 458 | const chatEntity = msg.peerId; |
| 459 | |
| 460 | let bannedUsers = await getBannedUsers(client, chatEntity); |
| 461 | if (!includeAll) { |
| 462 | bannedUsers = bannedUsers.filter((u: any) => u.kickedBy === myId); |
| 463 | } |
| 464 | |
| 465 | if (bannedUsers.length === 0) { |
no test coverage detected