nonebot-plugin-splatoon3-schedule 2.0.6__tar.gz → 2.0.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/PKG-INFO +21 -20
  2. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/README.md +1 -0
  3. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/__init__.py +75 -35
  4. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/check.py +63 -0
  5. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/config.py +3 -0
  6. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/data/__init__.py +1 -0
  7. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/data/data_source.py +162 -63
  8. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/data/db_image.py +38 -5
  9. nonebot_plugin_splatoon3_schedule-2.0.8/nonebot_plugin_splatoon3_schedule/data/playwright_handler.py +437 -0
  10. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/data/static_data_getter.py +1 -3
  11. nonebot_plugin_splatoon3_schedule-2.0.8/nonebot_plugin_splatoon3_schedule/data/utils.py +47 -0
  12. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/image/image.py +70 -11
  13. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/image/image_processer.py +63 -20
  14. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/db/image.db +0 -0
  15. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/util.py +31 -31
  16. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/utils/cos_upload.py +110 -64
  17. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/utils/translation.py +207 -6
  18. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/utils/utils.py +32 -8
  19. nonebot_plugin_splatoon3_schedule-2.0.8/pyproject.toml +56 -0
  20. nonebot_plugin_splatoon3_schedule-2.0.6/LICENSE +0 -21
  21. nonebot_plugin_splatoon3_schedule-2.0.6/pyproject.toml +0 -37
  22. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/data/db_control.py +0 -0
  23. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/image/__init__.py +0 -0
  24. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/image/image_processer_tools.py +0 -0
  25. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10024.png +0 -0
  26. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10025.ico +0 -0
  27. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10026.png +0 -0
  28. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/AREA.png +0 -0
  29. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/CLAM.png +0 -0
  30. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Cohozuna.png +0 -0
  31. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/GOAL.png +0 -0
  32. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Horrorboros.png +0 -0
  33. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/LOFT.png +0 -0
  34. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Megalodontia.png +0 -0
  35. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Random.png +0 -0
  36. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked-Challenge.png +0 -0
  37. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked-Open.png +0 -0
  38. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked.png +0 -0
  39. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Regular.png +0 -0
  40. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/TURF_WAR.png +0 -0
  41. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Triumvirate.png +0 -0
  42. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/X.png +0 -0
  43. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg.png +0 -0
  44. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg2.png +0 -0
  45. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg3.png +0 -0
  46. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/big_run.png +0 -0
  47. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/black-texture.png +0 -0
  48. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/cat_paw_mask.png +0 -0
  49. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop.png +0 -0
  50. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_bg2.png +0 -0
  51. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_fish.png +0 -0
  52. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_mask.png +0 -0
  53. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/event_bg.png +0 -0
  54. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/festival_mask.png +0 -0
  55. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/fight_mask.png +0 -0
  56. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/filleted_corner.png +0 -0
  57. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/private.png +0 -0
  58. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/swim_ring.png +0 -0
  59. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/team_coop.png +0 -0
  60. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/time_head_bg.png +0 -0
  61. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/font/Splatfont1.otf +0 -0
  62. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/font/Splatfont2.otf +0 -0
  63. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/font/cn.ttf +0 -0
  64. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/font/common.otf +0 -0
  65. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/utils/__init__.py +0 -0
  66. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/utils/bot.py +0 -0
  67. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/utils/dataClass.py +0 -0
@@ -1,11 +1,9 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.3
2
2
  Name: nonebot-plugin-splatoon3-schedule
3
- Version: 2.0.6
3
+ Version: 2.0.8
4
4
  Summary: 一个基于nonebot2框架的splatoon3游戏日程查询插件
5
- License-File: LICENSE
6
5
  Author: cypas
7
- Author-email: ayano05@outlook.com
8
- Requires-Python: >=3.9,<4.0
6
+ Author-email: cypas <ayano05@outlook.com>
9
7
  Classifier: Programming Language :: Python :: 3
10
8
  Classifier: Programming Language :: Python :: 3.9
11
9
  Classifier: Programming Language :: Python :: 3.10
@@ -13,20 +11,23 @@ Classifier: Programming Language :: Python :: 3.11
13
11
  Classifier: Programming Language :: Python :: 3.12
14
12
  Classifier: Programming Language :: Python :: 3.13
15
13
  Classifier: Programming Language :: Python :: 3.14
