nonebot-plugin-l4d2-server 0.6.6__py3-none-any.whl → 1.0.0a2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. nonebot_plugin_l4d2_server/__init__.py +10 -93
  2. nonebot_plugin_l4d2_server/__main__.py +140 -0
  3. nonebot_plugin_l4d2_server/config.py +35 -0
  4. nonebot_plugin_l4d2_server/data/font/loli.ttf +0 -0
  5. nonebot_plugin_l4d2_server/l4_anne/__init__.py +124 -0
  6. nonebot_plugin_l4d2_server/l4_anne/ranne.py +18 -0
  7. nonebot_plugin_l4d2_server/l4_help/Help.json +102 -0
  8. nonebot_plugin_l4d2_server/l4_help/__init__.py +57 -0
  9. nonebot_plugin_l4d2_server/l4_help/draw.py +206 -0
  10. nonebot_plugin_l4d2_server/l4_help/icon//344/273/213/347/273/215.png +0 -0
  11. nonebot_plugin_l4d2_server/l4_help/icon//344/273/273/345/212/241.png +0 -0
  12. nonebot_plugin_l4d2_server/l4_help/icon//344/277/241/346/201/257.png +0 -0
  13. nonebot_plugin_l4d2_server/l4_help/icon//345/205/254/345/221/212.png +0 -0
  14. nonebot_plugin_l4d2_server/l4_help/icon//345/210/200/345/211/221.png +0 -0
  15. nonebot_plugin_l4d2_server/l4_help/icon//345/210/207/346/215/242.png +0 -0
  16. nonebot_plugin_l4d2_server/l4_help/icon//345/210/240/351/231/244.png +0 -0
  17. nonebot_plugin_l4d2_server/l4_help/icon//345/210/267/346/226/260.png +0 -0
  18. nonebot_plugin_l4d2_server/l4_help/icon//345/215/241/347/273/204.png +0 -0
  19. nonebot_plugin_l4d2_server/l4_help/icon//345/223/252/351/207/214.png +0 -0
  20. nonebot_plugin_l4d2_server/l4_help/icon//345/234/260/345/233/276.png +0 -0
  21. nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/205/245.png +0 -0
  22. nonebot_plugin_l4d2_server/l4_help/icon//345/257/274/345/207/272.png +0 -0
  23. nonebot_plugin_l4d2_server/l4_help/icon//345/275/261.png +0 -0
  24. nonebot_plugin_l4d2_server/l4_help/icon//346/213/274/345/233/276.png +0 -0
  25. nonebot_plugin_l4d2_server/l4_help/icon//346/216/242/347/264/242.png +0 -0
  26. nonebot_plugin_l4d2_server/l4_help/icon//346/216/250/351/200/201.png +0 -0
  27. nonebot_plugin_l4d2_server/l4_help/icon//346/224/266/351/233/206.png +0 -0
  28. nonebot_plugin_l4d2_server/l4_help/icon//346/224/273/347/225/245.png +0 -0
  29. nonebot_plugin_l4d2_server/l4_help/icon//346/233/264/346/226/260.png +0 -0
  30. nonebot_plugin_l4d2_server/l4_help/icon//346/235/220/346/226/231.png +0 -0
  31. nonebot_plugin_l4d2_server/l4_help/icon//346/237/245/350/257/242.png +0 -0
  32. nonebot_plugin_l4d2_server/l4_help/icon//346/240/241/351/252/214.png +0 -0
  33. nonebot_plugin_l4d2_server/l4_help/icon//346/257/217/346/234/210.png +0 -0
  34. nonebot_plugin_l4d2_server/l4_help/icon//346/267/261/346/270/212.png +0 -0
  35. nonebot_plugin_l4d2_server/l4_help/icon//346/267/273/345/212/240.png +0 -0
  36. nonebot_plugin_l4d2_server/l4_help/icon//346/270/205/351/231/244.png +0 -0
  37. nonebot_plugin_l4d2_server/l4_help/icon//347/212/266/346/200/201.png +0 -0
  38. nonebot_plugin_l4d2_server/l4_help/icon//347/255/276/345/210/260.png +0 -0
  39. nonebot_plugin_l4d2_server/l4_help/icon//347/273/221/345/256/232.png +0 -0
  40. nonebot_plugin_l4d2_server/l4_help/icon//350/241/250.png +0 -0
  41. nonebot_plugin_l4d2_server/l4_help/icon//350/241/250/346/203/205.png +0 -0
  42. nonebot_plugin_l4d2_server/l4_help/icon//350/247/222/350/211/262.png +0 -0
  43. nonebot_plugin_l4d2_server/l4_help/icon//350/256/260/345/275/225.png +0 -0
  44. nonebot_plugin_l4d2_server/l4_help/icon//351/205/215/347/275/256.png +0 -0
  45. nonebot_plugin_l4d2_server/l4_help/icon//351/207/215/345/220/257.png +0 -0
  46. nonebot_plugin_l4d2_server/l4_help/texture2d/badge.png +0 -0
  47. nonebot_plugin_l4d2_server/l4_help/texture2d/banner.png +0 -0
  48. nonebot_plugin_l4d2_server/l4_help/texture2d/bg.jpg +0 -0
  49. nonebot_plugin_l4d2_server/l4_help/texture2d/button.png +0 -0
  50. nonebot_plugin_l4d2_server/l4_help/texture2d/icon.png +0 -0
  51. nonebot_plugin_l4d2_server/l4_image/__init__.py +16 -0
  52. nonebot_plugin_l4d2_server/l4_image/anne_pil.py +17 -0
  53. nonebot_plugin_l4d2_server/l4_image/convert.py +175 -0
  54. nonebot_plugin_l4d2_server/{l4d2_image → l4_image}/download.py +11 -35
  55. nonebot_plugin_l4d2_server/l4_image/html_img.py +105 -0
  56. nonebot_plugin_l4d2_server/l4_image/image_tools.py +468 -0
  57. nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/back.png +0 -0
  58. nonebot_plugin_l4d2_server/l4_image/img/anne/back1.jpg +0 -0
  59. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/head/head.png +0 -0
  60. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/header/logo.png +0 -0
  61. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/header/player1.jpg +0 -0
  62. nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.html +299 -0
  63. nonebot_plugin_l4d2_server/l4_image/img/template/Bocchi_The_Rock.png +0 -0
  64. nonebot_plugin_l4d2_server/l4_image/img/template/HYPixel11pxU-2.ttf +0 -0
  65. nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.html +341 -0
  66. nonebot_plugin_l4d2_server/l4_image/img/template/Pixel.png +0 -0
  67. nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.html +355 -0
  68. nonebot_plugin_l4d2_server/l4_image/img/template/Rainbow.png +0 -0
  69. nonebot_plugin_l4d2_server/l4_image/img/template/Tutumianhuatang-Bold-2.ttf +0 -0
  70. nonebot_plugin_l4d2_server/l4_image/img/template/bilibili.svg +1 -0
  71. nonebot_plugin_l4d2_server/l4_image/img/template/github.svg +1 -0
  72. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/l.svg +0 -1
  73. nonebot_plugin_l4d2_server/l4_image/img/template/m.svg +1 -0
  74. nonebot_plugin_l4d2_server/l4_image/img/template/normal.html +247 -0
  75. nonebot_plugin_l4d2_server/l4_image/img/template/vac.png +0 -0
  76. nonebot_plugin_l4d2_server/l4_image/img/template/vac_white.png +0 -0
  77. nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/w.svg +1 -1
  78. nonebot_plugin_l4d2_server/l4_image/model.py +15 -0
  79. nonebot_plugin_l4d2_server/{l4d2_image → l4_image}/vtfs.py +4 -2
  80. nonebot_plugin_l4d2_server/l4_request/__init__.py +143 -0
  81. nonebot_plugin_l4d2_server/l4_request/draw_msg.py +83 -0
  82. nonebot_plugin_l4d2_server/utils/api/api.py +10 -0
  83. nonebot_plugin_l4d2_server/utils/api/models.py +137 -0
  84. nonebot_plugin_l4d2_server/utils/api/request.py +337 -0
  85. nonebot_plugin_l4d2_server/utils/database/models.py +18 -0
  86. nonebot_plugin_l4d2_server/{l4d2_utils → utils}/utils.py +60 -63
  87. {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/METADATA +57 -66
  88. nonebot_plugin_l4d2_server-1.0.0a2.dist-info/RECORD +96 -0
  89. {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/WHEEL +1 -1
  90. nonebot_plugin_l4d2_server/data/L4D2/image/template/help.html +0 -263
  91. nonebot_plugin_l4d2_server/data/L4D2/image/template/help_dack.html +0 -231
  92. nonebot_plugin_l4d2_server/data/L4D2/image/template/m.svg +0 -1
  93. nonebot_plugin_l4d2_server/data/img/white.png +0 -0
  94. nonebot_plugin_l4d2_server/l4d2_anne/__init__.py +0 -95
  95. nonebot_plugin_l4d2_server/l4d2_anne/analysis.py +0 -54
  96. nonebot_plugin_l4d2_server/l4d2_anne/anne_telecom.py +0 -79
  97. nonebot_plugin_l4d2_server/l4d2_anne/server.py +0 -47
  98. nonebot_plugin_l4d2_server/l4d2_anne/startand.py +0 -17
  99. nonebot_plugin_l4d2_server/l4d2_anne/utils.py +0 -294
  100. nonebot_plugin_l4d2_server/l4d2_data/__init__.py +0 -105
  101. nonebot_plugin_l4d2_server/l4d2_data/config.py +0 -18
  102. nonebot_plugin_l4d2_server/l4d2_data/players.py +0 -100
  103. nonebot_plugin_l4d2_server/l4d2_data/serverip.py +0 -40
  104. nonebot_plugin_l4d2_server/l4d2_file/__init__.py +0 -222
  105. nonebot_plugin_l4d2_server/l4d2_file/ayromote.py +0 -64
  106. nonebot_plugin_l4d2_server/l4d2_file/input_json.py +0 -77
  107. nonebot_plugin_l4d2_server/l4d2_file/remote.py +0 -86
  108. nonebot_plugin_l4d2_server/l4d2_file/utils.py +0 -104
  109. nonebot_plugin_l4d2_server/l4d2_image/__init__.py +0 -125
  110. nonebot_plugin_l4d2_server/l4d2_image/htmlimg.py +0 -18
  111. nonebot_plugin_l4d2_server/l4d2_image/images.py +0 -92
  112. nonebot_plugin_l4d2_server/l4d2_image/one.py +0 -44
  113. nonebot_plugin_l4d2_server/l4d2_image/send_image_tool.py +0 -32
  114. nonebot_plugin_l4d2_server/l4d2_image/steam.py +0 -63
  115. nonebot_plugin_l4d2_server/l4d2_push/__init__.py +0 -225
  116. nonebot_plugin_l4d2_server/l4d2_queries/__init__.py +0 -326
  117. nonebot_plugin_l4d2_server/l4d2_queries/himi.py +0 -113
  118. nonebot_plugin_l4d2_server/l4d2_queries/local_ip.py +0 -41
  119. nonebot_plugin_l4d2_server/l4d2_queries/qqgroup.py +0 -370
  120. nonebot_plugin_l4d2_server/l4d2_queries/send_msg.py +0 -131
  121. nonebot_plugin_l4d2_server/l4d2_queries/utils.py +0 -212
  122. nonebot_plugin_l4d2_server/l4d2_server/__init__.py +0 -118
  123. nonebot_plugin_l4d2_server/l4d2_server/index.py +0 -0
  124. nonebot_plugin_l4d2_server/l4d2_server/rcon.py +0 -53
  125. nonebot_plugin_l4d2_server/l4d2_server/workshop.py +0 -82
  126. nonebot_plugin_l4d2_server/l4d2_update/__init__.py +0 -137
  127. nonebot_plugin_l4d2_server/l4d2_update/draw_update_log.py +0 -45
  128. nonebot_plugin_l4d2_server/l4d2_update/restart.py +0 -69
  129. nonebot_plugin_l4d2_server/l4d2_update/update.py +0 -53
  130. nonebot_plugin_l4d2_server/l4d2_utils/classcal.py +0 -53
  131. nonebot_plugin_l4d2_server/l4d2_utils/command.py +0 -23
  132. nonebot_plugin_l4d2_server/l4d2_utils/config.py +0 -201
  133. nonebot_plugin_l4d2_server/l4d2_utils/message.py +0 -59
  134. nonebot_plugin_l4d2_server/l4d2_utils/rule.py +0 -35
  135. nonebot_plugin_l4d2_server/l4d2_utils/seach.py +0 -43
  136. nonebot_plugin_l4d2_server/l4d2_utils/txt_to_img.py +0 -32
  137. nonebot_plugin_l4d2_server/l4d2_web/web.py +0 -277
  138. nonebot_plugin_l4d2_server/l4d2_web/webUI.py +0 -506
  139. nonebot_plugin_l4d2_server/l4d2_web/webUI_s.py +0 -94
  140. nonebot_plugin_l4d2_server-0.6.6.dist-info/RECORD +0 -70
  141. /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/anne.html +0 -0
  142. /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/group_ip.html +0 -0
  143. /nonebot_plugin_l4d2_server/{data/L4D2/image/template → l4_image/img/anne}/ip.html +0 -0
  144. /nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/fingerprint.svg +0 -0
  145. /nonebot_plugin_l4d2_server/{data/L4D2/image → l4_image/img}/template/vue.css +0 -0
  146. /nonebot_plugin_l4d2_server/{l4d2_data/database.py → l4_request/utils.py} +0 -0
  147. {nonebot_plugin_l4d2_server-0.6.6.dist-info → nonebot_plugin_l4d2_server-1.0.0a2.dist-info}/licenses/LICENSE +0 -0
@@ -1,326 +0,0 @@
1
- import json
2
- from time import sleep
3
- from typing import Dict, List, Tuple, Union
4
-
5
- from nonebot import on_command, on_keyword
6
- from nonebot.adapters import Event, Message
7
- from nonebot.adapters.onebot.v11 import GroupMessageEvent
8
- from nonebot.log import logger
9
- from nonebot.matcher import Matcher
10
- from nonebot.params import ArgPlainText, CommandArg, CommandStart, Keyword, RawCommand
11
- from nonebot_plugin_saa import Image, MessageFactory
12
-
13
- from ..l4d2_image import server_group_ip_pic
14
- from ..l4d2_queries.qqgroup import add_ip, del_ip, get_number_url, show_ip
15
- from ..l4d2_queries.utils import queries_server
16
- from ..l4d2_server.rcon import command_server
17
- from ..l4d2_utils.config import DATA_PATH, MASTER, driver, l4_config
18
- from ..l4d2_utils.txt_to_img import mode_txt_to_img
19
- from ..l4d2_utils.utils import split_maohao, str_to_picstr
20
- from .himi import get_himi_ip
21
- from .local_ip import ALL_HOST
22
- from .qqgroup import get_tan_jian
23
- from .send_msg import get_group_ip_to_msg, get_ip_to_mes
24
- from .utils import server_key
25
-
26
- tan_jian = on_command("tj", aliases={"探监"}, priority=20, block=True)
27
- prison = on_command("zl", aliases={"坐牢"}, priority=20, block=True)
28
- open_prison = on_command("kl", aliases={"开牢"}, priority=20, block=True)
29
- rcon_to_server = on_command(
30
- "rcon",
31
- aliases={"求生服务器指令", "服务器指令"},
32
- permission=MASTER,
33
- )
34
-
35
- # 查询
36
- queries_comm = on_keyword(
37
- keywords={"queries", "求生ip", "求生IP", "connect"},
38
- priority=20,
39
- block=True,
40
- )
41
- add_queries = on_command(
42
- "addq",
43
- aliases={"求生添加订阅"},
44
- priority=20,
45
- block=True,
46
- permission=MASTER,
47
- )
48
- del_queries = on_command(
49
- "delq",
50
- aliases={"求生取消订阅"},
51
- priority=20,
52
- block=True,
53
- permission=MASTER,
54
- )
55
- add2_queries = on_command(
56
- "l4add",
57
- aliases={"l4添加查询", "l4增加查询"},
58
- priority=20,
59
- block=True,
60
- permission=MASTER,
61
- )
62
- del2_queries = on_command(
63
- "l4del",
64
- aliases={"l4删除查询", "l4取消查询"},
65
- priority=20,
66
- block=True,
67
- permission=MASTER,
68
- )
69
- show_queries = on_command("showq", aliases={"求生订阅"}, priority=20, block=True)
70
- join_server = on_command("ld_jr", aliases={"求生加入"}, priority=20, block=True)
71
-
72
- updata_himi = on_command(
73
- "update_hime",
74
- aliases={"公益服更新,l4公益服更新"},
75
- priority=10,
76
- block=True,
77
- )
78
-
79
-
80
- async def get_des_ip():
81
- """初始化"""
82
-
83
- def count_ips(ip_dict: Dict[str, List[Dict[str, str]]]):
84
- """输出加载ip"""
85
- global ANNE_IP
86
- for key, value in ip_dict.items():
87
- if key in ["error_", "success_"]:
88
- ip_dict.pop(key)
89
- break
90
- count = len(value)
91
- logger.info(f"已加载:{key} | {count}个")
92
- if key == "云":
93
- ANNE_IP = {key: value}
94
- sleep(1)
95
-
96
- count_ips(ALL_HOST)
97
- ip_anne_list = []
98
- try:
99
- for one_tag in l4_config.l4_zl_tag:
100
- ips = ALL_HOST[one_tag]
101
- ip_anne_list: List[Tuple[str, str, str]] = []
102
- for one_ip in ips:
103
- host, port = split_maohao(one_ip["ip"])
104
- ip_anne_list.append((one_ip["id"], host, port))
105
- except (KeyError, TypeError):
106
- pass
107
- await get_read_ip(ip_anne_list)
108
-
109
- @tan_jian.handle()
110
- async def _(matcher: Matcher):
111
- msg = await get_tan_jian(ip_anne_list, 1)
112
- await str_to_picstr(push_msg=msg, matcher=matcher)
113
-
114
- @prison.handle()
115
- async def _(matcher: Matcher):
116
- msg = await get_tan_jian(ip_anne_list, 2)
117
- await str_to_picstr(push_msg=msg, matcher=matcher)
118
-
119
- @open_prison.handle()
120
- async def _(matcher: Matcher):
121
- msg = await get_tan_jian(ip_anne_list, 3)
122
- await str_to_picstr(push_msg=msg, matcher=matcher)
123
-
124
-
125
- async def get_read_ip(ip_anne_list: List[Tuple[str, str, str]]):
126
- get_ip = on_command("云", aliases=server_key(), priority=50, block=True)
127
- if not ip_anne_list:
128
- ...
129
-
130
- @get_ip.handle()
131
- async def _(
132
- matcher: Matcher,
133
- start: str = CommandStart(),
134
- command: str = RawCommand(),
135
- args: Message = CommandArg(),
136
- ):
137
- """例:
138
- 指令: /橘5
139
- start: /(command开头指令)
140
- command: /橘(响应的全部指令)
141
- args: 5(响应的指令后的数字)
142
- """
143
- print(start, command, args)
144
- if start:
145
- command = command.replace(start, "")
146
- if command == "anne":
147
- command = "云"
148
- msg: str = args.extract_plain_text()
149
- if "组" in msg:
150
- logger.info(f"关键词:{command}")
151
- # 以群组模式输出
152
- push_msg = await get_group_ip_to_msg(command)
153
- if push_msg is None or not push_msg:
154
- await matcher.finish("当前对象里并没有组")
155
- return
156
- print(push_msg)
157
- msg_img = await server_group_ip_pic(push_msg)
158
- await MessageFactory([Image(msg_img)]).send()
159
- else:
160
- push_msg = await get_ip_to_mes(msg, command)
161
- if push_msg is None:
162
- return
163
-
164
- await MessageFactory(push_msg).send()
165
-
166
-
167
- # tests = on_command("测试1")
168
-
169
- # @tests.handle()
170
- # async def _(event: Event,arg:Message=CommandArg()):
171
- # logger.info(event)
172
- # logger.info(arg.extract_plain_text())
173
-
174
-
175
- @add_queries.handle()
176
- async def _(matcher: Matcher, event: GroupMessageEvent, args: Message = CommandArg()):
177
- msg = args.extract_plain_text()
178
- if len(msg) == 0:
179
- await matcher.finish("请在该指令后加入参数,例如【114.51.49.19:1810】")
180
- [host, port] = split_maohao(msg)
181
- group_id = event.group_id
182
- msg = await add_ip(group_id, host, port)
183
- await matcher.finish(msg)
184
-
185
-
186
- @del_queries.handle()
187
- async def _(event: GroupMessageEvent, matcher: Matcher, args: Message = CommandArg()):
188
- msg = args.extract_plain_text()
189
- if not msg.isdigit():
190
- await matcher.finish("请输入正确的序号数字")
191
- group_id = event.group_id
192
- msg = await del_ip(group_id, msg)
193
- await matcher.finish(msg)
194
-
195
-
196
- @show_queries.handle()
197
- async def _(matcher: Matcher, event: GroupMessageEvent):
198
- group_id = event.group_id
199
- msg = await show_ip(group_id)
200
- if not msg:
201
- await matcher.finish("当前没有启动的服务器捏")
202
- return
203
- if isinstance(msg, str):
204
- await matcher.finish(msg)
205
- else:
206
- await MessageFactory([Image(msg)]).finish()
207
-
208
-
209
- @queries_comm.handle()
210
- async def _(matcher: Matcher, event: Event, keyword: str = Keyword()):
211
- msg = event.get_plaintext()
212
-
213
- if not msg:
214
- await matcher.finish("ip格式如中括号内【127.0.0.1】【114.51.49.19:1810】")
215
- ip = msg.split(keyword)[-1].split("\r")[0].split("\n")[0].split(" ")
216
- one_msg = None
217
- for one in ip:
218
- if one and one[-1].isdigit():
219
- one_msg = one
220
- break
221
- if not one_msg:
222
- await matcher.finish()
223
- return
224
- ip_list = split_maohao(one_msg)
225
- msg = await queries_server(ip_list)
226
- await str_to_picstr(msg, matcher, keyword)
227
-
228
-
229
- @join_server.handle()
230
- async def _(args: Message = CommandArg()):
231
- msg = args.extract_plain_text()
232
- url = await get_number_url(msg)
233
- await join_server.finish(url)
234
-
235
-
236
- @rcon_to_server.handle()
237
- async def _(matcher: Matcher, args: Message = CommandArg()):
238
- msg = args.extract_plain_text()
239
- if msg:
240
- matcher.set_arg("command", args)
241
-
242
-
243
- @rcon_to_server.got("command", prompt="请输入向服务器发送的指令")
244
- async def _(matcher: Matcher, tag: str = ArgPlainText("command")):
245
- tag = tag.strip()
246
- msg = await command_server(tag)
247
- try:
248
- await mode_txt_to_img("服务器返回", msg)
249
- except Exception as E:
250
- await matcher.finish(str(E), reply_message=True)
251
-
252
-
253
- async def init():
254
- global matchers
255
- # print('启动辣')
256
-
257
- await get_des_ip()
258
-
259
-
260
- @driver.on_startup
261
- async def _():
262
- await init()
263
-
264
-
265
- @add2_queries.handle()
266
- async def _(matcher: Matcher, arg: Message = CommandArg()):
267
- arg_list = arg.extract_plain_text().split(" ")
268
- if len(arg_list) == 2:
269
- tag, ip = arg_list
270
- file_name = f"{tag}.json"
271
- file_path = DATA_PATH.resolve() / "l4d2" / file_name
272
- with file_path.open(mode="r", encoding="utf-8") as f:
273
- tag_data: Dict[str, List[Dict[str, Union[int, str]]]] = json.load(f)
274
- num_list: List[str] = []
275
- for one_number in tag_data[tag]:
276
- num_list.append(str(one_number["id"]))
277
- add_num = 0
278
- for i in range(1, 100):
279
- if str(i) not in num_list:
280
- add_num = i
281
- break
282
- continue
283
- elif len(arg_list) == 3:
284
- tag, add_num, ip = arg_list
285
- file_name = f"{tag}.json"
286
- file_path = DATA_PATH.resolve() / "l4d2" / file_name
287
- with file_path.open(mode="r", encoding="utf-8") as f:
288
- tag_data: Dict[str, List[Dict[str, Union[int, str]]]] = json.load(f)
289
- else:
290
- await matcher.finish("参数不正确")
291
- return
292
- if add_num != 0:
293
- tag_data[tag].append({"id": int(add_num), "ip": ip})
294
- with file_path.open(mode="w", encoding="utf-8") as f:
295
- json.dump(tag_data, f, ensure_ascii=False)
296
- await matcher.finish(
297
- f"""成功添加
298
- 指令: {tag}{add_num}
299
- ip: {ip}
300
- """,
301
- )
302
- await matcher.finish("参数不正确")
303
-
304
-
305
- @del2_queries.handle()
306
- async def _(matcher: Matcher, arg: Message = CommandArg()):
307
- arg_list = arg.extract_plain_text().split(" ")
308
- if len(arg_list) == 2:
309
- tag, num = arg_list
310
- file_name = f"{tag}.json"
311
- file_path = DATA_PATH.resolve() / "l4d2" / file_name
312
- with file_path.open(mode="r", encoding="utf-8") as f:
313
- tag_data: Dict[str, List[Dict[str, Union[int, str]]]] = json.load(f)
314
- for one_number in tag_data[tag]:
315
- if str(one_number["id"]) == num:
316
- tag_data[tag].remove(one_number)
317
- with file_path.open(mode="w", encoding="utf-8") as f:
318
- json.dump(tag_data, f, ensure_ascii=False)
319
- await matcher.finish(f"成功删除指令指令: {tag}")
320
- await matcher.finish("参数不正确")
321
-
322
-
323
- @updata_himi.handle()
324
- async def _(matcher: Matcher):
325
- send_msg = await get_himi_ip()
326
- await matcher.finish(send_msg)
@@ -1,113 +0,0 @@
1
- import asyncio
2
- import json
3
- from pathlib import Path
4
- from typing import Dict, List
5
-
6
- import aiohttp
7
- from nonebot.log import logger
8
-
9
-
10
- # from ..l4d2_image.steam import url_to_msg
11
- async def url_to_msg(url: str):
12
- """获取URL数据的字节流"""
13
-
14
- async with aiohttp.ClientSession() as session:
15
- async with session.get(url, timeout=600) as response:
16
- if response.status == 200:
17
- return await response.text()
18
- return None
19
-
20
-
21
- async def get_himi_ip():
22
- url = "http://xg-squ.himeneko.cn:8080/cq/servers?nonce=272526ut&token=07163dc62723159a6accfc1fcad2029b"
23
- msg = await url_to_msg(url)
24
- if msg:
25
- msg_json: Dict[str, List[Dict[str, str]]] = json.loads(msg)
26
- else:
27
- return "api错误,这不是程序的原因,,"
28
- msg_list = msg_json["list"]
29
- new_json: Dict[str, List[Dict[str, str]]] = {}
30
- for one_server in msg_list:
31
- new_server: Dict[str, str] = {}
32
- tag = await name_to_tag(one_server["name"])
33
- new_server["id"] = await name_to_id(
34
- one_server["name"],
35
- tag,
36
- new_json,
37
- )
38
- new_server["ip"] = one_server["url"]
39
- logger.info(tag, "|", one_server["name"], "|", new_server["id"])
40
- if tag in new_json:
41
- new_json[tag].append(new_server)
42
- else:
43
- new_json[tag] = [new_server]
44
- send_msg: str = "更新成功:"
45
- for key, value in new_json.items():
46
- new_dict = {key: value} # 创建只有一个键值对的新字典
47
- send_msg += f"【{key}】: {len(value)}个"
48
- # 保存新字典为 JSON 文件
49
- with Path("data/L4d2/l4d2", f"{key}.json").open("w") as file:
50
- json.dump(new_dict, file, indent=4)
51
- return send_msg
52
-
53
-
54
- async def name_to_tag(name: str):
55
- """获取tag"""
56
- while name and ord(name[0]) == 65279:
57
- name = name[1::]
58
- if name.startswith("橘"):
59
- tag = "橘"
60
- elif name.startswith("["):
61
- tag = name[1::].split("]")[0].split(" ")[0]
62
- # print(tag, "|", name)
63
- elif name.startswith("『"):
64
- tag = name[1::].split("‖")[0].split(" ")[0]
65
- elif name.startswith("【"):
66
- tag = name[1::].split("】")[0].split(" ")[0]
67
- elif "电信云服" in name:
68
- tag = "云"
69
- elif "Neko" in name:
70
- tag = "Neko"
71
- else:
72
- tag = name[0] + name[1]
73
-
74
- return tag
75
-
76
-
77
- async def name_to_id(name: str, tag: str, msg_dict: Dict[str, List[Dict[str, str]]]):
78
- while name and ord(name[0]) == 65279:
79
- name = name[1::]
80
- if "#" in name:
81
- index = name.find("#")
82
- number = ""
83
- for i in range(index + 1, len(name)):
84
- if name[i].isdigit():
85
- number += name[i]
86
- if len(number) == 2: # 只提取一个或两个数字
87
- return str(number)
88
- else:
89
- break
90
- elif "[服]" in name:
91
- index = name.find("[服]")
92
- number = ""
93
- for i in range(index - 1, -1, -1):
94
- if name[i].isdigit():
95
- number = name[i] + number
96
- if len(number) == 1: # 只提取一个数字
97
- return str(number)
98
- else:
99
- break
100
- id_list: List[str] = []
101
- try:
102
- for one_server in msg_dict[tag]:
103
- id_list.append(str(one_server["id"]))
104
- for one in range(1, 100):
105
- if str(one) not in id_list:
106
- return str(one)
107
- except KeyError:
108
- return "1"
109
- return "1"
110
-
111
-
112
- if __name__ == "__main__":
113
- asyncio.run(get_himi_ip())
@@ -1,41 +0,0 @@
1
- import json
2
- from pathlib import Path
3
- from typing import Dict, List
4
-
5
- filename = Path("data/L4D2/l4d2.json")
6
- global_file = Path(Path(__file__).parent.parent, filename)
7
-
8
-
9
- def load_ip_json():
10
- # 本地模块
11
- local_host: Dict[str, List[Dict[str, str]]] = {}
12
- try:
13
- # 获取所有json文件的路径
14
- json_files = Path("data/L4D2/l4d2").glob("*.json")
15
-
16
- # 将所有json文件中的字典对象合并为一个字典
17
- for file_path in json_files:
18
- try:
19
- with file_path.open("r", encoding="utf-8") as f:
20
- local_host.update(json.load(f))
21
- except Exception:
22
- print("导入错误", file_path)
23
- except Exception:
24
- pass
25
- return local_host
26
-
27
-
28
- def load_group_json():
29
- try:
30
- group_host: Dict[str, List[str]] = json.load(filename.open("r", encoding="utf8"))
31
- except (IOError, FileNotFoundError):
32
- filename.parent.mkdir(parents=True, exist_ok=True)
33
- data: Dict[str, List[str]] = {"anne": ["云"]}
34
- with filename.open("w") as f:
35
- json.dump(data, f)
36
- group_host: Dict[str, List[str]] = {}
37
- return group_host
38
-
39
-
40
- ALL_HOST: Dict[str, List[Dict[str, str]]] = load_ip_json()
41
- Group_All_HOST: Dict[str, List[str]] = load_group_json()