nonebot-plugin-l4d2-server 0.5.1__py3-none-any.whl → 0.5.3__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.
Files changed (63) hide show
  1. LICENSE +674 -674
  2. README.md +373 -359
  3. nonebot_plugin_l4d2_server/__init__.py +13 -13
  4. nonebot_plugin_l4d2_server/command.py +232 -232
  5. nonebot_plugin_l4d2_server/config.py +209 -210
  6. nonebot_plugin_l4d2_server/data/L4D2/image/template/anne.html +60 -60
  7. nonebot_plugin_l4d2_server/data/L4D2/image/template/fingerprint.svg +15 -15
  8. nonebot_plugin_l4d2_server/data/L4D2/image/template/help.html +233 -233
  9. nonebot_plugin_l4d2_server/data/L4D2/image/template/help_dack.html +231 -231
  10. nonebot_plugin_l4d2_server/data/L4D2/image/template/ip.html +48 -48
  11. nonebot_plugin_l4d2_server/data/L4D2/image/template/l.svg +9 -9
  12. nonebot_plugin_l4d2_server/l4d2_anne/__init__.py +251 -251
  13. nonebot_plugin_l4d2_server/l4d2_anne/analysis.py +51 -51
  14. nonebot_plugin_l4d2_server/l4d2_anne/anne_telecom.py +75 -75
  15. nonebot_plugin_l4d2_server/l4d2_anne/server.py +65 -65
  16. nonebot_plugin_l4d2_server/l4d2_anne/startand.py +17 -17
  17. nonebot_plugin_l4d2_server/l4d2_data/__init__.py +91 -91
  18. nonebot_plugin_l4d2_server/l4d2_data/config.py +17 -17
  19. nonebot_plugin_l4d2_server/l4d2_data/database.py +0 -0
  20. nonebot_plugin_l4d2_server/l4d2_data/players.py +87 -87
  21. nonebot_plugin_l4d2_server/l4d2_data/serverip.py +32 -32
  22. nonebot_plugin_l4d2_server/l4d2_file/__init__.py +122 -122
  23. nonebot_plugin_l4d2_server/l4d2_file/ayromote.py +56 -56
  24. nonebot_plugin_l4d2_server/l4d2_file/remote.py +63 -63
  25. nonebot_plugin_l4d2_server/l4d2_image/__init__.py +103 -103
  26. nonebot_plugin_l4d2_server/l4d2_image/download.py +101 -101
  27. nonebot_plugin_l4d2_server/l4d2_image/htmlimg.py +32 -32
  28. nonebot_plugin_l4d2_server/l4d2_image/image.py +292 -0
  29. nonebot_plugin_l4d2_server/l4d2_image/send_image_tool.py +32 -32
  30. nonebot_plugin_l4d2_server/l4d2_image/steam.py +83 -83
  31. nonebot_plugin_l4d2_server/l4d2_image/vtfs.py +40 -40
  32. nonebot_plugin_l4d2_server/l4d2_queries/__init__.py +114 -114
  33. nonebot_plugin_l4d2_server/l4d2_queries/api.py +43 -43
  34. nonebot_plugin_l4d2_server/l4d2_queries/ohter.py +35 -35
  35. nonebot_plugin_l4d2_server/l4d2_queries/qqgroup.py +288 -288
  36. nonebot_plugin_l4d2_server/l4d2_server/__init__.py +61 -61
  37. nonebot_plugin_l4d2_server/l4d2_server/index.py +0 -0
  38. nonebot_plugin_l4d2_server/l4d2_server/rcon.py +28 -28
  39. nonebot_plugin_l4d2_server/l4d2_server/workshop.py +50 -50
  40. nonebot_plugin_l4d2_server/l4d2_update/__init__.py +143 -0
  41. nonebot_plugin_l4d2_server/l4d2_update/draw_update_log.py +41 -0
  42. nonebot_plugin_l4d2_server/l4d2_update/restart.py +67 -0
  43. nonebot_plugin_l4d2_server/l4d2_update/texture2d/art.png +0 -0
  44. nonebot_plugin_l4d2_server/l4d2_update/texture2d/bento.png +0 -0
  45. nonebot_plugin_l4d2_server/l4d2_update/texture2d/bug.png +0 -0
  46. nonebot_plugin_l4d2_server/l4d2_update/texture2d/feat.png +0 -0
  47. nonebot_plugin_l4d2_server/l4d2_update/texture2d/log_title.png +0 -0
  48. nonebot_plugin_l4d2_server/l4d2_update/texture2d/other.png +0 -0
  49. nonebot_plugin_l4d2_server/l4d2_update/texture2d/zap.png +0 -0
  50. nonebot_plugin_l4d2_server/l4d2_update/update.py +65 -0
  51. nonebot_plugin_l4d2_server/l4d2_web/web.py +234 -252
  52. nonebot_plugin_l4d2_server/l4d2_web/webUI.py +241 -245
  53. nonebot_plugin_l4d2_server/message.py +58 -58
  54. nonebot_plugin_l4d2_server/rule.py +15 -0
  55. nonebot_plugin_l4d2_server/seach.py +33 -33
  56. nonebot_plugin_l4d2_server/txt_to_img.py +64 -64
  57. nonebot_plugin_l4d2_server/utils.py +297 -272
  58. {nonebot_plugin_l4d2_server-0.5.1.dist-info → nonebot_plugin_l4d2_server-0.5.3.dist-info}/LICENSE +674 -674
  59. {nonebot_plugin_l4d2_server-0.5.1.dist-info → nonebot_plugin_l4d2_server-0.5.3.dist-info}/METADATA +19 -4
  60. nonebot_plugin_l4d2_server-0.5.3.dist-info/RECORD +68 -0
  61. {nonebot_plugin_l4d2_server-0.5.1.dist-info → nonebot_plugin_l4d2_server-0.5.3.dist-info}/WHEEL +1 -1
  62. nonebot_plugin_l4d2_server/chrome.py +0 -45
  63. nonebot_plugin_l4d2_server-0.5.1.dist-info/RECORD +0 -54
