AstrBot 4.5.1__py3-none-any.whl → 4.5.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- astrbot/api/__init__.py +10 -11
- astrbot/api/event/__init__.py +5 -6
- astrbot/api/event/filter/__init__.py +37 -36
- astrbot/api/platform/__init__.py +7 -8
- astrbot/api/provider/__init__.py +7 -7
- astrbot/api/star/__init__.py +3 -4
- astrbot/api/util/__init__.py +2 -2
- astrbot/cli/__main__.py +5 -5
- astrbot/cli/commands/__init__.py +3 -3
- astrbot/cli/commands/cmd_conf.py +19 -16
- astrbot/cli/commands/cmd_init.py +3 -2
- astrbot/cli/commands/cmd_plug.py +8 -10
- astrbot/cli/commands/cmd_run.py +5 -6
- astrbot/cli/utils/__init__.py +6 -6
- astrbot/cli/utils/basic.py +14 -14
- astrbot/cli/utils/plugin.py +24 -15
- astrbot/cli/utils/version_comparator.py +10 -12
- astrbot/core/__init__.py +8 -6
- astrbot/core/agent/agent.py +3 -2
- astrbot/core/agent/handoff.py +6 -2
- astrbot/core/agent/hooks.py +9 -6
- astrbot/core/agent/mcp_client.py +50 -15
- astrbot/core/agent/message.py +168 -0
- astrbot/core/agent/response.py +2 -1
- astrbot/core/agent/run_context.py +2 -3
- astrbot/core/agent/runners/base.py +10 -13
- astrbot/core/agent/runners/tool_loop_agent_runner.py +52 -51
- astrbot/core/agent/tool.py +60 -41
- astrbot/core/agent/tool_executor.py +9 -3
- astrbot/core/astr_agent_context.py +3 -1
- astrbot/core/astrbot_config_mgr.py +29 -9
- astrbot/core/config/__init__.py +2 -2
- astrbot/core/config/astrbot_config.py +28 -26
- astrbot/core/config/default.py +4 -6
- astrbot/core/conversation_mgr.py +105 -36
- astrbot/core/core_lifecycle.py +68 -54
- astrbot/core/db/__init__.py +33 -18
- astrbot/core/db/migration/helper.py +12 -10
- astrbot/core/db/migration/migra_3_to_4.py +53 -34
- astrbot/core/db/migration/migra_45_to_46.py +1 -1
- astrbot/core/db/migration/shared_preferences_v3.py +2 -1
- astrbot/core/db/migration/sqlite_v3.py +26 -23
- astrbot/core/db/po.py +27 -18
- astrbot/core/db/sqlite.py +74 -45
- astrbot/core/db/vec_db/base.py +10 -14
- astrbot/core/db/vec_db/faiss_impl/document_storage.py +90 -77
- astrbot/core/db/vec_db/faiss_impl/embedding_storage.py +9 -3
- astrbot/core/db/vec_db/faiss_impl/vec_db.py +36 -31
- astrbot/core/event_bus.py +8 -6
- astrbot/core/file_token_service.py +6 -5
- astrbot/core/initial_loader.py +7 -5
- astrbot/core/knowledge_base/chunking/__init__.py +1 -3
- astrbot/core/knowledge_base/chunking/base.py +1 -0
- astrbot/core/knowledge_base/chunking/fixed_size.py +2 -0
- astrbot/core/knowledge_base/chunking/recursive.py +16 -10
- astrbot/core/knowledge_base/kb_db_sqlite.py +50 -48
- astrbot/core/knowledge_base/kb_helper.py +30 -17
- astrbot/core/knowledge_base/kb_mgr.py +6 -7
- astrbot/core/knowledge_base/models.py +10 -4
- astrbot/core/knowledge_base/parsers/__init__.py +3 -5
- astrbot/core/knowledge_base/parsers/base.py +1 -0
- astrbot/core/knowledge_base/parsers/markitdown_parser.py +2 -1
- astrbot/core/knowledge_base/parsers/pdf_parser.py +2 -1
- astrbot/core/knowledge_base/parsers/text_parser.py +1 -0
- astrbot/core/knowledge_base/parsers/util.py +1 -1
- astrbot/core/knowledge_base/retrieval/__init__.py +6 -8
- astrbot/core/knowledge_base/retrieval/manager.py +17 -14
- astrbot/core/knowledge_base/retrieval/rank_fusion.py +7 -3
- astrbot/core/knowledge_base/retrieval/sparse_retriever.py +11 -5
- astrbot/core/log.py +21 -13
- astrbot/core/message/components.py +123 -217
- astrbot/core/message/message_event_result.py +24 -24
- astrbot/core/persona_mgr.py +20 -11
- astrbot/core/pipeline/__init__.py +7 -7
- astrbot/core/pipeline/content_safety_check/stage.py +13 -9
- astrbot/core/pipeline/content_safety_check/strategies/__init__.py +1 -2
- astrbot/core/pipeline/content_safety_check/strategies/baidu_aip.py +12 -13
- astrbot/core/pipeline/content_safety_check/strategies/keywords.py +1 -0
- astrbot/core/pipeline/content_safety_check/strategies/strategy.py +6 -6
- astrbot/core/pipeline/context.py +4 -1
- astrbot/core/pipeline/context_utils.py +77 -7
- astrbot/core/pipeline/preprocess_stage/stage.py +12 -9
- astrbot/core/pipeline/process_stage/method/llm_request.py +125 -72
- astrbot/core/pipeline/process_stage/method/star_request.py +19 -17
- astrbot/core/pipeline/process_stage/stage.py +13 -10
- astrbot/core/pipeline/process_stage/utils.py +6 -5
- astrbot/core/pipeline/rate_limit_check/stage.py +37 -36
- astrbot/core/pipeline/respond/stage.py +23 -20
- astrbot/core/pipeline/result_decorate/stage.py +31 -23
- astrbot/core/pipeline/scheduler.py +12 -8
- astrbot/core/pipeline/session_status_check/stage.py +12 -8
- astrbot/core/pipeline/stage.py +10 -4
- astrbot/core/pipeline/waking_check/stage.py +24 -18
- astrbot/core/pipeline/whitelist_check/stage.py +10 -7
- astrbot/core/platform/__init__.py +6 -6
- astrbot/core/platform/astr_message_event.py +76 -110
- astrbot/core/platform/astrbot_message.py +11 -13
- astrbot/core/platform/manager.py +16 -15
- astrbot/core/platform/message_session.py +5 -3
- astrbot/core/platform/platform.py +16 -24
- astrbot/core/platform/platform_metadata.py +4 -4
- astrbot/core/platform/register.py +8 -8
- astrbot/core/platform/sources/aiocqhttp/aiocqhttp_message_event.py +23 -15
- astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py +51 -33
- astrbot/core/platform/sources/dingtalk/dingtalk_adapter.py +42 -27
- astrbot/core/platform/sources/dingtalk/dingtalk_event.py +7 -3
- astrbot/core/platform/sources/discord/client.py +9 -6
- astrbot/core/platform/sources/discord/components.py +18 -14
- astrbot/core/platform/sources/discord/discord_platform_adapter.py +45 -30
- astrbot/core/platform/sources/discord/discord_platform_event.py +38 -30
- astrbot/core/platform/sources/lark/lark_adapter.py +23 -17
- astrbot/core/platform/sources/lark/lark_event.py +21 -14
- astrbot/core/platform/sources/misskey/misskey_adapter.py +107 -67
- astrbot/core/platform/sources/misskey/misskey_api.py +153 -129
- astrbot/core/platform/sources/misskey/misskey_event.py +20 -15
- astrbot/core/platform/sources/misskey/misskey_utils.py +74 -62
- astrbot/core/platform/sources/qqofficial/qqofficial_message_event.py +63 -44
- astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py +41 -26
- astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_adapter.py +36 -17
- astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_event.py +3 -1
- astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_server.py +12 -7
- astrbot/core/platform/sources/satori/satori_adapter.py +56 -38
- astrbot/core/platform/sources/satori/satori_event.py +34 -25
- astrbot/core/platform/sources/slack/client.py +11 -9
- astrbot/core/platform/sources/slack/slack_adapter.py +52 -36
- astrbot/core/platform/sources/slack/slack_event.py +34 -24
- astrbot/core/platform/sources/telegram/tg_adapter.py +38 -18
- astrbot/core/platform/sources/telegram/tg_event.py +32 -18
- astrbot/core/platform/sources/webchat/webchat_adapter.py +27 -17
- astrbot/core/platform/sources/webchat/webchat_event.py +14 -10
- astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py +115 -120
- astrbot/core/platform/sources/wechatpadpro/wechatpadpro_message_event.py +9 -8
- astrbot/core/platform/sources/wechatpadpro/xml_data_parser.py +15 -16
- astrbot/core/platform/sources/wecom/wecom_adapter.py +35 -18
- astrbot/core/platform/sources/wecom/wecom_event.py +55 -48
- astrbot/core/platform/sources/wecom/wecom_kf.py +34 -44
- astrbot/core/platform/sources/wecom/wecom_kf_message.py +26 -10
- astrbot/core/platform/sources/wecom_ai_bot/WXBizJsonMsgCrypt.py +18 -10
- astrbot/core/platform/sources/wecom_ai_bot/__init__.py +3 -5
- astrbot/core/platform/sources/wecom_ai_bot/ierror.py +0 -1
- astrbot/core/platform/sources/wecom_ai_bot/wecomai_adapter.py +61 -37
- astrbot/core/platform/sources/wecom_ai_bot/wecomai_api.py +67 -28
- astrbot/core/platform/sources/wecom_ai_bot/wecomai_event.py +8 -9
- astrbot/core/platform/sources/wecom_ai_bot/wecomai_queue_mgr.py +18 -9
- astrbot/core/platform/sources/wecom_ai_bot/wecomai_server.py +14 -12
- astrbot/core/platform/sources/wecom_ai_bot/wecomai_utils.py +22 -12
- astrbot/core/platform/sources/weixin_official_account/weixin_offacc_adapter.py +40 -26
- astrbot/core/platform/sources/weixin_official_account/weixin_offacc_event.py +47 -45
- astrbot/core/platform_message_history_mgr.py +5 -3
- astrbot/core/provider/__init__.py +2 -3
- astrbot/core/provider/entites.py +8 -8
- astrbot/core/provider/entities.py +61 -75
- astrbot/core/provider/func_tool_manager.py +59 -55
- astrbot/core/provider/manager.py +32 -22
- astrbot/core/provider/provider.py +72 -46
- astrbot/core/provider/register.py +7 -7
- astrbot/core/provider/sources/anthropic_source.py +48 -30
- astrbot/core/provider/sources/azure_tts_source.py +17 -13
- astrbot/core/provider/sources/coze_api_client.py +27 -17
- astrbot/core/provider/sources/coze_source.py +104 -87
- astrbot/core/provider/sources/dashscope_source.py +18 -11
- astrbot/core/provider/sources/dashscope_tts.py +36 -23
- astrbot/core/provider/sources/dify_source.py +25 -20
- astrbot/core/provider/sources/edge_tts_source.py +21 -17
- astrbot/core/provider/sources/fishaudio_tts_api_source.py +22 -14
- astrbot/core/provider/sources/gemini_embedding_source.py +12 -13
- astrbot/core/provider/sources/gemini_source.py +72 -58
- astrbot/core/provider/sources/gemini_tts_source.py +8 -6
- astrbot/core/provider/sources/gsv_selfhosted_source.py +17 -14
- astrbot/core/provider/sources/gsvi_tts_source.py +11 -7
- astrbot/core/provider/sources/minimax_tts_api_source.py +50 -40
- astrbot/core/provider/sources/openai_embedding_source.py +6 -8
- astrbot/core/provider/sources/openai_source.py +77 -69
- astrbot/core/provider/sources/openai_tts_api_source.py +14 -6
- astrbot/core/provider/sources/sensevoice_selfhosted_source.py +13 -11
- astrbot/core/provider/sources/vllm_rerank_source.py +10 -4
- astrbot/core/provider/sources/volcengine_tts.py +38 -31
- astrbot/core/provider/sources/whisper_api_source.py +14 -12
- astrbot/core/provider/sources/whisper_selfhosted_source.py +15 -11
- astrbot/core/provider/sources/xinference_rerank_source.py +16 -8
- astrbot/core/provider/sources/xinference_stt_provider.py +35 -25
- astrbot/core/star/__init__.py +16 -11
- astrbot/core/star/config.py +10 -15
- astrbot/core/star/context.py +97 -75
- astrbot/core/star/filter/__init__.py +4 -3
- astrbot/core/star/filter/command.py +30 -28
- astrbot/core/star/filter/command_group.py +27 -24
- astrbot/core/star/filter/custom_filter.py +6 -5
- astrbot/core/star/filter/event_message_type.py +4 -2
- astrbot/core/star/filter/permission.py +4 -2
- astrbot/core/star/filter/platform_adapter_type.py +4 -2
- astrbot/core/star/filter/regex.py +4 -2
- astrbot/core/star/register/__init__.py +19 -19
- astrbot/core/star/register/star.py +6 -2
- astrbot/core/star/register/star_handler.py +96 -73
- astrbot/core/star/session_llm_manager.py +48 -14
- astrbot/core/star/session_plugin_manager.py +29 -15
- astrbot/core/star/star.py +1 -2
- astrbot/core/star/star_handler.py +13 -8
- astrbot/core/star/star_manager.py +151 -59
- astrbot/core/star/star_tools.py +44 -37
- astrbot/core/star/updator.py +10 -10
- astrbot/core/umop_config_router.py +10 -4
- astrbot/core/updator.py +13 -5
- astrbot/core/utils/astrbot_path.py +3 -5
- astrbot/core/utils/dify_api_client.py +33 -15
- astrbot/core/utils/io.py +66 -42
- astrbot/core/utils/log_pipe.py +1 -1
- astrbot/core/utils/metrics.py +7 -7
- astrbot/core/utils/path_util.py +15 -16
- astrbot/core/utils/pip_installer.py +5 -5
- astrbot/core/utils/session_waiter.py +19 -20
- astrbot/core/utils/shared_preferences.py +45 -20
- astrbot/core/utils/t2i/__init__.py +4 -1
- astrbot/core/utils/t2i/network_strategy.py +35 -26
- astrbot/core/utils/t2i/renderer.py +11 -5
- astrbot/core/utils/t2i/template_manager.py +14 -15
- astrbot/core/utils/tencent_record_helper.py +19 -13
- astrbot/core/utils/version_comparator.py +10 -13
- astrbot/core/zip_updator.py +43 -40
- astrbot/dashboard/routes/__init__.py +18 -18
- astrbot/dashboard/routes/auth.py +10 -8
- astrbot/dashboard/routes/chat.py +30 -21
- astrbot/dashboard/routes/config.py +92 -75
- astrbot/dashboard/routes/conversation.py +46 -39
- astrbot/dashboard/routes/file.py +4 -2
- astrbot/dashboard/routes/knowledge_base.py +47 -40
- astrbot/dashboard/routes/log.py +9 -4
- astrbot/dashboard/routes/persona.py +19 -16
- astrbot/dashboard/routes/plugin.py +69 -55
- astrbot/dashboard/routes/route.py +3 -1
- astrbot/dashboard/routes/session_management.py +130 -116
- astrbot/dashboard/routes/stat.py +34 -34
- astrbot/dashboard/routes/t2i.py +15 -12
- astrbot/dashboard/routes/tools.py +56 -53
- astrbot/dashboard/routes/update.py +32 -28
- astrbot/dashboard/server.py +30 -26
- astrbot/dashboard/utils.py +8 -4
- {astrbot-4.5.1.dist-info → astrbot-4.5.3.dist-info}/METADATA +2 -1
- astrbot-4.5.3.dist-info/RECORD +261 -0
- astrbot-4.5.1.dist-info/RECORD +0 -260
- {astrbot-4.5.1.dist-info → astrbot-4.5.3.dist-info}/WHEEL +0 -0
- {astrbot-4.5.1.dist-info → astrbot-4.5.3.dist-info}/entry_points.txt +0 -0
- {astrbot-4.5.1.dist-info → astrbot-4.5.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import traceback
|
|
2
|
-
import aiohttp
|
|
3
|
-
import os
|
|
4
1
|
import json
|
|
2
|
+
import os
|
|
3
|
+
import ssl
|
|
4
|
+
import traceback
|
|
5
5
|
from datetime import datetime
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import aiohttp
|
|
8
8
|
import certifi
|
|
9
|
-
|
|
10
|
-
from .route import Route, Response, RouteContext
|
|
11
|
-
from astrbot.core import logger, file_token_service
|
|
12
9
|
from quart import request
|
|
13
|
-
|
|
10
|
+
|
|
11
|
+
from astrbot.core import DEMO_MODE, file_token_service, logger
|
|
14
12
|
from astrbot.core.core_lifecycle import AstrBotCoreLifecycle
|
|
15
|
-
from astrbot.core.star.star_handler import star_handlers_registry
|
|
16
13
|
from astrbot.core.star.filter.command import CommandFilter
|
|
17
14
|
from astrbot.core.star.filter.command_group import CommandGroupFilter
|
|
18
15
|
from astrbot.core.star.filter.permission import PermissionTypeFilter
|
|
19
16
|
from astrbot.core.star.filter.regex import RegexFilter
|
|
20
|
-
from astrbot.core.star.star_handler import EventType
|
|
21
|
-
from astrbot.core import
|
|
17
|
+
from astrbot.core.star.star_handler import EventType, star_handlers_registry
|
|
18
|
+
from astrbot.core.star.star_manager import PluginManager
|
|
19
|
+
|
|
20
|
+
from .route import Response, Route, RouteContext
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
class PluginRoute(Route):
|
|
@@ -106,29 +105,33 @@ class PluginRoute(Route):
|
|
|
106
105
|
|
|
107
106
|
for url in urls:
|
|
108
107
|
try:
|
|
109
|
-
async with
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
logger.
|
|
124
|
-
#
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
108
|
+
async with (
|
|
109
|
+
aiohttp.ClientSession(
|
|
110
|
+
trust_env=True,
|
|
111
|
+
connector=connector,
|
|
112
|
+
) as session,
|
|
113
|
+
session.get(url) as response,
|
|
114
|
+
):
|
|
115
|
+
if response.status == 200:
|
|
116
|
+
remote_data = await response.json()
|
|
117
|
+
|
|
118
|
+
# 检查远程数据是否为空
|
|
119
|
+
if not remote_data or (
|
|
120
|
+
isinstance(remote_data, dict) and len(remote_data) == 0
|
|
121
|
+
):
|
|
122
|
+
logger.warning(f"远程插件市场数据为空: {url}")
|
|
123
|
+
continue # 继续尝试其他URL或使用缓存
|
|
124
|
+
|
|
125
|
+
logger.info("成功获取远程插件市场数据")
|
|
126
|
+
# 获取最新的MD5并保存到缓存
|
|
127
|
+
current_md5 = await self._get_remote_md5()
|
|
128
|
+
self._save_plugin_cache(
|
|
129
|
+
cache_file,
|
|
130
|
+
remote_data,
|
|
131
|
+
current_md5,
|
|
132
|
+
)
|
|
133
|
+
return Response().ok(remote_data).__dict__
|
|
134
|
+
logger.error(f"请求 {url} 失败,状态码:{response.status}")
|
|
132
135
|
except Exception as e:
|
|
133
136
|
logger.error(f"请求 {url} 失败,错误:{e}")
|
|
134
137
|
|
|
@@ -165,7 +168,7 @@ class PluginRoute(Route):
|
|
|
165
168
|
|
|
166
169
|
is_valid = cached_md5 == remote_md5
|
|
167
170
|
logger.debug(
|
|
168
|
-
f"插件数据MD5: 本地={cached_md5}, 远程={remote_md5}, 有效={is_valid}"
|
|
171
|
+
f"插件数据MD5: 本地={cached_md5}, 远程={remote_md5}, 有效={is_valid}",
|
|
169
172
|
)
|
|
170
173
|
return is_valid
|
|
171
174
|
|
|
@@ -179,18 +182,20 @@ class PluginRoute(Route):
|
|
|
179
182
|
ssl_context = ssl.create_default_context(cafile=certifi.where())
|
|
180
183
|
connector = aiohttp.TCPConnector(ssl=ssl_context)
|
|
181
184
|
|
|
182
|
-
async with
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
185
|
+
async with (
|
|
186
|
+
aiohttp.ClientSession(
|
|
187
|
+
trust_env=True,
|
|
188
|
+
connector=connector,
|
|
189
|
+
) as session,
|
|
190
|
+
session.get(
|
|
191
|
+
"https://api.soulter.top/astrbot/plugins-md5",
|
|
192
|
+
) as response,
|
|
193
|
+
):
|
|
194
|
+
if response.status == 200:
|
|
195
|
+
data = await response.json()
|
|
196
|
+
return data.get("md5", "")
|
|
197
|
+
logger.error(f"获取MD5失败,状态码:{response.status}")
|
|
198
|
+
return ""
|
|
194
199
|
except Exception as e:
|
|
195
200
|
logger.error(f"获取远程MD5失败: {e}")
|
|
196
201
|
return ""
|
|
@@ -204,7 +209,7 @@ class PluginRoute(Route):
|
|
|
204
209
|
# 检查缓存是否有效
|
|
205
210
|
if "data" in cache_data and "timestamp" in cache_data:
|
|
206
211
|
logger.debug(
|
|
207
|
-
f"加载缓存文件: {cache_file}, 缓存时间: {cache_data['timestamp']}"
|
|
212
|
+
f"加载缓存文件: {cache_file}, 缓存时间: {cache_data['timestamp']}",
|
|
208
213
|
)
|
|
209
214
|
return cache_data["data"]
|
|
210
215
|
except Exception as e:
|
|
@@ -260,7 +265,7 @@ class PluginRoute(Route):
|
|
|
260
265
|
"activated": plugin.activated,
|
|
261
266
|
"online_vesion": "",
|
|
262
267
|
"handlers": await self.get_plugin_handlers_info(
|
|
263
|
-
plugin.star_handler_full_names
|
|
268
|
+
plugin.star_handler_full_names,
|
|
264
269
|
),
|
|
265
270
|
"display_name": plugin.display_name,
|
|
266
271
|
"logo": f"/api/file/{logo_url}" if logo_url else None,
|
|
@@ -279,13 +284,15 @@ class PluginRoute(Route):
|
|
|
279
284
|
for handler_full_name in handler_full_names:
|
|
280
285
|
info = {}
|
|
281
286
|
handler = star_handlers_registry.star_handlers_map.get(
|
|
282
|
-
handler_full_name,
|
|
287
|
+
handler_full_name,
|
|
288
|
+
None,
|
|
283
289
|
)
|
|
284
290
|
if handler is None:
|
|
285
291
|
continue
|
|
286
292
|
info["event_type"] = handler.event_type.name
|
|
287
293
|
info["event_type_h"] = self.translated_event_type.get(
|
|
288
|
-
handler.event_type,
|
|
294
|
+
handler.event_type,
|
|
295
|
+
handler.event_type.name,
|
|
289
296
|
)
|
|
290
297
|
info["handler_full_name"] = handler.handler_full_name
|
|
291
298
|
info["desc"] = handler.desc
|
|
@@ -308,7 +315,7 @@ class PluginRoute(Route):
|
|
|
308
315
|
info["cmd"] = filter.get_complete_command_names()[0]
|
|
309
316
|
info["cmd"] = info["cmd"].strip()
|
|
310
317
|
info["sub_command"] = filter.print_cmd_tree(
|
|
311
|
-
filter.sub_command_filters
|
|
318
|
+
filter.sub_command_filters,
|
|
312
319
|
)
|
|
313
320
|
elif isinstance(filter, RegexFilter):
|
|
314
321
|
info["type"] = "正则匹配"
|
|
@@ -388,9 +395,15 @@ class PluginRoute(Route):
|
|
|
388
395
|
|
|
389
396
|
post_data = await request.json
|
|
390
397
|
plugin_name = post_data["name"]
|
|
398
|
+
delete_config = post_data.get("delete_config", False)
|
|
399
|
+
delete_data = post_data.get("delete_data", False)
|
|
391
400
|
try:
|
|
392
401
|
logger.info(f"正在卸载插件 {plugin_name}")
|
|
393
|
-
await self.plugin_manager.uninstall_plugin(
|
|
402
|
+
await self.plugin_manager.uninstall_plugin(
|
|
403
|
+
plugin_name,
|
|
404
|
+
delete_config=delete_config,
|
|
405
|
+
delete_data=delete_data,
|
|
406
|
+
)
|
|
394
407
|
logger.info(f"卸载插件 {plugin_name} 成功")
|
|
395
408
|
return Response().ok(None, "卸载成功").__dict__
|
|
396
409
|
except Exception as e:
|
|
@@ -474,7 +487,8 @@ class PluginRoute(Route):
|
|
|
474
487
|
return Response().error(f"插件 {plugin_name} 不存在").__dict__
|
|
475
488
|
|
|
476
489
|
plugin_dir = os.path.join(
|
|
477
|
-
self.plugin_manager.plugin_store_path,
|
|
490
|
+
self.plugin_manager.plugin_store_path,
|
|
491
|
+
plugin_obj.root_dir_name,
|
|
478
492
|
)
|
|
479
493
|
|
|
480
494
|
if not os.path.isdir(plugin_dir):
|
|
@@ -498,4 +512,4 @@ class PluginRoute(Route):
|
|
|
498
512
|
)
|
|
499
513
|
except Exception as e:
|
|
500
514
|
logger.error(f"/api/plugin/readme: {traceback.format_exc()}")
|
|
501
|
-
return Response().error(f"读取README文件失败: {
|
|
515
|
+
return Response().error(f"读取README文件失败: {e!s}").__dict__
|