(msg: Api.Message)
| 456 | await msg.edit({ |
| 457 | text: "⏳ <b>依赖已在安装中...</b>", |
| 458 | parseMode: "html", |
| 459 | }); |
| 460 | else { |
| 461 | await msg.edit({ |
| 462 | text: "首次运行,正在自动安装依赖...", |
| 463 | parseMode: "html", |
| 464 | }); |
| 465 | installDependencies(msg); |
| 466 | } |
| 467 | return; |
| 468 | } |
| 469 | |
| 470 | const args = msg.message.slice(2).split(" ").slice(1); |
| 471 | const chatId = Number(msg.peerId?.toString()); |
| 472 | const allServers: ServerConfig[] = db.prepare("SELECT * FROM servers ORDER BY id").all(); |
| 473 | |
| 474 | try { |
| 475 | const command = args[0] || ""; |
| 476 | |
| 477 | // --- New: Timeout configuration --- |
| 478 | if (command === "timeout") { |
| 479 | if (args[1]) { |
| 480 | const newTimeout = parseInt(args[1]); |
| 481 | if (isNaN(newTimeout) || newTimeout < 10 || newTimeout > 600) { |
| 482 | await msg.edit({ |
| 483 | text: "❌ <b>无效的超时时间</b>\n\n请输入10到600之间的秒数。", |
| 484 | parseMode: "html", |
| 485 | }); |
| 486 | return; |
| 487 | } |
| 488 | DEFAULT_TIMEOUT = newTimeout * 1000; |
| 489 | saveConfig({ ...loadConfig(), timeout: DEFAULT_TIMEOUT }); |
| 490 | await msg.edit({ |
| 491 | text: `✅ <b>超时时间已设置</b>\n\n新的超时时间: <code>${newTimeout}</code> 秒`, |
| 492 | parseMode: "html", |
| 493 | }); |
| 494 | } else { |
| 495 | const currentTimeout = DEFAULT_TIMEOUT / 1000; |
| 496 | await msg.edit({ |
| 497 | text: `ℹ️ <b>当前超时设置</b>\n\n超时时间: <code>${currentTimeout}</code> 秒\n\n使用 <code>sl timeout <秒数></code> 来修改`, |
| 498 | parseMode: "html", |
| 499 | }); |
| 500 | } |
| 501 | return; |
| 502 | } |
| 503 | |
| 504 | // --- Server management commands --- |
| 505 | if (command === "add" || command === "list" || command === "del" || command === "backup" || command === "restore" || command === "rename") { |
| 506 | if (command === "add") { |
| 507 | const [name, connection, authMethod, ...creds] = args.slice(1); |
| 508 | const credential = creds.join(" "); |
| 509 | if (!name || !connection || !authMethod || !credential || !["password", "key"].includes(authMethod)) { |
| 510 | await msg.edit({ |
| 511 | text: `❌ <b>参数错误</b>\n\n${HELP_TEXT}`, |
| 512 | parseMode: "html", |
| 513 | }); |
| 514 | return; |
| 515 | } |
nothing calls this directly
no test coverage detected