16
- Requires-Dist: Pillow (>=11.3.0,<12.0.0)
17
- Requires-Dist: beautifulsoup4 (>=4.12.2,<5.0.0)
18
- Requires-Dist: cloudscraper (>=1.2.71,<2.0.0)
19
- Requires-Dist: cos_python_sdk_v5 (>=1.9.30,<2.0.0)
20
- Requires-Dist: httpx (>=0.28.1,<0.29.0)
21
- Requires-Dist: nonebot-adapter-kaiheila (>=0.3.4,<0.4.0)
22
- Requires-Dist: nonebot-adapter-onebot (>=2.4.6,<3.0.0)
23
- Requires-Dist: nonebot-adapter-qq (>=1.6.6,<2.0.0)
24
- Requires-Dist: nonebot-adapter-telegram (>=0.1.0b20,<0.2.0)
25
- Requires-Dist: nonebot-plugin-apscheduler (>=0.5.0,<0.6.0)
26
- Requires-Dist: nonebot2 (>=2.4.4,<3.0.0)
27
- Requires-Dist: nonebot_plugin_datastore (>=1.3.0,<2.0.0)
28
- Requires-Dist: playwright (>=1.40.0,<2.0.0)
29
- Requires-Dist: pydantic (>=1.0.0,<3.0.0,!=2.5.0,!=2.5.1)
14
+ Requires-Dist: beautifulsoup4>=4.12.2,<5
15
+ Requires-Dist: cloudscraper>=1.2.71,<2
16
+ Requires-Dist: httpx>=0.28.1,<0.29
17
+ Requires-Dist: nonebot2>=2.4.4,<3
18
+ Requires-Dist: pydantic>=1.0.0,!=2.5.0,!=2.5.1,<3.0.0
19
+ Requires-Dist: pillow>=11.3.0,<12
20
+ Requires-Dist: playwright>=1.40.0,<2
21
+ Requires-Dist: playwright-stealth>=2.0.3
22
+ Requires-Dist: nonebot-adapter-onebot>=2.4.6,<3
23
+ Requires-Dist: nonebot-adapter-telegram>=0.1.0b20,<0.2
24
+ Requires-Dist: nonebot-adapter-kaiheila>=0.3.4,<0.4
25
+ Requires-Dist: nonebot-adapter-qq>=1.6.7,<2
26
+ Requires-Dist: nonebot-plugin-apscheduler>=0.5.0,<0.6
27
+ Requires-Dist: nonebot-plugin-datastore>=1.3.0,<2
28
+ Requires-Dist: cos-python-sdk-v5>=1.9.30,<2
29
+ Requires-Dist: zhconv>=1.4.3,<2
30
+ Requires-Python: >=3.9, <4
30
31
  Description-Content-Type: text/markdown
31
32
 
32
33
  <div align="center">
@@ -199,8 +200,8 @@ splatoon3_schedule_plugin_priority_mode = False #日程插件的帮助菜单优
199
200
 
200
201
  - https://splatoon3.ink 日程数据来源
201
202
  - https://splatoonwiki.org 武器数据来源
203
+ - https://sendou.ink/builds 武器配装数据来源
202
204
 
203
205
  ## ⏳ Star 趋势
204
206
 
