diff --git a/src/nonebot_plugin_alconna/__init__.py b/src/nonebot_plugin_alconna/__init__.py index 2e76158..e0d2aea 100644 --- a/src/nonebot_plugin_alconna/__init__.py +++ b/src/nonebot_plugin_alconna/__init__.py @@ -128,7 +128,7 @@ from .uniseg import SupportAdapterModule as SupportAdapterModule from .extension import add_global_extension as add_global_extension -__version__ = "0.50.0" +__version__ = "0.50.1" __plugin_meta__ = PluginMetadata( name="Alconna 插件", diff --git a/src/nonebot_plugin_alconna/pattern.py b/src/nonebot_plugin_alconna/pattern.py index 349188f..d092045 100644 --- a/src/nonebot_plugin_alconna/pattern.py +++ b/src/nonebot_plugin_alconna/pattern.py @@ -39,7 +39,7 @@ def __init__( converter=converter, alias=f"select({target.__name__})", ) - self.accept = lambda x: isinstance(x, target) + self.accept = lambda x: isinstance(x, Segment) def match(self, input_: TS2): if not self.accept(input_): diff --git a/src/nonebot_plugin_alconna/uniseg/__init__.py b/src/nonebot_plugin_alconna/uniseg/__init__.py index 0bfc709..406a6f2 100644 --- a/src/nonebot_plugin_alconna/uniseg/__init__.py +++ b/src/nonebot_plugin_alconna/uniseg/__init__.py @@ -53,7 +53,7 @@ from .constraint import SupportAdapterModule as SupportAdapterModule from .adapters import BUILDER_MAPPING, FETCHER_MAPPING, EXPORTER_MAPPING -__version__ = "0.50.0" +__version__ = "0.50.1" __plugin_meta__ = PluginMetadata( name="Universal Segment 插件", diff --git a/tests/test_uniseg.py b/tests/test_uniseg.py index d144ac7..0050546 100644 --- a/tests/test_uniseg.py +++ b/tests/test_uniseg.py @@ -28,7 +28,14 @@ def test_uniseg(): Text("man").italic(0, 1), ] - assert select(Text).from_(Video).first.validate(Video(url="foobar")(Text("foobar"))).value() == Text("foobar") + pat = select(Text) + assert pat.first.validate(Text("foobar")).value() == Text("foobar") + assert pat.first.validate(Video(url="foobar")(Text("foobar"))).value() == Text("foobar") + assert pat.first.validate(Other(FallbackSegment.text("foobar"))(Text("foobar"))).value() == Text("foobar") + pat1 = select(Text).from_(Video) + assert pat1.first.validate(Text("foobar")).failed + assert pat1.first.validate(Video(url="foobar")(Text("foobar"))).value() == Text("foobar") + assert pat1.first.validate(Other(FallbackSegment.text("foobar"))(Text("foobar"))).failed def test_unimsg():