| 135 | } |
| 136 | |
| 137 | // 标准参数解析模式 |
| 138 | const lines = msg.text?.trim()?.split(/\r?\n/g) || []; |
| 139 | const parts = lines?.[0]?.split(/\s+/) || []; |
| 140 | const [, ...args] = parts; // 跳过命令本身 |
| 141 | const sub = (args[0] || "").toLowerCase(); |
| 142 | |
| 143 | try { |
| 144 | // 无参数时显示帮助 |
| 145 | if (!sub) { |
| 146 | await msg.edit({ text: help_text, parseMode: "html" }); |
| 147 | return; |
| 148 | } |
| 149 | |
| 150 | // 处理 help 在前的情况:.fadian help [subcommand] |
| 151 | if (sub === "help" || sub === "h") { |
| 152 | if (args[1]) { |
| 153 | // 显示特定子命令的帮助 |
| 154 | const subCmd = args[1].toLowerCase(); |
| 155 | await this.showSubCommandHelp(subCmd, msg); |
| 156 | } else { |
| 157 | // 显示总帮助 |
| 158 | await msg.edit({ text: help_text, parseMode: "html" }); |
| 159 | } |
| 160 | return; |
| 161 | } |
| 162 | |
| 163 | // 处理 help 在后的情况:.fadian [subcommand] help |
| 164 | if ( |
| 165 | args[1] && |
| 166 | (args[1].toLowerCase() === "help" || args[1].toLowerCase() === "h") |
| 167 | ) { |
| 168 | await this.showSubCommandHelp(sub, msg); |
| 169 | return; |
| 170 | } |
| 171 | |
| 172 | // 处理 clear 命令 |
| 173 | if (sub === "clear") { |
| 174 | await this.clearCache(msg); |
| 175 | return; |
| 176 | } |
| 177 | |
| 178 | // 处理具体的子命令 |
| 179 | switch (sub) { |
| 180 | case "fd": { |
| 181 | let targetName = (args.slice(1).join(" ") || lines[1] || "").trim(); |
| 182 | |
| 183 | // 如果没有提供名字,尝试从回复消息获取 |
| 184 | if (!targetName) { |
| 185 | const replyMsg = await safeGetReplyMessage(msg); |
| 186 | if (replyMsg) { |
| 187 | const sender = (await replyMsg.sender) as any; |
| 188 | if (sender) { |
| 189 | const firstName = sender.firstName || ""; |
| 190 | const lastName = sender.lastName || ""; |
| 191 | const username = sender.username || ""; |
| 192 | const title = sender.title || ""; |
| 193 | |
| 194 | // 优先使用 firstName + lastName,其次使用 title, 最后 username |
nothing calls this directly
no test coverage detected