nonebot-plugin-l4d2-server 1.0.2__py3-none-any.whl → 1.0.4__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.
@@ -3,7 +3,7 @@ import contextlib
3
3
  import socket
4
4
  from copy import deepcopy
5
5
  from pathlib import Path
6
- from typing import Any, Dict, List, Literal, Optional, Tuple, cast
6
+ from typing import Any, Dict, List, Literal, Optional, Tuple, Union, cast
7
7
 
8
8
  import a2s
9
9
  import aiofiles
@@ -47,8 +47,12 @@ class L4D2Api:
47
47
  ip_list: List[Tuple[str, int]],
48
48
  is_server: bool = True,
49
49
  is_player: bool = False,
50
- ) -> List[Tuple[a2s.SourceInfo, List[a2s.Player]]]:
51
- msg_list: List[Tuple[a2s.SourceInfo, List[a2s.Player]]] = []
50
+ ) -> List[
51
+ Tuple[Union[a2s.SourceInfo[str], a2s.GoldSrcInfo[str]], List[a2s.Player]]
52
+ ]:
53
+ msg_list: List[
54
+ Tuple[Union[a2s.SourceInfo[str], a2s.GoldSrcInfo[str]], List[a2s.Player]]
55
+ ] = []
52
56
  sorted_msg_list = []
53
57
  tasks = [] # 用来保存异步任务
54
58
  if ip_list != []:
@@ -80,19 +84,24 @@ class L4D2Api:
80
84
  is_player: bool,
81
85
  ):
82
86
  play: List[a2s.Player] = []
87
+ server: Union[a2s.SourceInfo, a2s.GoldSrcInfo]
83
88
  if is_server:
84
89
  try:
85
- server: a2s.SourceInfo = await a2s.ainfo(ip, timeout=3, encoding="utf8")
90
+ server = await a2s.ainfo(
91
+ ip,
92
+ timeout=3,
93
+ encoding="utf8",
94
+ )
86
95
 
87
96
  if server is not None:
88
- server.steam_id = index
97
+ server.steam_id = index # type: ignore
89
98
 
90
99
  except (
91
100
  asyncio.exceptions.TimeoutError,
92
101
  ConnectionRefusedError,
93
102
  socket.gaierror,
94
103
  ):
95
- server: a2s.SourceInfo = a2s.SourceInfo(
104
+ server = a2s.SourceInfo(
96
105
  protocol=0,
97
106
  server_name="服务器无响应",
98
107
  map_name="无",
@@ -137,7 +146,7 @@ class L4D2Api:
137
146
  json: Optional[Dict[str, Any]] = None,
138
147
  data: Optional[Dict[str, Any]] = None,
139
148
  is_json: bool = True,
140
- ):
149
+ ) -> Union[Dict[str, Any], BeautifulSoup]: # type: ignore
141
150
  header = deepcopy(self._HEADER)
142
151
 
143
152
  if json is not None:
@@ -181,7 +190,17 @@ class L4D2Api:
181
190
  return BeautifulSoup(html_content, "lxml")
182
191
 
183
192
  async def get_sourceban(self, tag: str = "云", url: str = anne_ban):
184
- """从sourceban++获取服务器列表,目前未做名称处理"""
193
+ """
194
+ 异步函数,从sourceban++获取服务器列表,目前未做名称处理。
195
+
196
+ Args:
197
+ tag (str): 用于标识不同来源的标签,默认为"云"。
198
+ url (str): SourceBan的URL,默认为anne_ban。
199
+
200
+ Returns:
201
+ list: 包含服务器信息的列表。
202
+
203
+ """
185
204
  if not (url.startswith(("http://", "https://"))):
186
205
  url = "http://" + url # 默认添加 http://
