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.
Files changed (147) hide show
  1. nonebot_plugin_l4d2_server/__init__.py +10 -93
  2. nonebot_plugin_l4d2_server/__main__.py +140 -0
  3. nonebot_plugin_l4d2_server/config.py +35 -0
  4. nonebot_plugin_l4d2_server/data/font/loli.ttf +0 -0
  5. nonebot_plugin_l4d2_server/l4_anne/__init__.py +124 -0
  6. nonebot_plugin_l4d2_server/l4_anne/ranne.py +18 -0
  7. nonebot_plugin_l4d2_server/l4_help/Help.json +102 -0
  8. nonebot_plugin_l4d2_server/l4_help/__init__.py +57 -0
  9. nonebot_plugin_l4d2_server/l4_help/draw.py +206 -0
  10. nonebot_plugin_l4d2_server/l4_help/icon//344/273/213/347/273/215.png +0 -0
  11. nonebot_plugin_l4d2_server/l4_help/icon//344/273/273/345/212/241.png +0 -0
  12. nonebot_plugin_l4d2_server/l4_help/icon//344/277/241/346/201/257.png +0 -0
  13. nonebot_plugin_l4d2_server/l4_help/icon//345/205/254/345/221/212.png +0 -0
  14. nonebot_plugin_l4d2_server/l4_help/icon//345/210/200/345/211/221.png +0 -0
  15. nonebot_plugin_l4d2_server/l4_help/icon//345/210/207/346/215/242.png +0 -0
  16. nonebot_plugin_l4d2_server/l4_help/icon//345/210/240/351/231/244.png +0 -0
  17. nonebot_plugin_l4d2_server/l4_help/icon//345/210/267/346/226/260.png +0 -0
  18. nonebot_plugin_l4d2_server/l4_help/icon//345/215/241/347/273/204.png +0 -0
  19. nonebot_plugin_l4d2_server/l4_help/icon//345/223/252/351/207/214.png +0 -0
  20. nonebot_plugin_l4d2_server/l4_help/icon//345/234/260/345/233/276.png +0 -0
  21. nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/205/245.png +0 -0
  22. nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/207/272.png +0 -0
  23. nonebot_plugin_l4d2_server/l4_help/icon//345/275/261.png +0 -0
  24. nonebot_plugin_l4d2_server/l4_help/icon//346/213/274/345/233/276.png +0 -0
  25. nonebot_plugin_l4d2_server/l4_help/icon//346/216/242/347/264/242.png +0 -0
  26. nonebot_plugin_l4d2_server/l4_help/icon//346/216/250/351/200/201.png +0 -0
  27. nonebot_plugin_l4d2_server/l4_help/icon//346/224/266/351/233/206.png +0 -0
  28. nonebot_plugin_l4d2_server/l4_help/icon//346/224/273/347/225/245.png +0 -0
  29. nonebot_plugin_l4d2_server/l4_help/icon//346/233/264/346/226/260.png +0 -0
  30. nonebot_plugin_l4d2_server/l4_help/icon//346/235/220/346/226/231.png +0 -0
  31. nonebot_plugin_l4d2_server/l4_help/icon//346/237/245/350/257/242.png +0 -0
  32. nonebot_plugin_l4d2_server/l4_help/icon//346/240/241/351/252/214.png +0 -0
  33. nonebot_plugin_l4d2_server/l4_help/icon//346/257/217/346/234/210.png +0 -0
  34. nonebot_plugin_l4d2_server/l4_help/icon//346/267/261/346/270/212.png +0 -0
  35. nonebot_plugin_l4d2_server/l4_help/icon//346/267/273/345/212/240.png +0 -0
  36. nonebot_plugin_l4d2_server/l4_help/icon//346/270/205/351/231/244.png +0 -0
  37. nonebot_plugin_l4d2_server/l4_help/icon//347/212/266/346/200/201.png +0 -0
  38. nonebot_plugin_l4d2_server/l4_help/icon//347/255/276/345/210/260.png +0 -0
  39. nonebot_plugin_l4d2_server/l4_help/icon//347/273/221/345/256/232.png +0 -0
  40. nonebot_plugin_l4d2_server/l4_help/icon//350/241/250.png +0 -0
  41. nonebot_plugin_l4d2_server/l4_help/icon//350/241/250/346/203/205.png +0 -0
  42. nonebot_plugin_l4d2_server/l4_help/icon//350/247/222/350/211/262.png +0 -0
  43. nonebot_plugin_l4d2_server/l4_help/icon//350/256/260/345/275/225.png +0 -0
  44. nonebot_plugin_l4d2_server/l4_help/icon//351/205/215/347/275/256.png +0 -0
  45. nonebot_plugin_l4d2_server/l4_help/icon//351/207/215/345/220/257.png +0 -0
  46. nonebot_plugin_l4d2_server/l4_help/texture2d/badge.png +0 -0
  47. nonebot_plugin_l4d2_server/l4_help/texture2d/banner.png +0 -0
  48. nonebot_plugin_l4d2_server/l4_help/texture2d/bg.jpg +0 -0
  49. nonebot_plugin_l4d2_server/l4_help/texture2d/button.png +0 -0
  50. nonebot_plugin_l4d2_server/l4_help/texture2d/icon.png +0 -0
  51. nonebot_plugin_l4d2_server/l4_image/__init__.py +16 -0
  52. nonebot_plugin_l4d2_server/l4_image/anne_pil.py +17 -0
  53. nonebot_plugin_l4d2_server/l4_image/convert.py +175 -0
  54. nonebot_plugin_l4d2_server/{l4d2_image → l4_image}/download.py +11 -35
  55. nonebot_plugin_l4d2_server/l4_image/html_img.py +105 -0
  56. nonebot_plugin_l4d2_server/l4_image/image_tools.py +468 -0
  57. nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/back.png +0 -0
  58. nonebot_plugin_l4d2_server/l4_image/img/anne/back1.jpg +0 -0
  59. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/head/head.png +0 -0
  60. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/header/logo.png +0 -0
  61. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/header/player1.jpg +0 -0
  62. nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.html +299 -0
  63. nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.png +0 -0
  64. nonebot_plugin_l4d2_server/l4_image/img/template/HYPixel11pxU-2.ttf +0 -0
  65. nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.html +341 -0
  66. nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.png +0 -0
  67. nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.html +355 -0
  68. nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.png +0 -0
  69. nonebot_plugin_l4d2_server/l4_image/img/template/Tutumianhuatang-Bold-2.ttf +0 -0
  70. nonebot_plugin_l4d2_server/l4_image/img/template/bilibili.svg +1 -0
  71. nonebot_plugin_l4d2_server/l4_image/img/template/github.svg +1 -0
  72. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/l.svg +0 -1
  73. nonebot_plugin_l4d2_server/l4_image/img/template/m.svg +1 -0
  74. nonebot_plugin_l4d2_server/l4_image/img/template/normal.html +247 -0
  75. nonebot_plugin_l4d2_server/l4_image/img/template/vac.png +0 -0
  76. nonebot_plugin_l4d2_server/l4_image/img/template/vac_white.png +0 -0
  77. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/w.svg +1 -1
  78. nonebot_plugin_l4d2_server/l4_image/model.py +15 -0
  79. nonebot_plugin_l4d2_server/{l4d2_image → l4_image}/vtfs.py +4 -2
  80. nonebot_plugin_l4d2_server/l4_request/__init__.py +143 -0
  81. nonebot_plugin_l4d2_server/l4_request/draw_msg.py +83 -0
  82. nonebot_plugin_l4d2_server/utils/api/api.py +10 -0
  83. nonebot_plugin_l4d2_server/utils/api/models.py +137 -0
  84. nonebot_plugin_l4d2_server/utils/api/request.py +337 -0
  85. nonebot_plugin_l4d2_server/utils/database/models.py +18 -0
  86. nonebot_plugin_l4d2_server/{l4d2_utils → utils}/utils.py +60 -63
  87. {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/METADATA +57 -66
  88. nonebot_plugin_l4d2_server-1.0.0a2.dist-info/RECORD +96 -0
  89. {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/WHEEL +1 -1
  90. nonebot_plugin_l4d2_server/data/L4D2/image/template/help.html +0 -263
  91. nonebot_plugin_l4d2_server/data/L4D2/image/template/help_dack.html +0 -231
  92. nonebot_plugin_l4d2_server/data/L4D2/image/template/m.svg +0 -1
  93. nonebot_plugin_l4d2_server/data/img/white.png +0 -0
  94. nonebot_plugin_l4d2_server/l4d2_anne/__init__.py +0 -95
  95. nonebot_plugin_l4d2_server/l4d2_anne/analysis.py +0 -54
  96. nonebot_plugin_l4d2_server/l4d2_anne/anne_telecom.py +0 -79
  97. nonebot_plugin_l4d2_server/l4d2_anne/server.py +0 -47
  98. nonebot_plugin_l4d2_server/l4d2_anne/startand.py +0 -17
  99. nonebot_plugin_l4d2_server/l4d2_anne/utils.py +0 -294
  100. nonebot_plugin_l4d2_server/l4d2_data/__init__.py +0 -105
  101. nonebot_plugin_l4d2_server/l4d2_data/config.py +0 -18
  102. nonebot_plugin_l4d2_server/l4d2_data/players.py +0 -100
  103. nonebot_plugin_l4d2_server/l4d2_data/serverip.py +0 -40
  104. nonebot_plugin_l4d2_server/l4d2_file/__init__.py +0 -222
  105. nonebot_plugin_l4d2_server/l4d2_file/ayromote.py +0 -64
  106. nonebot_plugin_l4d2_server/l4d2_file/input_json.py +0 -77
  107. nonebot_plugin_l4d2_server/l4d2_file/remote.py +0 -86
  108. nonebot_plugin_l4d2_server/l4d2_file/utils.py +0 -104
  109. nonebot_plugin_l4d2_server/l4d2_image/__init__.py +0 -125
  110. nonebot_plugin_l4d2_server/l4d2_image/htmlimg.py +0 -18
  111. nonebot_plugin_l4d2_server/l4d2_image/images.py +0 -92
  112. nonebot_plugin_l4d2_server/l4d2_image/one.py +0 -44
  113. nonebot_plugin_l4d2_server/l4d2_image/send_image_tool.py +0 -32
  114. nonebot_plugin_l4d2_server/l4d2_image/steam.py +0 -63
  115. nonebot_plugin_l4d2_server/l4d2_push/__init__.py +0 -225
  116. nonebot_plugin_l4d2_server/l4d2_queries/__init__.py +0 -326
  117. nonebot_plugin_l4d2_server/l4d2_queries/himi.py +0 -113
  118. nonebot_plugin_l4d2_server/l4d2_queries/local_ip.py +0 -41
  119. nonebot_plugin_l4d2_server/l4d2_queries/qqgroup.py +0 -370
  120. nonebot_plugin_l4d2_server/l4d2_queries/send_msg.py +0 -131
  121. nonebot_plugin_l4d2_server/l4d2_queries/utils.py +0 -212
  122. nonebot_plugin_l4d2_server/l4d2_server/__init__.py +0 -118
  123. nonebot_plugin_l4d2_server/l4d2_server/index.py +0 -0
  124. nonebot_plugin_l4d2_server/l4d2_server/rcon.py +0 -53
  125. nonebot_plugin_l4d2_server/l4d2_server/workshop.py +0 -82
  126. nonebot_plugin_l4d2_server/l4d2_update/__init__.py +0 -137
  127. nonebot_plugin_l4d2_server/l4d2_update/draw_update_log.py +0 -45
  128. nonebot_plugin_l4d2_server/l4d2_update/restart.py +0 -69
  129. nonebot_plugin_l4d2_server/l4d2_update/update.py +0 -53
  130. nonebot_plugin_l4d2_server/l4d2_utils/classcal.py +0 -53
  131. nonebot_plugin_l4d2_server/l4d2_utils/command.py +0 -23
  132. nonebot_plugin_l4d2_server/l4d2_utils/config.py +0 -201
  133. nonebot_plugin_l4d2_server/l4d2_utils/message.py +0 -59
  134. nonebot_plugin_l4d2_server/l4d2_utils/rule.py +0 -35
  135. nonebot_plugin_l4d2_server/l4d2_utils/seach.py +0 -43
  136. nonebot_plugin_l4d2_server/l4d2_utils/txt_to_img.py +0 -32
  137. nonebot_plugin_l4d2_server/l4d2_web/web.py +0 -277
  138. nonebot_plugin_l4d2_server/l4d2_web/webUI.py +0 -506
  139. nonebot_plugin_l4d2_server/l4d2_web/webUI_s.py +0 -94
  140. nonebot_plugin_l4d2_server-0.6.6.dist-info/RECORD +0 -70
  141. /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/anne.html +0 -0
  142. /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/group_ip.html +0 -0
  143. /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/ip.html +0 -0
  144. /nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/fingerprint.svg +0 -0
  145. /nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/vue.css +0 -0
  146. /nonebot_plugin_l4d2_server/{l4d2_data/database.py → l4_request/utils.py} +0 -0
  147. {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/licenses/LICENSE +0 -0
@@ -1,212 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import random
3
- import struct
4
- from typing import List
5
-
6
- import a2s
7
- from nonebot.log import logger
8
- from pydantic import BaseModel
9
-
10
- from ..l4d2_utils.classcal import PlayerInfo
11
- from ..l4d2_utils.config import l4_config
12
- from ..l4d2_utils.txt_to_img import mode_txt_to_img
13
- from ..l4d2_utils.utils import split_maohao
14
- from .local_ip import ALL_HOST, Group_All_HOST
15
-
16
-
17
- class GROUPMSG(BaseModel):
18
- tag: str
19
- online_server: int
20
- empty_server: int
21
- full_server: int
22
- max_server: int
23
-
24
- online_player: int
25
- max_player: int
26
-
27
- def __str__(self) -> str:
28
- return f"""组:{self.tag}
29
- 在线服务器:{self.online_server}/{self.max_server}
30
- 空服务器:{self.empty_server}/{self.max_server}
31
- 在线玩家数量:{self.online_player}/{self.max_player}"""
32
-
33
-
34
- async def queries_server(msg: list) -> str:
35
- """查询ip返回信息"""
36
- ip = msg[0]
37
- port = msg[1]
38
- msgs = ""
39
- try:
40
- msgs = await queries(ip, port)
41
- msgs += await player_queries(ip, port)
42
- except (struct.error, TimeoutError):
43
- pass
44
- # except Exception:
45
- # msgs = '有无法识别的用户名'
46
- # return msgs
47
- return msgs
48
-
49
-
50
- async def get_anne_server_ip(ip: str, ismsg: bool = False):
51
- """输出查询ip和ping"""
52
- if ismsg:
53
- ...
54
- host, port = split_maohao(ip)
55
- data = await queries_server([host, port])
56
- if l4_config.l4_image:
57
- await mode_txt_to_img(
58
- data.split("\n")[0],
59
- data.replace(data.split("\n")[0], f"\nconnect {ip}"),
60
- )
61
- return None
62
- data += f"\nconnect {ip}"
63
- return data
64
-
65
-
66
- async def json_server_to_tag_dict(key: str, msg: str):
67
- """
68
- l4d2字典转tag的dict结果
69
- - 1、先匹配腐竹
70
- - 2、匹配数字(几服),没有参数则从结果里随机返回一个
71
- """
72
- data_dict = {}
73
- msg = msg.replace(" ", "")
74
- # 腐竹循环
75
- for tag, value in ALL_HOST.items():
76
- value: List[dict]
77
- if tag == key:
78
- data_dict.update({"server": tag})
79
- if not msg:
80
- # 腐竹
81
- data_dict.update(random.choice(value))
82
- elif msg.isdigit():
83
- logger.info("腐竹 + 序号")
84
- for server in value:
85
- if msg == str(server["id"]):
86
- data_dict.update(server)
87
- break
88
-
89
- return data_dict
90
-
91
-
92
- async def player_queries_anne_dict(ip: str, port: int):
93
- """anne算法返回玩家"""
94
- port = int(port)
95
- # message_dic = await l4d2.APlayer(ip,port,times=5)
96
- message_list: List[a2s.Player] = await a2s.aplayers((ip, port)) # type: ignore
97
- msg_list: List[PlayerInfo] = []
98
- if message_list != []:
99
- for i in message_list:
100
- msg_list.append(
101
- PlayerInfo(
102
- name=i.name,
103
- Score=i.score,
104
- Duration=await convert_duration(i.duration),
105
- ),
106
- # {
107
- # "name": i.name,
108
- # "Score": i.score,
109
- # "Duration": await convert_duration(i.duration),
110
- # },
111
- )
112
- return msg_list
113
-
114
-
115
- async def player_queries(ip: str, port: int):
116
- port = int(port)
117
- message_list = await player_queries_anne_dict(ip, port)
118
- return await msg_ip_to_list(message_list)
119
-
120
-
121
- async def msg_ip_to_list(message_list: List[PlayerInfo]):
122
- message = ""
123
- n = 0
124
- if message_list == []:
125
- message += "服务器里,是空空的呢\n"
126
- else:
127
- max_duration_len = max([len(str(i.Duration)) for i in message_list])
128
- max_score_len = max([len(str(i.Score)) for i in message_list])
129
- for i in message_list:
130
- n += 1
131
- name = i.name
132
- score = i.Score
133
- if score == "0":
134
- score = "摸"
135
- duration = i.Duration
136
- soc = "[{:>{}}]".format(score, max_score_len)
137
- dur = "{:^{}}".format(duration, max_duration_len)
138
- message += f"{soc} | {dur} | {name} \n"
139
- return message
140
-
141
-
142
- async def convert_duration(duration: float) -> str:
143
- minutes, seconds = divmod(duration, 60)
144
- hours, minutes = divmod(minutes, 60)
145
- time_str = ""
146
- if hours > 0:
147
- time_str += f"{int(hours)}h "
148
- if minutes > 0 or hours > 0:
149
- time_str += f"{int(minutes)}m "
150
- time_str += f"{int(seconds)}s"
151
- return time_str.strip()
152
-
153
-
154
- async def queries(ip: str, port: int):
155
- port = int(port)
156
- msg_dict = await queries_dict(ip, port)
157
- message = f"名称:{msg_dict['name']}\n"
158
- message += f"地图:{msg_dict['map_']}\n"
159
- message += f"延迟:{msg_dict['ping']}\n"
160
- message += f"玩家:{msg_dict['players']} / {msg_dict['max_players']}\n"
161
- return message
162
-
163
-
164
- async def queries_dict(ip: str, port: int) -> dict:
165
- port = int(port)
166
- ip = str(ip)
167
- msg_dict = {}
168
- # message_dict = await l4d(ip,port)
169
- msg: a2s.SourceInfo = await a2s.ainfo((ip, port)) # type: ignore
170
- msg_dict["folder"] = msg.folder
171
- msg_dict["name"] = msg.server_name
172
- msg_dict["map_"] = msg.map_name
173
- msg_dict["players"] = msg.player_count
174
- msg_dict["max_players"] = msg.max_players
175
- msg_dict["rank_players"] = f"{msg.player_count}/{msg.max_players}"
176
- msg_dict["ip"] = str(ip) + ":" + str(port)
177
- msg_dict["ping"] = f"{msg.ping*1000:.0f}ms"
178
- msg_dict["system"] = f"{msg.platform}.svg"
179
- if msg_dict["players"] < msg_dict["max_players"]:
180
- msg_dict["enabled"] = True
181
- else:
182
- msg_dict["enabled"] = False
183
- return msg_dict
184
-
185
-
186
- def server_key():
187
- """响应的服务器开头"""
188
- a = set()
189
- for tag1, _value in ALL_HOST.items():
190
- try:
191
- a.add(tag1)
192
- except AttributeError:
193
- a.add("希腊那我从来没有想过这个事情")
194
- return a
195
-
196
-
197
- def group_key():
198
- """响应群组服务器开头"""
199
- a = set()
200
- for tag1, _value in Group_All_HOST.items():
201
- try:
202
- a.add(tag1)
203
- except AttributeError:
204
- a.add("希腊那我从来没有想过这个事情")
205
- return a
206
-
207
-
208
- async def auto_id(msg_list: List[int]):
209
- for one in range(1, 100):
210
- if one not in msg_list:
211
- return one
212
- return 0
@@ -1,118 +0,0 @@
1
- from typing import List, Union
2
-
3
- from nonebot import on_command
4
- from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, Message
5
- from nonebot.log import logger
6
- from nonebot.matcher import Matcher
7
- from nonebot.params import Arg, ArgPlainText, CommandArg
8
- from nonebot.typing import T_State
9
- from nonebot_plugin_saa import Image, MessageFactory, Text
10
-
11
- from ..l4d2_file.utils import all_zip_to_one
12
- from ..l4d2_image.steam import url_to_byte
13
- from ..l4d2_image.vtfs import img_to_vtf
14
- from ..l4d2_utils.utils import upload_file
15
- from .workshop import workshop_msg
16
-
17
- # 下载内容
18
- up_workshop = on_command(
19
- "workshop",
20
- aliases={"创意工坊下载", "求生创意工坊"},
21
- priority=20,
22
- block=True,
23
- )
24
- vtf_make = on_command("vtf_make", aliases={"求生喷漆"}, priority=20, block=True)
25
-
26
-
27
- @up_workshop.handle()
28
- async def _(matcher: Matcher, args: Message = CommandArg()):
29
- msg = args.extract_plain_text().strip()
30
- if msg:
31
- matcher.set_arg("ip", args)
32
-
33
-
34
- @up_workshop.got("ip", prompt="请输入创意工坊网址或者物品id")
35
- async def _(matcher: Matcher, state: T_State, tag: str = ArgPlainText("ip")):
36
- # 这一部分注释类型有大问题,反正能跑就不改了
37
- msg = await workshop_msg(tag)
38
- if not msg:
39
- await matcher.finish("没有这个物品捏")
40
- elif isinstance(msg, dict):
41
- pic = await url_to_byte(msg["图片地址"])
42
- if not pic:
43
- return
44
- message: str = ""
45
- for item, value in msg.items():
46
- if item in ["图片地址", "下载地址", "细节"] or not isinstance(item, str):
47
- continue
48
- message += f"{item} : {value}\n"
49
- message += "如果需要上传,请发送 'yes'"
50
- state["dic"] = msg
51
- await MessageFactory([Image(pic), Text(message)]).finish()
52
- elif isinstance(msg, list):
53
- lenge = len(msg)
54
- pic = await url_to_byte(msg[0]["图片地址"]) # type: ignore
55
- message: str = f"有{lenge}个文件\n"
56
- ones = []
57
- for one in msg:
58
- for item, value in one.items():
59
- if item in ["图片地址", "下载地址", "细节"]:
60
- continue
61
- message += f"{item}:{value}\n"
62
- ones.append(one)
63
- state["dic"] = ones
64
-
65
-
66
- @up_workshop.got("is_sure")
67
- async def _(matcher: Matcher, bot: Bot, event: GroupMessageEvent, state: T_State):
68
- is_sure = str(state["is_sure"])
69
- if is_sure == "yes":
70
- data_dict: Union[dict, List[dict]] = state["dic"]
71
- logger.info("开始上传")
72
- if isinstance(data_dict, dict):
73
- data_file = await url_to_byte(data_dict["下载地址"])
74
- if not data_file:
75
- return
76
- file_name = data_dict["名字"] + ".vpk"
77
- await matcher.send("获取地址成功,尝试上传")
78
- await upload_file(bot, event, data_file, file_name)
79
- else:
80
- data_file_list = []
81
- for data_one in data_dict:
82
- data_file = await url_to_byte(data_one["下载地址"])
83
- data_file_list.append(data_file)
84
- if not data_file:
85
- return
86
- file_name = data_one["名字"] + ".vpk"
87
- await all_zip_to_one(data_file_list)
88
- await upload_file(bot, event, data_file, file_name)
89
- else:
90
- await matcher.finish("已取消上传")
91
-
92
-
93
- @vtf_make.handle()
94
- async def _(matcher: Matcher, state: T_State, args: Message = CommandArg()):
95
- msg: str = args.extract_plain_text()
96
- if msg not in ["拉伸", "填充", "覆盖", ""]:
97
- await matcher.finish("错误的图片处理方式")
98
- if msg == "":
99
- msg = "拉伸"
100
- state["way"] = msg
101
- logger.info("方式", msg)
102
-
103
-
104
- @vtf_make.got("image", prompt="请发送喷漆图片")
105
- async def _(bot: Bot, event: GroupMessageEvent, state: T_State, tag=Arg("image")):
106
- pic_msg: GroupMessageEvent = state["image"][0]
107
- pic_url = pic_msg.dict()["data"]["url"]
108
- logger.info(pic_url)
109
- logger.info(type(pic_url))
110
- tag = state["way"]
111
- pic_bytes = await url_to_byte(pic_url)
112
- if not pic_bytes:
113
- return
114
- img_io = await img_to_vtf(pic_bytes, tag)
115
- img_bytes = img_io.getbuffer()
116
- usr_id = event.get_user_id()
117
- file_name: str = str(usr_id) + ".vtf"
118
- await upload_file(bot, event, img_bytes, file_name)
File without changes
@@ -1,53 +0,0 @@
1
- import asyncio
2
- from pathlib import Path
3
-
4
- import aiofiles
5
- from rcon.source import rcon
6
-
7
- from ..l4d2_utils.config import CHECK_FILE, l4_config
8
-
9
-
10
- async def rcon_server(password: str, msg: str):
11
- try:
12
- return await asyncio.wait_for(
13
- rcon(
14
- command=msg,
15
- host=l4_config.l4_ipall[CHECK_FILE]["host"],
16
- port=l4_config.l4_ipall[CHECK_FILE]["port"],
17
- passwd=password,
18
- ),
19
- timeout=30,
20
- )
21
- except asyncio.TimeoutError:
22
- return "超时"
23
-
24
-
25
- async def read_server_cfg_rcon():
26
- """如果没有输入rcon,尝试自动获取"""
27
- if not l4_config.l4_ipall[CHECK_FILE]["rcon"]:
28
- cfg_server = Path(
29
- l4_config.l4_ipall[CHECK_FILE]["location"],
30
- "left4dead2/cfg/server.cfg",
31
- )
32
- async with aiofiles.open(cfg_server, "r") as cfg:
33
- content: str = await cfg.read()
34
- lines = content.split("\n")
35
- for line in lines:
36
- if line.startswith("rcon_password"):
37
- password = line.split(" ")[-1]
38
- return password.strip('"')
39
- return l4_config.l4_ipall[CHECK_FILE]["rcon"]
40
-
41
-
42
- async def rcon_command(rcon, cmd):
43
- return await rcon_server(rcon, cmd.strip())
44
-
45
-
46
- async def command_server(msg: str):
47
- rcon = await read_server_cfg_rcon()
48
- msg = await rcon_command(rcon, msg)
49
- if not msg:
50
- msg = "你可能发送了一个无用指令,或者换图导致服务器无响应"
51
- elif msg.startswith("Unknown command"):
52
- msg = "无效指令:" + msg.replace("Unknown command", "").strip()
53
- return msg.strip().replace("\n", "")
@@ -1,82 +0,0 @@
1
- from typing import Dict, List, Union
2
-
3
- import httpx
4
- from nonebot.log import logger
5
-
6
- try:
7
- import ujson as json
8
- except ImportError:
9
- import json
10
-
11
-
12
- async def workshop_to_dict(msg: str):
13
- """把创意工坊的id,转化为信息字典"""
14
- i = await api_get_json(msg)
15
-
16
- # 处理是否是多地图文件
17
- if i["file_url"] == i["preview_url"]:
18
- return await primary_map(i) # type: ignore
19
- return await only_map(i)
20
-
21
-
22
- async def api_get_json(msg: str):
23
- url_search = "https://db.steamworkshopdownloader.io/prod/api/details/file"
24
- # data = {msg: ""}
25
- data = [int(msg)]
26
- headers = {
27
- "Accept": "application/json, text/plain, */*",
28
- "Accept-Encoding": "gzip, deflate, br",
29
- "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
30
- "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
31
- "Origin": "https://steamworkshopdownloader.io",
32
- "Referer": "https://steamworkshopdownloader.io/",
33
- "Sec-Ch-Ua": '"Not/A)Brand";v="99", "Microsoft Edge";v="115", "Chromium";v="115"',
34
- "Sec-Ch-Ua-Mobile": "?0",
35
- "Sec-Ch-Ua-Platform": '"Windows"',
36
- "Sec-Fetch-Dest": "empty",
37
- "Sec-Fetch-Mode": "cors",
38
- "Sec-Fetch-Site": "same-site",
39
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.188",
40
- }
41
- async with httpx.AsyncClient() as client:
42
- response = await client.post(url_search, headers=headers, json=data)
43
- data_msg = response.content.decode("utf-8", errors="ignore")
44
- logger.info(response.status_code)
45
- logger.info(data_msg)
46
- return json.loads(data_msg[1:-1])
47
-
48
-
49
- async def only_map(i: Dict[str, str]):
50
- """单地图下载"""
51
- out: Dict[str, str] = {}
52
- out["名字"] = i["title"]
53
- out["游戏"] = i["app_name"]
54
- out["下载地址"] = i["file_url"]
55
- out["图片地址"] = i["preview_url"]
56
- out["细节"] = i["file_description"]
57
- return out
58
-
59
-
60
- async def primary_map(i: Dict[str, List[Dict[str, str]]]):
61
- """主地图返回多地图参数"""
62
- map_list: List[Union[Dict[str, List[Dict[str, str]]], Dict[str, str]]] = []
63
- map_list.append(i)
64
- for one in i["children"]:
65
- map_list.append(await api_get_json(one["publishedfileid"]))
66
- return map_list
67
-
68
-
69
- async def workshop_msg(msg: str):
70
- """url变成id,拼接post请求"""
71
- if msg.startswith("https://steamcommunity.com/sharedfiles/filedetails/?id"):
72
- if "&" in msg:
73
- msg = msg.split("&")[0]
74
- else:
75
- pass
76
- msg = msg.replace("https://steamcommunity.com/sharedfiles/filedetails/?id=", "")
77
- if msg.isdigit():
78
- data: Union[dict, List[dict]] = await workshop_to_dict(msg)
79
- return data
80
- return None
81
- return None
82
- return None
@@ -1,137 +0,0 @@
1
- from typing import Any, Tuple
2
-
3
- from nonebot import get_bot, get_driver, on_command, on_regex
4
- from nonebot.adapters.onebot.v11 import Bot, MessageEvent, MessageSegment
5
- from nonebot.log import logger
6
- from nonebot.matcher import Matcher
7
- from nonebot.params import RegexGroup
8
- from nonebot.permission import SUPERUSER
9
-
10
- from ..l4d2_utils.rule import FullCommand
11
- from ..l4d2_utils.utils import register_menu
12
- from .draw_update_log import draw_update_log_img
13
- from .restart import restart_genshinuid, restart_message
14
-
15
- l4d_restart = on_command("l4重启", rule=FullCommand())
16
- get_update_log = on_command("l4更新记录", rule=FullCommand())
17
- l4d_update = on_regex(
18
- r"^(l4)(强行)?(强制)?(更新)$",
19
- block=True,
20
- )
21
-
22
-
23
- driver = get_driver()
24
-
25
-
26
- @driver.on_bot_connect
27
- async def _():
28
- logger.info("检查遗留信息...")
29
- bot = get_bot()
30
- update_log = await restart_message()
31
- if update_log == {}:
32
- return
33
- if update_log["send_type"] == "group":
34
- await bot.call_api(
35
- api="send_group_msg",
36
- group_id=update_log["send_to"],
37
- message=update_log["msg"],
38
- )
39
- else:
40
- await bot.call_api(
41
- api="send_private_msg",
42
- user_id=update_log["send_to"],
43
- message=update_log["msg"],
44
- )
45
- logger.info("遗留信息检查完毕!")
46
-
47
-
48
- @get_update_log.handle()
49
- @register_menu(
50
- "更新记录",
51
- "更新记录",
52
- "查看插件最近的更新记录",
53
- detail_des=(
54
- "介绍:\n查看插件最近的有效Git更新记录\n \n指令:\n- <ft color=(238,120,0)>更新记录</ft>"
55
- ),
56
- )
57
- async def send_updatelog_msg(
58
- matcher: Matcher,
59
- ):
60
- im = await draw_update_log_img(is_update=False)
61
- logger.info("正在执行[更新记录]...")
62
- if isinstance(im, str):
63
- await matcher.finish(im)
64
- elif isinstance(im, bytes):
65
- await matcher.finish(MessageSegment.image(im))
66
- else:
67
- await matcher.finish("发生了未知错误,请联系管理员检查后台输出!")
68
-
69
-
70
- @l4d_restart.handle()
71
- @register_menu(
72
- "重启Bot",
73
- "l4重启",
74
- "重启Bot框架",
75
- trigger_method="超级用户指令",
76
- detail_des=("介绍:\n重启Bot框架\n \n指令:\n- <ft color=(238,120,0)>l4重启</ft>"),
77
- )
78
- async def send_restart_msg(
79
- bot: Bot,
80
- event: MessageEvent,
81
- matcher: Matcher,
82
- ):
83
- if not await SUPERUSER(bot, event):
84
- return
85
- logger.warning("开始执行[重启]")
86
- qid = event.user_id
87
- if len(event.get_session_id().split("_")) == 3:
88
- send_id = event.get_session_id().split("_")[1]
89
- send_type = "group"
90
- else:
91
- send_id = qid
92
- send_type = "private"
93
- await matcher.send("正在执行[l4重启]...")
94
- await restart_genshinuid(send_type, str(send_id))
95
-
96
-
97
- @l4d_update.handle()
98
- @register_menu(
99
- "更新插件",
100
- "l4更新",
101
- "手动更新插件",
102
- detail_des=(
103
- "介绍:\n"
104
- "手动更新插件(执行 git pull)\n"
105
- "每加上一个可选参数,执行等级加1\n"
106
- "当执行等级≥1时会还原上次更改,等级≥2时会清空暂存\n"
107
- " \n"
108
- "指令:\n"
109
- "- <ft color=(238,120,0)>l4d</ft>"
110
- "<ft color=(125,125,125)>(强行)(强制)</ft>"
111
- "<ft color=(238,120,0)>更新</ft>"
112
- ),
113
- )
114
- async def send_update_msg(
115
- bot: Bot,
116
- event: MessageEvent,
117
- matcher: Matcher,
118
- args: Tuple[Any, ...] = RegexGroup(),
119
- ):
120
- if not await SUPERUSER(bot, event):
121
- return
122
-
123
- logger.info("[l4更新] 正在执行 ...")
124
- level = 2
125
- if args[1] is None:
126
- level -= 1
127
- if args[2] is None:
128
- level -= 1
129
- logger.info(f"[l4更新] 更新等级为{level}")
130
- await matcher.send(f"开始执行[l4更新], 执行等级为{level}")
131
- im = await draw_update_log_img(level)
132
- if isinstance(im, str):
133
- await matcher.finish(im)
134
- elif isinstance(im, bytes):
135
- await matcher.finish(MessageSegment.image(im))
136
- else:
137
- await matcher.finish("发生了未知错误,请联系管理员检查后台输出!")
@@ -1,45 +0,0 @@
1
- from pathlib import Path
2
- from typing import Union
3
-
4
- from .update import update_from_git
5
-
6
- # from PIL import Image, ImageDraw
7
-
8
-
9
- # from ..l4d2_image.image import convert_img
10
- # from ..l4d2_image.image import get_color_bg
11
- # from ..utils.genshin_fonts.genshin_fonts import genshin_font_origin
12
-
13
- R_PATH = Path(__file__).parent
14
- TEXT_PATH = R_PATH / "texture2d"
15
-
16
- # gs_font_30 = genshin_font_origin(30)
17
- black_color = (24, 24, 24)
18
-
19
- log_config = {
20
- "key": "✨🐛🎨⚡🍱♻️",
21
- "num": 18,
22
- }
23
-
24
- log_map = {"✨": "feat", "🐛": "bug", "🍱": "bento", "⚡️": "zap", "🎨": "art"}
25
-
26
-
27
- async def draw_update_log_img(
28
- level: int = 0,
29
- repo_path: Union[str, Path, None] = None,
30
- is_update: bool = True,
31
- ) -> Union[bytes, str]:
32
- log_list = await update_from_git(level, repo_path, log_config, is_update)
33
- if len(log_list) == 0:
34
- return (
35
- "更新失败!更多错误信息请查看控制台...\n"
36
- ">> 可以尝试使用\n"
37
- ">> [l4强制更新](危险)\n"
38
- ">> [l4强行强制更新](超级危险)!"
39
- )
40
-
41
- result = "L4D2Bot 更新记录\n\n"
42
- for log in log_list:
43
- result += f"- {log}\n"
44
-
45
- return result