From 92139558a1b99ae994c5b630c4170b7160f9b1a8 Mon Sep 17 00:00:00 2001 From: aicorein <75575271+aicorein@users.noreply.github.com> Date: Wed, 22 Jan 2025 15:21:56 +0000 Subject: [PATCH] Update doc by Github Action --- _modules/index.html | 2 +- _modules/melobot/_meta.html | 24 +- _modules/melobot/adapter/base.html | 86 ++-- _modules/melobot/adapter/content.html | 44 +- _modules/melobot/adapter/generic.html | 30 +- _modules/melobot/adapter/model.html | 80 ++-- _modules/melobot/bot.html | 8 +- _modules/melobot/bot/base.html | 132 +++--- _modules/melobot/ctx.html | 124 +++--- _modules/melobot/di.html | 94 ++--- _modules/melobot/exceptions.html | 50 +-- _modules/melobot/handle.html | 18 +- _modules/melobot/handle/process.html | 94 ++--- _modules/melobot/io/base.html | 74 ++-- _modules/melobot/log.html | 10 +- _modules/melobot/log/base.html | 148 +++---- _modules/melobot/log/patch.html | 36 +- _modules/melobot/plugin/base.html | 72 ++-- _modules/melobot/plugin/ipc.html | 46 +-- _modules/melobot/protocols/base.html | 12 +- .../protocols/onebot/v11/adapter/action.html | 176 ++++---- .../protocols/onebot/v11/adapter/base.html | 186 ++++----- .../protocols/onebot/v11/adapter/echo.html | 172 ++++---- .../protocols/onebot/v11/adapter/event.html | 304 +++++++------- .../protocols/onebot/v11/adapter/segment.html | 376 +++++++++--------- .../melobot/protocols/onebot/v11/handle.html | 66 +-- .../melobot/protocols/onebot/v11/io/base.html | 28 +- .../protocols/onebot/v11/io/duplex_http.html | 46 +-- .../protocols/onebot/v11/io/forward.html | 46 +-- .../protocols/onebot/v11/io/reverse.html | 50 +-- .../protocols/onebot/v11/utils/abc.html | 82 ++-- .../protocols/onebot/v11/utils/check.html | 56 +-- .../protocols/onebot/v11/utils/match.html | 40 +- .../protocols/onebot/v11/utils/parse.html | 60 +-- _modules/melobot/session.html | 12 +- _modules/melobot/session/base.html | 106 ++--- _modules/melobot/session/option.html | 78 +++- _modules/melobot/typ.html | 102 ++--- _modules/melobot/utils.html | 122 +++--- _static/pygments.css | 320 +++++++-------- api/index.html | 2 +- api/melobot.adapter.html | 2 +- api/melobot.bot.html | 2 +- api/melobot.ctx.html | 2 +- api/melobot.di.html | 2 +- api/melobot.exceptions.html | 2 +- api/melobot.handle.html | 2 +- api/melobot.html | 2 +- api/melobot.io.html | 2 +- api/melobot.log.html | 2 +- api/melobot.plugin.html | 2 +- api/melobot.protocol.html | 2 +- api/melobot.session.html | 28 +- api/melobot.typ.html | 20 +- api/melobot.utils.html | 8 +- genindex.html | 4 +- index.html | 2 +- intro/action-echo.html | 18 +- intro/async-callable.html | 24 +- intro/create-bot.html | 10 +- intro/event-preprocess.html | 126 +++--- intro/event-process.html | 40 +- intro/index.html | 2 +- intro/msg-action.html | 56 +-- melobot-prev.html | 2 +- ob_api/index.html | 2 +- ob_api/v11.adapter.html | 2 +- ob_api/v11.const.html | 2 +- ob_api/v11.handle.html | 2 +- ob_api/v11.io.html | 2 +- ob_api/v11.utils.html | 2 +- ob_refer/event-action.html | 2 +- ob_refer/forward-msg.html | 2 +- ob_refer/impl.html | 2 +- ob_refer/index.html | 2 +- ob_refer/msg.html | 2 +- ob_refer/onebot.html | 2 +- ob_refer/preprocess.html | 2 +- objects.inv | Bin 7076 -> 7080 bytes py-modindex.html | 2 +- search.html | 2 +- searchindex.js | 2 +- 82 files changed, 2042 insertions(+), 1966 deletions(-) diff --git a/_modules/index.html b/_modules/index.html index a72504db..7b106ee7 100644 --- a/_modules/index.html +++ b/_modules/index.html @@ -14,7 +14,7 @@ 概览:模块代码 - melobot 3.0.0 - + diff --git a/_modules/melobot/_meta.html b/_modules/melobot/_meta.html index dfe18ec9..c9b8c5cb 100644 --- a/_modules/melobot/_meta.html +++ b/_modules/melobot/_meta.html @@ -14,7 +14,7 @@ melobot._meta - melobot 3.0.0 - + @@ -300,16 +300,16 @@

melobot._meta 源代码

-from __future__ import annotations
+from __future__ import annotations
 
-from typing_extensions import Any, ClassVar, Generic, Literal, NamedTuple, NoReturn
+from typing_extensions import Any, ClassVar, Generic, Literal, NamedTuple, NoReturn
 
-from .typ import T
+from .typ import T
 
 __version__ = "3.0.0"
 
 
-def _version_str_to_info(s: str) -> VersionInfo:
+def _version_str_to_info(s: str) -> VersionInfo:
     parts = s.split(".")
     major = int(parts[0])
     minor = int(parts[1])
@@ -335,20 +335,20 @@ 

melobot._meta 源代码

     return VersionInfo(major, minor, micro, flag, serial)
 
 
-class ReadOnlyAttr(Generic[T]):
-    def __init__(self, val: T):
+class ReadOnlyAttr(Generic[T]):
+    def __init__(self, val: T):
         self.val = val
 
-    def __get__(self, obj: Any, klass: Any = None) -> T:
+    def __get__(self, obj: Any, klass: Any = None) -> T:
         return self.val
 
-    def __set__(self, obj: Any, value: T) -> NoReturn:
+    def __set__(self, obj: Any, value: T) -> NoReturn:
         raise AttributeError("只读属性无法重新设定值")
 
 
 
[文档] -class VersionInfo(NamedTuple): +class VersionInfo(NamedTuple): """版本信息元组""" major: int @@ -391,7 +391,7 @@

melobot._meta 源代码

 
 
 
-class MetaInfoMeta(type):
+class MetaInfoMeta(type):
     ver = ReadOnlyAttr[str](__version__)
     ver_info = ReadOnlyAttr[VersionInfo](_version_str_to_info(__version__))
     name = ReadOnlyAttr[str]("melobot")
@@ -412,7 +412,7 @@ 

melobot._meta 源代码

 
 
[文档] -class MetaInfo(metaclass=MetaInfoMeta): +class MetaInfo(metaclass=MetaInfoMeta): """melobot 项目只读元信息""" ver: ClassVar[str] diff --git a/_modules/melobot/adapter/base.html b/_modules/melobot/adapter/base.html index b65f981f..c6f1a8d9 100644 --- a/_modules/melobot/adapter/base.html +++ b/_modules/melobot/adapter/base.html @@ -14,7 +14,7 @@ melobot.adapter.base - melobot 3.0.0 - + @@ -300,15 +300,15 @@

melobot.adapter.base 源代码

-from __future__ import annotations
+from __future__ import annotations
 
-import asyncio
-from asyncio import create_task
-from contextlib import AsyncExitStack, _GeneratorContextManager, asynccontextmanager
-from enum import Enum
-from os import PathLike
+import asyncio
+from asyncio import create_task
+from contextlib import AsyncExitStack, _GeneratorContextManager, asynccontextmanager
+from enum import Enum
+from os import PathLike
 
