nonebot-plugin-shiro-web-console 0.1.14__tar.gz → 0.1.16__tar.gz

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.

Potentially problematic release.


This version of nonebot-plugin-shiro-web-console might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nonebot-plugin-shiro-web-console
3
- Version: 0.1.14
3
+ Version: 0.1.16
4
4
  Summary: 一个用于 NoneBot2 的网页控制台插件,支持通过浏览器查看日志和发送消息
5
5
  Project-URL: Homepage, https://github.com/luojisama/nonebot-plugin-shiro-web-console
6
6
  Project-URL: Bug Tracker, https://github.com/luojisama/nonebot-plugin-shiro-web-console/issues
@@ -61,6 +61,14 @@ web_console_password=your_password # 设置固定登录密码
61
61
 
62
62
  ## 更新日志
63
63
 
64
+ ### v0.1.16
65
+ - **修复**:修复 WebSocket 连接清理时的竞争条件(KeyError),解决偶发的 500 错误。
66
+
67
+ ### v0.1.15
68
+ - **修复**:修复插件商店操作时的 500 错误(缺少异步锁定义)。
69
+ - **修复**:修复 WebSocket 连接断开时的异常报错。
70
+ - **新增**:正式实装完整日志记录与下载功能。
71
+
64
72
  ### v0.1.14
65
73
  - **新增**:完整运行日志记录功能,支持在网页端直接下载。
66
74
  - **优化**:添加插件商店操作锁,解决多插件同时更新导致的冲突问题。
@@ -30,6 +30,14 @@ web_console_password=your_password # 设置固定登录密码
30
30
 
31
31
  ## 更新日志
32
32
 
33
+ ### v0.1.16
34
+ - **修复**:修复 WebSocket 连接清理时的竞争条件(KeyError),解决偶发的 500 错误。
35
+
36
+ ### v0.1.15
37
+ - **修复**:修复插件商店操作时的 500 错误(缺少异步锁定义)。
38
+ - **修复**:修复 WebSocket 连接断开时的异常报错。
39
+ - **新增**:正式实装完整日志记录与下载功能。
40
+
33
41
  ### v0.1.14
34
42
  - **新增**:完整运行日志记录功能,支持在网页端直接下载。
35
43
  - **优化**:添加插件商店操作锁,解决多插件同时更新导致的冲突问题。
@@ -35,7 +35,7 @@ __plugin_meta__ = PluginMetadata(
35
35
  supported_adapters={"~onebot.v11"},
36
36
  extra={
37
37
  "author": "luojisama",
38
- "version": "0.1.13",
38
+ "version": "0.1.16",
39
39
  "pypi_test": "nonebot-plugin-shiro-web-console",
40
40
  },
41
41
  )
@@ -55,7 +55,7 @@ async def broadcast_message(data: dict):
55
55
  dead_connections.add(ws)
56
56
 
57
57
  for ws in dead_connections:
58
- active_connections.remove(ws)
58
+ active_connections.discard(ws)
59
59
 
60
60
  # 日志缓冲区,保留最近 200 条日志
61
61
  log_buffer = deque(maxlen=200)
@@ -77,6 +77,15 @@ async def log_sink(message):
77
77
  # 注册 loguru sink
78
78
  logger.add(log_sink, format="{time} {level} {message}", level="INFO")
79
79
 
80
+ # Async lock for plugin actions
81
+ store_lock = asyncio.Lock()
82
+
83
+ # Persistent log configuration
84
+ log_dir = nonebot_plugin_localstore.get_plugin_data_dir() / "logs"
85
+ log_dir.mkdir(parents=True, exist_ok=True)
86
+ full_log_path = log_dir / "web_console_full.log"
87
+ logger.add(full_log_path, rotation="10 MB", encoding="utf-8", level="INFO", format="{time:YYYY-MM-DD HH:mm:ss} | {level} | {module}:{line} | {message}")
88
+
80
89
  # 验证码管理
81
90
  class AuthManager:
82
91
  def __init__(self):
@@ -608,6 +617,12 @@ if app:
608
617
  async def get_logs():
609
618
  return list(log_buffer)
610
619
 
620
+ @app.get("/web_console/api/logs/download", dependencies=[Depends(check_auth)])
621
+ async def download_logs():
622
+ if not full_log_path.exists():
623
+ return Response("暂无日志记录", status_code=404)
624
+ return FileResponse(full_log_path, filename="nonebot_full.log", media_type="text/plain")
625
+
611
626
  @app.get("/web_console/api/plugins", dependencies=[Depends(check_auth)])
612
627
  async def get_plugins():
613
628
  from nonebot import get_loaded_plugins
@@ -1080,7 +1095,6 @@ if app:
1080
1095
  # 保持连接,接收心跳或其他
1081
1096
  await websocket.receive_text()
1082
1097
  except WebSocketDisconnect:
1083
- active_connections.remove(websocket)
1098
+ active_connections.discard(websocket)
1084
1099
  except Exception:
1085
- if websocket in active_connections:
1086
- active_connections.remove(websocket)
1100
+ active_connections.discard(websocket)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nonebot-plugin-shiro-web-console"
3
- version = "0.1.14"
3
+ version = "0.1.16"
4
4
  description = "一个用于 NoneBot2 的网页控制台插件,支持通过浏览器查看日志和发送消息"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9"