diff --git a/README.md b/README.md index b602281..4db1179 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,10 @@ Telegram:[@lgc2333](https://t.me/lgc2333) ## 📝 更新日志 +### 0.3.1 + +- 兼容 HTTPX 0.28 + ### 0.3.0 - 适配 Pydantic V1 & V2 diff --git a/nonebot_plugin_nonememe/__init__.py b/nonebot_plugin_nonememe/__init__.py index a643866..0262f3c 100644 --- a/nonebot_plugin_nonememe/__init__.py +++ b/nonebot_plugin_nonememe/__init__.py @@ -7,7 +7,7 @@ from . import __main__ as __main__ # noqa: E402 from .config import ConfigModel # noqa: E402 -__version__ = "0.3.0" +__version__ = "0.3.1" __plugin_meta__ = PluginMetadata( name="NoneMeme", description="NoneBot 群大佬的日常", diff --git a/nonebot_plugin_nonememe/__main__.py b/nonebot_plugin_nonememe/__main__.py index 44febc0..9ed1970 100644 --- a/nonebot_plugin_nonememe/__main__.py +++ b/nonebot_plugin_nonememe/__main__.py @@ -1,5 +1,5 @@ import random -from typing import List, NoReturn +from typing import NoReturn from nonebot import logger, on_command from nonebot.adapters import Event, Message @@ -67,7 +67,7 @@ async def _(matcher: Matcher, state: T_State, event: Event): if arg in ("0", "q", "quit", "exit", "退出"): await matcher.finish("已退出选择") - searched: List[MemeItem] = state["items"] + searched: list[MemeItem] = state["items"] if not (arg.isdigit() and (0 <= (index := (int(arg) - 1)) < len(searched))): await matcher.reject("请输入正确的结果序号,退出选择请发送 `0`") diff --git a/nonebot_plugin_nonememe/data_source.py b/nonebot_plugin_nonememe/data_source.py index 78d9252..9ebdfc3 100644 --- a/nonebot_plugin_nonememe/data_source.py +++ b/nonebot_plugin_nonememe/data_source.py @@ -2,7 +2,7 @@ import re import urllib.parse from pathlib import Path -from typing import List, cast +from typing import cast import anyio import json5 @@ -31,13 +31,13 @@ class MemeItem(BaseModel): path: str -meme_list: List[MemeItem] = [] +meme_list: list[MemeItem] = [] def search_meme_items( keyword: str, use_regex: bool = False, # noqa: FBT001 -) -> List[MemeItem]: +) -> list[MemeItem]: if use_regex: pattern = re.compile(keyword, re.IGNORECASE) return [item for item in meme_list if pattern.search(item.name)] @@ -52,7 +52,7 @@ def search_meme_items( async def fetch_meme(path: str) -> bytes: - async with AsyncClient(proxies=config.nonememe_proxy) as cli: + async with AsyncClient(proxy=config.nonememe_proxy) as cli: resp = await cli.get(f"{config.nonememe_repo_prefix}/{path}") return resp.content @@ -72,13 +72,13 @@ def build_meme_item(meme_path: str) -> MemeItem: return MemeItem(name=path_obj.stem, suffix=path_obj.suffix, path=meme_path) -async def fetch_meme_list() -> List[MemeItem]: - async with AsyncClient(proxies=config.nonememe_proxy) as cli: +async def fetch_meme_list() -> list[MemeItem]: + async with AsyncClient(proxy=config.nonememe_proxy) as cli: resp = await cli.get(f"{config.nonememe_repo_prefix}/static/scripts/config.js") text = resp.text text = text[text.find("{") : text.rfind("}") + 1] - items: List[str] = cast(dict, json5.loads(text))["items"] + items: list[str] = cast(dict, json5.loads(text))["items"] return [build_meme_item(item) for item in items] @@ -104,7 +104,7 @@ async def update_meme_list(): logger.warning("Failed to fetch meme list, use cache instead") got_meme_list = type_validate_json( - List[MemeItem], + list[MemeItem], await cache_json_path.read_text(encoding="u8"), )