nonebot-plugin-l4d2-server 0.5.1__py3-none-any.whl → 0.5.2__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 (48) hide show
  1. LICENSE +674 -674
  2. README.md +364 -359
  3. nonebot_plugin_l4d2_server/__init__.py +1 -1
  4. nonebot_plugin_l4d2_server/chrome.py +44 -44
  5. nonebot_plugin_l4d2_server/command.py +232 -232
  6. nonebot_plugin_l4d2_server/config.py +210 -210
  7. nonebot_plugin_l4d2_server/data/L4D2/image/template/anne.html +60 -60
  8. nonebot_plugin_l4d2_server/data/L4D2/image/template/fingerprint.svg +15 -15
  9. nonebot_plugin_l4d2_server/data/L4D2/image/template/help.html +233 -233
  10. nonebot_plugin_l4d2_server/data/L4D2/image/template/help_dack.html +231 -231
  11. nonebot_plugin_l4d2_server/data/L4D2/image/template/ip.html +48 -48
  12. nonebot_plugin_l4d2_server/data/L4D2/image/template/l.svg +9 -9
  13. nonebot_plugin_l4d2_server/l4d2_anne/__init__.py +251 -251
  14. nonebot_plugin_l4d2_server/l4d2_anne/analysis.py +51 -51
  15. nonebot_plugin_l4d2_server/l4d2_anne/anne_telecom.py +75 -75
  16. nonebot_plugin_l4d2_server/l4d2_anne/server.py +65 -65
  17. nonebot_plugin_l4d2_server/l4d2_anne/startand.py +17 -17
  18. nonebot_plugin_l4d2_server/l4d2_data/__init__.py +91 -91
  19. nonebot_plugin_l4d2_server/l4d2_data/config.py +17 -17
  20. nonebot_plugin_l4d2_server/l4d2_data/players.py +87 -87
  21. nonebot_plugin_l4d2_server/l4d2_data/serverip.py +32 -32
  22. nonebot_plugin_l4d2_server/l4d2_file/__init__.py +122 -122
  23. nonebot_plugin_l4d2_server/l4d2_file/ayromote.py +56 -56
  24. nonebot_plugin_l4d2_server/l4d2_file/remote.py +63 -63
  25. nonebot_plugin_l4d2_server/l4d2_image/__init__.py +103 -103
  26. nonebot_plugin_l4d2_server/l4d2_image/download.py +101 -101
  27. nonebot_plugin_l4d2_server/l4d2_image/htmlimg.py +32 -32
  28. nonebot_plugin_l4d2_server/l4d2_image/send_image_tool.py +32 -32
  29. nonebot_plugin_l4d2_server/l4d2_image/steam.py +83 -83
  30. nonebot_plugin_l4d2_server/l4d2_image/vtfs.py +40 -40
  31. nonebot_plugin_l4d2_server/l4d2_queries/__init__.py +114 -114
  32. nonebot_plugin_l4d2_server/l4d2_queries/api.py +43 -43
  33. nonebot_plugin_l4d2_server/l4d2_queries/ohter.py +35 -35
  34. nonebot_plugin_l4d2_server/l4d2_queries/qqgroup.py +288 -288
  35. nonebot_plugin_l4d2_server/l4d2_server/__init__.py +61 -61
  36. nonebot_plugin_l4d2_server/l4d2_server/rcon.py +28 -28
  37. nonebot_plugin_l4d2_server/l4d2_server/workshop.py +50 -50
  38. nonebot_plugin_l4d2_server/l4d2_web/web.py +234 -252
  39. nonebot_plugin_l4d2_server/l4d2_web/webUI.py +241 -245
  40. nonebot_plugin_l4d2_server/message.py +58 -58
  41. nonebot_plugin_l4d2_server/seach.py +33 -33
  42. nonebot_plugin_l4d2_server/txt_to_img.py +64 -64
  43. nonebot_plugin_l4d2_server/utils.py +272 -272
  44. {nonebot_plugin_l4d2_server-0.5.1.dist-info → nonebot_plugin_l4d2_server-0.5.2.dist-info}/LICENSE +674 -674
  45. {nonebot_plugin_l4d2_server-0.5.1.dist-info → nonebot_plugin_l4d2_server-0.5.2.dist-info}/METADATA +6 -1
  46. nonebot_plugin_l4d2_server-0.5.2.dist-info/RECORD +54 -0
  47. {nonebot_plugin_l4d2_server-0.5.1.dist-info → nonebot_plugin_l4d2_server-0.5.2.dist-info}/WHEEL +1 -1
  48. nonebot_plugin_l4d2_server-0.5.1.dist-info/RECORD +0 -54