205
207
  [![Stargazers over time](https://starchart.cc/Cypas/splatoon3-schedule.svg)](https://starchart.cc/Cypas/splatoon3-schedule)
206
-
@@ -168,6 +168,7 @@ splatoon3_schedule_plugin_priority_mode = False #日程插件的帮助菜单优
168
168
 
169
169
  - https://splatoon3.ink 日程数据来源
170
170
  - https://splatoonwiki.org 武器数据来源
171
+ - https://sendou.ink/builds 武器配装数据来源
171
172
 
172
173
  ## ⏳ Star 趋势
173
174
 
@@ -35,6 +35,7 @@ matcher_stage_group = on_regex(
35
35
  async def _(bot: Bot, event: Event):
36
36
  plain_text = event.get_message().extract_plain_text().strip()
37
37
  # 触发关键词 替换.。\/ 等前缀触发词
38
+ plain_text = str_convert_to_simplified(plain_text)
38
39
  plain_text = multiple_replace(plain_text, dict_keyword_replace)
39
40
  logger.info("同义文本替换后触发词为:" + plain_text)
40
41
  # 判断是否满足进一步正则
@@ -99,6 +100,7 @@ matcher_stage = on_regex(
99
100
  async def _(bot: Bot, event: Event, re_tuple: Tuple = RegexGroup()):
100
101
  re_list = []
101
102
  for k, v in enumerate(re_tuple):
103
+ v = str_convert_to_simplified(v)
102
104
  # 遍历正则匹配字典进行替换文本
103
105
  re_list.append(dict_keyword_replace.get(v, v))
104
106
  logger.info("同义文本替换后触发词组为:" + json.dumps(re_list, ensure_ascii=False))
@@ -194,6 +196,7 @@ matcher_coop = on_regex(
194
196
  @matcher_coop.handle(parameterless=[Depends(_permission_check)])
195
197
  async def _(bot: Bot, event: Event):
196
198
  plain_text = event.get_message().extract_plain_text().strip()
199
+ plain_text = str_convert_to_simplified(plain_text)
197
200
  # 触发关键词 替换.。\/ 等前缀触发词
198
201
  plain_text = multiple_replace(plain_text, dict_keyword_replace)
199
202
  logger.info("同义文本替换后触发词为:" + plain_text)
@@ -211,7 +214,7 @@ async def _(bot: Bot, event: Event):
211
214
 
212
215
  # 配装 触发器
213
216
  matcher_build = on_regex(
214
- "^[\\/.,,。]?配装\s{0,2}([\\u4e00-\\u9fa5a-zA-Z0-9·-]{2,20}?(\s(装饰|改装|联名|新型|新艺术|金属箔|精英|精英装饰|姐妹|高磁波|墨黑|薄荷|黑|白|甲|乙))?)?\s?(区域|区|推塔|抢塔|塔楼|塔|蛤蜊|蛤|抢鱼|鱼虎|鱼|涂地|涂涂|涂)?$",
217
+ "^[\\/.,,。]{0,1}配装[\s ]{0,2}([\u4e00-\u9fa5a-zA-Z0-9·\-/\s ]{0,20})$",
215
218
  priority=8,
216
219
  block=True,
217
220
  )
@@ -220,45 +223,80 @@ matcher_build = on_regex(
220
223
  # 配装 触发器处理
221
224
  @matcher_build.handle(parameterless=[Depends(_permission_check)])
222
225
  async def _(bot: Bot, event: Event, re_tuple: Tuple = RegexGroup()):
223
- re_list = []
224
- for k, v in enumerate(re_tuple):
225
- # 遍历正则匹配字典进行替换文本
226
- if k == 0:
227
- # 武器名
228
- if v:
229
- v = v.upper()
230
- v = multiple_replace(v, dict_builds_pre_replace)
231
- re_list.append(v)
232
- if k == len(re_tuple) - 1:
233
- # 模式
234
- value = dict_keyword_replace.get(v, v)
235
- re_list.append(value)
236
- logger.info("同义文本替换后触发参数为:" + json.dumps(re_list, ensure_ascii=False))
237
-
238
- if not re_list[0]:
239
- msg = "请携带需要查询的武器或模式信息作为参数,若为贴牌需要加上贴牌二字,如:\n/配装 小绿\n指定模式查询:\n/配装 贴牌碳刷 塔楼"
226
+ # 分两步处理,外层只过滤前缀,将关键词分离出来
227
+ keywords = re_tuple[0]
228
+ keywords = str(keywords).strip()
229
+ # 第二步再处理是否有模式选项
230
+ # 场景词列表(按长度从长到短排序,优先匹配长词)
231
+ mode_words = [
232
+ "推塔",
233
+ "抢塔",
234
+ "塔楼",
235
+ "蛤蜊",
236
+ "抢鱼",
237
+ "鱼虎",
238
+ "涂地",
239
+ "涂涂",
240
+ "区域",
241
+ "区",
242
+ "塔",
243
+ "蛤",
244
+ "鱼",
245
+ "涂",
246
+ ]
247
+ # 第二步场景词剥离正则(核心:匹配末尾的最长场景词)
248
+ # 动态生成正则:(场景词1|场景词2|...) (长词在前)
249
+ mode_pattern = rf"^(.*?)({'|'.join(mode_words)})$"
250
+ scene_regex = re.compile(mode_pattern)
251
+ # 第二步:用正则剥离末尾的场景词
252
+ middle_text = keywords # 默认中间文本=原关键词(无场景词)
253
+ scene = None # 默认无场景词
254
+
255
+ # 匹配末尾的场景词
256
+ scene_match = scene_regex.match(keywords)
257
+ if scene_match:
258
+ # 提取剥离场景词后的中间文本(去首尾空格)
259
+ temp_middle = scene_match.group(1).strip()
260
+ # 校验中间文本长度≥2(核心约束)
261
+ if len(temp_middle) >= 2:
262
+ middle_text = temp_middle
263
+ scene = scene_match.group(2)
264
+
265
+ # 武器名过滤
266
+ middle_text = middle_text.upper()
267
+ middle_text = str_convert_to_simplified(middle_text)
268
+ middle_text = multiple_replace(middle_text, dict_builds_pre_replace)
269
+ if scene:
270
+ scene = dict_keyword_replace.get(scene, scene)
271
+
272
+ logger.info(f"同义文本替换后武器:{middle_text},模式:{scene or '全部'}")
273
+
274
+ if not middle_text:
275
+ msg = "请携带需要查询的武器或模式信息作为参数,若为贴牌需要加上贴牌二字,新贴牌需要加上'新贴牌' 或 '彩牌',如:\n/配装 小绿\n指定模式查询:\n/配装 贴牌碳刷 塔楼"
240
276
  await send_msg(bot, event, msg)
241
277
  return
242
278
 
243
279
  # 整理参数
244
- is_deco = False
245
- mode = None
246
- weapon_name = re_list[0]
247
- if "贴牌" in weapon_name:
248
- is_deco = True
280
+ is_deco = 0
281
+ weapon_name = middle_text
282
+ if "新贴牌" in weapon_name or "彩牌" in weapon_name:
283
+ is_deco = 2
284
+ weapon_name = weapon_name.replace("新贴牌", "").replace("彩牌", "")
285
+ elif "贴牌" in weapon_name:
286
+ is_deco = 1
249
287
  weapon_name = weapon_name.replace("贴牌", "")
250
288
 
251
289
  # 查询对应武器
252
290
  build_info = db_image.get_build_info(weapon_name, is_deco)
253
291
  if not build_info:
254
- msg = f"该关键词 {weapon_name} 未查询到对应武器,请试试使用官方中文武器名称或其他常用名称后再试,若为贴牌需要加上贴牌二字,如:\n/配装 小绿\n指定模式查询:\n/配装 贴牌碳刷 塔楼"
255
- logger.warning(f"该关键词未匹配到武器 {weapon_name}")
292
+ msg = f"该关键词 {middle_text} 未查询到对应武器,请试试使用官方中文武器名称或其他常用名称后再试,若为贴牌需要加上'贴牌'二字,新贴牌需要加上'新贴牌' 或 '彩牌',如:\n/配装 小绿\n指定模式查询:\n/配装 贴牌碳刷 塔楼"
293
+ logger.warning(f"该关键词未匹配到武器 {middle_text}")
256
294
  # 未匹配武器写到指定文件
257
295
  file_path = Path(os.path.join(DIR_RESOURCE, "未匹配武器.txt"))
258
296
  os.makedirs(os.path.dirname(file_path), exist_ok=True)
259
297
  # 以追加模式打开文件,编码指定为utf-8(避免中文乱码)
260
298
  with open(file_path, "a", encoding="utf-8") as f:
261
- f.write(f"{weapon_name}\n") # 每行一个关键词
299
+ f.write(f"{middle_text}\n") # 每行一个关键词
262
300
 
263
301
  await send_msg(bot, event, msg)
264
302
  return
@@ -266,24 +304,23 @@ async def _(bot: Bot, event: Event, re_tuple: Tuple = RegexGroup()):
266
304
  sendou_name: str = build_info.get("sendou_name")
267
305
 
268
306
  plain_text = "配装"
269
- re_list[0] = f'{zh_name.replace(" ", "")}'
270
- plain_text = f"{plain_text} {re_list[0]}"
271
- if re_list[1]:
272
- plain_text = f"{plain_text} {re_list[1]}"
307
+ zh_name = f'{zh_name.replace(" ", "")}'
308
+ plain_text += f" {zh_name}"
309
+ if scene:
310
+ plain_text += f" {scene}"
273
311
 
274
312
  # mode
275
- if re_list[1]:
276
- mode = re_list[1]
277
- mode_str = mode
313
+ if scene:
314
+ mode_str = scene
278
315
  else:
279
316
  mode_str = "全部"
280
- msg = f"正在获取武器 {re_list[0]} 在 {mode_str}模式下的配装推荐,请稍等..."
317
+ msg = f"正在获取武器 {zh_name} 在 {mode_str}模式下的配装推荐,请稍等..."
281
318
  await send_msg(bot, event, msg)
282
319
 
283
320
  # 传递函数指针
284
321
  func = get_build_image
285
322
  # 获取图片
286
- is_cache, img = await get_save_temp_image(plain_text, func, sendou_name, mode)
323
+ is_cache, img = await get_save_temp_image(plain_text, func, sendou_name, mode_str)
287
324
  # 发送图片
288
325
  await send_msg(bot, event, img, is_cache=is_cache)
289
326
 
@@ -300,6 +337,7 @@ matcher_else = on_regex(
300
337
  @matcher_else.handle(parameterless=[Depends(_permission_check)])
301
338
  async def _(bot: Bot, event: Event):
302
339
  plain_text = event.get_message().extract_plain_text().strip()
340
+ plain_text = str_convert_to_simplified(plain_text)
303
341
  # 触发关键词 替换.。\/ 等前缀触发词
304
342
  plain_text = multiple_replace(plain_text, dict_prefix_replace)
305
343
  plain_text = plain_text.replace("help", "帮助")
@@ -376,6 +414,7 @@ matcher_manage = on_regex(
376
414
  async def _(bot: Bot, event: Event, state: T_State, re_tuple: Tuple = RegexGroup()):
377
415
  re_list = []
378
416
  for k, v in enumerate(re_tuple):
417
+ v = str_convert_to_simplified(v)
379
418
  re_list.append(v)
380
419
  # 触发关键词 替换.。\/ 等前缀触发词
381
420
  plain_text = event.get_message().extract_plain_text().strip()
@@ -433,6 +472,7 @@ matcher_admin = on_regex(
433
472
  async def _(bot: Bot, event: Event):
434
473
  # 触发关键词 替换.。\/ 等前缀触发词
435
474
  plain_text = event.get_message().extract_plain_text().strip()
475
+ plain_text = str_convert_to_simplified(plain_text)
436
476
  plain_text = multiple_replace(plain_text, dict_prefix_replace)
437
477
  err_msg = "执行失败,错误日志为: "
438
478
  # 清空图片缓存
@@ -1,12 +1,25 @@
1
+ import time
1
2
  from typing import Union
3
+ from collections import deque
4
+ from datetime import datetime as dt, timedelta
2
5
 
6
+ from .utils.utils import get_msg_id
7
+ from .util import send_msg
3
8
  from .config import plugin_config, global_config
4
9
  from .data import db_control
10
+ from .data.utils import get_blacklist_msg_id
5
11
  from .utils.bot import *
6
12
 
7
13
  blacklist = {}
8
14
  guilds_info = {}
9
15
 
16
+ # QPS限制配置
17
+ QPS_LIMIT_COUNT = 10 # 60秒内最多请求次数
18
+ QPS_LIMIT_TIME = 60 # 时间窗口(秒)
19
+
20
+ # 用户请求时间戳记录 {user_key: deque([timestamp1, timestamp2, ...])}
21
+ user_request_times = {}
22
+
10
23
 
11
24
  def get_or_init(dictionary: dict, key: str, default=None):
12
25
  """字典赋值"""
@@ -170,6 +183,50 @@ def check_msg_permission(
170
183
  return True
171
184
 
172
185
 
186
+ async def _check_session_blacklist_handler(bot: Bot, event: Event, matcher: Matcher):
187
+ """校验用户是否在黑名单"""
188
+ platform = bot.adapter.get_name()
189
+ user_id = event.get_user_id()
190
+ user_key = get_msg_id(platform, user_id)
191
+ # 黑名单列表
192
+ black_l = await get_blacklist_msg_id()
193
+ if user_key in black_l:
194
+ msg = "你已无权使用小鱿鱿bot,若存在误封,请联系q群827977720"
195
+ logger.warning(f"黑名单 {user_key} 已禁止使用bot")
196
+ await send_msg(bot, event, msg=msg)
197
+ matcher.stop_propagation()
198
+ await matcher.finish()
199
+
200
+
201
+ async def _check_session_qps_limit_handler(bot: Bot, event: Event, matcher: Matcher):
202
+ """校验用户请求qps"""
203
+ platform = bot.adapter.get_name()
204
+ user_id = event.get_user_id()
205
+ user_key = get_msg_id(platform, user_id)
206
+
207
+ # QPS检测
208
+ current_time = time.time()
209
+ if user_key not in user_request_times:
210
+ user_request_times[user_key] = deque()
211
+
212
+ # 移除超过时间窗口的记录
213
+ while (
214
+ user_request_times[user_key]
215
+ and current_time - user_request_times[user_key][0] > QPS_LIMIT_TIME
216
+ ):
217
+ user_request_times[user_key].popleft()
218
+
219
+ # 检查请求次数是否超过限制
220
+ if len(user_request_times[user_key]) >= QPS_LIMIT_COUNT:
221
+ msg = "请勿频繁请求"
222
+ await send_msg(bot, event, msg=msg)
223
+ matcher.stop_propagation()
224
+ await matcher.finish()
225
+
226
+ # 记录当前请求时间
227
+ user_request_times[user_key].append(current_time)
228
+
229
+
173
230
  async def _permission_check(bot: Bot, event: Event, matcher: Matcher, state: T_State):
174
231
  """检查消息来源权限
175
232
  return值无意义,主要是靠matcher.finish()阻断事件"""
@@ -178,6 +235,12 @@ async def _permission_check(bot: Bot, event: Event, matcher: Matcher, state: T_S
178
235
  plain_text = event.get_message().extract_plain_text().strip()
179
236
  if not plain_text.startswith("/"):
180
237
  await matcher.finish()
238
+
239
+ # xyy qps校验
240
+ await _check_session_qps_limit_handler(bot, event, matcher)
241
+ # xyy 黑名单校验
242
+ await _check_session_blacklist_handler(bot, event, matcher)
243
+
181
244
  # id定义
182
245
  default_id = 25252
183
246
  guid: Union[int, str] = default_id # 服务器id
@@ -47,6 +47,9 @@ class Config(BaseModel):
47
47
  splatoon3_qq_md_mode: bool = False
48
48
  # 腾讯云cos配置
49
49
  splatoon3_cos_config: CosConfig = Field(default_factory=CosConfig)
50
+ # Flaresolverr 服务 URL(用于绕过 Cloudflare 保护)
51
+ # 格式示例: http://localhost:8191/v1
52
+ splatoon3_cf_flaresolverr_server_url: str = ""
50
53
 
51
54
 
52
55
  # 本地测试时由于不启动 driver,需要将下面三行注释并取消再下面两行的注释
@@ -2,3 +2,4 @@ from .data_source import *
2
2
  from .db_image import *
3
3
  from .static_data_getter import *
4
4
  from .db_control import *
5
+ from .playwright_handler import *
@@ -1,11 +1,13 @@
1
- from playwright.async_api import Browser, async_playwright
1
+ import time
2
+ import random
3
+
2
4
  from playwright.sync_api import FloatRect
3
5
 
4
6
  from .db_image import db_image
7
+ from .playwright_handler import get_screenshot
5
8
  from ..utils import *
6
9
 
7
10
  schedule_res = None
8
- _browser = None
9
11
  festivals_res = None
10
12
  festivals_res_save_ymdt: str
11
13
 
@@ -267,66 +269,163 @@ def get_stage_info(num_list=None, contest_match=None, rule_match=None):
267
269
  return schedule, num_list, new_contest_match, new_rule_match
268
270
 
269
271
 
270
- async def init_browser() -> Browser:
271
- """初始化 browser 并唤起"""
272
- global _browser
273
- p = await async_playwright().start()
274
- browser_args = [
275
- # 设置默认字体
276
- '--default-font-family="Noto Sans CJK"',
277
- ]
278
- if proxy_address:
279
- proxies = {"server": "http://{}".format(proxy_address)}
280
- # 代理访问
281
- _browser = await p.chromium.launch(proxy=proxies, args=browser_args)
282
- else:
283
- _browser = await p.chromium.launch(args=browser_args)
284
- return _browser
285
-
286
-
287
- async def get_browser() -> Browser:
288
- """获取目前唤起的 browser"""
289
- global _browser
290
- if _browser is None or not _browser.is_connected():
291
- _browser = await init_browser()
292
- return _browser
293
-
294
-
295
- async def get_screenshot(
296
- shot_url,
297
- mode="pc",
298
- selector=None,
299
- shot_path=None,
300
- ) -> bytes:
301
- """通过 browser 获取 shot_url 中的网页截图"""
302
- # playwright 要求不能有多个 browser 被同时唤起
303
- browser = await get_browser()
304
- if mode == "pc":
305
- context = await browser.new_context(
306
- viewport={"width": 1920, "height": 1080}, locale="zh-CH"
307
- )
308
- elif mode == "mobile":
309
- context = await browser.new_context(
310
- viewport={"width": 500, "height": 2000}, locale="zh-CH"
272
+ def get_newest_event_or_coop():
273
+ """
274
+ 取最新活动或者团工数据
275
+ :return: 文本拼接为 (今天/明天/后天),周一X时会有(活动/团工/BigRun) (名称)
276
+ """
277
+
278
+ def check_date_relation(target_dt: datetime.datetime) -> tuple:
279
+ """
280
+ 判断指定 datetime 日期是今天/明天/后天,并返回是否近期、日期关系、周几描述
281
+
282
+ 参数:
283
+ target_dt: 待判断的 datetime 类型日期
284
+
285
+ 返回:
286
+ tuple: (是否近期, 日期关系描述, 周几描述)
287
+ 是否近期:bool类型,今天/明天/后天返回True,其他返回False
288
+ 日期关系描述:"今天" / "明天" / "后天" / "其他日期"
289
+ 周几描述:"周一" / "周二" ... / "周日"
290
+ """
291
+ # 1. 处理时区和日期截取(只保留年月日,忽略时分秒)
292
+ # 获取当前 UTC+8 时间的日期部分
293
+ today = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(
294
+ hours=8
311
295
  )
312
- page = await context.new_page()
313
-
314
- try:
315
- await page.goto(shot_url, wait_until="load", timeout=300000)
316
- await page.wait_for_timeout(1500)
317
- if selector:
318
- # 元素选择器
319
- await page.wait_for_selector(selector)
320
- element = await page.query_selector(selector)
321
- screenshot = await element.screenshot(path=shot_path)
322
- img = screenshot
296
+ today_date = today.date()
297
+
298
+ # 提取目标日期的日期部分
299
+ target_date = target_dt.date()
300
+
301
+ # 2. 计算目标日期与今天的差值(天数)
302
+ delta_days = (target_date - today_date).days
303
+
304
+ # 3. 判断日期关系和是否近期
305
+ if delta_days == 0:
306
+ date_relation = "今天"
307
+ is_recent = True
308
+ elif delta_days == 1:
309
+ date_relation = "明天"
310
+ is_recent = True
311
+ elif delta_days == 2:
312
+ date_relation = "后天"
313
+ is_recent = True
323
314
  else:
324
- img = await page.screenshot(path=shot_path)
325
-
326
- return img
327
- except Exception as e:
328
- logger.error("Screenshot failed" + str(e))
329
- # return await page.screenshot(full_page=True)
330
- raise e
331
- finally:
332
- await context.close()
315
+ date_relation = "其他日期"
316
+ is_recent = False
317
+
318
+ # 4. 计算周几
319
+ weekday_num = target_dt.weekday() # weekday() 返回 0(周一)~6(周日)
320
+ weekday_desc = "周" + dict_weekday_trans.get(weekday_num, "")
321
+
322
+ # 是否近期,今天/明天/后天,周一
323
+ return is_recent, date_relation, weekday_desc
324
+
325
+ n_event_st, n_event_name = get_newest_event_data()
326
+ n_coop_st, n_coop_name = get_newest_salmonrun_data()
327
+ n_coop_gold_st, n_coop_gold_name = get_newest_gold_random_data()
328
+ msg = ""
329
+ if n_event_st:
330
+ is_recent, date_relation, weekday_desc = check_date_relation(
331
+ time_converter(n_event_st)
332
+ )
333
+ if is_recent:
334
+ msg += f"{date_relation}{weekday_desc},{time_converter_h(n_event_st)}时开始会有活动:{n_event_name}"
335
+ if n_coop_st:
336
+ is_recent, date_relation, weekday_desc = check_date_relation(
337
+ time_converter(n_coop_st)
338
+ )
339
+ if is_recent:
340
+ if msg:
341
+ msg += "\n"
342
+ msg += f"{date_relation}{weekday_desc},{time_converter_h(n_coop_st)}时开始会有 {n_coop_name}"
343
+ if n_coop_gold_st:
344
+ is_recent, date_relation, weekday_desc = check_date_relation(
345
+ time_converter(n_coop_gold_st)
346
+ )
347
+ if is_recent:
348
+ if msg:
349
+ msg += "\n"
350
+ msg += f"{date_relation}{weekday_desc},{time_converter_h(n_coop_gold_st)}时开始会有 {n_coop_gold_name}"
351
+ return msg
352
+
353
+
354
+ def get_newest_event_data():
355
+ """
356
+ 取最新活动数据
357
+ 返回 (时间(年月日T时分秒Z),名称)
358
+ """
359
+ # 取日程
360
+ schedule = get_schedule_data()
361
+ events = schedule["eventSchedules"]["nodes"]
362
+ # 如果存在活动
363
+ if len(events) > 0:
364
+ newest_event = events[0]
365
+ # 取时间
366
+ st = newest_event["timePeriods"][0]["startTime"]
367
+ # time_converter_yd(st),
368
+ # "周" + dict_weekday_trans.get(time_converter_weekday(st))
369
+ # 取中文翻译
370
+ cht_event_data = newest_event["leagueMatchSetting"]["leagueMatchEvent"]
371
+ _id = cht_event_data["id"]
372
+ trans_cht_event_data = get_trans_cht_data()["events"][_id]
373
+ # 替换为翻译文本
374
+ cht_event_data["name"] = trans_cht_event_data.get(
375
+ "name", cht_event_data["name"]
376
+ )
377
+ event_name = cht_event_data["name"]
378
+ return st, event_name
379
+ else:
380
+ return "", ""
381
+
382
+
383
+ def get_newest_gold_random_data():
384
+ """
385
+ 取最新金工 数据
386
+ 返回 (时间(年月日T时分秒Z),名称)
387
+ """
388
+ # 取日程
389
+ schedule = get_schedule_data()
390
+ # 一般打工数据
391
+ regular_schedules = schedule["coopGroupingSchedule"]["regularSchedules"]["nodes"]
392
+ # 遍历武器看是否存在金随机 金随机的名字为 Random_747937841598fff7 绿随机 Random_01b960996da8ed63
393
+ st = ""
394
+ coop_name = "随机金工"
395
+ for idx, sch in enumerate(regular_schedules):
396
+ weapon_name = f'{sch["setting"]["weapons"][0]["name"]}_{sch["setting"]["weapons"][0]["__splatoon3ink_id"]}'
397
+ if weapon_name == "Random_747937841598fff7":
398
+ # 取出这个打工周期的时间
399
+ st = sch["startTime"]
400
+ break
401
+
402
+ return st, coop_name
403
+
404
+
405
+ def get_newest_salmonrun_data():
406
+ """
407
+ 取最新big run或者团工 数据
408
+ 返回 (时间(年月日T时分秒Z),名称)
409
+ """
410
+ # 取日程
411
+ schedule = get_schedule_data()
412
+ # 取翻译
413
+ get_trans_cht_data()
414
+ # 团队打工竞赛
415
+ team_schedule = schedule["coopGroupingSchedule"]["teamContestSchedules"]["nodes"]
416
+ # big run 数据
417
+ bigrun_schedule = schedule["coopGroupingSchedule"]["bigRunSchedules"]["nodes"]
418
+ newest_coop = None
419
+ coop_name = ""
420
+ st = ""
421
+ if len(team_schedule) > 0:
422
+ newest_coop = team_schedule[0]
423
+ coop_name = "团队打工"
424
+ elif len(bigrun_schedule) > 0:
425
+ newest_coop = bigrun_schedule[0]
426
+ coop_name = "BigRun"
427
+
428
+ if newest_coop is not None:
429
+ # coop_stage_name = get_trans_stage(newest_coop["setting"]["coopStage"]["id"])
430
+ st = newest_coop["startTime"]
431
+ return st, coop_name