diff --git a/src/plugins/nonebot_bison/platform/bilibili.py b/src/plugins/nonebot_bison/platform/bilibili.py index 94327ec..b6c83c9 100644 --- a/src/plugins/nonebot_bison/platform/bilibili.py +++ b/src/plugins/nonebot_bison/platform/bilibili.py @@ -42,7 +42,7 @@ class Bilibili(NewMessage): async def parse_target(self, target_text: str) -> Target: if re.match(r"\d+", target_text): return Target(target_text) - elif match := re.match(r"(?:https://)?space.bilibili.com/(\d+)", target_text): + elif match := re.match(r"(?:https?://)?space.bilibili.com/(\d+)", target_text): return Target(match.group(1)) else: raise Platform.ParseTargetException() diff --git a/src/plugins/nonebot_bison/platform/weibo.py b/src/plugins/nonebot_bison/platform/weibo.py index 2e9f46b..7d5ef57 100644 --- a/src/plugins/nonebot_bison/platform/weibo.py +++ b/src/plugins/nonebot_bison/platform/weibo.py @@ -9,7 +9,7 @@ from nonebot.log import logger from ..post import Post from ..types import * -from .platform import NewMessage +from .platform import NewMessage, Platform class Weibo(NewMessage): @@ -28,6 +28,7 @@ class Weibo(NewMessage): schedule_type = "interval" schedule_kw = {"seconds": 3} has_target = True + parse_target_promot = "请输入用户主页(包含数字UID)的链接" async def get_target_name(self, target: Target) -> Optional[str]: async with httpx.AsyncClient() as client: @@ -41,6 +42,15 @@ class Weibo(NewMessage): else: return None + async def parse_target(self, target_text: str) -> Target: + if re.match(r"\d+", target_text): + return Target(target_text) + elif match := re.match(r"(?:https?://)?weibo.com/u/(\d+)", target_text): + # 都2202年了应该不会有http了吧,不过还是防一手 + return Target(match.group(1)) + else: + raise Platform.ParseTargetException() + async def get_sub_list(self, target: Target) -> list[RawPost]: async with httpx.AsyncClient() as client: params = {"containerid": "107603" + target}