(
client: TelegramClient,
chatId: any,
userId: number,
until: number = 0,
participant?: any
)
| 770 | const dialogMap = new Map<number, any>(); |
| 771 | |
| 772 | const collectDialogs = async (params: Record<string, any>) => { |
| 773 | const dialogs = await client.getDialogs(params); |
| 774 | for (const dialog of dialogs || []) { |
| 775 | if (dialog.isChannel || dialog.isGroup) { |
| 776 | dialogMap.set(Number(dialog.id), dialog); |
| 777 | } |
| 778 | } |
| 779 | }; |
| 780 | |
| 781 | await collectDialogs({}); |
| 782 | await collectDialogs({ folderId: 1 }); |
| 783 | |
| 784 | return Array.from(dialogMap.values()); |
| 785 | } |
| 786 | |
| 787 | /** |
| 788 | * teleproto Dialog.entity(Channel/Chat)自带 creator/adminRights, |
| 789 | * 比逐群 GetParticipant 更稳:无 RPC、无 accessHash 假阴性。 |
| 790 | */ |
| 791 | private static dialogHasManageRights(dialog: any): boolean { |
| 792 | const entity = dialog?.entity; |
| 793 | if (!entity) return false; |
| 794 | if (entity.creator) return true; |
| 795 | const rights = entity.adminRights; |
| 796 | if (!rights) return false; |
| 797 | return !!(rights.banUsers || rights.deleteMessages); |
| 798 | } |
| 799 | |
| 800 | static async getManagedGroups( |
| 801 | client: TelegramClient |
| 802 | ): Promise<ManagedGroup[]> { |
no test coverage detected