nonebot-plugin-splatoon3-schedule 2.0.5__tar.gz → 2.0.6__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.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/PKG-INFO +1 -1
  2. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/util.py +16 -15
  3. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/utils/cos_upload.py +77 -25
  4. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/pyproject.toml +1 -1
  5. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/LICENSE +0 -0
  6. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/README.md +0 -0
  7. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/__init__.py +0 -0
  8. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/check.py +0 -0
  9. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/config.py +0 -0
  10. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/data/__init__.py +0 -0
  11. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/data/data_source.py +0 -0
  12. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/data/db_control.py +0 -0
  13. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/data/db_image.py +0 -0
  14. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/data/static_data_getter.py +0 -0
  15. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/image/__init__.py +0 -0
  16. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/image/image.py +0 -0
  17. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/image/image_processer.py +0 -0
  18. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/image/image_processer_tools.py +0 -0
  19. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10024.png +0 -0
  20. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10025.ico +0 -0
  21. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10026.png +0 -0
  22. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/AREA.png +0 -0
  23. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/CLAM.png +0 -0
  24. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Cohozuna.png +0 -0
  25. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/GOAL.png +0 -0
  26. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Horrorboros.png +0 -0
  27. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/LOFT.png +0 -0
  28. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Megalodontia.png +0 -0
  29. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Random.png +0 -0
  30. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked-Challenge.png +0 -0
  31. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked-Open.png +0 -0
  32. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked.png +0 -0
  33. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Regular.png +0 -0
  34. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/TURF_WAR.png +0 -0
  35. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Triumvirate.png +0 -0
  36. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/X.png +0 -0
  37. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg.png +0 -0
  38. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg2.png +0 -0
  39. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg3.png +0 -0
  40. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/big_run.png +0 -0
  41. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/black-texture.png +0 -0
  42. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/cat_paw_mask.png +0 -0
  43. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop.png +0 -0
  44. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_bg2.png +0 -0
  45. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_fish.png +0 -0
  46. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_mask.png +0 -0
  47. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/event_bg.png +0 -0
  48. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/festival_mask.png +0 -0
  49. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/fight_mask.png +0 -0
  50. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/filleted_corner.png +0 -0
  51. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/private.png +0 -0
  52. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/swim_ring.png +0 -0
  53. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/team_coop.png +0 -0
  54. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/ImageData/time_head_bg.png +0 -0
  55. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/db/image.db +0 -0
  56. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/font/Splatfont1.otf +0 -0
  57. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/font/Splatfont2.otf +0 -0
  58. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/font/cn.ttf +0 -0
  59. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/resource/font/common.otf +0 -0
  60. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/utils/__init__.py +0 -0
  61. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/utils/bot.py +0 -0
  62. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/utils/dataClass.py +0 -0
  63. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/nonebot_plugin_splatoon3_schedule/utils/translation.py +0 -0
  64. {nonebot_plugin_splatoon3_schedule-2.0.5 → nonebot_plugin_splatoon3_schedule-2.0.6}/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.5
3
+ Version: 2.0.6
4
4
  Summary: 一个基于nonebot2框架的splatoon3游戏日程查询插件
5
5
  License-File: LICENSE
6
6
  Author: cypas
@@ -10,8 +10,8 @@ from .image.image import (
10
10
  get_coop_stages_image,
11
11
  get_events_image,
12
12
  )
13
- from .utils.cos_upload import cos_uploader, simple_upload_file
14
- from .utils.utils import get_time_now_china, trigger_with_probability
13
+ from .utils.cos_upload import cos_uploader, cos_upload_file
14
+ from .utils.utils import get_time_now_china, trigger_with_probability, get_image_size
15
15
  from .data import db_control, db_image
16
16
  from .utils.bot import *
17
17
 
@@ -107,7 +107,7 @@ async def send_push(bot: Bot, source_id):
107
107
 
108
108
 
109
109
  async def send_msg(
110
- bot: Bot, event: Event, msg: str | bytes, is_ad=False, is_cache=True
110
+ bot: Bot, event: Event, msg: str | bytes, is_ad=False, is_cache=True
111
111
  ):
112
112
  """公用send_msg"""
113
113
  # 指定回复模式
@@ -183,13 +183,10 @@ async def send_msg(
183
183
  await bot.send(event, Kook_MsgSeg.image(url), reply_sender=reply_mode)
184
184
  elif isinstance(bot, QQ_Bot):
185
185
  # 目前q群只支持url图片,得想办法上传图片获取url
186
- url = await get_image_url(img, is_cache=False)
186
+ url, image_size = await get_image_url_and_size(img)
187
187
  # logger.info("url:" + url)
188
188
  try:
189
189
  if plugin_config.splatoon3_qq_md_mode:
190
- image = Image.open(io.BytesIO(img))
191
- image_size = image.size
192
- image.close()
193
190
  user_id = event.get_user_id()
194
191
  qq_md = await get_qq_md(user_id, image_size, url)
195
192
  await bot.send(event, qq_md)
@@ -199,7 +196,7 @@ async def send_msg(
199
196
  if "消息被去重" in str(e):
200
197
  pass
201
198
  elif "富媒体文件格式不支持" in str(e):
202
- url = await get_image_url(img, is_cache=False)
199
+ url, image_size = await get_image_url_and_size(img)
203
200
  logger.info("图片上传失败,重新强制上传,url:" + url)
204
201
  await bot.send(event, message=QQ_MsgSeg.image(url))
205
202
  else:
@@ -211,14 +208,17 @@ async def send_msg(
211
208
  await send_msg(bot, event, ad_msg, is_ad=True)
212
209
 
213
210
 
214
- async def get_image_url(img: bytes, is_cache) -> str:
215
- """通过kook获取图片url"""
211
+ async def get_image_url_and_size(img_data: bytes) -> tuple[str, tuple[int, int]]:
212
+ """通过cos图床或kook图床获取图片url"""
216
213
  url = ""
214
+ image_size = (300, 300)
217
215
  # 优先使用腾讯cos上传
218
216
  if plugin_config.splatoon3_cos_config.enabled and cos_uploader.client is not None:
219
- url = simple_upload_file(img)
217
+ url, image_size = cos_upload_file(img_data)
220
218
  if url:
221
- return url
219
+ return url, image_size
220
+ else:
221
+ logger.warning("腾讯cos上传失败,使用kook上传")
222
222
 
223
223
  # 使用kook的接口传图片
224
224
  kook_bot = None
@@ -229,13 +229,14 @@ async def get_image_url(img: bytes, is_cache) -> str:
229
229
  break
230
230
  if kook_bot is not None:
231
231
  # 使用kook的接口传图片
232
- url = await kook_bot.upload_file(img)
233
- if url and not is_cache:
232
+ url = await kook_bot.upload_file(img_data)
233
+ image_size = get_image_size(img_data)
234
+ if url:
234
235
  channel_id = plugin_config.splatoon3_kk_channel_waste_chat_id
235
236
  await kook_bot.send_channel_msg(
236
237
  channel_id=channel_id, message=Kook_MsgSeg.image(url)
237
238
  )
238
- return url
239
+ return url, image_size
239
240
 
240
241
 
241
242
  async def send_channel_msg(bot: Bot, source_id, msg: str | bytes):
@@ -1,11 +1,13 @@
1
1
  import os, logging, mimetypes, re, sys, hashlib
2
+ import traceback
2
3
  from datetime import datetime
3
4
  from typing import Optional, Dict, Any, Tuple
4
5
  from io import BytesIO
5
6
 
6
7
  from nonebot import logger
7
8
 
8
- from .utils import plugin_config, get_image_size
9
+ from .utils import get_image_size
10
+ from .. import plugin_config
9
11
 
10
12
  try:
11
13
  from qcloud_cos import CosConfig, CosS3Client
@@ -20,6 +22,7 @@ class COSUploader:
20
22
 
21
23
  提供文件上传、删除、查询等功能
22
24
  """
25
+
23
26
  def __init__(self):
24
27
  """初始化COS上传器
25
28
 
@@ -87,7 +90,8 @@ class COSUploader:
87
90
  return sys.getsizeof(file_data) <= self.config.max_file_size
88
91
 
89
92
  def _generate_cos_key(self, user_id: str = None,
90
- md5: str = None, file_data: bytes = None) -> str:
93
+ md5: str = None, file_data: bytes = None,
94
+ width: int = 300, height: int = 300) -> str:
91
95
  """生成COS上传路径
92
96
 
93
97
  Args:
@@ -100,15 +104,15 @@ class COSUploader:
100
104
  """
101
105
  # 使用MD5作为文件名
102
106
  ext = self._get_file_extension(file_data)
103
- filename = f"{md5}{ext}"
104
-
107
+ filename = f"{md5}_w{width}h{height}{ext}"
108
+
105
109
  # 获取上传路径前缀
106
110
  upload_prefix = self.config.upload_path_prefix
107
-
111
+
108
112
  # 确保前缀以/结尾,避免路径拼接问题
109
113
  if upload_prefix and not upload_prefix.endswith('/'):
110
114
  upload_prefix += '/'
111
-
115
+
112
116
  if user_id:
113
117
  return f"{upload_prefix}{user_id}/{filename}"
114
118
  else:
@@ -171,18 +175,24 @@ class COSUploader:
171
175
  try:
172
176
  if not self._validate_file(file_data):
173
177
  return None
174
-
178
+
175
179
  # 计算文件MD5
176
180
  md5 = self._calculate_md5(file_data)
177
-
181
+
178
182
  # 检查缓存中是否已存在该MD5的URL
179
183
  cached_url = self._get_cached_url(md5)
180
184
  if cached_url:
181
- # 从缓存中获取尺寸信息
182
- try:
183
- dimensions = get_image_size(file_data)
184
- except:
185
- dimensions = (300, 300)
185
+ # 从URL中提取尺寸信息
186
+ dimensions = get_image_dimensions_from_url(cached_url)
187
+ if dimensions:
188
+ width, height = dimensions
189
+ else:
190
+ # 如果无法从URL中提取尺寸信息,尝试重新获取,否则则使用默认值
191
+ try:
192
+ width, height = get_image_size(file_data)
193
+ except:
194
+ width, height = (300, 300)
195
+
186
196
  # 返回缓存的结果
187
197
  return {
188
198
  'success': True,
@@ -190,19 +200,21 @@ class COSUploader:
190
200
  'file_url': cached_url,
191
201
  'filename': os.path.basename(cached_url),
192
202
  'file_size': sys.getsizeof(file_data),
193
- 'width': dimensions[0],
194
- 'height': dimensions[1],
195
- 'px': f'#{dimensions[0]}px #{dimensions[1]}px',
203
+ 'width': width,
204
+ 'height': height,
205
+ 'px': f'#{width}px #{height}px',
196
206
  'cached': True
197
207
  }
198
-
208
+
209
+ # 获取图片尺寸
199
210
  try:
200
211
  dimensions = get_image_size(file_data)
201
212
  except:
202
213
  dimensions = (300, 300)
203
-
214
+ width, height = dimensions
215
+
204
216
  # 使用MD5作为文件名生成cos_key
205
- cos_key = self._generate_cos_key(user_id, md5, file_data)
217
+ cos_key = self._generate_cos_key(user_id, md5, file_data, width, height)
206
218
  response = self.client.put_object(Bucket=self.config.bucket_name, Body=BytesIO(file_data),
207
219
  Key=cos_key, ContentType=self._get_content_type(file_data))
208
220
  base_url = f"https://{self.config.domain}" if self.config.domain else \
@@ -213,10 +225,14 @@ class COSUploader:
213
225
  return {
214
226
  'success': True, 'cos_key': cos_key, 'file_url': file_url,
215
227
  'filename': os.path.basename(cos_key), 'file_size': sys.getsizeof(file_data),
216
- 'width': dimensions[0], 'height': dimensions[1], 'px': f'#{dimensions[0]}px #{dimensions[1]}px',
228
+ 'width': width, 'height': height, 'px': f'#{width}px #{height}px',
217
229
  'cached': False
218
230
  }
219
231
  except:
232
+ if response:
233
+ logger.warning(f"cos上传失败:resp为:{response}\ntraceback:{traceback.format_exc()}")
234
+ else:
235
+ logger.warning(f"cos上传失败:traceback:{traceback.format_exc()}")
220
236
  return None
221
237
 
222
238
  def delete_file(self, cos_key: str) -> bool:
@@ -304,17 +320,30 @@ def upload_image(file_data: bytes, user_id: str = None, return_url_only: bool =
304
320
  return result['file_url'] if result and return_url_only else result
305
321
 
306
322
 
307
- def upload_file(file_data: bytes, user_id: str = None, return_url_only: bool = False):
308
- return upload_image(file_data, user_id, return_url_only=return_url_only)
323
+ def cos_upload_file(file_data: bytes, user_id: str = None):
324
+ """上传文件到COS
325
+
326
+ Args:
327
+ file_data: 文件数据的bytes类型
328
+ user_id: 用户ID
329
+
330
+ Returns:
331
+ 上传结果
332
+ """
333
+ result = upload_image(file_data, user_id)
334
+ url = result.get('file_url')
335
+ width = result.get('width', 300)
336
+ height = result.get('height', 300)
337
+ return url, (width, height)
309
338
 
310
339
 
311
- def simple_upload_file(file_data: bytes, user_id: str = None):
340
+ def cos_simple_upload_file(file_data: bytes, user_id: str = None):
312
341
  return upload_image(file_data, user_id, return_url_only=True)
313
342
 
314
343
 
315
344
  def _get_cos_base_url() -> str:
316
- base_url = f"https://{cos_uploader.config['domain']}" if cos_uploader.config.get('domain') else \
317
- f"https://{cos_uploader.config['bucket_name']}.cos.{cos_uploader.config['region']}.myqcloud.com"
345
+ base_url = f"https://{cos_uploader.config.domain}" if cos_uploader.config.domain else \
346
+ f"https://{cos_uploader.config.bucket_name}.cos.{cos_uploader.config.region}.myqcloud.com"
318
347
  return base_url
319
348
 
320
349
 
@@ -327,3 +356,26 @@ def delete_by_url(file_url: str):
327
356
  return False
328
357
  base_url = _get_cos_base_url()
329
358
  return cos_uploader.delete_file(file_url[len(base_url):]) if file_url.startswith(base_url) else False
359
+
360
+
361
+ def get_image_dimensions_from_url(url: str) -> Optional[Tuple[int, int]]:
362
+ """从URL中提取图片的宽高数据
363
+
364
+ Args:
365
+ url: 图片URL,文件名格式为: {md5}_w{width}h{height}{ext}
366
+
367
+ Returns:
368
+ Optional[Tuple[int, int]]: 图片的宽高元组(width, height),如果解析失败则返回None
369
+ """
370
+ try:
371
+ # 从URL中提取文件名
372
+ filename = os.path.basename(url)
373
+ # 使用正则表达式匹配宽高数据
374
+ match = re.search(r'_w(\d+)h(\d+)', filename)
375
+ if match:
376
+ width = int(match.group(1))
377
+ height = int(match.group(2))
378
+ return (width, height)
379
+ return None
380
+ except:
381
+ return None
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "nonebot-plugin-splatoon3-schedule"
3
- version = "2.0.5"
3
+ version = "2.0.6"
4
4
  description = "一个基于nonebot2框架的splatoon3游戏日程查询插件"
5
5
  authors = ["cypas <ayano05@outlook.com>"]
6
6
  readme = "README.md"