nonebot-plugin-l4d2-server 1.3.1__tar.gz → 1.3.5__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 (151) hide show
  1. {nonebot_plugin_l4d2_server-1.3.1 → nonebot_plugin_l4d2_server-1.3.5}/PKG-INFO +54 -21
  2. {nonebot_plugin_l4d2_server-1.3.1 → nonebot_plugin_l4d2_server-1.3.5}/README.md +42 -7
  3. {nonebot_plugin_l4d2_server-1.3.1 → nonebot_plugin_l4d2_server-1.3.5}/nonebot_plugin_l4d2_server/__init__.py +27 -6
  4. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/api/__init__.py +22 -0
  5. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/api/l4d2.py +394 -0
  6. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/shared/utils → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server}/api/models.py +4 -1
  7. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/shared/utils/api/api.py → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/api/sources.py +3 -4
  8. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/commands/__init__.py +9 -0
  9. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/commands/admin.py +104 -0
  10. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/commands/ban.py +145 -0
  11. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/commands/local.py +210 -0
  12. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/commands/query.py +169 -0
  13. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/config.py +102 -0
  14. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/consts.py +31 -0
  15. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/http_helpers.py +71 -0
  16. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/messages.py +35 -0
  17. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/registry.py +199 -0
  18. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/__init__.py +18 -0
  19. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/background.py +70 -0
  20. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/fonts.py +15 -0
  21. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render}/help/Help.json +29 -13
  22. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/textures/bg.jpg +0 -0
  23. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help.py +204 -0
  24. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/images.py +129 -0
  25. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/server_card.py +276 -0
  26. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/server_list.py +99 -0
  27. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/template → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/templates}/normal.html +1 -1
  28. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/template → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/templates}/style.css +4 -1
  29. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/workshop.py +75 -0
  30. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/services/__init__.py +13 -0
  31. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/services/filter.py +137 -0
  32. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/services/local_server.py +190 -0
  33. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/services/migrate.py +154 -0
  34. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/services/server_query.py +155 -0
  35. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/services/sourceban.py +51 -0
  36. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/services/workshop.py +66 -0
  37. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/store/__init__.py +5 -0
  38. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/shared/utils/group_store.py → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/store/groups.py +37 -26
  39. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/store/pages.py +70 -0
  40. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/version.py +3 -0
  41. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server.egg-info/PKG-INFO +252 -0
  42. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server.egg-info/SOURCES.txt +99 -0
  43. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server.egg-info/dependency_links.txt +1 -0
  44. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server.egg-info/requires.txt +16 -0
  45. nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server.egg-info/top_level.txt +1 -0
  46. {nonebot_plugin_l4d2_server-1.3.1 → nonebot_plugin_l4d2_server-1.3.5}/pyproject.toml +26 -38
  47. nonebot_plugin_l4d2_server-1.3.5/setup.cfg +4 -0
  48. nonebot_plugin_l4d2_server-1.3.5/tests/test_migrate.py +123 -0
  49. nonebot_plugin_l4d2_server-1.3.5/tests/test_registry.py +134 -0
  50. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/__main__.py +0 -368
  51. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/api/__init__.py +0 -5
  52. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/config.py +0 -159
  53. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/__init__.py +0 -55
  54. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/draw.py +0 -222
  55. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/texture2d/bg.jpg +0 -0
  56. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/domain/L4D2/l4d2/l4d2.json +0 -1
  57. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/domain/L4D2/l4d2.json +0 -1
  58. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/l4_ban/__init__.py +0 -5
  59. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/l4_ban/utils.py +0 -5
  60. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/l4_help/__init__.py +0 -8
  61. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/l4_image/__init__.py +0 -5
  62. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/l4_local/__init__.py +0 -5
  63. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/l4_request/__init__.py +0 -5
  64. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/message.py +0 -26
  65. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/commands/__init__.py +0 -1
  66. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/commands/server_groups.py +0 -0
  67. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/__init__.py +0 -16
  68. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/convert.py +0 -108
  69. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/html_img.py +0 -133
  70. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/image_tools.py +0 -287
  71. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/anne/anne.html +0 -60
  72. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/anne/back.png +0 -0
  73. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/anne/group_ip.html +0 -259
  74. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/anne/ip.html +0 -55
  75. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/head/head.png +0 -0
  76. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/header/logo.png +0 -0
  77. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/header/player1.jpg +0 -0
  78. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/model.py +0 -15
  79. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/server/ban/__init__.py +0 -174
  80. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/server/ban/utils.py +0 -11
  81. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/server/local/__init__.py +0 -230
  82. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/server/local/download.py +0 -38
  83. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/server/local/file.py +0 -147
  84. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/server/local/utils.py +0 -150
  85. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/server/query/__init__.py +0 -216
  86. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/server/query/draw_msg.py +0 -308
  87. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/server/query/tj.py +0 -73
  88. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/server/query/typing.py +0 -36
  89. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/server/query/utils.py +0 -348
  90. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/shared/utils/api/request.py +0 -491
  91. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/shared/utils/api/utils.py +0 -32
  92. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/shared/utils/database/models.py +0 -32
  93. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/shared/utils/sb_sources.py +0 -57
  94. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/shared/utils/utils.py +0 -199
  95. nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/utils/__init__.py +0 -5
  96. nonebot_plugin_l4d2_server-1.3.1/tests/__init__.py +0 -0
  97. nonebot_plugin_l4d2_server-1.3.1/tests/conftest.py +0 -27
  98. nonebot_plugin_l4d2_server-1.3.1/tests/help.py +0 -52
  99. nonebot_plugin_l4d2_server-1.3.1/tests/todo.md +0 -29
  100. {nonebot_plugin_l4d2_server-1.3.1 → nonebot_plugin_l4d2_server-1.3.5}/LICENSE +0 -0
  101. /nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/back_img/background .jpg → /nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/backgrounds/background.jpg +0 -0
  102. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/domain/font → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/fonts}/loli.ttf +0 -0
  103. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//344/273/213/347/273/215.png" +0 -0
  104. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//344/273/273/345/212/241.png" +0 -0
  105. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//344/277/241/346/201/257.png" +0 -0
  106. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//345/205/254/345/221/212.png" +0 -0
  107. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//345/210/200/345/211/221.png" +0 -0
  108. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//345/210/207/346/215/242.png" +0 -0
  109. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//345/210/240/351/231/244.png" +0 -0
  110. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//345/210/267/346/226/260.png" +0 -0
  111. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//345/215/241/347/273/204.png" +0 -0
  112. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//345/223/252/351/207/214.png" +0 -0
  113. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//345/234/260/345/233/276.png" +0 -0
  114. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//345/257/274/345/205/245.png" +0 -0
  115. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//345/257/274/345/207/272.png" +0 -0
  116. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//345/275/261.png" +0 -0
  117. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//346/213/274/345/233/276.png" +0 -0
  118. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//346/216/242/347/264/242.png" +0 -0
  119. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//346/216/250/351/200/201.png" +0 -0
  120. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//346/224/266/351/233/206.png" +0 -0
  121. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//346/224/273/347/225/245.png" +0 -0
  122. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//346/233/264/346/226/260.png" +0 -0
  123. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//346/235/220/346/226/231.png" +0 -0
  124. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//346/237/245/350/257/242.png" +0 -0
  125. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//346/240/241/351/252/214.png" +0 -0
  126. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//346/257/217/346/234/210.png" +0 -0
  127. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//346/267/261/346/270/212.png" +0 -0
  128. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//346/267/273/345/212/240.png" +0 -0
  129. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//346/270/205/351/231/244.png" +0 -0
  130. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//347/212/266/346/200/201.png" +0 -0
  131. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//347/255/276/345/210/260.png" +0 -0
  132. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//347/273/221/345/256/232.png" +0 -0
  133. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//350/241/250.png" +0 -0
  134. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//350/241/250/346/203/205.png" +0 -0
  135. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//350/247/222/350/211/262.png" +0 -0
  136. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//350/256/260/345/275/225.png" +0 -0
  137. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//351/205/215/347/275/256.png" +0 -0
  138. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/icon → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/icons}//351/207/215/345/220/257.png" +0 -0
  139. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/texture2d → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/textures}/badge.png +0 -0
  140. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/texture2d → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/textures}/banner.png +0 -0
  141. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/texture2d → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/textures}/button.png +0 -0
  142. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/core/help/texture2d → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/help/textures}/icon.png +0 -0
  143. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/template → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/templates}/github.svg +0 -0
  144. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/template → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/templates}/l.svg +0 -0
  145. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/template → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/templates}/m.svg +0 -0
  146. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/template → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/templates}/normal_old.html +0 -0
  147. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/template → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/templates}/vac.png +0 -0
  148. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/template → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/templates}/vac_white.png +0 -0
  149. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/template → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/templates}/vue.css +0 -0
  150. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/template → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/templates}/w.svg +0 -0
  151. {nonebot_plugin_l4d2_server-1.3.1/nonebot_plugin_l4d2_server/presentation/render/img/template → nonebot_plugin_l4d2_server-1.3.5/nonebot_plugin_l4d2_server/render/templates}/workshop.html +0 -0
