nonebot-plugin-splatoon3-schedule 2.0.7__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.
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/PKG-INFO +21 -21
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/README.md +1 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/check.py +63 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/config.py +3 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/data/__init__.py +1 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/data/data_source.py +44 -72
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/data/db_image.py +38 -5
- nonebot_plugin_splatoon3_schedule-2.0.8/nonebot_plugin_splatoon3_schedule/data/playwright_handler.py +437 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/data/static_data_getter.py +1 -3
- nonebot_plugin_splatoon3_schedule-2.0.8/nonebot_plugin_splatoon3_schedule/data/utils.py +47 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/image/image.py +47 -11
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/image/image_processer.py +41 -18
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/db/image.db +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/util.py +29 -30
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/utils/cos_upload.py +110 -64
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/utils/translation.py +177 -5
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/utils/utils.py +11 -0
- nonebot_plugin_splatoon3_schedule-2.0.8/pyproject.toml +56 -0
- nonebot_plugin_splatoon3_schedule-2.0.7/LICENSE +0 -21
- nonebot_plugin_splatoon3_schedule-2.0.7/pyproject.toml +0 -38
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/__init__.py +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/data/db_control.py +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/image/__init__.py +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/image/image_processer_tools.py +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10024.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10025.ico +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/10026.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/AREA.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/CLAM.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Cohozuna.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/GOAL.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Horrorboros.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/LOFT.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Megalodontia.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Random.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked-Challenge.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked-Open.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Ranked.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Regular.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/TURF_WAR.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/Triumvirate.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/X.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg2.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/bg3.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/big_run.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/black-texture.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/cat_paw_mask.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_bg2.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_fish.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/coop_mask.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/event_bg.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/festival_mask.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/fight_mask.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/filleted_corner.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/private.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/swim_ring.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/team_coop.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/ImageData/time_head_bg.png +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/font/Splatfont1.otf +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/font/Splatfont2.otf +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/font/cn.ttf +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/resource/font/common.otf +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/utils/__init__.py +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/utils/bot.py +0 -0
- {nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/nonebot_plugin_splatoon3_schedule/utils/dataClass.py +0 -0
{nonebot_plugin_splatoon3_schedule-2.0.7 → nonebot_plugin_splatoon3_schedule-2.0.8}/PKG-INFO
RENAMED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: nonebot-plugin-splatoon3-schedule
|
|
3
|
-
Version: 2.0.
|
|
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,21 +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:
|
|
17
|
-
Requires-Dist:
|
|
18
|
-
Requires-Dist:
|
|
19
|
-
Requires-Dist:
|
|
20
|
-
Requires-Dist:
|
|
21
|
-
Requires-Dist:
|
|
22
|
-
Requires-Dist:
|
|
23
|
-
Requires-Dist:
|
|
24
|
-
Requires-Dist: nonebot-adapter-
|
|
25
|
-
Requires-Dist: nonebot-
|
|
26
|
-
Requires-Dist:
|
|
27
|
-
Requires-Dist:
|
|
28
|
-
Requires-Dist:
|
|
29
|
-
Requires-Dist:
|
|
30
|
-
Requires-Dist:
|
|
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
|
|
31
31
|
Description-Content-Type: text/markdown
|
|
32
32
|
|
|
33
33
|
<div align="center">
|
|
@@ -200,8 +200,8 @@ splatoon3_schedule_plugin_priority_mode = False #日程插件的帮助菜单优
|
|
|
200
200
|
|
|
201
201
|
- https://splatoon3.ink 日程数据来源
|
|
202
202
|
- https://splatoonwiki.org 武器数据来源
|
|
203
|
+
- https://sendou.ink/builds 武器配装数据来源
|
|
203
204
|
|
|
204
205
|
## ⏳ Star 趋势
|
|
205
206
|
|
|
206
207
|
[](https://starchart.cc/Cypas/splatoon3-schedule)
|
|
207
|
-
|
|
@@ -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,需要将下面三行注释并取消再下面两行的注释
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import time
|
|
2
|
+
import random
|
|
2
3
|
|
|
3
|
-
from playwright.async_api import Browser, async_playwright
|
|
4
4
|
from playwright.sync_api import FloatRect
|
|
5
5
|
|
|
6
6
|
from .db_image import db_image
|
|
7
|
+
from .playwright_handler import get_screenshot
|
|
7
8
|
from ..utils import *
|
|
8
9
|
|
|
9
10
|
schedule_res = None
|
|
10
|
-
_browser = None
|
|
11
11
|
festivals_res = None
|
|
12
12
|
festivals_res_save_ymdt: str
|
|
13
13
|
|
|
@@ -77,8 +77,8 @@ def get_coop_info(_all=None):
|
|
|
77
77
|
return [
|
|
78
78
|
ImageInfo(
|
|
79
79
|
name=sch["setting"]["weapons"][_i]["name"]
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
+ "_"
|
|
81
|
+
+ sch["setting"]["weapons"][_i]["__splatoon3ink_id"],
|
|
82
82
|
url=sch["setting"]["weapons"][_i]["image"]["url"],
|
|
83
83
|
zh_name=get_trans_weapon(
|
|
84
84
|
sch["setting"]["weapons"][_i]["__splatoon3ink_id"]
|
|
@@ -290,7 +290,9 @@ def get_newest_event_or_coop():
|
|
|
290
290
|
"""
|
|
291
291
|
# 1. 处理时区和日期截取(只保留年月日,忽略时分秒)
|
|
292
292
|
# 获取当前 UTC+8 时间的日期部分
|
|
293
|
-
today = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(
|
|
293
|
+
today = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(
|
|
294
|
+
hours=8
|
|
295
|
+
)
|
|
294
296
|
today_date = today.date()
|
|
295
297
|
|
|
296
298
|
# 提取目标日期的日期部分
|
|
@@ -322,17 +324,30 @@ def get_newest_event_or_coop():
|
|
|
322
324
|
|
|
323
325
|
n_event_st, n_event_name = get_newest_event_data()
|
|
324
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()
|
|
325
328
|
msg = ""
|
|
326
329
|
if n_event_st:
|
|
327
|
-
is_recent, date_relation, weekday_desc = check_date_relation(
|
|
330
|
+
is_recent, date_relation, weekday_desc = check_date_relation(
|
|
331
|
+
time_converter(n_event_st)
|
|
332
|
+
)
|
|
328
333
|
if is_recent:
|
|
329
334
|
msg += f"{date_relation}{weekday_desc},{time_converter_h(n_event_st)}时开始会有活动:{n_event_name}"
|
|
330
335
|
if n_coop_st:
|
|
331
|
-
is_recent, date_relation, weekday_desc = check_date_relation(
|
|
336
|
+
is_recent, date_relation, weekday_desc = check_date_relation(
|
|
337
|
+
time_converter(n_coop_st)
|
|
338
|
+
)
|
|
332
339
|
if is_recent:
|
|
333
340
|
if msg:
|
|
334
341
|
msg += "\n"
|
|
335
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}"
|
|
336
351
|
return msg
|
|
337
352
|
|
|
338
353
|
|
|
@@ -365,6 +380,28 @@ def get_newest_event_data():
|
|
|
365
380
|
return "", ""
|
|
366
381
|
|
|
367
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
|
+
|
|
368
405
|
def get_newest_salmonrun_data():
|
|
369
406
|
"""
|
|
370
407
|
取最新big run或者团工 数据
|
|
@@ -392,68 +429,3 @@ def get_newest_salmonrun_data():
|
|
|
392
429
|
# coop_stage_name = get_trans_stage(newest_coop["setting"]["coopStage"]["id"])
|
|
393
430
|
st = newest_coop["startTime"]
|
|
394
431
|
return st, coop_name
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
async def init_browser() -> Browser:
|
|
398
|
-
"""初始化 browser 并唤起"""
|
|
399
|
-
global _browser
|
|
400
|
-
p = await async_playwright().start()
|
|
401
|
-
browser_args = [
|
|
402
|
-
# 设置默认字体
|
|
403
|
-
'--default-font-family="Noto Sans CJK"',
|
|
404
|
-
]
|
|
405
|
-
if proxy_address:
|
|
406
|
-
proxies = {"server": "http://{}".format(proxy_address)}
|
|
407
|
-
# 代理访问
|
|
408
|
-
_browser = await p.chromium.launch(proxy=proxies, args=browser_args)
|
|
409
|
-
else:
|
|
410
|
-
_browser = await p.chromium.launch(args=browser_args)
|
|
411
|
-
return _browser
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
async def get_browser() -> Browser:
|
|
415
|
-
"""获取目前唤起的 browser"""
|
|
416
|
-
global _browser
|
|
417
|
-
if _browser is None or not _browser.is_connected():
|
|
418
|
-
_browser = await init_browser()
|
|
419
|
-
return _browser
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
async def get_screenshot(
|
|
423
|
-
shot_url,
|
|
424
|
-
mode="pc",
|
|
425
|
-
selector=None,
|
|
426
|
-
shot_path=None,
|
|
427
|
-
) -> bytes:
|
|
428
|
-
"""通过 browser 获取 shot_url 中的网页截图"""
|
|
429
|
-
# playwright 要求不能有多个 browser 被同时唤起
|
|
430
|
-
browser = await get_browser()
|
|
431
|
-
if mode == "pc":
|
|
432
|
-
context = await browser.new_context(
|
|
433
|
-
viewport={"width": 1920, "height": 1080}, locale="zh-CH"
|
|
434
|
-
)
|
|
435
|
-
elif mode == "mobile":
|
|
436
|
-
context = await browser.new_context(
|
|
437
|
-
viewport={"width": 500, "height": 2000}, locale="zh-CH"
|
|
438
|
-
)
|
|
439
|
-
page = await context.new_page()
|
|
440
|
-
|
|
441
|
-
try:
|
|
442
|
-
await page.goto(shot_url, wait_until="load", timeout=300000)
|
|
443
|
-
await page.wait_for_timeout(1500)
|
|
444
|
-
if selector:
|
|
445
|
-
# 元素选择器
|
|
446
|
-
await page.wait_for_selector(selector)
|
|
447
|
-
element = await page.query_selector(selector)
|
|
448
|
-
screenshot = await element.screenshot(path=shot_path)
|
|
449
|
-
img = screenshot
|
|
450
|
-
else:
|
|
451
|
-
img = await page.screenshot(path=shot_path)
|
|
452
|
-
|
|
453
|
-
return img
|
|
454
|
-
except Exception as e:
|
|
455
|
-
logger.error("Screenshot failed" + str(e))
|
|
456
|
-
# return await page.screenshot(full_page=True)
|
|
457
|
-
raise e
|
|
458
|
-
finally:
|
|
459
|
-
await context.close()
|
|
@@ -243,7 +243,7 @@ class DBIMAGE:
|
|
|
243
243
|
|
|
244
244
|
def get_all_weapon_info(self) -> [dict]:
|
|
245
245
|
"""查询 全部武器信息"""
|
|
246
|
-
sql = f"select name,zh_name from WEAPON_INFO"
|
|
246
|
+
sql = f"select name,zh_name,zh_father_class from WEAPON_INFO"
|
|
247
247
|
c = self.conn.cursor()
|
|
248
248
|
c.execute(sql)
|
|
249
249
|
rows = c.fetchall()
|
|
@@ -294,12 +294,26 @@ class DBIMAGE:
|
|
|
294
294
|
self.conn.commit()
|
|
295
295
|
return result
|
|
296
296
|
|
|
297
|
-
def
|
|
298
|
-
"""
|
|
297
|
+
def get_build_info_by_deco(self, keywords, is_deco) -> dict:
|
|
298
|
+
"""通过关键词和贴牌取配装数据"""
|
|
299
299
|
if not is_deco:
|
|
300
|
-
sql = f"select * from BUILDS where keywords LIKE '%|{
|
|
300
|
+
sql = f"select * from BUILDS where keywords LIKE '%|{keywords}|%'"
|
|
301
301
|
else:
|
|
302
|
-
sql = f"select * from BUILDS where keywords LIKE '%|{
|
|
302
|
+
sql = f"select * from BUILDS where keywords LIKE '%|{keywords}|%' AND is_deco={is_deco}"
|
|
303
|
+
return self.model_get_build_info(sql)
|
|
304
|
+
|
|
305
|
+
def get_build_info_by_group_id(self, group_id, is_deco) -> dict:
|
|
306
|
+
"""通过分组和贴牌取配装数据"""
|
|
307
|
+
sql = f"select * from BUILDS where group_id ={group_id} and is_deco ={is_deco}"
|
|
308
|
+
return self.model_get_build_info(sql)
|
|
309
|
+
|
|
310
|
+
def get_build_info_by_keywords(self, keywords) -> dict:
|
|
311
|
+
"""通过关键词取配装数据"""
|
|
312
|
+
sql = f"select * from BUILDS where keywords LIKE '%{keywords}%'"
|
|
313
|
+
return self.model_get_build_info(sql)
|
|
314
|
+
|
|
315
|
+
def model_get_build_info(self, sql: str) -> dict:
|
|
316
|
+
"""取配装数据"""
|
|
303
317
|
c = self.conn.cursor()
|
|
304
318
|
c.execute(
|
|
305
319
|
sql,
|
|
@@ -314,5 +328,24 @@ class DBIMAGE:
|
|
|
314
328
|
self.conn.commit()
|
|
315
329
|
return result
|
|
316
330
|
|
|
331
|
+
def get_build_info(self, keywords, is_deco) -> dict:
|
|
332
|
+
"""取配装数据"""
|
|
333
|
+
res = self.get_build_info_by_deco(keywords, is_deco)
|
|
334
|
+
if not res:
|
|
335
|
+
# 尝试不限制贴牌搜索武器
|
|
336
|
+
res = self.get_build_info_by_deco(keywords, is_deco=0)
|
|
337
|
+
if res:
|
|
338
|
+
group_id = res.get("group_id")
|
|
339
|
+
# 通过group_id找到同组的武器
|
|
340
|
+
res = self.get_build_info_by_group_id(
|
|
341
|
+
group_id=group_id, is_deco=is_deco
|
|
342
|
+
)
|
|
343
|
+
else:
|
|
344
|
+
# 如果完整关键词大于等于两个字,兜底允许两个关键词直接匹配
|
|
345
|
+
if len(keywords) >= 2:
|
|
346
|
+
res = self.get_build_info_by_keywords(keywords)
|
|
347
|
+
|
|
348
|
+
return res
|
|
349
|
+
|
|
317
350
|
|
|
318
351
|
db_image = DBIMAGE()
|