(uid: number, userObj?: any)
| 620 | } else if (userObj.firstName) { |
| 621 | displayName = userObj.firstName; |
| 622 | } else if (userObj.lastName) { |
| 623 | displayName = userObj.lastName; |
| 624 | } |
| 625 | |
| 626 | if (userObj.username) { |
| 627 | username = `@${userObj.username}`; |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | if (displayName && username) { |
| 632 | return `• <a href="tg://user?id=${uid}">${htmlEscape(displayName)} ${htmlEscape(username)}</a>`; |
| 633 | } else if (displayName) { |
| 634 | return `• <a href="tg://user?id=${uid}">${htmlEscape(displayName)}</a>`; |
| 635 | } else if (username) { |
| 636 | return `• <a href="tg://user?id=${uid}">${htmlEscape(username)}</a>`; |
| 637 | } |
| 638 | |
| 639 | return `• <a href="tg://user?id=${uid}">${uid}</a>`; |
| 640 | } |
| 641 | |
| 642 | async function isUserAdmin(client: TelegramClient, chatId: string, userId: string): Promise<boolean> { |
| 643 | try { |
| 644 | const chatEntity = await client.getEntity(chatId); |
| 645 | |
| 646 | // 检查是否为超级群或频道 |
| 647 | if (chatEntity.className === 'Channel' || (chatEntity as any).megagroup) { |
| 648 | try { |
| 649 | const participant = await client.invoke( |
| 650 | new Api.channels.GetParticipant({ |
| 651 | channel: chatEntity, |
| 652 | participant: userId, |
nothing calls this directly
no test coverage detected