feat: 机器人管理 — 删除、编辑配置、完整创建表单

- PUT /api/bot/:id 更新机器人配置(保存到数据库,重启生效)
- GET /api/bot/:id/config 获取保存的配置
- BotManager.updateBot/getBotConfig 方法
- Settings 页面:删除按钮(带确认)、编辑弹窗(修改所有字段)
- 创建表单:完整字段(名称、地址、端口、昵称、默认频道)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
saopig1andClaude Opus 4.6 committed 2026-03-30 20:50:49 +08:00
1 parent bc9b2366d0
commit 067a30233f
3 files changed
+250 -6

No files matched your search

+21
View File
@@ -93,6 +93,27 @@ export class BotManager {
this.logger.info({ botId: id }, "Bot instance removed");
}
updateBot(id: string, params: Partial<CreateBotParams>): void {
const instances = this.database.getBotInstances();
const existing = instances.find((i) => i.id === id);
if (!existing) throw new Error(`Bot ${id} not found`);
this.database.saveBotInstance({
...existing,
name: params.name ?? existing.name,
serverAddress: params.serverAddress ?? existing.serverAddress,
serverPort: params.serverPort ?? existing.serverPort,
nickname: params.nickname ?? existing.nickname,
defaultChannel: params.defaultChannel ?? existing.defaultChannel,
channelPassword: params.channelPassword ?? existing.channelPassword,
});
this.logger.info({ botId: id }, "Bot instance config updated (restart to apply)");
}
getBotConfig(id: string): import("../data/database.js").BotInstance | undefined {
return this.database.getBotInstances().find((i) => i.id === id);
}
getBot(id: string): BotInstance | undefined {
return this.bots.get(id);
}