@@ -1,42 +1,40 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: nonebot-plugin-l4d2-server
3
- Version: 1.3.1
3
+ Version: 1.3.5
4
4
  Summary: L4D2 server related operations plugin for NoneBot2
5
- Keywords: steam,game,l4d2,nonebot2,plugin
6
- Author-Email: Agnes_Digital <Z735803792@163.com>
5
+ Author-email: Agnes_Digital <Z735803792@163.com>
7
6
  License: GPLv3
7
+ Project-URL: homepage, https://github.com/Agnes4m/nonebot_plugin_l4d2_server
8
+ Keywords: steam,game,l4d2,nonebot2,plugin
8
9
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
9
10
  Classifier: Programming Language :: Python
10
11
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.9
12
12
  Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
15
17
  Classifier: Operating System :: OS Independent
16
- Project-URL: homepage, https://github.com/Agnes4m/nonebot_plugin_l4d2_server
17
18
  Requires-Python: <4.0,>=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
18
21
  Requires-Dist: nonebot2>=2.1.0
19
22
  Requires-Dist: nonebot2[fastapi]>=2.3.3
20
23
  Requires-Dist: nonebot-plugin-htmlrender>=0.3.0
21
24
  Requires-Dist: nonebot-adapter-onebot>=2.4.4
22
25
  Requires-Dist: nonebot-plugin-alconna>=0.50.0
