nonebot-plugin-splatoon3-schedule 2.0.6__tar.gz → 2.0.7__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 (64) hide show
  1. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/PKG-INFO +2 -1
  2. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/__init__.py +75 -35
  3. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/data/data_source.py +133 -6
  4. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/data/db_image.py +1 -1
  5. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/image/image.py +27 -4
  6. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/image/image_processer.py +25 -5
  7. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/db/image.db +0 -0
  8. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/util.py +4 -3
  9. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/utils/translation.py +31 -2
  10. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/utils/utils.py +21 -8
  11. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/pyproject.toml +2 -1
  12. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/LICENSE +0 -0
  13. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/README.md +0 -0
  14. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/check.py +0 -0
  15. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/config.py +0 -0
  16. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/data/__init__.py +0 -0
  17. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/data/db_control.py +0 -0
  18. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/data/static_data_getter.py +0 -0
  19. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/image/__init__.py +0 -0
  20. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/image/image_processer_tools.py +0 -0
  21. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10024.png +0 -0
  22. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10025.ico +0 -0
  23. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10026.png +0 -0
  24. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/AREA.png +0 -0
  25. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/CLAM.png +0 -0
  26. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Cohozuna.png +0 -0
  27. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/GOAL.png +0 -0
  28. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Horrorboros.png +0 -0
  29. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/LOFT.png +0 -0
  30. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Megalodontia.png +0 -0
  31. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Random.png +0 -0
  32. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked-Challenge.png +0 -0
  33. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked-Open.png +0 -0
  34. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked.png +0 -0
  35. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Regular.png +0 -0
  36. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/TURF_WAR.png +0 -0
  37. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Triumvirate.png +0 -0
  38. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/X.png +0 -0
  39. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg.png +0 -0
  40. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg2.png +0 -0
  41. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg3.png +0 -0
  42. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/big_run.png +0 -0
  43. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/black-texture.png +0 -0
  44. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/cat_paw_mask.png +0 -0
  45. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop.png +0 -0
  46. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_bg2.png +0 -0
  47. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_fish.png +0 -0
  48. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_mask.png +0 -0
  49. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/event_bg.png +0 -0
  50. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/festival_mask.png +0 -0
  51. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/fight_mask.png +0 -0
  52. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/filleted_corner.png +0 -0
  53. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/private.png +0 -0
  54. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/swim_ring.png +0 -0
  55. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/team_coop.png +0 -0
  56. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/ImageData/time_head_bg.png +0 -0
  57. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/font/Splatfont1.otf +0 -0
  58. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/font/Splatfont2.otf +0 -0
  59. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/font/cn.ttf +0 -0
  60. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/resource/font/common.otf +0 -0
  61. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/utils/__init__.py +0 -0
  62. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/utils/bot.py +0 -0
  63. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/utils/cos_upload.py +0 -0
  64. {nonebot_plugin_splatoon3_schedule-2.0.6 → nonebot_plugin_splatoon3_schedule-2.0.7}/nonebot_plugin_splatoon3_schedule/utils/dataClass.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nonebot-plugin-splatoon3-schedule
3
- Version: 2.0.6
3
+ Version: 2.0.7
4
4
  Summary: 一个基于nonebot2框架的splatoon3游戏日程查询插件
5
5
  License-File: LICENSE
6
6
  Author: cypas
@@ -27,6 +27,7 @@ Requires-Dist: nonebot2 (>=2.4.4,<3.0.0)
27
27
  Requires-Dist: nonebot_plugin_datastore (>=1.3.0,<2.0.0)
28
28
  Requires-Dist: playwright (>=1.40.0,<2.0.0)
29
29
  Requires-Dist: pydantic (>=1.0.0,<3.0.0,!=2.5.0,!=2.5.1)
30
+ Requires-Dist: zhconv (>=1.4.3,<2.0.0)
30
31
  Description-Content-Type: text/markdown
31
32
 
32
33
  <div align="center">
@@ -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,3 +1,5 @@
1
+ import time
2
+
1
3
  from playwright.async_api import Browser, async_playwright
