diff --git a/nonebot_bison/platform/bilibili/scheduler.py b/nonebot_bison/platform/bilibili/scheduler.py index 060e72ed..36852491 100644 --- a/nonebot_bison/platform/bilibili/scheduler.py +++ b/nonebot_bison/platform/bilibili/scheduler.py @@ -27,7 +27,6 @@ class BilibiliClientManager(CookieClientManager): _inited: bool = False _site_name: str = "bilibili.com" - _default_cd: int = timedelta(seconds=120) def __init__(self) -> None: self._client = http_client() @@ -97,6 +96,7 @@ class BilibiliSite(CookieSite): schedule_type = "interval" client_mgr = BilibiliClientManager require_browser = True + default_cd: int = timedelta(seconds=120) class BililiveSite(Site): diff --git a/nonebot_bison/platform/weibo.py b/nonebot_bison/platform/weibo.py index 7d65394b..71733746 100644 --- a/nonebot_bison/platform/weibo.py +++ b/nonebot_bison/platform/weibo.py @@ -1,8 +1,8 @@ import re import json from typing import Any -from datetime import datetime from urllib.parse import unquote +from datetime import datetime, timedelta from yarl import URL from lxml.etree import HTML @@ -41,6 +41,7 @@ class WeiboSite(CookieSite): schedule_type = "interval" schedule_setting = {"seconds": 3} client_mgr = create_cookie_client_manager(name) + default_cd: int = timedelta(seconds=15) @classmethod async def _get_current_user_name(cls, cookies: dict) -> str: diff --git a/nonebot_bison/utils/site.py b/nonebot_bison/utils/site.py index 97ba8446..1827624b 100644 --- a/nonebot_bison/utils/site.py +++ b/nonebot_bison/utils/site.py @@ -44,7 +44,6 @@ async def refresh_client(self): class CookieClientManager(ClientManager): _site_name: str # 绑定的 site_name,需要使用 create_cookie_client_manager 创建 Client_mgr 时绑定 - _default_cd: int = timedelta(seconds=10) @classmethod async def _generate_anonymous_cookie(cls) -> Cookie: @@ -83,7 +82,7 @@ async def add_user_cookie(cls, content: str, cookie_name: str | None = None) -> raise ValueError() cookie = Cookie(site_name=cls._site_name, content=content) cookie.cookie_name = cookie_name if cookie_name else await cookie_site.get_cookie_name(content) - cookie.cd = cls._default_cd + cookie.cd = cookie_site.default_cd cookie_id = await config.add_cookie(cookie) return await config.get_cookie_by_id(cookie_id) @@ -166,6 +165,7 @@ def __str__(self): class CookieSite(Site): client_mgr: type[CookieClientManager] = CookieClientManager + default_cd: int = timedelta(seconds=10) @classmethod async def get_cookie_name(cls, content: str) -> str: