diff --git a/pdm.lock b/pdm.lock index 92fb270..8dc5e4a 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev", "lint"] strategy = ["cross_platform"] lock_version = "4.4" -content_hash = "sha256:65785b5d76b5b0865037142503769befe68c915f91aac3e0613b5941a59c15b4" +content_hash = "sha256:5b6554f1de32655ab74495412330dbd7de9e2d4a8269e185ab69341c48bec374" [[package]] name = "aiofiles" diff --git a/pyproject.toml b/pyproject.toml index 7c5bdb5..6f2fea8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,9 @@ description = "Bison 官方主题仓库" authors = [ {name = "AzideCupric", email = "rukuy@qq.com"}, ] -dependencies = [] +dependencies = [ + "nonebot-plugin-htmlrender>=0.2.2", +] requires-python = ">=3.10" readme = "README.md" license = {text = "MIT"} @@ -25,7 +27,6 @@ requires-python = ">=3.10" dependencies = [ "nonebot-plugin-htmlrender>=0.2.2" ] -optional-dependencies = [] entry-points = {pdm = {mina = "mina.plugin:ensure_pdm"}} [tool.mina.packages.basic-theme] @@ -41,7 +42,6 @@ authors = [ version = "0.1.0" requires-python = ">=3.10" dependencies = [] -optional-dependencies = [] entry-points = {pdm = {mina = "mina.plugin:ensure_pdm"}} [tool.mina.packages.brief-theme] @@ -57,7 +57,6 @@ authors = [ version = "0.1.0" requires-python = ">=3.10" dependencies = [] -optional-dependencies = [] entry-points = {pdm = {mina = "mina.plugin:ensure_pdm"}} [tool.mina.packages.ceobecanteen-theme] @@ -75,7 +74,6 @@ requires-python = ">=3.10" dependencies = [ "nonebot-plugin-htmlrender>=0.2.2" ] -optional-dependencies = [] entry-points = {pdm = {mina = "mina.plugin:ensure_pdm"}} @@ -94,7 +92,6 @@ requires-python = ">=3.10" dependencies = [ "nonebot-plugin-htmlrender>=0.2.2" ] -optional-dependencies = [] entry-points = {pdm = {mina = "mina.plugin:ensure_pdm"}} diff --git a/theme-template/__init__.py b/theme-template/__init__.py index ffd2807..de17f33 100644 --- a/theme-template/__init__.py +++ b/theme-template/__init__.py @@ -4,8 +4,8 @@ require("nonebot_bison") from nonebot_bison.theme import theme_manager +from .config import Config from .parse import NewTheme -from .config import ThemeConfig __plugin_meta__ = PluginMetadata( "", @@ -13,7 +13,7 @@ usage="", type="library", homepage="https://github.com/MountainDash/bison-themes/", - config=ThemeConfig, + config=Config, supported_adapters=inherit_supported_adapters("nonebot_bison"), ) diff --git a/themes/arknights-theme/__init__.py b/themes/arknights-theme/__init__.py index 8f81f97..e10bf54 100644 --- a/themes/arknights-theme/__init__.py +++ b/themes/arknights-theme/__init__.py @@ -4,7 +4,7 @@ require("nonebot_bison") from nonebot_bison.theme import theme_manager -from .config import ThemeConfig +from .config import Config from .parse import ArknightsTheme __plugin_meta__ = PluginMetadata( @@ -13,7 +13,7 @@ usage="pip install nonebot-bison-theme-arknights", type="library", homepage="https://github.com/MountainDash/bison-themes/arknights-theme", - config=ThemeConfig, + config=Config, supported_adapters=inherit_supported_adapters("nonebot_bison"), ) diff --git a/themes/basic-theme/__init__.py b/themes/basic-theme/__init__.py index b40b453..d9a4550 100644 --- a/themes/basic-theme/__init__.py +++ b/themes/basic-theme/__init__.py @@ -4,8 +4,8 @@ require("nonebot_bison") from nonebot_bison.theme import theme_manager +from .config import Config from .parse import BasicTheme -from .config import ThemeConfig __plugin_meta__ = PluginMetadata( "bison-themes-basic", @@ -13,7 +13,7 @@ usage="pip install nonebot-bison-theme-basic", type="library", homepage="https://github.com/MountainDash/bison-themes/basic-theme", - config=ThemeConfig, + config=Config, supported_adapters=inherit_supported_adapters("nonebot_bison"), ) diff --git a/themes/basic-theme/config.py b/themes/basic-theme/config.py index 41a9fb7..0bd162d 100644 --- a/themes/basic-theme/config.py +++ b/themes/basic-theme/config.py @@ -3,7 +3,7 @@ class ThemeConfig(BaseModel): - max_cut_length: int = Field(500, description="最大截断长度") + basic_max_cut_length: int = Field(500, description="最大截断长度") class Config(BaseModel): diff --git a/themes/basic-theme/parse.py b/themes/basic-theme/parse.py index 272cf90..bbde053 100644 --- a/themes/basic-theme/parse.py +++ b/themes/basic-theme/parse.py @@ -26,8 +26,8 @@ async def render(self, post: "Post") -> list[MessageSegmentFactory]: text += ( post.content - if len(post.content) < theme_config.max_cut_length - else f"{post.content[:theme_config.max_cut_length]}..." + if len(post.content) < theme_config.basic_max_cut_length + else f"{post.content[:theme_config.basic_max_cut_length]}..." ) text += f"\n来源: {post.platform.name} {post.nickname or ''}\n" diff --git a/themes/brief-theme/__init__.py b/themes/brief-theme/__init__.py index 94c6254..4ecd6b2 100644 --- a/themes/brief-theme/__init__.py +++ b/themes/brief-theme/__init__.py @@ -4,8 +4,8 @@ require("nonebot_bison") from nonebot_bison.theme import theme_manager +from .config import Config from .parse import BriefTheme -from .config import ThemeConfig __plugin_meta__ = PluginMetadata( "bison-themes-brief", @@ -13,7 +13,7 @@ usage="pip install nonebot-bison-theme-brief", type="library", homepage="https://github.com/MountainDash/bison-themes/brief-theme", - config=ThemeConfig, + config=Config, supported_adapters=inherit_supported_adapters("nonebot_bison"), ) diff --git a/themes/ceobecanteen-theme/__init__.py b/themes/ceobecanteen-theme/__init__.py index 9bae9ae..dca2a2a 100644 --- a/themes/ceobecanteen-theme/__init__.py +++ b/themes/ceobecanteen-theme/__init__.py @@ -4,7 +4,7 @@ require("nonebot_bison") from nonebot_bison.theme import theme_manager -from .config import ThemeConfig +from .config import Config from .parse import CeobeCanteenTheme __plugin_meta__ = PluginMetadata( @@ -13,7 +13,7 @@ usage="pip install nonebot-bison-theme-ceobecanteen", type="library", homepage="https://github.com/MountainDash/bison-themes/ceobecanteen-theme", - config=ThemeConfig, + config=Config, supported_adapters=inherit_supported_adapters("nonebot_bison"), ) diff --git a/themes/ht2i-theme/__init__.py b/themes/ht2i-theme/__init__.py index 3cb0973..5bc5e95 100644 --- a/themes/ht2i-theme/__init__.py +++ b/themes/ht2i-theme/__init__.py @@ -4,8 +4,8 @@ require("nonebot_bison") from nonebot_bison.theme import theme_manager +from .config import Config from .parse import Ht2iTheme -from .config import ThemeConfig __plugin_meta__ = PluginMetadata( "bison-themes-ht2i", @@ -13,7 +13,7 @@ usage="pip install nonebot-bison-theme-ht2i", type="library", homepage="https://github.com/MountainDash/bison-themes/ht2i-theme", - config=ThemeConfig, + config=Config, supported_adapters=inherit_supported_adapters("nonebot_bison"), ) diff --git a/themes/ht2i-theme/config.py b/themes/ht2i-theme/config.py index 2a467eb..d5e0b2c 100644 --- a/themes/ht2i-theme/config.py +++ b/themes/ht2i-theme/config.py @@ -3,7 +3,7 @@ class ThemeConfig(BaseModel): - max_cut_length: int | None = Field(None, description="最大截断长度, None为不截断") + ht2i_max_cut_length: int | None = Field(None, description="最大截断长度, None为不截断") @validator("max_cut_length") def validate_max_cut_length(cls, v): diff --git a/themes/ht2i-theme/parse.py b/themes/ht2i-theme/parse.py index dbc55e3..8c9e32e 100644 --- a/themes/ht2i-theme/parse.py +++ b/themes/ht2i-theme/parse.py @@ -34,11 +34,11 @@ async def render(self, post: "Post"): if post.title: _text += f"{post.title}\n\n" - if theme_config.max_cut_length: + if theme_config.ht2i_max_cut_length: _text += ( post.content - if len(post.content) < theme_config.max_cut_length - else f"{post.content[:theme_config.max_cut_length]}..." + if len(post.content) < theme_config.ht2i_max_cut_length + else f"{post.content[:theme_config.ht2i_max_cut_length]}..." ) else: _text += post.content if len(post.content) < 500 else f"{post.content[:500]}..."