From c5965ce153e4bd89fa31cd59b9d10ef6c7ba98b0 Mon Sep 17 00:00:00 2001 From: RF-Tar-Railt Date: Thu, 9 Jan 2025 23:55:15 +0800 Subject: [PATCH] :beers: @Filter() equals .bind --- arclet/entari/filter/common.py | 4 +++- example_plugin.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arclet/entari/filter/common.py b/arclet/entari/filter/common.py index e33a73f..72af25d 100644 --- a/arclet/entari/filter/common.py +++ b/arclet/entari/filter/common.py @@ -194,9 +194,11 @@ def to_me(self) -> Self: self.steps.append(ToMeJudger()) return self - def bind(self, func): + def __call__(self, func): return _bind(self)(func) + bind = __call__ + def and_(self, other: Union["Filter", _SessionFilter]) -> "Filter": new = Filter() _other = other if isinstance(other, Filter) else Filter(callback=other) diff --git a/example_plugin.py b/example_plugin.py index f8e82a7..b98828a 100644 --- a/example_plugin.py +++ b/example_plugin.py @@ -46,7 +46,7 @@ async def _(session: Session): return await session.send("Filter: public message, to me, and content is 'aaa'") -@disp_message.on(auxiliaries=[Filter().public().to_me().not_(lambda sess: str(sess.content) == "aaa")]) +@Filter().public().to_me().not_(lambda sess: str(sess.content) == "aaa") async def _(session: Session): return await session.send("Filter: public message, to me, but content is not 'aaa'")