| 1242 | } |
| 1243 | lowdb = null; |
| 1244 | } |
| 1245 | |
| 1246 | description: string = `智能转发助手 - 自动转发消息到指定目标\n\n${help_text}`; |
| 1247 | cmdHandlers: Record<string, (msg: Api.Message) => Promise<void>> = { |
| 1248 | shift: async (msg) => { |
| 1249 | const client = await getGlobalClient(); |
| 1250 | if (!client) { |
| 1251 | await msg.edit({ |
| 1252 | text: "❌ <b>客户端未初始化</b>", |
| 1253 | parseMode: "html", |
| 1254 | }); |
| 1255 | return; |
| 1256 | } |
| 1257 | |
| 1258 | // 标准参数解析模式 |
| 1259 | const lines = msg.message?.trim()?.split(/\r?\n/g) || []; |
| 1260 | const parts = lines?.[0]?.split(/\s+/) || []; |
| 1261 | const [, ...args] = parts; // 跳过命令本身 |
| 1262 | const sub = (args[0] || "").toLowerCase(); |
| 1263 | |
| 1264 | // 无参数时显示帮助 |
| 1265 | if (!sub) { |
| 1266 | await msg.edit({ |
| 1267 | text: HELP_TEXT, |
| 1268 | parseMode: "html", |
| 1269 | linkPreview: false, |
| 1270 | }); |
| 1271 | return; |
| 1272 | } |
| 1273 | |
| 1274 | // 处理 help 命令 |
| 1275 | if (sub === "help" || sub === "h") { |
| 1276 | await msg.edit({ |
| 1277 | text: HELP_TEXT, |
| 1278 | parseMode: "html", |
| 1279 | linkPreview: false, |
| 1280 | }); |
| 1281 | return; |
| 1282 | } |
| 1283 | |
| 1284 | try { |
| 1285 | // Migrate command - 迁移到 lowdb |
| 1286 | if (sub === "migrate") { |
| 1287 | if (await migrateToLowdb()) { |
| 1288 | await msg.edit({ |
| 1289 | text: `✅ <b>成功迁移到 lowdb 数据库</b>\n\n性能提升,功能增强!`, |
| 1290 | parseMode: "html", |
| 1291 | }); |
| 1292 | } else { |
| 1293 | await msg.edit({ |
| 1294 | text: `❌ <b>迁移失败或无需迁移</b>`, |
| 1295 | parseMode: "html", |
| 1296 | }); |
| 1297 | } |
| 1298 | return; |
| 1299 | } |
| 1300 | |
| 1301 | // Export command - 导出规则 |
nothing calls this directly
no test coverage detected