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

Method handleAtAdmins

atadmins/atadmins.ts:115–218  ·  view source on GitHub ↗
(msg: Api.Message, args: string[])

Source from the content-addressed store, hash-verified

113 await msg.edit({ text: "❌ 客户端未初始化", parseMode: "html" });
114 return;
115 }
116
117 try {
118 // 检查是否在群组中
119 if (!msg.peerId || !(msg.peerId instanceof Api.PeerChannel || msg.peerId instanceof Api.PeerChat)) {
120 await msg.edit({
121 text: `❌ <b>此命令只能在群组中使用</b>\n\n💡 请在群组中使用 <code>${mainPrefix}atadmins</code> 命令`,
122 parseMode: "html"
123 });
124 return;
125 }
126
127 // 获取管理员列表
128 const participants = await client.getParticipants(msg.peerId, {
129 filter: new Api.ChannelParticipantsAdmins()
130 });
131
132 const admins: string[] = [];
133 let adminCount = 0;
134 let botCount = 0;
135
136 for (const user of participants) {
137 if (user && !user.deleted) {
138 if (user.bot) {
139 botCount++;
140 continue; // 跳过机器人
141 }
142
143 adminCount++;
144 if (user.username) {
145 admins.push(`@${user.username}`);
146 } else {
147 const firstName = user.firstName || "";
148 const lastName = user.lastName || "";
149 const fullName = `${firstName} ${lastName}`.trim() || "用户";
150 // HTML转义用户名
151 const escapedName = htmlEscape(fullName);
152 admins.push(`[${escapedName}](tg://user?id=${user.id})`);
153 }
154 }
155 }
156
157 if (admins.length === 0) {
158 await msg.edit({
159 text: `❌ <b>未找到可召唤的管理员</b>\n\n📊 统计信息:\n• 总管理员: ${adminCount}\n• 机器人管理员: ${botCount}\n• 可召唤: 0\n\n💡 可能原因:所有管理员都是机器人或已删除账户`,
160 parseMode: "html"
161 });
162 return;
163 }
164
165 // 获取自定义消息内容(HTML转义)
166 const customMessage = args.join(" ").trim();
167 const say = customMessage ? htmlEscape(customMessage) : "召唤本群所有管理员";
168
169 const header = `${say}:\n\n`;
170 const chunks = this.chunkMentions(admins, header);
171
172 // 逐条发送(显式使用 Markdown 解析 tg://user?id= 链接)

Callers 1

AtAdminsPluginClass · 0.95

Calls 7

chunkMentionsMethod · 0.95
warnMethod · 0.80
errorMethod · 0.80
htmlEscapeFunction · 0.70
scheduleTimerFunction · 0.70
editMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected