mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-18 19:44:21 +00:00
fix: bot switching
This commit is contained in:
@@ -44,17 +44,23 @@ class BotService:
|
|||||||
if not include_secret:
|
if not include_secret:
|
||||||
masked_columns = ['adapter_config']
|
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 = {}
|
adapter_runtime_values = {}
|
||||||
|
|
||||||
runtime_bot = await self.ap.platform_mgr.get_bot_by_uuid(bot_uuid)
|
runtime_bot = await self.ap.platform_mgr.get_bot_by_uuid(bot_uuid)
|
||||||
if runtime_bot is not None:
|
if runtime_bot is not None:
|
||||||
adapter_runtime_values['bot_account_id'] = runtime_bot.adapter.bot_account_id
|
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
|
||||||
|
|
||||||
return persistence_bot_data
|
|
||||||
|
|
||||||
async def create_bot(self, bot_data: dict) -> str:
|
async def create_bot(self, bot_data: dict) -> str:
|
||||||
"""创建机器人"""
|
"""创建机器人"""
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ class RuntimeConnectionHandler(handler.Handler):
|
|||||||
async def get_bot_info(data: dict[str, Any]) -> handler.ActionResponse:
|
async def get_bot_info(data: dict[str, Any]) -> handler.ActionResponse:
|
||||||
"""Get bot info"""
|
"""Get bot info"""
|
||||||
bot_uuid = data['bot_uuid']
|
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(
|
return handler.ActionResponse.success(
|
||||||
data={
|
data={
|
||||||
'bot': bot,
|
'bot': bot,
|
||||||
|
|||||||
Reference in New Issue
Block a user