(
stat: AdminStat,
index: number,
total: number,
options?: {
commentText?: string;
commentPrefix?: string;
rankLabel?: string;
},
)
| 834 | const identityParts: string[] = []; |
| 835 | if (stat.adminRankText !== "无") { |
| 836 | identityParts.push(`<code>${htmlEscape(stat.adminRankText)}</code>`); |
| 837 | } |
| 838 | |
| 839 | const displayName = stat.name.trim(); |
| 840 | const usernameText = stat.username || ""; |
| 841 | if ( |
| 842 | displayName && |
| 843 | displayName !== stat.userId && |
| 844 | displayName !== usernameText |
| 845 | ) { |
| 846 | identityParts.push(htmlEscape(displayName)); |
| 847 | } |
| 848 | if (stat.username) { |
| 849 | identityParts.push(`<code>${htmlEscape(stat.username)}</code>`); |
| 850 | } |
| 851 | identityParts.push(`<code>${stat.userId}</code>`); |
| 852 | |
| 853 | const tailParts = [`<code>${htmlEscape(stat.avgPerDayText)}</code>`]; |
| 854 | if (stat.lockedSeat) { |
| 855 | tailParts.push("🔒"); |
| 856 | } |
| 857 | |
| 858 | const commentText = htmlEscape( |
| 859 | options?.commentText || buildSortComment(stat, index, total), |
| 860 | ); |
| 861 | const commentPrefix = options?.commentPrefix |
| 862 | ? `${htmlEscape(options.commentPrefix)}:` |
| 863 | : ""; |
| 864 | const rankLabel = options?.rankLabel || getRankDisplay(index); |
| 865 | return `${rankLabel} ${identityParts.join(" ")} | ${tailParts.join( |
| 866 | " | ", |
| 867 | )}\n └ <i>${commentPrefix}${commentText}</i>\n`; |
| 868 | } |
| 869 | |
| 870 | async function collectAdminStats( |
| 871 | msg: Api.Message, |
| 872 | target: TargetChat, |
| 873 | ): Promise<AdminStatsResult> { |
| 874 | await msg.edit({ |
| 875 | text: `🔍 正在获取 <b>${htmlEscape(target.titleDisplay)}</b> 的管理员列表...`, |
| 876 | parseMode: "html", |
| 877 | linkPreview: false, |
| 878 | }); |
| 879 | |
| 880 | const adminCollection = await getAdminCollection(target); |
| 881 | if (adminCollection.nonBotCount === 0) { |
| 882 | throw new Error("当前对话没有可统计的非 Bot 管理员,或无法获取管理员列表"); |
| 883 | } |
no test coverage detected