nonebot-plugin-splatoon3-schedule 2.0.2__tar.gz → 2.0.4__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 (63) hide show
  1. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/PKG-INFO +2 -1
  2. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/__init__.py +8 -0
  3. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/config.py +2 -0
  4. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/data/data_source.py +2 -6
  5. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/image/image_processer.py +12 -4
  6. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/util.py +75 -27
  7. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/utils/bot.py +9 -0
  8. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/utils/utils.py +8 -8
  9. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/pyproject.toml +2 -1
  10. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/LICENSE +0 -0
  11. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/README.md +0 -0
  12. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/check.py +0 -0
  13. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/data/__init__.py +0 -0
  14. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/data/db_control.py +0 -0
  15. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/data/db_image.py +0 -0
  16. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/data/static_data_getter.py +0 -0
  17. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/image/__init__.py +0 -0
  18. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/image/image.py +0 -0
  19. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/image/image_processer_tools.py +0 -0
  20. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10024.png +0 -0
  21. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10025.ico +0 -0
  22. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10026.png +0 -0
  23. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/AREA.png +0 -0
  24. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/CLAM.png +0 -0
  25. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Cohozuna.png +0 -0
  26. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/GOAL.png +0 -0
  27. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Horrorboros.png +0 -0
  28. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/LOFT.png +0 -0
  29. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Megalodontia.png +0 -0
  30. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Random.png +0 -0
  31. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked-Challenge.png +0 -0
  32. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked-Open.png +0 -0
  33. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked.png +0 -0
  34. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Regular.png +0 -0
  35. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/TURF_WAR.png +0 -0
  36. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Triumvirate.png +0 -0
  37. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/X.png +0 -0
  38. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg.png +0 -0
  39. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg2.png +0 -0
  40. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg3.png +0 -0
  41. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/big_run.png +0 -0
  42. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/black-texture.png +0 -0
  43. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/cat_paw_mask.png +0 -0
  44. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop.png +0 -0
  45. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_bg2.png +0 -0
  46. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_fish.png +0 -0
  47. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_mask.png +0 -0
  48. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/event_bg.png +0 -0
  49. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/festival_mask.png +0 -0
  50. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/fight_mask.png +0 -0
  51. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/filleted_corner.png +0 -0
  52. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/private.png +0 -0
  53. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/swim_ring.png +0 -0
  54. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/team_coop.png +0 -0
  55. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/time_head_bg.png +0 -0
  56. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/db/image.db +0 -0
  57. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/font/Splatfont1.otf +0 -0
  58. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/font/Splatfont2.otf +0 -0
  59. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/font/cn.ttf +0 -0
  60. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/font/common.otf +0 -0
  61. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/utils/__init__.py +0 -0
  62. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/utils/dataClass.py +0 -0
  63. {nonebot_plugin_splatoon3_schedule-2.0.2 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/utils/translation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nonebot-plugin-splatoon3-schedule
3
- Version: 2.0.2
3
+ Version: 2.0.4
4
4
  Summary: 一个基于nonebot2框架的splatoon3游戏日程查询插件
5
5
  License-File: LICENSE
6
6
  Author: cypas
@@ -23,6 +23,7 @@ Requires-Dist: nonebot-adapter-qq (>=1.6.6,<2.0.0)
23
23
  Requires-Dist: nonebot-adapter-telegram (>=0.1.0b20,<0.2.0)
24
24
  Requires-Dist: nonebot-plugin-apscheduler (>=0.5.0,<0.6.0)
25
25
  Requires-Dist: nonebot2 (>=2.4.4,<3.0.0)
26
+ Requires-Dist: nonebot_plugin_datastore (>=1.3.0,<2.0.0)
26
27
  Requires-Dist: playwright (>=1.40.0,<2.0.0)
27
28
  Requires-Dist: pydantic (>=1.0.0,<3.0.0,!=2.5.0,!=2.5.1)
28
29
  Description-Content-Type: text/markdown
@@ -1,3 +1,4 @@
1
+ from pathlib import Path
1
2
  from typing import Union, Tuple
2
3
 
3
4
  from .check import _permission_check, _guild_owner_check, ChannelInfo, init_blacklist
@@ -252,6 +253,13 @@ async def _(bot: Bot, event: Event, re_tuple: Tuple = RegexGroup()):
252
253
  if not build_info:
253
254
  msg = f"该关键词 {weapon_name} 未查询到对应武器,请试试使用官方中文武器名称或其他常用名称后再试,若为贴牌需要加上贴牌二字,如:\n/配装 小绿\n指定模式查询:\n/配装 贴牌碳刷 塔楼"
254
255
  logger.warning(f"该关键词未匹配到武器 {weapon_name}")
256
+ # 未匹配武器写到指定文件
257
+ file_path = Path(os.path.join(DIR_RESOURCE, "未匹配武器.txt"))
258
+ os.makedirs(os.path.dirname(file_path), exist_ok=True)
259
+ # 以追加模式打开文件,编码指定为utf-8(避免中文乱码)
260
+ with open(file_path, "a", encoding="utf-8") as f:
261
+ f.write(f"{weapon_name}\n") # 每行一个关键词
262
+
255
263
  await send_msg(bot, event, msg)
256
264
  return
257
265
  zh_name: str = build_info.get("zh_name")
@@ -32,6 +32,8 @@ class Config(BaseModel):
32
32
  splatoon3_schedule_plugin_priority_mode: bool = False
33
33
  # 垃圾图片频道
34
34
  splatoon3_kk_channel_waste_chat_id: str | int = ""
35
+ # 部分消息使用qq平台md卡片,开启了也没用,md模版需要在qqbot端进行审核,模板id目前在代码里是写死的
36
+ splatoon3_qq_md_mode: bool = False
35
37
 
36
38
 
37
39
  # 本地测试时由于不启动 driver,需要将下面三行注释并取消再下面两行的注释
@@ -88,8 +88,8 @@ def get_coop_info(_all=None):
88
88
 
89
89
  # 取时间信息
90
90
  def get_str_time(sch):
91
- _start_time = time_converter_mdhm(sch["startTime"])
92
- _end_time = time_converter_mdhm(sch["endTime"])
91
+ _start_time = time_converter_ymdhm(sch["startTime"])
92
+ _end_time = time_converter_ymdhm(sch["endTime"])
93
93
  return "{} - {}".format(_start_time, _end_time)
94
94
 
95
95
  # 取boss名称
@@ -98,10 +98,6 @@ def get_coop_info(_all=None):
98
98
 
99
99
  # 校验普通打工时间,是否在特殊打工模式之后
100
100
  def check_salmonrun_time(_start_time, _special_mode_start_time):
101
- # 输入时间都缺少年份,需要手动补充一个年份后还原为date对象
102
- year = get_time_now_china().year
103
- _start_time = str(year) + "-" + _start_time
104
- _special_mode_start_time = str(year) + "-" + _special_mode_start_time
105
101
  st = datetime.datetime.strptime(_start_time, "%Y-%m-%d %H:%M")
106
102
  su_st = datetime.datetime.strptime(_special_mode_start_time, "%Y-%m-%d %H:%M")
107
103
  if st > su_st:
@@ -445,14 +445,22 @@ def get_coop_stages(stage, weapon, time, boss, mode) -> Image.Image:
445
445
  def check_coop_fish(_time):
446
446
  start_time = _time.split(" - ")[0]
447
447
  now_time = get_time_now_china()
448
- # 输入时间都缺少年份,需要手动补充一个年份后还原为date对象
449
- year = now_time.year
450
- start_time = str(year) + "-" + start_time
451
448
  st = datetime.datetime.strptime(start_time, "%Y-%m-%d %H:%M")
452
449
  if st < now_time:
453
450
  return True
454
451
  return False
455
452
 
453
+ def time_remove_year(_time):
454
+ """移除日期的年份数据"""
455
+ str_p = "%Y-%m-%d %H:%M"
456
+ str_f = "%m-%d %H:%M"
457
+ start_time = _time.split(" - ")[0]
458
+ end_time = _time.split(" - ")[1]
459
+ st = datetime.datetime.strptime(start_time, str_p)
460
+ et = datetime.datetime.strptime(end_time, str_p)
461
+ t = f"{st.strftime(str_f)} - {et.strftime(str_f)}"
462
+ return t
463
+
456
464
  top_size_pos = (0, -2)
457
465
  bg_size = (800, len(stage) * 162 + top_size_pos[1])
458
466
  stage_bg_size = (300, 160)
@@ -478,7 +486,7 @@ def get_coop_stages(stage, weapon, time, boss, mode) -> Image.Image:
478
486
  time_text_pos = (50, 5 + pos * 160)
479
487
 
480
488
  time_text_size = ttf_get_size(font, val)
481
- dr.text(time_text_pos, val, font=font, fill="#FFFFFF")
489
+ dr.text(time_text_pos, time_remove_year(val), font=font, fill="#FFFFFF")
482
490
  if check_coop_fish(val):
483
491
  # 现在时间处于打工时间段内,绘制小鲑鱼
484
492
  coop_fish_img = get_file("coop_fish").resize(coop_fish_size)
@@ -1,10 +1,7 @@
1
+ import io
1
2
  import time
2
3
 
3
- # from nonebot.adapters.qq import AuditException, ActionFailed
4
- from nonebot.adapters.qq import (
5
- AuditException as QQ_AuditException,
6
- ActionFailed as QQ_ActionFailed,
7
- )
4
+ from PIL import Image
8
5
 
9
6
  from .config import plugin_config
10
7
  from .image.image import (
@@ -184,29 +181,28 @@ async def send_msg(
184
181
  logger.info("url:" + url)
185
182
  await bot.send(event, Kook_MsgSeg.image(url), reply_sender=reply_mode)
186
183
  elif isinstance(bot, QQ_Bot):
187
- if not isinstance(event, GroupAtMessageCreateEvent):
188
- try:
189
- await bot.send(event, message=QQ_MsgSeg.file_image(img))
190
- except QQ_ActionFailed as e:
191
- if "消息被去重" in str(e):
192
- pass
193
- else:
194
- logger.warning(f"QQ send msg error: {e}")
195
- else:
196
- # 目前q群只支持url图片,得想办法上传图片获取url
197
- url = await get_image_url(img, is_cache)
198
- logger.info("url:" + url)
199
- try:
184
+ # 目前q群只支持url图片,得想办法上传图片获取url
185
+ url = await get_image_url(img, is_cache=False)
186
+ logger.info("url:" + url)
187
+ try:
188
+ if plugin_config.splatoon3_qq_md_mode:
189
+ image = Image.open(io.BytesIO(img))
190
+ image_size = image.size
191
+ image.close()
192
+ user_id = event.get_user_id()
193
+ qq_md = await get_qq_md(user_id, image_size, url)
194
+ await bot.send(event, qq_md)
195
+ else:
200
196
  await bot.send(event, message=QQ_MsgSeg.image(url))
201
- except QQ_ActionFailed as e:
202
- if "消息被去重" in str(e):
203
- pass
204
- elif "富媒体文件格式不支持" in str(e):
205
- url = await get_image_url(img, is_cache=False)
206
- logger.info("图片上传失败,重新强制上传,url:" + url)
207
- await bot.send(event, message=QQ_MsgSeg.image(url))
208
- else:
209
- logger.warning(f"QQ send msg error: {e}")
197
+ except QQ_ActionFailed as e:
198
+ if "消息被去重" in str(e):
199
+ pass
200
+ elif "富媒体文件格式不支持" in str(e):
201
+ url = await get_image_url(img, is_cache=False)
202
+ logger.info("图片上传失败,重新强制上传,url:" + url)
203
+ await bot.send(event, message=QQ_MsgSeg.image(url))
204
+ else:
205
+ logger.warning(f"QQ send msg error: {e}")
210
206
 
211
207
  if not is_ad and trigger_with_probability():
212
208
  if isinstance(bot, QQ_Bot):
@@ -314,3 +310,55 @@ async def send_private_msg(bot: Bot, source_id, msg: str | bytes, event=None):
314
310
  logger.warning(f"主动消息发送失败,api操作结果为{e.__dict__}")
315
311
  elif isinstance(bot, Tg_Bot):
316
312
  await bot.send_photo(source_id, img)
313
+
314
+
315
+ async def get_or_set_plugin_data(key, value=None):
316
+ """获取或设置插件数据"""
317
+ from nonebot import require
318
+
319
+ require("nonebot_plugin_datastore")
320
+ from nonebot_plugin_datastore import get_plugin_data
321
+
322
+ if value is None:
323
+ # 读取配置
324
+ value = await get_plugin_data("sp3_xyy_bot").config.get(key)
325
+ return value
326
+ else:
327
+ # 存储配置
328
+ await get_plugin_data("sp3_xyy_bot").config.set(key, value)
329
+ return value
330
+
331
+
332
+ async def get_qq_md(user_id: str, img_size: tuple[int, int], url: str) -> QQ_Msg:
333
+ """日程md结构"""
334
+ template_id = "102083290_1705920931"
335
+ keyboard_template_id = "102083290_1767587639"
336
+
337
+ image_width, image_height = img_size
338
+
339
+ text_start = "发送/帮助查看详细用法"
340
+
341
+ # text_end作为公告消息
342
+ text_end = await get_or_set_plugin_data("splatoon3_bot_notice")
343
+
344
+ params = []
345
+ if user_id:
346
+ params.append({"key": "at_user_id", "values": [f"<@{user_id}>"]})
347
+ params.extend(
348
+ [
349
+ {"key": "text_start", "values": [f"{text_start}"]},
350
+ {"key": "img_size", "values": [f"img#{image_width}px #{image_height}px"]},
351
+ {"key": "img_url", "values": [f"{url}"]},
352
+ ]
353
+ )
354
+ if text_end:
355
+ text_end = text_end.replace("\\n", "\r").replace("\\r", "\r")
356
+ params.append({"key": "text_end", "values": [f"{text_end}"]})
357
+ md = QQ_MsgMarkdown.model_validate(
358
+ {"custom_template_id": f"{template_id}", "params": params}
359
+ )
360
+
361
+ keyboard = QQ_MsgKeyboard.model_validate({"id": f"{keyboard_template_id}"})
362
+
363
+ qq_msg = QQ_Msg([QQ_MsgSeg.markdown(md), QQ_MsgSeg.keyboard(keyboard)])
364
+ return qq_msg
@@ -46,6 +46,15 @@ from nonebot.adapters.kaiheila.event import ChannelMessageEvent as Kook_CME
46
46
  from nonebot.adapters.qq import Bot as QQ_Bot
47
47
  from nonebot.adapters.qq.event import MessageEvent as QQ_ME, GroupAtMessageCreateEvent
48
48
  from nonebot.adapters.qq import MessageSegment as QQ_MsgSeg
49
+ from nonebot.adapters.qq.message import Message as QQ_Msg
50
+ from nonebot.adapters.qq.models import (
51
+ MessageKeyboard as QQ_MsgKeyboard,
52
+ MessageMarkdown as QQ_MsgMarkdown,
53
+ )
54
+ from nonebot.adapters.qq import (
55
+ AuditException as QQ_AuditException,
56
+ ActionFailed as QQ_ActionFailed,
57
+ )
49
58
  from nonebot.adapters.qq.event import GroupAtMessageCreateEvent as QQ_GME # 群艾特信息
50
59
  from nonebot.adapters.qq.event import C2CMessageCreateEvent as QQ_C2CME # Q私聊信息
51
60
  from nonebot.adapters.qq.event import DirectMessageCreateEvent as QQ_PME # 频道私聊信息
@@ -120,6 +120,12 @@ def time_converter_mdhm(time_str):
120
120
  return datetime.datetime.strftime(dt, "%m-%d %H:%M")
121
121
 
122
122
 
123
+ def time_converter_ymdhm(time_str):
124
+ """时间转换 年-月-日 时:分"""
125
+ dt = time_converter(time_str)
126
+ return datetime.datetime.strftime(dt, "%Y-%m-%d %H:%M")
127
+
128
+
123
129
  def time_converter_weekday(time_str):
124
130
  """时间转换 周几,如周一"""
125
131
  dt = time_converter(time_str)
@@ -149,15 +155,9 @@ def get_time_now_china() -> datetime.datetime:
149
155
 
150
156
  def trigger_with_probability():
151
157
  """
152
- 该函数有30/1000的概率返回True(触发),970/1000的概率返回False(不触发)
153
-
154
- 返回:
155
- bool: 触发状态,True表示触发,False表示未触发
158
+ 该函数有2/100的概率返回True(触发)
156
159
  """
157
- # 生成0到999之间的随机整数(包含0和999)
158
- random_number = random.randint(0, 999)
159
- # 如果随机数是0、1或2,则触发(3种情况)
160
- return random_number < 30
160
+ return random.random() < 0.02
161
161
 
162
162
 
163
163
  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.2"
3
+ version = "2.0.4"
4
4
  description = "一个基于nonebot2框架的splatoon3游戏日程查询插件"
5
5
  authors = ["cypas <ayano05@outlook.com>"]
6
6
  readme = "README.md"
@@ -20,6 +20,7 @@ nonebot-adapter-telegram = "^0.1.0b20"
20
20
  nonebot-adapter-kaiheila = "^0.3.4"
21
21
  nonebot-adapter-qq = "^1.6.6"
22
22
  nonebot-plugin-apscheduler = "^0.5.0"
23
+ nonebot_plugin_datastore = "^1.3.0"
23
24
 
24
25
  [tool.poetry.group.test.dependencies]
25
26
  nonebug = "^0.3.5"