(
client: TelegramClient,
chatId: any,
resolvedParticipant: any,
bannedRights: Api.ChatBannedRights,
action: 'ban' | 'unban' | 'mute'
)
| 739 | return false; |
| 740 | } |
| 741 | |
| 742 | const meParticipant = participants.find((p: any) => Number(p?.userId) === Number((me as any).id)); |
| 743 | return meParticipant instanceof Api.ChatParticipantCreator || meParticipant instanceof Api.ChatParticipantAdmin; |
| 744 | } |
| 745 | |
| 746 | const participant = await client.invoke( |
| 747 | new Api.channels.GetParticipant({ |
| 748 | channel: chatId, |
| 749 | participant: me.id |
| 750 | }) |
| 751 | ); |
| 752 | |
| 753 | const p = participant.participant; |
| 754 | if (p instanceof Api.ChannelParticipantCreator) return true; |
| 755 | if (p instanceof Api.ChannelParticipantAdmin) { |
| 756 | return !!p.adminRights?.deleteMessages; |
| 757 | } |
| 758 | return false; |
| 759 | } catch { |
| 760 | return false; |
| 761 | } |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | // ==================== 群组管理器 ==================== |
| 766 | class GroupManager { |
| 767 | private static cache = CacheManager.getInstance(); |
| 768 | |
| 769 | private static async getAllManageableDialogs(client: TelegramClient): Promise<any[]> { |
| 770 | const dialogMap = new Map<number, any>(); |
| 771 | |
| 772 | const collectDialogs = async (params: Record<string, any>) => { |
| 773 | const dialogs = await client.getDialogs(params); |
no test coverage detected