mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-06-23 14:16:52 +08:00
🏷️ update type hints 2
This commit is contained in:
@@ -24,9 +24,9 @@ def do_add_cookie_target(add_cookie_target_matcher: type[Matcher]):
|
||||
await MessageFactory(await parse_text(res)).send()
|
||||
|
||||
@add_cookie_target_matcher.got("target_idx", parameterless=[handle_cancel])
|
||||
async def got_target_idx(state: T_State, target_idx: str = ArgPlainText()):
|
||||
async def got_target_idx(state: T_State, target_idx_str: str = ArgPlainText()):
|
||||
try:
|
||||
target_idx = int(target_idx)
|
||||
target_idx = int(target_idx_str)
|
||||
state["target"] = state["sub_table"][target_idx]
|
||||
state["site"] = platform_manager[state["target"]["platform_name"]].site
|
||||
except Exception:
|
||||
@@ -55,9 +55,9 @@ def do_add_cookie_target(add_cookie_target_matcher: type[Matcher]):
|
||||
)
|
||||
|
||||
@add_cookie_target_matcher.got("cookie_idx", MessageTemplate("{_prompt}"), [handle_cancel])
|
||||
async def got_cookie_idx(state: T_State, cookie_idx: str = ArgPlainText()):
|
||||
async def got_cookie_idx(state: T_State, cookie_idx_str: str = ArgPlainText()):
|
||||
try:
|
||||
cookie_idx = int(cookie_idx)
|
||||
cookie_idx = int(cookie_idx_str)
|
||||
state["cookie"] = state["cookies"][cookie_idx - 1]
|
||||
except Exception:
|
||||
await add_cookie_target_matcher.reject("序号错误")
|
||||
|
||||
@@ -8,11 +8,13 @@ from nonebot.adapters import Event
|
||||
from nonebot.typing import T_State
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.adapters.onebot.v11 import PrivateMessageEvent
|
||||
from nonebot.params import Depends, EventToMe, EventPlainText
|
||||
from nonebot_plugin_saa import PlatformTarget, extract_target
|
||||
|
||||
from ..config import config
|
||||
from ..types import Category
|
||||
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
|
||||
@@ -88,7 +90,7 @@ async def generate_sub_list_text(
|
||||
sub_list = [
|
||||
sub
|
||||
for sub in sub_list
|
||||
if is_cookie_client_manager(platform_manager.get(sub.target.platform_name).site.client_mgr)
|
||||
if is_cookie_client_manager(platform_manager[sub.target.platform_name].site.client_mgr)
|
||||
]
|
||||
if not sub_list:
|
||||
await matcher.finish("暂无已订阅账号\n请使用“添加订阅”命令添加订阅")
|
||||
@@ -109,7 +111,7 @@ async def generate_sub_list_text(
|
||||
res += " {}".format(", ".join(sub.tags)) + "\n"
|
||||
if is_show_cookie:
|
||||
target_cookies = await config.get_cookie(
|
||||
target=sub.target.target, site_name=platform.site.name, is_anonymous=False
|
||||
target=T_Target(sub.target.target), site_name=platform.site.name, is_anonymous=False
|
||||
)
|
||||
if target_cookies:
|
||||
res += " 关联的 Cookie:\n"
|
||||
@@ -126,6 +128,5 @@ async def only_allow_private(
|
||||
event: Event,
|
||||
matcher: type[Matcher],
|
||||
):
|
||||
# if not issubclass(PrivateMessageEvent, event.__class__):
|
||||
if event.message_type != "private":
|
||||
if not issubclass(PrivateMessageEvent, event.__class__):
|
||||
await matcher.finish("请在私聊中使用此命令")
|
||||
|
||||
Reference in New Issue
Block a user