nonebot-plugin-splatoon3-schedule 2.0.3__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.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/PKG-INFO +2 -1
  2. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/config.py +2 -0
  3. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/util.py +75 -27
  4. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/utils/bot.py +9 -0
  5. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/pyproject.toml +2 -1
  6. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/LICENSE +0 -0
  7. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/README.md +0 -0
  8. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/__init__.py +0 -0
  9. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/check.py +0 -0
  10. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/data/__init__.py +0 -0
  11. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/data/data_source.py +0 -0
  12. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/data/db_control.py +0 -0
  13. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/data/db_image.py +0 -0
  14. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/data/static_data_getter.py +0 -0
  15. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/image/__init__.py +0 -0
  16. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/image/image.py +0 -0
  17. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/image/image_processer.py +0 -0
  18. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/image/image_processer_tools.py +0 -0
  19. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10024.png +0 -0
  20. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10025.ico +0 -0
  21. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10026.png +0 -0
  22. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/AREA.png +0 -0
  23. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/CLAM.png +0 -0
  24. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Cohozuna.png +0 -0
  25. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/GOAL.png +0 -0
  26. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Horrorboros.png +0 -0
  27. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/LOFT.png +0 -0
  28. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Megalodontia.png +0 -0
  29. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Random.png +0 -0
  30. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked-Challenge.png +0 -0
  31. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked-Open.png +0 -0
  32. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked.png +0 -0
  33. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Regular.png +0 -0
  34. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/TURF_WAR.png +0 -0
  35. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Triumvirate.png +0 -0
  36. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/X.png +0 -0
  37. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg.png +0 -0
  38. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg2.png +0 -0
  39. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg3.png +0 -0
  40. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/big_run.png +0 -0
  41. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/black-texture.png +0 -0
  42. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/cat_paw_mask.png +0 -0
  43. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop.png +0 -0
  44. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_bg2.png +0 -0
  45. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_fish.png +0 -0
  46. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_mask.png +0 -0
  47. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/event_bg.png +0 -0
  48. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/festival_mask.png +0 -0
  49. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/fight_mask.png +0 -0
  50. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/filleted_corner.png +0 -0
  51. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/private.png +0 -0
  52. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/swim_ring.png +0 -0
  53. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/team_coop.png +0 -0
  54. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/ImageData/time_head_bg.png +0 -0
  55. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/db/image.db +0 -0
  56. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/font/Splatfont1.otf +0 -0
  57. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/font/Splatfont2.otf +0 -0
  58. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/font/cn.ttf +0 -0
  59. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/resource/font/common.otf +0 -0
  60. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/utils/__init__.py +0 -0
  61. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/utils/dataClass.py +0 -0
  62. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/utils/translation.py +0 -0
  63. {nonebot_plugin_splatoon3_schedule-2.0.3 → nonebot_plugin_splatoon3_schedule-2.0.4}/nonebot_plugin_splatoon3_schedule/utils/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nonebot-plugin-splatoon3-schedule
3
- Version: 2.0.3
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
@@ -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,需要将下面三行注释并取消再下面两行的注释
@@ -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 # 频道私聊信息
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "nonebot-plugin-splatoon3-schedule"
3
- version = "2.0.3"
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"