nonebot-plugin-l4d2-server 0.5.0__py3-none-any.whl → 0.5.2__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.
- LICENSE +674 -674
- README.md +365 -349
- nonebot_plugin_l4d2_server/__init__.py +1 -1
- nonebot_plugin_l4d2_server/chrome.py +45 -0
- nonebot_plugin_l4d2_server/command.py +232 -233
- nonebot_plugin_l4d2_server/config.py +210 -318
- nonebot_plugin_l4d2_server/data/L4D2/image/template/anne.html +60 -60
- nonebot_plugin_l4d2_server/data/L4D2/image/template/fingerprint.svg +15 -15
- nonebot_plugin_l4d2_server/data/L4D2/image/template/help.html +233 -233
- nonebot_plugin_l4d2_server/data/L4D2/image/template/help_dack.html +231 -231
- nonebot_plugin_l4d2_server/data/L4D2/image/template/ip.html +48 -48
- nonebot_plugin_l4d2_server/data/L4D2/image/template/l.svg +9 -9
- nonebot_plugin_l4d2_server/data/L4D2/image/template/vue.css +530 -530
- nonebot_plugin_l4d2_server/l4d2_anne/__init__.py +251 -251
- nonebot_plugin_l4d2_server/l4d2_anne/analysis.py +51 -51
- nonebot_plugin_l4d2_server/l4d2_anne/anne_telecom.py +75 -75
- nonebot_plugin_l4d2_server/l4d2_anne/server.py +65 -65
- nonebot_plugin_l4d2_server/l4d2_anne/startand.py +17 -17
- nonebot_plugin_l4d2_server/l4d2_data/__init__.py +91 -91
- nonebot_plugin_l4d2_server/l4d2_data/config.py +17 -17
- nonebot_plugin_l4d2_server/l4d2_data/players.py +87 -87
- nonebot_plugin_l4d2_server/l4d2_data/serverip.py +32 -32
- nonebot_plugin_l4d2_server/l4d2_file/__init__.py +122 -122
- nonebot_plugin_l4d2_server/l4d2_file/ayromote.py +56 -56
- nonebot_plugin_l4d2_server/l4d2_file/remote.py +63 -66
- nonebot_plugin_l4d2_server/l4d2_image/__init__.py +103 -103
- nonebot_plugin_l4d2_server/l4d2_image/download.py +101 -101
- nonebot_plugin_l4d2_server/l4d2_image/htmlimg.py +32 -32
- nonebot_plugin_l4d2_server/l4d2_image/send_image_tool.py +32 -32
- nonebot_plugin_l4d2_server/l4d2_image/steam.py +83 -83
- nonebot_plugin_l4d2_server/l4d2_image/vtfs.py +40 -40
- nonebot_plugin_l4d2_server/l4d2_queries/__init__.py +114 -114
- nonebot_plugin_l4d2_server/l4d2_queries/api.py +43 -43
- nonebot_plugin_l4d2_server/l4d2_queries/ohter.py +35 -25
- nonebot_plugin_l4d2_server/l4d2_queries/qqgroup.py +288 -288
- nonebot_plugin_l4d2_server/l4d2_server/__init__.py +61 -61
- nonebot_plugin_l4d2_server/l4d2_server/rcon.py +28 -28
- nonebot_plugin_l4d2_server/l4d2_server/workshop.py +50 -50
- nonebot_plugin_l4d2_server/l4d2_web/web.py +234 -234
- nonebot_plugin_l4d2_server/l4d2_web/webUI.py +241 -241
- nonebot_plugin_l4d2_server/message.py +58 -58
- nonebot_plugin_l4d2_server/seach.py +33 -33
- nonebot_plugin_l4d2_server/txt_to_img.py +64 -64
- nonebot_plugin_l4d2_server/utils.py +272 -272
- {nonebot_plugin_l4d2_server-0.5.0.dist-info → nonebot_plugin_l4d2_server-0.5.2.dist-info}/LICENSE +674 -674
- {nonebot_plugin_l4d2_server-0.5.0.dist-info → nonebot_plugin_l4d2_server-0.5.2.dist-info}/METADATA +47 -32
- nonebot_plugin_l4d2_server-0.5.2.dist-info/RECORD +54 -0
- nonebot_plugin_l4d2_server-0.5.0.dist-info/RECORD +0 -53
- {nonebot_plugin_l4d2_server-0.5.0.dist-info → nonebot_plugin_l4d2_server-0.5.2.dist-info}/WHEEL +0 -0
@@ -1,234 +1,234 @@
|
|
1
|
-
import datetime
|
2
|
-
from typing import Optional, Union
|
3
|
-
|
4
|
-
from fastapi import FastAPI
|
5
|
-
from fastapi import Header, HTTPException, Depends
|
6
|
-
from fastapi.responses import JSONResponse, HTMLResponse, RedirectResponse
|
7
|
-
from jose import jwt
|
8
|
-
from nonebot import get_bot, get_app
|
9
|
-
|
10
|
-
from pathlib import Path
|
11
|
-
|
12
|
-
from nonebot import get_driver, logger
|
13
|
-
from ..config import *
|
14
|
-
from ..utils import split_maohao
|
15
|
-
from ..l4d2_queries.qqgroup import qq_ip_querie
|
16
|
-
CONFIG_PATH = Path() / 'data' / 'L4D2' / 'l4d2.yml'
|
17
|
-
|
18
|
-
CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True)
|
19
|
-
|
20
|
-
driver = get_driver()
|
21
|
-
|
22
|
-
from .webUI import login_page, admin_app
|
23
|
-
|
24
|
-
requestAdaptor = '''
|
25
|
-
requestAdaptor(api) {
|
26
|
-
api.headers["token"] = localStorage.getItem("token");
|
27
|
-
return api;
|
28
|
-
},
|
29
|
-
'''
|
30
|
-
responseAdaptor = '''
|
31
|
-
responseAdaptor(api, payload, query, request, response) {
|
32
|
-
if (response.data.detail == '登录验证失败或已失效,请重新登录') {
|
33
|
-
window.location.href = '/l4d2/login'
|
34
|
-
window.localStorage.clear()
|
35
|
-
window.sessionStorage.clear()
|
36
|
-
window.alert('登录验证失败或已失效,请重新登录')
|
37
|
-
}
|
38
|
-
return payload
|
39
|
-
},
|
40
|
-
'''
|
41
|
-
|
42
|
-
|
43
|
-
def authentication():
|
44
|
-
def inner(token: Optional[str] = Header(...)):
|
45
|
-
try:
|
46
|
-
payload = jwt.decode(token, config_manager.config.web_secret_key, algorithms='HS256')
|
47
|
-
if not (username := payload.get('username')) or username != config_manager.config.web_username:
|
48
|
-
raise HTTPException(status_code=400, detail='登录验证失败或已失效,请重新登录')
|
49
|
-
except (jwt.JWTError, jwt.ExpiredSignatureError, AttributeError):
|
50
|
-
raise HTTPException(status_code=400, detail='登录验证失败或已失效,请重新登录')
|
51
|
-
|
52
|
-
return Depends(inner)
|
53
|
-
|
54
|
-
|
55
|
-
COMMAND_START = driver.config.command_start.copy()
|
56
|
-
if '' in COMMAND_START:
|
57
|
-
COMMAND_START.remove('')
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
@driver.on_startup
|
64
|
-
async def init_web():
|
65
|
-
if not config_manager.config.total_enable:
|
66
|
-
return
|
67
|
-
app: FastAPI = get_app()
|
68
|
-
logger.success('成功加载网页控制台')
|
69
|
-
@app.post('/l4d2/api/login', response_class=JSONResponse)
|
70
|
-
async def login(user: UserModel):
|
71
|
-
if user.username != config_manager.config.web_username or user.password != config_manager.config.web_password:
|
72
|
-
return {
|
73
|
-
'status': -100,
|
74
|
-
'msg': '登录失败,请确认用户ID和密码无误'
|
75
|
-
}
|
76
|
-
token = jwt.encode({'username': user.username,
|
77
|
-
'exp': datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(
|
78
|
-
minutes=30)}, config_manager.config.web_secret_key, algorithm='HS256')
|
79
|
-
return {
|
80
|
-
'status': 0,
|
81
|
-
'msg': '登录成功',
|
82
|
-
'data': {
|
83
|
-
'token': token
|
84
|
-
}
|
85
|
-
}
|
86
|
-
|
87
|
-
@app.get('/l4d2/api/get_group_list', response_class=JSONResponse, dependencies=[authentication()])
|
88
|
-
async def get_group_list_api():
|
89
|
-
try:
|
90
|
-
group_list = await get_bot().get_group_list()
|
91
|
-
group_list = [{'label': f'{group["group_name"]}({group["group_id"]})', 'value': group['group_id']} for group
|
92
|
-
in group_list]
|
93
|
-
return {
|
94
|
-
'status': 0,
|
95
|
-
'msg': 'ok',
|
96
|
-
'data': {
|
97
|
-
'group_list': group_list
|
98
|
-
}
|
99
|
-
}
|
100
|
-
except ValueError:
|
101
|
-
return {
|
102
|
-
'status': -100,
|
103
|
-
'msg': '获取群和好友列表失败,请确认已连接GOCQ'
|
104
|
-
}
|
105
|
-
|
106
|
-
@app.post('/l4d2/api/l4d2_global_config', response_class=JSONResponse, dependencies=[authentication()])
|
107
|
-
async def post_l4d2_global_config(data: dict):
|
108
|
-
config_manager.config.update(**data)
|
109
|
-
config_manager.save()
|
110
|
-
return {
|
111
|
-
'status': 0,
|
112
|
-
'msg': '保存成功'
|
113
|
-
}
|
114
|
-
|
115
|
-
@app.get('/l4d2/api/l4d2_global_config', response_class=JSONResponse, dependencies=[authentication()])
|
116
|
-
async def get_l4d2_global_config():
|
117
|
-
try:
|
118
|
-
bot = get_bot()
|
119
|
-
groups = await bot.get_group_list()
|
120
|
-
member_list = []
|
121
|
-
for group in groups:
|
122
|
-
members = await bot.get_group_member_list(group_id=group['group_id'])
|
123
|
-
member_list.extend(
|
124
|
-
[{'label': f'{member["nickname"] or member["card"]}({member["user_id"]})',
|
125
|
-
'value': member['user_id']}
|
126
|
-
for
|
127
|
-
member in members])
|
128
|
-
config = config_manager.config.dict(exclude={'group_config'})
|
129
|
-
config['member_list'] = member_list
|
130
|
-
config['l4_styles'] = ['standard','black']
|
131
|
-
|
132
|
-
return config
|
133
|
-
except ValueError:
|
134
|
-
return {
|
135
|
-
'status': -100,
|
136
|
-
'msg': '获取群和好友列表失败,请确认已连接GOCQ'
|
137
|
-
}
|
138
|
-
|
139
|
-
@app.get('/l4d2/api/get_query_contexts', response_class=JSONResponse, dependencies=[authentication()])
|
140
|
-
async def get_query_context():
|
141
|
-
try:
|
142
|
-
from ..command import ALL_HOST
|
143
|
-
this_ips = ALL_HOST
|
144
|
-
ip_lists = []
|
145
|
-
for ip_list, v in this_ips.items():
|
146
|
-
for d in v:
|
147
|
-
host, port = split_maohao(d['ip'])
|
148
|
-
ip_lists.append((d['id'], ip_list, host, port))
|
149
|
-
data_dict = await qq_ip_querie(ip_lists)
|
150
|
-
if not data_dict:
|
151
|
-
return{
|
152
|
-
'status': -100,
|
153
|
-
'msg': '返回失败,请确保有可用的服务器ip'
|
154
|
-
}
|
155
|
-
data_list = data_dict['msg_list']
|
156
|
-
return {
|
157
|
-
'status': 0,
|
158
|
-
'msg': 'ok',
|
159
|
-
'data': {
|
160
|
-
'items': data_list,
|
161
|
-
'total': len(data_list),
|
162
|
-
}
|
163
|
-
}
|
164
|
-
except ValueError:
|
165
|
-
return {
|
166
|
-
'status': -100,
|
167
|
-
'msg': '返回失败,请确保网络连接正常'
|
168
|
-
}
|
169
|
-
|
170
|
-
@app.get('/l4d2/api/get_l4d2_messages', response_class=JSONResponse, dependencies=[authentication()])
|
171
|
-
async def get_l4d2_messages():
|
172
|
-
try:
|
173
|
-
l4_ipall = config_manager.config.l4_ipall
|
174
|
-
config = [{'label': item['server_id'] , 'value': item['id_rank']}
|
175
|
-
for item in l4_ipall]
|
176
|
-
return {
|
177
|
-
'status': 0,
|
178
|
-
'msg': 'ok',
|
179
|
-
'data': {'server_list':config}
|
180
|
-
}
|
181
|
-
except ValueError:
|
182
|
-
return {
|
183
|
-
'status': -100,
|
184
|
-
'msg': '返回失败,请确保网络连接正常'
|
185
|
-
}
|
186
|
-
@app.get('/l4d2/api/l4d2_server_config', response_class=JSONResponse, dependencies=[authentication()])
|
187
|
-
async def get_l4d2_server_config(id_rank :str):
|
188
|
-
try:
|
189
|
-
l4_ipall = config_manager.config.l4_ipall
|
190
|
-
config = {}
|
191
|
-
for item in l4_ipall:
|
192
|
-
if item['id_rank'] == id_rank :
|
193
|
-
item['place'] = item['place'] == 'True' or item['place'] == True
|
194
|
-
config = item
|
195
|
-
break
|
196
|
-
return {
|
197
|
-
'status': 0,
|
198
|
-
'msg': 'ok',
|
199
|
-
'data': config
|
200
|
-
}
|
201
|
-
except ValueError:
|
202
|
-
return {
|
203
|
-
'status': -100,
|
204
|
-
'msg': '返回失败,请确保网络连接正常'
|
205
|
-
}
|
206
|
-
|
207
|
-
@app.post('/l4d2/api/l4d2_server_config', response_class=JSONResponse, dependencies=[authentication()])
|
208
|
-
async def post_l4d2_server_config(id_rank :str,data: dict):
|
209
|
-
for one in config_manager.config.l4_ipall:
|
210
|
-
if one['id_rank']==id_rank:
|
211
|
-
one.update(**data)
|
212
|
-
config_manager.save()
|
213
|
-
return {
|
214
|
-
'status': 0,
|
215
|
-
'msg': '保存成功'
|
216
|
-
}
|
217
|
-
|
218
|
-
|
219
|
-
@app.get('/l4d2', response_class=RedirectResponse)
|
220
|
-
async def redirect_page():
|
221
|
-
return RedirectResponse('/l4d2/login')
|
222
|
-
|
223
|
-
@app.get('/l4d2/login', response_class=HTMLResponse)
|
224
|
-
async def login_page_app():
|
225
|
-
return login_page.render(site_title='登录 | l4d2 后台管理',
|
226
|
-
theme='ang')
|
227
|
-
|
228
|
-
@app.get('/l4d2/admin', response_class=HTMLResponse)
|
229
|
-
async def admin_page_app():
|
230
|
-
return admin_app.render(site_title='l4d2-l4d2 后台管理',
|
231
|
-
theme='ang',
|
232
|
-
requestAdaptor=requestAdaptor,
|
233
|
-
responseAdaptor=responseAdaptor)
|
234
|
-
|
1
|
+
import datetime
|
2
|
+
from typing import Optional, Union
|
3
|
+
|
4
|
+
from fastapi import FastAPI
|
5
|
+
from fastapi import Header, HTTPException, Depends
|
6
|
+
from fastapi.responses import JSONResponse, HTMLResponse, RedirectResponse
|
7
|
+
from jose import jwt
|
8
|
+
from nonebot import get_bot, get_app
|
9
|
+
|
10
|
+
from pathlib import Path
|
11
|
+
|
12
|
+
from nonebot import get_driver, logger
|
13
|
+
from ..config import *
|
14
|
+
from ..utils import split_maohao
|
15
|
+
from ..l4d2_queries.qqgroup import qq_ip_querie
|
16
|
+
CONFIG_PATH = Path() / 'data' / 'L4D2' / 'l4d2.yml'
|
17
|
+
|
18
|
+
CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True)
|
19
|
+
|
20
|
+
driver = get_driver()
|
21
|
+
|
22
|
+
from .webUI import login_page, admin_app
|
23
|
+
|
24
|
+
requestAdaptor = '''
|
25
|
+
requestAdaptor(api) {
|
26
|
+
api.headers["token"] = localStorage.getItem("token");
|
27
|
+
return api;
|
28
|
+
},
|
29
|
+
'''
|
30
|
+
responseAdaptor = '''
|
31
|
+
responseAdaptor(api, payload, query, request, response) {
|
32
|
+
if (response.data.detail == '登录验证失败或已失效,请重新登录') {
|
33
|
+
window.location.href = '/l4d2/login'
|
34
|
+
window.localStorage.clear()
|
35
|
+
window.sessionStorage.clear()
|
36
|
+
window.alert('登录验证失败或已失效,请重新登录')
|
37
|
+
}
|
38
|
+
return payload
|
39
|
+
},
|
40
|
+
'''
|
41
|
+
|
42
|
+
|
43
|
+
def authentication():
|
44
|
+
def inner(token: Optional[str] = Header(...)):
|
45
|
+
try:
|
46
|
+
payload = jwt.decode(token, config_manager.config.web_secret_key, algorithms='HS256')
|
47
|
+
if not (username := payload.get('username')) or username != config_manager.config.web_username:
|
48
|
+
raise HTTPException(status_code=400, detail='登录验证失败或已失效,请重新登录')
|
49
|
+
except (jwt.JWTError, jwt.ExpiredSignatureError, AttributeError):
|
50
|
+
raise HTTPException(status_code=400, detail='登录验证失败或已失效,请重新登录')
|
51
|
+
|
52
|
+
return Depends(inner)
|
53
|
+
|
54
|
+
|
55
|
+
COMMAND_START = driver.config.command_start.copy()
|
56
|
+
if '' in COMMAND_START:
|
57
|
+
COMMAND_START.remove('')
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
@driver.on_startup
|
64
|
+
async def init_web():
|
65
|
+
if not config_manager.config.total_enable:
|
66
|
+
return
|
67
|
+
app: FastAPI = get_app()
|
68
|
+
logger.success('成功加载网页控制台')
|
69
|
+
@app.post('/l4d2/api/login', response_class=JSONResponse)
|
70
|
+
async def login(user: UserModel):
|
71
|
+
if user.username != config_manager.config.web_username or user.password != config_manager.config.web_password:
|
72
|
+
return {
|
73
|
+
'status': -100,
|
74
|
+
'msg': '登录失败,请确认用户ID和密码无误'
|
75
|
+
}
|
76
|
+
token = jwt.encode({'username': user.username,
|
77
|
+
'exp': datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(
|
78
|
+
minutes=30)}, config_manager.config.web_secret_key, algorithm='HS256')
|
79
|
+
return {
|
80
|
+
'status': 0,
|
81
|
+
'msg': '登录成功',
|
82
|
+
'data': {
|
83
|
+
'token': token
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
@app.get('/l4d2/api/get_group_list', response_class=JSONResponse, dependencies=[authentication()])
|
88
|
+
async def get_group_list_api():
|
89
|
+
try:
|
90
|
+
group_list = await get_bot().get_group_list()
|
91
|
+
group_list = [{'label': f'{group["group_name"]}({group["group_id"]})', 'value': group['group_id']} for group
|
92
|
+
in group_list]
|
93
|
+
return {
|
94
|
+
'status': 0,
|
95
|
+
'msg': 'ok',
|
96
|
+
'data': {
|
97
|
+
'group_list': group_list
|
98
|
+
}
|
99
|
+
}
|
100
|
+
except ValueError:
|
101
|
+
return {
|
102
|
+
'status': -100,
|
103
|
+
'msg': '获取群和好友列表失败,请确认已连接GOCQ'
|
104
|
+
}
|
105
|
+
|
106
|
+
@app.post('/l4d2/api/l4d2_global_config', response_class=JSONResponse, dependencies=[authentication()])
|
107
|
+
async def post_l4d2_global_config(data: dict):
|
108
|
+
config_manager.config.update(**data)
|
109
|
+
config_manager.save()
|
110
|
+
return {
|
111
|
+
'status': 0,
|
112
|
+
'msg': '保存成功'
|
113
|
+
}
|
114
|
+
|
115
|
+
@app.get('/l4d2/api/l4d2_global_config', response_class=JSONResponse, dependencies=[authentication()])
|
116
|
+
async def get_l4d2_global_config():
|
117
|
+
try:
|
118
|
+
bot = get_bot()
|
119
|
+
groups = await bot.get_group_list()
|
120
|
+
member_list = []
|
121
|
+
for group in groups:
|
122
|
+
members = await bot.get_group_member_list(group_id=group['group_id'])
|
123
|
+
member_list.extend(
|
124
|
+
[{'label': f'{member["nickname"] or member["card"]}({member["user_id"]})',
|
125
|
+
'value': member['user_id']}
|
126
|
+
for
|
127
|
+
member in members])
|
128
|
+
config = config_manager.config.dict(exclude={'group_config'})
|
129
|
+
config['member_list'] = member_list
|
130
|
+
config['l4_styles'] = ['standard','black']
|
131
|
+
|
132
|
+
return config
|
133
|
+
except ValueError:
|
134
|
+
return {
|
135
|
+
'status': -100,
|
136
|
+
'msg': '获取群和好友列表失败,请确认已连接GOCQ'
|
137
|
+
}
|
138
|
+
|
139
|
+
@app.get('/l4d2/api/get_query_contexts', response_class=JSONResponse, dependencies=[authentication()])
|
140
|
+
async def get_query_context():
|
141
|
+
try:
|
142
|
+
from ..command import ALL_HOST
|
143
|
+
this_ips = ALL_HOST
|
144
|
+
ip_lists = []
|
145
|
+
for ip_list, v in this_ips.items():
|
146
|
+
for d in v:
|
147
|
+
host, port = split_maohao(d['ip'])
|
148
|
+
ip_lists.append((d['id'], ip_list, host, port))
|
149
|
+
data_dict = await qq_ip_querie(ip_lists)
|
150
|
+
if not data_dict:
|
151
|
+
return{
|
152
|
+
'status': -100,
|
153
|
+
'msg': '返回失败,请确保有可用的服务器ip'
|
154
|
+
}
|
155
|
+
data_list = data_dict['msg_list']
|
156
|
+
return {
|
157
|
+
'status': 0,
|
158
|
+
'msg': 'ok',
|
159
|
+
'data': {
|
160
|
+
'items': data_list,
|
161
|
+
'total': len(data_list),
|
162
|
+
}
|
163
|
+
}
|
164
|
+
except ValueError:
|
165
|
+
return {
|
166
|
+
'status': -100,
|
167
|
+
'msg': '返回失败,请确保网络连接正常'
|
168
|
+
}
|
169
|
+
|
170
|
+
@app.get('/l4d2/api/get_l4d2_messages', response_class=JSONResponse, dependencies=[authentication()])
|
171
|
+
async def get_l4d2_messages():
|
172
|
+
try:
|
173
|
+
l4_ipall = config_manager.config.l4_ipall
|
174
|
+
config = [{'label': item['server_id'] , 'value': item['id_rank']}
|
175
|
+
for item in l4_ipall]
|
176
|
+
return {
|
177
|
+
'status': 0,
|
178
|
+
'msg': 'ok',
|
179
|
+
'data': {'server_list':config}
|
180
|
+
}
|
181
|
+
except ValueError:
|
182
|
+
return {
|
183
|
+
'status': -100,
|
184
|
+
'msg': '返回失败,请确保网络连接正常'
|
185
|
+
}
|
186
|
+
@app.get('/l4d2/api/l4d2_server_config', response_class=JSONResponse, dependencies=[authentication()])
|
187
|
+
async def get_l4d2_server_config(id_rank :str):
|
188
|
+
try:
|
189
|
+
l4_ipall = config_manager.config.l4_ipall
|
190
|
+
config = {}
|
191
|
+
for item in l4_ipall:
|
192
|
+
if item['id_rank'] == id_rank :
|
193
|
+
item['place'] = item['place'] == 'True' or item['place'] == True
|
194
|
+
config = item
|
195
|
+
break
|
196
|
+
return {
|
197
|
+
'status': 0,
|
198
|
+
'msg': 'ok',
|
199
|
+
'data': config
|
200
|
+
}
|
201
|
+
except ValueError:
|
202
|
+
return {
|
203
|
+
'status': -100,
|
204
|
+
'msg': '返回失败,请确保网络连接正常'
|
205
|
+
}
|
206
|
+
|
207
|
+
@app.post('/l4d2/api/l4d2_server_config', response_class=JSONResponse, dependencies=[authentication()])
|
208
|
+
async def post_l4d2_server_config(id_rank :str,data: dict):
|
209
|
+
for one in config_manager.config.l4_ipall:
|
210
|
+
if one['id_rank']==id_rank:
|
211
|
+
one.update(**data)
|
212
|
+
config_manager.save()
|
213
|
+
return {
|
214
|
+
'status': 0,
|
215
|
+
'msg': '保存成功'
|
216
|
+
}
|
217
|
+
|
218
|
+
|
219
|
+
@app.get('/l4d2', response_class=RedirectResponse)
|
220
|
+
async def redirect_page():
|
221
|
+
return RedirectResponse('/l4d2/login')
|
222
|
+
|
223
|
+
@app.get('/l4d2/login', response_class=HTMLResponse)
|
224
|
+
async def login_page_app():
|
225
|
+
return login_page.render(site_title='登录 | l4d2 后台管理',
|
226
|
+
theme='ang')
|
227
|
+
|
228
|
+
@app.get('/l4d2/admin', response_class=HTMLResponse)
|
229
|
+
async def admin_page_app():
|
230
|
+
return admin_app.render(site_title='l4d2-l4d2 后台管理',
|
231
|
+
theme='ang',
|
232
|
+
requestAdaptor=requestAdaptor,
|
233
|
+
responseAdaptor=responseAdaptor)
|
234
|
+
|