nonebot-plugin-l4d2-server 1.0.6__tar.gz → 1.0.8__tar.gz

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 (96) hide show
  1. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/PKG-INFO +1 -1
  2. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/__main__.py +20 -3
  3. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/__init__.py +1 -1
  4. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_request/__init__.py +55 -30
  5. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_request/utils.py +3 -3
  6. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/utils/api/request.py +84 -81
  7. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/utils/api/utils.py +1 -1
  8. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/pyproject.toml +1 -1
  9. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/LICENSE +0 -0
  10. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/README.md +0 -0
  11. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/__init__.py +0 -0
  12. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/config.py +0 -0
  13. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/data/font/loli.ttf +0 -0
  14. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/Help.json +0 -0
  15. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/draw.py +0 -0
  16. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//344/273/213/347/273/215.png" +0 -0
  17. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//344/273/273/345/212/241.png" +0 -0
  18. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//344/277/241/346/201/257.png" +0 -0
  19. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//345/205/254/345/221/212.png" +0 -0
  20. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//345/210/200/345/211/221.png" +0 -0
  21. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//345/210/207/346/215/242.png" +0 -0
  22. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//345/210/240/351/231/244.png" +0 -0
  23. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//345/210/267/346/226/260.png" +0 -0
  24. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//345/215/241/347/273/204.png" +0 -0
  25. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//345/223/252/351/207/214.png" +0 -0
  26. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//345/234/260/345/233/276.png" +0 -0
  27. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/205/245.png" +0 -0
  28. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/207/272.png" +0 -0
  29. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//345/275/261.png" +0 -0
  30. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//346/213/274/345/233/276.png" +0 -0
  31. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//346/216/242/347/264/242.png" +0 -0
  32. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//346/216/250/351/200/201.png" +0 -0
  33. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//346/224/266/351/233/206.png" +0 -0
  34. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//346/224/273/347/225/245.png" +0 -0
  35. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//346/233/264/346/226/260.png" +0 -0
  36. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//346/235/220/346/226/231.png" +0 -0
  37. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//346/237/245/350/257/242.png" +0 -0
  38. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//346/240/241/351/252/214.png" +0 -0
  39. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//346/257/217/346/234/210.png" +0 -0
  40. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//346/267/261/346/270/212.png" +0 -0
  41. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//346/267/273/345/212/240.png" +0 -0
  42. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//346/270/205/351/231/244.png" +0 -0
  43. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//347/212/266/346/200/201.png" +0 -0
  44. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//347/255/276/345/210/260.png" +0 -0
  45. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//347/273/221/345/256/232.png" +0 -0
  46. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//350/241/250.png" +0 -0
  47. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//350/241/250/346/203/205.png" +0 -0
  48. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//350/247/222/350/211/262.png" +0 -0
  49. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//350/256/260/345/275/225.png" +0 -0
  50. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//351/205/215/347/275/256.png" +0 -0
  51. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/icon//351/207/215/345/220/257.png" +0 -0
  52. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/texture2d/badge.png +0 -0
  53. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/texture2d/banner.png +0 -0
  54. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/texture2d/bg.jpg +0 -0
  55. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/texture2d/button.png +0 -0
  56. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_help/texture2d/icon.png +0 -0
  57. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/__init__.py +0 -0
  58. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/convert.py +0 -0
  59. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/download.py +0 -0
  60. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/html_img.py +0 -0
  61. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/image_tools.py +0 -0
  62. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/anne/anne.html +0 -0
  63. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/anne/back.png +0 -0
  64. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/anne/back1.jpg +0 -0
  65. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/anne/group_ip.html +0 -0
  66. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/anne/ip.html +0 -0
  67. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/head/head.png +0 -0
  68. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/header/logo.png +0 -0
  69. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/header/player1.jpg +0 -0
  70. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.html +0 -0
  71. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.png +0 -0
  72. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/HYPixel11pxU-2.ttf +0 -0
  73. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.html +0 -0
  74. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.png +0 -0
  75. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.html +0 -0
  76. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.png +0 -0
  77. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/Tutumianhuatang-Bold-2.ttf +0 -0
  78. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/bilibili.svg +0 -0
  79. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/fingerprint.svg +0 -0
  80. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/github.svg +0 -0
  81. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/l.svg +0 -0
  82. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/m.svg +0 -0
  83. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/normal.html +0 -0
  84. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/vac.png +0 -0
  85. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/vac_white.png +0 -0
  86. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/vue.css +0 -0
  87. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/img/template/w.svg +0 -0
  88. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/model.py +0 -0
  89. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_image/vtfs.py +0 -0
  90. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_local/__init__.py +0 -0
  91. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_local/file.py +0 -0
  92. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/l4_request/draw_msg.py +0 -0
  93. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/utils/api/api.py +0 -0
  94. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/utils/api/models.py +0 -0
  95. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/utils/database/models.py +0 -0
  96. {nonebot_plugin_l4d2_server-1.0.6 → nonebot_plugin_l4d2_server-1.0.8}/nonebot_plugin_l4d2_server/utils/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-l4d2-server
