nonebot-plugin-l4d2-server 1.0.0a2__tar.gz → 1.0.0b1__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.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/PKG-INFO +1 -1
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/__main__.py +1 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/config.py +7 -1
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_anne/__init__.py +2 -1
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/Help.json +8 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/__init__.py +1 -1
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/anne_pil.py +3 -2
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/convert.py +8 -12
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/download.py +5 -3
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/html_img.py +2 -2
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/image_tools.py +8 -5
- nonebot_plugin_l4d2_server-1.0.0b1/nonebot_plugin_l4d2_server/l4_local/__init__.py +94 -0
- nonebot_plugin_l4d2_server-1.0.0b1/nonebot_plugin_l4d2_server/l4_local/file.py +105 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_request/draw_msg.py +1 -1
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/utils/utils.py +13 -2
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/pyproject.toml +47 -1
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/LICENSE +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/README.md +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/__init__.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/data/font/loli.ttf +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_anne/ranne.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/draw.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//344/273/213/347/273/215.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//344/273/273/345/212/241.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//344/277/241/346/201/257.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//345/205/254/345/221/212.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//345/210/200/345/211/221.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//345/210/207/346/215/242.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//345/210/240/351/231/244.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//345/210/267/346/226/260.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//345/215/241/347/273/204.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//345/223/252/351/207/214.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//345/234/260/345/233/276.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/205/245.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/207/272.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//345/275/261.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//346/213/274/345/233/276.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//346/216/242/347/264/242.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//346/216/250/351/200/201.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//346/224/266/351/233/206.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//346/224/273/347/225/245.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//346/233/264/346/226/260.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//346/235/220/346/226/231.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//346/237/245/350/257/242.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//346/240/241/351/252/214.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//346/257/217/346/234/210.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//346/267/261/346/270/212.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//346/267/273/345/212/240.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//346/270/205/351/231/244.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//347/212/266/346/200/201.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//347/255/276/345/210/260.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//347/273/221/345/256/232.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//350/241/250.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//350/241/250/346/203/205.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//350/247/222/350/211/262.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//350/256/260/345/275/225.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//351/205/215/347/275/256.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/icon//351/207/215/345/220/257.png" +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/texture2d/badge.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/texture2d/banner.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/texture2d/bg.jpg +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/texture2d/button.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_help/texture2d/icon.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/__init__.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/anne/anne.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/anne/back.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/anne/back1.jpg +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/anne/group_ip.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/anne/ip.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/head/head.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/header/logo.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/header/player1.jpg +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/HYPixel11pxU-2.ttf +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/Tutumianhuatang-Bold-2.ttf +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/bilibili.svg +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/fingerprint.svg +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/github.svg +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/l.svg +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/m.svg +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/normal.html +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/vac.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/vac_white.png +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/vue.css +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/img/template/w.svg +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/model.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_image/vtfs.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_request/__init__.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/l4_request/utils.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/utils/api/api.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/utils/api/models.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/utils/api/request.py +0 -0
- {nonebot_plugin_l4d2_server-1.0.0a2 → nonebot_plugin_l4d2_server-1.0.0b1}/nonebot_plugin_l4d2_server/utils/database/models.py +0 -0
@@ -11,9 +11,12 @@ server_all_path.mkdir(parents=True, exist_ok=True)
|
|
11
11
|
|
12
12
|
ICONPATH = DATAPATH / "icon"
|
13
13
|
|
14
|
+
global map_index
|
15
|
+
map_index = 0
|
16
|
+
|
14
17
|
|
15
18
|
class ConfigModel(BaseModel):
|
16
|
-
l4_anne: bool =
|
19
|
+
l4_anne: bool = False
|
17
20
|
"""是否启用anne电信服相关功能"""
|
18
21
|
l4_enable: bool = True
|
19
22
|
"""是否全局启用求生功能"""
|
@@ -30,6 +33,9 @@ class ConfigModel(BaseModel):
|
|
30
33
|
l4_font: str = str(Path(__file__).parent.joinpath("data/font/loli.ttf"))
|
31
34
|
"""字体"""
|
32
35
|
l4_show_ip: bool = True
|
36
|
+
"""单服务器查询时候是否展示ip直连地址"""
|
37
|
+
l4_local: list[str] = []
|
38
|
+
"""本地服务器路径,填写路径下有`steam_appid.txt`文件"""
|
33
39
|
|
34
40
|
|
35
41
|
config = get_plugin_config(ConfigModel)
|
@@ -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.0b1"
|
14
14
|
TEXT_PATH = Path(__file__).parent / "texture2d"
|
15
15
|
HELP_DATA = Path(__file__).parent / "Help.json"
|
16
16
|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
from pathlib import Path
|
2
2
|
|
3
|
-
from nonebot_plugin_l4d2_server.utils.api.models import AnnePlayer2
|
4
3
|
from PIL import Image, ImageFont
|
5
4
|
|
5
|
+
from nonebot_plugin_l4d2_server.utils.api.models import AnnePlayer2
|
6
|
+
|
6
7
|
from ..config import config
|
7
8
|
|
8
9
|
font = ImageFont.truetype(config.l4_font)
|
@@ -10,7 +11,7 @@ font = ImageFont.truetype(config.l4_font)
|
|
10
11
|
anne_path = Path(__file__).parent / "img" / "anne"
|
11
12
|
|
12
13
|
|
13
|
-
async def anne_player_info(msg: AnnePlayer2):
|
14
|
+
async def anne_player_info(msg: AnnePlayer2): # noqa: RUF029
|
14
15
|
back_img = Image.open(anne_path / "back1.jpg")
|
15
16
|
base_img = Image.new("RGBA", (back_img.size), (255, 255, 255, 50))
|
16
17
|
back_img.paste(base_img, (0, 0), base_img)
|
@@ -21,32 +21,28 @@ def core_font(size: int) -> ImageFont.FreeTypeFont:
|
|
21
21
|
async def convert_img(
|
22
22
|
img: Image.Image,
|
23
23
|
is_base64: bool = False,
|
24
|
-
) -> bytes:
|
25
|
-
...
|
24
|
+
) -> bytes: ...
|
26
25
|
|
27
26
|
|
28
27
|
@overload
|
29
28
|
async def convert_img(
|
30
29
|
img: Image.Image,
|
31
|
-
is_base64: bool = True,
|
32
|
-
) -> str:
|
33
|
-
...
|
30
|
+
is_base64: bool = True, # noqa: FBT001
|
31
|
+
) -> str: ...
|
34
32
|
|
35
33
|
|
36
34
|
@overload
|
37
35
|
async def convert_img(
|
38
36
|
img: bytes,
|
39
37
|
is_base64: bool = False,
|
40
|
-
) -> str:
|
41
|
-
...
|
38
|
+
) -> str: ...
|
42
39
|
|
43
40
|
|
44
41
|
@overload
|
45
42
|
async def convert_img(
|
46
43
|
img: Path,
|
47
44
|
is_base64: bool = False,
|
48
|
-
) -> str:
|
49
|
-
...
|
45
|
+
) -> str: ...
|
50
46
|
|
51
47
|
|
52
48
|
async def convert_img(
|
@@ -78,7 +74,7 @@ async def convert_img(
|
|
78
74
|
async with aiofiles.open(img, "rb") as fp:
|
79
75
|
img = await fp.read()
|
80
76
|
|
81
|
-
logger.success("
|
77
|
+
logger.success("图片处理完成!")
|
82
78
|
|
83
79
|
return f"base64://{b64encode(img).decode()}"
|
84
80
|
|
@@ -90,7 +86,7 @@ def convert_img_sync(img_path: Path):
|
|
90
86
|
return f"base64://{b64encode(img).decode()}"
|
91
87
|
|
92
88
|
|
93
|
-
async def str_lenth(r: str, size: int, limit: int = 540) -> str:
|
89
|
+
async def str_lenth(r: str, size: int, limit: int = 540) -> str: # noqa: RUF029
|
94
90
|
result = ""
|
95
91
|
temp = 0
|
96
92
|
for i in r:
|
@@ -158,7 +154,7 @@ async def text2pic(text: str, max_size: int = 800, font_size: int = 24):
|
|
158
154
|
|
159
155
|
img = Image.new(
|
160
156
|
"RGB",
|
161
|
-
(max_size, len(text) * font_size //
|
157
|
+
(max_size, len(text) * font_size // 10),
|
162
158
|
(255, 255, 255),
|
163
159
|
)
|
164
160
|
img_draw = ImageDraw.ImageDraw(img)
|
@@ -27,20 +27,22 @@ async def download_url(url: str) -> bytes:
|
|
27
27
|
logger.warning(f"Error downloading {url}, retry {i}/3: {e}")
|
28
28
|
await asyncio.sleep(3)
|
29
29
|
|
30
|
-
raise Exception(f"{url}
|
30
|
+
raise Exception(f"{url} 下载失败!")
|
31
31
|
|
32
32
|
|
33
33
|
async def download_head(user_id: str) -> bytes:
|
34
34
|
url = f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=640"
|
35
35
|
data = await download_url(url)
|
36
|
-
if
|
36
|
+
if (
|
37
|
+
hashlib.md5(data).hexdigest() == "acef72340ac0e914090bd35799f5594e"
|
38
|
+
): # noqa: S324
|
37
39
|
url = f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=100"
|
38
40
|
data = await download_url(url)
|
39
41
|
return data
|
40
42
|
|
41
43
|
|
42
44
|
def square_to_circle(im: ImageS):
|
43
|
-
"""im
|
45
|
+
"""im是正方形,变圆形"""
|
44
46
|
size = im.size
|
45
47
|
mask = Image.new("L", size, 0)
|
46
48
|
draw = ImageDraw.Draw(mask)
|
@@ -23,7 +23,7 @@ env = jinja2.Environment(
|
|
23
23
|
|
24
24
|
async def server_ip_pic(server_dict: List[OutServer]):
|
25
25
|
"""
|
26
|
-
|
26
|
+
输入一个字典列表,输出图片
|
27
27
|
msg_dict:folder/name/map_/players/max_players/Players/[Name]
|
28
28
|
"""
|
29
29
|
for server_info in server_dict:
|
@@ -92,7 +92,7 @@ async def get_server_img(plugins: List[OutServer]) -> Optional[bytes]:
|
|
92
92
|
|
93
93
|
# async def server_group_ip_pic(msg_list: List[ServerGroup]) -> bytes:
|
94
94
|
# """
|
95
|
-
#
|
95
|
+
# 输入一个群组字典列表,输出图片
|
96
96
|
# msg_dict:folder/name/map_/players/max_players/Players/[Name]
|
97
97
|
# """
|
98
98
|
# template = env.get_template("group_ip.html")
|
@@ -44,7 +44,10 @@ def get_v4_bg(w: int, h: int, is_dark: bool = False, is_blur: bool = False):
|
|
44
44
|
return img.convert("RGBA")
|
45
45
|
|
46
46
|
|
47
|
-
async def shift_image_hue(
|
47
|
+
async def shift_image_hue(
|
48
|
+
img: Image.Image,
|
49
|
+
angle: float = 30,
|
50
|
+
) -> Image.Image: # noqa: RUF029
|
48
51
|
alpha = img.getchannel("A")
|
49
52
|
img = img.convert("HSV")
|
50
53
|
|
@@ -120,7 +123,7 @@ def draw_center_text_by_line(
|
|
120
123
|
line = line.replace("\n", "")
|
121
124
|
img.text((x, y), line, fill, font, anchor)
|
122
125
|
line, lenth = "", 0
|
123
|
-
y += h *
|
126
|
+
y += h * 1.5
|
124
127
|
else:
|
125
128
|
img.text((x, y), line, fill, font, anchor)
|
126
129
|
return y
|
@@ -198,7 +201,7 @@ def easy_paste(
|
|
198
201
|
"""
|
199
202
|
inplace method
|
200
203
|
快速粘贴, 自动获取被粘贴图像的坐标。
|
201
|
-
pos
|
204
|
+
pos应当是粘贴点坐标,direction指定粘贴点方位,例如lt为左上
|
202
205
|
"""
|
203
206
|
x, y = pos
|
204
207
|
size_x, size_y = im_paste.size
|
@@ -379,11 +382,11 @@ class CustomizeImage:
|
|
379
382
|
for i in range(color):
|
380
383
|
bg = tuple(
|
381
384
|
q.getpalette()[ # type:ignore
|
382
|
-
i * 3 : (i * 3) + 3
|
385
|
+
i * 3 : (i * 3) + 3
|
383
386
|
],
|
384
387
|
)
|
385
388
|
light_value = bg[0] * 0.3 + bg[1] * 0.6 + bg[2] * 0.1
|
386
|
-
if abs(light_value - based_light) < temp:
|
389
|
+
if abs(light_value - based_light) < temp:
|
387
390
|
bg_color = bg
|
388
391
|
temp = abs(light_value - based_light)
|
389
392
|
return bg_color # type:ignore
|
@@ -0,0 +1,94 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
|
3
|
+
from nonebot.adapters import Event
|
4
|
+
from nonebot.log import logger
|
5
|
+
from nonebot.matcher import Matcher
|
6
|
+
from nonebot_plugin_alconna import File, UniMessage, UniMsg, on_alconna
|
7
|
+
|
8
|
+
from ..config import config, map_index
|
9
|
+
from ..l4_image.convert import text2pic
|
10
|
+
from ..utils.utils import mes_list
|
11
|
+
from .file import updown_l4d2_vpk
|
12
|
+
|
13
|
+
vpk_path = config.l4_local[map_index]
|
14
|
+
|
15
|
+
local_path_list = config.l4_local
|
16
|
+
if not local_path_list:
|
17
|
+
logger.warning(
|
18
|
+
"未填写本地服务器路径,如果想要使用本地服务器功能,请填写本地服务器路径",
|
19
|
+
)
|
20
|
+
else:
|
21
|
+
local_path: list[Path] = []
|
22
|
+
for folder_path in local_path_list:
|
23
|
+
path = Path(folder_path)
|
24
|
+
|
25
|
+
if path.is_dir():
|
26
|
+
for nextdir in path.iterdir():
|
27
|
+
# 如果找到了名为left4dead2的目录,返回True
|
28
|
+
if nextdir.name == "left4dead2" and nextdir.is_dir():
|
29
|
+
local_path.append(nextdir)
|
30
|
+
continue
|
31
|
+
logger.debug(f"本地服务器路径列表:{local_path}")
|
32
|
+
|
33
|
+
search_map = on_alconna(
|
34
|
+
"l4map",
|
35
|
+
aliases={"l4地图查询", "l4地图"},
|
36
|
+
priority=20,
|
37
|
+
block=True,
|
38
|
+
)
|
39
|
+
|
40
|
+
@search_map.handle()
|
41
|
+
async def _():
|
42
|
+
supath = local_path[map_index] / "addons"
|
43
|
+
vpk_list: list[str] = []
|
44
|
+
print(supath)
|
45
|
+
if supath.is_dir():
|
46
|
+
for sudir in supath.iterdir():
|
47
|
+
logger.info(f"找到文件:{sudir}")
|
48
|
+
if sudir.is_file() and sudir.name.endswith(".vpk"):
|
49
|
+
vpk_list.append(sudir.name)
|
50
|
+
if not vpk_list:
|
51
|
+
await UniMessage.text("未找到可用的VPK文件").finish()
|
52
|
+
out_msg = "\n".join(
|
53
|
+
f"{index + 1}、{line}" for index, line in enumerate(vpk_list)
|
54
|
+
)
|
55
|
+
|
56
|
+
img = await text2pic(f"服务器地图:\n{out_msg}")
|
57
|
+
await UniMessage.image(raw=img).send()
|
58
|
+
|
59
|
+
up = on_alconna(
|
60
|
+
"l4upload",
|
61
|
+
aliases={"l4地图上传"},
|
62
|
+
priority=5,
|
63
|
+
block=True,
|
64
|
+
)
|
65
|
+
|
66
|
+
@up.handle()
|
67
|
+
async def _():
|
68
|
+
await UniMessage.text("请发送地图文件").finish()
|
69
|
+
|
70
|
+
@up.got("map_url", prompt="图来")
|
71
|
+
async def _(ev: Event, msg: UniMsg, matcher: Matcher):
|
72
|
+
if not msg.has(File):
|
73
|
+
await UniMessage.text("不是文件,退出交互").finish()
|
74
|
+
args = ev.dict()
|
75
|
+
if args["notice_type"] != "offline_file":
|
76
|
+
matcher.set_arg("txt", args) # type: ignore
|
77
|
+
return
|
78
|
+
l4_file_path = config.l4_local[map_index]
|
79
|
+
map_path = Path(l4_file_path, vpk_path) # type: ignore
|
80
|
+
# 检查下载路径是否存在
|
81
|
+
if not Path(l4_file_path).exists(): # type: ignore
|
82
|
+
await UniMessage.text("你填写的路径不存在辣").finish()
|
83
|
+
if not Path(map_path).exists():
|
84
|
+
await UniMessage.text("这个路径并不是求生服务器的路径,请再看看罢").finish()
|
85
|
+
url: str = args["file"]["url"]
|
86
|
+
name: str = args["file"]["name"]
|
87
|
+
# 如果不符合格式则忽略
|
88
|
+
await up.send("已收到文件,开始下载")
|
89
|
+
vpk_files = await updown_l4d2_vpk(map_path, name, url)
|
90
|
+
if vpk_files:
|
91
|
+
mes = "解压成功,新增以下几个vpk文件"
|
92
|
+
await UniMessage.text(mes_list(mes, vpk_files)).finish()
|
93
|
+
else:
|
94
|
+
await UniMessage.text("你可能上传了相同的文件,或者解压失败了捏").finish()
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import io
|
2
|
+
import platform
|
3
|
+
import zipfile
|
4
|
+
from pathlib import Path
|
5
|
+
from typing import Callable, Dict, List
|
6
|
+
from zipfile import ZipFile
|
7
|
+
|
8
|
+
import rarfile
|
9
|
+
from nonebot.log import logger
|
10
|
+
from pyunpack import Archive
|
11
|
+
|
12
|
+
from ..utils.utils import get_file, get_vpk
|
13
|
+
|
14
|
+
systems = platform.system()
|
15
|
+
|
16
|
+
|
17
|
+
async def updown_l4d2_vpk(map_paths: Path, name: str, url: str):
|
18
|
+
"""从url下载压缩包并解压到位置"""
|
19
|
+
original_vpk_files = get_vpk(map_paths)
|
20
|
+
down_file = Path(map_paths, name)
|
21
|
+
if await get_file(url, down_file) is None:
|
22
|
+
return None
|
23
|
+
msg = open_packet(name, down_file)
|
24
|
+
logger.info(msg)
|
25
|
+
|
26
|
+
extracted_vpk_files = get_vpk(map_paths)
|
27
|
+
# 获取新增vpk文件的list
|
28
|
+
return list(set(extracted_vpk_files) - set(original_vpk_files))
|
29
|
+
|
30
|
+
|
31
|
+
SUPPORTED_EXTENSIONS = (".zip", ".7z", ".rar")
|
32
|
+
|
33
|
+
|
34
|
+
def unzip_zipfile(down_file: Path, down_path: Path):
|
35
|
+
"""解压zip文件"""
|
36
|
+
with support_gbk(zipfile.ZipFile(down_file, "r")) as z:
|
37
|
+
z.extractall(down_path)
|
38
|
+
down_file.unlink()
|
39
|
+
|
40
|
+
|
41
|
+
def unpack_7zfile(down_file: Path, down_path: Path):
|
42
|
+
"""解压7z文件"""
|
43
|
+
Archive(str(down_file)).extractall(str(down_path))
|
44
|
+
down_file.unlink()
|
45
|
+
|
46
|
+
|
47
|
+
def unpack_rarfile(down_file: Path, down_path: Path):
|
48
|
+
"""解压rar文件"""
|
49
|
+
with rarfile.RarFile(down_file, "r") as z:
|
50
|
+
z.extractall(down_path)
|
51
|
+
down_file.unlink()
|
52
|
+
|
53
|
+
|
54
|
+
def open_packet(name: str, down_file: Path) -> str:
|
55
|
+
"""解压压缩包"""
|
56
|
+
down_path = down_file.parent
|
57
|
+
logger.info("文件名为:" + name)
|
58
|
+
logger.info(f"系统为{systems}")
|
59
|
+
if name.endswith(".vpk"):
|
60
|
+
return "vpk文件已下载"
|
61
|
+
|
62
|
+
for ext in SUPPORTED_EXTENSIONS:
|
63
|
+
if name.endswith(ext):
|
64
|
+
mes = f"{ext[1:]}文件已下载,正在解压"
|
65
|
+
unpack_funcs: Dict[str, Callable] = {
|
66
|
+
".zip": unzip_zipfile,
|
67
|
+
".7z": unpack_7zfile,
|
68
|
+
".rar": unpack_rarfile,
|
69
|
+
}
|
70
|
+
unpack_func = unpack_funcs.get(ext)
|
71
|
+
if not unpack_func:
|
72
|
+
raise ValueError(f"不支持的拓展名: {ext}")
|
73
|
+
unpack_func(down_file, down_path)
|
74
|
+
return mes
|
75
|
+
|
76
|
+
raise ValueError(f"不支持的文件: {name}")
|
77
|
+
|
78
|
+
|
79
|
+
def support_gbk(zip_file: ZipFile):
|
80
|
+
"""
|
81
|
+
压缩包中文恢复
|
82
|
+
"""
|
83
|
+
if isinstance(zip_file, ZipFile):
|
84
|
+
name_to_info = zip_file.NameToInfo
|
85
|
+
# copy map first
|
86
|
+
for name, info in name_to_info.copy().items():
|
87
|
+
real_name = name.encode("cp437").decode("gbk")
|
88
|
+
if real_name != name:
|
89
|
+
info.filename = real_name
|
90
|
+
del name_to_info[name]
|
91
|
+
name_to_info[real_name] = info
|
92
|
+
return zip_file
|
93
|
+
|
94
|
+
|
95
|
+
async def all_zip_to_one(data_list: List[bytes]): # noqa: RUF029
|
96
|
+
"""多压缩包文件合并"""
|
97
|
+
file_list = [io.BytesIO(data).getbuffer() for data in data_list]
|
98
|
+
data_file = io.BytesIO()
|
99
|
+
|
100
|
+
with ZipFile(data_file, mode="w") as zf:
|
101
|
+
for i, file in enumerate(file_list):
|
102
|
+
filename = f"file{i}.zip"
|
103
|
+
zf.writestr(filename, file)
|
104
|
+
|
105
|
+
return data_file.getbuffer()
|
@@ -52,7 +52,7 @@ async def get_much_server(server_json: List[NserverOut], command: str):
|
|
52
52
|
out_server: List[OutServer] = []
|
53
53
|
search_list: List[Tuple[str, int]] = []
|
54
54
|
for i in server_json:
|
55
|
-
search_list.append((i["host"], i["port"]))
|
55
|
+
search_list.append((i["host"], i["port"]))
|
56
56
|
|
57
57
|
all_server = await L4API.a2s_info(search_list, is_player=True)
|
58
58
|
|
@@ -6,8 +6,10 @@ from typing import Any, Dict, List, Optional, Tuple
|
|
6
6
|
|
7
7
|
import aiofiles
|
8
8
|
import aiohttp
|
9
|
+
import nonebot
|
9
10
|
from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, MessageEvent
|
10
11
|
from nonebot.log import logger
|
12
|
+
from nonebot_plugin_alconna import UniMessage
|
11
13
|
|
12
14
|
|
13
15
|
async def get_file(url: str, down_file: Path):
|
@@ -174,7 +176,7 @@ def split_maohao(msg: str) -> Tuple[str, int]:
|
|
174
176
|
|
175
177
|
|
176
178
|
headers = {
|
177
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0",
|
179
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0",
|
178
180
|
}
|
179
181
|
|
180
182
|
|
@@ -198,7 +200,16 @@ async def url_to_msg(url: str):
|
|
198
200
|
return None
|
199
201
|
|
200
202
|
|
201
|
-
async def get_message_at(datas: str) -> Optional[int]:
|
203
|
+
async def get_message_at(datas: str) -> Optional[int]:
|
202
204
|
data: Dict[str, Any] = json.loads(datas)
|
203
205
|
at_list = [int(msg["data"]["qq"]) for msg in data["message"] if msg["type"] == "at"]
|
204
206
|
return at_list[0] if at_list else None
|
207
|
+
|
208
|
+
|
209
|
+
async def send_ip_msg(msg: str):
|
210
|
+
try:
|
211
|
+
await UniMessage.text(msg).finish()
|
212
|
+
except nonebot.adapters.qq:
|
213
|
+
msg_new = msg.split("\n")[:-2]
|
214
|
+
msg_out = "\n".join(msg_new)
|
215
|
+
await UniMessage.text(msg_out).send()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "nonebot-plugin-l4d2-server"
|
3
|
-
version = "1.0.
|
3
|
+
version = "1.0.0b1"
|
4
4
|
description = "L4D2 server related operations plugin for NoneBot2"
|
5
5
|
authors = [
|
6
6
|
{ name = "Agnes_Digital", email = "Z735803792@163.com" },
|
@@ -52,6 +52,52 @@ homepage = "https://github.com/Agnes4m/nonebot_plugin_l4d2_server"
|
|
52
52
|
[tool.pdm.build]
|
53
53
|
includes = []
|
54
54
|
|
55
|
+
[tool.ruff]
|
56
|
+
ignore = [
|
57
|
+
"B008",
|
58
|
+
"B905",
|
59
|
+
"E501",
|
60
|
+
"N999",
|
61
|
+
"FBT002",
|
62
|
+
"PGH003",
|
63
|
+
"RUF001",
|
64
|
+
"RUF002",
|
65
|
+
"RUF003",
|
66
|
+
"RUF006",
|
67
|
+
"RUF100",
|
68
|
+
"SIM117",
|
69
|
+
"TRY002",
|
70
|
+
"TRY003",
|
71
|
+
"FBT001",
|
72
|
+
]
|
73
|
+
select = [
|
74
|
+
"A",
|
75
|
+
"ARG",
|
76
|
+
"ASYNC",
|
77
|
+
"B",
|
78
|
+
"C4",
|
79
|
+
"COM",
|
80
|
+
"E",
|
81
|
+
"F",
|
82
|
+
"FBT",
|
83
|
+
"FLY",
|
84
|
+
"I",
|
85
|
+
"ISC",
|
86
|
+
"N",
|
87
|
+
"PIE",
|
88
|
+
"PGH",
|
89
|
+
"PTH",
|
90
|
+
"PYI",
|
91
|
+
"Q",
|
92
|
+
"RET",
|
93
|
+
"RSE",
|
94
|
+
"RUF",
|
95
|
+
"SIM",
|
96
|
+
"SLF",
|
97
|
+
"SLOT",
|
98
|
+
"TRY",
|
99
|
+
]
|
100
|
+
|
55
101
|
[build-system]
|
56
102
|
requires = [
|
57
103
|
"pdm-backend",
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|