23
- Requires-Dist: nonebot_plugin_datastore>=1.3.0
24
- Requires-Dist: nonebot-plugin-tortoise-orm>=0.1.4
25
26
  Requires-Dist: aiohttp>=3.8.4
26
27
  Requires-Dist: jinja2>=3.0.0
27
- Requires-Dist: srctools>=2.6.0
28
28
  Requires-Dist: httpx>=0.22.0
29
29
  Requires-Dist: python-a2s>=1.4.1
30
30
  Requires-Dist: ujson>=5.10.0
31
- Requires-Dist: rcon>=2.1.0
32
31
  Requires-Dist: pillow>10.0.0
33
- Requires-Dist: rarfile>=4.2
34
32
  Requires-Dist: pyunpack>=0.3
35
33
  Requires-Dist: aiofiles>=24.1.0
36
- Requires-Dist: bs4==0.0.2
34
+ Requires-Dist: beautifulsoup4>=4.12.0
37
35
  Requires-Dist: lxml>=6.0.2
38
- Requires-Dist: playwright==1.57.0
39
- Description-Content-Type: text/markdown
36
+ Requires-Dist: playwright>=1.61.0
37
+ Dynamic: license-file
40
38
 
41
39
  <!-- markdownlint-disable MD026 MD031 MD033 MD036 MD041 MD046 MD051 -->
42
40
  <div align="center">
@@ -106,15 +104,39 @@ _✨Nonebot & Left 4 Dead 2 server 操作 ✨_
106
104
  - l4 查找用户 在已知服务器中查找
107
105
  - l4 工坊下载 提供创意工坊 id 下载到服务器和群聊
108
106
 
109
- ### 自定义查服背景图片
107
+ ### 自定义服务器列表背景图片
110
108
 
111
- 插件支持自定义图片背景,在 `data/L4D2/custom_backgrounds/` 目录下放入 PNG/JPG/JPEG 格式图片即可,插件会自动随机选择使用。
109
+ `/云` 等组查询输出的服务器列表(HTML)图支持自定义背景。`/云1` 这类具体服查询**不受影响**,固定使用深蓝灰纯色背景。
112
110
 
113
- 具体位置参考 [数据结构](./docs/standand.md)
111
+ ```
112
+ <l4_path>/custom_backgrounds/ ← 放任意张图即可;插件会随机抽一张
113
+ ```
114
114
 
115
- - 目录不存在时插件会自动创建
116
- - 放入图片无需重启立即生效
117
- - 未放置图片时默认使用纯白色背景
115
+ `<l4_path>` 默认为 `data/L4D2`(即 `<l4_path>/custom_backgrounds/` = `data/L4D2/custom_backgrounds/`);如要换位置,在 `.env` 里改:
116
+
117
+ ```dotenv
118
+ L4_PATH=/path/to/your/data
119
+ ```
120
+
121
+ 使用步骤:
122
+
123
+ 1. 找到 `<l4_path>/custom_backgrounds/`(默认 `data/L4D2/custom_backgrounds/`,与 `云.json` 等组文件同级);
124
+ 2. 把你想要的背景图放入该目录,支持 `.jpg` / `.jpeg` / `.png` 格式,可放多张;
125
+ 3. 完成。下一次查询即会使用新背景。
126
+
127
+ > 目录会在插件启动时自动创建,无需手动建。
128
+
129
+ **查找顺序**:
130
+
131
+ - `/云`(服务器列表):从 `<l4_path>/custom_backgrounds/` 所有图片中**随机抽一张**;目录为空时回退到内置 `background.jpg`
132
+ - `/云1`(单服务器卡):固定使用深蓝灰纯色背景(`#496D89`),不加载任何图片
133
+
134
+ **选择规则**:
135
+
136
+ - 目录中有多张图时,每次查询**随机抽取**一张;
137
+ - 想只用某张图,把其余图片删掉或移走;
138
+ - 替换同名图片会按文件修改时间自动重新加载,无需重启;
139
+ - **建议尺寸**:宽幅横图(如 1920×1080),列表图会按高度铺满并横向平铺。
118
140
 
119
141
  ## 安装
120
142
 
@@ -177,6 +199,10 @@ conda install nonebot-plugin-l4d2-server
177
199
 
178
200
  ## [数据结构](./docs/standand.md)
179
201
 
202
+ > 服务器组文件存放位置:`<l4_path>/<组名>.json`(默认 `data/L4D2/<组名>.json`),旧版 `<l4_path>/l4d2/` 子目录会在启动时自动迁移。
203
+ >
204
+ > 所有数据路径(组文件、sb_pages、自定义背景图、迁移脚本)都跟着 `l4_path` 配置走,CWD 在哪都无所谓。改 `l4_path` 一处生效。
205
+
180
206
  ## env 设置
181
207
 
182
208
  ```bash
@@ -187,7 +213,7 @@ conda install nonebot-plugin-l4d2-server
187
213
  l4_connect = True
188
214
  """是否在查服命令后加入connect ip"""
189
215
  l4_path = "data/L4D2"
190
- """插件数据路径"""
216
+ """插件数据根目录。组 JSON / sb_pages / 自定义背景图 / 迁移脚本都从这里派生。"""
191
217
  l4_players = 4
192
218
  """查询总图的时候展示的用户数量"""
193
219
  l4_style = "default"
@@ -197,6 +223,13 @@ conda install nonebot-plugin-l4d2-server
197
223
 
198
224
  ## 和 0.x.x 更改部分
199
225
 
226
+ - **服务器组指令(`云`、`云1` 等)规则层拒绝非数字后缀**:之前输入 `云云` 会被解析为「组 `云` + args=`云`」然后静默退出,现在直接在 nonebot 规则层拒绝,不会进入 handler,也不会被本插件拦截后续处理。`云1` / `云12` 仍正常触发单服查询;
227
+ - **单服务器查询(`云1`)合并图片与 `connect host:port` 文本**:图片和 `connect host:port` 文本作为一条合并消息发出(受 `l4_connect` 配置控制),方便直接点链接加入服务器;
228
+ - **单服务器卡(`云1`)长内容自动换行**:服务器名、地图名、connect IP 等超出 380px 卡片宽度时,会按像素宽度自动换行展示,图片高度随行数自动撑高;
229
+ - **服务器列表(`云`)地图名溢出处理**:`.map-name` CSS 增加 `text-overflow: ellipsis`,超长地图名以省略号截断,不再撑破卡片;
230
+ - **查服背景图按渲染类型拆分目录**(后续调整):`/云`(服务器列表)从 `<l4_path>/custom_backgrounds/` 根目录的所有图片中随机抽一张,目录为空时回退到内置 `background.jpg`;`/云1`(单服务器卡)固定使用深蓝灰纯色,不加载任何图片。详见「自定义服务器列表背景图片」;
231
+ - **数据路径统一从 `l4_path` 派生**:组文件、sb_pages、自定义背景图、迁移脚本都跟着 `l4_path` 配置走,不再各自写死相对路径。`.env` 里改 `L4_PATH` 一处即生效,不用再管 bot 启动 CWD。
232
+
200
233
  ## 其他
201
234
 
202
235
  - anne 部分,已移植到[这里](https://github.com/Agnes4m/L4D2UID),通过 core 插件调用
@@ -66,15 +66,39 @@ _✨Nonebot & Left 4 Dead 2 server 操作 ✨_
66
66
  - l4 查找用户 在已知服务器中查找
67
67
  - l4 工坊下载 提供创意工坊 id 下载到服务器和群聊
68
68
 
69
- ### 自定义查服背景图片
69
+ ### 自定义服务器列表背景图片
70
70
 
71
- 插件支持自定义图片背景,在 `data/L4D2/custom_backgrounds/` 目录下放入 PNG/JPG/JPEG 格式图片即可,插件会自动随机选择使用。
71
+ `/云` 等组查询输出的服务器列表(HTML)图支持自定义背景。`/云1` 这类具体服查询**不受影响**,固定使用深蓝灰纯色背景。
72
72
 
73
- 具体位置参考 [数据结构](./docs/standand.md)
73
+ ```
74
+ <l4_path>/custom_backgrounds/ ← 放任意张图即可;插件会随机抽一张
75
+ ```
76
+
77
+ `<l4_path>` 默认为 `data/L4D2`(即 `<l4_path>/custom_backgrounds/` = `data/L4D2/custom_backgrounds/`);如要换位置,在 `.env` 里改:
78
+
79
+ ```dotenv
80
+ L4_PATH=/path/to/your/data
81
+ ```
82
+
83
+ 使用步骤:
84
+
85
+ 1. 找到 `<l4_path>/custom_backgrounds/`(默认 `data/L4D2/custom_backgrounds/`,与 `云.json` 等组文件同级);
86
+ 2. 把你想要的背景图放入该目录,支持 `.jpg` / `.jpeg` / `.png` 格式,可放多张;
87
+ 3. 完成。下一次查询即会使用新背景。
74
88
 
75
- - 目录不存在时插件会自动创建
76
- - 放入图片无需重启立即生效
77
- - 未放置图片时默认使用纯白色背景
89
+ > 目录会在插件启动时自动创建,无需手动建。
90
+
91
+ **查找顺序**:
92
+
93
+ - `/云`(服务器列表):从 `<l4_path>/custom_backgrounds/` 所有图片中**随机抽一张**;目录为空时回退到内置 `background.jpg`
94
+ - `/云1`(单服务器卡):固定使用深蓝灰纯色背景(`#496D89`),不加载任何图片
95
+
96
+ **选择规则**:
97
+
98
+ - 目录中有多张图时,每次查询**随机抽取**一张;
99
+ - 想只用某张图,把其余图片删掉或移走;
100
+ - 替换同名图片会按文件修改时间自动重新加载,无需重启;
101
+ - **建议尺寸**:宽幅横图(如 1920×1080),列表图会按高度铺满并横向平铺。
78
102
 
