mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 04:52:50 +08:00
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:
1 parent
bc9b2366d0
commit
067a30233f
3 files changed
+250
-6
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user