| 214 | await this.edit(msg, `❌ 格式错误:${PREFIX}checkin add [ID] [名称] [目标] [可选: data:xxx | text:xxx]`); |
| 215 | return; |
| 216 | } |
| 217 | |
| 218 | const matcher = this.parseButtonMatcher(args.slice(4)); |
| 219 | const chatId = String(msg.chatId || msg.peerId || ""); |
| 220 | |
| 221 | const client = await getGlobalClient(); |
| 222 | const prompt = await client.sendMessage(chatId, { |
| 223 | message: [ |
| 224 | `📝 请<b>回复此消息</b>,发送签到命令(支持空格和特殊字符)`, |
| 225 | ``, |
| 226 | `ID: ${this.escape(id)}`, |
| 227 | `名称: ${this.escape(name)}`, |
| 228 | `目标: ${this.escape(target)}`, |
| 229 | matcher.callbackData ? `回调: ${this.escape(matcher.callbackData)}` : "", |
| 230 | matcher.buttonText ? `按钮: ${this.escape(matcher.buttonText)}` : "", |
| 231 | ].filter(Boolean).join("\n"), |
| 232 | parseMode: "html", |
| 233 | linkPreview: false, |
| 234 | }); |
| 235 | |
| 236 | this.pendingAdds.set(chatId, { |
| 237 | promptMsgId: Number((prompt as any)?.id || 0), |
| 238 | id, |
| 239 | name, |
| 240 | target, |
| 241 | matcher, |
| 242 | }); |
| 243 | return; |
| 244 | } |
| 245 | |
| 246 | if (action === "del" || action === "delete") { |
| 247 | const id = args[1]; |
| 248 | if (!id) return void (await this.edit(msg, `❌ 请指定目标ID:${PREFIX}checkin del [ID]`)); |
| 249 | const n = conf.targets.length; |
| 250 | conf.targets = conf.targets.filter((t) => t.id !== id); |
| 251 | this.cfg.save({ targets: conf.targets }); |
| 252 | await this.edit(msg, conf.targets.length < n ? `✅ 已删除签到目标: ${id}` : `❌ 未找到目标: ${id}`); |
| 253 | return; |
| 254 | } |
| 255 | |
| 256 | if (action === "list") { |
| 257 | if (!conf.targets.length) return void (await this.edit(msg, "📝 当前没有配置签到目标")); |
| 258 | const enabled = conf.targets.filter((t) => t.enabled).length; |
| 259 | const lines = conf.targets |
| 260 | .map((t, i) => { |
| 261 | const m = t.callbackData ? `\n 回调: ${this.escape(t.callbackData)}` : t.buttonText ? `\n 按钮: ${this.escape(t.buttonText)}` : ""; |
| 262 | return `${t.enabled ? "🟢" : "🔴"} <b>${i + 1}. ${this.escape(t.name)}</b>\n ID: ${this.escape(t.id)}\n 目标: ${this.escape(t.target)}\n 命令: ${this.escape(t.command)}${m}`; |
| 263 | }) |
| 264 | .join("\n\n"); |
| 265 | await this.edit(msg, `📝 <b>签到目标列表</b> (${enabled}/${conf.targets.length} 个启用)\n\n${lines}`); |
| 266 | return; |
| 267 | } |
| 268 | |
| 269 | if (action === "toggle") { |
| 270 | const id = args[1]; |
| 271 | if (!id) return void (await this.edit(msg, `❌ 请指定目标ID:${PREFIX}checkin toggle [ID]`)); |
| 272 | const t = conf.targets.find((x) => x.id === id); |
| 273 | if (!t) return void (await this.edit(msg, `❌ 未找到目标: ${id}`)); |