mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-09 18:27:56 +08:00
🐛 B站请求策略阶段行为优化 (#610)
* 🐛 调整ruff的pytest警告 * 🐛 调整导入关系警告 * 🐛 删除奇怪无用的赋值和取值逻辑 * ✅ 不同测试部分所用变量应加以区分 * 🐛 subs_io model添加默认值 * 🐛 修完所有的 ruff PT001 警告 * 🔧 按ruff建议修改ruff配置 warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `pyproject.toml`: - 'ignore' -> 'lint.ignore' - 'select' -> 'lint.select' * 🔊 降低B站请求策略非Raise阶段API352的日志等级 * 🐛 Raise阶段应该 raise err * 🔊 日志添加平台名 * 🐛 bzhanhan调度继续降低至60s --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -236,15 +236,19 @@ def retry_for_352(api_func: Callable[[TBilibili, Target], Awaitable[list[DynRawP
|
||||
case RetryState.NROMAL | RetryState.REFRESH | RetryState.RAISE:
|
||||
try:
|
||||
res = await api_func(bls, *args, **kwargs)
|
||||
except ApiCode352Error:
|
||||
logger.error("API 352 错误")
|
||||
except ApiCode352Error as e:
|
||||
logger.warning("本次 Bilibili API 请求返回 352 错误码")
|
||||
await _retry_fsm.emit(RetryEvent.REQUEST_AND_RAISE)
|
||||
|
||||
if _retry_fsm.current_state == RetryState.RAISE:
|
||||
raise e
|
||||
|
||||
return []
|
||||
else:
|
||||
await _retry_fsm.emit(RetryEvent.REQUEST_AND_SUCCESS)
|
||||
return res
|
||||
case RetryState.BACKOFF:
|
||||
logger.warning("回避中,不请求")
|
||||
logger.warning("本次 Bilibili 请求回避中,不请求")
|
||||
await _retry_fsm.emit(RetryEvent.IN_BACKOFF_TIME)
|
||||
return []
|
||||
case _:
|
||||
|
||||
@@ -68,7 +68,7 @@ class BilibiliClientManager(ClientManager):
|
||||
|
||||
class BilibiliSite(Site):
|
||||
name = "bilibili.com"
|
||||
schedule_setting = {"seconds": 50}
|
||||
schedule_setting = {"seconds": 60}
|
||||
schedule_type = "interval"
|
||||
client_mgr = BilibiliClientManager
|
||||
require_browser = True
|
||||
|
||||
Reference in New Issue
Block a user