nonebot-plugin-l4d2-server 0.6.6__py3-none-any.whl → 1.0.0a1__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 (186) hide show
  1. nonebot_plugin_l4d2_server/__init__.py +9 -92
  2. nonebot_plugin_l4d2_server/__main__.py +90 -0
  3. nonebot_plugin_l4d2_server/config.py +30 -0
  4. nonebot_plugin_l4d2_server/data/L4D2/image/head/head.png +0 -0
  5. nonebot_plugin_l4d2_server/data/L4D2/image/header/logo.png +0 -0
  6. nonebot_plugin_l4d2_server/data/L4D2/image/header/player1.jpg +0 -0
  7. nonebot_plugin_l4d2_server/data/L4D2/image/template/anne.html +50 -42
  8. nonebot_plugin_l4d2_server/data/L4D2/image/template/back.png +0 -0
  9. nonebot_plugin_l4d2_server/data/L4D2/image/template/group_ip.html +1 -2
  10. nonebot_plugin_l4d2_server/data/L4D2/image/template/help.html +1 -2
  11. nonebot_plugin_l4d2_server/data/L4D2/image/template/help_dack.html +259 -221
  12. nonebot_plugin_l4d2_server/data/L4D2/image/template/ip.html +1 -2
  13. nonebot_plugin_l4d2_server/data/font/loli.ttf +0 -0
  14. nonebot_plugin_l4d2_server/data/icon//344/273/213/347/273/215.png +0 -0
  15. nonebot_plugin_l4d2_server/data/icon//344/273/273/345/212/241.png +0 -0
  16. nonebot_plugin_l4d2_server/data/icon//344/277/241/346/201/257.png +0 -0
  17. nonebot_plugin_l4d2_server/data/icon//345/205/254/345/221/212.png +0 -0
  18. nonebot_plugin_l4d2_server/data/icon//345/210/200/345/211/221.png +0 -0
  19. nonebot_plugin_l4d2_server/data/icon//345/210/207/346/215/242.png +0 -0
  20. nonebot_plugin_l4d2_server/data/icon//345/210/240/351/231/244.png +0 -0
  21. nonebot_plugin_l4d2_server/data/icon//345/210/267/346/226/260.png +0 -0
  22. nonebot_plugin_l4d2_server/data/icon//345/215/241/347/273/204.png +0 -0
  23. nonebot_plugin_l4d2_server/data/icon//345/223/252/351/207/214.png +0 -0
  24. nonebot_plugin_l4d2_server/data/icon//345/234/260/345/233/276.png +0 -0
  25. nonebot_plugin_l4d2_server/data/icon//345/257/274/345/205/245.png +0 -0
  26. nonebot_plugin_l4d2_server/data/icon//345/257/274/345/207/272.png +0 -0
  27. nonebot_plugin_l4d2_server/data/icon//345/275/261.png +0 -0
  28. nonebot_plugin_l4d2_server/data/icon//346/213/274/345/233/276.png +0 -0
  29. nonebot_plugin_l4d2_server/data/icon//346/216/242/347/264/242.png +0 -0
  30. nonebot_plugin_l4d2_server/data/icon//346/216/250/351/200/201.png +0 -0
  31. nonebot_plugin_l4d2_server/data/icon//346/224/266/351/233/206.png +0 -0
  32. nonebot_plugin_l4d2_server/data/icon//346/224/273/347/225/245.png +0 -0
  33. nonebot_plugin_l4d2_server/data/icon//346/233/264/346/226/260.png +0 -0
  34. nonebot_plugin_l4d2_server/data/icon//346/235/220/346/226/231.png +0 -0
  35. nonebot_plugin_l4d2_server/data/icon//346/237/245/350/257/242.png +0 -0
  36. nonebot_plugin_l4d2_server/data/icon//346/240/241/351/252/214.png +0 -0
  37. nonebot_plugin_l4d2_server/data/icon//346/257/217/346/234/210.png +0 -0
  38. nonebot_plugin_l4d2_server/data/icon//346/267/261/346/270/212.png +0 -0
  39. nonebot_plugin_l4d2_server/data/icon//346/267/273/345/212/240.png +0 -0
  40. nonebot_plugin_l4d2_server/data/icon//346/270/205/351/231/244.png +0 -0
  41. nonebot_plugin_l4d2_server/data/icon//347/212/266/346/200/201.png +0 -0
  42. nonebot_plugin_l4d2_server/data/icon//347/255/276/345/210/260.png +0 -0
  43. nonebot_plugin_l4d2_server/data/icon//347/273/221/345/256/232.png +0 -0
  44. nonebot_plugin_l4d2_server/data/icon//350/241/250.png +0 -0
  45. nonebot_plugin_l4d2_server/data/icon//350/241/250/346/203/205.png +0 -0
  46. nonebot_plugin_l4d2_server/data/icon//350/247/222/350/211/262.png +0 -0
  47. nonebot_plugin_l4d2_server/data/icon//350/256/260/345/275/225.png +0 -0
  48. nonebot_plugin_l4d2_server/data/icon//351/205/215/347/275/256.png +0 -0
  49. nonebot_plugin_l4d2_server/data/icon//351/207/215/345/220/257.png +0 -0
  50. nonebot_plugin_l4d2_server/data/img/l4d2.png +0 -0
  51. nonebot_plugin_l4d2_server/data/img/linux.png +0 -0
  52. nonebot_plugin_l4d2_server/data/img/vac.png +0 -0
  53. nonebot_plugin_l4d2_server/data/img/white.png +0 -0
  54. nonebot_plugin_l4d2_server/l4_help/Help.json +65 -0
  55. nonebot_plugin_l4d2_server/l4_help/__init__.py +57 -0
  56. nonebot_plugin_l4d2_server/l4_help/draw.py +206 -0
  57. nonebot_plugin_l4d2_server/l4_help/icon//344/273/213/347/273/215.png +0 -0
  58. nonebot_plugin_l4d2_server/l4_help/icon//344/273/273/345/212/241.png +0 -0
  59. nonebot_plugin_l4d2_server/l4_help/icon//344/277/241/346/201/257.png +0 -0
  60. nonebot_plugin_l4d2_server/l4_help/icon//345/205/254/345/221/212.png +0 -0
  61. nonebot_plugin_l4d2_server/l4_help/icon//345/210/200/345/211/221.png +0 -0
  62. nonebot_plugin_l4d2_server/l4_help/icon//345/210/207/346/215/242.png +0 -0
  63. nonebot_plugin_l4d2_server/l4_help/icon//345/210/240/351/231/244.png +0 -0
  64. nonebot_plugin_l4d2_server/l4_help/icon//345/210/267/346/226/260.png +0 -0
  65. nonebot_plugin_l4d2_server/l4_help/icon//345/215/241/347/273/204.png +0 -0
  66. nonebot_plugin_l4d2_server/l4_help/icon//345/223/252/351/207/214.png +0 -0
  67. nonebot_plugin_l4d2_server/l4_help/icon//345/234/260/345/233/276.png +0 -0
  68. nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/205/245.png +0 -0
  69. nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/207/272.png +0 -0
  70. nonebot_plugin_l4d2_server/l4_help/icon//345/275/261.png +0 -0
  71. nonebot_plugin_l4d2_server/l4_help/icon//346/213/274/345/233/276.png +0 -0
  72. nonebot_plugin_l4d2_server/l4_help/icon//346/216/242/347/264/242.png +0 -0
  73. nonebot_plugin_l4d2_server/l4_help/icon//346/216/250/351/200/201.png +0 -0
  74. nonebot_plugin_l4d2_server/l4_help/icon//346/224/266/351/233/206.png +0 -0
  75. nonebot_plugin_l4d2_server/l4_help/icon//346/224/273/347/225/245.png +0 -0
  76. nonebot_plugin_l4d2_server/l4_help/icon//346/233/264/346/226/260.png +0 -0
  77. nonebot_plugin_l4d2_server/l4_help/icon//346/235/220/346/226/231.png +0 -0
  78. nonebot_plugin_l4d2_server/l4_help/icon//346/237/245/350/257/242.png +0 -0
  79. nonebot_plugin_l4d2_server/l4_help/icon//346/240/241/351/252/214.png +0 -0
  80. nonebot_plugin_l4d2_server/l4_help/icon//346/257/217/346/234/210.png +0 -0
  81. nonebot_plugin_l4d2_server/l4_help/icon//346/267/261/346/270/212.png +0 -0
  82. nonebot_plugin_l4d2_server/l4_help/icon//346/267/273/345/212/240.png +0 -0
  83. nonebot_plugin_l4d2_server/l4_help/icon//346/270/205/351/231/244.png +0 -0
  84. nonebot_plugin_l4d2_server/l4_help/icon//347/212/266/346/200/201.png +0 -0
  85. nonebot_plugin_l4d2_server/l4_help/icon//347/255/276/345/210/260.png +0 -0
  86. nonebot_plugin_l4d2_server/l4_help/icon//347/273/221/345/256/232.png +0 -0
  87. nonebot_plugin_l4d2_server/l4_help/icon//350/241/250.png +0 -0
  88. nonebot_plugin_l4d2_server/l4_help/icon//350/241/250/346/203/205.png +0 -0
  89. nonebot_plugin_l4d2_server/l4_help/icon//350/247/222/350/211/262.png +0 -0
  90. nonebot_plugin_l4d2_server/l4_help/icon//350/256/260/345/275/225.png +0 -0
  91. nonebot_plugin_l4d2_server/l4_help/icon//351/205/215/347/275/256.png +0 -0
  92. nonebot_plugin_l4d2_server/l4_help/icon//351/207/215/345/220/257.png +0 -0
  93. nonebot_plugin_l4d2_server/l4_help/texture2d/badge.png +0 -0
  94. nonebot_plugin_l4d2_server/l4_help/texture2d/banner.png +0 -0
  95. nonebot_plugin_l4d2_server/l4_help/texture2d/bg.jpg +0 -0
  96. nonebot_plugin_l4d2_server/l4_help/texture2d/button.png +0 -0
  97. nonebot_plugin_l4d2_server/l4_help/texture2d/icon.png +0 -0
  98. nonebot_plugin_l4d2_server/l4_image/__init__.py +16 -0
  99. nonebot_plugin_l4d2_server/l4_image/convert.py +175 -0
  100. nonebot_plugin_l4d2_server/{l4d2_image → l4_image}/download.py +6 -30
  101. nonebot_plugin_l4d2_server/{l4d2_image/__init__.py → l4_image/html_img.py} +54 -45
  102. nonebot_plugin_l4d2_server/l4_image/image_tools.py +468 -0
  103. nonebot_plugin_l4d2_server/l4_image/img/anne/anne.html +60 -0
  104. nonebot_plugin_l4d2_server/l4_image/img/anne/back.png +0 -0
  105. nonebot_plugin_l4d2_server/l4_image/img/anne/group_ip.html +259 -0
  106. nonebot_plugin_l4d2_server/l4_image/img/anne/ip.html +55 -0
  107. nonebot_plugin_l4d2_server/l4_image/img/head/head.png +0 -0
  108. nonebot_plugin_l4d2_server/l4_image/img/header/logo.png +0 -0
  109. nonebot_plugin_l4d2_server/l4_image/img/header/player1.jpg +0 -0
  110. nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.html +312 -0
  111. nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.png +0 -0
  112. nonebot_plugin_l4d2_server/l4_image/img/template/HYPixel11pxU-2.ttf +0 -0
  113. nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.html +350 -0
  114. nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.png +0 -0
  115. nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.html +321 -0
  116. nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.png +0 -0
  117. nonebot_plugin_l4d2_server/l4_image/img/template/Tutumianhuatang-Bold-2.ttf +0 -0
  118. nonebot_plugin_l4d2_server/l4_image/img/template/bilibili.svg +1 -0
  119. nonebot_plugin_l4d2_server/l4_image/img/template/fingerprint.svg +15 -0
  120. nonebot_plugin_l4d2_server/l4_image/img/template/github.svg +1 -0
  121. nonebot_plugin_l4d2_server/l4_image/img/template/l.svg +9 -0
  122. nonebot_plugin_l4d2_server/l4_image/img/template/m.svg +1 -0
  123. nonebot_plugin_l4d2_server/l4_image/img/template/normal.html +257 -0
  124. nonebot_plugin_l4d2_server/l4_image/img/template/vue.css +531 -0
  125. nonebot_plugin_l4d2_server/l4_image/img/template/w.svg +1 -0
  126. nonebot_plugin_l4d2_server/l4_image/img/template//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
  127. nonebot_plugin_l4d2_server/l4_image/model.py +15 -0
  128. nonebot_plugin_l4d2_server/{l4d2_image → l4_image}/vtfs.py +2 -0
  129. nonebot_plugin_l4d2_server/l4_request/__init__.py +84 -0
  130. nonebot_plugin_l4d2_server/l4_request/draw_msg.py +88 -0
  131. nonebot_plugin_l4d2_server/utils/api/api.py +4 -0
  132. nonebot_plugin_l4d2_server/utils/api/models.py +29 -0
  133. nonebot_plugin_l4d2_server/utils/api/request.py +119 -0
  134. nonebot_plugin_l4d2_server/utils/database/models.py +29 -0
  135. nonebot_plugin_l4d2_server/{l4d2_utils → utils}/utils.py +52 -55
  136. {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a1.dist-info}/METADATA +47 -64
  137. nonebot_plugin_l4d2_server-1.0.0a1.dist-info/RECORD +144 -0
  138. {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a1.dist-info}/WHEEL +1 -1
  139. nonebot_plugin_l4d2_server/l4d2_anne/__init__.py +0 -95
  140. nonebot_plugin_l4d2_server/l4d2_anne/analysis.py +0 -54
  141. nonebot_plugin_l4d2_server/l4d2_anne/anne_telecom.py +0 -79
  142. nonebot_plugin_l4d2_server/l4d2_anne/server.py +0 -47
  143. nonebot_plugin_l4d2_server/l4d2_anne/startand.py +0 -17
  144. nonebot_plugin_l4d2_server/l4d2_anne/utils.py +0 -294
  145. nonebot_plugin_l4d2_server/l4d2_data/__init__.py +0 -105
  146. nonebot_plugin_l4d2_server/l4d2_data/config.py +0 -18
  147. nonebot_plugin_l4d2_server/l4d2_data/database.py +0 -0
  148. nonebot_plugin_l4d2_server/l4d2_data/players.py +0 -100
  149. nonebot_plugin_l4d2_server/l4d2_data/serverip.py +0 -40
  150. nonebot_plugin_l4d2_server/l4d2_file/__init__.py +0 -222
  151. nonebot_plugin_l4d2_server/l4d2_file/ayromote.py +0 -64
  152. nonebot_plugin_l4d2_server/l4d2_file/input_json.py +0 -77
  153. nonebot_plugin_l4d2_server/l4d2_file/remote.py +0 -86
  154. nonebot_plugin_l4d2_server/l4d2_file/utils.py +0 -104
  155. nonebot_plugin_l4d2_server/l4d2_image/htmlimg.py +0 -18
  156. nonebot_plugin_l4d2_server/l4d2_image/images.py +0 -92
  157. nonebot_plugin_l4d2_server/l4d2_image/one.py +0 -44
  158. nonebot_plugin_l4d2_server/l4d2_image/send_image_tool.py +0 -32
  159. nonebot_plugin_l4d2_server/l4d2_image/steam.py +0 -63
  160. nonebot_plugin_l4d2_server/l4d2_push/__init__.py +0 -225
  161. nonebot_plugin_l4d2_server/l4d2_queries/__init__.py +0 -326
  162. nonebot_plugin_l4d2_server/l4d2_queries/himi.py +0 -113
  163. nonebot_plugin_l4d2_server/l4d2_queries/local_ip.py +0 -41
  164. nonebot_plugin_l4d2_server/l4d2_queries/qqgroup.py +0 -370
  165. nonebot_plugin_l4d2_server/l4d2_queries/send_msg.py +0 -131
  166. nonebot_plugin_l4d2_server/l4d2_queries/utils.py +0 -212
  167. nonebot_plugin_l4d2_server/l4d2_server/__init__.py +0 -118
  168. nonebot_plugin_l4d2_server/l4d2_server/index.py +0 -0
  169. nonebot_plugin_l4d2_server/l4d2_server/rcon.py +0 -53
  170. nonebot_plugin_l4d2_server/l4d2_server/workshop.py +0 -82
  171. nonebot_plugin_l4d2_server/l4d2_update/__init__.py +0 -137
  172. nonebot_plugin_l4d2_server/l4d2_update/draw_update_log.py +0 -45
  173. nonebot_plugin_l4d2_server/l4d2_update/restart.py +0 -69
  174. nonebot_plugin_l4d2_server/l4d2_update/update.py +0 -53
  175. nonebot_plugin_l4d2_server/l4d2_utils/classcal.py +0 -53
  176. nonebot_plugin_l4d2_server/l4d2_utils/command.py +0 -23
  177. nonebot_plugin_l4d2_server/l4d2_utils/config.py +0 -201
  178. nonebot_plugin_l4d2_server/l4d2_utils/message.py +0 -59
  179. nonebot_plugin_l4d2_server/l4d2_utils/rule.py +0 -35
  180. nonebot_plugin_l4d2_server/l4d2_utils/seach.py +0 -43
  181. nonebot_plugin_l4d2_server/l4d2_utils/txt_to_img.py +0 -32
  182. nonebot_plugin_l4d2_server/l4d2_web/web.py +0 -277
  183. nonebot_plugin_l4d2_server/l4d2_web/webUI.py +0 -506
  184. nonebot_plugin_l4d2_server/l4d2_web/webUI_s.py +0 -94
  185. nonebot_plugin_l4d2_server-0.6.6.dist-info/RECORD +0 -70
  186. {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a1.dist-info}/licenses/LICENSE +0 -0
