nonebot-plugin-l4d2-server 0.6.6__py3-none-any.whl → 1.0.0a2__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_l4d2_server/__init__.py +10 -93
- nonebot_plugin_l4d2_server/__main__.py +140 -0
- nonebot_plugin_l4d2_server/config.py +35 -0
- nonebot_plugin_l4d2_server/data/font/loli.ttf +0 -0
- nonebot_plugin_l4d2_server/l4_anne/__init__.py +124 -0
- nonebot_plugin_l4d2_server/l4_anne/ranne.py +18 -0
- nonebot_plugin_l4d2_server/l4_help/Help.json +102 -0
- nonebot_plugin_l4d2_server/l4_help/__init__.py +57 -0
- nonebot_plugin_l4d2_server/l4_help/draw.py +206 -0
- nonebot_plugin_l4d2_server/l4_help/icon//344/273/213/347/273/215.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//344/273/273/345/212/241.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//344/277/241/346/201/257.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/205/254/345/221/212.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/210/200/345/211/221.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/210/207/346/215/242.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/210/240/351/231/244.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/210/267/346/226/260.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/215/241/347/273/204.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/223/252/351/207/214.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/234/260/345/233/276.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/205/245.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/207/272.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//345/275/261.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/213/274/345/233/276.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/216/242/347/264/242.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/216/250/351/200/201.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/224/266/351/233/206.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/224/273/347/225/245.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/233/264/346/226/260.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/235/220/346/226/231.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/237/245/350/257/242.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/240/241/351/252/214.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/257/217/346/234/210.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/267/261/346/270/212.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/267/273/345/212/240.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//346/270/205/351/231/244.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//347/212/266/346/200/201.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//347/255/276/345/210/260.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//347/273/221/345/256/232.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//350/241/250.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//350/241/250/346/203/205.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//350/247/222/350/211/262.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//350/256/260/345/275/225.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//351/205/215/347/275/256.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/icon//351/207/215/345/220/257.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/texture2d/badge.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/texture2d/banner.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/texture2d/bg.jpg +0 -0
- nonebot_plugin_l4d2_server/l4_help/texture2d/button.png +0 -0
- nonebot_plugin_l4d2_server/l4_help/texture2d/icon.png +0 -0
- nonebot_plugin_l4d2_server/l4_image/__init__.py +16 -0
- nonebot_plugin_l4d2_server/l4_image/anne_pil.py +17 -0
- nonebot_plugin_l4d2_server/l4_image/convert.py +175 -0
- nonebot_plugin_l4d2_server/{l4d2_image → l4_image}/download.py +11 -35
- nonebot_plugin_l4d2_server/l4_image/html_img.py +105 -0
- nonebot_plugin_l4d2_server/l4_image/image_tools.py +468 -0
- nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/back.png +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/anne/back1.jpg +0 -0
- nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/head/head.png +0 -0
- nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/header/logo.png +0 -0
- nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/header/player1.jpg +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.html +299 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.png +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/HYPixel11pxU-2.ttf +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.html +341 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.png +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.html +355 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.png +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/Tutumianhuatang-Bold-2.ttf +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/bilibili.svg +1 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/github.svg +1 -0
- nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/l.svg +0 -1
- nonebot_plugin_l4d2_server/l4_image/img/template/m.svg +1 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/normal.html +247 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/vac.png +0 -0
- nonebot_plugin_l4d2_server/l4_image/img/template/vac_white.png +0 -0
- nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/w.svg +1 -1
- nonebot_plugin_l4d2_server/l4_image/model.py +15 -0
- nonebot_plugin_l4d2_server/{l4d2_image → l4_image}/vtfs.py +4 -2
- nonebot_plugin_l4d2_server/l4_request/__init__.py +143 -0
- nonebot_plugin_l4d2_server/l4_request/draw_msg.py +83 -0
- nonebot_plugin_l4d2_server/utils/api/api.py +10 -0
- nonebot_plugin_l4d2_server/utils/api/models.py +137 -0
- nonebot_plugin_l4d2_server/utils/api/request.py +337 -0
- nonebot_plugin_l4d2_server/utils/database/models.py +18 -0
- nonebot_plugin_l4d2_server/{l4d2_utils → utils}/utils.py +60 -63
- {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/METADATA +57 -66
- nonebot_plugin_l4d2_server-1.0.0a2.dist-info/RECORD +96 -0
- {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/WHEEL +1 -1
- nonebot_plugin_l4d2_server/data/L4D2/image/template/help.html +0 -263
- nonebot_plugin_l4d2_server/data/L4D2/image/template/help_dack.html +0 -231
- nonebot_plugin_l4d2_server/data/L4D2/image/template/m.svg +0 -1
- nonebot_plugin_l4d2_server/data/img/white.png +0 -0
- nonebot_plugin_l4d2_server/l4d2_anne/__init__.py +0 -95
- nonebot_plugin_l4d2_server/l4d2_anne/analysis.py +0 -54
- nonebot_plugin_l4d2_server/l4d2_anne/anne_telecom.py +0 -79
- nonebot_plugin_l4d2_server/l4d2_anne/server.py +0 -47
- nonebot_plugin_l4d2_server/l4d2_anne/startand.py +0 -17
- nonebot_plugin_l4d2_server/l4d2_anne/utils.py +0 -294
- nonebot_plugin_l4d2_server/l4d2_data/__init__.py +0 -105
- nonebot_plugin_l4d2_server/l4d2_data/config.py +0 -18
- nonebot_plugin_l4d2_server/l4d2_data/players.py +0 -100
- nonebot_plugin_l4d2_server/l4d2_data/serverip.py +0 -40
- nonebot_plugin_l4d2_server/l4d2_file/__init__.py +0 -222
- nonebot_plugin_l4d2_server/l4d2_file/ayromote.py +0 -64
- nonebot_plugin_l4d2_server/l4d2_file/input_json.py +0 -77
- nonebot_plugin_l4d2_server/l4d2_file/remote.py +0 -86
- nonebot_plugin_l4d2_server/l4d2_file/utils.py +0 -104
- nonebot_plugin_l4d2_server/l4d2_image/__init__.py +0 -125
- nonebot_plugin_l4d2_server/l4d2_image/htmlimg.py +0 -18
- nonebot_plugin_l4d2_server/l4d2_image/images.py +0 -92
- nonebot_plugin_l4d2_server/l4d2_image/one.py +0 -44
- nonebot_plugin_l4d2_server/l4d2_image/send_image_tool.py +0 -32
- nonebot_plugin_l4d2_server/l4d2_image/steam.py +0 -63
- nonebot_plugin_l4d2_server/l4d2_push/__init__.py +0 -225
- nonebot_plugin_l4d2_server/l4d2_queries/__init__.py +0 -326
- nonebot_plugin_l4d2_server/l4d2_queries/himi.py +0 -113
- nonebot_plugin_l4d2_server/l4d2_queries/local_ip.py +0 -41
- nonebot_plugin_l4d2_server/l4d2_queries/qqgroup.py +0 -370
- nonebot_plugin_l4d2_server/l4d2_queries/send_msg.py +0 -131
- nonebot_plugin_l4d2_server/l4d2_queries/utils.py +0 -212
- nonebot_plugin_l4d2_server/l4d2_server/__init__.py +0 -118
- nonebot_plugin_l4d2_server/l4d2_server/index.py +0 -0
- nonebot_plugin_l4d2_server/l4d2_server/rcon.py +0 -53
- nonebot_plugin_l4d2_server/l4d2_server/workshop.py +0 -82
- nonebot_plugin_l4d2_server/l4d2_update/__init__.py +0 -137
- nonebot_plugin_l4d2_server/l4d2_update/draw_update_log.py +0 -45
- nonebot_plugin_l4d2_server/l4d2_update/restart.py +0 -69
- nonebot_plugin_l4d2_server/l4d2_update/update.py +0 -53
- nonebot_plugin_l4d2_server/l4d2_utils/classcal.py +0 -53
- nonebot_plugin_l4d2_server/l4d2_utils/command.py +0 -23
- nonebot_plugin_l4d2_server/l4d2_utils/config.py +0 -201
- nonebot_plugin_l4d2_server/l4d2_utils/message.py +0 -59
- nonebot_plugin_l4d2_server/l4d2_utils/rule.py +0 -35
- nonebot_plugin_l4d2_server/l4d2_utils/seach.py +0 -43
- nonebot_plugin_l4d2_server/l4d2_utils/txt_to_img.py +0 -32
- nonebot_plugin_l4d2_server/l4d2_web/web.py +0 -277
- nonebot_plugin_l4d2_server/l4d2_web/webUI.py +0 -506
- nonebot_plugin_l4d2_server/l4d2_web/webUI_s.py +0 -94
- nonebot_plugin_l4d2_server-0.6.6.dist-info/RECORD +0 -70
- /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/anne.html +0 -0
- /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/group_ip.html +0 -0
- /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/ip.html +0 -0
- /nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/fingerprint.svg +0 -0
- /nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/vue.css +0 -0
- /nonebot_plugin_l4d2_server/{l4d2_data/database.py → l4_request/utils.py} +0 -0
- {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/licenses/LICENSE +0 -0
@@ -4,8 +4,10 @@ from nonebot.log import logger
|
|
4
4
|
from PIL import Image as Image
|
5
5
|
from srctools.vtf import VTF, ImageFormats
|
6
6
|
|
7
|
+
# 以下部分测试喷漆失败,todo
|
7
8
|
|
8
|
-
|
9
|
+
|
10
|
+
async def img_to_vtf(pic_byte: bytes, tag: str) -> BytesIO:
|
9
11
|
pic = BytesIO(pic_byte)
|
10
12
|
pic = Image.open(pic).convert("RGBA")
|
11
13
|
vtf_io = BytesIO()
|
@@ -19,7 +21,7 @@ async def img_to_vtf(pic_byte: bytes, tag) -> BytesIO:
|
|
19
21
|
if tag == "覆盖":
|
20
22
|
logger.info(tag)
|
21
23
|
img2 = Image.new("RGBA", (1024, 1024), (255, 255, 255, 0))
|
22
|
-
|
24
|
+
_, _, _, a = pic.split()
|
23
25
|
img2.paste(pic, mask=a)
|
24
26
|
pic = pic.resize((1024, 1024))
|
25
27
|
elif tag == "填充":
|
@@ -0,0 +1,143 @@
|
|
1
|
+
from typing import Dict, List, Optional, cast
|
2
|
+
|
3
|
+
from nonebot.log import logger
|
4
|
+
|
5
|
+
from ..config import server_all_path
|
6
|
+
from ..l4_image import msg_to_image
|
7
|
+
from ..utils.api.models import AllServer, NserverOut, OutServer
|
8
|
+
from ..utils.utils import split_maohao
|
9
|
+
from .draw_msg import draw_one_ip, get_much_server
|
10
|
+
|
11
|
+
try:
|
12
|
+
import ujson as json
|
13
|
+
except ImportError:
|
14
|
+
import json
|
15
|
+
|
16
|
+
|
17
|
+
# 获取全部服务器信息
|
18
|
+
ALLHOST: Dict[str, List[NserverOut]] = {}
|
19
|
+
COMMAND = set()
|
20
|
+
|
21
|
+
|
22
|
+
async def get_all_server_detail():
|
23
|
+
out_list: List[AllServer] = []
|
24
|
+
for group in ALLHOST:
|
25
|
+
msg_list = await get_group_detail(group)
|
26
|
+
if msg_list is None:
|
27
|
+
continue
|
28
|
+
active_server = 0
|
29
|
+
max_server = 0
|
30
|
+
active_player = 0
|
31
|
+
max_player = 0
|
32
|
+
for index, msg in enumerate(msg_list):
|
33
|
+
max_server = index + 1
|
34
|
+
if msg["server"].max_players != 0:
|
35
|
+
active_server += 1
|
36
|
+
active_player += msg["server"].player_count
|
37
|
+
max_player += msg["server"].max_players
|
38
|
+
data = {
|
39
|
+
"command": group,
|
40
|
+
"active_server": active_server,
|
41
|
+
"max_server": max_server,
|
42
|
+
"active_player": active_player,
|
43
|
+
"max_player": max_player,
|
44
|
+
}
|
45
|
+
out_list.append(cast(AllServer, data))
|
46
|
+
|
47
|
+
# to do作图,先用文字凑合
|
48
|
+
out_msg = ""
|
49
|
+
for one in out_list:
|
50
|
+
out_msg += f"{one['command']} | 服务器{one['active_server']}/{one['max_server']} | 玩家{one['active_player']}/{one['max_player']}\n"
|
51
|
+
return out_msg
|
52
|
+
|
53
|
+
|
54
|
+
async def get_server_detail(
|
55
|
+
command: str,
|
56
|
+
_id: Optional[str] = None,
|
57
|
+
is_img: bool = True,
|
58
|
+
):
|
59
|
+
server_json = ALLHOST.get(command)
|
60
|
+
logger.info(server_json)
|
61
|
+
if server_json is None:
|
62
|
+
logger.warning("未找到这个组")
|
63
|
+
return None
|
64
|
+
|
65
|
+
if _id is None:
|
66
|
+
# 输出组信息
|
67
|
+
logger.info(f"正在请求组服务器信息 {command}")
|
68
|
+
server_dict = await get_much_server(server_json, command)
|
69
|
+
if is_img:
|
70
|
+
out_msg = await msg_to_image(server_dict)
|
71
|
+
else:
|
72
|
+
out_msg = server_dict
|
73
|
+
return out_msg
|
74
|
+
|
75
|
+
# 返回单个
|
76
|
+
logger.info("正在请求单服务器信息")
|
77
|
+
out_msg = ""
|
78
|
+
for i in server_json:
|
79
|
+
if str(_id) == str(i["id"]):
|
80
|
+
out_msg = await draw_one_ip(i["host"], i["port"])
|
81
|
+
if is_img:
|
82
|
+
return cast(bytes, out_msg)
|
83
|
+
if not is_img:
|
84
|
+
return cast(List[OutServer], out_msg)
|
85
|
+
# print(out_msg)
|
86
|
+
return None
|
87
|
+
|
88
|
+
|
89
|
+
async def get_group_detail(
|
90
|
+
command: str,
|
91
|
+
):
|
92
|
+
server_json = ALLHOST.get(command)
|
93
|
+
logger.info(server_json)
|
94
|
+
if server_json is None:
|
95
|
+
logger.warning("未找到这个组")
|
96
|
+
return None
|
97
|
+
|
98
|
+
logger.info("正在请求组服务器信息")
|
99
|
+
return await get_much_server(server_json, command)
|
100
|
+
|
101
|
+
|
102
|
+
async def get_ip_server(ip: str):
|
103
|
+
host, port = split_maohao(ip)
|
104
|
+
return await draw_one_ip(host, port)
|
105
|
+
|
106
|
+
|
107
|
+
# 以下是重载ip
|
108
|
+
def reload_ip():
|
109
|
+
global COMMAND
|
110
|
+
# print("正在读取json文件")
|
111
|
+
group_ip = []
|
112
|
+
for item in server_all_path.iterdir():
|
113
|
+
if item.is_file():
|
114
|
+
if item.name.endswith("json"):
|
115
|
+
json_data = json.loads(item.read_text(encoding="utf-8"))
|
116
|
+
group_server = cast(Dict[str, List[NserverOut]], json_data)
|
117
|
+
|
118
|
+
for group, group_ip in group_server.items():
|
119
|
+
# 处理ip,host,port关系
|
120
|
+
for one_ip in group_ip:
|
121
|
+
if one_ip.get("ip"):
|
122
|
+
if one_ip.get("host") and one_ip.get("port"):
|
123
|
+
pass
|
124
|
+
if one_ip.get("host") and not one_ip.get("port"):
|
125
|
+
one_ip["port"] = 20715
|
126
|
+
if not one_ip.get("host"):
|
127
|
+
one_ip["host"], one_ip["port"] = split_maohao(
|
128
|
+
one_ip.get("ip"),
|
129
|
+
)
|
130
|
+
else:
|
131
|
+
if one_ip.get("host") and one_ip.get("port"):
|
132
|
+
one_ip["ip"] = f'{one_ip["host"]}:{one_ip["port"]}'
|
133
|
+
if one_ip.get("host") and not one_ip.get("port"):
|
134
|
+
one_ip["ip"] = f'{one_ip["host"]}:20715'
|
135
|
+
else:
|
136
|
+
logger.warning(f"{one_ip} 没有ip")
|
137
|
+
|
138
|
+
ALLHOST.update({group: group_ip})
|
139
|
+
COMMAND.add(group)
|
140
|
+
logger.success(f"成功加载 {item.name.split('.')[0]} {len(group_ip)}个")
|
141
|
+
|
142
|
+
if item.name.endswith("txt"):
|
143
|
+
"""to do"""
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import asyncio
|
2
|
+
|
3
|
+
# from logging import log
|
4
|
+
from typing import List, Tuple
|
5
|
+
|
6
|
+
from ..config import config
|
7
|
+
from ..utils.api.models import NserverOut, OutServer
|
8
|
+
from ..utils.api.request import L4API
|
9
|
+
|
10
|
+
|
11
|
+
async def draw_one_ip(host: str, port: int):
|
12
|
+
"""输出单个ip"""
|
13
|
+
# 先用文字凑合
|
14
|
+
try:
|
15
|
+
ser_list = await L4API.a2s_info([(host, port)], is_player=True)
|
16
|
+
except asyncio.exceptions.TimeoutError:
|
17
|
+
return "服务器无响应"
|
18
|
+
player_msg = ""
|
19
|
+
one_server = ser_list[0][0]
|
20
|
+
one_player = ser_list[0][1]
|
21
|
+
|
22
|
+
if len(one_player):
|
23
|
+
max_duration_len = max(
|
24
|
+
[len(str(await convert_duration(i.duration))) for i in one_player],
|
25
|
+
)
|
26
|
+
max_score_len = max(len(str(i.score)) for i in one_player)
|
27
|
+
|
28
|
+
for player in one_player:
|
29
|
+
soc = "[{:>{}}]".format(player.score, max_score_len)
|
30
|
+
chines_dur = await convert_duration(player.duration)
|
31
|
+
dur = "{:^{}}".format(chines_dur, max_duration_len)
|
32
|
+
|
33
|
+
player_msg += f"{soc} | {dur} | {player.name} \n"
|
34
|
+
else:
|
35
|
+
player_msg = "服务器感觉很安静啊"
|
36
|
+
|
37
|
+
msg = f"""*{one_server.server_name}*
|
38
|
+
游戏: {one_server.folder}
|
39
|
+
地图: {one_server.map_name}
|
40
|
+
人数: {one_server.player_count}/{one_server.max_players}"""
|
41
|
+
if one_server.ping is not None:
|
42
|
+
msg += f"""
|
43
|
+
ping: {one_server.ping * 1000:.0f}ms
|
44
|
+
{player_msg}"""
|
45
|
+
if config.l4_show_ip:
|
46
|
+
msg += f"""
|
47
|
+
connect {host}:{port}"""
|
48
|
+
return msg
|
49
|
+
|
50
|
+
|
51
|
+
async def get_much_server(server_json: List[NserverOut], command: str):
|
52
|
+
out_server: List[OutServer] = []
|
53
|
+
search_list: List[Tuple[str, int]] = []
|
54
|
+
for i in server_json:
|
55
|
+
search_list.append((i["host"], i["port"])) # noqa: PERF401
|
56
|
+
|
57
|
+
all_server = await L4API.a2s_info(search_list, is_player=True)
|
58
|
+
|
59
|
+
for index, i in enumerate(all_server):
|
60
|
+
out_server.append(
|
61
|
+
{
|
62
|
+
"server": i[0],
|
63
|
+
"player": i[1],
|
64
|
+
"host": server_json[index]["host"],
|
65
|
+
"port": server_json[index]["port"],
|
66
|
+
"command": command,
|
67
|
+
"id_": server_json[index]["id"],
|
68
|
+
},
|
69
|
+
)
|
70
|
+
|
71
|
+
return out_server
|
72
|
+
|
73
|
+
|
74
|
+
async def convert_duration(duration: float) -> str:
|
75
|
+
minutes, seconds = divmod(duration, 60)
|
76
|
+
hours, minutes = divmod(minutes, 60)
|
77
|
+
time_str = ""
|
78
|
+
if hours > 0:
|
79
|
+
time_str += f"{int(hours)}h "
|
80
|
+
if minutes > 0:
|
81
|
+
time_str += f"{int(minutes)}m "
|
82
|
+
time_str += f"{int(seconds)}s"
|
83
|
+
return time_str
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# coding=utf-8
|
2
|
+
|
3
|
+
|
4
|
+
anne_ban = "https://sb.trygek.com/"
|
5
|
+
"""anne电信服网址,sourceban++"""
|
6
|
+
anne_ser = f"{anne_ban}l4d_stats/"
|
7
|
+
AnneRankApi = f"{anne_ser}ranking/index.php?type=coop"
|
8
|
+
AnnePlayerApi = f"{anne_ser}ranking/player.php?steamid="
|
9
|
+
# post
|
10
|
+
AnneSearchApi = f"{anne_ser}/ranking/search.php"
|
@@ -0,0 +1,137 @@
|
|
1
|
+
# coding=utf-8
|
2
|
+
from typing import List, Optional, TypedDict
|
3
|
+
|
4
|
+
import a2s
|
5
|
+
from pydantic import BaseModel
|
6
|
+
|
7
|
+
|
8
|
+
class SourceBansInfo(BaseModel):
|
9
|
+
"""source服务器信息"""
|
10
|
+
|
11
|
+
index: int
|
12
|
+
host: str
|
13
|
+
port: int
|
14
|
+
|
15
|
+
|
16
|
+
class NserverOut(TypedDict):
|
17
|
+
id: int
|
18
|
+
ip: str
|
19
|
+
host: str
|
20
|
+
port: int
|
21
|
+
version: Optional[str]
|
22
|
+
|
23
|
+
|
24
|
+
class OutServer(TypedDict):
|
25
|
+
server: a2s.SourceInfo
|
26
|
+
player: List[a2s.Player]
|
27
|
+
host: str
|
28
|
+
port: int
|
29
|
+
command: str
|
30
|
+
id_: int
|
31
|
+
|
32
|
+
|
33
|
+
class AnnePlayer(TypedDict):
|
34
|
+
mode: str
|
35
|
+
name: str
|
36
|
+
source: str
|
37
|
+
playtime: str
|
38
|
+
|
39
|
+
|
40
|
+
class AllServer(TypedDict):
|
41
|
+
command: str
|
42
|
+
active_server: int
|
43
|
+
max_server: int
|
44
|
+
active_player: int
|
45
|
+
max_player: int
|
46
|
+
|
47
|
+
|
48
|
+
class AnneSearch(TypedDict):
|
49
|
+
steamid: str
|
50
|
+
rank: str
|
51
|
+
name: str
|
52
|
+
score: str
|
53
|
+
play_time: str
|
54
|
+
last_time: str
|
55
|
+
|
56
|
+
|
57
|
+
class AnnePlayerDetail(TypedDict):
|
58
|
+
rank: int
|
59
|
+
source: str
|
60
|
+
avg_source: float
|
61
|
+
kills: str
|
62
|
+
kills_people: str
|
63
|
+
headshots: str
|
64
|
+
avg_headshots: float
|
65
|
+
map_play: str
|
66
|
+
|
67
|
+
|
68
|
+
class AnnePlayerError(TypedDict):
|
69
|
+
mistake_shout: str
|
70
|
+
kill_friend: str
|
71
|
+
down_friend: str
|
72
|
+
abandon_friend: str
|
73
|
+
put_into: str
|
74
|
+
agitate_witch: str
|
75
|
+
|
76
|
+
|
77
|
+
class AnnePlayerInfAvg(TypedDict):
|
78
|
+
avg_smoker: float
|
79
|
+
avg_boomer: float
|
80
|
+
avg_hunter: float
|
81
|
+
avg_charger: float
|
82
|
+
avg_spitter: float
|
83
|
+
avg_jockey: float
|
84
|
+
avg_tank: float
|
85
|
+
|
86
|
+
|
87
|
+
class AnnePlayerSur(TypedDict):
|
88
|
+
map_clear: str
|
89
|
+
prefect_into: str
|
90
|
+
get_oil: str
|
91
|
+
ammo_arrange: str
|
92
|
+
adrenaline_give: str
|
93
|
+
pills_give: str
|
94
|
+
"""给药"""
|
95
|
+
first_aid_give: str
|
96
|
+
"""给包"""
|
97
|
+
friend_up: str
|
98
|
+
diss_friend: str
|
99
|
+
save_friend: str
|
100
|
+
protect_friend: str
|
101
|
+
pro_from_smoker: str
|
102
|
+
pro_from_hunter: str
|
103
|
+
pro_from_charger: str
|
104
|
+
pro_from_jockey: str
|
105
|
+
melee_charge: str
|
106
|
+
"""刀牛"""
|
107
|
+
tank_kill: str
|
108
|
+
witch_instantly_kill: str
|
109
|
+
"""秒妹"""
|
110
|
+
|
111
|
+
|
112
|
+
class AnnePlayerInf(TypedDict):
|
113
|
+
sur_ace: str
|
114
|
+
sur_down: str
|
115
|
+
boommer_hit: str
|
116
|
+
hunter_prefect: str
|
117
|
+
hunter_success: str
|
118
|
+
tank_damage: str
|
119
|
+
charger_multiple: str
|
120
|
+
|
121
|
+
|
122
|
+
class AnnePlayerInfo(TypedDict):
|
123
|
+
name: str
|
124
|
+
avatar: str
|
125
|
+
steamid: str
|
126
|
+
playtime: str
|
127
|
+
lasttime: str
|
128
|
+
|
129
|
+
|
130
|
+
class AnnePlayer2(TypedDict):
|
131
|
+
kill_msg: str
|
132
|
+
info: AnnePlayerInfo
|
133
|
+
detail: AnnePlayerDetail
|
134
|
+
error: AnnePlayerError
|
135
|
+
inf_avg: AnnePlayerInfAvg
|
136
|
+
sur: AnnePlayerSur
|
137
|
+
inf: AnnePlayerInf
|