ErisPulse 2.3.3.dev0__py3-none-any.whl → 2.3.4.dev2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. ErisPulse/CLI/__init__.py +11 -0
  2. ErisPulse/CLI/__init__.pyi +13 -0
  3. ErisPulse/CLI/base.py +52 -0
  4. ErisPulse/CLI/base.pyi +50 -0
  5. ErisPulse/CLI/cli.py +224 -0
  6. ErisPulse/CLI/cli.pyi +80 -0
  7. ErisPulse/CLI/commands/__init__.py +6 -0
  8. ErisPulse/CLI/commands/__init__.pyi +12 -0
  9. ErisPulse/CLI/commands/init.py +395 -0
  10. ErisPulse/CLI/commands/init.pyi +70 -0
  11. ErisPulse/CLI/commands/install.py +302 -0
  12. ErisPulse/CLI/commands/install.pyi +58 -0
  13. ErisPulse/CLI/commands/list.py +160 -0
  14. ErisPulse/CLI/commands/list.pyi +44 -0
  15. ErisPulse/CLI/commands/list_remote.py +123 -0
  16. ErisPulse/CLI/commands/list_remote.pyi +35 -0
  17. ErisPulse/CLI/commands/run.py +108 -0
  18. ErisPulse/CLI/commands/run.pyi +39 -0
  19. ErisPulse/CLI/commands/self_update.py +232 -0
  20. ErisPulse/CLI/commands/self_update.pyi +47 -0
  21. ErisPulse/CLI/commands/uninstall.py +32 -0
  22. ErisPulse/CLI/commands/uninstall.pyi +24 -0
  23. ErisPulse/CLI/commands/upgrade.py +56 -0
  24. ErisPulse/CLI/commands/upgrade.pyi +25 -0
  25. ErisPulse/CLI/console.pyi +20 -0
  26. ErisPulse/CLI/registry.py +112 -0
  27. ErisPulse/CLI/registry.pyi +99 -0
  28. ErisPulse/{utils → CLI/utils}/__init__.py +2 -6
  29. ErisPulse/CLI/utils/__init__.pyi +14 -0
  30. ErisPulse/{utils → CLI/utils}/package_manager.py +146 -20
  31. ErisPulse/CLI/utils/package_manager.pyi +241 -0
  32. ErisPulse/{utils → CLI/utils}/reload_handler.py +7 -8
  33. ErisPulse/CLI/utils/reload_handler.pyi +64 -0
  34. ErisPulse/Core/Bases/__init__.pyi +14 -0
  35. ErisPulse/Core/Bases/adapter.py +13 -1
  36. ErisPulse/Core/Bases/adapter.pyi +140 -0
  37. ErisPulse/Core/Bases/manager.py +136 -0
  38. ErisPulse/Core/Bases/manager.pyi +108 -0
  39. ErisPulse/Core/Bases/module.py +53 -1
  40. ErisPulse/Core/Bases/module.pyi +95 -0
  41. ErisPulse/Core/Event/__init__.pyi +26 -0
  42. ErisPulse/Core/Event/base.pyi +62 -0
  43. ErisPulse/Core/Event/command.py +6 -1
  44. ErisPulse/Core/Event/command.pyi +113 -0
  45. ErisPulse/Core/Event/exceptions.pyi +43 -0
  46. ErisPulse/Core/Event/message.pyi +93 -0
  47. ErisPulse/Core/Event/meta.pyi +92 -0
  48. ErisPulse/Core/Event/notice.pyi +108 -0
  49. ErisPulse/Core/Event/request.pyi +76 -0
  50. ErisPulse/Core/Event/wrapper.py +2 -3
  51. ErisPulse/Core/Event/wrapper.pyi +403 -0
  52. ErisPulse/Core/__init__.py +16 -13
  53. ErisPulse/Core/__init__.pyi +16 -0
  54. ErisPulse/Core/_self_config.py +1 -1
  55. ErisPulse/Core/_self_config.pyi +72 -0
  56. ErisPulse/Core/adapter.py +70 -10
  57. ErisPulse/Core/adapter.pyi +246 -0
  58. ErisPulse/Core/config.pyi +70 -0
  59. ErisPulse/Core/exceptions.py +4 -2
  60. ErisPulse/Core/exceptions.pyi +60 -0
  61. ErisPulse/Core/lifecycle.py +15 -1
  62. ErisPulse/Core/lifecycle.pyi +92 -0
  63. ErisPulse/Core/logger.py +21 -15
  64. ErisPulse/Core/logger.pyi +169 -0
  65. ErisPulse/Core/module.py +57 -9
  66. ErisPulse/Core/module.pyi +189 -0
  67. ErisPulse/Core/router.py +13 -5
  68. ErisPulse/Core/router.pyi +120 -0
  69. ErisPulse/Core/storage.py +94 -256
  70. ErisPulse/Core/storage.pyi +220 -0
  71. ErisPulse/__init__.py +35 -1236
  72. ErisPulse/__init__.pyi +22 -0
  73. ErisPulse/__main__.py +1 -1
  74. ErisPulse/__main__.pyi +24 -0
  75. ErisPulse/loaders/__init__.py +22 -0
  76. ErisPulse/loaders/__init__.pyi +21 -0
  77. ErisPulse/loaders/adapter_loader.py +187 -0
  78. ErisPulse/loaders/adapter_loader.pyi +82 -0
  79. ErisPulse/loaders/base_loader.py +162 -0
  80. ErisPulse/loaders/base_loader.pyi +23 -0
  81. ErisPulse/loaders/initializer.py +150 -0
  82. ErisPulse/loaders/initializer.pyi +60 -0
  83. ErisPulse/loaders/module_loader.py +618 -0
  84. ErisPulse/loaders/module_loader.pyi +179 -0
  85. ErisPulse/loaders/strategy.py +129 -0
  86. ErisPulse/loaders/strategy.pyi +90 -0
  87. ErisPulse/sdk.py +435 -0
  88. ErisPulse/sdk.pyi +158 -0
  89. {erispulse-2.3.3.dev0.dist-info → erispulse-2.3.4.dev2.dist-info}/METADATA +6 -20
  90. erispulse-2.3.4.dev2.dist-info/RECORD +103 -0
  91. {erispulse-2.3.3.dev0.dist-info → erispulse-2.3.4.dev2.dist-info}/licenses/LICENSE +3 -3
  92. ErisPulse/Core/ux.py +0 -635
  93. ErisPulse/utils/cli.py +0 -1097
  94. erispulse-2.3.3.dev0.dist-info/RECORD +0 -35
  95. /ErisPulse/{utils → CLI}/console.py +0 -0
  96. {erispulse-2.3.3.dev0.dist-info → erispulse-2.3.4.dev2.dist-info}/WHEEL +0 -0
  97. {erispulse-2.3.3.dev0.dist-info → erispulse-2.3.4.dev2.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,241 @@
1
+ # type: ignore
2
+ #
3
+ # Auto-generated type stub for package_manager.py
4
+ # DO NOT EDIT MANUALLY - Generated by generate-type-stubs.py
5
+ #
6
+
7
+ """
8
+ ErisPulse SDK 包管理器
9
+
10
+ 提供包安装、卸载、升级和查询功能
11
+ """
12
+
13
+ import os
14
+ import asyncio
15
+ import importlib.metadata
16
+ import json
17
+ import subprocess
18
+ import sys
19
+ import time
20
+ from typing import List, Dict, Tuple, Optional, Any
21
+ from rich.panel import Panel
22
+ from rich.progress import Progress, BarColumn, TextColumn
23
+ from rich.prompt import Confirm
24
+ from ..console import console
25
+
26
+ class PackageManager:
27
+ """
28
+ ErisPulse包管理器
29
+
30
+ 提供包安装、卸载、升级和查询功能
31
+
32
+ {!--< tips >!--}
33
+ 1. 支持本地和远程包管理
34
+ 2. 包含1小时缓存机制
35
+ {!--< /tips >!--}
36
+ """
37
+ def __init__(self: None) -> ...:
38
+ """
39
+ 初始化包管理器
40
+ """
41
+ ...
42
+ async def _fetch_remote_packages(self: object, url: str) -> Optional[dict]:
43
+ """
44
+ 从指定URL获取远程包数据
45
+
46
+ :param url: 远程包数据URL
47
+ :return: 解析后的JSON数据,失败返回None
48
+
49
+ :raises ClientError: 网络请求失败时抛出
50
+ :raises JSONDecodeError: JSON解析失败时抛出
51
+ """
52
+ ...
53
+ async def get_remote_packages(self: object, force_refresh: bool = ...) -> dict:
54
+ """
55
+ 获取远程包列表,带缓存机制
56
+
57
+ :param force_refresh: 是否强制刷新缓存
58
+ :return: 包含模块和适配器的字典
59
+
60
+ :return:
61
+ dict: {
62
+ "modules": {模块名: 模块信息},
63
+ "adapters": {适配器名: 适配器信息},
64
+ "cli_extensions": {扩展名: 扩展信息}
65
+ }
66
+ """
67
+ ...
68
+ def get_installed_packages(self: object) -> Dict[(str, Dict[(str, Dict[(str, str)])])]:
69
+ """
70
+ 获取已安装的包信息
71
+
72
+ :return: 已安装包字典,包含模块、适配器和CLI扩展
73
+
74
+ :return:
75
+ dict: {
76
+ "modules": {模块名: 模块信息},
77
+ "adapters": {适配器名: 适配器信息},
78
+ "cli_extensions": {扩展名: 扩展信息}
79
+ }
80
+ """
81
+ ...
82
+ def _is_module_enabled(self: object, module_name: str) -> bool:
83
+ """
84
+ 检查模块是否启用
85
+
86
+ :param module_name: 模块名称
87
+ :return: 模块是否启用
88
+
89
+ :raises ImportError: 核心模块不可用时抛出
90
+ """
91
+ ...
92
+ def _normalize_name(self: object, name: str) -> str:
93
+ """
94
+ 标准化包名,统一转为小写以实现大小写不敏感比较
95
+
96
+ :param name: 原始名称
97
+ :return: 标准化后的名称
98
+ """
99
+ ...
100
+ async def _find_package_by_alias(self: object, alias: str) -> Optional[str]:
101
+ """
102
+ 通过别名查找实际包名(大小写不敏感)
103
+ 支持查找已安装包和远程包
104
+
105
+ :param alias: 包别名或PyPI包名
106
+ :return: 实际包名,未找到返回None
107
+ """
108
+ ...
109
+ def _find_installed_package_by_name(self: object, name: str) -> Optional[str]:
110
+ """
111
+ 在已安装包中查找实际包名(大小写不敏感)
112
+
113
+ :param name: 包名或别名
114
+ :return: 实际包名,未找到返回None
115
+ """
116
+ ...
117
+ async def check_package_updates(self: object) -> Dict[(str, Tuple[(str, str)])]:
118
+ """
119
+ 检查包更新,对比本地版本和远程版本
120
+
121
+ :return: {包名: (当前版本, 最新版本)},仅包含有新版本的包
122
+ """
123
+ ...
124
+ async def _get_pypi_package_version(self: object, package_name: str, force_refresh: bool = ...) -> Optional[str]:
125
+ """
126
+ 从PyPI获取包的最新版本,带缓存机制
127
+
128
+ :param package_name: PyPI包名
129
+ :param force_refresh: 是否强制刷新缓存
130
+ :return: 最新版本号,失败返回None
131
+ """
132
+ ...
133
+ def _run_pip_command_with_output(self: object, args: List[str], description: str) -> Tuple[(bool, str, str)]:
134
+ """
135
+ 执行pip命令并捕获输出
136
+
137
+ :param args: pip命令参数列表
138
+ :param description: 进度条描述
139
+ :return: (是否成功, 标准输出, 标准错误)
140
+ """
141
+ ...
142
+ def _compare_versions(self: object, version1: str, version2: str) -> int:
143
+ """
144
+ 比较两个版本号
145
+
146
+ :param version1: 版本号1
147
+ :param version2: 版本号2
148
+ :return: 1 if version1 > version2, -1 if version1 < version2, 0 if equal
149
+ """
150
+ ...
151
+ def _check_sdk_compatibility(self: object, min_sdk_version: str) -> Tuple[(bool, str)]:
152
+ """
153
+ 检查SDK版本兼容性
154
+
155
+ :param min_sdk_version: 所需的最小SDK版本
156
+ :return: (是否兼容, 当前版本信息)
157
+ """
158
+ ...
159
+ async def _get_package_info(self: object, package_name: str) -> Optional[Dict[(str, Any)]]:
160
+ """
161
+ 获取包的详细信息(包括min_sdk_version等)
162
+
163
+ :param package_name: 包名或别名
164
+ :return: 包信息字典
165
+ """
166
+ ...
167
+ def install_package(self: object, package_names: List[str], upgrade: bool = ..., pre: bool = ...) -> bool:
168
+ """
169
+ 安装指定包(支持多个包)
170
+
171
+ :param package_names: 要安装的包名或别名列表
172
+ :param upgrade: 是否升级已安装的包
173
+ :param pre: 是否包含预发布版本
174
+ :return: 安装是否成功
175
+ """
176
+ ...
177
+ def uninstall_package(self: object, package_names: List[str]) -> bool:
178
+ """
179
+ 卸载指定包(支持多个包,支持别名)
180
+
181
+ :param package_names: 要卸载的包名或别名列表
182
+ :return: 卸载是否成功
183
+ """
184
+ ...
185
+ def upgrade_all(self: object) -> bool:
186
+ """
187
+ 升级所有有新版本的ErisPulse包
188
+
189
+ :return: 升级是否成功
190
+
191
+ :raises KeyboardInterrupt: 用户取消操作时抛出
192
+ """
193
+ ...
194
+ def upgrade_package(self: object, package_names: List[str], pre: bool = ...) -> bool:
195
+ """
196
+ 升级指定包(支持多个包)
197
+
198
+ :param package_names: 要升级的包名或别名列表
199
+ :param pre: 是否包含预发布版本
200
+ :return: 升级是否成功
201
+ """
202
+ ...
203
+ def search_package(self: object, query: str) -> Dict[(str, List[Dict[(str, str)]])]:
204
+ """
205
+ 搜索包(本地和远程)
206
+
207
+ :param query: 搜索关键词
208
+ :return: 匹配的包信息
209
+ """
210
+ ...
211
+ def get_installed_version(self: object) -> str:
212
+ """
213
+ 获取当前安装的ErisPulse版本
214
+
215
+ :return: 当前版本号
216
+ """
217
+ ...
218
+ async def get_pypi_versions(self: object) -> List[Dict[(str, Any)]]:
219
+ """
220
+ 从PyPI获取ErisPulse的所有可用版本
221
+
222
+ :return: 版本信息列表
223
+ """
224
+ ...
225
+ def _is_pre_release(self: object, version: str) -> bool:
226
+ """
227
+ 判断版本是否为预发布版本
228
+
229
+ :param version: 版本号
230
+ :return: 是否为预发布版本
231
+ """
232
+ ...
233
+ def update_self(self: object, target_version: str = ..., force: bool = ...) -> bool:
234
+ """
235
+ 更新ErisPulse SDK本身
236
+
237
+ :param target_version: 目标版本号,None表示更新到最新版本
238
+ :param force: 是否强制更新
239
+ :return: 更新是否成功
240
+ """
241
+ ...
@@ -10,7 +10,7 @@ import sys
10
10
  import time
11
11
  from watchdog.events import FileSystemEventHandler
12
12
 
13
- from .console import console
13
+ from ..console import console
14
14
 
15
15
 
16
16
  class ReloadHandler(FileSystemEventHandler):
@@ -96,16 +96,15 @@ class ReloadHandler(FileSystemEventHandler):
96
96
  :param event: 文件系统事件
97
97
  :param reason: 重载原因
98
98
  """
99
- from ErisPulse.Core import logger
100
99
 
101
100
  try:
102
- from .cli import _cleanup_adapters, _cleanup_modules
103
- logger.info(f"检测到文件变更 ({reason}),正在关闭适配器和模块...")
104
- _cleanup_adapters()
105
- _cleanup_modules()
101
+ import asyncio
102
+ from ... import uninit
103
+ console.print(f"检测到文件变更 ({reason}),正在关闭适配器和模块...")
104
+ asyncio.run(uninit())
106
105
  except Exception as e:
107
- logger.warning(f"关闭适配器和模块时出错: {e}")
106
+ console.print(f"关闭适配器和模块时出错: {e}")
108
107
 
109
- logger.info("正在重启...")
108
+ console.print("正在重启...")
110
109
  self._terminate_process()
111
110
  self.start_process()
@@ -0,0 +1,64 @@
1
+ # type: ignore
2
+ #
3
+ # Auto-generated type stub for reload_handler.py
4
+ # DO NOT EDIT MANUALLY - Generated by generate-type-stubs.py
5
+ #
6
+
7
+ """
8
+ ErisPulse SDK 热重载处理器
9
+
10
+ 实现热重载功能,监控文件变化并重启进程
11
+ """
12
+
13
+ import os
14
+ import subprocess
15
+ import sys
16
+ import time
17
+ from watchdog.events import FileSystemEventHandler
18
+ from ..console import console
19
+
20
+ class ReloadHandler(FileSystemEventHandler):
21
+ """
22
+ 文件系统事件处理器
23
+
24
+ 实现热重载功能,监控文件变化并重启进程
25
+
26
+ {!--< tips >!--}
27
+ 1. 支持.py文件修改重载
28
+ 2. 支持配置文件修改重载
29
+ {!--< /tips >!--}
30
+ """
31
+ def __init__(self: None, script_path: str, reload_mode: bool = ...) -> ...:
32
+ """
33
+ 初始化处理器
34
+
35
+ :param script_path: 要监控的脚本路径
36
+ :param reload_mode: 是否启用重载模式
37
+ """
38
+ ...
39
+ def start_process(self: object) -> ...:
40
+ """
41
+ 启动监控进程
42
+ """
43
+ ...
44
+ def _terminate_process(self: object) -> ...:
45
+ """
46
+ 终止当前进程
47
+
48
+ :raises subprocess.TimeoutExpired: 进程终止超时时抛出
49
+ """
50
+ ...
51
+ def on_modified(self: object, event: ...) -> ...:
52
+ """
53
+ 文件修改事件处理
54
+
55
+ :param event: 文件系统事件
56
+ """
57
+ ...
58
+ def _handle_reload(self: object, event: ..., reason: str) -> ...:
59
+ """
60
+ 处理热重载逻辑
61
+ :param event: 文件系统事件
62
+ :param reason: 重载原因
63
+ """
64
+ ...
@@ -0,0 +1,14 @@
1
+ # type: ignore
2
+ #
3
+ # Auto-generated type stub for __init__.py
4
+ # DO NOT EDIT MANUALLY - Generated by generate-type-stubs.py
5
+ #
6
+
7
+ """
8
+ ErisPulse 基础模块
9
+
10
+ 提供核心基类定义,包括适配器和模块基类
11
+ """
12
+
13
+ from .adapter import SendDSL, BaseAdapter
14
+ from .module import BaseModule
@@ -72,7 +72,19 @@ class SendDSL:
72
72
  >>> adapter.Send.To("123").Using("bot1").Text("Hello") # 支持乱序
73
73
  """
74
74
  return self.__class__(self._adapter, self._target_type, self._target_id, account_id)
75
-
75
+
76
+ def Account(self, account_id: Union[str, int]) -> 'SendDSL':
77
+ """
78
+ 设置发送账号
79
+
80
+ :param _account_id: 发送账号
81
+ :return: SendDSL实例
82
+
83
+ :example:
84
+ >>> adapter.Send.Account("bot1").To("123").Text("Hello")
85
+ >>> adapter.Send.To("123").Account("bot1").Text("Hello") # 支持乱序
86
+ """
87
+ return self.__class__(self._adapter, self._target_type, self._target_id, account_id)
76
88
 
77
89
  class BaseAdapter:
78
90
  """
@@ -0,0 +1,140 @@
1
+ # type: ignore
2
+ #
3
+ # Auto-generated type stub for adapter.py
4
+ # DO NOT EDIT MANUALLY - Generated by generate-type-stubs.py
5
+ #
6
+
7
+ """
8
+ ErisPulse 适配器基础模块
9
+
10
+ 提供适配器和消息发送DSL的基类实现
11
+
12
+ {!--< tips >!--}
13
+ 1. 用于实现与不同平台的交互接口
14
+ 2. 提供统一的消息发送DSL风格接口
15
+ {!--< /tips >!--}
16
+ """
17
+
18
+ import asyncio
19
+ from typing import Any, Optional, Union, Awaitable
20
+
21
+ class SendDSL:
22
+ """
23
+ 消息发送DSL基类
24
+
25
+ 用于实现 Send.To(...).Func(...) 风格的链式调用接口
26
+
27
+ {!--< tips >!--}
28
+ 1. 子类应实现具体的消息发送方法(如Text, Image等)
29
+ 2. 通过__getattr__实现动态方法调用
30
+ {!--< /tips >!--}
31
+ """
32
+ def __init__(self: None, adapter: BaseAdapter, target_type: Optional[str] = ..., target_id: Optional[str] = ..., account_id: Optional[str] = ...) -> ...:
33
+ """
34
+ 初始化DSL发送器
35
+
36
+ :param adapter: 所属适配器实例
37
+ :param target_type: 目标类型(可选)
38
+ :param target_id: 目标ID(可选)
39
+ :param _account_id: 发送账号(可选)
40
+ """
41
+ ...
42
+ def To(self: object, target_type: str = ..., target_id: Union[(str, int)] = ...) -> SendDSL:
43
+ """
44
+ 设置消息目标
45
+
46
+ :param target_type: 目标类型(可选)
47
+ :param target_id: 目标ID(可选)
48
+ :return: SendDSL实例
49
+
50
+ :example:
51
+ >>> adapter.Send.To("user", "123").Text("Hello")
52
+ >>> adapter.Send.To("123").Text("Hello") # 简化形式
53
+ """
54
+ ...
55
+ def Using(self: object, account_id: Union[(str, int)]) -> SendDSL:
56
+ """
57
+ 设置发送账号
58
+
59
+ :param _account_id: 发送账号
60
+ :return: SendDSL实例
61
+
62
+ :example:
63
+ >>> adapter.Send.Using("bot1").To("123").Text("Hello")
64
+ >>> adapter.Send.To("123").Using("bot1").Text("Hello") # 支持乱序
65
+ """
66
+ ...
67
+ def Account(self: object, account_id: Union[(str, int)]) -> SendDSL:
68
+ """
69
+ 设置发送账号
70
+
71
+ :param _account_id: 发送账号
72
+ :return: SendDSL实例
73
+
74
+ :example:
75
+ >>> adapter.Send.Account("bot1").To("123").Text("Hello")
76
+ >>> adapter.Send.To("123").Account("bot1").Text("Hello") # 支持乱序
77
+ """
78
+ ...
79
+
80
+ class BaseAdapter:
81
+ """
82
+ 适配器基类
83
+
84
+ 提供与外部平台交互的标准接口,子类必须实现必要方法
85
+
86
+ {!--< tips >!--}
87
+ 1. 必须实现call_api, start和shutdown方法
88
+ 2. 可以自定义Send类实现平台特定的消息发送逻辑
89
+ 3. 通过on装饰器注册事件处理器
90
+ 4. 支持OneBot12协议的事件处理
91
+ {!--< /tips >!--}
92
+ """
93
+ def __init__(self: None) -> ...:
94
+ ...
95
+ async def call_api(self: object, endpoint: str, **params: Any) -> Any:
96
+ """
97
+ 调用平台API的抽象方法
98
+
99
+ :param endpoint: API端点
100
+ :param params: API参数
101
+ :return: API调用结果
102
+ :raises NotImplementedError: 必须由子类实现
103
+ """
104
+ ...
105
+ async def start(self: object) -> None:
106
+ """
107
+ 启动适配器的抽象方法
108
+
109
+ :raises NotImplementedError: 必须由子类实现
110
+ """
111
+ ...
112
+ async def shutdown(self: object) -> None:
113
+ """
114
+ 关闭适配器的抽象方法
115
+
116
+ :raises NotImplementedError: 必须由子类实现
117
+ """
118
+ ...
119
+ async def emit(self: object) -> None:
120
+ ...
121
+ def send(self: object, target_type: str, target_id: str, message: Any, **kwargs: Any) -> asyncio.Task:
122
+ """
123
+ 发送消息的便捷方法,返回一个 asyncio Task
124
+
125
+ :param target_type: 目标类型
126
+ :param target_id: 目标ID
127
+ :param message: 消息内容
128
+ :param kwargs: 其他参数
129
+ - method: 发送方法名(默认为"Text")
130
+ :return: asyncio.Task 对象,用户可以自主决定是否等待
131
+
132
+ :raises AttributeError: 当发送方法不存在时抛出
133
+
134
+ :example:
135
+ >>> task = adapter.send("user", "123", "Hello")
136
+ >>> # 用户可以选择等待: result = await task
137
+ >>> # 或者不等待让其在后台执行
138
+ >>> await adapter.send("group", "456", "Hello", method="Markdown") # 直接等待
139
+ """
140
+ ...
@@ -0,0 +1,136 @@
1
+ """
2
+ ErisPulse 管理器基类
3
+
4
+ 提供适配器和模块管理器的统一接口定义
5
+
6
+ {!--< tips >!--}
7
+ 适配器管理器和模块管理器都应继承此基类以保持接口一致性
8
+ {!--< /tips >!--}
9
+ """
10
+
11
+ from abc import ABC, abstractmethod
12
+ from typing import Dict, List, Any, Type, Optional
13
+
14
+
15
+ class ManagerBase(ABC):
16
+ """
17
+ 管理器基类
18
+
19
+ 定义适配器和模块管理器的统一接口
20
+
21
+ {!--< tips >!--}
22
+ 统一方法:
23
+ - register(): 注册类
24
+ - unregister(): 取消注册
25
+ - get(): 获取实例
26
+ - exists(): 检查是否存在
27
+ - enable()/disable(): 启用/禁用
28
+ - is_enabled(): 检查是否启用
29
+ - list_*(): 列出相关项
30
+ {!--< /tips >!--}
31
+ """
32
+
33
+ # ==================== 注册与取消注册 ====================
34
+
35
+ @abstractmethod
36
+ def register(self, name: str, class_type: Type, info: Optional[Dict] = None) -> bool:
37
+ """
38
+ 注册类
39
+
40
+ :param name: 名称
41
+ :param class_type: 类类型
42
+ :param info: 额外信息
43
+ :return: 是否注册成功
44
+ """
45
+ ...
46
+
47
+ @abstractmethod
48
+ def unregister(self, name: str) -> bool:
49
+ """
50
+ 取消注册
51
+
52
+ :param name: 名称
53
+ :return: 是否取消成功
54
+ """
55
+ ...
56
+
57
+ # ==================== 实例获取 ====================
58
+
59
+ @abstractmethod
60
+ def get(self, name: str) -> Any:
61
+ """
62
+ 获取实例
63
+
64
+ :param name: 名称
65
+ :return: 实例或 None
66
+ """
67
+ ...
68
+
69
+ # ==================== 存在性检查 ====================
70
+
71
+ @abstractmethod
72
+ def exists(self, name: str) -> bool:
73
+ """
74
+ 检查是否存在(在配置中注册)
75
+
76
+ :param name: 名称
77
+ :return: 是否存在
78
+ """
79
+ ...
80
+
81
+ # ==================== 启用/禁用管理 ====================
82
+
83
+ @abstractmethod
84
+ def is_enabled(self, name: str) -> bool:
85
+ """
86
+ 检查是否启用
87
+
88
+ :param name: 名称
89
+ :return: 是否启用
90
+ """
91
+ ...
92
+
93
+ @abstractmethod
94
+ def enable(self, name: str) -> bool:
95
+ """
96
+ 启用
97
+
98
+ :param name: 名称
99
+ :return: 是否成功
100
+ """
101
+ ...
102
+
103
+ @abstractmethod
104
+ def disable(self, name: str) -> bool:
105
+ """
106
+ 禁用
107
+
108
+ :param name: 名称
109
+ :return: 是否成功
110
+ """
111
+ ...
112
+
113
+ # ==================== 列表方法 ====================
114
+
115
+ @abstractmethod
116
+ def list_registered(self) -> List[str]:
117
+ """
118
+ 列出所有已注册的项
119
+
120
+ :return: 名称列表
121
+ """
122
+ ...
123
+
124
+ @abstractmethod
125
+ def list_items(self) -> Dict[str, bool]:
126
+ """
127
+ 列出所有项及其状态
128
+
129
+ :return: {名称: 是否启用} 字典
130
+ """
131
+ ...
132
+
133
+
134
+ __all__ = [
135
+ "ManagerBase"
136
+ ]