2
4
  from playwright.sync_api import FloatRect
3
5
 
@@ -75,8 +77,8 @@ def get_coop_info(_all=None):
75
77
  return [
76
78
  ImageInfo(
77
79
  name=sch["setting"]["weapons"][_i]["name"]
78
- + "_"
79
- + sch["setting"]["weapons"][_i]["__splatoon3ink_id"],
80
+ + "_"
81
+ + sch["setting"]["weapons"][_i]["__splatoon3ink_id"],
80
82
  url=sch["setting"]["weapons"][_i]["image"]["url"],
81
83
  zh_name=get_trans_weapon(
82
84
  sch["setting"]["weapons"][_i]["__splatoon3ink_id"]
@@ -267,6 +269,131 @@ 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
 
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(hours=8)
294
+ today_date = today.date()
295
+
296
+ # 提取目标日期的日期部分
297
+ target_date = target_dt.date()
298
+
299
+ # 2. 计算目标日期与今天的差值(天数)
300
+ delta_days = (target_date - today_date).days
301
+
302
+ # 3. 判断日期关系和是否近期
303
+ if delta_days == 0:
304
+ date_relation = "今天"
305
+ is_recent = True
306
+ elif delta_days == 1:
307
+ date_relation = "明天"
308
+ is_recent = True
309
+ elif delta_days == 2:
310
+ date_relation = "后天"
311
+ is_recent = True
312
+ else:
313
+ date_relation = "其他日期"
314
+ is_recent = False
315
+
316
+ # 4. 计算周几
317
+ weekday_num = target_dt.weekday() # weekday() 返回 0(周一)~6(周日)
318
+ weekday_desc = "周" + dict_weekday_trans.get(weekday_num, "")
319
+
320
+ # 是否近期,今天/明天/后天,周一
321
+ return is_recent, date_relation, weekday_desc
322
+
323
+ n_event_st, n_event_name = get_newest_event_data()
324
+ n_coop_st, n_coop_name = get_newest_salmonrun_data()
325
+ msg = ""
326
+ if n_event_st:
327
+ is_recent, date_relation, weekday_desc = check_date_relation(time_converter(n_event_st))
328
+ if is_recent:
329
+ msg += f"{date_relation}{weekday_desc},{time_converter_h(n_event_st)}时开始会有活动:{n_event_name}"
330
+ if n_coop_st:
331
+ is_recent, date_relation, weekday_desc = check_date_relation(time_converter(n_coop_st))
332
+ if is_recent:
333
+ if msg:
334
+ msg += "\n"
335
+ msg += f"{date_relation}{weekday_desc},{time_converter_h(n_coop_st)}时开始会有 {n_coop_name}"
336
+ return msg
337
+
338
+
339
+ def get_newest_event_data():
340
+ """
341
+ 取最新活动数据
342
+ 返回 (时间(年月日T时分秒Z),名称)
343
+ """
344
+ # 取日程
345
+ schedule = get_schedule_data()
346
+ events = schedule["eventSchedules"]["nodes"]
347
+ # 如果存在活动
348
+ if len(events) > 0:
349
+ newest_event = events[0]
350
+ # 取时间
351
+ st = newest_event["timePeriods"][0]["startTime"]
352
+ # time_converter_yd(st),
353
+ # "周" + dict_weekday_trans.get(time_converter_weekday(st))
354
+ # 取中文翻译
355
+ cht_event_data = newest_event["leagueMatchSetting"]["leagueMatchEvent"]
356
+ _id = cht_event_data["id"]
357
+ trans_cht_event_data = get_trans_cht_data()["events"][_id]
358
+ # 替换为翻译文本
359
+ cht_event_data["name"] = trans_cht_event_data.get(
360
+ "name", cht_event_data["name"]
361
+ )
362
+ event_name = cht_event_data["name"]
363
+ return st, event_name
364
+ else:
365
+ return "", ""
366
+
367
+
368
+ def get_newest_salmonrun_data():
369
+ """
370
+ 取最新big run或者团工 数据
371
+ 返回 (时间(年月日T时分秒Z),名称)
372
+ """
373
+ # 取日程
374
+ schedule = get_schedule_data()
375
+ # 取翻译
376
+ get_trans_cht_data()
377
+ # 团队打工竞赛
378
+ team_schedule = schedule["coopGroupingSchedule"]["teamContestSchedules"]["nodes"]
379
+ # big run 数据
380
+ bigrun_schedule = schedule["coopGroupingSchedule"]["bigRunSchedules"]["nodes"]
381
+ newest_coop = None
382
+ coop_name = ""
383
+ st = ""
384
+ if len(team_schedule) > 0:
385
+ newest_coop = team_schedule[0]
386
+ coop_name = "团队打工"
387
+ elif len(bigrun_schedule) > 0:
388
+ newest_coop = bigrun_schedule[0]
389
+ coop_name = "BigRun"
390
+
391
+ if newest_coop is not None:
392
+ # coop_stage_name = get_trans_stage(newest_coop["setting"]["coopStage"]["id"])
393
+ st = newest_coop["startTime"]
394
+ return st, coop_name
395
+
396
+
270
397
  async def init_browser() -> Browser:
271
398
  """初始化 browser 并唤起"""
272
399
  global _browser
@@ -293,10 +420,10 @@ async def get_browser() -> Browser:
293
420
 
294
421
 
295
422
  async def get_screenshot(
296
- shot_url,
297
- mode="pc",
298
- selector=None,
299
- shot_path=None,
423
+ shot_url,
424
+ mode="pc",
425
+ selector=None,
426
+ shot_path=None,
300
427
  ) -> bytes:
301
428
  """通过 browser 获取 shot_url 中的网页截图"""
302
429
  # playwright 要求不能有多个 browser 被同时唤起
@@ -299,7 +299,7 @@ class DBIMAGE:
299
299
  if not is_deco:
300
300
  sql = f"select * from BUILDS where keywords LIKE '%|{keyword}|%'"
301
301
  else:
302
- sql = f"select * from BUILDS where keywords LIKE '%|{keyword}|%' AND is_deco=1"
302
+ sql = f"select * from BUILDS where keywords LIKE '%|{keyword}|%' AND is_deco={is_deco}"
303
303
  c = self.conn.cursor()
304
304
  c.execute(
305
305
  sql,
@@ -74,21 +74,44 @@ async def get_build_image(*args):
74
74
  mode = dict_builds_mode_trans.get(mode, mode)
75
75
 
76
76
  url = f"https://sendou.ink/builds/{sendou_name}?limit=6"
77
- if mode:
77
+ if mode and mode != "全部":
78
78
  url += (
79
79
  '&f=[{"type":"mode","mode":"'
80
80
  + mode
81
- + '"},{"type":"date","date":"2025-09-03"}]'
81
+ + '"},{"type":"date","date":"2026-01-29"}]'
82
82
  )
83
83
  else:
84
- url += '&f=[{"type":"date","date":"2025-09-03"}]'
84
+ url += '&f=[{"type":"date","date":"2026-01-29"}]'
85
85
 
86
86
  logger.info(f"sendou.ink url: {url}")
87
87
  try:
88
88
  img = await get_screenshot(shot_url=url, mode="pc", selector=".layout__main")
89
+ im = Image.open(io.BytesIO(img))
90
+ # 裁切顶部虚影部分
91
+ crop_box = (
92
+ 0,
93
+ 60,
94
+ im.width,
95
+ im.height - 70,
96
+ ) # 传入的四个参数可以理解为是 左上角的x点,y点,和右下角的x点,y点
97
+ cropped_img = im.crop(crop_box)
98
+ # 添加一行文本版权声明
99
+ ttf = ImageFont.truetype(ttf_path_chinese, 20)
100
+ img_width = cropped_img.width
101
+ img_height = cropped_img.height
102
+ # 写一行网址
103
+ time_head_text = f"配装数据来源: https://sendou.ink/builds"
104
+ w, h = ttf_get_size(ttf, time_head_text)
105
+ time_head_text_pos = (
106
+ (img_width - w) / 2,
107
+ img_height - 33,
108
+ )
109
+ drawer = ImageDraw.Draw(cropped_img)
110
+ drawer.text(time_head_text_pos, time_head_text, font=ttf, fill=(247, 62, 139))
111
+ return cropped_img
112
+
89
113
  except Exception as e:
90
114
  return f"bot服务器网络错误,网页截图失败,请稍后再试:{e}"
91
- return img
92
115
 
93
116
 
94
117
  async def get_random_weapon_image(*args):
@@ -182,7 +182,7 @@ def get_events(events: list) -> Image.Image:
182
182
  event_card_pos = (20, pos_h + 20)
183
183
  paste_with_a(image_background, event_card, event_card_pos)
184
184
  pos_h += event_card.size[1] + 30
185
- # 绘制祭典说明卡片
185
+ # 绘制活动说明卡片
186
186
  event_desc_card_bg_size = (event_card_bg_size[0], 300)
187
187
  event_desc_card = get_event_desc_card(cht_event_data, event_desc_card_bg_size)
188
188
  event_card_pos = (20, pos_h)
@@ -846,7 +846,7 @@ def get_help() -> Image.Image:
846
846
  def get_nso_help() -> Image.Image:
847
847
  """绘制 nso帮助图片"""
848
848
  all_width = 1200
849
- image_background_size = (all_width, 4300)
849
+ image_background_size = (all_width, 4550)
850
850
 
851
851
  # 取背景rgb颜色
852
852
  bg_rgb = dict_bg_rgb["活动"]
@@ -1019,7 +1019,7 @@ def get_nso_help() -> Image.Image:
1019
1019
  # 绘制 帮助卡片
1020
1020
  cmd_list = ["/me"]
1021
1021
  desc_list = [
1022
- ("无参数", "显示个人技术,奖牌,对战/打工数量,胜率等信息"),
1022
+ ("无参数", "显示个人技术,奖牌,对战/打工数量,胜率等信息(私聊使用该命令时将展示更多信息,如武器分,x分)"),
1023
1023
  ]
1024
1024
  text_card, card_h = drawer_nso_help_card(cmd_list, desc_list, text_width=text_width)
1025
1025
  # 贴图
@@ -1073,7 +1073,7 @@ def get_nso_help() -> Image.Image:
1073
1073
  cmd_list = ["/report"]
1074
1074
  desc_list = [
1075
1075
  ("无参数", "查询昨天的日报数据(对战/打工情况,胜率变化等)"),
1076
- ("2024-01-30", "查询某日日报数据,日期格式为2024-01-30"),
1076
+ ("2024-01-30", "查询指定日期到最新日报间的数据变化,日期格式为2024-01-30"),
1077
1077
  ]
1078
1078
  text_card, card_h = drawer_nso_help_card(cmd_list, desc_list, text_width=text_width)
1079
1079
  # 贴图
@@ -1090,6 +1090,26 @@ def get_nso_help() -> Image.Image:
1090
1090
  text_bg_pos = (title_pos[0] + 30, height)
1091
1091
  paste_with_a(image_background, text_card, text_bg_pos)
1092
1092
  height += card_h + 10
1093
+ # 绘制 帮助卡片
1094
+ cmd_list = ["/观星导出"]
1095
+ desc_list = [
1096
+ ("无参数", "导出观星网站所需要的装备json文件"),
1097
+ ]
1098
+ text_card, card_h = drawer_nso_help_card(cmd_list, desc_list, text_width=text_width)
1099
+ # 贴图
1100
+ text_bg_pos = (title_pos[0] + 30, height)
1101
+ paste_with_a(image_background, text_card, text_bg_pos)
1102
+ height += card_h + 10
1103
+ # 绘制 帮助卡片
1104
+ cmd_list = ["/nso网页版"]
1105
+ desc_list = [
1106
+ ("无参数", "让你可以在任何支持油猴脚本的浏览器内打开喷三鱿鱼圈,\n适用于网络太差进不去nso或nso不方便升级的时候使用"),
1107
+ ]
1108
+ text_card, card_h = drawer_nso_help_card(cmd_list, desc_list, text_width=text_width)
1109
+ # 贴图
1110
+ text_bg_pos = (title_pos[0] + 30, height)
1111
+ paste_with_a(image_background, text_card, text_bg_pos)
1112
+ height += card_h + 10
1093
1113
 
1094
1114
  # 绘制title
1095
1115
  title = "stat.ink战绩同步"
@@ -1169,7 +1189,7 @@ def get_nso_help() -> Image.Image:
1169
1189
  # 绘制 帮助卡片
1170
1190
  cmd_list = ["/report_notify"]
1171
1191
  desc_list = [
1172
- ("open", "开启每日日报主动推送(早上8点定时发送)"),
1192
+ ("open", "开启每日日报主动推送(早上9点定时发送)"),
1173
1193
  ("close", "关闭日报主动推送"),
1174
1194
  ]
1175
1195
  text_card, card_h = drawer_nso_help_card(cmd_list, desc_list, text_width=text_width)
@@ -12,7 +12,7 @@ from .image.image import (
12
12
  )
13
13
  from .utils.cos_upload import cos_uploader, cos_upload_file
14
14
  from .utils.utils import get_time_now_china, trigger_with_probability, get_image_size
15
- from .data import db_control, db_image
15
+ from .data import db_control, db_image, get_newest_event_or_coop
16
16
  from .utils.bot import *
17
17
 
18
18
 
@@ -345,7 +345,8 @@ async def get_qq_md(user_id: str, img_size: tuple[int, int], url: str) -> QQ_Msg
345
345
 
346
346
  image_width, image_height = img_size
347
347
 
348
- text_start = "发送/帮助查看详细用法"
348
+ text_start = get_newest_event_or_coop() or "发送/帮助查看详细用法"
349
+ text_start = text_start.replace("\n", "\r")
349
350
 
350
351
  # text_end作为公告消息
351
352
  text_end = await get_or_set_plugin_data("splatoon3_bot_notice")
@@ -361,7 +362,7 @@ async def get_qq_md(user_id: str, img_size: tuple[int, int], url: str) -> QQ_Msg
361
362
  ]
362
363
  )
363
364
  if text_end:
364
- text_end = text_end.replace("\\n", "\r").replace("\\r", "\r")
365
+ text_end = "\r" + text_end.replace("\\n", "\r").replace("\\r", "\r")
365
366
  params.append({"key": "text_end", "values": [f"{text_end}"]})
366
367
  md = QQ_MsgMarkdown.model_validate(
367
368
  {"custom_template_id": f"{template_id}", "params": params}
@@ -2,6 +2,7 @@ import datetime
2
2
  import json
3
3
  import random
4
4
 
5
+ import zhconv
5
6
  from nonebot.log import logger
6
7
  from .utils import (
7
8
  get_time_ymd,
@@ -125,6 +126,15 @@ def weapon_semantic_word_conversion(word: str):
125
126
  return word_type[4], random.choice(list(father_class_list))
126
127
 
127
128
 
129
+ def str_convert_to_simplified(words: str):
130
+ """字符串转简体中文"""
131
+ if words:
132
+ simplified_text = zhconv.convert(words, "zh-hans")
133
+ return simplified_text
134
+ else:
135
+ return words
136
+
137
+
128
138
  # 翻译字典
129
139
  dict_rule_reverse_trans = {
130
140
  "LOFT": "真格塔楼",
@@ -210,13 +220,32 @@ dict_keyword_replace = {
210
220
  # 配装武器关键词前置处理
211
221
  dict_builds_pre_replace = {
212
222
  "无印": "",
223
+ "原版": "",
213
224
  "炮": "泡",
214
225
  "息": "熄",
215
226
  "篮": "蓝",
216
- "斯普拉顿": "斯普拉遁",
227
+ "斯普拉顿": "斯普拉",
228
+ "斯普拉遁": "斯普拉",
217
229
  "拴": "栓",
218
- "四开": "四K",
230
+ "四开": "4K",
231
+ "四K": "4K",
232
+ "4开": "4K",
233
+ "新形": "新型",
219
234
  "设计": "射击",
235
+ "渔工": "鱼弓",
236
+ "渡": "镀",
237
+ "防空露营": "露营防空",
238
+ "锯齿": "巨齿",
239
+ "针筒": "针管",
240
+ "牙膏刀": "太刀",
241
+ "牙膏": "太刀",
242
+ "顶级": "顶尖",
243
+ "酸奶": "奶",
244
+ "牛奶": "奶",
245
+ "笔桶": "笔桶",
246
+ "抢": "枪",
247
+ "雨刮": "雨刷",
248
+ "挂水刀": "刮水刀",
220
249
  " ": "",
221
250
  ".": "",
222
251
  "。": "",
@@ -7,6 +7,7 @@ import cloudscraper
7
7
  import httpx
8
8
  from PIL import ImageFont, Image
9
9
  from httpx import Response
10
+ from nonebot import logger
10
11
 
11
12
  from .dataClass import TimeUtil
12
13
  from ..config import plugin_config
@@ -45,12 +46,18 @@ def cf_http_get(url: str):
45
46
  # 请求报错,可以加上时延
46
47
  # scraper = cloudscraper.create_scraper(delay = 6)
47
48
  if proxy_address:
48
- cf_proxies = {
49
- "http": "http://{}".format(proxy_address),
50
- "https": "http://{}".format(proxy_address),
51
- }
52
- # 获取网页内容 代理访问
53
- res = scraper.get(url, proxies=cf_proxies)
49
+ try:
50
+ cf_proxies = {
51
+ "http": "http://{}".format(proxy_address),
52
+ "https": "http://{}".format(proxy_address),
53
+ }
54
+ # 获取网页内容 代理访问
55
+ res = scraper.get(url, proxies=cf_proxies)
56
+ except Exception as e:
57
+ # 可能是代理挂了,切换为直连模式再请求一次
58
+ logger.warning("代理请求失败,将进行直连请求重试")
59
+ res = scraper.get(url)
60
+
54
61
  else:
55
62
  # 获取网页内容
56
63
  res = scraper.get(url)
@@ -114,6 +121,12 @@ def time_converter_hm(time_str):
114
121
  return datetime.datetime.strftime(dt, "%H:%M")
115
122
 
116
123
 
124
+ def time_converter_h(time_str):
125
+ """时间转换 时"""
126
+ dt = time_converter(time_str)
127
+ return datetime.datetime.strftime(dt, "%H")
128
+
129
+
117
130
  def time_converter_mdhm(time_str):
118
131
  """时间转换 月-日 时:分"""
119
132
  dt = time_converter(time_str)
@@ -155,9 +168,9 @@ def get_time_now_china() -> datetime.datetime:
155
168
 
156
169
  def trigger_with_probability():
157
170
  """
158
- 该函数有2/100的概率返回True(触发)
171
+ 该函数有1/100的概率返回True(触发)
159
172
  """
160
- return random.random() < 0.02
173
+ return random.random() < 0.01
161
174
 
162
175
 
163
176
  def ttf_get_size(font: ImageFont.FreeTypeFont, text: str) -> tuple:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "nonebot-plugin-splatoon3-schedule"
3
- version = "2.0.6"
3
+ version = "2.0.7"
4
4
  description = "一个基于nonebot2框架的splatoon3游戏日程查询插件"
5
5
  authors = ["cypas <ayano05@outlook.com>"]
6
6
  readme = "README.md"
@@ -22,6 +22,7 @@ nonebot-adapter-qq = "^1.6.6"
22
22
  nonebot-plugin-apscheduler = "^0.5.0"
23
23
  nonebot_plugin_datastore = "^1.3.0"
24
24
  cos_python_sdk_v5 = "^1.9.30"
25
+ zhconv = "^1.4.3"
25
26
 
26
27
  [tool.poetry.group.test.dependencies]
27
28
  nonebug = "^0.3.5"