@@ -1,18 +0,0 @@
1
- # from pathlib import Path
2
- # import yaml
3
-
4
- # DATABASE = Path() / "data" / "L4D2"
5
- # class L4D2Config:
6
-
7
- # def __init__(self):
8
- # self.config_yaml = "config.yaml"
9
- # config_data = self._config_data()
10
-
11
- # self
12
-
13
- # def _config_data(self):
14
- # """配置数据"""
15
- # with open(self.config_yaml, 'r', encoding='utf-8') as e:
16
- # a = e.read()
17
- # data = yaml.safe_load(a)
18
- # return data
File without changes
@@ -1,100 +0,0 @@
1
- import sqlite3
2
- from typing import List, Optional, Tuple, Union
3
-
4
- from ..l4d2_utils.config import DATASQLITE
5
-
6
-
7
- class L4D2Player:
8
- """数据库L4D2_Player表的操作"""
9
-
10
- def __init__(self):
11
- """连接数据库"""
12
- self.datasqlite_path = DATASQLITE
13
- self.conn = sqlite3.connect(self.datasqlite_path / "L4D2.db")
14
- self.c = self.conn.cursor()
15
-
16
- async def _add_player_nickname(self, qq, nickname):
17
- """绑定昵称"""
18
- # try:
19
- self.c.execute(
20
- "INSERT INTO L4d2_players (qq, nickname, steamid) VALUES (?,?,NULL)",
21
- (qq, nickname),
22
- )
23
- self.conn.commit()
24
- # return True
25
- # except sqlite3.IntegrityError:
26
- # return False
27
-
28
- async def _add_player_steamid(self, qq, steamid):
29
- """绑定steamid"""
30
- self.c.execute(
31
- "INSERT INTO L4d2_players (qq, nickname, steamid) VALUES (?,NULL,?)",
32
- (qq, steamid),
33
- )
34
- self.conn.commit()
35
-
36
- async def add_player_all(self, qq, nickname, steamid):
37
- """用新数据覆盖旧数据"""
38
- # try:
39
- self.c.execute(
40
- "INSERT OR REPLACE INTO L4d2_players (qq, nickname, steamid) VALUES (?,?,?)", # noqa: E501
41
- (qq, nickname, steamid),
42
- )
43
- self.conn.commit()
44
- return True
45
- # except sqlite3.IntegrityError:
46
- # return False
47
-
48
- def delete_player(self, qq):
49
- """解除绑定"""
50
- self.c.execute(f"DELETE FROM L4d2_players WHERE qq = {qq}")
51
- self.conn.commit()
52
- return True
53
-
54
- def query_player_qq(self, qq) -> Union[tuple, None]:
55
- """通过qq获取数据"""
56
- self.c.execute(f"SELECT * FROM L4d2_players WHERE qq = '{qq}'")
57
- return self.c.fetchone()
58
-
59
- async def _query_player_nickname(self, nickname: str) -> Union[tuple, None]:
60
- """通过nickname获取数据"""
61
- self.c.execute(f"SELECT * FROM L4d2_players WHERE nickname = '{nickname}'")
62
- return self.c.fetchone()
63
-
64
- async def _query_player_steamid(self, steamid: str):
65
- """通过steamid获取数据"""
66
- self.c.execute(f"SELECT * FROM L4d2_players WHERE steamid = '{steamid}'")
67
- return self.c.fetchone()
68
-
69
- async def search_data(
70
- self,
71
- qq: Optional[str],
72
- nickname: Optional[str],
73
- steamid: Optional[str],
74
- ) -> Union[tuple, None]:
75
- """
76
- 输入元组查询,优先qq其次steamid最后nickname,不需要值可以为None
77
- 输出为元组,如果为空输出None
78
- data = (qq , nickname , steamid )
79
- """
80
- if qq:
81
- self.c.execute("SELECT * FROM L4d2_players WHERE qq=?", (qq,))
82
- result = self.c.fetchone()
83
- if result:
84
- return result
85
- if steamid:
86
- self.c.execute("SELECT * FROM L4d2_players WHERE steamid=?", (steamid,))
87
- result = self.c.fetchone()
88
- if result:
89
- return result
90
- if nickname:
91
- self.c.execute("SELECT * FROM L4d2_players WHERE nickname=?", (nickname,))
92
- result = self.c.fetchone()
93
- if result:
94
- return result
95
- return None
96
-
97
- def _query_all_player(self) -> List[Tuple]:
98
- """获取所有玩家信息"""
99
- self.c.execute("SELECT * FROM L4d2_players")
100
- return self.c.fetchall()
@@ -1,40 +0,0 @@
1
- import sqlite3
2
-
3
- from ..l4d2_utils.config import DATASQLITE
4
-
5
-
6
- class L4D2Server:
7
- """数据库L4D2_server表的操作"""
8
-
9
- def __init__(self):
10
- """连接数据库"""
11
- self.datasqlite_path = DATASQLITE
12
- self.conn = sqlite3.connect(self.datasqlite_path / "L4D2.db")
13
- self.c = self.conn.cursor()
14
-
15
- async def bind_server_ip(self, qqgroup, host, port):
16
- """绑定群订阅ip"""
17
- self.c.execute(
18
- "INSERT OR REPLACE INTO L4D2_server (qqgroup, host, port) VALUES (?,?,?)",
19
- (qqgroup, host, port),
20
- )
21
- self.conn.commit()
22
-
23
- async def query_server_ip(self, qqgroup):
24
- """输入群号,返回数据库里订阅ip元组列表"""
25
- self.c.execute(
26
- f"SELECT number, qqgroup ,host ,port FROM L4D2_server WHERE qqgroup = {qqgroup}",
27
- )
28
- return self.c.fetchall()
29
-
30
- async def del_server_ip(self, id_: int):
31
- """删除指定id的ip"""
32
- self.c.execute(f"DELETE FROM L4D2_server WHERE number = {id_}")
33
- self.conn.commit()
34
-
35
- async def query_number(self, number: int):
36
- """通过序号找服务器"""
37
- self.c.execute(
38
- f"SELECT qqgroup , host ,port FROM L4D2_server WHERE number = {number}",
39
- )
40
- return self.c.fetchone()
@@ -1,222 +0,0 @@
1
- import re
2
- from pathlib import Path
3
- from typing import Tuple
4
-
5
- from nonebot import on_command, on_regex
6
- from nonebot.adapters.onebot.v11 import Event, Message, NoticeEvent
7
- from nonebot.log import logger
8
- from nonebot.matcher import Matcher
9
- from nonebot.params import ArgPlainText, CommandArg, RegexGroup
10
-
11
- # from nonebot.typing import T_State
12
- from ..l4d2_utils.config import MASTER, config_manager, file_format, l4_config, vpk_path
13
- from ..l4d2_utils.rule import wenjian
14
- from ..l4d2_utils.txt_to_img import mode_txt_to_img
15
- from ..l4d2_utils.utils import del_map, get_vpk, mes_list, rename_map
16
- from .input_json import upload # noqa: F401
17
- from .utils import updown_l4d2_vpk
18
-
19
- up = on_command(
20
- "l4_upload",
21
- aliases={"l4地图上传"},
22
- priority=20,
23
- block=True,
24
- )
25
-
26
-
27
- rename_vpk = on_regex(
28
- r"^l4地图\s*(\S+.*?)\s*(改|改名)?\s*(\S+.*?)\s*$",
29
- flags=re.S,
30
- block=True,
31
- priority=20,
32
- permission=MASTER,
33
- )
34
-
35
- find_vpk = on_command("l4_map", aliases={"l4地图"}, priority=25, block=True)
36
- del_vpk = on_command(
37
- "l4_del_map",
38
- aliases={"l4地图删除", "地图删除"},
39
- priority=20,
40
- permission=MASTER,
41
- )
42
-
43
-
44
- check_path = on_command(
45
- "l4_check",
46
- aliases={"l4路径"},
47
- priority=20,
48
- block=True,
49
- permission=MASTER,
50
- )
51
- smx_file = on_command(
52
- "l4_smx",
53
- aliases={"l4插件"},
54
- priority=20,
55
- block=True,
56
- permission=MASTER,
57
- )
58
-
59
-
60
- @up.handle()
61
- async def _(): ...
62
-
63
-
64
- @up.got("map_url", prompt="图来")
65
- async def _(matcher: Matcher, event: Event):
66
- if not isinstance(event, NoticeEvent) or not wenjian(event):
67
- await matcher.finish("未检测到地图")
68
- return
69
- args = event.dict()
70
- if args["notice_type"] != "offline_file":
71
- matcher.set_arg("txt", args) # type: ignore
72
- return
73
- l4_file_path = l4_config.l4_ipall[l4_config.l4_number]["location"]
74
- map_path = Path(l4_file_path, vpk_path) # type: ignore
75
- # 检查下载路径是否存在
76
- if not Path(l4_file_path).exists(): # type: ignore
77
- await matcher.finish("你填写的路径不存在辣")
78
- if not Path(map_path).exists():
79
- await matcher.finish("这个路径并不是求生服务器的路径,请再看看罢")
80
- url: str = args["file"]["url"]
81
- name: str = args["file"]["name"]
82
- # 如果不符合格式则忽略
83
- await up.send("已收到文件,开始下载")
84
- vpk_files = await updown_l4d2_vpk(map_path, name, url)
85
- if vpk_files:
86
- mes = "解压成功,新增以下几个vpk文件"
87
- await matcher.finish(mes_list(mes, vpk_files))
88
- else:
89
- await matcher.finish("你可能上传了相同的文件,或者解压失败了捏")
90
-
91
-
92
- path_list: str = "请选择上传位置(输入阿拉伯数字)"
93
- times = 0
94
- for one_path in l4_config.l4_ipall:
95
- times += 1
96
- path_msg = one_path["location"]
97
- path_list += f"\n {times!s} | {path_msg}"
98
-
99
-
100
- @up.got("is_sure", prompt=path_list)
101
- async def _(matcher: Matcher):
102
- args = matcher.get_arg("txt")
103
- l4_file = l4_config.l4_ipall
104
- if args is None:
105
- await matcher.finish("获取文件出错辣,再试一次吧")
106
- return
107
-
108
- is_sure = str(matcher.get_arg("is_sure")).strip()
109
- if not is_sure.isdigit():
110
- await matcher.finish("已取消上传")
111
-
112
- file_path: str = ""
113
- for one_server in l4_file:
114
- if one_server["id_rank"] == is_sure:
115
- file_path = one_server["location"]
116
- if not file_path:
117
- await matcher.finish("没有这个序号拉baka")
118
-
119
- map_path = Path(file_path, vpk_path)
120
-
121
- # 检查下载路径是否存在
122
- if not Path(file_path).exists():
123
- await matcher.finish("你填写的路径不存在辣")
124
- if not map_path.exists():
125
- await matcher.finish("这个路径并不是求生服务器的路径,请再看看罢")
126
-
127
- url = args["file"]["url"]
128
- name = args["file"]["name"]
129
- # 如果不符合格式则忽略
130
- if not name.endswith(file_format): # type: ignore
131
- return
132
-
133
- await matcher.send("已收到文件,开始下载")
134
- vpk_files = await updown_l4d2_vpk(map_path, name, url) # type: ignore
135
-
136
- if vpk_files:
137
- logger.info("检查到新增文件")
138
- mes = "解压成功,新增以下几个vpk文件"
139
- elif vpk_files is None:
140
- await matcher.finish("文件错误")
141
- return
142
- else:
143
- mes = "你可能上传了相同的文件,或者解压失败了捏"
144
-
145
- await matcher.finish(mes_list(mes, vpk_files))
146
-
147
-
148
- @find_vpk.handle()
149
- async def _():
150
- map_path = Path(l4_config.l4_ipall[l4_config.l4_number]["location"], vpk_path)
151
- name_vpk = get_vpk(map_path)
152
- logger.info("获取文件列表成功")
153
- mes = "当前服务器下有以下vpk文件"
154
- msg = mes_list("", name_vpk).replace(" ", "")
155
-
156
- await mode_txt_to_img(mes, msg)
157
-
158
-
159
- @del_vpk.handle()
160
- async def _(matcher: Matcher, args: Message = CommandArg()):
161
- num1 = args.extract_plain_text()
162
- if num1:
163
- matcher.set_arg("num", args)
164
-
165
-
166
- @del_vpk.got("num", prompt="你要删除第几个序号的地图(阿拉伯数字)")
167
- async def _(matcher: Matcher, tag: str = ArgPlainText("num")):
168
- map_path = Path(l4_config.l4_ipall[l4_config.l4_number]["location"], vpk_path)
169
- vpk_name = del_map(int(tag), map_path)
170
- await matcher.finish("已删除地图:" + vpk_name)
171
-
172
-
173
- @rename_vpk.handle()
174
- async def _(
175
- matcher: Matcher,
176
- matched: Tuple[int, str, str] = RegexGroup(),
177
- ):
178
- num, useless, rename = matched
179
- map_path = Path(l4_config.l4_ipall[l4_config.l4_number]["location"], vpk_path)
180
- logger.info("检查是否名字是.vpk后缀")
181
- if not rename.endswith(".vpk"):
182
- rename = rename + ".vpk"
183
- logger.info("尝试改名")
184
- try:
185
- map_name = rename_map(num, rename, map_path)
186
- if map_name:
187
- await matcher.finish("改名成功\n原名:" + map_name + "\n新名称:" + rename)
188
- except ValueError:
189
- await matcher.finish("参数错误,输入【求生地图】获取全部名称")
190
-
191
-
192
- @check_path.handle()
193
- async def _(matcher: Matcher, args: Message = CommandArg()):
194
- msg = args.extract_plain_text()
195
- if msg.startswith("切换"):
196
- msg_number = int("".join(msg.replace("切换", " ").split()))
197
- if msg_number > len(l4_config.l4_ipall) or msg_number < 0:
198
- await matcher.send("没有这个序号的路径呐")
199
- else:
200
- l4_config.l4_number = msg_number - 1
201
- now_path = l4_config.l4_ipall[l4_config.l4_number]["location"]
202
- await matcher.send(
203
- f"已经切换路径为\n{l4_config.l4_number+1!s}、{now_path}",
204
- ) # noqa: E501
205
- config_manager.save()
206
- else:
207
- now_path = l4_config.l4_ipall[l4_config.l4_number]["location"]
208
- await matcher.send(f"当前的路径为\n{l4_config.l4_number+1!s}、{now_path}")
209
-
210
-
211
- @smx_file.handle()
212
- async def _():
213
- smx_path = Path(
214
- l4_config.l4_ipall[l4_config.l4_number]["location"],
215
- "left4dead2/addons/sourcemod/plugins",
216
- )
217
- name_smx = get_vpk(smx_path, file_=".smx")
218
- logger.info("获取文件列表成功")
219
- mes = "当前服务器下有以下smx文件"
220
- msg = ""
221
- msg = mes_list(msg, name_smx).replace(" ", "")
222
- await mode_txt_to_img(mes, msg)
@@ -1,64 +0,0 @@
1
- # import asyncio
2
- # import asyncssh
3
-
4
-
5
- # class AsyncSSHClient:
6
- # def __init__(self, host, port, username, password=None, private_key=None):
7
- # self.host = host
8
- # self.port = port
9
- # self.username = username
10
- # self.password = password
11
- # self.private_key = private_key
12
-
13
- # async def connect(self):
14
- # if self.private_key is not None:
15
- # try:
16
- # key = asyncssh.read_private_key(self.private_key)
17
- # except asyncssh.Error as exc:
18
- # raise ValueError(f"Unable to read private key: {exc}")
19
- # else:
20
- # key = None
21
-
22
- # self.conn = await asyncssh.connect(
23
- # self.host,
24
- # self.port,
25
- # username=self.username,
26
- # password=self.password,
27
- # client_keys=key,
28
- # )
29
-
30
- # async def upload(self, local_path, remote_path):
31
- # async with self.conn.sftp() as sftp:
32
- # await sftp.put(local_path, remote_path)
33
-
34
- # async def delete(self, remote_path):
35
- # async with self.conn.sftp() as sftp:
36
- # await sftp.remove(remote_path)
37
-
38
- # async def listdir(self, remote_path):
39
- # async with self.conn.sftp() as sftp:
40
- # return await sftp.listdir(remote_path)
41
-
42
- # async def close(self):
43
- # self.conn.close()
44
-
45
-
46
- # async def remote(
47
- # mode: str,
48
- # host: str,
49
- # user: str,
50
- # password: str,
51
- # local_path="",
52
- # port=22,
53
- # remote_path="",
54
- # ):
55
- # """mode:upload、read、del"""
56
- # client = AsyncSSHClient(host, port, user, password)
57
- # await client.connect()
58
- # if mode == "upload":
59
- # await client.upload(local_path, remote_path)
60
- # elif mode == "read":
61
- # file = await client.read(remote_path)
62
- # return file
63
- # elif mode == "del":
64
- # await client.delete(remote_path)
@@ -1,77 +0,0 @@
1
- import json
2
- from pathlib import Path
3
- from typing import Dict, List
4
-
5
- from nonebot import on_notice
6
- from nonebot.adapters.onebot.v11 import NoticeEvent
7
- from nonebot.log import logger
8
- from nonebot.matcher import Matcher
9
-
10
- from ..l4d2_image.steam import url_to_msg
11
-
12
- upload = on_notice(priority=1)
13
-
14
-
15
- @upload.handle()
16
- async def _(matcher: Matcher, event: NoticeEvent):
17
- try:
18
- arg = event.dict()
19
- files: dict = arg["file"]
20
- name: str = files["name"]
21
- if arg["notice_type"] == "offline_file" and name.endswith(".json"):
22
- try:
23
- msg = await url_to_msg(files["url"])
24
- if not msg:
25
- return
26
- jsons: Dict[str, List[Dict[str, str]]] = json.loads(msg)
27
- except json.decoder:
28
- logger.info("求生json格式不正确")
29
- await matcher.finish("求生json格式不正确")
30
- return
31
- if not validate_json(jsons):
32
- logger.info("求生json格式不正确")
33
- await matcher.finish("求生json格式不正确")
34
- print(name)
35
- key = await up_date(jsons, name)
36
- if key:
37
- # logger.info(jsons)
38
- msg = "输入成功\n"
39
- for key, value in jsons.items():
40
- msg += f"【{key}】指令:{len(value)}个\n"
41
- logger.info(msg)
42
- await matcher.send(msg)
43
- except KeyError:
44
- pass
45
-
46
-
47
- async def validate_json(json_data):
48
- try:
49
- data = json.loads(json_data)
50
- if not isinstance(data, dict):
51
- return False
52
-
53
- for key, value in data.items():
54
- if not isinstance(value, list):
55
- return False
56
- for item in value:
57
- if not isinstance(item, dict):
58
- return False
59
- if not all(key in item for key in ["id", "ip"]):
60
- return False
61
- if True:
62
- return True
63
-
64
- except json.JSONDecodeError:
65
- return False
66
-
67
-
68
- async def up_date(data: Dict[str, List[Dict[str, str]]], name: str):
69
- print(data)
70
- directory = Path("data/L4D2/l4d2")
71
- directory.mkdir(parents=True, exist_ok=True)
72
-
73
- file_path = directory / name
74
- with file_path.open("w") as json_file:
75
- json.dump(data, json_file)
76
-
77
- return True
@@ -1,86 +0,0 @@
1
- # import asyncio
2
- # import paramiko
3
-
4
-
5
- # class SSHClient:
6
- # def __init__(self, hostname, port, username, password):
7
- # self._hostname = hostname
8
- # self._port = port
9
- # self._username = username
10
- # self._password = password
11
- # self._ssh = None
12
-
13
- # async def connect(self):
14
- # self._ssh = paramiko.SSHClient()
15
- # self._ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
16
- # await asyncio.get_event_loop().run_in_executor(
17
- # None,
18
- # self._ssh.connect,
19
- # self._hostname,
20
- # self._port,
21
- # self._username,
22
- # self._password,
23
- # )
24
-
25
- # async def upload(self, local_file_path, remote_file_path):
26
- # with paramiko.Transport((self._hostname, self._port)) as transport:
27
- # await asyncio.get_event_loop().run_in_executor(
28
- # None, transport.connect, None, self._username, self._password
29
- # )
30
- # sftp = paramiko.SFTPClient.from_transport(transport)
31
- # await asyncio.get_event_loop().run_in_executor(
32
- # None, sftp.put, local_file_path, remote_file_path
33
- # )
34
-
35
- # async def delete(self, remote_file_path):
36
- # with paramiko.Transport((self._hostname, self._port)) as transport:
37
- # await asyncio.get_event_loop().run_in_executor(
38
- # None, transport.connect, None, self._username, self._password
39
- # )
40
- # sftp = paramiko.SFTPClient.from_transport(transport)
41
- # await asyncio.get_event_loop().run_in_executor(
42
- # None, sftp.remove, remote_file_path
43
- # )
44
-
45
- # async def read(self, remote_dir_path):
46
- # with paramiko.Transport((self._hostname, self._port)) as transport:
47
- # await asyncio.get_event_loop().run_in_executor(
48
- # None, transport.connect, None, self._username, self._password
49
- # )
50
- # sftp = paramiko.SFTPClient.from_transport(transport)
51
- # return await asyncio.get_event_loop().run_in_executor(
52
- # None, sftp.listdir, remote_dir_path
53
- # )
54
-
55
- # async def close(self):
56
- # if self._ssh is not None:
57
- # self._ssh.close()
58
-
59
-
60
- # async def main():
61
- # ssh = SSHClient("example.com", 22, "username", "password")
62
- # await ssh.connect()
63
-
64
- # await ssh.upload("/path/to/local/file", "/path/to/remote/file")
65
- # await ssh.delete("/path/to/remote/file")
66
- # files = await ssh.list("/path/to/remote/directory")
67
- # print(files)
68
-
69
- # await ssh.close()
70
-
71
- # if __name__ == '__main__':
72
- # asyncio.run(main())
73
-
74
-
75
- # async def remote(
76
- # mode: str, host, user, password, local_path="", port=22, remote_path=""
77
- # ):
78
- # """mode:upload、read、del"""
79
- # client = SSHClient(host, port, user, password)
80
- # if mode == "upload":
81
- # await client.upload(local_path, remote_path)
82
- # elif mode == "read":
83
- # file = await client.read(remote_path)
84
- # return file
85
- # elif mode == "del":
86
- # await client.delete(remote_path)