1818from astrbot .core .star .star_handler import EventType
1919from astrbot .core import DEMO_MODE
2020
21- try :
22- import nh3
23- except ImportError :
24- logger .warning ("未安装 nh3 库,无法清理插件 README.md 中的 HTML 标签。" )
25- nh3 = None
26-
2721
2822class PluginRoute (Route ):
2923 def __init__ (
@@ -332,9 +326,6 @@ async def on_plugin(self):
332326 return Response ().error (str (e )).__dict__
333327
334328 async def get_plugin_readme (self ):
335- if not nh3 :
336- return Response ().error ("未安装 nh3 库" ).__dict__
337-
338329 plugin_name = request .args .get ("name" )
339330 logger .debug (f"正在获取插件 { plugin_name } 的README文件内容" )
340331
@@ -370,11 +361,9 @@ async def get_plugin_readme(self):
370361 with open (readme_path , "r" , encoding = "utf-8" ) as f :
371362 readme_content = f .read ()
372363
373- cleaned_content = nh3 .clean (readme_content )
374-
375364 return (
376365 Response ()
377- .ok ({"content" : cleaned_content }, "成功获取README内容" )
366+ .ok ({"content" : readme_content }, "成功获取README内容" )
378367 .__dict__
379368 )
380369 except Exception as e :
@@ -395,12 +384,14 @@ async def get_plugin_platform_enable(self):
395384 platform_type = platform .get ("type" , "" )
396385 platform_id = platform .get ("id" , "" )
397386
398- platforms .append ({
399- "name" : platform_id , # 使用type作为name,这是系统内部使用的平台名称
400- "id" : platform_id , # 保留id字段以便前端可以显示
401- "type" : platform_type ,
402- "display_name" : f"{ platform_type } ({ platform_id } )" ,
403- })
387+ platforms .append (
388+ {
389+ "name" : platform_id , # 使用type作为name,这是系统内部使用的平台名称
390+ "id" : platform_id , # 保留id字段以便前端可以显示
391+ "type" : platform_type ,
392+ "display_name" : f"{ platform_type } ({ platform_id } )" ,
393+ }
394+ )
404395
405396 adjusted_platform_enable = {}
406397 for platform_id , plugins in platform_enable .items ():
@@ -409,23 +400,27 @@ async def get_plugin_platform_enable(self):
409400 # 获取所有插件,包括系统内部插件
410401 plugins = []
411402 for plugin in self .plugin_manager .context .get_all_stars ():
412- plugins .append ({
413- "name" : plugin .name ,
414- "desc" : plugin .desc ,
415- "reserved" : plugin .reserved , # 添加reserved标志
416- })
403+ plugins .append (
404+ {
405+ "name" : plugin .name ,
406+ "desc" : plugin .desc ,
407+ "reserved" : plugin .reserved , # 添加reserved标志
408+ }
409+ )
417410
418411 logger .debug (
419412 f"获取插件平台配置: 原始配置={ platform_enable } , 调整后={ adjusted_platform_enable } "
420413 )
421414
422415 return (
423416 Response ()
424- .ok ({
425- "platforms" : platforms ,
426- "plugins" : plugins ,
427- "platform_enable" : adjusted_platform_enable ,
428- })
417+ .ok (
418+ {
419+ "platforms" : platforms ,
420+ "plugins" : plugins ,
421+ "platform_enable" : adjusted_platform_enable ,
422+ }
423+ )
429424 .__dict__
430425 )
431426 except Exception as e :
0 commit comments