nonebot-plugin-shiro-web-console 0.1.0__py3-none-any.whl → 0.1.5__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.
- nonebot_plugin_shiro_web_console/__init__.py +15 -7
- nonebot_plugin_shiro_web_console/config.py +8 -0
- {nonebot_plugin_shiro_web_console-0.1.0.dist-info → nonebot_plugin_shiro_web_console-0.1.5.dist-info}/METADATA +3 -1
- nonebot_plugin_shiro_web_console-0.1.5.dist-info/RECORD +7 -0
- nonebot_plugin_shiro_web_console-0.1.0.dist-info/RECORD +0 -6
- {nonebot_plugin_shiro_web_console-0.1.0.dist-info → nonebot_plugin_shiro_web_console-0.1.5.dist-info}/WHEEL +0 -0
- {nonebot_plugin_shiro_web_console-0.1.0.dist-info → nonebot_plugin_shiro_web_console-0.1.5.dist-info}/licenses/LICENSE +0 -0
|
@@ -13,7 +13,10 @@ from collections import deque
|
|
|
13
13
|
from fastapi import FastAPI, WebSocket, WebSocketDisconnect, Request, Response, Depends, HTTPException
|
|
14
14
|
from fastapi.staticfiles import StaticFiles
|
|
15
15
|
from fastapi.responses import HTMLResponse, JSONResponse, FileResponse
|
|
16
|
-
from nonebot import get_app, get_bot, get_driver, logger, on_message, on_command
|
|
16
|
+
from nonebot import get_app, get_bot, get_driver, logger, on_message, on_command, require
|
|
17
|
+
require("nonebot_plugin_localstore")
|
|
18
|
+
import nonebot_plugin_localstore
|
|
19
|
+
from .config import Config, config
|
|
17
20
|
from nonebot.permission import SUPERUSER
|
|
18
21
|
from nonebot.adapters.onebot.v11 import Bot, MessageEvent, GroupMessageEvent, PrivateMessageEvent, MessageSegment
|
|
19
22
|
from nonebot.plugin import PluginMetadata
|
|
@@ -22,12 +25,13 @@ __plugin_meta__ = PluginMetadata(
|
|
|
22
25
|
name="Shiro Web Console",
|
|
23
26
|
description="通过浏览器查看日志、管理机器人并发送消息",
|
|
24
27
|
usage="访问 /web_console 查看,在机器人聊天框发送“web控制台”获取登录码",
|
|
25
|
-
type="
|
|
28
|
+
type="application",
|
|
26
29
|
homepage="https://github.com/luojisama/nonebot-plugin-shiro-web-console",
|
|
30
|
+
config=Config,
|
|
27
31
|
supported_adapters={"~onebot.v11"},
|
|
28
32
|
extra={
|
|
29
33
|
"author": "luojisama",
|
|
30
|
-
"version": "0.1.
|
|
34
|
+
"version": "0.1.5",
|
|
31
35
|
"pypi_test": "nonebot-plugin-shiro-web-console",
|
|
32
36
|
},
|
|
33
37
|
)
|
|
@@ -55,8 +59,7 @@ class AuthManager:
|
|
|
55
59
|
self.token_expire: Optional[datetime] = None
|
|
56
60
|
|
|
57
61
|
# 密码持久化文件路径
|
|
58
|
-
self.data_dir =
|
|
59
|
-
self.data_dir.mkdir(exist_ok=True)
|
|
62
|
+
self.data_dir = nonebot_plugin_localstore.get_plugin_data_dir()
|
|
60
63
|
self.password_file = self.data_dir / "password.json"
|
|
61
64
|
|
|
62
65
|
# 初始加载密码
|
|
@@ -69,7 +72,7 @@ class AuthManager:
|
|
|
69
72
|
return data.get("password", "admin123")
|
|
70
73
|
except:
|
|
71
74
|
pass
|
|
72
|
-
return
|
|
75
|
+
return config.web_console_password
|
|
73
76
|
|
|
74
77
|
def save_password(self, new_password: str):
|
|
75
78
|
self.admin_password = new_password
|
|
@@ -122,7 +125,12 @@ async def check_auth(request: Request):
|
|
|
122
125
|
raise HTTPException(status_code=401, detail="Unauthorized")
|
|
123
126
|
return True
|
|
124
127
|
|
|
125
|
-
|
|
128
|
+
try:
|
|
129
|
+
app: FastAPI = get_app()
|
|
130
|
+
except ValueError:
|
|
131
|
+
app = FastAPI()
|
|
132
|
+
logger.warning("FastAPI app not found, created a new one. This might happen during plugin test.")
|
|
133
|
+
|
|
126
134
|
static_path = Path(__file__).parent / "static"
|
|
127
135
|
index_html = static_path / "index.html"
|
|
128
136
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nonebot-plugin-shiro-web-console
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
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
|
|
@@ -24,7 +24,9 @@ Requires-Dist: fastapi>=0.95.0
|
|
|
24
24
|
Requires-Dist: httpx>=0.23.0
|
|
25
25
|
Requires-Dist: jinja2>=3.1.0
|
|
26
26
|
Requires-Dist: nonebot-adapter-onebot>=2.4.0
|
|
27
|
+
Requires-Dist: nonebot-plugin-localstore>=0.6.0
|
|
27
28
|
Requires-Dist: nonebot2>=2.2.0
|
|
29
|
+
Requires-Dist: pydantic
|
|
28
30
|
Requires-Dist: uvicorn>=0.20.0
|
|
29
31
|
Description-Content-Type: text/markdown
|
|
30
32
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
nonebot_plugin_shiro_web_console/__init__.py,sha256=HGNaL_ImvssgoH96gcJKDsAqizcLYmshn-OW-HIt6qQ,31507
|
|
2
|
+
nonebot_plugin_shiro_web_console/config.py,sha256=LqHht8N5CuSMyBbEjzyJgfZtg05cvBlpGn_2MgTjt-g,202
|
|
3
|
+
nonebot_plugin_shiro_web_console/static/index.html,sha256=YFQ4e0WsfWYHQ01pD0Xify-CFCcnKE9mXDG6vQimU4s,78428
|
|
4
|
+
nonebot_plugin_shiro_web_console-0.1.5.dist-info/METADATA,sha256=uBu8UzEhMILhUi8bR-BdEwgu94hYMOT2MNqIDdP7WxU,2010
|
|
5
|
+
nonebot_plugin_shiro_web_console-0.1.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
+
nonebot_plugin_shiro_web_console-0.1.5.dist-info/licenses/LICENSE,sha256=WedEfsrQQfoZsmbJHIAPn4UY_IcpavYULMV5in_ZPbg,1066
|
|
7
|
+
nonebot_plugin_shiro_web_console-0.1.5.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
nonebot_plugin_shiro_web_console/__init__.py,sha256=9CBXKUq98cujB1g3N0rEw302TNoVqF67FHKX86y9Kf0,31278
|
|
2
|
-
nonebot_plugin_shiro_web_console/static/index.html,sha256=YFQ4e0WsfWYHQ01pD0Xify-CFCcnKE9mXDG6vQimU4s,78428
|
|
3
|
-
nonebot_plugin_shiro_web_console-0.1.0.dist-info/METADATA,sha256=KlzGn4NfcRYZ-x7DNpzYPPcAsx0dCcrgXlre1K-j4jk,1938
|
|
4
|
-
nonebot_plugin_shiro_web_console-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
5
|
-
nonebot_plugin_shiro_web_console-0.1.0.dist-info/licenses/LICENSE,sha256=WedEfsrQQfoZsmbJHIAPn4UY_IcpavYULMV5in_ZPbg,1066
|
|
6
|
-
nonebot_plugin_shiro_web_console-0.1.0.dist-info/RECORD,,
|
|
File without changes
|