nonebot-plugin-l4d2-server 0.5.0__py3-none-any.whl → 0.5.2__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.
- LICENSE +674 -674
- README.md +365 -349
- nonebot_plugin_l4d2_server/__init__.py +1 -1
- nonebot_plugin_l4d2_server/chrome.py +45 -0
- nonebot_plugin_l4d2_server/command.py +232 -233
- nonebot_plugin_l4d2_server/config.py +210 -318
- nonebot_plugin_l4d2_server/data/L4D2/image/template/anne.html +60 -60
- nonebot_plugin_l4d2_server/data/L4D2/image/template/fingerprint.svg +15 -15
- nonebot_plugin_l4d2_server/data/L4D2/image/template/help.html +233 -233
- nonebot_plugin_l4d2_server/data/L4D2/image/template/help_dack.html +231 -231
- nonebot_plugin_l4d2_server/data/L4D2/image/template/ip.html +48 -48
- nonebot_plugin_l4d2_server/data/L4D2/image/template/l.svg +9 -9
- nonebot_plugin_l4d2_server/data/L4D2/image/template/vue.css +530 -530
- nonebot_plugin_l4d2_server/l4d2_anne/__init__.py +251 -251
- nonebot_plugin_l4d2_server/l4d2_anne/analysis.py +51 -51
- nonebot_plugin_l4d2_server/l4d2_anne/anne_telecom.py +75 -75
- nonebot_plugin_l4d2_server/l4d2_anne/server.py +65 -65
- nonebot_plugin_l4d2_server/l4d2_anne/startand.py +17 -17
- nonebot_plugin_l4d2_server/l4d2_data/__init__.py +91 -91
- nonebot_plugin_l4d2_server/l4d2_data/config.py +17 -17
- nonebot_plugin_l4d2_server/l4d2_data/players.py +87 -87
- nonebot_plugin_l4d2_server/l4d2_data/serverip.py +32 -32
- nonebot_plugin_l4d2_server/l4d2_file/__init__.py +122 -122
- nonebot_plugin_l4d2_server/l4d2_file/ayromote.py +56 -56
- nonebot_plugin_l4d2_server/l4d2_file/remote.py +63 -66
- nonebot_plugin_l4d2_server/l4d2_image/__init__.py +103 -103
- nonebot_plugin_l4d2_server/l4d2_image/download.py +101 -101
- nonebot_plugin_l4d2_server/l4d2_image/htmlimg.py +32 -32
- nonebot_plugin_l4d2_server/l4d2_image/send_image_tool.py +32 -32
- nonebot_plugin_l4d2_server/l4d2_image/steam.py +83 -83
- nonebot_plugin_l4d2_server/l4d2_image/vtfs.py +40 -40
- nonebot_plugin_l4d2_server/l4d2_queries/__init__.py +114 -114
- nonebot_plugin_l4d2_server/l4d2_queries/api.py +43 -43
- nonebot_plugin_l4d2_server/l4d2_queries/ohter.py +35 -25
- nonebot_plugin_l4d2_server/l4d2_queries/qqgroup.py +288 -288
- nonebot_plugin_l4d2_server/l4d2_server/__init__.py +61 -61
- nonebot_plugin_l4d2_server/l4d2_server/rcon.py +28 -28
- nonebot_plugin_l4d2_server/l4d2_server/workshop.py +50 -50
- nonebot_plugin_l4d2_server/l4d2_web/web.py +234 -234
- nonebot_plugin_l4d2_server/l4d2_web/webUI.py +241 -241
- nonebot_plugin_l4d2_server/message.py +58 -58
- nonebot_plugin_l4d2_server/seach.py +33 -33
- nonebot_plugin_l4d2_server/txt_to_img.py +64 -64
- nonebot_plugin_l4d2_server/utils.py +272 -272
- {nonebot_plugin_l4d2_server-0.5.0.dist-info → nonebot_plugin_l4d2_server-0.5.2.dist-info}/LICENSE +674 -674
- {nonebot_plugin_l4d2_server-0.5.0.dist-info → nonebot_plugin_l4d2_server-0.5.2.dist-info}/METADATA +47 -32
- nonebot_plugin_l4d2_server-0.5.2.dist-info/RECORD +54 -0
- nonebot_plugin_l4d2_server-0.5.0.dist-info/RECORD +0 -53
- {nonebot_plugin_l4d2_server-0.5.0.dist-info → nonebot_plugin_l4d2_server-0.5.2.dist-info}/WHEEL +0 -0
@@ -1,33 +1,33 @@
|
|
1
|
-
from bs4 import BeautifulSoup
|
2
|
-
import httpx
|
3
|
-
|
4
|
-
|
5
|
-
def anne_search(name):
|
6
|
-
"""输入名字返回列表["""
|
7
|
-
url = 'https://sb.trygek.com/l4d_stats/ranking/search.php'
|
8
|
-
data = {'search': name}
|
9
|
-
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
|
10
|
-
data = httpx.post(url,data = data,headers=headers,timeout=60).content.decode('utf-8')
|
11
|
-
soup = BeautifulSoup(data, 'html.parser')
|
12
|
-
# 获取标题
|
13
|
-
title = []
|
14
|
-
thead = soup.find('thead')
|
15
|
-
for i in thead.find_all('td'):
|
16
|
-
tag = i.text.strip()
|
17
|
-
title.append(tag)
|
18
|
-
title.append('steamid')
|
19
|
-
# 角色信息
|
20
|
-
datas = soup.find('table')
|
21
|
-
datas = datas.find('tbody')
|
22
|
-
datas = datas.find_all('tr')
|
23
|
-
return [datas,title]
|
24
|
-
|
25
|
-
def name_steamid_html(name):
|
26
|
-
"""您称通过网页来返回求生steamid"""
|
27
|
-
data_title = anne_search(name)
|
28
|
-
data = data_title[0]
|
29
|
-
for i in data:
|
30
|
-
onclick:str = i['onclick']
|
31
|
-
steamid = onclick.split('=')[2].strip("'")
|
32
|
-
return steamid
|
33
|
-
|
1
|
+
from bs4 import BeautifulSoup
|
2
|
+
import httpx
|
3
|
+
|
4
|
+
|
5
|
+
def anne_search(name):
|
6
|
+
"""输入名字返回列表["""
|
7
|
+
url = 'https://sb.trygek.com/l4d_stats/ranking/search.php'
|
8
|
+
data = {'search': name}
|
9
|
+
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
|
10
|
+
data = httpx.post(url,data = data,headers=headers,timeout=60).content.decode('utf-8')
|
11
|
+
soup = BeautifulSoup(data, 'html.parser')
|
12
|
+
# 获取标题
|
13
|
+
title = []
|
14
|
+
thead = soup.find('thead')
|
15
|
+
for i in thead.find_all('td'):
|
16
|
+
tag = i.text.strip()
|
17
|
+
title.append(tag)
|
18
|
+
title.append('steamid')
|
19
|
+
# 角色信息
|
20
|
+
datas = soup.find('table')
|
21
|
+
datas = datas.find('tbody')
|
22
|
+
datas = datas.find_all('tr')
|
23
|
+
return [datas,title]
|
24
|
+
|
25
|
+
def name_steamid_html(name):
|
26
|
+
"""您称通过网页来返回求生steamid"""
|
27
|
+
data_title = anne_search(name)
|
28
|
+
data = data_title[0]
|
29
|
+
for i in data:
|
30
|
+
onclick:str = i['onclick']
|
31
|
+
steamid = onclick.split('=')[2].strip("'")
|
32
|
+
return steamid
|
33
|
+
|
@@ -1,65 +1,65 @@
|
|
1
|
-
from io import BytesIO
|
2
|
-
from PIL import Image, ImageDraw, ImageFont
|
3
|
-
from nonebot.adapters.onebot.v11 import MessageSegment
|
4
|
-
from nonebot_plugin_txt2img import Txt2Img
|
5
|
-
from .config import l4_config
|
6
|
-
|
7
|
-
l4_font = l4_config.l4_font
|
8
|
-
"""直接超的智障回复"""
|
9
|
-
def txt_to_img(text: str, font_size=30, font_path=l4_font) -> bytes:
|
10
|
-
text = line_break(text)
|
11
|
-
d_font = ImageFont.truetype(font_path, font_size)
|
12
|
-
lines = text.count('\n') # 计算行数
|
13
|
-
image = Image.new("L", (LINE_CHAR_COUNT*font_size //
|
14
|
-
2 + 50, font_size*lines+50), "white")
|
15
|
-
draw_table = ImageDraw.Draw(im=image)
|
16
|
-
draw_table.text(xy=(25, 25), text=text, fill='#000000',
|
17
|
-
font=d_font, spacing=4) # spacing调节机制不清楚如何计算
|
18
|
-
new_img = image.convert("RGB")
|
19
|
-
img_byte = BytesIO()
|
20
|
-
new_img.save(img_byte, format='PNG')
|
21
|
-
binary_content = img_byte.getvalue()
|
22
|
-
return binary_content
|
23
|
-
|
24
|
-
|
25
|
-
LINE_CHAR_COUNT = 30*2 # 每行字符数:30个中文字符(=60英文字符)
|
26
|
-
CHAR_SIZE = 30
|
27
|
-
TABLE_WIDTH = 4
|
28
|
-
|
29
|
-
|
30
|
-
def line_break(line: str) -> str:
|
31
|
-
ret = ''
|
32
|
-
width = 0
|
33
|
-
for c in line:
|
34
|
-
if len(c.encode('utf8')) == 3: # 中文
|
35
|
-
if LINE_CHAR_COUNT == width + 1: # 剩余位置不够一个汉字
|
36
|
-
width = 2
|
37
|
-
ret += '\n' + c
|
38
|
-
else: # 中文宽度加2,注意换行边界
|
39
|
-
width += 2
|
40
|
-
ret += c
|
41
|
-
else:
|
42
|
-
if c == '\t':
|
43
|
-
space_c = TABLE_WIDTH - width % TABLE_WIDTH # 已有长度对TABLE_WIDTH取余
|
44
|
-
ret += ' ' * space_c
|
45
|
-
width += space_c
|
46
|
-
elif c == '\n':
|
47
|
-
width = 0
|
48
|
-
ret += c
|
49
|
-
else:
|
50
|
-
width += 1
|
51
|
-
ret += c
|
52
|
-
if width >= LINE_CHAR_COUNT:
|
53
|
-
ret += '\n'
|
54
|
-
width = 0
|
55
|
-
if ret.endswith('\n'):
|
56
|
-
return ret
|
57
|
-
return ret + '\n'
|
58
|
-
|
59
|
-
|
60
|
-
def mode_txt_to_img(title:str,text:str,font_size:int = 32,):
|
61
|
-
txt2img = Txt2Img()
|
62
|
-
txt2img.set_font_size(font_size)
|
63
|
-
pic = txt2img.draw(title, text)
|
64
|
-
msg = MessageSegment.image(pic)
|
1
|
+
from io import BytesIO
|
2
|
+
from PIL import Image, ImageDraw, ImageFont
|
3
|
+
from nonebot.adapters.onebot.v11 import MessageSegment
|
4
|
+
from nonebot_plugin_txt2img import Txt2Img
|
5
|
+
from .config import l4_config
|
6
|
+
|
7
|
+
l4_font = l4_config.l4_font
|
8
|
+
"""直接超的智障回复"""
|
9
|
+
def txt_to_img(text: str, font_size=30, font_path=l4_font) -> bytes:
|
10
|
+
text = line_break(text)
|
11
|
+
d_font = ImageFont.truetype(font_path, font_size)
|
12
|
+
lines = text.count('\n') # 计算行数
|
13
|
+
image = Image.new("L", (LINE_CHAR_COUNT*font_size //
|
14
|
+
2 + 50, font_size*lines+50), "white")
|
15
|
+
draw_table = ImageDraw.Draw(im=image)
|
16
|
+
draw_table.text(xy=(25, 25), text=text, fill='#000000',
|
17
|
+
font=d_font, spacing=4) # spacing调节机制不清楚如何计算
|
18
|
+
new_img = image.convert("RGB")
|
19
|
+
img_byte = BytesIO()
|
20
|
+
new_img.save(img_byte, format='PNG')
|
21
|
+
binary_content = img_byte.getvalue()
|
22
|
+
return binary_content
|
23
|
+
|
24
|
+
|
25
|
+
LINE_CHAR_COUNT = 30*2 # 每行字符数:30个中文字符(=60英文字符)
|
26
|
+
CHAR_SIZE = 30
|
27
|
+
TABLE_WIDTH = 4
|
28
|
+
|
29
|
+
|
30
|
+
def line_break(line: str) -> str:
|
31
|
+
ret = ''
|
32
|
+
width = 0
|
33
|
+
for c in line:
|
34
|
+
if len(c.encode('utf8')) == 3: # 中文
|
35
|
+
if LINE_CHAR_COUNT == width + 1: # 剩余位置不够一个汉字
|
36
|
+
width = 2
|
37
|
+
ret += '\n' + c
|
38
|
+
else: # 中文宽度加2,注意换行边界
|
39
|
+
width += 2
|
40
|
+
ret += c
|
41
|
+
else:
|
42
|
+
if c == '\t':
|
43
|
+
space_c = TABLE_WIDTH - width % TABLE_WIDTH # 已有长度对TABLE_WIDTH取余
|
44
|
+
ret += ' ' * space_c
|
45
|
+
width += space_c
|
46
|
+
elif c == '\n':
|
47
|
+
width = 0
|
48
|
+
ret += c
|
49
|
+
else:
|
50
|
+
width += 1
|
51
|
+
ret += c
|
52
|
+
if width >= LINE_CHAR_COUNT:
|
53
|
+
ret += '\n'
|
54
|
+
width = 0
|
55
|
+
if ret.endswith('\n'):
|
56
|
+
return ret
|
57
|
+
return ret + '\n'
|
58
|
+
|
59
|
+
|
60
|
+
def mode_txt_to_img(title:str,text:str,font_size:int = 32,):
|
61
|
+
txt2img = Txt2Img()
|
62
|
+
txt2img.set_font_size(font_size)
|
63
|
+
pic = txt2img.draw(title, text)
|
64
|
+
msg = MessageSegment.image(pic)
|
65
65
|
return msg
|