@@ -45,7 +45,7 @@ scheduler = require("nonebot_plugin_apscheduler").scheduler
45
45
  driver = get_driver()
46
46
 
47
47
 
48
- __version__ = "0.5.1"
48
+ __version__ = "0.5.2"
49
49
  __plugin_meta__ = PluginMetadata(
50
50
  name="求生之路小助手",
51
51
  description='群内对有关求生之路的查询和操作',
@@ -1,45 +1,45 @@
1
- try:
2
- from selenium import webdriver
3
- from selenium.webdriver.chrome.options import Options
4
- from selenium.webdriver.common.by import By
5
- except:
6
- pass
7
- url = 'https://server.trygek.com/index.php'
8
-
9
-
10
- def get_anne_server():
11
- chrome_options = Options()
12
- chrome_options.add_argument('--no-sandbox') #“–no-sandbox”参数是让Chrome在root权限下跑
13
- chrome_options.add_argument('--ignore-certificate-errors')
14
- chrome_options.add_argument('--disable-dev-shm-usage')
15
- chrome_options.add_argument('-ignore-certificate-errors')
16
- chrome_options.add_argument('--headless') #“–headless”参数是不用打开图形界面
17
- driver = webdriver.Chrome(chrome_options=chrome_options)
18
- print('启动成功')
19
- # browser.get(url)
20
- # browser.add_cookie({'name':'token','value':token_value})
21
- driver.get(url)
22
- print('网页已打开,正在浏览')
23
- i = 0
24
- n = 1
25
- msg = ''
26
- while i <= 40:
27
- try:
28
- i += 1
29
- mes =''
30
- xpath1 = '//*[@id="host_{}"]'.format(i)
31
- xpath2 = '/html/body/main/div[3]/div[5]/div/div/table/tbody/tr[{}]/td[5]'.format(n)
32
- xpath3 = '//*[@id="players_{}"]'.format(i)
33
- xpath4 = '//*[@id="map_{}"]'.format(i)
34
- xpath = [xpath1,xpath2,xpath3,xpath4]
35
- names = ['服务器名称','服务器ip','玩家','地图']
36
- for x in range(5):
37
- name:str = driver.find_element(By.XPATH,xpath[x-1]).text
38
- mes += names[x-1] + '' + name + '\n'
39
- msg += mes
40
- msg += '--------------------\n'
41
- n += 2
42
- except :
43
- continue
44
- return msg
1
+ try:
2
+ from selenium import webdriver
3
+ from selenium.webdriver.chrome.options import Options
4
+ from selenium.webdriver.common.by import By
5
+ except:
6
+ pass
7
+ url = 'https://server.trygek.com/index.php'
8
+
9
+
10
+ def get_anne_server():
11
+ chrome_options = Options()
12
+ chrome_options.add_argument('--no-sandbox') #“–no-sandbox”参数是让Chrome在root权限下跑
13
+ chrome_options.add_argument('--ignore-certificate-errors')
14
+ chrome_options.add_argument('--disable-dev-shm-usage')
15
+ chrome_options.add_argument('-ignore-certificate-errors')
16
+ chrome_options.add_argument('--headless') #“–headless”参数是不用打开图形界面
17
+ driver = webdriver.Chrome(chrome_options=chrome_options)
18
+ print('启动成功')
19
+ # browser.get(url)
20
+ # browser.add_cookie({'name':'token','value':token_value})
21
+ driver.get(url)
22
+ print('网页已打开,正在浏览')
23
+ i = 0
24
+ n = 1
25
+ msg = ''
26
+ while i <= 40:
27
+ try:
28
+ i += 1
29
+ mes =''
30
+ xpath1 = '//*[@id="host_{}"]'.format(i)
31
+ xpath2 = '/html/body/main/div[3]/div[5]/div/div/table/tbody/tr[{}]/td[5]'.format(n)
32
+ xpath3 = '//*[@id="players_{}"]'.format(i)
33
+ xpath4 = '//*[@id="map_{}"]'.format(i)
34
+ xpath = [xpath1,xpath2,xpath3,xpath4]
35
+ names = ['服务器名称','服务器ip','玩家','地图']
36
+ for x in range(5):
37
+ name:str = driver.find_element(By.XPATH,xpath[x-1]).text
38
+ mes += names[x-1] + '' + name + '\n'
39
+ msg += mes
40
+ msg += '--------------------\n'
41
+ n += 2
42
+ except :
43
+ continue
44
+ return msg
45
45
 
@@ -1,233 +1,233 @@
1
- import re
2
- import asyncio
3
- from typing import Type
4
- from time import sleep
5
-
6
- from nonebot import on_notice,on_command,on_regex,on_keyword,MatcherGroup
7
- from nonebot.params import CommandArg,RawCommand,CommandStart
8
- from nonebot.matcher import Matcher
9
- import nonebot
10
- from nonebot.adapters.onebot.v11 import (
11
- GroupUploadNoticeEvent,
12
- NoticeEvent,
13
- MessageEvent,
14
- Message,
15
- MessageSegment,
16
- GroupMessageEvent,
17
- )
18
-
19
- from .l4d2_anne.server import server_key,ANNE_IP
20
- from .config import *
21
- from .l4d2_queries.qqgroup import split_maohao
22
- # from .utils import qq_ip_queries_pic,json_server_to_tag_dict,get_anne_server_ip,get_tan_jian
23
- from .utils import *
24
- help_ = on_command('l4_help',aliases={'求生帮助'},priority=20,block=True)
25
-
26
- # 服务器
27
- # last_operation_time = nonebot.Config.parse_obj(nonebot.get_driver().config.dict()).SUPERUSERS
28
-
29
-
30
-
31
- def wenjian(
32
- event:NoticeEvent):
33
- args = event.dict()
34
- try:
35
- name: str = args['file']['name']
36
- usr_id = str(args['user_id'])
37
- except KeyError:
38
- return False
39
- if args['notice_type'] == 'offline_file':
40
- if l4_config.l4_master:
41
- return name.endswith(file_format) and usr_id in l4_config.l4_master
42
- else:
43
- return name.endswith(file_format)
44
- elif args['notice_type'] == 'group_upload':
45
- if l4_config.l4_master:
46
- return usr_id in l4_config.l4_master and name.endswith(file_format)
47
- else:
48
- return False
49
-
50
- up = on_notice(rule=wenjian)
51
-
52
-
53
-
54
- rename_vpk = on_regex(
55
- r"^求生地图\s*(\S+.*?)\s*(改|改名)?\s*(\S+.*?)\s*$",
56
- flags= re.S,
57
- block= True,
58
- priority= 20,
59
- permission= Master,
60
- )
61
-
62
- find_vpk = on_command("l4_map",aliases={"求生地图","查看求生地图"},priority=25,block=True)
63
- del_vpk = on_command("l4_del_map",aliases={"求生地图删除","地图删除"},priority=20,block=True,permission= Master)
64
- rcon_to_server = on_command('rcon',aliases={"求生服务器指令","服务器指令","求生服务器控制台"},block=True,permission= Master)
65
- check_path = on_command('l4_check',aliases={'求生路径'},priority=20,block=True,permission= Master)
66
- smx_file = on_command('l4_smx',aliases={'求生插件'},priority=20,block=True,permission= Master)
67
-
68
- # anne
69
- anne_player = on_command('Ranne',aliases={"求生anne"},priority=25,block=True)
70
- anne_bind = on_command('Rbind',aliases={'steam绑定','求生绑定','anne绑定'},priority=20,block=True)
71
- del_bind = on_command('del_bind',aliases={'steam解绑','求生解绑','anne解绑'},priority=20,block=True)
72
- prison = on_command('zl',aliases={'坐牢'},priority=20,block=True)
73
- open_prison = on_command('kl',aliases={'开牢'},priority=20,block=True)
74
-
75
- # updata = on_command('updata',aliases={'求生更新'},priority=20,block=True,permission= Master)
76
- tan_jian = on_command('tj',aliases={'探监'},priority=20,block=True)
77
-
78
- # 查询
79
- queries = on_command('queries',aliases={'求生ip','求生IP'},priority=20,block=True)
80
- add_queries = on_command('addq',aliases={"求生添加订阅"},priority=20,block=True,permission= Master)
81
- del_queries = on_command('delq',aliases={"求生取消订阅"},priority=20,block=True,permission= Master)
82
- show_queries = on_command('showq',aliases={"求生订阅"},priority=20,block=True)
83
- join_server = on_command('ld_jr',aliases={"求生加入"},priority=20,block=True)
84
- connect_rcon = on_command("Rrcon", aliases={"求生连接", '求生链接','求生rcon'}, priority=50, block=False)
85
- end_connect = ['stop', '结束', '连接结束', '结束连接']
86
- search_api = on_command('search',aliases={'求生三方'}, priority=20, block=True,permission= Master)
87
- which_map = on_keyword(("是什么图"),priority=20, block=False)
88
- reload_ip = on_command('l4_reload',aliases={'重载ip'},priority=30,permission=Master)
89
-
90
- # 下载内容
91
- up_workshop = on_command('workshop',aliases={'创意工坊下载','求生创意工坊'},priority=20,block=True)
92
- vtf_make = on_command('vtf_make',aliases={'求生喷漆'},priority=20,block=True)
93
-
94
- @help_.handle()
95
- async def _():
96
- msg = [
97
- '=====求生机器人帮助=====',
98
- '1、电信服战绩查询【求生anne[id/steamid/@]】',
99
- '2、电信服绑定【求生绑定[id/steamid]】',
100
- '3、电信服状态查询【云xx】'
101
- '4、创意工坊下载【创意工坊下载[物品id/链接]】',
102
- '5、指定ip查询【求生ip[ip]】(可以是域名)',
103
- '6、求生喷漆制作【求生喷漆】',
104
- '6、本地服务器操作(略,详情看项目地址)',
105
- ]
106
- messgae = ''
107
- for i in msg:
108
- messgae += i + '\n'
109
- await help_.finish(messgae)
110
-
111
- def get_session_id(event: MessageEvent) -> str:
112
- if isinstance(event, GroupMessageEvent):
113
- return f"group_{event.group_id}"
114
- else:
115
- return f"private_{event.user_id}"
116
-
117
- matchers: Dict[str, List[Type[Matcher]]] = {}
118
-
119
-
120
-
121
- async def get_des_ip():
122
- global ALL_HOST
123
- global ANNE_IP
124
- global matchers
125
- if l4_config.l4_tag == None:
126
- pass
127
- else:
128
- # try:
129
- # qq = l4_config.l4_master[0]
130
- # except:
131
- # qq = list(nonebot.get_bot().config.superusers)[0]
132
- # ALL_HOST.update(await seach_map(msg = l4_config.l4_tag,qq = qq, key=l4_config.l4_key,mode='ip'))
133
- def count_ips(ip_dict:dict):
134
- global ANNE_IP
135
- for key, value in ip_dict.items():
136
- if key in ['error_','success_']:
137
- ip_dict.pop(key)
138
- break
139
- count = len(value)
140
- logger.info(f'已加载:{key} | {count}个')
141
- if key == '云':
142
- ANNE_IP = {key:value}
143
- sleep(1)
144
- count_ips(ALL_HOST)
145
- ip_anne_list=[]
146
- try:
147
- ips = ALL_HOST['云']
148
- ip_anne_list = []
149
- for one_ip in ips:
150
- host,port = split_maohao(one_ip['ip'])
151
- ip_anne_list.append((one_ip['id'],host,port))
152
- except KeyError:
153
- pass
154
-
155
-
156
- get_ip = on_command('anne',aliases=server_key(),priority=80,block=True)
157
- @get_ip.handle()
158
- async def _(matcher:Matcher,start:str = CommandStart(),command: str = RawCommand(),args:Message = CommandArg()):
159
- global matchers
160
- if get_ip.plugin_name not in matchers:
161
- matchers[get_ip.plugin_name] = []
162
- matchers[get_ip.plugin_name].append(get_ip)
163
- if start:
164
- command = command.replace(start,'')
165
- if command == 'anne':
166
- command = '云'
167
- msg:str = args.extract_plain_text()
168
- if not msg:
169
- # 以图片输出全部当前
170
- if command in gamemode_list:
171
- this_ips = [d for l in ALL_HOST.values() for d in l if d.get('version') == command]
172
- igr = True
173
- else:
174
- this_ips:list = ALL_HOST[command]
175
- igr = False
176
- if not this_ips:
177
- matcher.finish('')
178
- ip_list = []
179
- for one_ip in this_ips:
180
- host,port = split_maohao(one_ip['ip'])
181
- ip_list.append((one_ip['id'],host,port))
182
- img = await qq_ip_queries_pic(ip_list,igr)
183
- if img:
184
- await matcher.finish(MessageSegment.image(img))
185
- else:
186
- await matcher.finish("服务器无响应")
187
- else:
188
- if not msg[0].isdigit():
189
- if any(mode in msg for mode in gamemode_list):
190
- pass
191
- else:
192
- return
193
- message = await json_server_to_tag_dict(command,msg)
194
- if len(message) == 0:
195
- # 关键词不匹配,忽略
196
- return
197
- ip = str(message['ip'])
198
- logger.info(ip)
199
- try:
200
- msg= await get_anne_server_ip(ip)
201
- await matcher.finish(msg)
202
- except (OSError,asyncio.exceptions.TimeoutError):
203
- await matcher.finish('服务器无响应')
204
-
205
-
206
- @tan_jian.handle()
207
- async def _(matcher:Matcher,event:MessageEvent):
208
- msg = await get_tan_jian(ip_anne_list,1)
209
- await matcher.finish(msg)
210
-
211
- @prison.handle()
212
- async def _(matcher:Matcher,event:MessageEvent):
213
- msg = await get_tan_jian(ip_anne_list,2)
214
- await matcher.finish(msg)
215
-
216
- @open_prison.handle()
217
- async def _(matcher:Matcher,event:MessageEvent):
218
-
219
- msg = await get_tan_jian(ip_anne_list,3)
220
- await matcher.finish(msg)
221
-
222
-
223
-
224
- async def init():
225
- global matchers
226
- # print('启动辣')
227
- await get_des_ip()
228
-
229
-
230
-
231
- @driver.on_bot_connect
232
- async def _():
1
+ import re
2
+ import asyncio
3
+ from typing import Type
4
+ from time import sleep
5
+
6
+ from nonebot import on_notice,on_command,on_regex,on_keyword,MatcherGroup
7
+ from nonebot.params import CommandArg,RawCommand,CommandStart
8
+ from nonebot.matcher import Matcher
9
+ import nonebot
10
+ from nonebot.adapters.onebot.v11 import (
11
+ GroupUploadNoticeEvent,
12
+ NoticeEvent,
13
+ MessageEvent,
14
+ Message,
15
+ MessageSegment,
16
+ GroupMessageEvent,
17
+ )
18
+
19
+ from .l4d2_anne.server import server_key,ANNE_IP
20
+ from .config import *
21
+ from .l4d2_queries.qqgroup import split_maohao
22
+ # from .utils import qq_ip_queries_pic,json_server_to_tag_dict,get_anne_server_ip,get_tan_jian
23
+ from .utils import *
24
+ help_ = on_command('l4_help',aliases={'求生帮助'},priority=20,block=True)
25
+
26
+ # 服务器
27
+ # last_operation_time = nonebot.Config.parse_obj(nonebot.get_driver().config.dict()).SUPERUSERS
28
+
29
+
30
+
31
+ def wenjian(
32
+ event:NoticeEvent):
33
+ args = event.dict()
34
+ try:
35
+ name: str = args['file']['name']
36
+ usr_id = str(args['user_id'])
37
+ except KeyError:
38
+ return False
39
+ if args['notice_type'] == 'offline_file':
40
+ if l4_config.l4_master:
41
+ return name.endswith(file_format) and usr_id in l4_config.l4_master
42
+ else:
43
+ return name.endswith(file_format)
44
+ elif args['notice_type'] == 'group_upload':
45
+ if l4_config.l4_master:
46
+ return usr_id in l4_config.l4_master and name.endswith(file_format)
47
+ else:
48
+ return False
49
+
50
+ up = on_notice(rule=wenjian)
51
+
52
+
53
+
54
+ rename_vpk = on_regex(
55
+ r"^求生地图\s*(\S+.*?)\s*(改|改名)?\s*(\S+.*?)\s*$",
56
+ flags= re.S,
57
+ block= True,
58
+ priority= 20,
59
+ permission= Master,
60
+ )
61
+
62
+ find_vpk = on_command("l4_map",aliases={"求生地图","查看求生地图"},priority=25,block=True)
63
+ del_vpk = on_command("l4_del_map",aliases={"求生地图删除","地图删除"},priority=20,block=True,permission= Master)
64
+ rcon_to_server = on_command('rcon',aliases={"求生服务器指令","服务器指令","求生服务器控制台"},block=True,permission= Master)
65
+ check_path = on_command('l4_check',aliases={'求生路径'},priority=20,block=True,permission= Master)
66
+ smx_file = on_command('l4_smx',aliases={'求生插件'},priority=20,block=True,permission= Master)
67
+
68
+ # anne
69
+ anne_player = on_command('Ranne',aliases={"求生anne"},priority=25,block=True)
70
+ anne_bind = on_command('Rbind',aliases={'steam绑定','求生绑定','anne绑定'},priority=20,block=True)
71
+ del_bind = on_command('del_bind',aliases={'steam解绑','求生解绑','anne解绑'},priority=20,block=True)
72
+ prison = on_command('zl',aliases={'坐牢'},priority=20,block=True)
73
+ open_prison = on_command('kl',aliases={'开牢'},priority=20,block=True)
74
+
75
+ # updata = on_command('updata',aliases={'求生更新'},priority=20,block=True,permission= Master)
76
+ tan_jian = on_command('tj',aliases={'探监'},priority=20,block=True)
77
+
78
+ # 查询
79
+ queries = on_command('queries',aliases={'求生ip','求生IP'},priority=20,block=True)
80
+ add_queries = on_command('addq',aliases={"求生添加订阅"},priority=20,block=True,permission= Master)
81
+ del_queries = on_command('delq',aliases={"求生取消订阅"},priority=20,block=True,permission= Master)
82
+ show_queries = on_command('showq',aliases={"求生订阅"},priority=20,block=True)
83
+ join_server = on_command('ld_jr',aliases={"求生加入"},priority=20,block=True)
84
+ connect_rcon = on_command("Rrcon", aliases={"求生连接", '求生链接','求生rcon'}, priority=50, block=False)
85
+ end_connect = ['stop', '结束', '连接结束', '结束连接']
86
+ search_api = on_command('search',aliases={'求生三方'}, priority=20, block=True,permission= Master)
87
+ which_map = on_keyword(("是什么图"),priority=20, block=False)
88
+ reload_ip = on_command('l4_reload',aliases={'重载ip'},priority=30,permission=Master)
89
+
90
+ # 下载内容
91
+ up_workshop = on_command('workshop',aliases={'创意工坊下载','求生创意工坊'},priority=20,block=True)
92
+ vtf_make = on_command('vtf_make',aliases={'求生喷漆'},priority=20,block=True)
93
+
94
+ @help_.handle()
95
+ async def _():
96
+ msg = [
97
+ '=====求生机器人帮助=====',
98
+ '1、电信服战绩查询【求生anne[id/steamid/@]】',
99
+ '2、电信服绑定【求生绑定[id/steamid]】',
100
+ '3、电信服状态查询【云xx】'
101
+ '4、创意工坊下载【创意工坊下载[物品id/链接]】',
102
+ '5、指定ip查询【求生ip[ip]】(可以是域名)',
103
+ '6、求生喷漆制作【求生喷漆】',
104
+ '6、本地服务器操作(略,详情看项目地址)',
105
+ ]
106
+ messgae = ''
107
+ for i in msg:
108
+ messgae += i + '\n'
109
+ await help_.finish(messgae)
110
+
111
+ def get_session_id(event: MessageEvent) -> str:
112
+ if isinstance(event, GroupMessageEvent):
113
+ return f"group_{event.group_id}"
114
+ else:
115
+ return f"private_{event.user_id}"
116
+
117
+ matchers: Dict[str, List[Type[Matcher]]] = {}
118
+
119
+
120
+
121
+ async def get_des_ip():
122
+ global ALL_HOST
123
+ global ANNE_IP
124
+ global matchers
125
+ if l4_config.l4_tag == None:
126
+ pass
127
+ else:
128
+ # try:
129
+ # qq = l4_config.l4_master[0]
130
+ # except:
131
+ # qq = list(nonebot.get_bot().config.superusers)[0]
132
+ # ALL_HOST.update(await seach_map(msg = l4_config.l4_tag,qq = qq, key=l4_config.l4_key,mode='ip'))
133
+ def count_ips(ip_dict:dict):
134
+ global ANNE_IP
135
+ for key, value in ip_dict.items():
136
+ if key in ['error_','success_']:
137
+ ip_dict.pop(key)
138
+ break
139
+ count = len(value)
140
+ logger.info(f'已加载:{key} | {count}个')
141
+ if key == '云':
142
+ ANNE_IP = {key:value}
143
+ sleep(1)
144
+ count_ips(ALL_HOST)
145
+ ip_anne_list=[]
146
+ try:
147
+ ips = ALL_HOST['云']
148
+ ip_anne_list = []
149
+ for one_ip in ips:
150
+ host,port = split_maohao(one_ip['ip'])
151
+ ip_anne_list.append((one_ip['id'],host,port))
152
+ except KeyError:
153
+ pass
154
+
155
+
156
+ get_ip = on_command('anne',aliases=server_key(),priority=80,block=True)
157
+ @get_ip.handle()
158
+ async def _(matcher:Matcher,start:str = CommandStart(),command: str = RawCommand(),args:Message = CommandArg()):
159
+ global matchers
160
+ if get_ip.plugin_name not in matchers:
161
+ matchers[get_ip.plugin_name] = []
162
+ matchers[get_ip.plugin_name].append(get_ip)
163
+ if start:
164
+ command = command.replace(start,'')
165
+ if command == 'anne':
166
+ command = '云'
167
+ msg:str = args.extract_plain_text()
168
+ if not msg:
169
+ # 以图片输出全部当前
170
+ if command in gamemode_list:
171
+ this_ips = [d for l in ALL_HOST.values() for d in l if d.get('version') == command]
172
+ igr = True
173
+ else:
174
+ this_ips:list = ALL_HOST[command]
175
+ igr = False
176
+ if not this_ips:
177
+ matcher.finish('')
178
+ ip_list = []
179
+ for one_ip in this_ips:
180
+ host,port = split_maohao(one_ip['ip'])
181
+ ip_list.append((one_ip['id'],host,port))
182
+ img = await qq_ip_queries_pic(ip_list,igr)
183
+ if img:
184
+ await matcher.finish(MessageSegment.image(img))
185
+ else:
186
+ await matcher.finish("服务器无响应")
187
+ else:
188
+ if not msg[0].isdigit():
189
+ if any(mode in msg for mode in gamemode_list):
190
+ pass
191
+ else:
192
+ return
193
+ message = await json_server_to_tag_dict(command,msg)
194
+ if len(message) == 0:
195
+ # 关键词不匹配,忽略
196
+ return
197
+ ip = str(message['ip'])
198
+ logger.info(ip)
199
+ try:
200
+ msg= await get_anne_server_ip(ip)
201
+ await matcher.finish(msg)
202
+ except (OSError,asyncio.exceptions.TimeoutError):
203
+ await matcher.finish('服务器无响应')
204
+
205
+
206
+ @tan_jian.handle()
207
+ async def _(matcher:Matcher,event:MessageEvent):
208
+ msg = await get_tan_jian(ip_anne_list,1)
209
+ await matcher.finish(msg)
210
+
211
+ @prison.handle()
212
+ async def _(matcher:Matcher,event:MessageEvent):
213
+ msg = await get_tan_jian(ip_anne_list,2)
214
+ await matcher.finish(msg)
215
+
216
+ @open_prison.handle()
217
+ async def _(matcher:Matcher,event:MessageEvent):
218
+
219
+ msg = await get_tan_jian(ip_anne_list,3)
220
+ await matcher.finish(msg)
221
+
222
+
223
+
224
+ async def init():
225
+ global matchers
226
+ # print('启动辣')
227
+ await get_des_ip()
228
+
229
+
230
+
231
+ @driver.on_bot_connect
232
+ async def _():
233
233
  await init()