mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-19 03:54:19 +00:00
feat: get_bot_info api
This commit is contained in:
@@ -44,7 +44,17 @@ 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)
|
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:
|
async def create_bot(self, bot_data: dict) -> str:
|
||||||
"""创建机器人"""
|
"""创建机器人"""
|
||||||
|
|||||||
@@ -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)
|
@self.action(PluginToRuntimeAction.SEND_MESSAGE)
|
||||||
async def send_message(data: dict[str, Any]) -> handler.ActionResponse:
|
async def send_message(data: dict[str, Any]) -> handler.ActionResponse:
|
||||||
"""Send message"""
|
"""Send message"""
|
||||||
|
|||||||
Reference in New Issue
Block a user