fix: bot switching

This commit is contained in:
Junyan Qin
2025-08-15 17:02:00 +08:00
parent bf2bc70794
commit 2b8eb5f01c
2 changed files with 11 additions and 5 deletions

View File

@@ -44,17 +44,23 @@ class BotService:
if not include_secret:
masked_columns = ['adapter_config']
return self.ap.persistence_mgr.serialize_model(persistence_bot.Bot, bot, masked_columns)
async def get_runtime_bot_info(self, bot_uuid: str, include_secret: bool = True) -> dict:
"""获取机器人运行时信息"""
persistence_bot = await self.get_bot(bot_uuid, include_secret)
if persistence_bot is None:
raise Exception('Bot not found')
adapter_runtime_values = {}
runtime_bot = await self.ap.platform_mgr.get_bot_by_uuid(bot_uuid)
if runtime_bot is not None:
adapter_runtime_values['bot_account_id'] = runtime_bot.adapter.bot_account_id
persistence_bot_data = self.ap.persistence_mgr.serialize_model(persistence_bot.Bot, bot, masked_columns)
persistence_bot['adapter_runtime_values'] = adapter_runtime_values
persistence_bot_data['adapter_runtime_values'] = adapter_runtime_values
return persistence_bot_data
return persistence_bot
async def create_bot(self, bot_data: dict) -> str:
"""创建机器人"""

View File

@@ -191,7 +191,7 @@ class RuntimeConnectionHandler(handler.Handler):
async def get_bot_info(data: dict[str, Any]) -> handler.ActionResponse:
"""Get bot info"""
bot_uuid = data['bot_uuid']
bot = await self.ap.bot_service.get_bot(bot_uuid, include_secret=False)
bot = await self.ap.bot_service.get_runtime_bot_info(bot_uuid, include_secret=False)
return handler.ActionResponse.success(
data={
'bot': bot,