-from typing_extensions import (
+from typing_extensions import (
     TYPE_CHECKING,
     AsyncGenerator,
     Callable,
@@ -323,10 +323,10 @@ 

melobot.adapter.base 源代码

     final,
 )
 
-from .._hook import Hookable
-from ..ctx import EventBuildInfo, EventBuildInfoCtx, LoggerCtx, OutSrcFilterCtx
-from ..exceptions import AdapterError
-from ..io.base import (
+from .._hook import Hookable
+from ..ctx import EventBuildInfo, EventBuildInfoCtx, LoggerCtx, OutSrcFilterCtx
+from ..exceptions import AdapterError
+from ..io.base import (
     AbstractInSource,
     AbstractOutSource,
     EchoPacketT,
@@ -335,13 +335,13 @@ 

melobot.adapter.base 源代码

     OutPacketT,
     OutSourceT,
 )
-from ..log.base import LogLevel
-from ..typ import AsyncCallable, BetterABC, P, abstractmethod
-from .content import Content
-from .model import ActionHandle, ActionT, EchoT, Event, EventT
+from ..log.base import LogLevel
+from ..typ import AsyncCallable, BetterABC, P, abstractmethod
+from .content import Content
+from .model import ActionHandle, ActionT, EchoT, Event, EventT
 
 if TYPE_CHECKING:
-    from ..bot.dispatch import Dispatcher
+    from ..bot.dispatch import Dispatcher
 
 
 _EVENT_BUILD_INFO_CTX = EventBuildInfoCtx()
@@ -350,13 +350,13 @@ 

melobot.adapter.base 源代码

 
 
[文档] -class AbstractEventFactory(BetterABC, Generic[InPacketT, EventT]): +class AbstractEventFactory(BetterABC, Generic[InPacketT, EventT]): """抽象事件工厂类"""
[文档] @abstractmethod - async def create(self, packet: InPacketT) -> EventT: + async def create(self, packet: InPacketT) -> EventT: """将 :class:`.InPacket` 对象转换为 :class:`.Event` 对象的方法 :param packet: 输入包 @@ -372,13 +372,13 @@

melobot.adapter.base 源代码

 
 
[文档] -class AbstractOutputFactory(BetterABC, Generic[OutPacketT, ActionT]): +class AbstractOutputFactory(BetterABC, Generic[OutPacketT, ActionT]): """抽象输出工厂类"""
[文档] @abstractmethod - async def create(self, action: ActionT) -> OutPacketT: + async def create(self, action: ActionT) -> OutPacketT: """将 :class:`.Action` 对象转换为 :class:`.OutPacket` 对象的方法 :param packet: 行为 @@ -394,13 +394,13 @@

melobot.adapter.base 源代码

 
 
[文档] -class AbstractEchoFactory(BetterABC, Generic[EchoPacketT, EchoT]): +class AbstractEchoFactory(BetterABC, Generic[EchoPacketT, EchoT]): """抽象回应工厂类"""
[文档] @abstractmethod - async def create(self, packet: EchoPacketT) -> EchoT | None: + async def create(self, packet: EchoPacketT) -> EchoT | None: """将 :class:`.EchoPacket` 对象转换为 :class:`.Echo` 对象的方法 :param packet: 回应包 @@ -416,7 +416,7 @@

melobot.adapter.base 源代码

 
 
[文档] -class AdapterLifeSpan(Enum): +class AdapterLifeSpan(Enum): """适配器生命周期阶段的枚举""" BEFORE_EVENT_HANDLE = "beh" @@ -428,7 +428,7 @@

melobot.adapter.base 源代码

 
 
[文档] -class Adapter( +class Adapter( BetterABC, Generic[ EventFactoryT, @@ -448,7 +448,7 @@

melobot.adapter.base 源代码

     # pylint: disable=duplicate-code
     # pylint: disable=unused-argument
 
-    def __init__(
+    def __init__(
         self,
         protocol: LiteralString,
         event_factory: EventFactoryT,
@@ -469,12 +469,12 @@ 

melobot.adapter.base 源代码

 
 
[文档] - def on( + def on( self, *periods: AdapterLifeSpan ) -> Callable[[AsyncCallable[P, None]], AsyncCallable[P, None]]: groups = (AdapterLifeSpan.BEFORE_EVENT_HANDLE, AdapterLifeSpan.BEFORE_ACTION_EXEC) - def wrapped(func: AsyncCallable[P, None]) -> AsyncCallable[P, None]: + def wrapped(func: AsyncCallable[P, None]) -> AsyncCallable[P, None]: for type in periods: self._hook_bus.register(type, func, once=type not in groups) return func @@ -485,7 +485,7 @@

melobot.adapter.base 源代码

 
[文档] @final - def get_isrcs(self, filter: Callable[[InSourceT], bool]) -> set[InSourceT]: + def get_isrcs(self, filter: Callable[[InSourceT], bool]) -> set[InSourceT]: """获取与当前适配器匹配的所有输入源 :param filter: 过滤函数,为 `True` 时保留输入源 @@ -497,7 +497,7 @@

melobot.adapter.base 源代码

 
[文档] @final - def get_osrcs(self, filter: Callable[[OutSourceT], bool]) -> set[OutSourceT]: + def get_osrcs(self, filter: Callable[[OutSourceT], bool]) -> set[OutSourceT]: """获取与当前适配器匹配的所有输出源 :param filter: 过滤函数,为 `True` 时保留输出源 @@ -507,7 +507,7 @@

melobot.adapter.base 源代码

 
 
     @final
-    async def __adapter_input_loop__(self, src: InSourceT) -> NoReturn:
+    async def __adapter_input_loop__(self, src: InSourceT) -> NoReturn:
         logger = LoggerCtx().get()
         while True:
             try:
@@ -524,7 +524,7 @@ 

melobot.adapter.base 源代码

 
     @asynccontextmanager
     @final
-    async def __adapter_launch__(self) -> AsyncGenerator[Self, None]:
+    async def __adapter_launch__(self) -> AsyncGenerator[Self, None]:
         if self._inited:
             raise AdapterError(f"适配器 {self} 已在运行,不能重复启动")
 
@@ -558,7 +558,7 @@ 

melobot.adapter.base 源代码

 
[文档] @final - def filter_out( + def filter_out( self, filter: Callable[[OutSourceT], bool] ) -> _GeneratorContextManager[Callable[[OutSourceT], bool]]: """上下文管理器,提供由 `filter` 控制输出的输出上下文 @@ -570,7 +570,7 @@

melobot.adapter.base 源代码

 
 
[文档] - async def call_output(self, action: ActionT) -> tuple[ActionHandle, ...]: + async def call_output(self, action: ActionT) -> tuple[ActionHandle, ...]: """输出行为,并返回各个输出源返回的 :class:`.ActionHandle` 组成的元组 适配器开发者的适配器子类可以重写此方法,以实现自定义功能 @@ -605,7 +605,7 @@

melobot.adapter.base 源代码

 
 
     @abstractmethod
-    async def __send_text__(self, text: str) -> tuple[ActionHandle, ...]:
+    async def __send_text__(self, text: str) -> tuple[ActionHandle, ...]:
         """输出文本
 
         抽象方法。所有适配器子类应该实现此方法
@@ -615,7 +615,7 @@ 

melobot.adapter.base 源代码

         """
         raise NotImplementedError
 
-    async def __send_media__(
+    async def __send_media__(
         self,
         name: str,
         raw: bytes | None = None,
@@ -636,7 +636,7 @@ 

melobot.adapter.base 源代码

             f"[melobot media: {name if url is None else name + ' at ' + url}]"
         )
 
-    async def __send_image__(
+    async def __send_image__(
         self,
         name: str,
         raw: bytes | None = None,
@@ -657,7 +657,7 @@ 

melobot.adapter.base 源代码

             f"[melobot image: {name if url is None else name + ' at ' + url}]"
         )
 
-    async def __send_audio__(
+    async def __send_audio__(
         self,
         name: str,
         raw: bytes | None = None,
@@ -678,7 +678,7 @@ 

melobot.adapter.base 源代码

             f"[melobot audio: {name if url is None else name + ' at ' + url}]"
         )
 
-    async def __send_voice__(
+    async def __send_voice__(
         self,
         name: str,
         raw: bytes | None = None,
@@ -699,7 +699,7 @@ 

melobot.adapter.base 源代码

             f"[melobot voice: {name if url is None else name + ' at ' + url}]"
         )
 
-    async def __send_video__(
+    async def __send_video__(
         self,
         name: str,
         raw: bytes | None = None,
@@ -720,7 +720,7 @@ 

melobot.adapter.base 源代码

             f"[melobot video: {name if url is None else name + ' at ' + url}]"
         )
 
-    async def __send_file__(
+    async def __send_file__(
         self, name: str, path: str | PathLike[str]
     ) -> tuple[ActionHandle, ...]:
         """输出文件
@@ -733,7 +733,7 @@ 

melobot.adapter.base 源代码

         """
         return await self.__send_text__(f"[melobot file: {name} at {path}]")
 
-    async def __send_refer__(
+    async def __send_refer__(
         self, event: Event, contents: Sequence[Content] | None = None
     ) -> tuple[ActionHandle, ...]:
         """输出对过往事件的引用
@@ -748,7 +748,7 @@ 

melobot.adapter.base 源代码

             f"[melobot refer: {event.__class__.__name__}({event.id})]"
         )
 
-    async def __send_resource__(self, name: str, url: str) -> tuple[ActionHandle, ...]:
+    async def __send_resource__(self, name: str, url: str) -> tuple[ActionHandle, ...]:
         """输出网络资源
 
         建议所有适配器子类重写此方法,否则回退到基类实现:仅使用 :func:`send_text` 输出相关提示信息
diff --git a/_modules/melobot/adapter/content.html b/_modules/melobot/adapter/content.html
index b074559d..2c6c54e1 100644
--- a/_modules/melobot/adapter/content.html
+++ b/_modules/melobot/adapter/content.html
@@ -14,7 +14,7 @@
 
     
         melobot.adapter.content - melobot 3.0.0
-      
+      
     
     
     
@@ -300,16 +300,16 @@
         

melobot.adapter.content 源代码

-from __future__ import annotations
+from __future__ import annotations
 
-import mimetypes
+import mimetypes
 
-from typing_extensions import Hashable, Sequence, TypeVar
+from typing_extensions import Hashable, Sequence, TypeVar
 
 
 
[文档] -class Content: +class Content: """通用内容基类"""
@@ -319,12 +319,12 @@

melobot.adapter.content 源代码

 
 
[文档] -class TextContent(Content): +class TextContent(Content): """文本内容"""
[文档] - def __init__(self, text: str) -> None: + def __init__(self, text: str) -> None: """初始化文本内容 :param text: 文本 @@ -337,12 +337,12 @@

melobot.adapter.content 源代码

 
 
[文档] -class MediaContent(Content): +class MediaContent(Content): """多媒体内容"""
[文档] - def __init__( + def __init__( self, *, name: str, @@ -369,40 +369,40 @@

melobot.adapter.content 源代码

 
 
[文档] -class ImageContent(MediaContent): +class ImageContent(MediaContent): """图像内容,初始化方法参考基类"""
[文档] -class AudioContent(MediaContent): +class AudioContent(MediaContent): """音频内容,初始化方法参考基类"""
[文档] -class VoiceContent(AudioContent): +class VoiceContent(AudioContent): """语音内容,初始化方法参考基类"""
[文档] -class VideoContent(MediaContent): +class VideoContent(MediaContent): """视频内容,初始化方法参考基类"""
[文档] -class FileContent(Content): +class FileContent(Content): """文件内容"""
[文档] - def __init__(self, name: str, flag: Hashable) -> None: + def __init__(self, name: str, flag: Hashable) -> None: """初始化文件内容 :param name: 文件名 @@ -413,19 +413,19 @@

melobot.adapter.content 源代码

         self.name = name
- def __repr__(self) -> str: + def __repr__(self) -> str: return f"[melobot File: {self.name} at {self.flag}]"
[文档] -class ReferContent(Content): +class ReferContent(Content): """引用内容"""
[文档] - def __init__(self, prompt: str, flag: Hashable, contents: Sequence[Content]) -> None: + def __init__(self, prompt: str, flag: Hashable, contents: Sequence[Content]) -> None: """初始化引用内容 :param prompt: 引用的文本提示 @@ -438,19 +438,19 @@

melobot.adapter.content 源代码

         self.sub_contents = contents
- def __repr__(self) -> str: + def __repr__(self) -> str: return f"[melobot Refer: {self.prompt} at {self.flag}]"
[文档] -class ResourceContent(Content): +class ResourceContent(Content): """资源内容"""
[文档] - def __init__(self, name: str, url: str) -> None: + def __init__(self, name: str, url: str) -> None: """初始化资源内容 :param name: 名称 @@ -461,7 +461,7 @@

melobot.adapter.content 源代码

         self.name = name
- def __repr__(self) -> str: + def __repr__(self) -> str: return f"[melobot Resource: {self.name} at {self.url}]"
diff --git a/_modules/melobot/adapter/generic.html b/_modules/melobot/adapter/generic.html index 1ee4a116..b585e62e 100644 --- a/_modules/melobot/adapter/generic.html +++ b/_modules/melobot/adapter/generic.html @@ -14,7 +14,7 @@ melobot.adapter.generic - melobot 3.0.0 - + @@ -300,20 +300,20 @@

melobot.adapter.generic 源代码

-from os import PathLike
+from os import PathLike
 
-from typing_extensions import Sequence
+from typing_extensions import Sequence
 
-from ..ctx import EventBuildInfoCtx
-from .content import Content
-from .model import ActionHandle, Event
+from ..ctx import EventBuildInfoCtx
+from .content import Content
+from .model import ActionHandle, Event
 
 _CTX = EventBuildInfoCtx()
 
 
 
[文档] -async def send_text(text: str) -> tuple[ActionHandle, ...]: +async def send_text(text: str) -> tuple[ActionHandle, ...]: """通用文本输出方法""" return await _CTX.get().adapter.__send_text__(text)
@@ -321,7 +321,7 @@

melobot.adapter.generic 源代码

 
 
[文档] -async def send_media( +async def send_media( name: str, raw: bytes | None = None, url: str | None = None, @@ -334,7 +334,7 @@

melobot.adapter.generic 源代码

 
 
[文档] -async def send_image( +async def send_image( name: str, raw: bytes | None = None, url: str | None = None, @@ -347,7 +347,7 @@

melobot.adapter.generic 源代码

 
 
[文档] -async def send_audio( +async def send_audio( name: str, raw: bytes | None = None, url: str | None = None, @@ -360,7 +360,7 @@

melobot.adapter.generic 源代码

 
 
[文档] -async def send_voice( +async def send_voice( name: str, raw: bytes | None = None, url: str | None = None, @@ -373,7 +373,7 @@

melobot.adapter.generic 源代码

 
 
[文档] -async def send_video( +async def send_video( name: str, raw: bytes | None = None, url: str | None = None, @@ -386,7 +386,7 @@

melobot.adapter.generic 源代码

 
 
[文档] -async def send_file(name: str, path: str | PathLike[str]) -> tuple[ActionHandle, ...]: +async def send_file(name: str, path: str | PathLike[str]) -> tuple[ActionHandle, ...]: """通用文件输出方法""" return await _CTX.get().adapter.__send_file__(name, path)
@@ -394,7 +394,7 @@

melobot.adapter.generic 源代码

 
 
[文档] -async def send_refer( +async def send_refer( event: Event, contents: Sequence[Content] | None = None ) -> tuple[ActionHandle, ...]: """通用过往事件引用输出方法""" @@ -404,7 +404,7 @@

melobot.adapter.generic 源代码

 
 
[文档] -async def send_resource(name: str, url: str) -> tuple[ActionHandle, ...]: +async def send_resource(name: str, url: str) -> tuple[ActionHandle, ...]: """通用其他资源输出方法""" return await _CTX.get().adapter.__send_resource__(name, url)
diff --git a/_modules/melobot/adapter/model.html b/_modules/melobot/adapter/model.html index 3ba69e91..9f792640 100644 --- a/_modules/melobot/adapter/model.html +++ b/_modules/melobot/adapter/model.html @@ -14,7 +14,7 @@ melobot.adapter.model - melobot 3.0.0 - + @@ -300,15 +300,15 @@

melobot.adapter.model 源代码

-from __future__ import annotations
+from __future__ import annotations
 
-import asyncio
-from asyncio import create_task
-from contextlib import contextmanager
-from dataclasses import dataclass, field
-from time import time_ns
+import asyncio
+from asyncio import create_task
+from contextlib import contextmanager
+from dataclasses import dataclass, field
+from time import time_ns
 
-from typing_extensions import (
+from typing_extensions import (
     TYPE_CHECKING,
     Any,
     Awaitable,
@@ -324,21 +324,21 @@ 

melobot.adapter.model 源代码

     cast,
 )
 
-from ..ctx import ActionManualSignalCtx, Context, LoggerCtx
-from ..exceptions import AdapterError
-from ..io.base import AbstractOutSource
-from ..log.base import LogLevel
-from ..typ import AttrsReprable, T
-from ..utils import get_id, to_coro
-from .content import Content
+from ..ctx import ActionManualSignalCtx, Context, LoggerCtx
+from ..exceptions import AdapterError
+from ..io.base import AbstractOutSource
+from ..log.base import LogLevel
+from ..typ import AttrsReprable, T
+from ..utils import get_id, to_coro
+from .content import Content
 
 if TYPE_CHECKING:
-    from .base import AbstractEchoFactory, AbstractOutputFactory
+    from .base import AbstractEchoFactory, AbstractOutputFactory
 
 
 
[文档] -class Event(AttrsReprable): +class Event(AttrsReprable): """事件基类 :ivar float time: 时间戳 @@ -348,7 +348,7 @@

melobot.adapter.model 源代码

     :ivar typing.Hashable | None scope: 所在的域,可空
     """
 
-    def __init__(
+    def __init__(
         self,
         time: float = -1,
         id: str = "",
@@ -371,7 +371,7 @@ 

melobot.adapter.model 源代码

 
 
[文档] -class Action(AttrsReprable): +class Action(AttrsReprable): """行为基类 :ivar float time: 时间戳 @@ -382,7 +382,7 @@

melobot.adapter.model 源代码

     :ivar Event | None trigger: 触发该行为的事件,为空表明不由事件触发
     """
 
-    def __init__(
+    def __init__(
         self,
         time: float = -1,
         id: str = "",
@@ -402,7 +402,7 @@ 

melobot.adapter.model 源代码

 
 
[文档] -class Echo(AttrsReprable): +class Echo(AttrsReprable): """回应基类 :ivar float time: 时间戳 @@ -415,7 +415,7 @@

melobot.adapter.model 源代码

     :ivar Any data: 回应数据
     """
 
-    def __init__(
+    def __init__(
         self,
         time: float = -1,
         id: str = "",
@@ -446,7 +446,7 @@ 

melobot.adapter.model 源代码

 
 
[文档] -class ActionHandle(Generic[ActionRetT]): +class ActionHandle(Generic[ActionRetT]): """行为操作句柄 :ivar Action action: 操作包含的行为对象 @@ -454,7 +454,7 @@

melobot.adapter.model 源代码

     :ivar AbstractOutSource out_src: 执行操作的输出源对象
     """
 
-    def __init__(
+    def __init__(
         self,
         action: Action,
         out_src: AbstractOutSource,
@@ -473,18 +473,18 @@ 

melobot.adapter.model 源代码

         if not ActionManualSignalCtx().try_get():
             self.execute()
 
-    async def _wait(self) -> ActionRetT:
+    async def _wait(self) -> ActionRetT:
         await self._done.wait()
         return self._echo
 
 
[文档] - def __await__(self) -> Generator[Any, Any, ActionRetT]: + def __await__(self) -> Generator[Any, Any, ActionRetT]: """本对象实现 __await__ 接口,因此可等待。返回本操作对应的回应数据""" return self._wait().__await__()
- async def _execute(self) -> None: + async def _execute(self) -> None: try: output_packet = await self._output_factory.create(self.action) echo_packet = await self.out_src.output(output_packet) @@ -498,7 +498,7 @@

melobot.adapter.model 源代码

             )
             logger.generic_obj("异常点局部变量", locals(), level=LogLevel.ERROR)
 
-    def execute(self) -> Self:
+    def execute(self) -> Self:
         if self.status != "PENDING":
             raise AdapterError("行为操作正在执行或执行完毕,不应该再执行")
 
@@ -509,14 +509,14 @@ 

melobot.adapter.model 源代码

 
 
 @dataclass
-class _ChainStep:
+class _ChainStep:
     coros: Sequence[Coroutine]
     ret_when: Literal["FIRST_COMPLETED", "FIRST_EXCEPTION", "ALL_COMPLETED"]
     next: _ChainStep | None = None
 
 
 @dataclass(kw_only=True)
-class _ChainCtxStep(_ChainStep):  # type: ignore[override]
+class _ChainCtxStep(_ChainStep):  # type: ignore[override]
     ctx_var: Context
     ctx_val: Any
     coros: Sequence[Coroutine] = field(default_factory=tuple)
@@ -525,20 +525,20 @@ 

melobot.adapter.model 源代码

 
 
[文档] -class ActionChain: +class ActionChain: """行为链""" - def __init__(self) -> None: + def __init__(self) -> None: self._chain: list[_ChainStep] = [] - def _add_step(self, step: _ChainStep) -> None: + def _add_step(self, step: _ChainStep) -> None: if len(self._chain): self._chain[-1].next = step self._chain.append(step)
[文档] - def unfold(self, ctx: Context[T], val: T) -> Self: + def unfold(self, ctx: Context[T], val: T) -> Self: """指定链后续的步骤中在 `ctx` 类别的上下文中执行,上下文值为 `val` :param ctx: 上下文类别 @@ -549,7 +549,7 @@

melobot.adapter.model 源代码

         return self
- async def _exec_handle(self, handles: Awaitable[tuple[ActionHandle, ...]]) -> None: + async def _exec_handle(self, handles: Awaitable[tuple[ActionHandle, ...]]) -> None: _handles = await handles for handle in _handles: handle.execute() @@ -557,7 +557,7 @@

melobot.adapter.model 源代码

 
 
[文档] - def add( + def add( self, *handles: Awaitable[tuple[ActionHandle, ...]], ret_when: Literal[ @@ -577,7 +577,7 @@

melobot.adapter.model 源代码

 
 
[文档] - def sleep(self, interval: float) -> Self: + def sleep(self, interval: float) -> Self: """ 在链的步骤中添加指定时长的等待 @@ -589,7 +589,7 @@

melobot.adapter.model 源代码

         return self
- async def _start(self, step: _ChainStep) -> None: + async def _start(self, step: _ChainStep) -> None: if isinstance(step, _ChainCtxStep): with step.ctx_var.unfold(step.ctx_val): if step.next: @@ -603,7 +603,7 @@

melobot.adapter.model 源代码

 
 
[文档] - async def run(self) -> None: + async def run(self) -> None: """顺序执行链的所有步骤""" await self._start(self._chain[0])
@@ -613,7 +613,7 @@

melobot.adapter.model 源代码

 
[文档] @contextmanager -def open_chain() -> Generator[ActionChain, None, None]: +def open_chain() -> Generator[ActionChain, None, None]: """创建行为链的上下文管理器 :yield: 行为链对象 diff --git a/_modules/melobot/bot.html b/_modules/melobot/bot.html index 1d515fe6..b4722a12 100644 --- a/_modules/melobot/bot.html +++ b/_modules/melobot/bot.html @@ -14,7 +14,7 @@ melobot.bot - melobot 3.0.0 - + @@ -300,13 +300,13 @@

melobot.bot 源代码

-from ..ctx import BotCtx as _BotCtx
-from .base import CLI_RUNTIME, LAST_EXIT_SIGNAL, Bot, BotExitSignal, BotLifeSpan
+from ..ctx import BotCtx as _BotCtx
+from .base import CLI_RUNTIME, LAST_EXIT_SIGNAL, Bot, BotExitSignal, BotLifeSpan
 
 
 
[文档] -def get_bot() -> Bot: +def get_bot() -> Bot: """获得当前上下文中的 bot 对象 :return: bot 对象 diff --git a/_modules/melobot/bot/base.html b/_modules/melobot/bot/base.html index 0b495695..d1c38d90 100644 --- a/_modules/melobot/bot/base.html +++ b/_modules/melobot/bot/base.html @@ -14,7 +14,7 @@ melobot.bot.base - melobot 3.0.0 - + @@ -300,20 +300,20 @@

melobot.bot.base 源代码

-from __future__ import annotations
-
-import asyncio
-import asyncio.tasks
-import os
-import platform
-import sys
-from contextlib import AsyncExitStack, ExitStack, asynccontextmanager, contextmanager
-from enum import Enum
-from os import PathLike
-from pathlib import Path
-from types import ModuleType
-
-from typing_extensions import (
+from __future__ import annotations
+
+import asyncio
+import asyncio.tasks
+import os
+import platform
+import sys
+from contextlib import AsyncExitStack, ExitStack, asynccontextmanager, contextmanager
+from enum import Enum
+from os import PathLike
+from pathlib import Path
+from types import ModuleType
+
+from typing_extensions import (
     Any,
     AsyncGenerator,
     Callable,
@@ -324,24 +324,24 @@ 

melobot.bot.base 源代码

     NoReturn,
 )
 
-from .._hook import Hookable
-from .._meta import MetaInfo
-from ..adapter.base import Adapter
-from ..ctx import BotCtx, LoggerCtx
-from ..exceptions import BotError
-from ..io.base import AbstractInSource, AbstractIOSource, AbstractOutSource
-from ..log.base import GenericLogger, Logger, NullLogger
-from ..plugin.base import Plugin, PluginLifeSpan, PluginPlanner
-from ..plugin.ipc import AsyncShare, IPCManager, SyncShare
-from ..plugin.load import PluginLoader
-from ..protocols.base import ProtocolStack
-from ..typ import AsyncCallable, P
-from .dispatch import Dispatcher
+from .._hook import Hookable
+from .._meta import MetaInfo
+from ..adapter.base import Adapter
+from ..ctx import BotCtx, LoggerCtx
+from ..exceptions import BotError
+from ..io.base import AbstractInSource, AbstractIOSource, AbstractOutSource
+from ..log.base import GenericLogger, Logger, NullLogger
+from ..plugin.base import Plugin, PluginLifeSpan, PluginPlanner
+from ..plugin.ipc import AsyncShare, IPCManager, SyncShare
+from ..plugin.load import PluginLoader
+from ..protocols.base import ProtocolStack
+from ..typ import AsyncCallable, P
+from .dispatch import Dispatcher
 
 
 
[文档] -class BotLifeSpan(Enum): +class BotLifeSpan(Enum): """bot 生命周期阶段的枚举""" LOADED = "l" @@ -352,7 +352,7 @@

melobot.bot.base 源代码

 
 
 
-class BotExitSignal(Enum):
+class BotExitSignal(Enum):
     NORMAL_STOP = 0
     ERROR = 1
     RESTART = 2
@@ -366,7 +366,7 @@ 

melobot.bot.base 源代码

 _LOGGER_CTX = LoggerCtx()
 
 
-def _start_log(logger: GenericLogger) -> None:
+def _start_log(logger: GenericLogger) -> None:
     for row in MetaInfo.logo.split("\n"):
         logger.info(f"{row}")
     logger.info("")
@@ -378,7 +378,7 @@ 

melobot.bot.base 源代码

 
 
[文档] -class Bot(Hookable[BotLifeSpan]): +class Bot(Hookable[BotLifeSpan]): """bot 类 :ivar str name: bot 对象的名称 @@ -387,7 +387,7 @@

melobot.bot.base 源代码

 
     __instances__: dict[str, Bot] = {}
 
-    def __new__(cls, name: str = "melobot", /, *args: Any, **kwargs: Any) -> Bot:
+    def __new__(cls, name: str = "melobot", /, *args: Any, **kwargs: Any) -> Bot:
         if name in Bot.__instances__:
             raise BotError(f"命名为 {name} 的 bot 实例已存在,请改名避免冲突")
         obj = super().__new__(cls)
@@ -396,7 +396,7 @@ 

melobot.bot.base 源代码

 
 
[文档] - def __init__( + def __init__( self, name: str = "melobot", /, @@ -438,23 +438,23 @@

melobot.bot.base 源代码

         self._rip_signal = asyncio.Event()
- def __repr__(self) -> str: + def __repr__(self) -> str: return f'Bot(name="{self.name}")' @property - def loop(self) -> asyncio.AbstractEventLoop: + def loop(self) -> asyncio.AbstractEventLoop: """获得当前 bot 运行时的事件循环对象""" return asyncio.get_running_loop() @contextmanager - def _common_sync_ctx(self) -> Generator[ExitStack, None, None]: + def _common_sync_ctx(self) -> Generator[ExitStack, None, None]: with ExitStack() as stack: stack.enter_context(_BOT_CTX.unfold(self)) stack.enter_context(_LOGGER_CTX.unfold(self.logger)) yield stack @asynccontextmanager - async def _common_async_ctx(self) -> AsyncGenerator[AsyncExitStack, None]: + async def _common_async_ctx(self) -> AsyncGenerator[AsyncExitStack, None]: async with AsyncExitStack() as stack: stack.enter_context(_BOT_CTX.unfold(self)) stack.enter_context(_LOGGER_CTX.unfold(self.logger)) @@ -462,7 +462,7 @@

melobot.bot.base 源代码

 
 
[文档] - def add_input(self, src: AbstractInSource) -> Bot: + def add_input(self, src: AbstractInSource) -> Bot: """绑定输入源 :param src: 输入源 @@ -477,7 +477,7 @@

melobot.bot.base 源代码

 
 
[文档] - def add_output(self, src: AbstractOutSource) -> Bot: + def add_output(self, src: AbstractOutSource) -> Bot: """绑定输出源 :param src: 输出源 @@ -492,7 +492,7 @@

melobot.bot.base 源代码

 
 
[文档] - def add_io(self, src: AbstractIOSource) -> Bot: + def add_io(self, src: AbstractIOSource) -> Bot: """绑定输入输出源 :param src: 输入输出源 @@ -505,7 +505,7 @@

melobot.bot.base 源代码

 
 
[文档] - def add_adapter(self, adapter: Adapter) -> Bot: + def add_adapter(self, adapter: Adapter) -> Bot: """绑定适配器 :param adapter: 适配器对象 @@ -524,7 +524,7 @@

melobot.bot.base 源代码

 
 
[文档] - def add_protocol(self, pstack: ProtocolStack) -> Bot: + def add_protocol(self, pstack: ProtocolStack) -> Bot: """绑定完整的协议栈,这包含了一组协同工作的输入源、输出源和适配器 :param pstack: 协议栈对象 @@ -539,7 +539,7 @@

melobot.bot.base 源代码

         return self
- def _core_init(self) -> None: + def _core_init(self) -> None: _start_log(self.logger) for protocol, srcs in self._in_srcs.items(): @@ -577,7 +577,7 @@

melobot.bot.base 源代码

 
 
[文档] - def load_plugin( + def load_plugin( self, plugin: ModuleType | str | PathLike[str] | PluginPlanner, load_depth: int = 1, @@ -619,7 +619,7 @@

melobot.bot.base 源代码

 
 
[文档] - def load_plugins( + def load_plugins( self, plugins: Iterable[ModuleType | str | PathLike[str] | PluginPlanner], load_depth: int = 1, @@ -635,7 +635,7 @@

melobot.bot.base 源代码

 
 
[文档] - def load_plugins_dir(self, pdir: str | PathLike[str], load_depth: int = 1) -> None: + def load_plugins_dir(self, pdir: str | PathLike[str], load_depth: int = 1) -> None: """与 :func:`load_plugin` 行为类似,但是参数变为插件目录的父目录,本方法可以加载单个目录下的多个插件 :param pdir: 插件所在父目录的路径 @@ -654,7 +654,7 @@

melobot.bot.base 源代码

 
 
[文档] - def load_plugins_dirs( + def load_plugins_dirs( self, pdirs: Iterable[str | PathLike[str]], load_depth: int = 1 ) -> None: """与 :func:`load_plugins_dir` 行为类似,但是参数变为可迭代对象,每个元素为包含插件目录的父目录。 @@ -669,7 +669,7 @@

melobot.bot.base 源代码

 
 
[文档] - async def core_run(self) -> None: + async def core_run(self) -> None: """运行 bot 的方法,可以在异步事件循环中自由地使用 若使用此方法,则需要自行管理异步事件循环 @@ -719,7 +719,7 @@

melobot.bot.base 源代码

 
 
[文档] - def run(self, debug: bool = False) -> None: + def run(self, debug: bool = False) -> None: """安全地运行 bot 的阻塞方法,这适用于只运行单一 bot 的情况 :param debug: 是否启用 :py:mod:`asyncio` 的调试模式,但是这不会更改 :py:mod:`asyncio` 日志器的日志等级 @@ -730,14 +730,14 @@

melobot.bot.base 源代码

 
[文档] @classmethod - def start(cls, *bots: Bot, debug: bool = False) -> None: + def start(cls, *bots: Bot, debug: bool = False) -> None: """安全地同时运行多个 bot 的阻塞方法 :param bots: 要运行的 bot 对象 :param debug: 参见 :func:`run` 同名参数 """ - async def bots_run() -> None: + async def bots_run() -> None: tasks = [] for bot in bots: tasks.append(asyncio.create_task(bot.core_run())) @@ -751,7 +751,7 @@

melobot.bot.base 源代码

 
 
[文档] - async def close(self) -> None: + async def close(self) -> None: """停止并关闭当前 bot""" if not self._running: raise BotError(f"{self} 未在运行中,不能停止运行") @@ -762,7 +762,7 @@

melobot.bot.base 源代码

 
 
[文档] - async def restart(self) -> NoReturn: + async def restart(self) -> NoReturn: """重启当前 bot,需要通过模块运行模式启动 bot 主脚本: .. code:: shell @@ -780,7 +780,7 @@

melobot.bot.base 源代码

 
 
[文档] - def get_adapter( + def get_adapter( self, type: LiteralString | type[Adapter] | None = None, filter: Callable[[Adapter], bool] | None = None, @@ -810,7 +810,7 @@

melobot.bot.base 源代码

 
 
[文档] - def get_adapters( + def get_adapters( self, filter: Callable[[Adapter], bool] | None = None ) -> set[Adapter]: """获取一组适配器 @@ -825,7 +825,7 @@

melobot.bot.base 源代码

 
 
[文档] - def get_plugins(self) -> list[str]: + def get_plugins(self) -> list[str]: """获取所有绑定的插件的名称 :return: 所绑定的插件的名称列表 @@ -835,7 +835,7 @@

melobot.bot.base 源代码

 
 
[文档] - def get_share(self, plugin: str, share: str) -> SyncShare | AsyncShare: + def get_share(self, plugin: str, share: str) -> SyncShare | AsyncShare: """获取绑定的插件中的共享对象 :param plugin: 插件名称 @@ -846,33 +846,33 @@

melobot.bot.base 源代码

 
 
     @property
-    def on_loaded(self) -> Callable[[AsyncCallable[P, None]], AsyncCallable[P, None]]:
+    def on_loaded(self) -> Callable[[AsyncCallable[P, None]], AsyncCallable[P, None]]:
         """给 bot 注册 :obj:`.BotLifeSpan.LOADED` 阶段 hook 的装饰器"""
         return self.on(BotLifeSpan.LOADED)
 
     @property
-    def on_reloaded(self) -> Callable[[AsyncCallable[P, None]], AsyncCallable[P, None]]:
+    def on_reloaded(self) -> Callable[[AsyncCallable[P, None]], AsyncCallable[P, None]]:
         """给 bot 注册 :obj:`.BotLifeSpan.RELOADED` 阶段 hook 的装饰器"""
         return self.on(BotLifeSpan.RELOADED)
 
     @property
-    def on_started(self) -> Callable[[AsyncCallable[P, None]], AsyncCallable[P, None]]:
+    def on_started(self) -> Callable[[AsyncCallable[P, None]], AsyncCallable[P, None]]:
         """给 bot 注册 :obj:`.BotLifeSpan.STARTED` 阶段 hook 的装饰器"""
         return self.on(BotLifeSpan.STARTED)
 
     @property
-    def on_close(self) -> Callable[[AsyncCallable[P, None]], AsyncCallable[P, None]]:
+    def on_close(self) -> Callable[[AsyncCallable[P, None]], AsyncCallable[P, None]]:
         """给 bot 注册 :obj:`.BotLifeSpan.CLOSE` 阶段 hook 的装饰器"""
         return self.on(BotLifeSpan.CLOSE)
 
     @property
-    def on_stopped(self) -> Callable[[AsyncCallable[P, None]], AsyncCallable[P, None]]:
+    def on_stopped(self) -> Callable[[AsyncCallable[P, None]], AsyncCallable[P, None]]:
         """给 bot 注册 :obj:`.BotLifeSpan.STOPPED` 阶段 hook 的装饰器"""
         return self.on(BotLifeSpan.STOPPED)
-def _safe_run(main: Coroutine[Any, Any, None], debug: bool) -> None: +def _safe_run(main: Coroutine[Any, Any, None], debug: bool) -> None: try: loop = asyncio.get_event_loop() asyncio.get_event_loop_policy().set_event_loop(loop) @@ -900,7 +900,7 @@

melobot.bot.base 源代码

             loop.close()
 
 
-async def alive_signal_guard(main_coro: Coroutine[Any, Any, None]) -> None:
+async def alive_signal_guard(main_coro: Coroutine[Any, Any, None]) -> None:
     asyncio.create_task(main_coro)
 
     while True:
@@ -911,7 +911,7 @@ 

melobot.bot.base 源代码

         await asyncio.sleep(0.45)
 
 
-def _cancel_all_tasks(loop: asyncio.AbstractEventLoop) -> None:
+def _cancel_all_tasks(loop: asyncio.AbstractEventLoop) -> None:
     to_cancel = asyncio.tasks.all_tasks(loop)
     if not to_cancel:
         return
diff --git a/_modules/melobot/ctx.html b/_modules/melobot/ctx.html
index fccebe19..70d23006 100644
--- a/_modules/melobot/ctx.html
+++ b/_modules/melobot/ctx.html
@@ -14,7 +14,7 @@
 
     
         melobot.ctx - melobot 3.0.0
-      
+      
     
     
     
@@ -300,30 +300,30 @@
         

melobot.ctx 源代码

-from contextlib import contextmanager
-from contextvars import ContextVar, Token
-from dataclasses import dataclass, field
-from enum import Enum
+from contextlib import contextmanager
+from contextvars import ContextVar, Token
+from dataclasses import dataclass, field
+from enum import Enum
 
-from typing_extensions import TYPE_CHECKING, Any, Callable, Generator, Generic, Union
+from typing_extensions import TYPE_CHECKING, Any, Callable, Generator, Generic, Union
 
-from .exceptions import AdapterError, BotError, FlowError, LogError, SessionError
-from .typ import SingletonMeta, T
+from .exceptions import AdapterError, BotError, FlowError, LogError, SessionError
+from .typ import SingletonMeta, T
 
 if TYPE_CHECKING:
-    from .adapter import model
-    from .adapter.base import Adapter
-    from .bot.base import Bot
-    from .handle.process import Flow, FlowNode
-    from .io.base import AbstractInSource, OutSourceT
-    from .log.base import GenericLogger
-    from .session.base import Session, SessionStore
-    from .session.option import Rule
+    from .adapter import model
+    from .adapter.base import Adapter
+    from .bot.base import Bot
+    from .handle.process import Flow, FlowNode
+    from .io.base import AbstractInSource, OutSourceT
+    from .log.base import GenericLogger
+    from .session.base import Session, SessionStore
+    from .session.option import Rule
 
 
 
[文档] -class Context(Generic[T], metaclass=SingletonMeta): +class Context(Generic[T], metaclass=SingletonMeta): """上下文对象,本质是对 :class:`contextvars.ContextVar` 操作的封装 继承该基类,可以实现自己的上下文对象。 @@ -332,7 +332,7 @@

melobot.ctx 源代码

 
 
[文档] - def __init__( + def __init__( self, ctx_name: str, lookup_exc_cls: type[BaseException], @@ -356,7 +356,7 @@

melobot.ctx 源代码

 
 
[文档] - def get(self) -> T: + def get(self) -> T: """在当前上下文中,获取本上下文对象的上下文值 :return: 上下文对象的上下文值 @@ -364,12 +364,12 @@

melobot.ctx 源代码

         try:
             return self.__storage__.get()
         except LookupError:
-            raise self.lookup_exc_cls(self.lookup_exc_tip) from None
+ raise self.lookup_exc_cls(self.lookup_exc_tip) from None
[文档] - def try_get(self) -> T | None: + def try_get(self) -> T | None: """与 :func:`get` 类似,但不存在上下文对象时返回 `None` :return: 上下文对象的上下文值 @@ -379,7 +379,7 @@

melobot.ctx 源代码

 
 
[文档] - def add(self, ctx: T) -> Token[T]: + def add(self, ctx: T) -> Token[T]: """在当前上下文中,添加一个上下文值 :param ctx: 上下文值 @@ -390,7 +390,7 @@

melobot.ctx 源代码

 
 
[文档] - def remove(self, token: Token[T]) -> None: + def remove(self, token: Token[T]) -> None: """移除当前上下文中的上下文值 :param token: 添加时返回的 :class:`contextvars.Token` 对象 @@ -401,7 +401,7 @@

melobot.ctx 源代码

 
[文档] @contextmanager - def unfold(self, obj: T) -> Generator[T, None, None]: + def unfold(self, obj: T) -> Generator[T, None, None]: """展开一个上下文值为 `obj` 的上下文环境,返回上下文管理器 上下文管理器可 `yield` 上下文值,退出上下文管理器作用域后自动清理 @@ -420,34 +420,34 @@

melobot.ctx 源代码

 _OutSrcFilterType = Callable[["OutSourceT"], bool]
 
 
-class OutSrcFilterCtx(Context[_OutSrcFilterType]):
-    def __init__(self) -> None:
+class OutSrcFilterCtx(Context[_OutSrcFilterType]):
+    def __init__(self) -> None:
         super().__init__("MELOBOT_OUT_SRC_FILTER", AdapterError)
 
 
 @dataclass
-class EventBuildInfo:
+class EventBuildInfo:
     adapter: "Adapter"
     in_src: "AbstractInSource"
 
 
-class EventBuildInfoCtx(Context[EventBuildInfo]):
-    def __init__(self) -> None:
+class EventBuildInfoCtx(Context[EventBuildInfo]):
+    def __init__(self) -> None:
         super().__init__(
             "MELOBOT_EVENT_BUILD_INFO",
             AdapterError,
             "此时不在活动的事件处理流中,无法获取适配器与输入源的上下文信息",
         )
 
-    def get_adapter_type(self) -> type["Adapter"]:
-        from .adapter.base import Adapter
+    def get_adapter_type(self) -> type["Adapter"]:
+        from .adapter.base import Adapter
 
         return Adapter
 
 
 
[文档] -class FlowRecordStage(Enum): +class FlowRecordStage(Enum): """流记录阶段的枚举""" FLOW_START = "fs" @@ -468,7 +468,7 @@

melobot.ctx 源代码

 
[文档] @dataclass -class FlowRecord: +class FlowRecord: """流记录""" stage: FlowRecordStage @@ -479,20 +479,20 @@

melobot.ctx 源代码

 
 
 
-class FlowRecords(list[FlowRecord]):
-    def append(self, snapshot: FlowRecord) -> None:
+class FlowRecords(list[FlowRecord]):
+    def append(self, snapshot: FlowRecord) -> None:
         super().append(snapshot)
 
 
 
[文档] -class FlowStore(dict[str, Any]): +class FlowStore(dict[str, Any]): """流存储,将会在流运行前初始化,运行结束后销毁"""
@dataclass -class FlowStatus: +class FlowStatus: event: "model.Event" flow: "Flow" node: "FlowNode" @@ -501,21 +501,21 @@

melobot.ctx 源代码

     store: FlowStore = field(default_factory=FlowStore)
 
 
-class FlowCtx(Context[FlowStatus]):
-    def __init__(self) -> None:
+class FlowCtx(Context[FlowStatus]):
+    def __init__(self) -> None:
         super().__init__(
             "MELOBOT_FLOW",
             FlowError,
             "此时不在活动的事件处理流中,无法获取处理流信息",
         )
 
-    def get_event(self) -> "model.Event":
+    def get_event(self) -> "model.Event":
         session = SessionCtx().try_get()
         if session is not None:
             return session.event
         return self.get().event
 
-    def try_get_event(self) -> Union["model.Event", None]:
+    def try_get_event(self) -> Union["model.Event", None]:
         session = SessionCtx().try_get()
         if session is not None:
             return session.event
@@ -525,62 +525,62 @@ 

melobot.ctx 源代码

             return status.event
         return None
 
-    def get_event_type(self) -> type["model.Event"]:
-        from .adapter.model import Event
+    def get_event_type(self) -> type["model.Event"]:
+        from .adapter.model import Event
 
         return Event
 
-    def get_store(self) -> FlowStore:
+    def get_store(self) -> FlowStore:
         return self.get().store
 
-    def get_store_type(self) -> type[FlowStore]:
+    def get_store_type(self) -> type[FlowStore]:
         return FlowStore
 
 
-class BotCtx(Context["Bot"]):
-    def __init__(self) -> None:
+class BotCtx(Context["Bot"]):
+    def __init__(self) -> None:
         super().__init__("MELOBOT_BOT", BotError, "此时未初始化 bot 实例,无法获取")
 
-    def get_type(self) -> type["Bot"]:
-        from .bot.base import Bot
+    def get_type(self) -> type["Bot"]:
+        from .bot.base import Bot
 
         return Bot
 
 
-class SessionCtx(Context["Session"]):
-    def __init__(self) -> None:
+class SessionCtx(Context["Session"]):
+    def __init__(self) -> None:
         super().__init__(
             "MELOBOT_SESSION",
             SessionError,
             "此时不在活动的事件处理流中,无法获取会话信息",
         )
 
-    def get_store(self) -> "SessionStore":
+    def get_store(self) -> "SessionStore":
         return self.get().store
 
-    def get_store_type(self) -> type["SessionStore"]:
-        from .session.base import SessionStore
+    def get_store_type(self) -> type["SessionStore"]:
+        from .session.base import SessionStore
 
         return SessionStore
 
-    def get_rule_type(self) -> type["Rule"]:
-        from .session.option import Rule
+    def get_rule_type(self) -> type["Rule"]:
+        from .session.option import Rule
 
         return Rule
 
 
-class LoggerCtx(Context["GenericLogger"]):
-    def __init__(self) -> None:
+class LoggerCtx(Context["GenericLogger"]):
+    def __init__(self) -> None:
         super().__init__("MELOBOT_LOGGER", LogError, "此时未初始化 logger 实例,无法获取")
 
-    def get_type(self) -> type["GenericLogger"]:
-        from .log.base import GenericLogger
+    def get_type(self) -> type["GenericLogger"]:
+        from .log.base import GenericLogger
 
         return GenericLogger
 
 
-class ActionManualSignalCtx(Context[bool]):
-    def __init__(self) -> None:
+class ActionManualSignalCtx(Context[bool]):
+    def __init__(self) -> None:
         super().__init__("MELOBOT_ACTION_MANUAL_SIGNAL", AdapterError)
 
diff --git a/_modules/melobot/di.html b/_modules/melobot/di.html index 0d098237..bd32f59d 100644 --- a/_modules/melobot/di.html +++ b/_modules/melobot/di.html @@ -14,7 +14,7 @@ melobot.di - melobot 3.0.0 - + @@ -300,17 +300,17 @@

melobot.di 源代码

-from __future__ import annotations
+from __future__ import annotations
 
-from asyncio import Lock
-from collections import deque
-from dataclasses import dataclass
-from functools import wraps
-from inspect import Parameter, isawaitable, signature, unwrap
-from sys import version_info
-from types import BuiltinFunctionType, FunctionType, LambdaType
+from asyncio import Lock
+from collections import deque
+from dataclasses import dataclass
+from functools import wraps
+from inspect import Parameter, isawaitable, signature, unwrap
+from sys import version_info
+from types import BuiltinFunctionType, FunctionType, LambdaType
 
-from typing_extensions import (
+from typing_extensions import (
     TYPE_CHECKING,
     Annotated,
     Any,
@@ -322,9 +322,9 @@ 

melobot.di 源代码

     get_origin,
 )
 
-from .ctx import BotCtx, EventBuildInfoCtx, FlowCtx, LoggerCtx, SessionCtx
-from .exceptions import DependBindError, DependInitError
-from .typ import (
+from .ctx import BotCtx, EventBuildInfoCtx, FlowCtx, LoggerCtx, SessionCtx
+from .exceptions import DependBindError, DependInitError
+from .typ import (
     AsyncCallable,
     BetterABC,
     P,
@@ -334,14 +334,14 @@ 

melobot.di 源代码

     is_subhint,
     is_type,
 )
-from .utils import get_obj_name, to_async
+from .utils import get_obj_name, to_async
 
 if TYPE_CHECKING:
-    from .adapter.base import Adapter
+    from .adapter.base import Adapter
 
 
-class DependNotMatched(BaseException):
-    def __init__(
+class DependNotMatched(BaseException):
+    def __init__(
         self, msg: str, func_name: str, arg_name: str, real_type: type, hint: Any
     ) -> None:
         super().__init__(msg)
@@ -353,10 +353,10 @@ 

melobot.di 源代码

 
 
[文档] -class Depends: +class Depends:
[文档] - def __init__( + def __init__( self, dep: Callable[[], Any] | AsyncCallable[[], Any] | Depends, sub_getter: Callable[[Any], Any] | AsyncCallable[[Any], Any] | None = None, @@ -395,12 +395,12 @@

melobot.di 源代码

         self._cached: Any = VoidType.VOID
- def __repr__(self) -> str: + def __repr__(self) -> str: getter_str = f"getter={self.getter}" if self.getter is not None else "" ref_str = f"ref={self.ref}" if self.ref is not None else "" return f"{self.__class__.__name__}({ref_str if ref_str != '' else getter_str})" - async def _get(self, dep_scope: dict[Depends, Any]) -> Any: + async def _get(self, dep_scope: dict[Depends, Any]) -> Any: if self.getter is not None: val = await self.getter() else: @@ -415,7 +415,7 @@

melobot.di 源代码

                 val = await val
         return val
 
-    async def fulfill(self, dep_scope: dict[Depends, Any]) -> Any:
+    async def fulfill(self, dep_scope: dict[Depends, Any]) -> Any:
         if self._lock is None:
             val = await self._get(dep_scope)
         elif self._cached is not VoidType.VOID:
@@ -431,7 +431,7 @@ 

melobot.di 源代码

 
 
 
-def _adapter_get(hint: Any) -> "Adapter | None":
+def _adapter_get(hint: Any) -> "Adapter | None":
     ctx = EventBuildInfoCtx()
     try:
         return ctx.get().adapter
@@ -439,15 +439,15 @@ 

melobot.di 源代码

         return BotCtx().get().get_adapter(hint)
 
 
-def _custom_logger_get(hint: Any, data: CustomLogger) -> Any:
+def _custom_logger_get(hint: Any, data: CustomLogger) -> Any:
     val = LoggerCtx().get()
     if not is_type(val, hint):
         val = data.getter()
     return val
 
 
-class AutoDepends(Depends):
-    def __init__(self, func: Callable, name: str, hint: Any) -> None:
+class AutoDepends(Depends):
+    def __init__(self, func: Callable, name: str, hint: Any) -> None:
         self.hint = hint
         self.func = func
         self.func_name = get_obj_name(func, otype="callable")
@@ -509,7 +509,7 @@ 

melobot.di 源代码

 
         super().__init__(self.orig_getter, sub_getter=None, cache=False, recursive=False)
 
-    def _unmatch_exc(self, real_type: Any) -> DependNotMatched:
+    def _unmatch_exc(self, real_type: Any) -> DependNotMatched:
         return DependNotMatched(
             f"函数 {self.func_name} 的参数 {self.arg_name} " f"与注解 {self.hint} 不匹配",
             self.func_name,
@@ -518,7 +518,7 @@ 

melobot.di 源代码

             self.hint,
         )
 
-    def _match_check(self, val: Any) -> None:
+    def _match_check(self, val: Any) -> None:
         for data in self.metadatas:
             if isinstance(data, Exclude):
                 if any(isinstance(val, t) for t in data.types):
@@ -531,7 +531,7 @@ 

melobot.di 源代码

         if not is_type(val, self.hint):
             raise self._unmatch_exc(type(val))
 
-    async def fulfill(self, dep_scope: dict[Depends, Any]) -> Any:
+    async def fulfill(self, dep_scope: dict[Depends, Any]) -> Any:
         val = await super().fulfill(dep_scope)
 
         if isinstance(val, Reflection):
@@ -551,7 +551,7 @@ 

melobot.di 源代码

 
[文档] @dataclass -class Exclude: +class Exclude: """数据类。`types` 指定的类别会在依赖注入时被排除 .. code:: python @@ -568,7 +568,7 @@

melobot.di 源代码

 
[文档] @dataclass -class CustomLogger: +class CustomLogger: """数据类。`getter` 参数会用于指定类别日志器不存在时的获取方法 .. code:: python @@ -585,7 +585,7 @@

melobot.di 源代码

 
[文档] @dataclass -class Reflect: +class Reflect: """数据类。指定不直接获取当前依赖项,而是获取对应的一个反射代理 这适用于希望依赖会随着上下文改变,而动态变化的情况。例如动态引用会话流程中的事件对象 @@ -607,15 +607,15 @@

melobot.di 源代码

 
 
 
-class Reflection:
-    def __init__(self, getter: Callable[[], Any]) -> None:
+class Reflection:
+    def __init__(self, getter: Callable[[], Any]) -> None:
         super().__setattr__("__obj_getter__", getter)
 
     @property
-    def __origin__(self) -> Any:
+    def __origin__(self) -> Any:
         return self.__obj_getter__()
 
-    def __getattr__(self, name: str) -> Any:
+    def __getattr__(self, name: str) -> Any:
         getter = self.__obj_getter__
         if name == "__obj_getter__":
             return getter
@@ -624,7 +624,7 @@ 

melobot.di 源代码

 
         return getattr(getter(), name)
 
-    def __setattr__(self, name: str, value: Any) -> Any:
+    def __setattr__(self, name: str, value: Any) -> Any:
         getter = self.__obj_getter__
         if name == "__obj_getter__":
             return getter
@@ -634,7 +634,7 @@ 

melobot.di 源代码

         return setattr(getter(), name, value)
 
 
-def _init_auto_deps(func: Callable[P, T], allow_manual_arg: bool) -> None:
+def _init_auto_deps(func: Callable[P, T], allow_manual_arg: bool) -> None:
     try:
         sign = signature(func)
     except ValueError as e:
@@ -642,7 +642,7 @@ 

melobot.di 源代码

         if str(e).startswith(tip) and version_info <= (3, 10):
             raise DependInitError(
                 f"内建函数 {func} 在 python <= 3.10 的版本中,无法进行依赖注入"
-            ) from None
+            ) from None
         raise
 
     empty = Parameter.empty
@@ -685,7 +685,7 @@ 

melobot.di 源代码

     origin_f.__kwdefaults__ = kwds if len(kwds) else None  # type: ignore[assignment]
 
 
-def _get_bound_args(
+def _get_bound_args(
     func: Callable, /, *args: Any, **kwargs: Any
 ) -> tuple[list[Any], dict[str, Any]]:
     sign = signature(func)
@@ -697,7 +697,7 @@ 

melobot.di 源代码

         raise DependBindError(
             f"依赖注入匹配失败。匹配函数 {fname} 的参数时发生错误:{e}。"
             "这可能是因为传参个数不匹配,或提供了错误的类型注解"
-        ) from None
+        ) from None
 
     bind.apply_defaults()
     return list(bind.args), bind.kwargs
@@ -705,7 +705,7 @@ 

melobot.di 源代码

 
 
[文档] -class DependsHook(Depends, BetterABC, Generic[T]): +class DependsHook(Depends, BetterABC, Generic[T]): """依赖钩子 包装一个依赖项,依赖满足后内部的 hook 将会执行 @@ -713,7 +713,7 @@

melobot.di 源代码

 
 
[文档] - def __init__( + def __init__( self, func: Callable[P, T] | AsyncCallable[P, T], cache: bool = False, @@ -725,7 +725,7 @@

melobot.di 源代码

 
[文档] @abstractmethod - async def deps_callback(self, val: T) -> None: + async def deps_callback(self, val: T) -> None: """所有依赖钩子子类必须实现该抽象方法 :param val: 依赖项被满足后的值 @@ -733,7 +733,7 @@

melobot.di 源代码

         raise NotImplementedError
- async def fulfill(self, dep_scope: dict[Depends, Any]) -> Any: + async def fulfill(self, dep_scope: dict[Depends, Any]) -> Any: val = await super().fulfill(dep_scope) await self.deps_callback(val) return val
@@ -742,7 +742,7 @@

melobot.di 源代码

 
 
[文档] -def inject_deps( +def inject_deps( injectee: Callable[..., T] | AsyncCallable[..., T], manual_arg: bool = False ) -> AsyncCallable[..., T]: """依赖注入标记装饰器,标记当前对象需要被依赖注入 @@ -756,7 +756,7 @@

melobot.di 源代码

     """
 
     @wraps(injectee)
-    async def di_wrapped(*args: P.args, **kwargs: P.kwargs) -> T:
+    async def di_wrapped(*args: P.args, **kwargs: P.kwargs) -> T:
         _args, _kwargs = _get_bound_args(injectee, *args, **kwargs)
         dep_scope: dict[Depends, Any] = {}
 
diff --git a/_modules/melobot/exceptions.html b/_modules/melobot/exceptions.html
index e4814146..c04940e7 100644
--- a/_modules/melobot/exceptions.html
+++ b/_modules/melobot/exceptions.html
@@ -14,7 +14,7 @@
 
     
         melobot.exceptions - melobot 3.0.0
-      
+      
     
     
     
@@ -300,11 +300,11 @@
         

melobot.exceptions 源代码

-import logging
-import sys
+import logging
+import sys
 
-import better_exceptions
-from typing_extensions import Any
+import better_exceptions
+from typing_extensions import Any
 
 better_exceptions.SUPPORTS_COLOR = True
 better_exceptions.color.SUPPORTS_COLOR = True
@@ -322,10 +322,10 @@ 

melobot.exceptions 源代码

 
 
[文档] -class BotException(Exception): +class BotException(Exception): """bot 异常基类""" - def __init__(self, *args: object): + def __init__(self, *args: object): super().__init__(self, args) if not len(args): self.err = "" @@ -337,122 +337,122 @@

melobot.exceptions 源代码

             f"[{self.__class__.__module__}.{self.__class__.__qualname__}] {self.err}"
         )
 
-    def __str__(self) -> str:
+    def __str__(self) -> str:
         return self.err
[文档] -class ValidateError(BotException): +class ValidateError(BotException): """:py:mod:`melobot.utils` 函数参数验证异常"""
[文档] -class BotError(BotException): +class BotError(BotException): """melobot bot 异常"""
[文档] -class SourceError(BotException): +class SourceError(BotException): """melobot 源异常"""
[文档] -class PluginError(BotException): +class PluginError(BotException): """melobot 插件异常"""
[文档] -class PluginAutoGenError(PluginError): +class PluginAutoGenError(PluginError): """melobot 插件自动生成异常"""
[文档] -class PluginLoadError(PluginError): +class PluginLoadError(PluginError): """melobot 插件加载异常"""
[文档] -class PluginIpcError(PluginError): +class PluginIpcError(PluginError): """melobot 插件间通信异常"""
[文档] -class SessionError(BotException): +class SessionError(BotException): """melobot 会话异常"""
[文档] -class FlowError(BotException): +class FlowError(BotException): """melobot 处理流异常"""
[文档] -class LogError(BotException): +class LogError(BotException): """melobot 日志器异常"""
[文档] -class HookError(BotException): +class HookError(BotException): """melobot 生命周期组件异常"""
[文档] -class AdapterError(BotException): +class AdapterError(BotException): """melobot 适配器异常"""
[文档] -class DependError(BotException): +class DependError(BotException): """melobot 依赖注入异常"""
[文档] -class DependInitError(DependError): +class DependInitError(DependError): """melobot 依赖注入项初始化失败"""
[文档] -class DependBindError(DependError): +class DependBindError(DependError): """melobot 依赖注入项值绑定失败"""
[文档] -class DynamicImpError(BotException, ImportError): +class DynamicImpError(BotException, ImportError): """melobot 动态导入组件异常""" - def __init__( + def __init__( self, *args: Any, name: str | None = None, path: str | None = None ) -> None: BotException.__init__(self, *args) diff --git a/_modules/melobot/handle.html b/_modules/melobot/handle.html index f52cb8bb..836488c0 100644 --- a/_modules/melobot/handle.html +++ b/_modules/melobot/handle.html @@ -14,7 +14,7 @@ melobot.handle - melobot 3.0.0 - + @@ -300,10 +300,10 @@

melobot.handle 源代码

-from ..adapter.model import Event as _Event
-from ..ctx import FlowCtx as _FlowCtx
-from ..ctx import FlowRecord, FlowRecordStage, FlowStore
-from .process import (
+from ..adapter.model import Event as _Event
+from ..ctx import FlowCtx as _FlowCtx
+from ..ctx import FlowRecord, FlowRecordStage, FlowStore
+from .process import (
     Flow,
     FlowNode,
     block,
@@ -319,7 +319,7 @@ 

melobot.handle 源代码

 
 
[文档] -def get_flow_records() -> tuple[FlowRecord, ...]: +def get_flow_records() -> tuple[FlowRecord, ...]: """获取当前上下文中的流记录 :return: 流记录 @@ -330,7 +330,7 @@

melobot.handle 源代码

 
 
[文档] -def get_flow_store() -> FlowStore: +def get_flow_store() -> FlowStore: """获取当前上下文中的流存储 :return: 流存储 @@ -341,7 +341,7 @@

melobot.handle 源代码

 
 
[文档] -def get_event() -> _Event: +def get_event() -> _Event: """获取当前上下文中的事件 :return: 事件 @@ -352,7 +352,7 @@

melobot.handle 源代码

 
 
[文档] -def try_get_event() -> _Event | None: +def try_get_event() -> _Event | None: """尝试获取当前上下文中的事件 :return: 事件或空 diff --git a/_modules/melobot/handle/process.html b/_modules/melobot/handle/process.html index dbf25ce1..f26554db 100644 --- a/_modules/melobot/handle/process.html +++ b/_modules/melobot/handle/process.html @@ -14,7 +14,7 @@ melobot.handle.process - melobot 3.0.0 - + @@ -300,29 +300,29 @@

melobot.handle.process 源代码

-from __future__ import annotations
+from __future__ import annotations
 
-from asyncio import create_task
-from dataclasses import dataclass
-from itertools import tee
+from asyncio import create_task
+from dataclasses import dataclass
+from itertools import tee
 
-from typing_extensions import Iterable, NoReturn, Sequence
+from typing_extensions import Iterable, NoReturn, Sequence
 
-from ..adapter.model import Event
-from ..ctx import FlowCtx, FlowRecord, FlowRecords
-from ..ctx import FlowRecordStage as RecordStage
-from ..ctx import FlowStatus, FlowStore
-from ..di import DependNotMatched, inject_deps
-from ..exceptions import FlowError
-from ..typ import AsyncCallable, HandleLevel
-from ..utils import get_obj_name
+from ..adapter.model import Event
+from ..ctx import FlowCtx, FlowRecord, FlowRecords
+from ..ctx import FlowRecordStage as RecordStage
+from ..ctx import FlowStatus, FlowStore
+from ..di import DependNotMatched, inject_deps
+from ..exceptions import FlowError
+from ..typ import AsyncCallable, HandleLevel
+from ..utils import get_obj_name
 
 _FLOW_CTX = FlowCtx()
 
 
 
[文档] -def node(func: AsyncCallable[..., bool | None]) -> FlowNode: +def node(func: AsyncCallable[..., bool | None]) -> FlowNode: """处理结点装饰器,将当前异步可调用对象装饰为一个处理结点""" return FlowNode(func)
@@ -330,7 +330,7 @@

melobot.handle.process 源代码

 
 
[文档] -def no_deps_node(func: AsyncCallable[..., bool | None]) -> FlowNode: +def no_deps_node(func: AsyncCallable[..., bool | None]) -> FlowNode: """与 :func:`node` 类似,但是不自动为结点标记依赖注入。 需要后续使用 :func:`.inject_deps` 手动标记依赖注入, @@ -342,10 +342,10 @@

melobot.handle.process 源代码

 
 
[文档] -class FlowNode: +class FlowNode: """处理流结点""" - def __init__( + def __init__( self, func: AsyncCallable[..., bool | None], no_deps: bool = False ) -> None: self.name = get_obj_name(func, otype="callable") @@ -353,10 +353,10 @@

melobot.handle.process 源代码

             func if no_deps else inject_deps(func)
         )
 
-    def __repr__(self) -> str:
+    def __repr__(self) -> str:
         return f"{self.__class__.__name__}(name={self.name})"
 
-    async def process(self, event: Event, flow: Flow) -> None:
+    async def process(self, event: Event, flow: Flow) -> None:
         try:
             status = _FLOW_CTX.get()
             records, store = status.records, status.store
@@ -395,18 +395,18 @@ 

melobot.handle.process 源代码

 
 
 @dataclass
-class _NodeInfo:
+class _NodeInfo:
     nexts: list[FlowNode]
     in_deg: int
     out_deg: int
 
-    def copy(self) -> _NodeInfo:
+    def copy(self) -> _NodeInfo:
         return _NodeInfo(self.nexts, self.in_deg, self.out_deg)
 
 
 
[文档] -class Flow: +class Flow: """处理流 :ivar str name: 处理流的标识 @@ -414,7 +414,7 @@

melobot.handle.process 源代码

 
 
[文档] - def __init__( + def __init__( self, name: str, *edge_maps: Iterable[Iterable[FlowNode] | FlowNode], @@ -448,7 +448,7 @@

melobot.handle.process 源代码

             raise FlowError(f"定义的处理流 {self.name} 中存在环路")
- def _get_edges( + def _get_edges( self, edge_maps: Sequence[Sequence[Iterable[FlowNode]]] ) -> list[tuple[FlowNode, FlowNode]]: edges: list[tuple[FlowNode, FlowNode]] = [] @@ -474,16 +474,16 @@

melobot.handle.process 源代码

         return edges
 
     @property
-    def priority(self) -> HandleLevel:
+    def priority(self) -> HandleLevel:
         """处理流的优先级"""
         return self._priority
 
-    def on_priority_reset(self, callback: AsyncCallable[[HandleLevel], None]) -> None:
+    def on_priority_reset(self, callback: AsyncCallable[[HandleLevel], None]) -> None:
         self._priority_cb = callback
 
 
[文档] - async def reset_priority(self, new_prior: HandleLevel) -> None: + async def reset_priority(self, new_prior: HandleLevel) -> None: """重设处理流的优先级 不会立即生效,通常会在下一次进入处理流前生效。 @@ -492,7 +492,7 @@

melobot.handle.process 源代码

         :param new_prior: 新优先级
         """
 
-        async def _reset_wrapper() -> None:
+        async def _reset_wrapper() -> None:
             await self._priority_cb(new_prior)
             self._priority = new_prior
 
@@ -500,14 +500,14 @@ 

melobot.handle.process 源代码

 
 
     @property
-    def starts(self) -> tuple[FlowNode, ...]:
+    def starts(self) -> tuple[FlowNode, ...]:
         return tuple(n for n, info in self.graph.items() if info.in_deg == 0)
 
     @property
-    def ends(self) -> tuple[FlowNode, ...]:
+    def ends(self) -> tuple[FlowNode, ...]:
         return tuple(n for n, info in self.graph.items() if info.out_deg == 0)
 
-    def __repr__(self) -> str:
+    def __repr__(self) -> str:
         output = f"{self.__class__.__name__}(name={self.name}, nums={len(self.graph)}"
 
         if len(self.graph):
@@ -516,7 +516,7 @@ 

melobot.handle.process 源代码

             output += ")"
         return output
 
-    def _add(self, _from: FlowNode, to: FlowNode | None) -> None:
+    def _add(self, _from: FlowNode, to: FlowNode | None) -> None:
         from_info = self.graph.setdefault(_from, _NodeInfo([], 0, 0))
 
         if to is not None:
@@ -525,7 +525,7 @@ 

melobot.handle.process 源代码

             from_info.out_deg += 1
             from_info.nexts.append(to)
 
-    def _valid_check(self) -> bool:
+    def _valid_check(self) -> bool:
         graph = {n: info.copy() for n, info in self.graph.items()}
 
         while len(graph):
@@ -545,7 +545,7 @@ 

melobot.handle.process 源代码