(
target: TargetChat,
stats: AdminStat[],
counts: { totalCount: number; botCount: number; nonBotCount: number },
limit: number,
)
| 946 | `📉 <b>未锁席位倒数榜</b>`, |
| 947 | buildTargetDisplay(target), |
| 948 | `管理员数量: 总 <code>${counts.totalCount}</code> | Bot <code>${counts.botCount}</code> | 非 Bot <code>${counts.nonBotCount}</code>`, |
| 949 | `未锁席位: <code>${unlockedStats.length}</code> | 展示: <code>${visibleStats.length}</code> | 倒数范围: <code>${limit}</code>`, |
| 950 | `排序: <code>未锁席位的周日均消息数倒数 ${limit} 人</code>`, |
| 951 | "", |
| 952 | ]; |
| 953 | |
| 954 | if (unlockedStats.length === 0) { |
| 955 | return [...headerLines, `暂无未锁定席位的管理员。`].join("\n").trim(); |
| 956 | } |
| 957 | |
| 958 | const bodyLines: string[] = []; |
| 959 | for (const stat of visibleStats) { |
| 960 | const originalIndex = unlockedStats.findIndex( |
| 961 | (candidate) => candidate.userId === stat.userId, |
| 962 | ); |
| 963 | bodyLines.push( |
| 964 | buildCompactSortLine( |
| 965 | stat, |
| 966 | originalIndex >= 0 ? originalIndex : 0, |
| 967 | unlockedStats.length, |
| 968 | { |
| 969 | commentText: buildTailComment( |
| 970 | stat, |
| 971 | originalIndex >= 0 ? originalIndex : 0, |
| 972 | unlockedStats.length, |
| 973 | ), |
| 974 | }, |
| 975 | ), |
| 976 | ); |
| 977 | } |
| 978 | |
| 979 | return [...headerLines, ...bodyLines].join("\n").trim(); |
| 980 | } |
| 981 | |
| 982 | function parseTailArgs(remainder: string): { |
| 983 | limit: number; |
| 984 | targetArg?: string; |
| 985 | } { |
| 986 | const trimmed = remainder.trim(); |
| 987 | if (!trimmed) { |
| 988 | return { limit: 10 }; |
| 989 | } |
| 990 | |
| 991 | const tokens = trimmed.split(/\s+/).filter(Boolean); |
| 992 | const firstToken = tokens[0] || ""; |
| 993 | |
| 994 | if (/^[1-9]\d*$/.test(firstToken)) { |
| 995 | const limit = Number(firstToken); |
no test coverage detected