feat: get_bot_info api

This commit is contained in:
Junyan Qin
2025-08-13 20:54:43 +08:00
parent 621f1301b3
commit 39c50d3c12
2 changed files with 22 additions and 1 deletions

View File

@@ -44,7 +44,17 @@ class BotService:
if not include_secret:
masked_columns = ['adapter_config']
return self.ap.persistence_mgr.serialize_model(persistence_bot.Bot, bot, masked_columns)
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_data['adapter_runtime_values'] = adapter_runtime_values
return persistence_bot_data
async def create_bot(self, bot_data: dict) -> str:
"""创建机器人"""

View File

@@ -187,6 +187,17 @@ class RuntimeConnectionHandler(handler.Handler):
},
)
@self.action(PluginToRuntimeAction.GET_BOT_INFO)
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)
return handler.ActionResponse.success(
data={
'bot': bot,
},
)
@self.action(PluginToRuntimeAction.SEND_MESSAGE)
async def send_message(data: dict[str, Any]) -> handler.ActionResponse:
"""Send message"""