187
206
  soup = await self._server_request(
@@ -272,14 +291,14 @@ class L4D2Api:
272
291
  if not isinstance(soup, BeautifulSoup):
273
292
  return None
274
293
 
275
- tbody = soup.find(
294
+ tbody = cast(BeautifulSoup, soup).find(
276
295
  "div",
277
296
  class_="content text-center text-md-left",
278
297
  style="background-color: #f2f2f2;",
279
298
  )
280
299
  if tbody is None:
281
300
  return None
282
- kill_tag = tbody.find(
301
+ kill_tag = cast(BeautifulSoup, tbody).find(
283
302
  "div",
284
303
  class_="card-body worldmap d-flex flex-column justify-content-center text-center",
285
304
  )
@@ -7,6 +7,7 @@ from typing import Any, Dict, List, Optional, Tuple
7
7
  import aiofiles
8
8
  import aiohttp
9
9
  import nonebot
10
+ from aiohttp import ClientTimeout
10
11
  from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, MessageEvent
11
12
  from nonebot.log import logger
12
13
  from nonebot_plugin_alconna import UniMessage
@@ -184,7 +185,11 @@ async def url_to_byte(url: str):
184
185
  """获取URL数据的字节流"""
185
186
 
186
187
  async with aiohttp.ClientSession() as session:
187
- async with session.get(url, headers=headers, timeout=600) as response:
188
+ async with session.get(
189
+ url,
190
+ headers=headers,
191
+ timeout=ClientTimeout(total=600),
192
+ ) as response:
188
193
  if response.status == 200:
189
194
  return await response.read()
190
195
  return None
@@ -194,7 +199,11 @@ async def url_to_msg(url: str):
194
199
  """获取URL数据的字节流"""
195
200
 
196
201
  async with aiohttp.ClientSession() as session:
197
- async with session.get(url, headers=headers, timeout=600) as response:
202
+ async with session.get(
203
+ url,
204
+ headers=headers,
205
+ timeout=ClientTimeout(total=600),
206
+ ) as response:
198
207
  if response.status == 200:
199
208
  return await response.text()
200
209
  return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-l4d2-server
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: L4D2 server related operations plugin for NoneBot2
5
5
  Keywords: steam,game,l4d2,nonebot2,plugin
6
6
  Author-Email: Agnes_Digital <Z735803792@163.com>
@@ -11,10 +11,12 @@ Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Programming Language :: Python :: 3.9
12
12
  Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
14
15
  Classifier: Operating System :: OS Independent
15
16
  Project-URL: homepage, https://github.com/Agnes4m/nonebot_plugin_l4d2_server
16
17
  Requires-Python: <4.0,>=3.9
17
18
  Requires-Dist: nonebot2>=2.0.0
19
+ Requires-Dist: nonebot2[fastapi]>=2.3.3
18
20
  Requires-Dist: nonebot-plugin-htmlrender>=0.3.0
19
21
  Requires-Dist: nonebot-adapter-onebot>=2.4.4
20
22
  Requires-Dist: nonebot-plugin-alconna>=0.50.0
@@ -29,8 +31,8 @@ Requires-Dist: python-a2s>=1.4.1
29
31
  Requires-Dist: ujson>=5.10.0
30
32
  Requires-Dist: lxml>=5.2.2
31
33
  Requires-Dist: rcon>=2.1.0
32
- Requires-Dist: pillow>9
33
- Requires-Dist: beautifulsoup4>=4.12.3
34
+ Requires-Dist: pillow>10
35
+ Requires-Dist: bs4>=0.0.2
34
36
  Requires-Dist: rarfile>=4.2
35
37
  Requires-Dist: pyunpack>=0.3
36
38
  Requires-Dist: aiofiles>=24.1.0
@@ -45,7 +47,7 @@ Description-Content-Type: text/markdown
45
47
 
46
48
  <div align="center">
47
49
 
48
- # nonebot_plugin_l4d2_server 1.0.0a1
50
+ # nonebot_plugin_l4d2_server 1.0.4
49
51
 
50
52
  _✨Nonebot & Left 4 Dead 2 server操作✨_
51
53
  <div align = "center">
@@ -75,15 +77,12 @@ _✨Nonebot & Left 4 Dead 2 server操作✨_
75
77
 
76
78
  ## 顶置公告(如果以前用0.x.x版本暂时别更新)
77
79
 
78
- - **版本** 1.x.x进行了破坏式更新,目前处于测试阶段,使用旧插件的不要更新
80
+ - **版本** 1.x.x进行了破坏式更新,使用旧插件的不要更新
79
81
 
80
- ## 更改部分
82
+ ## 指令
81
83
 
82
- - 取消了网页控制台(没有卵用)
83
- - 取消了自动重启(与其他插件功能重复)
84
- - 取消了git拉取更新(nb规范用pypi)
85
- - 增加pil和浏览器渲染做选择(可以选择pil以节省性能性能)
86
- - 删除无用部分(依赖太多难以维护)
84
+ - 在json文件设置的前缀指令,例如设置"云",则指令 云 输出组服务器,云1 输出1号服务器
85
+ - l4图片开启/关闭 超管指令 可以修改输出单图是否为图片输出
87
86
 
88
87
  ## 安装
89
88
 
@@ -140,8 +139,7 @@ conda install nonebot-plugin-l4d2-server
140
139
  ## 主要功能
141
140
 
142
141
  - [ ] 求生服务器-本地多路径操作(传地图等)
143
- - [ ] 批量查询指定ip服务器状态和玩家
144
- - [ ] [求生电信服anne](https://github.com/fantasylidong/CompetitiveWithAnne)[查询~](https://sb.trygek.com/l4d_stats/ranking/index.php)
142
+ - [x] 批量查询指定ip服务器状态和玩家
145
143
 
146
144
  ## [数据结构](./docs/standand.md)
147
145
 
@@ -150,8 +148,6 @@ conda install nonebot-plugin-l4d2-server
150
148
  ## env设置
151
149
 
152
150
  """bash
153
- l4_anne = False
154
- """是否启用anne电信服相关功能"""
155
151
  l4_enable = True
156
152
  """是否全局启用求生功能"""
157
153
  l4_image = False
@@ -170,6 +166,15 @@ conda install nonebot-plugin-l4d2-server
170
166
  - 缤纷彩虹
171
167
  """
172
168
 
169
+ ## 和0.x.x更改部分
170
+
171
+ - 取消了网页控制台(没有卵用)
172
+ - 取消了自动重启(与其他插件功能重复)
173
+ - 取消了git拉取更新(nb规范用pypi)
174
+ - 增加pil和浏览器渲染做选择(可以选择pil以节省性能性能)
175
+ - 删除无用部分(依赖太多难以维护)
176
+ - 删除了anne部分,已移植到[这里](https://github.com/Agnes4m/L4D2UID),通过core插件调用
177
+
173
178
  ## 其他
174
179
 
175
180
  - 本人技术很差,如果您有发现BUG或者更好的建议,欢迎提Issue & Pr
@@ -1,15 +1,13 @@
1
- nonebot_plugin_l4d2_server-1.0.2.dist-info/METADATA,sha256=XqVzrC4S7KU6SCMgUx_ztxZobhrTefaqwnhG6vFzUmU,6596
2
- nonebot_plugin_l4d2_server-1.0.2.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
- nonebot_plugin_l4d2_server-1.0.2.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
- nonebot_plugin_l4d2_server-1.0.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
1
+ nonebot_plugin_l4d2_server-1.0.4.dist-info/METADATA,sha256=kZdrFtRaRtfYjXvIapyyUJnulUxQPjtbzRAOHAVyBkA,6763
2
+ nonebot_plugin_l4d2_server-1.0.4.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
+ nonebot_plugin_l4d2_server-1.0.4.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
+ nonebot_plugin_l4d2_server-1.0.4.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
5
5
  nonebot_plugin_l4d2_server/__init__.py,sha256=PIufOk1bxOx-nYqdoinoB7BcntIETNFwfzqKnmu-teE,1624
6
- nonebot_plugin_l4d2_server/__main__.py,sha256=E33d-UIdYmBZfT0ASW8WRkqoTXcF_NWRJIcQD_NS3FA,7981
7
- nonebot_plugin_l4d2_server/config.py,sha256=CavZ4EGdLvooVrUeP8zGsbZ0TJNsxGl2WT9rpyJtvhw,1175
6
+ nonebot_plugin_l4d2_server/__main__.py,sha256=Z8laU36rLdNq-Qfroj-1t6dbt4rfKLetvJ1cY937oGo,10232
7
+ nonebot_plugin_l4d2_server/config.py,sha256=_UKAn1g5BbykMNc6LXRujKoGhpxIM5JAdh3z301BLHk,2665
8
8
  nonebot_plugin_l4d2_server/data/font/loli.ttf,sha256=Yrh-RPoCrn1-NG94DR0x20ASXYUt8g3Ep6BCt3CdOFk,11125812
9
- nonebot_plugin_l4d2_server/l4_anne/__init__.py,sha256=zX4kTu4LAsqm7_li0-GcihnbYI65SBPkfUCPTs79U8k,4124
10
- nonebot_plugin_l4d2_server/l4_anne/ranne.py,sha256=vtNQJ-74rJiwVI3IYS3ZgFk_LaCviKU1yxrGk3DFvQs,532
11
9
  nonebot_plugin_l4d2_server/l4_help/Help.json,sha256=hz_k-qmGmGJKwCa8wmkHTLzXu6C-G-E_g7xdK-t6fNk,2673
12
- nonebot_plugin_l4d2_server/l4_help/__init__.py,sha256=cabiFBsUVFWs6EUC2XpXhp6PBWRmdBLWEVRNJAvjN6Y,1535
10
+ nonebot_plugin_l4d2_server/l4_help/__init__.py,sha256=sZRp6HJE2hvEcSST7CXJk8eAyv6rj4kLIcOK_7xUTI0,1535
13
11
  nonebot_plugin_l4d2_server/l4_help/draw.py,sha256=y6yDPUnoZFvwly8cf7g9HRpT1JXTxyA9DC1TuvUinTM,6448
14
12
  nonebot_plugin_l4d2_server/l4_help/icon/介绍.png,sha256=3QC6A38QC-7gDBxmtQSQdbsz7hsefU5LL-oZmJ41zTk,3806
15
13
  nonebot_plugin_l4d2_server/l4_help/icon/任务.png,sha256=nyZ4_kM21ZO95nwanCFnUfCGX-PkmJXYQf9OrJVKomY,3782
@@ -88,12 +86,12 @@ nonebot_plugin_l4d2_server/l4_image/model.py,sha256=FGsCvf_BKbRNJUVy6I5BKnArMY-3
88
86
  nonebot_plugin_l4d2_server/l4_image/vtfs.py,sha256=He_7zzEIOip8MXP55TS7aWPbzo6ac0wPf602nN3GWZM,1461
89
87
  nonebot_plugin_l4d2_server/l4_local/__init__.py,sha256=nz9KUxmuvRrryHakQQ4B30oC9jeGWZ3sON1tCKb-lS0,3603
90
88
  nonebot_plugin_l4d2_server/l4_local/file.py,sha256=hew1Y8kV3uSZvUGplmi09EGKC89-sUJWsWV7SCEstI8,3067
91
- nonebot_plugin_l4d2_server/l4_request/__init__.py,sha256=FRYBGRM30VoImQqAu3k90r82qkeo8wPjR93t6WLx7nk,7144
92
- nonebot_plugin_l4d2_server/l4_request/draw_msg.py,sha256=WjV2eEVVxsd4akNKDzVl6aRIegJ5pPbIzqziC0vBRmM,2697
89
+ nonebot_plugin_l4d2_server/l4_request/__init__.py,sha256=9Yo6mQ_bIBvMwQubC3Ctie6H2Qzx7ScwCQyVS9y25TE,11682
90
+ nonebot_plugin_l4d2_server/l4_request/draw_msg.py,sha256=koAVWrsDoLCTmwXY-NJTi5yjL1y1ND3daFkDWccQjcU,8071
93
91
  nonebot_plugin_l4d2_server/l4_request/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
94
92
  nonebot_plugin_l4d2_server/utils/api/api.py,sha256=auvDicCEKwvnm6EJYeCxCtugFby61K-zAmmaRWWEwtM,296
95
- nonebot_plugin_l4d2_server/utils/api/models.py,sha256=EKAAM5RsFK-hV-a80tc4r35ToNRhnCWVuQ-7imwBjwE,2386
96
- nonebot_plugin_l4d2_server/utils/api/request.py,sha256=hugBaPBK-gUr5Xemyk7dSHP1JlzYrEZcXPinkNX0AuU,14987
93
+ nonebot_plugin_l4d2_server/utils/api/models.py,sha256=p-hoxPHwadTaMRb2hqwfbaQ3pvJySrV8VbBmhA0Oi-M,2391
94
+ nonebot_plugin_l4d2_server/utils/api/request.py,sha256=aAsXtxvm7erXLfFCbs6NmsZCRGpsg3tsMdWvSn8SkNU,15575
97
95
  nonebot_plugin_l4d2_server/utils/database/models.py,sha256=SLdcgwsn39r_ZkcBoqf4MLX1EfpCOjGBwWcR16u9Bqo,454
98
- nonebot_plugin_l4d2_server/utils/utils.py,sha256=C-QzwtUCbq7QXmHplpmo3OTKbRztE1W7V-IywvufDl0,5971
99
- nonebot_plugin_l4d2_server-1.0.2.dist-info/RECORD,,
96
+ nonebot_plugin_l4d2_server/utils/utils.py,sha256=TD3cUCxmmj2GPmK1sQwP7NtkIXNO2FpuXjymaUqBDYo,6141
97
+ nonebot_plugin_l4d2_server-1.0.4.dist-info/RECORD,,
@@ -1,125 +0,0 @@
1
- from nonebot import log as log
2
- from nonebot import on_command
3
- from nonebot.adapters import Event, Message
4
- from nonebot.log import logger
5
- from nonebot.params import CommandArg
6
- from nonebot_plugin_alconna import UniMessage
7
-
8
- from ..utils.api.request import L4API
9
- from ..utils.database.models import SteamUser
10
- from ..utils.utils import get_message_at
11
- from .ranne import get_anne_rank_out
12
-
13
- anne_bind = on_command("Banne", aliases={"l4绑定", "anne绑定"}, priority=5, block=True)
14
- anne_search = on_command("Sanne", aliases={"anne搜索"})
15
- anne_rank = on_command("Ranne", aliases={"anne成绩"}, block=True, priority=1)
16
-
17
- anne_del = on_command(
18
- "Danne",
19
- aliases={"l4删除", "anne删除", "l4解绑", "anne解绑"},
20
- priority=5,
21
- block=True,
22
- )
23
-
24
-
25
- @anne_search.handle()
26
- async def _(args: Message = CommandArg()):
27
- name: str = args.extract_plain_text().strip()
28
- print(name)
29
- user_list = await L4API.get_anne_steamid(name)
30
- if user_list is None:
31
- await UniMessage.text("未找到玩家").finish()
32
- msg = f"---有{len(user_list)}个玩家---"
33
- for index, user in enumerate(user_list, start=1):
34
- if index >= 10:
35
- break
36
- msg += f"""
37
- {index}. {user["name"]} | [{user["score"]}] | {user["play_time"]}
38
- {user["steamid"]}
39
- """
40
- if msg:
41
- await UniMessage.text("\n".join(msg.splitlines())).finish()
42
- else:
43
- await UniMessage.text("没有找到玩家").finish()
44
-
45
-
46
- @anne_bind.handle()
47
- async def _(ev: Event, args: Message = CommandArg()):
48
- arg: str = args.extract_plain_text()
49
- if not arg:
50
- await UniMessage.text("虚空绑定?").finish()
51
-
52
- user = await SteamUser.get_or_none(userid=int(ev.get_user_id()))
53
- if user is None:
54
- user = await SteamUser.create(userid=int(ev.get_user_id()))
55
-
56
- if len(arg) == 17:
57
- # steamid64
58
- logger.info(f"SteamID64:{arg}")
59
- user.SteamID64 = arg
60
- msg = "绑定steamid64"
61
-
62
- elif arg.startswith("STEAM_"):
63
- # steamid
64
- logger.info(f"SteamID:{arg}")
65
- user.SteamID = arg
66
- msg = "绑定steamid"
67
-
68
- else:
69
- # name
70
- logger.info(f"Name:{arg}")
71
- user.Name = arg
72
- msg = "绑定名字"
73
- await user.save()
74
-
75
- return await UniMessage.text(f"{msg}成功").finish()
76
-
77
-
78
- @anne_del.handle()
79
- async def _(ev: Event):
80
- if record := await SteamUser.get_or_none(userid=int(ev.get_user_id())):
81
- logger.info(f"删除用户:{record}")
82
- await record.delete()
83
- await record.save()
84
- return await UniMessage.text("删除成功").finish()
85
- return await UniMessage.text("没有绑定信息呢").finish()
86
-
87
-
88
- @anne_rank.handle()
89
- async def _(ev: Event, args: Message = CommandArg()):
90
- uid = await get_message_at(str(ev.json()))
91
- if uid is None:
92
- uid = int(int(ev.get_user_id()))
93
- steamid = ""
94
- arg: str = args.extract_plain_text().strip()
95
- logger.info(f"arg:{arg}")
96
- # 优先从数据库查询
97
- if not arg:
98
- msg = await SteamUser.get_or_none(userid=uid)
99
- if msg is not None:
100
- steamid = msg.SteamID
101
- if not steamid:
102
- name = msg.Name
103
- if not name:
104
- await UniMessage.text("未绑定名字/steamid").finish()
105
- msg_dict = await L4API.get_anne_steamid(name)
106
- if not msg_dict:
107
- await UniMessage.text("绑定的昵称找不到呢").finish()
108
- steamid = msg_dict[0]["steamid"]
109
- logger.info(f"steamid:{steamid}")
110
-
111
- # 再从arg中查找
112
- else:
113
- if arg.startswith("STEAM_"):
114
- steamid = arg
115
- else:
116
- arg_dict = await L4API.get_anne_steamid(arg)
117
- if not arg_dict:
118
- await UniMessage.text("未找到该昵称玩家").finish()
119
- steamid = arg_dict[0]["steamid"]
120
- if not steamid:
121
- await UniMessage.text("未找到玩家,请使用指令`l4搜索`查找").finish()
122
- out_msg = await get_anne_rank_out(steamid)
123
- if out_msg is None:
124
- await UniMessage.text("未找到玩家").finish()
125
- await UniMessage.text(out_msg).finish()
@@ -1,18 +0,0 @@
1
- # coding=utf-8
2
- # anne战绩查询
3
- from ..utils.api.request import L4API
4
-
5
-
6
- async def get_anne_rank_out(steamid: str):
7
- msg = await L4API.get_anne_playerdetail(steamid)
8
- if msg is None:
9
- return None
10
- return f"""电信anne查询结果:
11
- 昵称:{msg['info']['name']}
12
- 排名:{msg['detail']['rank']}
13
- 分数:{msg['detail']["source"]}
14
- 击杀:{msg['detail']["kills"]}
15
- 爆头率:{msg['detail']["avg_source"]}
16
- 时间:{msg['info']['playtime']}
17
- 上次:{msg['info']['lasttime']}
18
- """