mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-02 09:26:12 +08:00
✨ 集中判断是否为CookieClientManager
This commit is contained in:
parent
0ce2893911
commit
6537f01a34
@ -7,6 +7,7 @@ from ..config.db_model import Target
|
||||
from ..types import Target as T_Target
|
||||
from ..platform import platform_manager
|
||||
from ..plugin_config import plugin_config
|
||||
from ..utils.site import is_cookie_client_manager
|
||||
|
||||
scheduler_dict: dict[type[Site], Scheduler] = {}
|
||||
|
||||
@ -30,7 +31,7 @@ async def init_scheduler():
|
||||
else:
|
||||
_schedule_class_platform_dict[site].append(platform_name)
|
||||
for site, target_list in _schedule_class_dict.items():
|
||||
if hasattr(site.client_mgr, "_cookie_client_manger_"):
|
||||
if is_cookie_client_manager(site.client_mgr):
|
||||
await site.client_mgr.init_universal_cookie()
|
||||
if not plugin_config.bison_use_browser and site.require_browser:
|
||||
logger.warning(f"{site.name} requires browser, it will not schedule.")
|
||||
|
@ -8,6 +8,7 @@ from ..config import config
|
||||
from ..config.db_model import Cookie
|
||||
from ..platform import platform_manager
|
||||
from ..apis import check_sub_target_cookie
|
||||
from ..utils.site import is_cookie_client_manager
|
||||
from .utils import common_platform, gen_handle_cancel
|
||||
|
||||
|
||||
@ -22,7 +23,7 @@ def do_add_cookie(add_cookie: type[Matcher]):
|
||||
[
|
||||
f"{platform_name}: {platform_manager[platform_name].name}\n"
|
||||
for platform_name in common_platform
|
||||
if hasattr(platform_manager[platform_name].site.client_mgr, "_cookie_client_manger_")
|
||||
if is_cookie_client_manager(platform_manager[platform_name].site.client_mgr)
|
||||
]
|
||||
)
|
||||
+ "要查看全部平台请输入:“全部”\n中止添加cookie过程请输入:“取消”"
|
||||
@ -35,7 +36,7 @@ def do_add_cookie(add_cookie: type[Matcher]):
|
||||
[
|
||||
f"{platform_name}: {platform.name}"
|
||||
for platform_name, platform in platform_manager.items()
|
||||
if hasattr(platform_manager[platform_name].site.client_mgr, "_cookie_client_manger_")
|
||||
if is_cookie_client_manager(platform_manager[platform_name].site.client_mgr)
|
||||
]
|
||||
)
|
||||
await add_cookie.reject(message)
|
||||
|
@ -41,6 +41,10 @@ class DefaultClientManager(ClientManager):
|
||||
pass
|
||||
|
||||
|
||||
def is_cookie_client_manager(manger: type[ClientManager]) -> bool:
|
||||
return hasattr(manger, "_cookie_client_manger_")
|
||||
|
||||
|
||||
class CookieClientManager(ClientManager):
|
||||
_cookie_client_manger_ = True
|
||||
_platform_name: str
|
||||
|
Loading…
x
Reference in New Issue
Block a user