(msg: Api.Message, args: string[])
| 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= 链接) |
no test coverage detected