From b1657305f8a05356decfd3334b5b58a95ef8b59a Mon Sep 17 00:00:00 2001 From: RF-Tar-Railt Date: Tue, 17 Dec 2024 17:57:47 +0800 Subject: [PATCH] :beers: version 0.10.4 simplify self log --- arclet/entari/__init__.py | 3 +-- arclet/entari/command/provider.py | 2 +- arclet/entari/core.py | 10 ++++++---- arclet/entari/event/send.py | 4 ++-- arclet/entari/message.py | 7 ++++++- pyproject.toml | 2 +- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/arclet/entari/__init__.py b/arclet/entari/__init__.py index 90712a3..8858126 100644 --- a/arclet/entari/__init__.py +++ b/arclet/entari/__init__.py @@ -37,7 +37,6 @@ from satori.client import Account as Account from satori.client.config import WebhookInfo as WebhookInfo from satori.client.config import WebsocketsInfo as WebsocketsInfo -from satori.client.protocol import ApiProtocol as ApiProtocol from . import command as command from . import scheduler as scheduler @@ -64,4 +63,4 @@ WH = WebhookInfo filter_ = Filter -__version__ = "0.10.3" +__version__ = "0.10.4" diff --git a/arclet/entari/command/provider.py b/arclet/entari/command/provider.py index 05c888a..8e3a8ab 100644 --- a/arclet/entari/command/provider.py +++ b/arclet/entari/command/provider.py @@ -138,7 +138,7 @@ async def __call__(self, context: Contexts): class Assign(JudgeAuxiliary): def __init__(self, path: str, value: Any = _seminal, or_not: bool = False): - super().__init__() + super().__init__(priority=60) self.path = path self.value = value self.or_not = or_not diff --git a/arclet/entari/core.py b/arclet/entari/core.py index fcd4d0b..22add8f 100644 --- a/arclet/entari/core.py +++ b/arclet/entari/core.py @@ -79,14 +79,16 @@ async def log_msg(event: MessageCreatedEvent): f"({event.user.id}) -> {event.message.content!r}" ) - if cfg.get("record_send", True): + if cfg.get("record_send", False): @plg.use(SendResponse) async def log_send(event: SendResponse): if event.session: - log.message.info(f"[{event.session.channel.name or event.session.channel.id}] <- {event.message!r}") + log.message.info( + f"[{event.session.channel.name or event.session.channel.id}] <- {event.message.display()!r}" + ) else: - log.message.info(f"[{event.channel}] <- {event.message!r}") + log.message.info(f"[{event.channel}] <- {event.message.display()!r}") class Entari(App): @@ -132,7 +134,7 @@ def __init__( for plug in EntariConfig.instance.prelude_plugin: load_plugin(plug, prelude=True) plugins = [ - plug for plug in EntariConfig.instance.plugin if not plug.startswith("~") or not plug.startswith("$") + plug for plug in EntariConfig.instance.plugin if not plug.startswith("~") and not plug.startswith("$") ] requires(*plugins) for plug in plugins: diff --git a/arclet/entari/event/send.py b/arclet/entari/event/send.py index a411b40..f1bd0ff 100644 --- a/arclet/entari/event/send.py +++ b/arclet/entari/event/send.py @@ -8,7 +8,7 @@ from ..message import MessageChain if TYPE_CHECKING: - from ..session import Session + from ..session import SatoriEvent, Session @dataclass @@ -16,7 +16,7 @@ class SendRequest: account: Account channel: str message: MessageChain - session: Union["Session", None] = None + session: Union["Session[SatoriEvent]", None] = None async def gather(self, context: Contexts): context["account"] = self.account diff --git a/arclet/entari/message.py b/arclet/entari/message.py index f7b0c93..553e099 100644 --- a/arclet/entari/message.py +++ b/arclet/entari/message.py @@ -5,8 +5,8 @@ from typing import TYPE_CHECKING, Any, Callable, TypeVar, Union, overload from typing_extensions import Self, SupportsIndex, TypeAlias -from satori import Element, Text from satori import select as satori_select +from satori.element import At, Element, Link, Sharp, Style, Text T = TypeVar("T") TE = TypeVar("TE", bound=Element) @@ -610,3 +610,8 @@ def rstrip(self, *segments: str | Element | type[Element]) -> Self: else: break return self.__class__(copy) + + def display(self): + return "".join( + str(elem) if isinstance(elem, (Text, Style, At, Sharp, Link)) else elem.__class__.__name__ for elem in self + ) diff --git a/pyproject.toml b/pyproject.toml index 470ecf4..bb05c5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "arclet-entari" -version = "0.10.3" +version = "0.10.4" description = "Simple IM Framework based on satori-python" authors = [ {name = "RF-Tar-Railt",email = "rf_tar_railt@qq.com"},