nonebot-plugin-l4d2-server 1.0.1__tar.gz → 1.0.3__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.
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/PKG-INFO +8 -3
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/__main__.py +56 -34
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/config.py +4 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/__init__.py +1 -1
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_local/__init__.py +3 -1
- nonebot_plugin_l4d2_server-1.0.3/nonebot_plugin_l4d2_server/l4_request/__init__.py +283 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_request/draw_msg.py +7 -1
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/utils/api/request.py +33 -9
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/pyproject.toml +15 -4
- nonebot_plugin_l4d2_server-1.0.1/nonebot_plugin_l4d2_server/l4_request/__init__.py +0 -209
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/LICENSE +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/README.md +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/__init__.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/data/font/loli.ttf +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_anne/__init__.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_anne/ranne.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/Help.json +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/draw.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//344/273/213/347/273/215.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//344/273/273/345/212/241.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//344/277/241/346/201/257.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//345/205/254/345/221/212.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//345/210/200/345/211/221.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//345/210/207/346/215/242.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//345/210/240/351/231/244.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//345/210/267/346/226/260.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//345/215/241/347/273/204.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//345/223/252/351/207/214.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//345/234/260/345/233/276.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/205/245.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/207/272.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//345/275/261.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//346/213/274/345/233/276.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//346/216/242/347/264/242.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//346/216/250/351/200/201.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//346/224/266/351/233/206.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//346/224/273/347/225/245.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//346/233/264/346/226/260.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//346/235/220/346/226/231.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//346/237/245/350/257/242.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//346/240/241/351/252/214.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//346/257/217/346/234/210.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//346/267/261/346/270/212.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//346/267/273/345/212/240.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//346/270/205/351/231/244.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//347/212/266/346/200/201.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//347/255/276/345/210/260.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//347/273/221/345/256/232.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//350/241/250.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//350/241/250/346/203/205.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//350/247/222/350/211/262.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//350/256/260/345/275/225.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//351/205/215/347/275/256.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/icon//351/207/215/345/220/257.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/texture2d/badge.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/texture2d/banner.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/texture2d/bg.jpg +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/texture2d/button.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_help/texture2d/icon.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/__init__.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/anne_pil.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/convert.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/download.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/html_img.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/image_tools.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/anne/anne.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/anne/back.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/anne/back1.jpg +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/anne/group_ip.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/anne/ip.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/head/head.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/header/logo.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/header/player1.jpg +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/HYPixel11pxU-2.ttf +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/Tutumianhuatang-Bold-2.ttf +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/bilibili.svg +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/fingerprint.svg +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/github.svg +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/l.svg +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/m.svg +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/normal.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/vac.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/vac_white.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/vue.css +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/img/template/w.svg +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/model.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_image/vtfs.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_local/file.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/l4_request/utils.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/utils/api/api.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/utils/api/models.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/utils/database/models.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.1 → nonebot_plugin_l4d2_server-1.0.3}/nonebot_plugin_l4d2_server/utils/utils.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nonebot-plugin-l4d2-server
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.3
|
4
4
|
Summary: L4D2 server related operations plugin for NoneBot2
|
5
5
|
Keywords: steam,game,l4d2,nonebot2,plugin
|
6
6
|
Author-Email: Agnes_Digital <Z735803792@163.com>
|
@@ -11,10 +11,12 @@ Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.9
|
12
12
|
Classifier: Programming Language :: Python :: 3.10
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
14
15
|
Classifier: Operating System :: OS Independent
|
15
16
|
Project-URL: homepage, https://github.com/Agnes4m/nonebot_plugin_l4d2_server
|
16
17
|
Requires-Python: <4.0,>=3.9
|
17
18
|
Requires-Dist: nonebot2>=2.0.0
|
19
|
+
Requires-Dist: nonebot2[fastapi]>=2.3.3
|
18
20
|
Requires-Dist: nonebot-plugin-htmlrender>=0.3.0
|
19
21
|
Requires-Dist: nonebot-adapter-onebot>=2.4.4
|
20
22
|
Requires-Dist: nonebot-plugin-alconna>=0.50.0
|
@@ -25,12 +27,15 @@ Requires-Dist: jinja2>=3.0.0
|
|
25
27
|
Requires-Dist: srctools>=2.3.9
|
26
28
|
Requires-Dist: httpx<0.24.1,>=0.22.0
|
27
29
|
Requires-Dist: msgspec>=0.18.0
|
28
|
-
Requires-Dist: python-a2s>=1.
|
30
|
+
Requires-Dist: python-a2s>=1.4.1
|
29
31
|
Requires-Dist: ujson>=5.10.0
|
30
32
|
Requires-Dist: lxml>=5.2.2
|
31
33
|
Requires-Dist: rcon>=2.1.0
|
32
|
-
Requires-Dist: pillow>
|
34
|
+
Requires-Dist: pillow>10
|
33
35
|
Requires-Dist: beautifulsoup4>=4.12.3
|
36
|
+
Requires-Dist: rarfile>=4.2
|
37
|
+
Requires-Dist: pyunpack>=0.3
|
38
|
+
Requires-Dist: aiofiles>=24.1.0
|
34
39
|
Description-Content-Type: text/markdown
|
35
40
|
|
36
41
|
<!-- markdownlint-disable MD026 MD031 MD033 MD036 MD041 MD046 MD051 -->
|
@@ -18,6 +18,7 @@
|
|
18
18
|
from pathlib import Path
|
19
19
|
from typing import TYPE_CHECKING, List, Optional
|
20
20
|
|
21
|
+
import aiofiles
|
21
22
|
import ujson as json
|
22
23
|
from nonebot.adapters import Message
|
23
24
|
from nonebot.log import logger
|
@@ -35,7 +36,7 @@ from .l4_request import (
|
|
35
36
|
get_ip_server,
|
36
37
|
get_server_detail,
|
37
38
|
reload_ip,
|
38
|
-
tj_request
|
39
|
+
tj_request,
|
39
40
|
)
|
40
41
|
from .utils.api.request import L4API
|
41
42
|
|
@@ -54,6 +55,8 @@ l4_find_player = on_command("l4find", aliases={"l4查找"})
|
|
54
55
|
ld_tj = on_command("tj", aliases={"探监"})
|
55
56
|
ld_zl = on_command("zl")
|
56
57
|
ld_kl = on_command("kl")
|
58
|
+
config_path = Path(config.l4_path) / "config.json"
|
59
|
+
|
57
60
|
|
58
61
|
@l4_help.handle()
|
59
62
|
async def _(matcher: Matcher):
|
@@ -102,17 +105,27 @@ async def _(
|
|
102
105
|
async def _(
|
103
106
|
args: Message = CommandArg(),
|
104
107
|
):
|
108
|
+
# 以后有时间补img格式
|
105
109
|
msg: str = args.extract_plain_text().strip()
|
106
110
|
tag_list: List[str] = msg.split(" ", maxsplit=1)
|
107
|
-
if len(tag_list)
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
111
|
+
if len(tag_list) == 1:
|
112
|
+
await UniMessage.text("未设置组,正在全服查找,时间较长").send()
|
113
|
+
name = tag_list[0]
|
114
|
+
out: List[OutServer] = await get_server_detail(is_img=False) # type: ignore
|
115
|
+
out_msg = "未找到玩家"
|
116
|
+
for one in out:
|
117
|
+
for player in one["player"]:
|
118
|
+
if name in player.name:
|
119
|
+
out_msg = await get_ip_server(f"{one['host']}:{one['port']}")
|
120
|
+
if len(tag_list) == 2:
|
121
|
+
group, name = tag_list
|
122
|
+
await UniMessage.text(f"正在查询{group}组").send()
|
123
|
+
out: List[OutServer] = await get_server_detail(group, is_img=False) # type: ignore
|
124
|
+
out_msg = "未找到玩家"
|
125
|
+
for one in out:
|
126
|
+
for player in one["player"]:
|
127
|
+
if name in player.name:
|
128
|
+
out_msg = await get_ip_server(f"{one['host']}:{one['port']}")
|
116
129
|
|
117
130
|
return await UniMessage.text(out_msg).finish()
|
118
131
|
|
@@ -149,18 +162,18 @@ async def _(args: Message = CommandArg()):
|
|
149
162
|
logger.info(f"重载{tag}的ip")
|
150
163
|
await L4API.get_sourceban(tag, url)
|
151
164
|
await UniMessage.text("重载ip完成").finish()
|
152
|
-
|
165
|
+
|
153
166
|
|
154
167
|
l4_add_ban = on_command("l4addban", aliases={"l4添加ban"})
|
168
|
+
|
169
|
+
|
155
170
|
@l4_add_ban.handle()
|
156
171
|
async def _(args: Message = CommandArg()):
|
157
172
|
arg = args.extract_plain_text().strip().split(" ")
|
158
|
-
|
173
|
+
|
159
174
|
if len(arg) != 2:
|
160
175
|
await UniMessage.text("请在命令后增加响应指令名和网址").finish()
|
161
|
-
|
162
|
-
config_path = Path(config.l4_path) / "config.json"
|
163
|
-
|
176
|
+
|
164
177
|
if not config_path.is_file():
|
165
178
|
config_data = {}
|
166
179
|
else:
|
@@ -169,61 +182,70 @@ async def _(args: Message = CommandArg()):
|
|
169
182
|
config_data = json.load(f)
|
170
183
|
except (json.JSONDecodeError, FileNotFoundError):
|
171
184
|
config_data = {}
|
172
|
-
|
185
|
+
|
173
186
|
config_data.update({arg[0]: arg[1]})
|
174
|
-
|
187
|
+
|
175
188
|
try:
|
176
189
|
with config_path.open("w") as f:
|
177
190
|
json.dump(config_data, f, ensure_ascii=False, indent=4)
|
178
191
|
except IOError as e:
|
179
192
|
await UniMessage.text(f"文件写入失败: {e}").finish()
|
180
|
-
|
193
|
+
|
181
194
|
await L4API.get_sourceban(arg[0], arg[1])
|
182
195
|
await UniMessage.text(f"添加成功\n组名: {arg[0]}\n网址: {arg[1]}").finish()
|
183
|
-
|
196
|
+
|
184
197
|
|
185
198
|
l4_del_ban = on_command("l4delban", aliases={"l4删除ban", "l4移除ban"})
|
199
|
+
|
200
|
+
|
186
201
|
@l4_del_ban.handle()
|
187
|
-
async def _(args: Message = CommandArg()):
|
202
|
+
async def _(args: Message = CommandArg()):
|
188
203
|
arg = args.extract_plain_text().strip().split(" ")
|
189
|
-
if
|
204
|
+
if len(arg) not in [1, 2]:
|
190
205
|
await UniMessage.text("请在命令后增加响应指令名或者带响应网址").finish()
|
191
206
|
elif len(arg) == 1:
|
192
207
|
if not Path(Path(config.l4_path) / "config.json").is_file():
|
193
208
|
await UniMessage.text("没有添加过组名").finish()
|
194
209
|
else:
|
195
|
-
with (Path(config.l4_path) / "config.json").open(
|
210
|
+
with (Path(config.l4_path) / "config.json").open(
|
211
|
+
"r",
|
212
|
+
encoding="utf-8",
|
213
|
+
) as f:
|
196
214
|
content = f.read().strip()
|
197
|
-
config_data = json.loads(content)
|
215
|
+
config_data = json.loads(content)
|
198
216
|
if arg[0] not in config_data:
|
199
217
|
await UniMessage.text("没有添加过这个组").finish()
|
200
218
|
else:
|
201
219
|
del config_data[arg[0]]
|
202
|
-
|
203
|
-
|
204
|
-
|
220
|
+
async with aiofiles.open(config_path, "w", encoding="utf-8") as f:
|
221
|
+
json.dump(config_data, f, ensure_ascii=False, indent=4)
|
222
|
+
await UniMessage.text(f"删除成功,组名:{arg[0]}").finish()
|
205
223
|
elif len(arg) == 2:
|
206
224
|
if not Path(Path(config.l4_path) / "config.json").is_file():
|
207
225
|
await UniMessage.text("没有添加过组名").finish()
|
208
226
|
else:
|
209
|
-
with (Path(config.l4_path) / "config.json").open(
|
227
|
+
with (Path(config.l4_path) / "config.json").open(
|
228
|
+
"r",
|
229
|
+
encoding="utf-8",
|
230
|
+
) as f:
|
210
231
|
content = f.read().strip()
|
211
232
|
config_datas = json.loads(content)
|
212
233
|
if arg[0] not in config_datas:
|
213
234
|
await UniMessage.text("没有添加过这个组").finish()
|
214
235
|
else:
|
215
236
|
config_datas[arg[0]] = arg[1]
|
216
|
-
with
|
217
|
-
json.dump(config_datas, f,ensure_ascii=False,indent=4)
|
237
|
+
async with aiofiles.open(config_path, "w", encoding="utf-8") as f:
|
238
|
+
json.dump(config_datas, f, ensure_ascii=False, indent=4)
|
218
239
|
await UniMessage.text(f"修改成功,组名:{arg[0]},网址:{arg[1]}").finish()
|
219
|
-
|
220
|
-
|
240
|
+
|
241
|
+
|
221
242
|
@ld_tj.handle()
|
222
243
|
async def _(matcher: Matcher):
|
223
244
|
await matcher.send("正在寻找牢房信息")
|
224
|
-
await matcher.finish(await tj_request("云","tj"))
|
225
|
-
|
245
|
+
await matcher.finish(await tj_request("云", "tj"))
|
246
|
+
|
247
|
+
|
226
248
|
@ld_zl.handle()
|
227
249
|
async def _(matcher: Matcher):
|
228
250
|
await matcher.send("正在寻找牢房信息")
|
229
|
-
await matcher.finish(await tj_request("云","zl"))
|
251
|
+
await matcher.finish(await tj_request("云", "zl"))
|
@@ -1,10 +1,14 @@
|
|
1
1
|
from pathlib import Path
|
2
2
|
|
3
3
|
from nonebot import get_plugin_config
|
4
|
+
from nonebot.log import logger
|
4
5
|
from pydantic import BaseModel
|
5
6
|
|
6
7
|
DATAPATH = Path(__file__).parent.joinpath("data")
|
7
8
|
DATAOUT = Path("data/L4D2")
|
9
|
+
if not Path(DATAOUT / "l4d2.json").exists():
|
10
|
+
logger.info("文件 l4d2.json 不存在,已创建并初始化为 {}")
|
11
|
+
Path(DATAOUT / "l4d2.json").write_text("{}", encoding="utf-8")
|
8
12
|
print(DATAOUT.absolute())
|
9
13
|
server_all_path = DATAOUT / "l4d2"
|
10
14
|
server_all_path.mkdir(parents=True, exist_ok=True)
|
@@ -10,7 +10,7 @@ from ..l4_image.convert import core_font
|
|
10
10
|
from ..l4_image.model import PluginHelp
|
11
11
|
from .draw import get_help
|
12
12
|
|
13
|
-
__version__ = "1.0.
|
13
|
+
__version__ = "1.0.3"
|
14
14
|
TEXT_PATH = Path(__file__).parent / "texture2d"
|
15
15
|
HELP_DATA = Path(__file__).parent / "Help.json"
|
16
16
|
|
@@ -13,7 +13,9 @@ from .file import updown_l4d2_vpk
|
|
13
13
|
try:
|
14
14
|
vpk_path = config.l4_local[map_index]
|
15
15
|
except IndexError:
|
16
|
-
logger.warning(
|
16
|
+
logger.warning(
|
17
|
+
"未填写本地服务器路径,如果想要使用本地服务器功能,请填写本地服务器路径",
|
18
|
+
)
|
17
19
|
vpk_path = ""
|
18
20
|
|
19
21
|
local_path_list = config.l4_local
|
@@ -0,0 +1,283 @@
|
|
1
|
+
import random
|
2
|
+
from typing import Dict, List, Optional, cast
|
3
|
+
|
4
|
+
from nonebot.log import logger
|
5
|
+
|
6
|
+
from ..config import server_all_path
|
7
|
+
from ..l4_image import msg_to_image
|
8
|
+
from ..utils.api.models import AllServer, NserverOut, OutServer
|
9
|
+
from ..utils.api.request import L4API
|
10
|
+
from ..utils.utils import split_maohao
|
11
|
+
from .draw_msg import convert_duration, draw_one_ip, get_much_server
|
12
|
+
|
13
|
+
try:
|
14
|
+
import ujson as json
|
15
|
+
except ImportError:
|
16
|
+
import json
|
17
|
+
|
18
|
+
from ..config import config
|
19
|
+
|
20
|
+
# 获取全部服务器信息
|
21
|
+
ALLHOST: Dict[str, List[NserverOut]] = {}
|
22
|
+
COMMAND = set()
|
23
|
+
|
24
|
+
|
25
|
+
async def get_all_server_detail():
|
26
|
+
"""
|
27
|
+
获取所有服务器的详细信息。
|
28
|
+
|
29
|
+
Args:
|
30
|
+
无
|
31
|
+
|
32
|
+
Returns:
|
33
|
+
str: 包含所有服务器详细信息的字符串。
|
34
|
+
|
35
|
+
"""
|
36
|
+
out_list: List[AllServer] = []
|
37
|
+
for group in ALLHOST:
|
38
|
+
msg_list = await get_group_detail(group)
|
39
|
+
if msg_list is None:
|
40
|
+
continue
|
41
|
+
active_server = 0
|
42
|
+
max_server = 0
|
43
|
+
active_player = 0
|
44
|
+
max_player = 0
|
45
|
+
for index, msg in enumerate(msg_list):
|
46
|
+
max_server = index + 1
|
47
|
+
if msg["server"].max_players != 0:
|
48
|
+
active_server += 1
|
49
|
+
active_player += msg["server"].player_count
|
50
|
+
max_player += msg["server"].max_players
|
51
|
+
data = {
|
52
|
+
"command": group,
|
53
|
+
"active_server": active_server,
|
54
|
+
"max_server": max_server,
|
55
|
+
"active_player": active_player,
|
56
|
+
"max_player": max_player,
|
57
|
+
}
|
58
|
+
out_list.append(cast(AllServer, data))
|
59
|
+
|
60
|
+
# to do作图,先用文字凑合
|
61
|
+
out_msg = ""
|
62
|
+
for one in out_list:
|
63
|
+
if one["max_player"]:
|
64
|
+
out_msg += f"{one['command']} | 服务器{one['active_server']}/{one['max_server']} | 玩家{one['active_player']}/{one['max_player']}\n"
|
65
|
+
else:
|
66
|
+
continue
|
67
|
+
return out_msg
|
68
|
+
|
69
|
+
|
70
|
+
async def get_server_detail(
|
71
|
+
command: str = "",
|
72
|
+
_id: Optional[str] = None,
|
73
|
+
is_img: bool = True,
|
74
|
+
):
|
75
|
+
"""
|
76
|
+
异步获取服务器详细信息。
|
77
|
+
|
78
|
+
Args:
|
79
|
+
command (str): 服务器组名。
|
80
|
+
_id (Optional[str], optional): 服务器ID。默认为None。
|
81
|
+
is_img (bool, optional): 是否返回图片格式的信息。默认为True。
|
82
|
+
|
83
|
+
Returns:
|
84
|
+
Union[bytes, List[OutServer], None]: 返回服务器详细信息。如果为图片格式,返回bytes类型;
|
85
|
+
如果不是图片格式,返回List[OutServer]类型;如果未找到服务器组,返回None。
|
86
|
+
|
87
|
+
"""
|
88
|
+
if command:
|
89
|
+
server_json = ALLHOST.get(command)
|
90
|
+
else:
|
91
|
+
server_json = []
|
92
|
+
for servers in ALLHOST.values():
|
93
|
+
server_json.extend(servers)
|
94
|
+
|
95
|
+
logger.info(server_json)
|
96
|
+
if server_json is None:
|
97
|
+
logger.warning("未找到这个组")
|
98
|
+
return None
|
99
|
+
|
100
|
+
if _id is None:
|
101
|
+
# 输出组信息
|
102
|
+
logger.info(f"正在请求组服务器信息 {command}")
|
103
|
+
server_dict = await get_much_server(server_json, command)
|
104
|
+
if is_img:
|
105
|
+
out_msg = await msg_to_image(server_dict)
|
106
|
+
else:
|
107
|
+
out_msg = server_dict
|
108
|
+
return out_msg
|
109
|
+
|
110
|
+
# 返回单个
|
111
|
+
logger.info("正在请求单服务器信息")
|
112
|
+
out_msg = ""
|
113
|
+
for i in server_json:
|
114
|
+
if str(_id) == str(i["id"]):
|
115
|
+
out_msg = await draw_one_ip(i["host"], i["port"])
|
116
|
+
if is_img:
|
117
|
+
return cast(bytes, out_msg)
|
118
|
+
if not is_img:
|
119
|
+
return cast(List[OutServer], out_msg)
|
120
|
+
# print(out_msg)
|
121
|
+
return None
|
122
|
+
|
123
|
+
|
124
|
+
async def get_group_detail(
|
125
|
+
command: str,
|
126
|
+
):
|
127
|
+
server_json = ALLHOST.get(command)
|
128
|
+
logger.info(server_json)
|
129
|
+
if server_json is None:
|
130
|
+
logger.warning("未找到这个组")
|
131
|
+
return None
|
132
|
+
|
133
|
+
logger.info("正在请求组服务器信息")
|
134
|
+
return await get_much_server(server_json, command)
|
135
|
+
|
136
|
+
|
137
|
+
async def get_ip_server(ip: str):
|
138
|
+
host, port = split_maohao(ip)
|
139
|
+
return await draw_one_ip(host, port)
|
140
|
+
|
141
|
+
|
142
|
+
# 以下是重载ip
|
143
|
+
def reload_ip():
|
144
|
+
global COMMAND
|
145
|
+
# print("正在读取json文件")
|
146
|
+
group_ip = []
|
147
|
+
for item in server_all_path.iterdir():
|
148
|
+
if item.is_file() and item.name.endswith("json"):
|
149
|
+
json_data = json.loads(item.read_text(encoding="utf-8"))
|
150
|
+
group_server = cast(Dict[str, List[NserverOut]], json_data)
|
151
|
+
|
152
|
+
for group, group_ip in group_server.items():
|
153
|
+
# 处理ip,host,port关系
|
154
|
+
for one_ip in group_ip:
|
155
|
+
if one_ip.get("ip"):
|
156
|
+
if one_ip.get("host") and one_ip.get("port"):
|
157
|
+
pass
|
158
|
+
if one_ip.get("host") and not one_ip.get("port"):
|
159
|
+
one_ip["port"] = 20715
|
160
|
+
if not one_ip.get("host"):
|
161
|
+
one_ip["host"], one_ip["port"] = split_maohao(
|
162
|
+
one_ip.get("ip"),
|
163
|
+
)
|
164
|
+
else:
|
165
|
+
if one_ip.get("host") and one_ip.get("port"):
|
166
|
+
one_ip["ip"] = f'{one_ip["host"]}:{one_ip["port"]}'
|
167
|
+
if one_ip.get("host") and not one_ip.get("port"):
|
168
|
+
one_ip["ip"] = f'{one_ip["host"]}:20715'
|
169
|
+
else:
|
170
|
+
logger.warning(f"{one_ip} 没有ip")
|
171
|
+
|
172
|
+
ALLHOST.update({group: group_ip})
|
173
|
+
COMMAND.add(group)
|
174
|
+
logger.success(f"成功加载 {item.name.split('.')[0]} {len(group_ip)}个")
|
175
|
+
|
176
|
+
|
177
|
+
async def tj_request(command: str = "云", tj="tj"):
|
178
|
+
map_type = "普通药役"
|
179
|
+
server_json = ALLHOST.get(command)
|
180
|
+
logger.info(server_json)
|
181
|
+
if server_json is None:
|
182
|
+
logger.warning("未找到这个组")
|
183
|
+
return None
|
184
|
+
|
185
|
+
logger.info("正在获取电信服务器信息")
|
186
|
+
player_msg = ""
|
187
|
+
right_ip = []
|
188
|
+
|
189
|
+
async def _filter_servers(servers: list, tj_mode: str) -> list:
|
190
|
+
"""筛选符合条件的服务器
|
191
|
+
Args:
|
192
|
+
servers: 服务器列表
|
193
|
+
tj_mode: 筛选模式('tj'或'zl')
|
194
|
+
Returns:
|
195
|
+
符合条件的服务器列表
|
196
|
+
"""
|
197
|
+
filtered = []
|
198
|
+
for i in servers:
|
199
|
+
ser_list = await L4API.a2s_info([(i["host"], i["port"])], is_player=True)
|
200
|
+
if not ser_list:
|
201
|
+
continue
|
202
|
+
|
203
|
+
srv = ser_list[0][0]
|
204
|
+
players = ser_list[0][1]
|
205
|
+
|
206
|
+
if tj_mode == "tj" and map_type in srv.map_name:
|
207
|
+
score = sum(p.score for p in players[:4])
|
208
|
+
t = srv.map_name.split("[")[-1].split("特")[0]
|
209
|
+
if t.isdigit() and int(t) * 50 < score:
|
210
|
+
logger.info(
|
211
|
+
f"符合TJ条件的服务器: {i['host']}:{i['port']}, 地图: {srv.map_name}, 分数: {score}",
|
212
|
+
)
|
213
|
+
filtered.append(i)
|
214
|
+
elif tj_mode == "zl" and map_type in srv.map_name and len(players) <= 4:
|
215
|
+
logger.info(
|
216
|
+
f"符合ZL条件的服务器: {i['host']}:{i['port']}, 地图: {srv.map_name}, 玩家数: {len(players)}",
|
217
|
+
)
|
218
|
+
filtered.append(i)
|
219
|
+
return filtered
|
220
|
+
|
221
|
+
async def _format_players(player_list: list) -> str:
|
222
|
+
"""格式化玩家信息
|
223
|
+
Args:
|
224
|
+
player_list: 玩家对象列表
|
225
|
+
Returns:
|
226
|
+
格式化后的玩家信息字符串
|
227
|
+
"""
|
228
|
+
durations = [await convert_duration(p.duration) for p in player_list]
|
229
|
+
max_duration_len = max(len(str(d)) for d in durations)
|
230
|
+
max_score_len = max(len(str(p.score)) for p in player_list)
|
231
|
+
return "\n".join(
|
232
|
+
f"[{p.score:>{max_score_len}}] | {durations[i]:^{max_duration_len}} | {p.name[0]}***{p.name[-1]}"
|
233
|
+
for i, p in enumerate(player_list)
|
234
|
+
)
|
235
|
+
|
236
|
+
def _build_message(srv_info, players_msg: str, selected_srv: dict) -> str:
|
237
|
+
"""构建服务器信息消息
|
238
|
+
Args:
|
239
|
+
srv_info: 服务器信息对象
|
240
|
+
players_msg: 格式化后的玩家信息
|
241
|
+
selected_srv: 选中的服务器信息
|
242
|
+
Returns:
|
243
|
+
完整的消息字符串
|
244
|
+
"""
|
245
|
+
msg = f"""*{srv_info.server_name}*
|
246
|
+
游戏: {srv_info.folder}
|
247
|
+
地图: {srv_info.map_name}
|
248
|
+
人数: {srv_info.player_count}/{srv_info.max_players}"""
|
249
|
+
if srv_info.ping is not None:
|
250
|
+
msg += f"\nping: {srv_info.ping * 1000:.0f}ms\n{players_msg}"
|
251
|
+
if config.l4_show_ip:
|
252
|
+
msg += f"\nconnect {selected_srv['host']}:{selected_srv['port']}"
|
253
|
+
return msg
|
254
|
+
|
255
|
+
try:
|
256
|
+
right_ip = await _filter_servers(server_json, tj)
|
257
|
+
|
258
|
+
if not right_ip:
|
259
|
+
logger.warning("没有找到符合条件的服务器")
|
260
|
+
return "没有符合条件的服务器"
|
261
|
+
|
262
|
+
logger.info(
|
263
|
+
f"符合条件的服务器列表: {[f'{ip['host']}:{ip['port']}' for ip in right_ip]}",
|
264
|
+
)
|
265
|
+
s = random.choice(right_ip)
|
266
|
+
logger.info(f"最终选择的服务器: {s['host']}:{s['port']}")
|
267
|
+
ser_list = await L4API.a2s_info([(s["host"], s["port"])], is_player=True)
|
268
|
+
if not ser_list:
|
269
|
+
return "获取服务器信息失败"
|
270
|
+
|
271
|
+
one_server = ser_list[0][0]
|
272
|
+
one_player = ser_list[0][1]
|
273
|
+
|
274
|
+
if one_player:
|
275
|
+
player_msg = await _format_players(one_player)
|
276
|
+
else:
|
277
|
+
player_msg = "服务器感觉很安静啊"
|
278
|
+
|
279
|
+
return _build_message(one_server, player_msg, s)
|
280
|
+
|
281
|
+
except Exception as e:
|
282
|
+
logger.error(f"tj_request error: {e}")
|
283
|
+
return "获取服务器信息时出错"
|
@@ -32,7 +32,7 @@ async def draw_one_ip(host: str, port: int):
|
|
32
32
|
name_leg = len(player.name)
|
33
33
|
if name_leg > 2:
|
34
34
|
xing = "*" * (name_leg - 2)
|
35
|
-
name = f"{player.name[0]}xing{player.name[-1]}"
|
35
|
+
name = f"{player.name[0]}{xing}{player.name[-1]}"
|
36
36
|
else:
|
37
37
|
name = player.name
|
38
38
|
player_msg += f"{soc} | {dur} | {name} \n"
|
@@ -77,6 +77,12 @@ async def get_much_server(server_json: List[NserverOut], command: str):
|
|
77
77
|
|
78
78
|
|
79
79
|
async def convert_duration(duration: float) -> str:
|
80
|
+
"""Convert duration in seconds to human-readable string format (e.g. '1h 30m 15s')
|
81
|
+
Args:
|
82
|
+
duration: Duration in seconds
|
83
|
+
Returns:
|
84
|
+
Formatted time string
|
85
|
+
"""
|
80
86
|
minutes, seconds = divmod(duration, 60)
|
81
87
|
hours, minutes = divmod(minutes, 60)
|
82
88
|
time_str = ""
|
@@ -6,6 +6,7 @@ from pathlib import Path
|
|
6
6
|
from typing import Any, Dict, List, Literal, Optional, Tuple, cast
|
7
7
|
|
8
8
|
import a2s
|
9
|
+
import aiofiles
|
9
10
|
import ujson as js
|
10
11
|
import ujson as json
|
11
12
|
from bs4 import BeautifulSoup
|
@@ -28,6 +29,8 @@ from .models import (
|
|
28
29
|
SourceBansInfo,
|
29
30
|
)
|
30
31
|
|
32
|
+
config_path = Path(config.l4_path) / "config.json"
|
33
|
+
|
31
34
|
|
32
35
|
class L4D2Api:
|
33
36
|
ssl_verify = False
|
@@ -76,11 +79,11 @@ class L4D2Api:
|
|
76
79
|
is_server: bool,
|
77
80
|
is_player: bool,
|
78
81
|
):
|
79
|
-
server: a2s.SourceInfo = a2s.SourceInfo()
|
80
82
|
play: List[a2s.Player] = []
|
81
83
|
if is_server:
|
82
84
|
try:
|
83
|
-
server = await a2s.ainfo(ip)
|
85
|
+
server: a2s.SourceInfo = await a2s.ainfo(ip, timeout=3, encoding="utf8")
|
86
|
+
|
84
87
|
if server is not None:
|
85
88
|
server.steam_id = index
|
86
89
|
|
@@ -89,6 +92,25 @@ class L4D2Api:
|
|
89
92
|
ConnectionRefusedError,
|
90
93
|
socket.gaierror,
|
91
94
|
):
|
95
|
+
server: a2s.SourceInfo = a2s.SourceInfo(
|
96
|
+
protocol=0,
|
97
|
+
server_name="服务器无响应",
|
98
|
+
map_name="无",
|
99
|
+
folder="m",
|
100
|
+
game="L4D2",
|
101
|
+
app_id=114514,
|
102
|
+
steam_id=index,
|
103
|
+
player_count=0,
|
104
|
+
max_players=0,
|
105
|
+
bot_count=0,
|
106
|
+
server_type="w",
|
107
|
+
platform="w",
|
108
|
+
password_protected=False,
|
109
|
+
vac_enabled=False,
|
110
|
+
version="1.0",
|
111
|
+
edf=0,
|
112
|
+
ping=0,
|
113
|
+
)
|
92
114
|
server.steam_id = index
|
93
115
|
server.player_count = 0
|
94
116
|
server.max_players = 0
|
@@ -103,7 +125,7 @@ class L4D2Api:
|
|
103
125
|
ConnectionRefusedError,
|
104
126
|
socket.gaierror,
|
105
127
|
):
|
106
|
-
play = await a2s.aplayers(ip)
|
128
|
+
play = await a2s.aplayers(ip, timeout=3, encoding="utf8")
|
107
129
|
return server, play
|
108
130
|
|
109
131
|
async def _server_request(
|
@@ -158,7 +180,7 @@ class L4D2Api:
|
|
158
180
|
html_content = resp.content
|
159
181
|
return BeautifulSoup(html_content, "lxml")
|
160
182
|
|
161
|
-
async def get_sourceban(self, tag:str = "云", url: str = anne_ban):
|
183
|
+
async def get_sourceban(self, tag: str = "云", url: str = anne_ban):
|
162
184
|
"""从sourceban++获取服务器列表,目前未做名称处理"""
|
163
185
|
if not (url.startswith(("http://", "https://"))):
|
164
186
|
url = "http://" + url # 默认添加 http://
|
@@ -184,23 +206,25 @@ class L4D2Api:
|
|
184
206
|
)
|
185
207
|
|
186
208
|
if not Path(Path(config.l4_path) / "config.json").is_file():
|
187
|
-
with
|
188
|
-
f.write("{}")
|
209
|
+
async with aiofiles.open(config_path, "w", encoding="utf-8") as f:
|
210
|
+
await f.write("{}")
|
189
211
|
with (Path(config.l4_path) / "config.json").open("r", encoding="utf-8") as f:
|
190
212
|
content = f.read().strip()
|
191
213
|
ip_json = json.loads(content)
|
192
214
|
if tag in ip_json:
|
193
215
|
url = ip_json[tag]
|
194
|
-
|
216
|
+
tag_path = Path(Path(config.l4_path) / f"l4d2/{tag}.json")
|
217
|
+
|
218
|
+
async with aiofiles.open(tag_path, "w", encoding="utf-8") as f:
|
195
219
|
print(Path(Path(config.l4_path) / f"l4d2/{tag}.json"))
|
196
220
|
up_data = {}
|
197
221
|
for server in server_list:
|
198
222
|
new_dict = {}
|
199
|
-
new_dict["id"] = int(server.index
|
223
|
+
new_dict["id"] = int(server.index) + 1
|
200
224
|
new_dict["ip"] = server.host + ":" + str(server.port)
|
201
225
|
up_data.update(new_dict)
|
202
226
|
print(up_data)
|
203
|
-
json.dump(up_data, f)
|
227
|
+
json.dump(up_data, f, ensure_ascii=False, indent=4)
|
204
228
|
return server_list
|
205
229
|
|
206
230
|
async def get_anne_steamid(self, name: str):
|