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,294 +0,0 @@
|
|
1
|
-
from typing import List
|
2
|
-
|
3
|
-
import httpx
|
4
|
-
import pandas as pd
|
5
|
-
from bs4 import BeautifulSoup
|
6
|
-
from nonebot.log import logger
|
7
|
-
|
8
|
-
from ..l4d2_data.players import L4D2Player
|
9
|
-
from ..l4d2_image import out_png
|
10
|
-
from ..l4d2_utils.seach import anne_search
|
11
|
-
from .analysis import df_to_guoguanlv
|
12
|
-
|
13
|
-
# from .anne_telecom import ANNE_API
|
14
|
-
|
15
|
-
|
16
|
-
s = L4D2Player()
|
17
|
-
headers = {
|
18
|
-
"User-Agent": (
|
19
|
-
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) "
|
20
|
-
"Gecko/20100101 Firefox/107.0"
|
21
|
-
),
|
22
|
-
}
|
23
|
-
|
24
|
-
|
25
|
-
async def anne_html(name: str):
|
26
|
-
"""搜索里提取玩家信息,返回列表字典"""
|
27
|
-
data_title = anne_search(name)
|
28
|
-
if not data_title:
|
29
|
-
return None
|
30
|
-
data = data_title[0]
|
31
|
-
title = data_title[1]
|
32
|
-
if len(data) == 0 or data[0] == "No Player found.":
|
33
|
-
return []
|
34
|
-
data_list: list = []
|
35
|
-
logger.info(data)
|
36
|
-
for i in data:
|
37
|
-
i: BeautifulSoup
|
38
|
-
|
39
|
-
def find_text(soup, attr_en, attr_alt):
|
40
|
-
try:
|
41
|
-
element = soup.find("td", {"data-title": attr_en})
|
42
|
-
if element is None:
|
43
|
-
element = soup.find("td", {"data-title": attr_alt})
|
44
|
-
return element.text.strip() if element else ""
|
45
|
-
except AttributeError:
|
46
|
-
return ""
|
47
|
-
|
48
|
-
rank = find_text(i, "Rank:", "排名:")
|
49
|
-
player = find_text(i, "Player:", "玩家:")
|
50
|
-
points = find_text(i, "Points:", "分数:")
|
51
|
-
playtime = find_text(i, "Playtime:", "游玩时间:")
|
52
|
-
last_online = find_text(i, "Last Online:", "最后上线时间:")
|
53
|
-
onclick = i["onclick"]
|
54
|
-
steamid = onclick.split("=")[2].strip("'") # type: ignore
|
55
|
-
play_json = {
|
56
|
-
title[0]: rank,
|
57
|
-
title[1]: player,
|
58
|
-
title[2]: points,
|
59
|
-
# title[3]:country,
|
60
|
-
title[3]: playtime,
|
61
|
-
title[4]: last_online,
|
62
|
-
title[5]: steamid,
|
63
|
-
}
|
64
|
-
data_list.append(play_json)
|
65
|
-
logger.info("搜寻数据")
|
66
|
-
return data_list
|
67
|
-
|
68
|
-
|
69
|
-
def anne_html_msg(data_list: list):
|
70
|
-
"""从搜索结果的字典列表中,返回发送信息"""
|
71
|
-
mes = "搜索到以下玩家信息"
|
72
|
-
ns = 0
|
73
|
-
|
74
|
-
for one in data_list:
|
75
|
-
one: dict
|
76
|
-
ns += 1
|
77
|
-
x = 6
|
78
|
-
|
79
|
-
titles = list(one.keys())
|
80
|
-
for i in range(x):
|
81
|
-
mes += "\n" + titles[i] + ":" + str(one[titles[i]])
|
82
|
-
mes += "\n--------------------"
|
83
|
-
if ns > 4:
|
84
|
-
break
|
85
|
-
return mes
|
86
|
-
|
87
|
-
|
88
|
-
async def write_player(id_, msg: str, nickname: str):
|
89
|
-
"""绑定用户"""
|
90
|
-
# 判断是steam
|
91
|
-
if msg.startswith("STEAM"):
|
92
|
-
# try:
|
93
|
-
data_tuple = s.query_player_qq(id_)
|
94
|
-
if data_tuple is not None:
|
95
|
-
qq, nicknam, steamid = data_tuple
|
96
|
-
else:
|
97
|
-
nicknam = None
|
98
|
-
await s.add_player_all(id_, nicknam, msg)
|
99
|
-
# except TypeError:
|
100
|
-
# await s._add_player_steamid(id_ , msg)
|
101
|
-
return "绑定成功喵~\nQQ:" + nickname + "\n" + "steamid:" + msg
|
102
|
-
# try:
|
103
|
-
data_tuple = s.query_player_qq(id_)
|
104
|
-
if data_tuple is not None:
|
105
|
-
id_, nicknam, steamid = data_tuple
|
106
|
-
else:
|
107
|
-
steamid = None
|
108
|
-
await s.add_player_all(id_, msg, steamid)
|
109
|
-
# except TypeError:
|
110
|
-
# await s._add_player_nickname(id_ , msg )
|
111
|
-
return "绑定成功喵~\nQQ:" + nickname + "\n" + "steam昵称:" + msg
|
112
|
-
|
113
|
-
|
114
|
-
def del_player(id_: str):
|
115
|
-
"""删除绑定信息,返回消息"""
|
116
|
-
if not s.query_player_qq(id_):
|
117
|
-
return "你还没有绑定过,请使用[求生绑定+昵称/steamid]"
|
118
|
-
if s.delete_player:
|
119
|
-
return "删除成功喵~"
|
120
|
-
return None
|
121
|
-
|
122
|
-
|
123
|
-
async def id_to_mes(name: str):
|
124
|
-
"""根据name从数据库,返回steamid、或者空白"""
|
125
|
-
data_tuple = await s.search_data(None, name, None)
|
126
|
-
if data_tuple:
|
127
|
-
return data_tuple[2]
|
128
|
-
return None
|
129
|
-
|
130
|
-
|
131
|
-
def anne_rank_dict(name: str):
|
132
|
-
"""用steamid,查详情,输出字典"""
|
133
|
-
data_dict = {}
|
134
|
-
url = f"https://sb.trygek.com/l4d_stats/ranking/player.php?steamid={name}"
|
135
|
-
|
136
|
-
data = httpx.get(url=url, headers=headers, timeout=5)
|
137
|
-
if data.status_code != 200:
|
138
|
-
return [f"查询错误,状态码{data.status_code}"]
|
139
|
-
data = data.content.decode("utf-8")
|
140
|
-
data = BeautifulSoup(data, "html.parser")
|
141
|
-
detail = data.find_all("table")
|
142
|
-
n = 0
|
143
|
-
data_list: List[dict] = []
|
144
|
-
while n < 2:
|
145
|
-
detail2 = detail[n]
|
146
|
-
tr = detail2.find_all("tr")
|
147
|
-
for i in tr:
|
148
|
-
title = i.find("td", {"class": "w-50"})
|
149
|
-
value = title.find_next_sibling("td")
|
150
|
-
new_dict = {title.text: value.text}
|
151
|
-
data_dict.update(new_dict)
|
152
|
-
data_list.append(data_dict)
|
153
|
-
n += 1
|
154
|
-
# 获取头像
|
155
|
-
element: str = data.find_all(attrs={"style": "cursor:pointer"})[0].get("onclick")
|
156
|
-
player_url = element.split("'")[1]
|
157
|
-
data_list[0].update({"个人资料": player_url})
|
158
|
-
# 获取一言
|
159
|
-
message = data.select(
|
160
|
-
(
|
161
|
-
"html body div.content.text-center.text-md-left "
|
162
|
-
"div.container.text-left div.col-md-12.h-100 "
|
163
|
-
"div.card-body.worldmap.d-flex.flex-column.justify-content-center."
|
164
|
-
"text-center span"
|
165
|
-
),
|
166
|
-
)
|
167
|
-
msg_list = []
|
168
|
-
for i in message:
|
169
|
-
msg_list.append(i.text)
|
170
|
-
data_list[0].update({"一言": msg_list})
|
171
|
-
return data_list
|
172
|
-
|
173
|
-
|
174
|
-
def anne_rank_dict_msg(data_list):
|
175
|
-
"""字典转msg"""
|
176
|
-
msg = ""
|
177
|
-
for data_dict in data_list:
|
178
|
-
mes = ""
|
179
|
-
for i in data_dict:
|
180
|
-
mes += "\n" + i + data_dict[i]
|
181
|
-
mes += "\n--------------------"
|
182
|
-
msg += mes
|
183
|
-
return msg
|
184
|
-
|
185
|
-
|
186
|
-
async def anne_message(name: str, usr_id: str):
|
187
|
-
"""获取anne信息可输出信息"""
|
188
|
-
if name:
|
189
|
-
logger.info("关键词查询" + name)
|
190
|
-
if not name.startswith("STEAM"):
|
191
|
-
steamid = await id_to_mes(name)
|
192
|
-
if not steamid:
|
193
|
-
logger.info("没有找到qq,使用默认头像")
|
194
|
-
message = await anne_html(name)
|
195
|
-
if not message:
|
196
|
-
return None
|
197
|
-
usr_id = "1145149191810"
|
198
|
-
if len(message) == 0:
|
199
|
-
return "没有叫这个名字的...\n"
|
200
|
-
if len(message) > 1:
|
201
|
-
return anne_html_msg(message)
|
202
|
-
name = message[0]["steamid"]
|
203
|
-
else:
|
204
|
-
name = steamid
|
205
|
-
|
206
|
-
# steamid
|
207
|
-
msg = anne_rank_dict(name)[0]
|
208
|
-
if isinstance(msg, dict):
|
209
|
-
msg.update(await df_to_guoguanlv(await anne_map_msg(name)))
|
210
|
-
logger.info("使用图片")
|
211
|
-
msg = await out_png(usr_id, msg)
|
212
|
-
return msg
|
213
|
-
"""
|
214
|
-
1、qq>数据>没有数据,返回
|
215
|
-
2、qq>数据>steamid>查询
|
216
|
-
3、qq>数据>昵称>查询
|
217
|
-
"""
|
218
|
-
logger.info("qq信息查询")
|
219
|
-
data_tuple = s.query_player_qq(usr_id)
|
220
|
-
logger.info(data_tuple)
|
221
|
-
if not data_tuple:
|
222
|
-
return "没有绑定信息...请使用【求生绑定 xxx】\n"
|
223
|
-
# 只有名字,先查询数据在判断
|
224
|
-
if data_tuple[2]:
|
225
|
-
name = data_tuple[2]
|
226
|
-
elif data_tuple[1]:
|
227
|
-
name = await id_to_mes(data_tuple[1]) # type: ignore
|
228
|
-
logger.info(name)
|
229
|
-
if not name:
|
230
|
-
message = await anne_html(data_tuple[1])
|
231
|
-
if not message:
|
232
|
-
return None
|
233
|
-
usr_id = "1145149191810"
|
234
|
-
if len(message) == 0:
|
235
|
-
return "没有叫这个名字的...\n"
|
236
|
-
if len(message) > 1:
|
237
|
-
return anne_html_msg(message)
|
238
|
-
name = message[0]["steamid"]
|
239
|
-
|
240
|
-
# name是steamid
|
241
|
-
msg = anne_rank_dict(name)[0]
|
242
|
-
if isinstance(msg, dict):
|
243
|
-
msg.update(await df_to_guoguanlv(await anne_map_msg(name)))
|
244
|
-
logger.info("使用图片")
|
245
|
-
msg = await out_png(usr_id, msg)
|
246
|
-
return msg
|
247
|
-
|
248
|
-
|
249
|
-
async def anne_map_msg(steamid: str):
|
250
|
-
"""steamid->地图信息"""
|
251
|
-
url = f"https://sb.trygek.com/l4d_stats/ranking/timedmaps.php?steamid={steamid}"
|
252
|
-
|
253
|
-
data = httpx.get(url, headers=headers, timeout=5).content.decode( # noqa: ASYNC100
|
254
|
-
"utf-8",
|
255
|
-
)
|
256
|
-
soup = BeautifulSoup(data, "html.parser")
|
257
|
-
data_list = []
|
258
|
-
cards = soup.select("div.card.rounded-0")
|
259
|
-
for card in cards:
|
260
|
-
tbodies = card.select("tbody")
|
261
|
-
for tbody in tbodies:
|
262
|
-
rows = [td.text.strip() for td in tbody.find_all("td")]
|
263
|
-
for i in range(0, len(rows), 9):
|
264
|
-
row = rows[i : i + 9]
|
265
|
-
data_list.append(row)
|
266
|
-
return pd.DataFrame(
|
267
|
-
data_list,
|
268
|
-
columns=[
|
269
|
-
"游戏模式",
|
270
|
-
"地图",
|
271
|
-
"难度",
|
272
|
-
"完成时间",
|
273
|
-
"特感数量",
|
274
|
-
"刷新间隔",
|
275
|
-
"B数使用",
|
276
|
-
"刷特模式",
|
277
|
-
"Anne版本",
|
278
|
-
],
|
279
|
-
)
|
280
|
-
|
281
|
-
|
282
|
-
def name_exist(id_: str):
|
283
|
-
"""删除绑定信息"""
|
284
|
-
return del_player(id_)
|
285
|
-
|
286
|
-
|
287
|
-
async def search_anne(name: str, usr_id: str):
|
288
|
-
"""获取anne成绩"""
|
289
|
-
return await anne_message(name, usr_id)
|
290
|
-
|
291
|
-
|
292
|
-
async def bind_steam(id_: str, msg: str, nickname: str):
|
293
|
-
"""绑定qq-steam"""
|
294
|
-
return await write_player(id_, msg, nickname)
|
@@ -1,105 +0,0 @@
|
|
1
|
-
import sqlite3
|
2
|
-
|
3
|
-
from nonebot.log import logger
|
4
|
-
|
5
|
-
from ..l4d2_utils.config import (
|
6
|
-
DATASQLITE,
|
7
|
-
L4d2_BOOLEAN,
|
8
|
-
L4d2_INTEGER,
|
9
|
-
L4d2_players_tag,
|
10
|
-
L4d2_server_tag,
|
11
|
-
L4d2_TEXT,
|
12
|
-
table_data,
|
13
|
-
tables_columns,
|
14
|
-
)
|
15
|
-
|
16
|
-
|
17
|
-
class L4D2DataSqlite:
|
18
|
-
"""连接数据库和断开数据库,以及一些检查函数"""
|
19
|
-
|
20
|
-
def __init__(self):
|
21
|
-
"""连接数据库"""
|
22
|
-
self.datasqlite_path = DATASQLITE
|
23
|
-
self.datasqlite_path.mkdir(parents=True, exist_ok=True)
|
24
|
-
self.conn = sqlite3.connect(self.datasqlite_path / "L4D2.db")
|
25
|
-
self._check_tables_exist()
|
26
|
-
self._check_data_existence()
|
27
|
-
self._check_data_validity()
|
28
|
-
logger.info("已连接求生数据库")
|
29
|
-
|
30
|
-
def _base_conn(self):
|
31
|
-
return self.conn
|
32
|
-
|
33
|
-
def _check_tables_exist(self) -> None:
|
34
|
-
"""
|
35
|
-
检查表是否存在
|
36
|
-
"""
|
37
|
-
c = self.conn.cursor()
|
38
|
-
for table in table_data:
|
39
|
-
c.execute(
|
40
|
-
f"SELECT name FROM sqlite_master WHERE type='table' AND name='{table}'",
|
41
|
-
)
|
42
|
-
if c.fetchone() is None:
|
43
|
-
if table == "L4d2_players":
|
44
|
-
c.execute(f"CREATE TABLE {table} (qq INTEGER PRIMARY KEY)")
|
45
|
-
elif table == "L4D2_server":
|
46
|
-
c.execute(f"CREATE TABLE {table} (number INTEGER PRIMARY KEY)")
|
47
|
-
self.conn.commit()
|
48
|
-
|
49
|
-
def _check_data_existence(self) -> None:
|
50
|
-
"""
|
51
|
-
检查表头是否存在,如果不存在则新建并填充默认值
|
52
|
-
"""
|
53
|
-
c = self.conn.cursor()
|
54
|
-
for table, tag in tables_columns.items():
|
55
|
-
for column in tag:
|
56
|
-
c.execute(f"PRAGMA table_info({table})")
|
57
|
-
if not any(col[1] == column for col in c.fetchall()):
|
58
|
-
if column in L4d2_BOOLEAN:
|
59
|
-
c.execute(
|
60
|
-
f"ALTER TABLE {table} ADD COLUMN {column} BOOLEAN DEFAULT 0",
|
61
|
-
)
|
62
|
-
elif column in L4d2_INTEGER:
|
63
|
-
c.execute(
|
64
|
-
f"ALTER TABLE {table} ADD COLUMN {column} INTEGER DEFAULT NULL",
|
65
|
-
)
|
66
|
-
else:
|
67
|
-
c.execute(
|
68
|
-
f"ALTER TABLE {table} ADD COLUMN {column} TEXT DEFAULT NULL",
|
69
|
-
)
|
70
|
-
self.conn.commit()
|
71
|
-
|
72
|
-
def _check_data_validity(self) -> None:
|
73
|
-
"""
|
74
|
-
检查数据库数据的合法性
|
75
|
-
错误数据默认填充NULL或者False
|
76
|
-
"""
|
77
|
-
c = self.conn.cursor()
|
78
|
-
columns = None
|
79
|
-
table = None
|
80
|
-
for table in table_data:
|
81
|
-
columns = L4d2_players_tag if table == "L4d2_players" else L4d2_server_tag
|
82
|
-
if not columns:
|
83
|
-
return
|
84
|
-
for column in columns:
|
85
|
-
if column in L4d2_INTEGER:
|
86
|
-
c.execute(
|
87
|
-
f"UPDATE {table} SET {column} = NULL WHERE typeof({column}) != 'integer'",
|
88
|
-
)
|
89
|
-
elif column in L4d2_TEXT:
|
90
|
-
c.execute(
|
91
|
-
f"UPDATE {table} SET {column} = NULL WHERE typeof({column}) != 'text'",
|
92
|
-
)
|
93
|
-
elif column in L4d2_BOOLEAN:
|
94
|
-
c.execute(
|
95
|
-
f"UPDATE {table} SET {column} = 'False' WHERE typeof({column}) != 'boolean'",
|
96
|
-
)
|
97
|
-
self.conn.commit()
|
98
|
-
|
99
|
-
def _close(self):
|
100
|
-
"""断开连接到数据库"""
|
101
|
-
self.conn.close()
|
102
|
-
logger.info("已断开求生数据库")
|
103
|
-
|
104
|
-
|
105
|
-
sq_L4D2 = L4D2DataSqlite() # noqa: N816
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# from pathlib import Path
|
2
|
-
# import yaml
|
3
|
-
|
4
|
-
# DATABASE = Path() / "data" / "L4D2"
|
5
|
-
# class L4D2Config:
|
6
|
-
|
7
|
-
# def __init__(self):
|
8
|
-
# self.config_yaml = "config.yaml"
|
9
|
-
# config_data = self._config_data()
|
10
|
-
|
11
|
-
# self
|
12
|
-
|
13
|
-
# def _config_data(self):
|
14
|
-
# """配置数据"""
|
15
|
-
# with open(self.config_yaml, 'r', encoding='utf-8') as e:
|
16
|
-
# a = e.read()
|
17
|
-
# data = yaml.safe_load(a)
|
18
|
-
# return data
|
@@ -1,100 +0,0 @@
|
|
1
|
-
import sqlite3
|
2
|
-
from typing import List, Optional, Tuple, Union
|
3
|
-
|
4
|
-
from ..l4d2_utils.config import DATASQLITE
|
5
|
-
|
6
|
-
|
7
|
-
class L4D2Player:
|
8
|
-
"""数据库L4D2_Player表的操作"""
|
9
|
-
|
10
|
-
def __init__(self):
|
11
|
-
"""连接数据库"""
|
12
|
-
self.datasqlite_path = DATASQLITE
|
13
|
-
self.conn = sqlite3.connect(self.datasqlite_path / "L4D2.db")
|
14
|
-
self.c = self.conn.cursor()
|
15
|
-
|
16
|
-
async def _add_player_nickname(self, qq, nickname):
|
17
|
-
"""绑定昵称"""
|
18
|
-
# try:
|
19
|
-
self.c.execute(
|
20
|
-
"INSERT INTO L4d2_players (qq, nickname, steamid) VALUES (?,?,NULL)",
|
21
|
-
(qq, nickname),
|
22
|
-
)
|
23
|
-
self.conn.commit()
|
24
|
-
# return True
|
25
|
-
# except sqlite3.IntegrityError:
|
26
|
-
# return False
|
27
|
-
|
28
|
-
async def _add_player_steamid(self, qq, steamid):
|
29
|
-
"""绑定steamid"""
|
30
|
-
self.c.execute(
|
31
|
-
"INSERT INTO L4d2_players (qq, nickname, steamid) VALUES (?,NULL,?)",
|
32
|
-
(qq, steamid),
|
33
|
-
)
|
34
|
-
self.conn.commit()
|
35
|
-
|
36
|
-
async def add_player_all(self, qq, nickname, steamid):
|
37
|
-
"""用新数据覆盖旧数据"""
|
38
|
-
# try:
|
39
|
-
self.c.execute(
|
40
|
-
"INSERT OR REPLACE INTO L4d2_players (qq, nickname, steamid) VALUES (?,?,?)", # noqa: E501
|
41
|
-
(qq, nickname, steamid),
|
42
|
-
)
|
43
|
-
self.conn.commit()
|
44
|
-
return True
|
45
|
-
# except sqlite3.IntegrityError:
|
46
|
-
# return False
|
47
|
-
|
48
|
-
def delete_player(self, qq):
|
49
|
-
"""解除绑定"""
|
50
|
-
self.c.execute(f"DELETE FROM L4d2_players WHERE qq = {qq}")
|
51
|
-
self.conn.commit()
|
52
|
-
return True
|
53
|
-
|
54
|
-
def query_player_qq(self, qq) -> Union[tuple, None]:
|
55
|
-
"""通过qq获取数据"""
|
56
|
-
self.c.execute(f"SELECT * FROM L4d2_players WHERE qq = '{qq}'")
|
57
|
-
return self.c.fetchone()
|
58
|
-
|
59
|
-
async def _query_player_nickname(self, nickname: str) -> Union[tuple, None]:
|
60
|
-
"""通过nickname获取数据"""
|
61
|
-
self.c.execute(f"SELECT * FROM L4d2_players WHERE nickname = '{nickname}'")
|
62
|
-
return self.c.fetchone()
|
63
|
-
|
64
|
-
async def _query_player_steamid(self, steamid: str):
|
65
|
-
"""通过steamid获取数据"""
|
66
|
-
self.c.execute(f"SELECT * FROM L4d2_players WHERE steamid = '{steamid}'")
|
67
|
-
return self.c.fetchone()
|
68
|
-
|
69
|
-
async def search_data(
|
70
|
-
self,
|
71
|
-
qq: Optional[str],
|
72
|
-
nickname: Optional[str],
|
73
|
-
steamid: Optional[str],
|
74
|
-
) -> Union[tuple, None]:
|
75
|
-
"""
|
76
|
-
输入元组查询,优先qq其次steamid最后nickname,不需要值可以为None
|
77
|
-
输出为元组,如果为空输出None
|
78
|
-
data = (qq , nickname , steamid )
|
79
|
-
"""
|
80
|
-
if qq:
|
81
|
-
self.c.execute("SELECT * FROM L4d2_players WHERE qq=?", (qq,))
|
82
|
-
result = self.c.fetchone()
|
83
|
-
if result:
|
84
|
-
return result
|
85
|
-
if steamid:
|
86
|
-
self.c.execute("SELECT * FROM L4d2_players WHERE steamid=?", (steamid,))
|
87
|
-
result = self.c.fetchone()
|
88
|
-
if result:
|
89
|
-
return result
|
90
|
-
if nickname:
|
91
|
-
self.c.execute("SELECT * FROM L4d2_players WHERE nickname=?", (nickname,))
|
92
|
-
result = self.c.fetchone()
|
93
|
-
if result:
|
94
|
-
return result
|
95
|
-
return None
|
96
|
-
|
97
|
-
def _query_all_player(self) -> List[Tuple]:
|
98
|
-
"""获取所有玩家信息"""
|
99
|
-
self.c.execute("SELECT * FROM L4d2_players")
|
100
|
-
return self.c.fetchall()
|
@@ -1,40 +0,0 @@
|
|
1
|
-
import sqlite3
|
2
|
-
|
3
|
-
from ..l4d2_utils.config import DATASQLITE
|
4
|
-
|
5
|
-
|
6
|
-
class L4D2Server:
|
7
|
-
"""数据库L4D2_server表的操作"""
|
8
|
-
|
9
|
-
def __init__(self):
|
10
|
-
"""连接数据库"""
|
11
|
-
self.datasqlite_path = DATASQLITE
|
12
|
-
self.conn = sqlite3.connect(self.datasqlite_path / "L4D2.db")
|
13
|
-
self.c = self.conn.cursor()
|
14
|
-
|
15
|
-
async def bind_server_ip(self, qqgroup, host, port):
|
16
|
-
"""绑定群订阅ip"""
|
17
|
-
self.c.execute(
|
18
|
-
"INSERT OR REPLACE INTO L4D2_server (qqgroup, host, port) VALUES (?,?,?)",
|
19
|
-
(qqgroup, host, port),
|
20
|
-
)
|
21
|
-
self.conn.commit()
|
22
|
-
|
23
|
-
async def query_server_ip(self, qqgroup):
|
24
|
-
"""输入群号,返回数据库里订阅ip元组列表"""
|
25
|
-
self.c.execute(
|
26
|
-
f"SELECT number, qqgroup ,host ,port FROM L4D2_server WHERE qqgroup = {qqgroup}",
|
27
|
-
)
|
28
|
-
return self.c.fetchall()
|
29
|
-
|
30
|
-
async def del_server_ip(self, id_: int):
|
31
|
-
"""删除指定id的ip"""
|
32
|
-
self.c.execute(f"DELETE FROM L4D2_server WHERE number = {id_}")
|
33
|
-
self.conn.commit()
|
34
|
-
|
35
|
-
async def query_number(self, number: int):
|
36
|
-
"""通过序号找服务器"""
|
37
|
-
self.c.execute(
|
38
|
-
f"SELECT qqgroup , host ,port FROM L4D2_server WHERE number = {number}",
|
39
|
-
)
|
40
|
-
return self.c.fetchone()
|