3
- Version: 1.0.6
3
+ Version: 1.0.8
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>
@@ -37,10 +37,12 @@ from .l4_request import (
37
37
  get_ip_server,
38
38
  get_server_detail,
39
39
  reload_ip,
40
+ server_find,
40
41
  tj_request,
41
42
  )
42
43
  from .utils.api.request import L4API
43
44
  from .utils.api.utils import out_msg_out
45
+ from .utils.utils import split_maohao
44
46
 
45
47
  if TYPE_CHECKING:
46
48
  from .utils.api.models import OutServer
@@ -133,21 +135,30 @@ async def _(
133
135
  if len(tag_list) == 1:
134
136
  await UniMessage.text("未设置组,正在全服查找,时间较长").send()
135
137
  name = tag_list[0]
136
- out: List[OutServer] = await get_server_detail(is_img=False) # type: ignore
138
+ out: List[OutServer] = await server_find(is_img=False) # type: ignore
139
+ logger.info(out)
140
+ logger.info(type(out))
137
141
  out_msg = "未找到玩家"
138
142
  for one in out:
143
+ logger.info(one)
139
144
  for player in one["player"]:
140
145
  if name in player.name:
141
146
  out_msg = await get_ip_server(f"{one['host']}:{one['port']}")
142
147
  if len(tag_list) == 2:
143
148
  group, name = tag_list
144
149
  await UniMessage.text(f"正在查询{group}组").send()
145
- out: List[OutServer] = await get_server_detail(group=group, is_img=False) # type: ignore
150
+ out: List[OutServer] = await server_find(command=group, is_img=False) # type: ignore
146
151
  out_msg = "未找到玩家"
147
152
  for one in out:
148
153
  for player in one["player"]:
149
154
  if name in player.name:
150
155
  out_msg = await get_ip_server(f"{one['host']}:{one['port']}")
156
+ if config.l4_connect and isinstance(out_msg, bytes):
157
+ out_msg = UniMessage.image(raw=out_msg) + UniMessage.text(
158
+ f"\nconnect {one['host']}:{one['port']}",
159
+ )
160
+ else:
161
+ out_msg = UniMessage.text(out_msg)
151
162
 
152
163
  return await out_msg_out(out_msg)
153
164
 
@@ -161,7 +172,13 @@ async def _():
161
172
  async def _(args: Message = CommandArg()):
162
173
  ip: Optional[str] = args.extract_plain_text()
163
174
  if ip is not None:
164
- await out_msg_out(await get_ip_server(ip), is_connect=config.l4_image)
175
+ host, port = split_maohao(ip)
176
+ await out_msg_out(
177
+ await get_ip_server(ip),
178
+ is_connect=config.l4_connect,
179
+ host=host,
180
+ port=port,
181
+ )
165
182
 
166
183
 
167
184
  @l4_reload.handle()
@@ -10,7 +10,7 @@ from ..l4_image.convert import core_font
10
10
  from ..l4_image.model import PluginHelp
11
11
  from .draw import get_help
12
12
 
13
- __version__ = "1.0.6"
13
+ __version__ = "1.0.8"
14
14
  TEXT_PATH = Path(__file__).parent / "texture2d"
15
15
  HELP_DATA = Path(__file__).parent / "Help.json"
16
16
 
@@ -30,32 +30,32 @@ ALLHOST: Dict[str, List[NserverOut]] = {}
30
30
  COMMAND = set()
31
31
 
32
32
 
33
- async def get_all_server_detail():
33
+ async def get_all_server_detail() -> str:
34
34
  """
35
35
  获取所有服务器的详细信息。
36
36
 
37
- Args:
38
-
39
-
40
37
  Returns:
41
38
  str: 包含所有服务器详细信息的字符串。
42
-
43
39
  """
44
40
  out_list: List[AllServer] = []
45
41
  for group in ALLHOST:
46
42
  msg_list = await get_group_detail(group)
47
- if msg_list is None:
43
+ if not msg_list:
48
44
  continue
49
- active_server = 0
50
- max_server = 0
51
- active_player = 0
52
- max_player = 0
53
- for index, msg in enumerate(msg_list):
54
- max_server = index + 1
55
- if msg["server"].max_players != 0:
56
- active_server += 1
57
- active_player += msg["server"].player_count
58
- max_player += msg["server"].max_players
45
+
46
+ active_server = sum(1 for msg in msg_list if msg["server"].max_players != 0)
47
+ max_server = len(msg_list)
48
+ active_player = sum(
49
+ msg["server"].player_count
50
+ for msg in msg_list
51
+ if msg["server"].max_players != 0
52
+ )
53
+ max_player = sum(
54
+ msg["server"].max_players
55
+ for msg in msg_list
56
+ if msg["server"].max_players != 0
57
+ )
58
+
59
59
  data = {
60
60
  "command": group,
61
61
  "active_server": active_server,
@@ -65,14 +65,12 @@ async def get_all_server_detail():
65
65
  }
66
66
  out_list.append(cast(AllServer, data))
67
67
 
68
- # to do作图,先用文字凑合
69
- out_msg = ""
70
- for one in out_list:
71
- if one["max_player"]:
72
- out_msg += f"{one['command']} | 服务器{one['active_server']}/{one['max_server']} | 玩家{one['active_player']}/{one['max_player']}\n"
73
- else:
74
- continue
75
- return out_msg
68
+ # 输出服务器信息文本
69
+ return "\n".join(
70
+ f"{one['command']} | 服务器{one['active_server']}/{one['max_server']} | 玩家{one['active_player']}/{one['max_player']}"
71
+ for one in out_list
72
+ if one["max_player"]
73
+ )
76
74
 
77
75
 
78
76
  async def get_server_detail(
@@ -87,13 +85,10 @@ async def get_server_detail(
87
85
  command (str): 服务器组名。
88
86
  _id (Optional[str], optional): 服务器ID。默认为None。
89
87
  is_img (bool, optional): 是否返回图片格式的信息。默认为True。
90
- return_host_port (bool, optional): 是否返回host和port值。默认为False。
91
88
 
92
89
  Returns:
93
- Union[bytes, str, None, Tuple[str, int]]:
94
- 如果return_host_port为True且_id不为None,返回(host, port)元组;
95
- 否则返回服务器详细信息(图片格式返回bytes,文本格式返回str);
96
- 未找到服务器组返回None。
90
+ Union[UniMessage, None]:
91
+ 返回服务器详细信息(图片或文本格式),未找到服务器组或服务器时返回None
97
92
  """
98
93
  server_json = _get_server_json(command, ALLHOST)
99
94
  logger.info(server_json)
@@ -101,7 +96,7 @@ async def get_server_detail(
101
96
  logger.warning("未找到这个组")
102
97
  return None
103
98
 
104
- # 输出组服务器
99
+ # 输出组服务器信息
105
100
  if _id is None:
106
101
  return await _handle_group_info(server_json, command, is_img)
107
102
 
@@ -213,3 +208,33 @@ async def tj_request(command: str = "云", tj="tj"):
213
208
  except Exception as e:
214
209
  logger.error(f"tj_request error: {e}")
215
210
  return "获取服务器信息时出错"
211
+
212
+
213
+ async def server_find(
214
+ command: str = "云",
215
+ _id: Optional[str] = None,
216
+ is_img: bool = True,
217
+ ):
218
+ server_json = _get_server_json(command, ALLHOST)
219
+ logger.info(server_json)
220
+ if server_json is None:
221
+ logger.warning("未找到这个组")
222
+ return None
223
+
224
+ # 输出组服务器信息
225
+ if _id is None:
226
+ return await _handle_group_info(server_json, command, is_img)
227
+
228
+ _ip = await get_single_server_info(server_json, _id)
229
+ if _ip is None:
230
+ logger.warning("未找到这个服务器")
231
+ return None
232
+
233
+ out_msg = await _handle_single_server(server_json, _id, is_img)
234
+ if isinstance(out_msg, bytes):
235
+ return UniMessage.image(raw=out_msg) + UniMessage.text(
236
+ f"connect {_ip[0]}:{_ip[1]}",
237
+ )
238
+ if isinstance(out_msg, str):
239
+ return UniMessage.text(out_msg)
240
+ return None
@@ -34,7 +34,7 @@ async def _handle_group_info(
34
34
  server_json: list,
35
35
  command: str,
36
36
  is_img: bool,
37
- ) -> Union[bytes, str, None]:
37
+ ):
38
38
  """
39
39
  处理服务器组信息请求
40
40
 
@@ -44,13 +44,13 @@ async def _handle_group_info(
44
44
  is_img (bool): 是否返回图片格式
45
45
 
46
46
  Returns:
47
- Union[bytes, str, None]: 图片格式返回bytes,否则返回服务器列表
47
+ Union[bytes, list, None]: 图片格式返回bytes,否则返回服务器列表
48
48
  """
49
49
  logger.info(f"正在请求组服务器信息 {command}")
50
50
  server_dict = await get_much_server(server_json, command)
51
51
  if is_img:
52
52
  return await msg_to_image(server_dict)
53
- return str(server_dict)
53
+ return server_dict
54
54
 
55
55
 
56
56
  async def get_single_server_info(
@@ -313,98 +313,101 @@ class L4D2Api:
313
313
  )
314
314
  if tbody is None:
315
315
  return None
316
- kill_tag = cast(BeautifulSoup, tbody).find(
316
+
317
+ def get_table_dict(table, keys):
318
+ trs = table.select("tr")
319
+ return {
320
+ key: trs[i].select("td")[1].text.strip() for i, key in enumerate(keys)
321
+ }
322
+
323
+ kill_tag = cast(Tag, tbody).find(
317
324
  "div",
318
325
  class_="card-body worldmap d-flex flex-column justify-content-center text-center",
319
326
  )
320
327
 
321
- tbody_tags = tbody.find_all(
322
- "table",
323
- class_="table content-table-noborder text-left",
324
- )
328
+ tbody_tags = []
329
+ if isinstance(tbody, Tag):
330
+ tbody_tags = tbody.find_all(
331
+ "table",
332
+ class_="table content-table-noborder text-left",
333
+ )
334
+ if len(tbody_tags) < 6:
335
+ return None
336
+
337
+ info_keys = ["name", "avatar", "steamid", "playtime", "lasttime"]
338
+ detail_keys = [
339
+ "rank",
340
+ "source",
341
+ "avg_source",
342
+ "kills",
343
+ "kills_people",
344
+ "headshots",
345
+ "avg_headshots",
346
+ "map_play",
347
+ ]
348
+ error_keys = [
349
+ "mistake_shout",
350
+ "kill_friend",
351
+ "down_friend",
352
+ "abandon_friend",
353
+ "put_into",
354
+ "agitate_witch",
355
+ ]
356
+ inf_avg_keys = [
357
+ "avg_smoker",
358
+ "avg_boomer",
359
+ "avg_hunter",
360
+ "avg_charger",
361
+ "avg_spitter",
362
+ "avg_jockey",
363
+ "avg_tank",
364
+ ]
365
+ sur_keys = [
366
+ "map_clear",
367
+ "prefect_into",
368
+ "get_oil",
369
+ "ammo_arrange",
370
+ "adrenaline_give",
371
+ "pills_give",
372
+ "first_aid_give",
373
+ "friend_up",
374
+ "diss_friend",
375
+ "save_friend",
376
+ "protect_friend",
377
+ "pro_from_smoker",
378
+ "pro_from_hunter",
379
+ "pro_from_charger",
380
+ "pro_from_jockey",
381
+ "melee_charge",
382
+ "tank_kill",
383
+ "witch_instantly_kill",
384
+ ]
385
+ inf_keys = [
386
+ "sur_ace",
387
+ "sur_down",
388
+ "boommer_hit",
389
+ "hunter_prefect",
390
+ "hunter_success",
391
+ "tank_damage",
392
+ "charger_multiple",
393
+ ]
394
+
395
+ info_dict = get_table_dict(tbody_tags[0], info_keys)
396
+ detail_dict = get_table_dict(tbody_tags[1], detail_keys)
397
+ error_dict = get_table_dict(tbody_tags[2], error_keys)
398
+ inf_avg_dict = get_table_dict(tbody_tags[3], inf_avg_keys)
399
+ sur_dict = get_table_dict(tbody_tags[4], sur_keys)
400
+ inf_dict = get_table_dict(tbody_tags[5], inf_keys)
325
401
 
326
- info_tag = tbody_tags[0]
327
- detail_tag = tbody_tags[1]
328
- error_tag = tbody_tags[2]
329
- inf_avg_tag = tbody_tags[3]
330
- sur_tag = tbody_tags[4]
331
- inf_tag = tbody_tags[5]
332
-
333
- info_tr = info_tag.select("tr")
334
- info_dict = {
335
- "name": info_tr[0].select("td")[1].text.strip(),
336
- "avatar": info_tr[1].select("td")[1].text.strip(),
337
- "steamid": info_tr[2].select("td")[1].text.strip(),
338
- "playtime": info_tr[3].select("td")[1].text.strip(),
339
- "lasttime": info_tr[4].select("td")[1].text.strip(),
340
- }
341
- detail_tag = {
342
- "rank": detail_tag.select("tr")[0].select("td")[1].text.strip(),
343
- "source": detail_tag.select("tr")[1].select("td")[1].text.strip(),
344
- "avg_source": detail_tag.select("tr")[2].select("td")[1].text.strip(),
345
- "kills": detail_tag.select("tr")[3].select("td")[1].text.strip(),
346
- "kills_people": detail_tag.select("tr")[4].select("td")[1].text.strip(),
347
- "headshots": detail_tag.select("tr")[5].select("td")[1].text.strip(),
348
- "avg_headshots": detail_tag.select("tr")[6].select("td")[1].text.strip(),
349
- "map_play": detail_tag.select("tr")[7].select("td")[1].text.strip(),
350
- }
351
- error_tag = {
352
- "mistake_shout": error_tag.select("tr")[0].select("td")[1].text.strip(),
353
- "kill_friend": error_tag.select("tr")[1].select("td")[1].text.strip(),
354
- "down_friend": error_tag.select("tr")[2].select("td")[1].text.strip(),
355
- "abandon_friend": error_tag.select("tr")[3].select("td")[1].text.strip(),
356
- "put_into": error_tag.select("tr")[4].select("td")[1].text.strip(),
357
- "agitate_witch": error_tag.select("tr")[5].select("td")[1].text.strip(),
358
- }
359
- inf_avg_dict = {
360
- "avg_smoker": inf_avg_tag.select("tr")[0].select("td")[1].text.strip(),
361
- "avg_boomer": inf_avg_tag.select("tr")[1].select("td")[1].text.strip(),
362
- "avg_hunter": inf_avg_tag.select("tr")[2].select("td")[1].text.strip(),
363
- "avg_charger": inf_avg_tag.select("tr")[3].select("td")[1].text.strip(),
364
- "avg_spitter": inf_avg_tag.select("tr")[4].select("td")[1].text.strip(),
365
- "avg_jockey": inf_avg_tag.select("tr")[5].select("td")[1].text.strip(),
366
- "avg_tank": inf_avg_tag.select("tr")[6].select("td")[1].text.strip(),
367
- }
368
- sur_dict = {
369
- "map_clear": sur_tag.select("tr")[0].select("td")[1].text.strip(),
370
- "prefect_into": sur_tag.select("tr")[1].select("td")[1].text.strip(),
371
- "get_oil": sur_tag.select("tr")[2].select("td")[1].text.strip(),
372
- "ammo_arrange": sur_tag.select("tr")[3].select("td")[1].text.strip(),
373
- "adrenaline_give": sur_tag.select("tr")[4].select("td")[1].text.strip(),
374
- "pills_give": sur_tag.select("tr")[5].select("td")[1].text.strip(),
375
- "first_aid_give": sur_tag.select("tr")[6].select("td")[1].text.strip(),
376
- "friend_up": sur_tag.select("tr")[7].select("td")[1].text.strip(),
377
- "diss_friend": sur_tag.select("tr")[8].select("td")[1].text.strip(),
378
- "save_friend": sur_tag.select("tr")[9].select("td")[1].text.strip(),
379
- "protect_friend": sur_tag.select("tr")[10].select("td")[1].text.strip(),
380
- "pro_from_smoker": sur_tag.select("tr")[11].select("td")[1].text.strip(),
381
- "pro_from_hunter": sur_tag.select("tr")[12].select("td")[1].text.strip(),
382
- "pro_from_charger": sur_tag.select("tr")[13].select("td")[1].text.strip(),
383
- "pro_from_jockey": sur_tag.select("tr")[14].select("td")[1].text.strip(),
384
- "melee_charge": sur_tag.select("tr")[15].select("td")[1].text.strip(),
385
- "tank_kill": sur_tag.select("tr")[16].select("td")[1].text.strip(),
386
- "witch_instantly_kill": sur_tag.select("tr")[17]
387
- .select("td")[1]
388
- .text.strip(),
389
- }
390
- inf_dict = {
391
- "sur_ace": inf_tag.select("tr")[0].select("td")[1].text.strip(),
392
- "sur_down": inf_tag.select("tr")[1].select("td")[1].text.strip(),
393
- "boommer_hit": inf_tag.select("tr")[2].select("td")[1].text.strip(),
394
- "hunter_prefect": inf_tag.select("tr")[3].select("td")[1].text.strip(),
395
- "hunter_success": inf_tag.select("tr")[4].select("td")[1].text.strip(),
396
- "tank_damage": inf_tag.select("tr")[5].select("td")[1].text.strip(),
397
- "charger_multiple": inf_tag.select("tr")[6].select("td")[1].text.strip(),
398
- }
399
402
  info_dict = cast(AnnePlayerInfo, info_dict)
400
- detail_dict = cast(AnnePlayerDetail, detail_tag)
401
- error_dict = cast(AnnePlayerError, error_tag)
403
+ detail_dict = cast(AnnePlayerDetail, detail_dict)
404
+ error_dict = cast(AnnePlayerError, error_dict)
402
405
  inf_avg_dict = cast(AnnePlayerInfAvg, inf_avg_dict)
403
406
  sur_dict = cast(AnnePlayerSur, sur_dict)
404
407
  inf_dict = cast(AnnePlayerInf, inf_dict)
405
408
 
406
409
  out_dict = {
407
- "kill_msg": kill_tag.text if kill_tag is not None else "",
410
+ "kill_msg": kill_tag.text.strip() if kill_tag else "",
408
411
  "info": info_dict,
409
412
  "detail": detail_dict,
410
413
  "inf_avg": inf_avg_dict,
@@ -24,7 +24,7 @@ async def out_msg_out(
24
24
  await UniMessage.text(msg).finish()
25
25
  if is_connect:
26
26
  out = UniMessage.image(raw=msg) + UniMessage.text(
27
- f"连接到服务器: {host}:{port}",
27
+ f"connect: {host}:{port}",
28
28
  )
29
29
  return await out.finish()
30
30
  return await UniMessage.image(raw=msg).finish()
@@ -47,7 +47,7 @@ classifiers = [
47
47
  "Operating System :: OS Independent",
48
48
  ]
49
49
  readme = "README.md"
50
- version = "1.0.6"
50
+ version = "1.0.8"
51
51
 
52
52
  [project.license]
53
53
  text = "GPLv3"