(msg: Api.Message, args: string[])
| 900 | } catch { |
| 901 | peer = "me"; |
| 902 | } |
| 903 | } |
| 904 | |
| 905 | // 发送导出文件 |
| 906 | await client.sendFile(peer, { |
| 907 | file: new CustomFile( |
| 908 | "ssh_keys_export.zip", |
| 909 | fs.statSync(archivePath).size, |
| 910 | "", |
| 911 | fs.readFileSync(archivePath) |
| 912 | ), |
| 913 | caption: `📦 <b>SSH密钥导出包</b>\n\n🖥️ 服务器: ${hostname}\n📊 密钥数量: ${lines.length}\n📅 导出时间: ${dayjs().format("YYYY-MM-DD HH:mm:ss")}\n\n📁 <b>包含文件:</b>\n• authorized_keys_export.txt (带注释说明)\n• authorized_keys (纯密钥文件)\n\n⚠️ <b>安全提示:</b> 请妥善保管密钥文件`, |
| 914 | parseMode: "html" |
| 915 | }); |
| 916 | |
| 917 | await msg.edit({ |
| 918 | text: `✅ <b>密钥导出成功</b>\n\n📊 导出密钥数量: ${lines.length}\n📁 文件已发送到: ${targetChat === "me" ? "收藏夹" : htmlEscape(targetChat)}\n\n💡 <b>文件说明:</b>\n• 带注释的完整导出文件\n• 纯净的authorized_keys文件\n• 可直接用于其他服务器配置`, |
| 919 | parseMode: "html" |
| 920 | }); |
| 921 | |
| 922 | // 清理临时文件 |
| 923 | fs.rmSync(workDir, { recursive: true, force: true }); |
| 924 | |
| 925 | } catch (error: any) { |
| 926 | throw new Error(`导出授权密钥失败: ${error.message}`); |
| 927 | } |
| 928 | } |
| 929 | |
| 930 | // 修改root密码 |
| 931 | private async changePassword(msg: Api.Message, args: string[]): Promise<void> { |
| 932 | const newPassword = args.join(" ").trim(); |
| 933 | |
| 934 | if (!newPassword) { |
| 935 | await msg.edit({ |
| 936 | text: `❌ <b>请提供新密码</b>\n\n示例: <code>${mainPrefix}ssh passwd 新密码123</code>`, |
| 937 | parseMode: "html" |
| 938 | }); |
| 939 | return; |
| 940 | } |
no test coverage detected