@@ -1,114 +1,114 @@
1
- import a2s
2
- from typing import List
3
-
4
- async def queries(ip:str,port:int):
5
- port = int(port)
6
- msg_dict = await queries_dict(ip,port)
7
- message = 'ip:' + msg_dict['ip'] + '\n'
8
- message += '名称:' + msg_dict['name'] + '\n'
9
- message += f"地图:{msg_dict['map_']}\n"
10
- message += f"延迟:{msg_dict['ping']}\n"
11
- message += f"玩家:{msg_dict['players']} / {msg_dict['max_players']}\n"
12
- return message
13
-
14
- async def queries_dict(ip:str,port:int) -> dict:
15
- port = int(port)
16
- ip = str(ip)
17
- msg_dict = {}
18
- # message_dict = await l4d(ip,port)
19
- msg:a2s.SourceInfo = await a2s.ainfo((ip,port))
20
- # message_dict = await l4d2.server(ip,port,times=5)
21
- msg_dict['folder'] = msg.folder
22
- msg_dict['name'] = msg.server_name
23
- msg_dict['map_'] = msg.map_name
24
- msg_dict['players'] = msg.player_count
25
- msg_dict['max_players'] = msg.max_players
26
- msg_dict['rank_players'] = f'{msg.player_count}/{msg.max_players}'
27
- msg_dict['ip'] = str(ip) + ':' +str(port)
28
- msg_dict['ping'] = f"{msg.ping*1000:.0f}ms"
29
- msg_dict['system'] = f"{msg.platform}.svg"
30
- if msg_dict['players'] < msg_dict['max_players']:
31
- msg_dict['enabled'] = True
32
- else:
33
- msg_dict['enabled'] = False
34
- return msg_dict
35
-
36
- async def player_queries_anne_dict(ip:str,port:int):
37
- """anne算法返回玩家"""
38
- port = int(port)
39
- # message_dic = await l4d2.APlayer(ip,port,times=5)
40
- message_list:List[a2s.Player] = await a2s.aplayers((ip,port))
41
- msg_list = []
42
- if message_list != []:
43
- for i in message_list:
44
- msg_list.append({
45
- 'name':i.name,
46
- 'Score':i.score,
47
- 'Duration':await convert_duration(i.duration)
48
- })
49
- return msg_list
50
-
51
- # async def player_queries_dict(ip:str,port:int):
52
- # """一般算法返回玩家"""
53
- # port = int(port)
54
- # new_dict = {}
55
- # message_dic = await l4d2.APlayer(ip,port,times=5)
56
- # if message_dic == {}:
57
- # new_dict['header'] = 0
58
- # else:
59
- # pass
60
- # new_list = []
61
- # for i in message_dic['Players']:
62
- # new_list.append(i['Name'])
63
- # new_dict.update({'Players':new_list})
64
- # return new_dict
65
-
66
- async def player_queries(ip:str,port:int):
67
- port = int(port)
68
- message_list = await player_queries_anne_dict(ip,port)
69
- return await msg_ip_to_list(message_list)
70
-
71
- async def msg_ip_to_list(message_list:list):
72
- message = ''
73
- n = 0
74
- if message_list == []:
75
- message += '服务器里,是空空的呢\n'
76
- else:
77
- max_duration_len = max([len(str(i['Duration'])) for i in message_list])
78
- max_score_len = max([len(str(i['Score'])) for i in message_list])
79
- for i in message_list:
80
- print(i)
81
- n += 1
82
- name = i['name']
83
- Score = i['Score']
84
- if Score == '0':
85
- Score = '摸'
86
- Duration = i['Duration']
87
- soc = "[{:>{}}]".format(Score,max_score_len)
88
- dur = "{:^{}}".format(Duration, max_duration_len)
89
- message += f'{soc} | {dur} | {name} \n'
90
- return message
91
-
92
- async def convert_duration(duration: int) -> str:
93
- minutes, seconds = divmod(duration, 60)
94
- hours, minutes = divmod(minutes, 60)
95
- time_str = ""
96
- if hours > 0:
97
- time_str += f"{int(hours)}h "
98
- if minutes > 0 or hours > 0:
99
- time_str += f"{int(minutes)}m "
100
- time_str += f"{int(seconds)}s"
101
- return time_str.strip()
102
-
103
- async def server_rule_dict(ip:str,port:int):
104
- port = int(port)
105
- ip = str(ip)
106
- msg_dict = {}
107
- # message_dict = await l4d(ip,port)
108
- try:
109
- msg:dict = await a2s.arules((ip,port))
110
- msg_dict['tick'] = msg['l4d2_tickrate_enabler'] + "tick"
111
- except:
112
- msg_dict['tick'] = ''
113
- return msg_dict
114
-
1
+ import a2s
2
+ from typing import List
3
+
4
+ async def queries(ip:str,port:int):
5
+ port = int(port)
6
+ msg_dict = await queries_dict(ip,port)
7
+ message = 'ip:' + msg_dict['ip'] + '\n'
8
+ message += '名称:' + msg_dict['name'] + '\n'
9
+ message += f"地图:{msg_dict['map_']}\n"
10
+ message += f"延迟:{msg_dict['ping']}\n"
11
+ message += f"玩家:{msg_dict['players']} / {msg_dict['max_players']}\n"
12
+ return message
13
+
14
+ async def queries_dict(ip:str,port:int) -> dict:
15
+ port = int(port)
16
+ ip = str(ip)
17
+ msg_dict = {}
18
+ # message_dict = await l4d(ip,port)
19
+ msg:a2s.SourceInfo = await a2s.ainfo((ip,port))
20
+ # message_dict = await l4d2.server(ip,port,times=5)
21
+ msg_dict['folder'] = msg.folder
22
+ msg_dict['name'] = msg.server_name
23
+ msg_dict['map_'] = msg.map_name
24
+ msg_dict['players'] = msg.player_count
25
+ msg_dict['max_players'] = msg.max_players
26
+ msg_dict['rank_players'] = f'{msg.player_count}/{msg.max_players}'
27
+ msg_dict['ip'] = str(ip) + ':' +str(port)
28
+ msg_dict['ping'] = f"{msg.ping*1000:.0f}ms"
29
+ msg_dict['system'] = f"{msg.platform}.svg"
30
+ if msg_dict['players'] < msg_dict['max_players']:
31
+ msg_dict['enabled'] = True
32
+ else:
33
+ msg_dict['enabled'] = False
34
+ return msg_dict
35
+
36
+ async def player_queries_anne_dict(ip:str,port:int):
37
+ """anne算法返回玩家"""
38
+ port = int(port)
39
+ # message_dic = await l4d2.APlayer(ip,port,times=5)
40
+ message_list:List[a2s.Player] = await a2s.aplayers((ip,port))
41
+ msg_list = []
42
+ if message_list != []:
43
+ for i in message_list:
44
+ msg_list.append({
45
+ 'name':i.name,
46
+ 'Score':i.score,
47
+ 'Duration':await convert_duration(i.duration)
48
+ })
49
+ return msg_list
50
+
51
+ # async def player_queries_dict(ip:str,port:int):
52
+ # """一般算法返回玩家"""
53
+ # port = int(port)
54
+ # new_dict = {}
55
+ # message_dic = await l4d2.APlayer(ip,port,times=5)
56
+ # if message_dic == {}:
57
+ # new_dict['header'] = 0
58
+ # else:
59
+ # pass
60
+ # new_list = []
61
+ # for i in message_dic['Players']:
62
+ # new_list.append(i['Name'])
63
+ # new_dict.update({'Players':new_list})
64
+ # return new_dict
65
+
66
+ async def player_queries(ip:str,port:int):
67
+ port = int(port)
68
+ message_list = await player_queries_anne_dict(ip,port)
69
+ return await msg_ip_to_list(message_list)
70
+
71
+ async def msg_ip_to_list(message_list:list):
72
+ message = ''
73
+ n = 0
74
+ if message_list == []:
75
+ message += '服务器里,是空空的呢\n'
76
+ else:
77
+ max_duration_len = max([len(str(i['Duration'])) for i in message_list])
78
+ max_score_len = max([len(str(i['Score'])) for i in message_list])
79
+ for i in message_list:
80
+ print(i)
81
+ n += 1
82
+ name = i['name']
83
+ Score = i['Score']
84
+ if Score == '0':
85
+ Score = '摸'
86
+ Duration = i['Duration']
87
+ soc = "[{:>{}}]".format(Score,max_score_len)
88
+ dur = "{:^{}}".format(Duration, max_duration_len)
89
+ message += f'{soc} | {dur} | {name} \n'
90
+ return message
91
+
92
+ async def convert_duration(duration: int) -> str:
93
+ minutes, seconds = divmod(duration, 60)
94
+ hours, minutes = divmod(minutes, 60)
95
+ time_str = ""
96
+ if hours > 0:
97
+ time_str += f"{int(hours)}h "
98
+ if minutes > 0 or hours > 0:
99
+ time_str += f"{int(minutes)}m "
100
+ time_str += f"{int(seconds)}s"
101
+ return time_str.strip()
102
+
103
+ async def server_rule_dict(ip:str,port:int):
104
+ port = int(port)
105
+ ip = str(ip)
106
+ msg_dict = {}
107
+ # message_dict = await l4d(ip,port)
108
+ try:
109
+ msg:dict = await a2s.arules((ip,port))
110
+ msg_dict['tick'] = msg['l4d2_tickrate_enabler'] + "tick"
111
+ except:
112
+ msg_dict['tick'] = ''
113
+ return msg_dict
114
+
@@ -1,43 +1,43 @@
1
- import httpx
2
- from typing import List,Union
3
- from nonebot.log import logger
4
-
5
- async def seach_map(msg:Union[list,str],qq:str,key:str,mode:str = 'zh'):
6
- url = "http://106.13.207.45:4015/l4d2"
7
- json = {
8
- "mode":mode,
9
- "map_name":msg,
10
- "qq":qq,
11
- "key":key
12
- }
13
- file = httpx.post(url=url,json=json)
14
- if mode == 'zh':
15
- if file.status_code == 200:
16
- return file.json()
17
- elif file.status_code == 204:
18
- return "没有结果"
19
- elif file.status_code == 406:
20
- return "参数错误"
21
- elif file.status_code == 401:
22
- return file.json()
23
- elif mode == 'ip':
24
- rep:dict = file.json()
25
- try:
26
- logger.error(rep['error_'])
27
- except:
28
- pass
29
- print(file.json())
30
- return file.json()
31
- elif mode == 'first':
32
- ip_tag:list = file.json()
33
- return ip_tag
34
-
35
-
36
- async def map_dict_to_str(data:List[dict]):
37
- msg = ""
38
- for key,value in data[0].items():
39
- if key == "url":
40
- continue
41
- msg += f"{key}:{value}\n"
42
- return msg
43
-
1
+ # import httpx
2
+ # from typing import List,Union
3
+ # from nonebot.log import logger
4
+
5
+ # async def seach_map(msg:Union[list,str],qq:str,key:str,mode:str = 'zh'):
6
+ # url = ""
7
+ # json = {
8
+ # "mode":mode,
9
+ # "map_name":msg,
10
+ # "qq":qq,
11
+ # "key":key
12
+ # }
13
+ # file = httpx.post(url=url,json=json)
14
+ # if mode == 'zh':
15
+ # if file.status_code == 200:
16
+ # return file.json()
17
+ # elif file.status_code == 204:
18
+ # return "没有结果"
19
+ # elif file.status_code == 406:
20
+ # return "参数错误"
21
+ # elif file.status_code == 401:
22
+ # return file.json()
23
+ # elif mode == 'ip':
24
+ # rep:dict = file.json()
25
+ # try:
26
+ # logger.error(rep['error_'])
27
+ # except:
28
+ # pass
29
+ # print(file.json())
30
+ # return file.json()
31
+ # elif mode == 'first':
32
+ # ip_tag:list = file.json()
33
+ # return ip_tag
34
+
35
+
36
+ # async def map_dict_to_str(data:List[dict]):
37
+ # msg = ""
38
+ # for key,value in data[0].items():
39
+ # if key == "url":
40
+ # continue
41
+ # msg += f"{key}:{value}\n"
42
+ # return msg
43
+
@@ -1,35 +1,35 @@
1
- try:
2
- import ujson as json
3
- except:
4
- import json
5
- from pathlib import Path
6
- from typing import Dict,List
7
- import os
8
-
9
- BOT_DIR = os.path.dirname(os.path.abspath(__file__))
10
- filename = 'data/L4D2/l4d2.json'
11
- global_file = Path(Path(__file__).parent.parent,filename)
12
- def load_josn():
13
- # 本地模块
14
- try:
15
- LOCAL_HOST:dict = json.load(open(
16
- filename, "r", encoding="utf8"))
17
- except IOError or FileNotFoundError:
18
- os.makedirs(os.path.dirname(filename), exist_ok=True)
19
- data = {}
20
- with open(filename, "w") as f:
21
- json.dump(data, f)
22
- LOCAL_HOST:dict = {}
23
- try:
24
- # 获取所有json文件的路径
25
- json_files = Path('data/L4D2/l4d2').glob('*.json')
26
-
27
- # 将所有json文件中的字典对象合并为一个字典
28
- for file_path in json_files:
29
- with open(file_path, 'r', encoding='utf-8') as f:
30
- LOCAL_HOST.update(json.load(f))
31
- except:
32
- pass
33
- return LOCAL_HOST
34
-
35
- ALL_HOST:Dict[str, List[dict]] = load_josn()
1
+ try:
2
+ import ujson as json
3
+ except:
4
+ import json
5
+ from pathlib import Path
6
+ from typing import Dict,List
7
+ import os
8
+
9
+ BOT_DIR = os.path.dirname(os.path.abspath(__file__))
10
+ filename = 'data/L4D2/l4d2.json'
11
+ global_file = Path(Path(__file__).parent.parent,filename)
12
+ def load_josn():
13
+ # 本地模块
14
+ try:
15
+ LOCAL_HOST:dict = json.load(open(
16
+ filename, "r", encoding="utf8"))
17
+ except IOError or FileNotFoundError:
18
+ os.makedirs(os.path.dirname(filename), exist_ok=True)
19
+ data = {}
20
+ with open(filename, "w") as f:
21
+ json.dump(data, f)
22
+ LOCAL_HOST:dict = {}
23
+ try:
24
+ # 获取所有json文件的路径
25
+ json_files = Path('data/L4D2/l4d2').glob('*.json')
26
+
27
+ # 将所有json文件中的字典对象合并为一个字典
28
+ for file_path in json_files:
29
+ with open(file_path, 'r', encoding='utf-8') as f:
30
+ LOCAL_HOST.update(json.load(f))
31
+ except:
32
+ pass
33
+ return LOCAL_HOST
34
+
35
+ ALL_HOST:Dict[str, List[dict]] = load_josn()