MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / collectAdminStats

Function collectAdminStats

admin_board/admin_board.ts:882–923  ·  view source on GitHub ↗
(
  msg: Api.Message,
  target: TargetChat,
)

Source from the content-addressed store, hash-verified

880 const adminCollection = await getAdminCollection(target);
881 if (adminCollection.nonBotCount === 0) {
882 throw new Error("当前对话没有可统计的非 Bot 管理员,或无法获取管理员列表");
883 }
884
885 const lockedSeatSet = await getLockedSeatSet(target);
886 const stats: AdminStat[] = [];
887 const admins = adminCollection.visibleAdmins;
888
889 for (let index = 0; index < admins.length; index++) {
890 if (index === 0 || (index + 1) % 5 === 0 || index === admins.length - 1) {
891 await msg.edit({
892 text: `📊 正在统计管理员排序简表...\n目标: <b>${htmlEscape(
893 target.titleDisplay,
894 )}</b>\n进度: <code>${index + 1}/${admins.length}</code>`,
895 parseMode: "html",
896 linkPreview: false,
897 });
898 }
899
900 stats.push(await collectAdminStat(target, admins[index], lockedSeatSet));
901 }
902
903 return {
904 stats: sortAdminStats(stats),
905 counts: {
906 totalCount: adminCollection.totalCount,
907 botCount: adminCollection.botCount,
908 nonBotCount: adminCollection.nonBotCount,
909 },
910 };
911}
912
913function buildSortText(
914 target: TargetChat,
915 stats: AdminStat[],
916 counts: { totalCount: number; botCount: number; nonBotCount: number },
917): string {
918 const headerLines = [
919 `📊 <b>管理员排序简表</b>`,
920 buildTargetDisplay(target),
921 `管理员数量: 总 <code>${counts.totalCount}</code> | Bot <code>${counts.botCount}</code> | 非 Bot <code>${counts.nonBotCount}</code>`,
922 `排序: <code>周日均消息数 ↓</code>`,
923 "",
924 ];
925
926 const bodyLines: string[] = [];

Callers 2

handleTrimActionFunction · 0.85
AdminBoardPluginClass · 0.85

Calls 6

getAdminCollectionFunction · 0.85
getLockedSeatSetFunction · 0.85
collectAdminStatFunction · 0.85
sortAdminStatsFunction · 0.85
htmlEscapeFunction · 0.70
editMethod · 0.45

Tested by

no test coverage detected