79
103
  ## 安装
80
104
 
@@ -137,6 +161,10 @@ conda install nonebot-plugin-l4d2-server
137
161
 
138
162
  ## [数据结构](./docs/standand.md)
139
163
 
164
+ > 服务器组文件存放位置:`<l4_path>/<组名>.json`(默认 `data/L4D2/<组名>.json`),旧版 `<l4_path>/l4d2/` 子目录会在启动时自动迁移。
165
+ >
166
+ > 所有数据路径(组文件、sb_pages、自定义背景图、迁移脚本)都跟着 `l4_path` 配置走,CWD 在哪都无所谓。改 `l4_path` 一处生效。
167
+
140
168
  ## env 设置
141
169
 
142
170
  ```bash
@@ -147,7 +175,7 @@ conda install nonebot-plugin-l4d2-server
147
175
  l4_connect = True
148
176
  """是否在查服命令后加入connect ip"""
149
177
  l4_path = "data/L4D2"
150
- """插件数据路径"""
178
+ """插件数据根目录。组 JSON / sb_pages / 自定义背景图 / 迁移脚本都从这里派生。"""
151
179
  l4_players = 4
152
180
  """查询总图的时候展示的用户数量"""
153
181
  l4_style = "default"
@@ -157,6 +185,13 @@ conda install nonebot-plugin-l4d2-server
157
185
 
158
186
  ## 和 0.x.x 更改部分
159
187
 
188
+ - **服务器组指令(`云`、`云1` 等)规则层拒绝非数字后缀**:之前输入 `云云` 会被解析为「组 `云` + args=`云`」然后静默退出,现在直接在 nonebot 规则层拒绝,不会进入 handler,也不会被本插件拦截后续处理。`云1` / `云12` 仍正常触发单服查询;
189
+ - **单服务器查询(`云1`)合并图片与 `connect host:port` 文本**:图片和 `connect host:port` 文本作为一条合并消息发出(受 `l4_connect` 配置控制),方便直接点链接加入服务器;
190
+ - **单服务器卡(`云1`)长内容自动换行**:服务器名、地图名、connect IP 等超出 380px 卡片宽度时,会按像素宽度自动换行展示,图片高度随行数自动撑高;
191
+ - **服务器列表(`云`)地图名溢出处理**:`.map-name` CSS 增加 `text-overflow: ellipsis`,超长地图名以省略号截断,不再撑破卡片;
192
+ - **查服背景图按渲染类型拆分目录**(后续调整):`/云`(服务器列表)从 `<l4_path>/custom_backgrounds/` 根目录的所有图片中随机抽一张,目录为空时回退到内置 `background.jpg`;`/云1`(单服务器卡)固定使用深蓝灰纯色,不加载任何图片。详见「自定义服务器列表背景图片」;
193
+ - **数据路径统一从 `l4_path` 派生**:组文件、sb_pages、自定义背景图、迁移脚本都跟着 `l4_path` 配置走,不再各自写死相对路径。`.env` 里改 `L4_PATH` 一处即生效,不用再管 bot 启动 CWD。
194
+
160
195
  ## 其他
161
196
 
162
197
  - anne 部分,已移植到[这里](https://github.com/Agnes4m/L4D2UID),通过 core 插件调用
@@ -1,7 +1,7 @@
1
1
  """
2
2
  * Copyright (c) 2023, Agnes Digital
3
3
  *
4
- * This program is free software: you can redistribute it and/or modify
4
+ * This program is free software: you can redistribute it and or modify
5
5
  * it under the terms of the GNU General Public License as published by
6
6
  * the Free Software Foundation, either version 3 of the License, or
7
7
  * (at your option) any later version.
@@ -20,17 +20,38 @@ from nonebot.plugin import PluginMetadata, inherit_supported_adapters
20
20
 
21
21
  # 依赖插件声明 必须在导入其它插件模块之前执行
22
22
  require("nonebot_plugin_alconna")
23
- require("nonebot_plugin_datastore")
24
23
  require("nonebot_plugin_htmlrender")
25
- require("nonebot_plugin_tortoise_orm")
26
24
 
27
- from . import __main__ # noqa: E402, F401
25
+ from . import commands # noqa: E402, F401 (registers all commands)
28
26
  from .config import ConfigModel # noqa: E402
29
- from .l4_help import __version__ # noqa: E402
30
- from .shared.utils.database import models # noqa: E402, F401
27
+ from .services import migrate, sourceban # noqa: E402
28
+ from .version import __version__ # noqa: E402
31
29
 
32
30
  driver = get_driver()
33
31
 
32
+ # Initial scan to populate command aliases before any rule refresh.
33
+ from .registry import registry as _registry # noqa: E402
34
+
35
+ _registry.scan_commands()
36
+
37
+
38
+ @driver.on_startup
39
+ async def _on_startup() -> None:
40
+ from .config import config
41
+ from .render.background import ensure_user_background_dir
42
+
43
+ # 确保 l4_path 指向的数据根目录存在;之后再做迁移 / 加载 / 后台目录建好。
44
+ config.data_dir.mkdir(parents=True, exist_ok=True)
45
+ migrate.migrate_legacy_layout()
46
+ # 只从磁盘 JSON 加载,避免每次启动都重新抓取所有 SourceBans 页面;
47
+ # 需要更新缓存时使用 l4刷新组 命令。
48
+ await sourceban.reload_registry()
49
+ sourceban.register_anne_alias()
50
+ from .commands.query import refresh_server_command_rule
51
+
52
+ refresh_server_command_rule()
53
+ ensure_user_background_dir()
54
+
34
55
 
35
56
  __plugin_meta__ = PluginMetadata(
36
57
  name="求生之路小助手",
@@ -0,0 +1,22 @@
1
+ """External API clients."""
2
+
3
+ from .l4d2 import L4API, L4D2Api
4
+ from .models import (
5
+ AllServer,
6
+ AnnePlayer2,
7
+ NserverOut,
8
+ OutServer,
9
+ SourceBansInfo,
10
+ WorksopInfo,
11
+ )
12
+
13
+ __all__ = [
14
+ "L4API",
15
+ "AllServer",
16
+ "AnnePlayer2",
17
+ "L4D2Api",
18
+ "NserverOut",
19
+ "OutServer",
20
+ "SourceBansInfo",
21
+ "WorksopInfo",
22
+ ]
@@ -0,0 +1,394 @@
1
+ """L4D2 external API client: A2S queries, SourceBans scraping, Workshop lookup.
2
+
3
+ Replaces the legacy ``shared/utils/api/request.py``. The dead
4
+ ``config.json`` override path (which always read an empty ``{}``) has been
5
+ removed; the ``url`` argument is used directly.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import asyncio
11
+ import contextlib
12
+ from copy import deepcopy
13
+ from typing import Any, Dict, List, Literal, Optional, Tuple, Union, cast
14
+
15
+ import a2s
16
+ from bs4 import BeautifulSoup, Tag
17
+ from httpx import AsyncClient
18
+ from nonebot.log import logger
19
+
20
+ from ..http_helpers import split_maohao
21
+ from .models import (
22
+ AnnePlayer2,
23
+ AnnePlayerDetail,
24
+ AnnePlayerInf,
25
+ AnnePlayerInfAvg,
26
+ AnnePlayerInfo,
27
+ AnnePlayerSur,
28
+ AnneSearch,
29
+ SourceBansInfo,
30
+ WorksopInfo,
31
+ )
32
+ from .sources import AnnePlayerApi, AnneSearchApi, WorkshopApi, anne_ban
33
+
34
+
35
+ class L4D2Api:
36
+ """All HTTP / A2S calls in one place."""
37
+
38
+ ssl_verify: bool = False
39
+
40
+ _HEADER: Dict[str, str] = { # noqa: RUF012
41
+ "User-Agent": (
42
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
43
+ "(KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0"
44
+ ),
45
+ "Content-Type": "application/x-www-form-urlencoded",
46
+ "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
47
+ }
48
+
49
+ # ---------- A2S ----------
50
+
51
+ @staticmethod
52
+ def _empty_source_info() -> a2s.SourceInfo:
53
+ return a2s.SourceInfo(
54
+ protocol=0,
55
+ server_name="服务器无响应",
56
+ map_name="无",
57
+ folder="m",
58
+ game="L4D2",
59
+ app_id=114514,
60
+ steam_id=0,
61
+ player_count=0,
62
+ max_players=0,
63
+ bot_count=0,
64
+ server_type="w",
65
+ platform="w",
66
+ password_protected=False,
67
+ vac_enabled=False,
68
+ version="1.0",
69
+ edf=0,
70
+ ping=0,
71
+ )
72
+
73
+ async def a2s_info_single(
74
+ self,
75
+ ip: Tuple[str, int],
76
+ ) -> a2s.SourceInfo[str]:
77
+ """Query a single server; fall back to empty SourceInfo on error."""
78
+ try:
79
+ return await a2s.ainfo(ip, timeout=3, encoding="utf8")
80
+ except Exception:
81
+ return self._empty_source_info()
82
+
83
+ async def a2s_info_batch(
84
+ self,
85
+ ip_list: List[Tuple[str, int]],
86
+ want_players: bool = True,
87
+ ) -> List[Tuple[a2s.SourceInfo[str], List[a2s.Player]]]:
88
+ """Query multiple servers in parallel. Order is stable by steam_id."""
89
+ if not ip_list:
90
+ return []
91
+
92
+ tasks = [
93
+ asyncio.create_task(self._a2s_one(ip, idx, want_players))
94
+ for idx, ip in enumerate(ip_list)
95
+ ]
96
+ try:
97
+ results = await asyncio.gather(*tasks)
98
+ except Exception as exc:
99
+ logger.error(f"批量 A2S 查询失败: {exc}")
100
+ results = [(self._empty_source_info(), []) for _ in ip_list]
101
+
102
+ return sorted(
103
+ results,
104
+ key=lambda pair: (
105
+ getattr(pair[0], "steam_id", float("inf")) is None,
106
+ getattr(pair[0], "steam_id", float("inf")),
107
+ ),
108
+ )
109
+
110
+ async def _a2s_one(
111
+ self,
112
+ ip: Tuple[str, int],
113
+ index: int,
114
+ want_players: bool,
115
+ ) -> Tuple[a2s.SourceInfo, List[a2s.Player]]:
116
+ server: Union[a2s.SourceInfo, a2s.GoldSrcInfo]
117
+ try:
118
+ server = await a2s.ainfo(ip, timeout=3, encoding="utf8")
119
+ if server is not None:
120
+ server.steam_id = index # type: ignore[attr-defined]
121
+ except Exception:
122
+ server = self._empty_source_info()
123
+ server.steam_id = index # type: ignore[attr-defined]
124
+ want_players = False
125
+
126
+ players: List[a2s.Player] = []
127
+ if want_players:
128
+ with contextlib.suppress(Exception):
129
+ players = await a2s.aplayers(ip, timeout=3, encoding="utf8")
130
+ return server, players
131
+
132
+ # ---------- HTTP ----------
133
+
134
+ async def _request(
135
+ self,
136
+ url: str,
137
+ method: Literal["GET", "POST"] = "GET",
138
+ params: Optional[Dict[str, Any]] = None,
139
+ json_body: Optional[Dict[str, Any] | list] = None,
140
+ data: Optional[Dict[str, Any]] = None,
141
+ expect_json: bool = True,
142
+ ) -> Union[Dict[str, Any], BeautifulSoup]: # type: ignore[return-value]
143
+ headers = deepcopy(self._HEADER)
144
+ if method == "GET" and json_body is not None:
145
+ method = "POST"
146
+
147
+ async with AsyncClient(verify=self.ssl_verify) as client:
148
+ resp = await client.request(
149
+ method,
150
+ url=url,
151
+ headers=headers,
152
+ params=params,
153
+ json=json_body,
154
+ data=data,
155
+ timeout=300,
156
+ )
157
+
158
+ if not expect_json:
159
+ return BeautifulSoup(resp.content, "lxml")
160
+
161
+ try:
162
+ raw = resp.json()
163
+ except Exception:
164
+ text = resp.text
165
+ try:
166
+ import ujson as json # type: ignore[import-not-found]
167
+
168
+ raw = json.loads(text)
169
+ except Exception:
170
+ raw = {"result": {"error_code": -999, "data": text}}
171
+
172
+ try:
173
+ if not raw.get("result"):
174
+ return raw
175
+ except Exception:
176
+ return raw
177
+
178
+ if (
179
+ "result" in raw
180
+ and isinstance(raw["result"], dict)
181
+ and "error_code" in raw["result"]
182
+ and raw.get("code") != 200
183
+ ):
184
+ return raw["result"]["error_code"]
185
+ return raw
186
+
187
+ # ---------- SourceBans ----------
188
+
189
+ async def get_sourceban(
190
+ self,
191
+ _tag: str = "云",
192
+ url: str = anne_ban,
193
+ ) -> List[SourceBansInfo]:
194
+ """Scrape a SourceBans++ page and return server info objects."""
195
+ if not url.startswith(("http://", "https://")):
196
+ url = "http://" + url
197
+ resp = await self._request(url=url, expect_json=False)
198
+ if not isinstance(resp, BeautifulSoup):
199
+ return []
200
+
201
+ servers: List[SourceBansInfo] = []
202
+ tbody = resp.select_one("tbody")
203
+ if tbody is None:
204
+ return []
205
+
206
+ for index, tr in enumerate(tbody.select("tr")):
207
+ td_tags = tr.find_all("td")
208
+ if len(td_tags) < 5:
209
+ continue
210
+ host, port = split_maohao(td_tags[4].text)
211
+ servers.append(SourceBansInfo(index=index, host=host, port=port))
212
+ return servers
213
+
214
+ # ---------- Anne (电信服) ----------
215
+
216
+ async def get_anne_steamid(self, name: str) -> Optional[List[AnneSearch]]:
217
+ """Search Anne player database by nickname."""
218
+ resp = await self._request(
219
+ url=AnneSearchApi,
220
+ data={"search": name},
221
+ method="POST",
222
+ expect_json=False,
223
+ )
224
+ if not isinstance(resp, BeautifulSoup):
225
+ return None
226
+
227
+ tbody = resp.select_one("tbody")
228
+ if tbody is None:
229
+ return None
230
+
231
+ results: List[AnneSearch] = []
232
+ for tr in tbody.select("tr"):
233
+ onclick = tr.get("onclick")
234
+ if onclick is None or isinstance(onclick, list):
235
+ continue
236
+ steamid = onclick.split("steamid=")[1].replace("'", "")
237
+ td_tags = tr.select("td")
238
+ results.append(
239
+ {
240
+ "steamid": steamid,
241
+ "rank": td_tags[0].text.strip(),
242
+ "name": td_tags[1].text.strip(),
243
+ "score": td_tags[2].text.strip(),
244
+ "play_time": td_tags[3].text.strip(),
245
+ "last_time": td_tags,
246
+ },
247
+ )
248
+ logger.debug(results)
249
+ return results
250
+
251
+ async def get_anne_playerdetail(self, steamid: str) -> Optional[AnnePlayer2]:
252
+ """Fetch Anne player details by steamid."""
253
+ resp = await self._request(
254
+ url=AnnePlayerApi,
255
+ method="GET",
256
+ params={"steamid": steamid},
257
+ expect_json=False,
258
+ )
259
+ if not isinstance(resp, BeautifulSoup):
260
+ return None
261
+
262
+ tbody = resp.find(
263
+ "div",
264
+ class_="content text-center text-md-left",
265
+ style="background-color: #f2f2f2;",
266
+ )
267
+ if tbody is None:
268
+ return None
269
+
270
+ if not isinstance(tbody, Tag):
271
+ return None
272
+
273
+ kill_tag = tbody.find(
274
+ "div",
275
+ class_="card-body worldmap d-flex flex-column justify-content-center text-center",
276
+ )
277
+
278
+ tbody_tags = tbody.find_all(
279
+ "table",
280
+ class_="table content-table-noborder text-left",
281
+ )
282
+ if len(tbody_tags) < 6:
283
+ return None
284
+
285
+ def get_table_dict(table, keys):
286
+ trs = table.select("tr")
287
+ return {
288
+ key: trs[i].select("td")[1].text.strip() for i, key in enumerate(keys)
289
+ }
290
+
291
+ info_keys = ["name", "avatar", "steamid", "playtime", "lasttime"]
292
+ detail_keys = [
293
+ "rank",
294
+ "source",
295
+ "avg_source",
296
+ "kills",
297
+ "kills_people",
298
+ "headshots",
299
+ "avg_headshots",
300
+ "map_play",
301
+ ]
302
+ error_keys = [
303
+ "mistake_shout",
304
+ "kill_friend",
305
+ "down_friend",
306
+ "abandon_friend",
307
+ "put_into",
308
+ "agitate_witch",
309
+ ]
310
+ inf_avg_keys = [
311
+ "avg_smoker",
312
+ "avg_boomer",
313
+ "avg_hunter",
314
+ "avg_charger",
315
+ "avg_spitter",
316
+ "avg_jockey",
317
+ "avg_tank",
318
+ ]
319
+ sur_keys = [
320
+ "map_clear",
321
+ "prefect_into",
322
+ "get_oil",
323
+ "ammo_arrange",
324
+ "adrenaline_give",
325
+ "pills_give",
326
+ "first_aid_give",
327
+ "friend_up",
328
+ "diss_friend",
329
+ "save_friend",
330
+ "protect_friend",
331
+ "pro_from_smoker",
332
+ "pro_from_hunter",
333
+ "pro_from_charger",
334
+ "pro_from_jockey",
335
+ "melee_charge",
336
+ "tank_kill",
337
+ "witch_instantly_kill",
338
+ ]
339
+ inf_keys = [
340
+ "sur_ace",
341
+ "sur_down",
342
+ "boommer_hit",
343
+ "hunter_prefect",
344
+ "hunter_success",
345
+ "tank_damage",
346
+ "charger_multiple",
347
+ ]
348
+
349
+ info_dict = get_table_dict(tbody_tags[0], info_keys)
350
+ detail_dict = get_table_dict(tbody_tags[1], detail_keys)
351
+ error_dict = get_table_dict(tbody_tags[2], error_keys)
352
+ inf_avg_dict = get_table_dict(tbody_tags[3], inf_avg_keys)
353
+ sur_dict = get_table_dict(tbody_tags[4], sur_keys)
354
+ inf_dict = get_table_dict(tbody_tags[5], inf_keys)
355
+
356
+ return cast(
357
+ AnnePlayer2,
358
+ {
359
+ "kill_msg": kill_tag.text.strip() if kill_tag else "",
360
+ "info": cast(AnnePlayerInfo, info_dict),
361
+ "detail": cast(AnnePlayerDetail, detail_dict),
362
+ "inf_avg": cast(AnnePlayerInfAvg, inf_avg_dict),
363
+ "sur": cast(AnnePlayerSur, sur_dict),
364
+ "inf": cast(AnnePlayerInf, inf_dict),
365
+ "error": error_dict,
366
+ },
367
+ )
368
+
369
+ # ---------- Steam Workshop ----------
370
+
371
+ async def workshops(self, workshop_id: str) -> WorksopInfo:
372
+ """Fetch Workshop item details by id."""
373
+ resp = await self._request(
374
+ url=WorkshopApi,
375
+ method="POST",
376
+ json_body=[int(workshop_id)],
377
+ expect_json=True,
378
+ )
379
+ if not isinstance(resp, dict):
380
+ raise TypeError("请求创意工坊失败")
381
+
382
+ if (
383
+ "result" in resp
384
+ and isinstance(resp["result"], list)
385
+ and len(resp["result"]) > 0
386
+ ):
387
+ return cast(WorksopInfo, resp["result"][0])
388
+ if len(resp) > 0:
389
+ return cast(WorksopInfo, resp)
390
+ raise ValueError("没有找到创意工坊内容")
391
+
392
+
393
+ # Module-level singleton.
394
+ L4API = L4D2Api()