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
@@ -1,370 +0,0 @@
|
|
1
|
-
import asyncio
|
2
|
-
import random
|
3
|
-
from pathlib import Path
|
4
|
-
from typing import Dict, List, Tuple
|
5
|
-
|
6
|
-
import a2s
|
7
|
-
import aiofiles
|
8
|
-
from nonebot.log import logger
|
9
|
-
|
10
|
-
from ..l4d2_data.serverip import L4D2Server
|
11
|
-
from ..l4d2_image import server_ip_pic
|
12
|
-
from ..l4d2_utils.classcal import ServerStatus
|
13
|
-
from ..l4d2_utils.message import KAILAO, PRISON, QUEREN
|
14
|
-
from ..l4d2_utils.utils import split_maohao
|
15
|
-
from .local_ip import ALL_HOST
|
16
|
-
from .utils import (
|
17
|
-
msg_ip_to_list,
|
18
|
-
player_queries,
|
19
|
-
player_queries_anne_dict,
|
20
|
-
queries,
|
21
|
-
queries_dict,
|
22
|
-
)
|
23
|
-
|
24
|
-
try:
|
25
|
-
import ujson as json
|
26
|
-
except ImportError:
|
27
|
-
import json
|
28
|
-
si = L4D2Server()
|
29
|
-
errors = (
|
30
|
-
ConnectionRefusedError,
|
31
|
-
ConnectionResetError,
|
32
|
-
asyncio.exceptions.TimeoutError,
|
33
|
-
OSError,
|
34
|
-
)
|
35
|
-
# errors = (TypeError,KeyError,ValueError,ConnectionResetError,TimeoutError)
|
36
|
-
|
37
|
-
|
38
|
-
async def get_qqgroup_ip_msg(qqgroup):
|
39
|
-
"""首先,获取qq群订阅数据,再依次queries返回ip原标"""
|
40
|
-
return await si.query_server_ip(qqgroup)
|
41
|
-
|
42
|
-
|
43
|
-
async def bind_group_ip(group: int, host: str, port: int):
|
44
|
-
ip_list = await si.query_server_ip(group)
|
45
|
-
if (host, port) in ip_list:
|
46
|
-
return "本群已添加过该ip辣"
|
47
|
-
await si.bind_server_ip(group, host, port)
|
48
|
-
return "绑定成功喵,新增ip" + host
|
49
|
-
|
50
|
-
|
51
|
-
async def del_group_ip(group: int, number: int):
|
52
|
-
number = int(number)
|
53
|
-
logger.info(number)
|
54
|
-
try:
|
55
|
-
groups, host, port = await si.query_number(number)
|
56
|
-
except TypeError:
|
57
|
-
return "没有这个序号哦"
|
58
|
-
if groups != group:
|
59
|
-
return "本群可没有订阅过这个ip"
|
60
|
-
await si.del_server_ip(number)
|
61
|
-
return "取消成功喵,已删除序号" + str(number)
|
62
|
-
|
63
|
-
|
64
|
-
async def qq_ip_queries(msg: List[tuple]):
|
65
|
-
"""输入一个ip的二元元组组成的列表,返回一个输出消息的列表
|
66
|
-
未来作图这里重置"""
|
67
|
-
messsage = ""
|
68
|
-
for i in msg:
|
69
|
-
number, qqgroup, host, port = i
|
70
|
-
msg2 = await player_queries(host, port)
|
71
|
-
msg1 = await queries(host, port)
|
72
|
-
messsage += f"序号、{number!s} \n{msg1}{msg2}--------------------\n"
|
73
|
-
return messsage
|
74
|
-
|
75
|
-
|
76
|
-
async def qq_ip_querie(msg: List[Tuple[str, str, int]], igr: bool = True):
|
77
|
-
msg_list: List[ServerStatus] = []
|
78
|
-
tasks = [] # 用来保存异步任务
|
79
|
-
if msg != []:
|
80
|
-
for i in msg:
|
81
|
-
try:
|
82
|
-
number: str
|
83
|
-
host: str
|
84
|
-
port: int
|
85
|
-
qqgroup: str = "" # 初始化为""
|
86
|
-
if len(i) == 3:
|
87
|
-
number, host, port = i
|
88
|
-
else:
|
89
|
-
number, qqgroup, host, port = i # type: ignore
|
90
|
-
# 将异步任务添加到任务列表中
|
91
|
-
tasks.append(
|
92
|
-
asyncio.create_task(
|
93
|
-
process_message(
|
94
|
-
number,
|
95
|
-
host,
|
96
|
-
port,
|
97
|
-
msg_list,
|
98
|
-
igr,
|
99
|
-
qqgroup,
|
100
|
-
),
|
101
|
-
),
|
102
|
-
)
|
103
|
-
except ValueError:
|
104
|
-
continue # 处理异常情况
|
105
|
-
# 等待所有异步任务完成
|
106
|
-
await asyncio.gather(*tasks)
|
107
|
-
# 对msg_list按照number顺序排序
|
108
|
-
# msg_list.sort(key=lambda x: x["number"])
|
109
|
-
send_list = sorted(msg_list, key=lambda x: int(x.number))
|
110
|
-
result = {"msg_list": send_list}
|
111
|
-
|
112
|
-
else:
|
113
|
-
result: Dict[str, List[ServerStatus]] = {}
|
114
|
-
return result
|
115
|
-
|
116
|
-
|
117
|
-
async def qq_ip_queries_pic(msg: list, igr=False):
|
118
|
-
result = await qq_ip_querie(msg, igr)
|
119
|
-
if "msg_list" in result:
|
120
|
-
pic = await server_ip_pic(result["msg_list"])
|
121
|
-
else:
|
122
|
-
pic = None
|
123
|
-
return pic
|
124
|
-
|
125
|
-
|
126
|
-
async def process_message(
|
127
|
-
number: str,
|
128
|
-
host: str,
|
129
|
-
port: int,
|
130
|
-
msg_list: List[ServerStatus],
|
131
|
-
igr: bool,
|
132
|
-
qqgroup: str = "",
|
133
|
-
):
|
134
|
-
try:
|
135
|
-
msg2 = await player_queries_anne_dict(host, port)
|
136
|
-
msg1 = await queries_dict(host, port)
|
137
|
-
msg3 = await server_rule_dict(host, port)
|
138
|
-
msg1.update(
|
139
|
-
{
|
140
|
-
"Players": msg2,
|
141
|
-
"number": number,
|
142
|
-
},
|
143
|
-
)
|
144
|
-
msg1.update(msg3)
|
145
|
-
if qqgroup:
|
146
|
-
msg1.update({"tag": qqgroup})
|
147
|
-
msg_list.append(ServerStatus(**msg1))
|
148
|
-
except errors:
|
149
|
-
if igr:
|
150
|
-
pass
|
151
|
-
else:
|
152
|
-
# 空白字典
|
153
|
-
null_dict = ServerStatus(number=number)
|
154
|
-
msg_list.append(null_dict)
|
155
|
-
|
156
|
-
|
157
|
-
async def get_tan_jian(msg: List[tuple], mode: int):
|
158
|
-
"""获取anne列表抽一个"""
|
159
|
-
msg_list = []
|
160
|
-
random.shuffle(msg)
|
161
|
-
for i in msg:
|
162
|
-
number, host, port = i
|
163
|
-
try:
|
164
|
-
if mode == 1:
|
165
|
-
# 探监
|
166
|
-
msg2 = await player_queries_anne_dict(host, port)
|
167
|
-
point = 0
|
168
|
-
for i in msg2:
|
169
|
-
point += int(i["Score"])
|
170
|
-
logger.info(point)
|
171
|
-
msg1 = await queries_dict(host, port)
|
172
|
-
sp: str = msg1["name"]
|
173
|
-
if "特" not in sp:
|
174
|
-
continue
|
175
|
-
sps = int(sp.split("特")[0].split("[")[-1])
|
176
|
-
points = point / 4
|
177
|
-
if points / sps < 10:
|
178
|
-
continue
|
179
|
-
if "HT" in msg1["name"]:
|
180
|
-
continue
|
181
|
-
msg1.update({"Players": msg2})
|
182
|
-
msg1.update({"ranks": point})
|
183
|
-
ips = f"{host}:{port!s}"
|
184
|
-
msg1.update({"ips": ips})
|
185
|
-
# msg1是一行数据完整的字典
|
186
|
-
msg_list.append(msg1)
|
187
|
-
if mode == 2:
|
188
|
-
# 坐牢
|
189
|
-
# try:
|
190
|
-
msg1 = await queries_dict(host, port)
|
191
|
-
if "普通药役" in msg1["name"]:
|
192
|
-
if "缺人" in msg1["name"]:
|
193
|
-
msg2 = await player_queries_anne_dict(host, port)
|
194
|
-
msg1.update({"Players": msg2})
|
195
|
-
ips = f"{host}:{port!s}"
|
196
|
-
msg1.update({"ips": ips})
|
197
|
-
# msg1是一行数据完整的字典
|
198
|
-
else:
|
199
|
-
continue
|
200
|
-
else:
|
201
|
-
continue
|
202
|
-
msg_list.append(msg1)
|
203
|
-
if mode == 3:
|
204
|
-
# 开牢
|
205
|
-
msg1 = await queries_dict(host, port)
|
206
|
-
if "[" not in msg1["name"]:
|
207
|
-
msg2 = await player_queries_anne_dict(host, port)
|
208
|
-
msg1.update({"Players": msg2})
|
209
|
-
ips = f"{host}:{port!s}"
|
210
|
-
msg1.update({"ips": ips})
|
211
|
-
# msg1是一行数据完整的字典
|
212
|
-
msg_list.append(msg1)
|
213
|
-
except errors:
|
214
|
-
continue
|
215
|
-
if msg_list != []:
|
216
|
-
break
|
217
|
-
# 随机选一个牢房
|
218
|
-
logger.info(msg_list)
|
219
|
-
if len(msg_list) == 0:
|
220
|
-
return "暂时没有这种牢房捏"
|
221
|
-
logger.info(len(msg_list))
|
222
|
-
mse = msg_list[0]
|
223
|
-
message: str = ""
|
224
|
-
if mode == 1:
|
225
|
-
ranks = mse["ranks"]
|
226
|
-
if ranks <= 300:
|
227
|
-
message = random.choice(PRISON[1])
|
228
|
-
if 300 < ranks <= 450:
|
229
|
-
message = random.choice(PRISON[2])
|
230
|
-
if ranks > 450:
|
231
|
-
message = random.choice(PRISON[3])
|
232
|
-
if mode == 2:
|
233
|
-
player_point = mse["players"]
|
234
|
-
if player_point == "1":
|
235
|
-
message = random.choice(QUEREN[1])
|
236
|
-
elif player_point == "2":
|
237
|
-
message = random.choice(QUEREN[2])
|
238
|
-
elif player_point == "3":
|
239
|
-
message = random.choice(QUEREN[3])
|
240
|
-
else:
|
241
|
-
message = random.choice(QUEREN[4])
|
242
|
-
if mode == 3:
|
243
|
-
message = random.choice(KAILAO)
|
244
|
-
message += f"\n名称:{mse['name']}\n"
|
245
|
-
message += f"地图:{mse['map_']} \n"
|
246
|
-
message += f"玩家:{mse['players']} / {mse['max_players']}\n"
|
247
|
-
try:
|
248
|
-
message += await msg_ip_to_list(mse["Players"])
|
249
|
-
except KeyError:
|
250
|
-
message += "服务器里,是空空的呢\n"
|
251
|
-
return message
|
252
|
-
|
253
|
-
|
254
|
-
async def get_server_ip(number):
|
255
|
-
group, host, port = await si.query_number(number)
|
256
|
-
try:
|
257
|
-
return str(host) + ":" + str(port)
|
258
|
-
except TypeError:
|
259
|
-
return None
|
260
|
-
|
261
|
-
|
262
|
-
async def write_json(data_str: str):
|
263
|
-
"""
|
264
|
-
添加数据或者删除数据
|
265
|
-
- 【求生更新 添加 腐竹 ip 模式 序号】
|
266
|
-
- 【求生更新 添加 腐竹 ip 模式】
|
267
|
-
- 【求生更新 删除 腐竹 序号】
|
268
|
-
"""
|
269
|
-
data_list = data_str.split()
|
270
|
-
logger.info(data_list)
|
271
|
-
if data_list[0] == "添加":
|
272
|
-
add_server = {}
|
273
|
-
server_dict = ALL_HOST.get(data_list[1], {})
|
274
|
-
if not server_dict:
|
275
|
-
logger.info("新建分支")
|
276
|
-
ALL_HOST[data_list[1]] = []
|
277
|
-
for key, value in ALL_HOST.items():
|
278
|
-
if data_list[1] == key:
|
279
|
-
ids = [server["id"] for server in value]
|
280
|
-
# 序号
|
281
|
-
if len(data_list) == 4:
|
282
|
-
data_num = int(max(ids, default=0)) + 1
|
283
|
-
add_server.update({"id": data_num})
|
284
|
-
elif len(data_list) == 5:
|
285
|
-
if not data_list[4].isdigit():
|
286
|
-
return "请输入【求生更新 添加 腐竹 ip 模式 序号】"
|
287
|
-
data_num = int(data_list[4])
|
288
|
-
if data_num in ids:
|
289
|
-
return "该序号已存在,请删除原序号【求生更新 删除 腐竹 序号】"
|
290
|
-
add_server.update({"id": data_num})
|
291
|
-
else:
|
292
|
-
return "请输入【求生更新 添加 腐竹 ip 模式 序号】"
|
293
|
-
# 模式,ip
|
294
|
-
try:
|
295
|
-
host, port = split_maohao(data_list[2])
|
296
|
-
add_server.update({"host": host, "port": port})
|
297
|
-
except KeyError:
|
298
|
-
return "ip格式不正确【114.11.4.514:9191】"
|
299
|
-
add_server.update({"version": data_list[3]})
|
300
|
-
value.append(add_server)
|
301
|
-
ALL_HOST[key] = value
|
302
|
-
with Path("data/L4D2/l4d2.json").open("w", encoding="utf8") as f_new:
|
303
|
-
json.dump(ALL_HOST, f_new, ensure_ascii=False, indent=4)
|
304
|
-
return f"添加成功,指令为{key}{data_num}"
|
305
|
-
return None
|
306
|
-
|
307
|
-
if data_list[0] == "删除":
|
308
|
-
for key, value in ALL_HOST.items():
|
309
|
-
if data_list[1] == key:
|
310
|
-
try:
|
311
|
-
data_num = int(data_list[2])
|
312
|
-
except ValueError:
|
313
|
-
return "序号应该为大于0的正整数,请输入【求生更新 删除 腐竹 序号】"
|
314
|
-
for i, server in enumerate(value):
|
315
|
-
if data_num == server["id"]:
|
316
|
-
value.pop(i)
|
317
|
-
if not value:
|
318
|
-
ALL_HOST.pop(key)
|
319
|
-
async with aiofiles.open(
|
320
|
-
"data/L4D2/l4d2.json",
|
321
|
-
"w",
|
322
|
-
encoding="utf8",
|
323
|
-
) as f_new:
|
324
|
-
await f_new.write(
|
325
|
-
json.dumps(ALL_HOST, ensure_ascii=False, indent=4),
|
326
|
-
)
|
327
|
-
await f_new.flush()
|
328
|
-
return "删除成功喵"
|
329
|
-
return "序号不正确,请输入【求生更新 删除 腐竹 序号】"
|
330
|
-
return "腐竹名不存在,请输入【求生更新 删除 腐竹 序号】"
|
331
|
-
return None
|
332
|
-
|
333
|
-
|
334
|
-
async def add_ip(group_id, host, port):
|
335
|
-
"""先查找是否存在,如果不存在则创建"""
|
336
|
-
return await bind_group_ip(group_id, host, port)
|
337
|
-
|
338
|
-
|
339
|
-
async def del_ip(group_id, number):
|
340
|
-
"""删除群ip"""
|
341
|
-
return await del_group_ip(group_id, number)
|
342
|
-
|
343
|
-
|
344
|
-
async def show_ip(group_id):
|
345
|
-
"""先查找群ip,再根据群ip返回"""
|
346
|
-
data_list = await get_qqgroup_ip_msg(group_id)
|
347
|
-
logger.info(data_list)
|
348
|
-
if len(data_list) == 0:
|
349
|
-
return "本群没有订阅"
|
350
|
-
return await qq_ip_queries_pic(data_list)
|
351
|
-
|
352
|
-
|
353
|
-
async def get_number_url(number):
|
354
|
-
ip = await get_server_ip(number)
|
355
|
-
if not ip:
|
356
|
-
return "该序号不存在"
|
357
|
-
return f"connect {ip}"
|
358
|
-
|
359
|
-
|
360
|
-
async def server_rule_dict(ip: str, port: int):
|
361
|
-
port = int(port)
|
362
|
-
ip = str(ip)
|
363
|
-
msg_dict = {}
|
364
|
-
# message_dict = await l4d(ip,port)
|
365
|
-
try:
|
366
|
-
msg: dict = await a2s.arules((ip, port)) # type: ignore
|
367
|
-
msg_dict["tick"] = msg["l4d2_tickrate_enabler"] + "tick"
|
368
|
-
except Exception:
|
369
|
-
msg_dict["tick"] = ""
|
370
|
-
return msg_dict
|
@@ -1,131 +0,0 @@
|
|
1
|
-
import asyncio
|
2
|
-
from typing import Dict, List, Optional, Tuple
|
3
|
-
|
4
|
-
from nonebot.log import logger
|
5
|
-
from nonebot_plugin_saa import Image, Text
|
6
|
-
|
7
|
-
from ..l4d2_queries.local_ip import ALL_HOST
|
8
|
-
from ..l4d2_queries.qqgroup import qq_ip_queries_pic
|
9
|
-
from ..l4d2_queries.utils import get_anne_server_ip, json_server_to_tag_dict
|
10
|
-
from ..l4d2_utils.classcal import ServerGroup, ServerStatus
|
11
|
-
from ..l4d2_utils.utils import split_maohao
|
12
|
-
from .local_ip import Group_All_HOST
|
13
|
-
from .qqgroup import qq_ip_querie
|
14
|
-
|
15
|
-
|
16
|
-
async def get_ip_to_mes(msg: str, command: str = ""):
|
17
|
-
if not msg:
|
18
|
-
# 以图片输出全部当前
|
19
|
-
igr = False
|
20
|
-
# if command in gamemode_list:
|
21
|
-
# this_ips = [
|
22
|
-
# d for l in ALL_HOST.values() for d in l if d.get("version") == command
|
23
|
-
# ]
|
24
|
-
# igr = True
|
25
|
-
# else:
|
26
|
-
this_ips = ALL_HOST[command]
|
27
|
-
ip_list: List[Tuple[str, str, str]] = []
|
28
|
-
for one_ip in this_ips:
|
29
|
-
host, port = split_maohao(one_ip["ip"])
|
30
|
-
msg_tuple = (one_ip["id"], host, port)
|
31
|
-
ip_list.append(msg_tuple)
|
32
|
-
img = await qq_ip_queries_pic(ip_list, igr)
|
33
|
-
return [Image(img)] if img else None
|
34
|
-
|
35
|
-
if not msg[0].isdigit():
|
36
|
-
# if any(mode in msg for mode in gamemode_list):
|
37
|
-
# pass
|
38
|
-
# else:
|
39
|
-
return None
|
40
|
-
message = await json_server_to_tag_dict(command, msg)
|
41
|
-
if len(message) == 0:
|
42
|
-
# 关键词不匹配,忽略
|
43
|
-
return None
|
44
|
-
ip = str(message["ip"])
|
45
|
-
logger.info(ip)
|
46
|
-
|
47
|
-
try:
|
48
|
-
msg_send: Optional[str] = await get_anne_server_ip(ip)
|
49
|
-
if msg_send is not None:
|
50
|
-
return [Text(msg_send)]
|
51
|
-
|
52
|
-
except (OSError, asyncio.exceptions.TimeoutError):
|
53
|
-
return [Text("服务器无响应")]
|
54
|
-
|
55
|
-
|
56
|
-
# async def get_read_group_ip():
|
57
|
-
# """输出群组服务器"""
|
58
|
-
# get_grou_ip = on_command("anne", aliases=group_key(), priority=80, block=True)
|
59
|
-
|
60
|
-
# @get_grou_ip.handle()
|
61
|
-
# async def _(
|
62
|
-
# matcher: Matcher,
|
63
|
-
# start: str = CommandStart(),
|
64
|
-
# command: str = RawCommand(),
|
65
|
-
# args: Message = CommandArg(),
|
66
|
-
# ):
|
67
|
-
# if start:
|
68
|
-
# command = command.replace(start, "")
|
69
|
-
# msg: str = args.extract_plain_text()
|
70
|
-
# push_msg = await get_group_ip_to_msg(msg, command)
|
71
|
-
# msg_img = await server_group_ip_pic(push_msg)
|
72
|
-
# if isinstance(push_msg, bytes):
|
73
|
-
# await MessageFactory([Image(push_msg)]).finish()
|
74
|
-
# elif msg and type(push_msg) == list:
|
75
|
-
# await MessageFactory([Image(push_msg[0]), Text(push_msg[-1])]).finish()
|
76
|
-
# elif msg and isinstance(push_msg, str):
|
77
|
-
# await str_to_picstr(push_msg, matcher)
|
78
|
-
# await matcher.finish()
|
79
|
-
|
80
|
-
|
81
|
-
async def get_group_ip_to_msg(command: str):
|
82
|
-
"""输出群组ip的dict信息"""
|
83
|
-
if command in Group_All_HOST:
|
84
|
-
group_tag_list: List[str] = Group_All_HOST[command]
|
85
|
-
elif command in ALL_HOST:
|
86
|
-
group_tag_list = [command]
|
87
|
-
else:
|
88
|
-
return None
|
89
|
-
logger.info(f"组内关键词{group_tag_list}")
|
90
|
-
group_ip_dict: Dict[str, List[Dict[str, str]]] = {}
|
91
|
-
tag = len(group_tag_list) == 0
|
92
|
-
return_list: List[ServerGroup] = []
|
93
|
-
id_number = 0
|
94
|
-
for tag, one_group in ALL_HOST.items():
|
95
|
-
id_number += 1
|
96
|
-
if tag in group_tag_list and tag:
|
97
|
-
group_ip_dict.update({tag: one_group})
|
98
|
-
ip_tuple_list: List[Tuple[str, str, int]] = []
|
99
|
-
for one_server in one_group:
|
100
|
-
number = one_server["id"]
|
101
|
-
host, port = split_maohao(one_server["ip"])
|
102
|
-
ip_tuple_list.append((number, host, int(port)))
|
103
|
-
msg_group_server = await qq_ip_querie(ip_tuple_list)
|
104
|
-
return_list.append(
|
105
|
-
await check_group_msg(msg_group_server, id_number, command),
|
106
|
-
)
|
107
|
-
|
108
|
-
return return_list
|
109
|
-
# 还没写完
|
110
|
-
# host, port = split_maohao(one_ip["ip"])
|
111
|
-
# msg_tuple = (one_ip["id"], host, port)
|
112
|
-
# ip_list.append(msg_tuple)
|
113
|
-
# img = await qq_ip_queries_pic(ip_list, igr)
|
114
|
-
|
115
|
-
|
116
|
-
async def check_group_msg(msg: Dict[str, List[ServerStatus]], number: int, command: str):
|
117
|
-
server_info = ServerGroup()
|
118
|
-
server_info.server_id = number
|
119
|
-
|
120
|
-
for server_group in msg["msg_list"]:
|
121
|
-
# 服务器,服务器玩家数量
|
122
|
-
# 当前/总数
|
123
|
-
server_info.server_tag = command
|
124
|
-
if server_group.name == "null":
|
125
|
-
server_info.server_all_number += 1
|
126
|
-
continue
|
127
|
-
server_info.server_all_number += 1
|
128
|
-
server_info.server_number += 1
|
129
|
-
server_info.server_people += server_group.players
|
130
|
-
server_info.server_all_people += server_group.max_players
|
131
|
-
return server_info
|