✨ feat: 支持通过指令下载插件 /plugin get
This commit is contained in:
@@ -332,7 +332,10 @@ class PluginManager:
|
||||
)
|
||||
# 绑定 llm_tool handler
|
||||
for func_tool in llm_tools.func_list:
|
||||
if func_tool.handler.__module__ == metadata.module_path:
|
||||
if (
|
||||
func_tool.handler
|
||||
and func_tool.handler.__module__ == metadata.module_path
|
||||
):
|
||||
func_tool.handler_module_path = metadata.module_path
|
||||
func_tool.handler = functools.partial(
|
||||
func_tool.handler, metadata.star_cls
|
||||
|
||||
@@ -53,13 +53,6 @@ class ConversationRoute(Route):
|
||||
exclude_platforms.split(",") if exclude_platforms else []
|
||||
)
|
||||
|
||||
logger.info(
|
||||
f"获取对话列表: page={page}, page_size={page_size}, "
|
||||
f"platforms={platform_list}, message_types={message_type_list}, "
|
||||
f"search={search_query}, exclude_ids={exclude_id_list}, "
|
||||
f"exclude_platforms={exclude_platform_list}"
|
||||
)
|
||||
|
||||
# 限制页面大小,防止请求过大数据
|
||||
if page < 1:
|
||||
page = 1
|
||||
@@ -79,7 +72,6 @@ class ConversationRoute(Route):
|
||||
exclude_ids=exclude_id_list,
|
||||
exclude_platforms=exclude_platform_list,
|
||||
)
|
||||
logger.info(f"获取到 {len(conversations)} 条对话,总数: {total_count}")
|
||||
except Exception as e:
|
||||
logger.error(f"数据库查询出错: {str(e)}\n{traceback.format_exc()}")
|
||||
return Response().error(f"数据库查询出错: {str(e)}").__dict__
|
||||
@@ -98,10 +90,6 @@ class ConversationRoute(Route):
|
||||
"total_pages": total_pages,
|
||||
},
|
||||
}
|
||||
|
||||
logger.info(
|
||||
f"返回对话列表成功: {json.dumps(result, ensure_ascii=False)[:200]}..."
|
||||
)
|
||||
return Response().ok(result).__dict__
|
||||
|
||||
except Exception as e:
|
||||
|
||||
@@ -13,6 +13,7 @@ from astrbot.core.provider.sources.dify_source import ProviderDify
|
||||
from astrbot.core.utils.io import download_dashboard, get_dashboard_version
|
||||
from astrbot.core.star.star_handler import star_handlers_registry, StarHandlerMetadata
|
||||
from astrbot.core.star.star import star_map
|
||||
from astrbot.core.star.star_manager import PluginManager
|
||||
from astrbot.core.star.filter.command import CommandFilter
|
||||
from astrbot.core.star.filter.command_group import CommandGroupFilter
|
||||
from astrbot.core.star.filter.permission import PermissionTypeFilter
|
||||
@@ -196,7 +197,29 @@ class Main(star.Star):
|
||||
return
|
||||
await self.context._star_manager.turn_on_plugin(oper2)
|
||||
event.set_result(MessageEventResult().message(f"插件 {oper2} 已启用。"))
|
||||
elif oper1 == "get":
|
||||
if not oper2:
|
||||
raise Exception("请输入插件地址。")
|
||||
if not event.is_admin():
|
||||
raise Exception(
|
||||
"改指令限制仅管理员使用,且无法通过 /alter_cmd 更改。"
|
||||
)
|
||||
if not oper2.startswith("http"):
|
||||
oper2 = f"https://github.com/{oper2}"
|
||||
|
||||
logger.info(f"准备从 {oper2} 获取插件。")
|
||||
|
||||
if self.context._star_manager:
|
||||
star_mgr: PluginManager = self.context._star_manager
|
||||
try:
|
||||
await star_mgr.install_plugin(oper2)
|
||||
event.set_result(MessageEventResult().message("获取插件成功。"))
|
||||
except Exception as e:
|
||||
logger.error(f"获取插件失败: {e}")
|
||||
event.set_result(
|
||||
MessageEventResult().message(f"获取插件失败: {e}")
|
||||
)
|
||||
return
|
||||
else:
|
||||
# 获取插件帮助
|
||||
plugin = self.context.get_registered_star(oper1)
|
||||
|
||||
Reference in New Issue
Block a user