ErisPulse 2.3.1__tar.gz → 2.3.3__tar.gz

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 (200) hide show
  1. {erispulse-2.3.1 → erispulse-2.3.3}/PKG-INFO +1 -3
  2. {erispulse-2.3.1 → erispulse-2.3.3}/pyproject.toml +13 -3
  3. erispulse-2.3.3/src/ErisPulse/Core/Bases/__init__.pyi +14 -0
  4. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/Bases/adapter.py +13 -1
  5. erispulse-2.3.3/src/ErisPulse/Core/Bases/adapter.pyi +140 -0
  6. erispulse-2.3.3/src/ErisPulse/Core/Bases/module.pyi +52 -0
  7. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/Event/__init__.py +3 -1
  8. erispulse-2.3.3/src/ErisPulse/Core/Event/__init__.pyi +26 -0
  9. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/Event/base.py +5 -0
  10. erispulse-2.3.3/src/ErisPulse/Core/Event/base.pyi +62 -0
  11. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/Event/command.py +66 -17
  12. erispulse-2.3.3/src/ErisPulse/Core/Event/command.pyi +113 -0
  13. erispulse-2.3.3/src/ErisPulse/Core/Event/exceptions.pyi +43 -0
  14. erispulse-2.3.3/src/ErisPulse/Core/Event/message.pyi +93 -0
  15. erispulse-2.3.3/src/ErisPulse/Core/Event/meta.pyi +92 -0
  16. erispulse-2.3.3/src/ErisPulse/Core/Event/notice.pyi +108 -0
  17. erispulse-2.3.3/src/ErisPulse/Core/Event/request.pyi +76 -0
  18. erispulse-2.3.3/src/ErisPulse/Core/Event/wrapper.py +592 -0
  19. erispulse-2.3.3/src/ErisPulse/Core/Event/wrapper.pyi +404 -0
  20. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/__init__.py +16 -8
  21. erispulse-2.3.3/src/ErisPulse/Core/__init__.pyi +17 -0
  22. erispulse-2.3.3/src/ErisPulse/Core/_self_config.pyi +72 -0
  23. erispulse-2.3.3/src/ErisPulse/Core/adapter.pyi +229 -0
  24. erispulse-2.3.3/src/ErisPulse/Core/config.pyi +70 -0
  25. erispulse-2.3.3/src/ErisPulse/Core/exceptions.pyi +60 -0
  26. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/lifecycle.py +6 -1
  27. erispulse-2.3.3/src/ErisPulse/Core/lifecycle.pyi +92 -0
  28. erispulse-2.3.3/src/ErisPulse/Core/logger.pyi +168 -0
  29. erispulse-2.3.3/src/ErisPulse/Core/module.pyi +178 -0
  30. erispulse-2.3.3/src/ErisPulse/Core/router.pyi +120 -0
  31. erispulse-2.3.3/src/ErisPulse/Core/storage.pyi +273 -0
  32. erispulse-2.3.3/src/ErisPulse/Core/ux.pyi +94 -0
  33. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/__init__.py +10 -5
  34. erispulse-2.3.3/src/ErisPulse/__init__.pyi +310 -0
  35. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/__main__.py +0 -5
  36. erispulse-2.3.3/src/ErisPulse/__main__.pyi +24 -0
  37. erispulse-2.3.3/src/ErisPulse/sdk_protocol.py +150 -0
  38. erispulse-2.3.3/src/ErisPulse/sdk_protocol.pyi +100 -0
  39. erispulse-2.3.3/src/ErisPulse/utils/__init__.pyi +16 -0
  40. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/utils/cli.py +9 -4
  41. erispulse-2.3.3/src/ErisPulse/utils/cli.pyi +145 -0
  42. erispulse-2.3.3/src/ErisPulse/utils/console.pyi +20 -0
  43. erispulse-2.3.3/src/ErisPulse/utils/package_manager.pyi +224 -0
  44. erispulse-2.3.3/src/ErisPulse/utils/reload_handler.pyi +64 -0
  45. erispulse-2.3.3/stubs/ErisPulse/Core/Bases/__init__.pyi +14 -0
  46. erispulse-2.3.3/stubs/ErisPulse/Core/Bases/adapter.pyi +140 -0
  47. erispulse-2.3.3/stubs/ErisPulse/Core/Bases/module.pyi +52 -0
  48. erispulse-2.3.3/stubs/ErisPulse/Core/Event/__init__.pyi +26 -0
  49. erispulse-2.3.3/stubs/ErisPulse/Core/Event/base.pyi +62 -0
  50. erispulse-2.3.3/stubs/ErisPulse/Core/Event/command.pyi +113 -0
  51. erispulse-2.3.3/stubs/ErisPulse/Core/Event/exceptions.pyi +43 -0
  52. erispulse-2.3.3/stubs/ErisPulse/Core/Event/message.pyi +93 -0
  53. erispulse-2.3.3/stubs/ErisPulse/Core/Event/meta.pyi +92 -0
  54. erispulse-2.3.3/stubs/ErisPulse/Core/Event/notice.pyi +108 -0
  55. erispulse-2.3.3/stubs/ErisPulse/Core/Event/request.pyi +76 -0
  56. erispulse-2.3.3/stubs/ErisPulse/Core/Event/wrapper.pyi +404 -0
  57. erispulse-2.3.3/stubs/ErisPulse/Core/__init__.pyi +17 -0
  58. erispulse-2.3.3/stubs/ErisPulse/Core/_self_config.pyi +72 -0
  59. erispulse-2.3.3/stubs/ErisPulse/Core/adapter.pyi +229 -0
  60. erispulse-2.3.3/stubs/ErisPulse/Core/config.pyi +70 -0
  61. erispulse-2.3.3/stubs/ErisPulse/Core/exceptions.pyi +60 -0
  62. erispulse-2.3.3/stubs/ErisPulse/Core/lifecycle.pyi +92 -0
  63. erispulse-2.3.3/stubs/ErisPulse/Core/logger.pyi +168 -0
  64. erispulse-2.3.3/stubs/ErisPulse/Core/module.pyi +178 -0
  65. erispulse-2.3.3/stubs/ErisPulse/Core/router.pyi +120 -0
  66. erispulse-2.3.3/stubs/ErisPulse/Core/storage.pyi +273 -0
  67. erispulse-2.3.3/stubs/ErisPulse/Core/ux.pyi +94 -0
  68. erispulse-2.3.3/stubs/ErisPulse/__init__.pyi +310 -0
  69. erispulse-2.3.3/stubs/ErisPulse/__main__.pyi +24 -0
  70. erispulse-2.3.3/stubs/ErisPulse/sdk_protocol.pyi +100 -0
  71. erispulse-2.3.3/stubs/ErisPulse/utils/__init__.pyi +16 -0
  72. erispulse-2.3.3/stubs/ErisPulse/utils/cli.pyi +145 -0
  73. erispulse-2.3.3/stubs/ErisPulse/utils/console.pyi +20 -0
  74. erispulse-2.3.3/stubs/ErisPulse/utils/package_manager.pyi +224 -0
  75. erispulse-2.3.3/stubs/ErisPulse/utils/reload_handler.pyi +64 -0
  76. erispulse-2.3.1/.github/ISSUE_TEMPLATE/config.yml +0 -5
  77. erispulse-2.3.1/.github/ISSUE_TEMPLATE/module_submission.md +0 -38
  78. erispulse-2.3.1/.github/PULL_REQUEST_TEMPLATE.md +0 -22
  79. erispulse-2.3.1/.github/assets/docs/install_pip.gif +0 -0
  80. erispulse-2.3.1/.github/assets/erispulse_logo.png +0 -0
  81. erispulse-2.3.1/.github/scripts/update_packages.py +0 -125
  82. erispulse-2.3.1/.github/tools/merge_md.py +0 -424
  83. erispulse-2.3.1/.github/tools/update-api-docs.py +0 -609
  84. erispulse-2.3.1/.github/workflows/auto-tag-release.yml +0 -95
  85. erispulse-2.3.1/.github/workflows/auto-update-packages.yml +0 -84
  86. erispulse-2.3.1/.github/workflows/code-quality-check.yml +0 -86
  87. erispulse-2.3.1/.github/workflows/pypi-publish.yml +0 -91
  88. erispulse-2.3.1/.python-version +0 -1
  89. erispulse-2.3.1/CHANGELOG.md +0 -651
  90. erispulse-2.3.1/CODE_OF_CONDUCT.md +0 -54
  91. erispulse-2.3.1/CONTRIBUTING.md +0 -62
  92. erispulse-2.3.1/SECURITY.md +0 -25
  93. erispulse-2.3.1/devs/test.py +0 -396
  94. erispulse-2.3.1/devs/test_adapter.py +0 -225
  95. erispulse-2.3.1/devs/test_cmd.py +0 -419
  96. erispulse-2.3.1/devs/test_event.py +0 -100
  97. erispulse-2.3.1/devs/test_files/test.docx +0 -0
  98. erispulse-2.3.1/devs/test_files/test.jpg +0 -0
  99. erispulse-2.3.1/devs/test_files/test.mp4 +0 -0
  100. erispulse-2.3.1/docs/README.md +0 -48
  101. erispulse-2.3.1/docs/ai/AIDocs/ErisPulse-AdapterDev.md +0 -7285
  102. erispulse-2.3.1/docs/ai/AIDocs/ErisPulse-Full.md +0 -7847
  103. erispulse-2.3.1/docs/ai/AIDocs/ErisPulse-ModuleDev.md +0 -3279
  104. erispulse-2.3.1/docs/ai/README.md +0 -25
  105. erispulse-2.3.1/docs/ai/module-generation.md +0 -65
  106. erispulse-2.3.1/docs/api/ErisPulse/Core/Bases/__init__.md +0 -16
  107. erispulse-2.3.1/docs/api/ErisPulse/Core/Bases/adapter.md +0 -145
  108. erispulse-2.3.1/docs/api/ErisPulse/Core/Bases/module.md +0 -60
  109. erispulse-2.3.1/docs/api/ErisPulse/Core/Event/__init__.md +0 -36
  110. erispulse-2.3.1/docs/api/ErisPulse/Core/Event/base.md +0 -88
  111. erispulse-2.3.1/docs/api/ErisPulse/Core/Event/command.md +0 -165
  112. erispulse-2.3.1/docs/api/ErisPulse/Core/Event/exceptions.md +0 -46
  113. erispulse-2.3.1/docs/api/ErisPulse/Core/Event/message.md +0 -112
  114. erispulse-2.3.1/docs/api/ErisPulse/Core/Event/meta.md +0 -111
  115. erispulse-2.3.1/docs/api/ErisPulse/Core/Event/notice.md +0 -129
  116. erispulse-2.3.1/docs/api/ErisPulse/Core/Event/request.md +0 -93
  117. erispulse-2.3.1/docs/api/ErisPulse/Core/_self_config.md +0 -68
  118. erispulse-2.3.1/docs/api/ErisPulse/Core/adapter.md +0 -280
  119. erispulse-2.3.1/docs/api/ErisPulse/Core/config.md +0 -82
  120. erispulse-2.3.1/docs/api/ErisPulse/Core/exceptions.md +0 -70
  121. erispulse-2.3.1/docs/api/ErisPulse/Core/lifecycle.md +0 -101
  122. erispulse-2.3.1/docs/api/ErisPulse/Core/logger.md +0 -150
  123. erispulse-2.3.1/docs/api/ErisPulse/Core/module.md +0 -229
  124. erispulse-2.3.1/docs/api/ErisPulse/Core/router.md +0 -130
  125. erispulse-2.3.1/docs/api/ErisPulse/Core/storage.md +0 -363
  126. erispulse-2.3.1/docs/api/ErisPulse/Core/ux.md +0 -101
  127. erispulse-2.3.1/docs/api/ErisPulse/__init__.md +0 -356
  128. erispulse-2.3.1/docs/api/ErisPulse/__main__.md +0 -30
  129. erispulse-2.3.1/docs/api/ErisPulse/utils/__init__.md +0 -16
  130. erispulse-2.3.1/docs/api/ErisPulse/utils/cli.md +0 -157
  131. erispulse-2.3.1/docs/api/ErisPulse/utils/package_manager.md +0 -239
  132. erispulse-2.3.1/docs/api/ErisPulse/utils/reload_handler.md +0 -69
  133. erispulse-2.3.1/docs/core/README.md +0 -22
  134. erispulse-2.3.1/docs/core/adapters.md +0 -107
  135. erispulse-2.3.1/docs/core/best-practices.md +0 -326
  136. erispulse-2.3.1/docs/core/cli.md +0 -78
  137. erispulse-2.3.1/docs/core/concepts.md +0 -38
  138. erispulse-2.3.1/docs/core/event-system.md +0 -597
  139. erispulse-2.3.1/docs/core/lazy-loading.md +0 -261
  140. erispulse-2.3.1/docs/core/modules.md +0 -659
  141. erispulse-2.3.1/docs/core/router.md +0 -535
  142. erispulse-2.3.1/docs/core/self-config.md +0 -188
  143. erispulse-2.3.1/docs/development/README.md +0 -44
  144. erispulse-2.3.1/docs/development/adapter.md +0 -454
  145. erispulse-2.3.1/docs/development/cli.md +0 -88
  146. erispulse-2.3.1/docs/development/module.md +0 -339
  147. erispulse-2.3.1/docs/platform-features/README.md +0 -219
  148. erispulse-2.3.1/docs/platform-features/email.md +0 -138
  149. erispulse-2.3.1/docs/platform-features/maintain-notes.md +0 -144
  150. erispulse-2.3.1/docs/platform-features/onebot11.md +0 -167
  151. erispulse-2.3.1/docs/platform-features/telegram.md +0 -139
  152. erispulse-2.3.1/docs/platform-features/yunhu.md +0 -153
  153. erispulse-2.3.1/docs/quick-start.md +0 -149
  154. erispulse-2.3.1/docs/standards/README.md +0 -19
  155. erispulse-2.3.1/docs/standards/api-response.md +0 -109
  156. erispulse-2.3.1/docs/standards/event-conversion.md +0 -194
  157. erispulse-2.3.1/docs/styleguide/README.md +0 -5
  158. erispulse-2.3.1/docs/styleguide/docstring_spec.md +0 -95
  159. erispulse-2.3.1/examples/example-adapter/LICENSE +0 -21
  160. erispulse-2.3.1/examples/example-adapter/MyAdapter/Converter.py +0 -38
  161. erispulse-2.3.1/examples/example-adapter/MyAdapter/Core.py +0 -141
  162. erispulse-2.3.1/examples/example-adapter/MyAdapter/__init__.py +0 -7
  163. erispulse-2.3.1/examples/example-adapter/README.md +0 -0
  164. erispulse-2.3.1/examples/example-adapter/pyproject.toml +0 -17
  165. erispulse-2.3.1/examples/example-cli-module/LICENSE +0 -21
  166. erispulse-2.3.1/examples/example-cli-module/README.md +0 -0
  167. erispulse-2.3.1/examples/example-cli-module/my_cli_module/__init__.py +0 -1
  168. erispulse-2.3.1/examples/example-cli-module/my_cli_module/cli.py +0 -61
  169. erispulse-2.3.1/examples/example-cli-module/pyproject.toml +0 -18
  170. erispulse-2.3.1/examples/example-module/LICENSE +0 -21
  171. erispulse-2.3.1/examples/example-module/MyModule/Core.py +0 -166
  172. erispulse-2.3.1/examples/example-module/MyModule/__init__.py +0 -1
  173. erispulse-2.3.1/examples/example-module/README.md +0 -29
  174. erispulse-2.3.1/examples/example-module/pyproject.toml +0 -17
  175. erispulse-2.3.1/packages.json +0 -246
  176. erispulse-2.3.1/scripts/install/install.ps1 +0 -339
  177. erispulse-2.3.1/scripts/install/install.sh +0 -271
  178. {erispulse-2.3.1 → erispulse-2.3.3}/.gitignore +0 -0
  179. {erispulse-2.3.1 → erispulse-2.3.3}/LICENSE +0 -0
  180. {erispulse-2.3.1 → erispulse-2.3.3}/README.md +0 -0
  181. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/Bases/__init__.py +0 -0
  182. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/Bases/module.py +0 -0
  183. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/Event/exceptions.py +0 -0
  184. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/Event/message.py +0 -0
  185. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/Event/meta.py +0 -0
  186. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/Event/notice.py +0 -0
  187. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/Event/request.py +0 -0
  188. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/_self_config.py +0 -0
  189. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/adapter.py +0 -0
  190. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/config.py +0 -0
  191. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/exceptions.py +0 -0
  192. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/logger.py +0 -0
  193. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/module.py +0 -0
  194. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/router.py +0 -0
  195. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/storage.py +0 -0
  196. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/Core/ux.py +0 -0
  197. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/utils/__init__.py +0 -0
  198. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/utils/console.py +0 -0
  199. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/utils/package_manager.py +0 -0
  200. {erispulse-2.3.1 → erispulse-2.3.3}/src/ErisPulse/utils/reload_handler.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ErisPulse
3
- Version: 2.3.1
3
+ Version: 2.3.3
4
4
  Summary: ErisPulse 是一个模块化、可扩展的异步 Python SDK 框架,主要用于构建高效、可维护的机器人应用程序。
5
5
  Author-email: "艾莉丝·格雷拉特(WSu2059)" <wsu2059@qq.com>
6
6
  License: MIT License
@@ -57,9 +57,7 @@ Requires-Dist: aiohttp
57
57
  Requires-Dist: colorama
58
58
  Requires-Dist: fastapi>=0.116.1
59
59
  Requires-Dist: hypercorn>=0.14.0
60
- Requires-Dist: keyboard
61
60
  Requires-Dist: packaging>=25.0
62
- Requires-Dist: pip
63
61
  Requires-Dist: pydantic>=2.10.6
64
62
  Requires-Dist: python-multipart>=0.0.20
65
63
  Requires-Dist: rich
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "ErisPulse"
7
- version = "2.3.1"
7
+ version = "2.3.3"
8
8
  description = "ErisPulse 是一个模块化、可扩展的异步 Python SDK 框架,主要用于构建高效、可维护的机器人应用程序。"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -29,10 +29,8 @@ classifiers = [
29
29
  ]
30
30
 
31
31
  dependencies = [
32
- "pip",
33
32
  "rich",
34
33
  "colorama",
35
- "keyboard",
36
34
  "aiohttp",
37
35
  "watchdog",
38
36
  "toml",
@@ -53,6 +51,18 @@ epsdk-cli = "ErisPulse.__main__:main"
53
51
  [tool.hatch]
54
52
  project.root = "src"
55
53
 
54
+ [tool.hatch.build.targets.wheel]
55
+ packages = ["src/ErisPulse"]
56
+
57
+ [tool.hatch.build.targets.wheel.shared-data]
58
+ "stubs/ErisPulse" = "ErisPulse-stubs/ErisPulse"
59
+
60
+ [tool.hatch.build.targets.sdist]
61
+ include = [
62
+ "/src/ErisPulse",
63
+ "/stubs/ErisPulse",
64
+ ]
65
+
56
66
  [tool.ruff]
57
67
  target-version = "py310"
58
68
 
@@ -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,52 @@
1
+ # type: ignore
2
+ #
3
+ # Auto-generated type stub for module.py
4
+ # DO NOT EDIT MANUALLY - Generated by generate-type-stubs.py
5
+ #
6
+
7
+ """
8
+ ErisPulse 模块基础模块
9
+
10
+ 提供模块基类定义和标准接口
11
+ """
12
+
13
+ class BaseModule:
14
+ """
15
+ 模块基类
16
+
17
+ 提供模块加载和卸载的标准接口
18
+ """
19
+ def should_eager_load() -> bool:
20
+ """
21
+ 模块是否应该在启动时加载
22
+ 默认为False(即懒加载)
23
+
24
+ :return: 是否应该在启动时加载
25
+ """
26
+ ...
27
+ async def on_load(self: object, event: dict) -> bool:
28
+ """
29
+ 当模块被加载时调用
30
+
31
+ :param event: 事件内容
32
+ :return: 处理结果
33
+
34
+ {!--< tips >!--}
35
+ 其中,event事件内容为:
36
+ `{ "module_name": "模块名" }`
37
+ {!--< /tips >!--}
38
+ """
39
+ ...
40
+ async def on_unload(self: object, event: dict) -> bool:
41
+ """
42
+ 当模块被卸载时调用
43
+
44
+ :param event: 事件内容
45
+ :return: 处理结果
46
+
47
+ {!--< tips >!--}
48
+ 其中,event事件内容为:
49
+ `{ "module_name": "模块名" }`
50
+ {!--< /tips >!--}
51
+ """
52
+ ...
@@ -15,6 +15,7 @@ from .message import message
15
15
  from .notice import notice
16
16
  from .request import request
17
17
  from .meta import meta
18
+ from .wrapper import Event
18
19
  from . import exceptions
19
20
  from .. import config
20
21
 
@@ -61,5 +62,6 @@ __all__ = [
61
62
  "notice",
62
63
  "request",
63
64
  "meta",
65
+ "Event",
64
66
  "exceptions"
65
- ]
67
+ ]
@@ -0,0 +1,26 @@
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
+ {!--< tips >!--}
13
+ 1. 所有事件处理都基于OneBot12标准事件格式
14
+ 2. 通过装饰器方式注册事件处理器
15
+ 3. 支持优先级和条件过滤
16
+ {!--< /tips >!--}
17
+ """
18
+
19
+ from .command import command
20
+ from .message import message
21
+ from .notice import notice
22
+ from .request import request
23
+ from .meta import meta
24
+ from .wrapper import Event
25
+ from . import exceptions
26
+ from .. import config
@@ -12,6 +12,7 @@ ErisPulse 事件处理基础模块
12
12
  from .. import adapter, logger
13
13
  from typing import Callable, Any, Dict, List
14
14
  import asyncio
15
+ from .wrapper import Event
15
16
 
16
17
  class BaseEventHandler:
17
18
  """
@@ -94,6 +95,10 @@ class BaseEventHandler:
94
95
 
95
96
  :param event: 事件数据
96
97
  """
98
+ # 如果还不是Event对象,则转换为Event对象
99
+ if not isinstance(event, Event):
100
+ event = Event(event)
101
+
97
102
  # 执行处理器
98
103
  for handler_info in self.handlers:
99
104
  condition = handler_info.get("condition")
@@ -0,0 +1,62 @@
1
+ # type: ignore
2
+ #
3
+ # Auto-generated type stub for base.py
4
+ # DO NOT EDIT MANUALLY - Generated by generate-type-stubs.py
5
+ #
6
+
7
+ """
8
+ ErisPulse 事件处理基础模块
9
+
10
+ 提供事件处理的核心功能,包括事件注册和处理
11
+
12
+ {!--< tips >!--}
13
+ 1. 所有事件处理都基于OneBot12标准事件格式
14
+ 2. 通过适配器系统进行事件分发和接收
15
+ {!--< /tips >!--}
16
+ """
17
+
18
+ from .. import adapter, logger
19
+ from typing import Callable, Any, Dict, List
20
+ import asyncio
21
+ from .wrapper import Event
22
+
23
+ class BaseEventHandler:
24
+ """
25
+ 基础事件处理器
26
+
27
+ 提供事件处理的基本功能,包括处理器注册和注销
28
+ """
29
+ def __init__(self: None, event_type: str, module_name: str = ...) -> ...:
30
+ """
31
+ 初始化事件处理器
32
+
33
+ :param event_type: 事件类型
34
+ :param module_name: 模块名称
35
+ """
36
+ ...
37
+ def register(self: object, handler: Callable, priority: int = ..., condition: Callable = ...) -> ...:
38
+ """
39
+ 注册事件处理器
40
+
41
+ :param handler: 事件处理器函数
42
+ :param priority: 处理器优先级,数值越小优先级越高
43
+ :param condition: 处理器条件函数,返回True时才会执行处理器
44
+ """
45
+ ...
46
+ def unregister(self: object, handler: Callable) -> bool:
47
+ """
48
+ 注销事件处理器
49
+
50
+ :param handler: 要注销的事件处理器
51
+ :return: 是否成功注销
52
+ """
53
+ ...
54
+ def __call__(self: object, priority: int = ..., condition: Callable = ...) -> ...:
55
+ """
56
+ 装饰器方式注册事件处理器
57
+
58
+ :param priority: 处理器优先级
59
+ :param condition: 处理器条件函数
60
+ :return: 装饰器函数
61
+ """
62
+ ...
@@ -240,35 +240,80 @@ class CommandHandler:
240
240
  if event.get("type") != "message":
241
241
  return
242
242
 
243
+ async def _process_text_for_command(event: Dict[str, Any], text: str) -> bool:
244
+ """
245
+ 处理文本内容,尝试匹配并执行命令
246
+
247
+ {!--< internal-use >!--}
248
+ 内部使用的方法,用于处理文本内容并尝试执行命令
249
+
250
+ :param event: 消息事件数据
251
+ :param text: 要处理的文本内容
252
+ :return: 是否成功执行命令
253
+ """
254
+ if not text:
255
+ return False
256
+
257
+ # 处理大小写敏感性
258
+ check_text = text if self.case_sensitive else text.lower()
259
+ prefix = self.prefix if self.case_sensitive else self.prefix.lower()
260
+
261
+ # 检查前缀
262
+ has_prefix = check_text.startswith(prefix)
263
+ has_space_prefix = self.allow_space_prefix and check_text.startswith(prefix + " ")
264
+
265
+ if not has_prefix and not has_space_prefix:
266
+ return False
267
+
268
+ # 尝试执行命令
269
+ return await self._try_execute_command(event, text, check_text)
270
+
271
+ # 从 message 列表和 alt_message 中提取文本内容
243
272
  message_segments = event.get("message", [])
244
- text_content = ""
273
+ message_text = ""
245
274
  for segment in message_segments:
246
275
  if segment.get("type") == "text":
247
- text_content = segment.get("data", {}).get("text", "")
276
+ message_text = segment.get("data", {}).get("text", "")
248
277
  break
249
278
 
250
- if not text_content:
251
- return
279
+ alt_message = event.get("alt_message", "")
252
280
 
253
- # 处理大小写敏感性
254
- check_text = text_content if self.case_sensitive else text_content.lower()
255
- prefix = self.prefix if self.case_sensitive else self.prefix.lower()
281
+ # 尝试使用 message 列表的内容
282
+ if message_text:
283
+ command_matched = await _process_text_for_command(event, message_text)
284
+ if command_matched:
285
+ return
256
286
 
257
- # 检查前缀
258
- if not check_text.startswith(prefix):
259
- # 检查是否允许空格前缀 (例如: "/ command")
260
- if self.allow_space_prefix and check_text.startswith(prefix + " "):
261
- pass
262
- else:
263
- # 检查是否是等待回复的消息
264
- await self._check_pending_reply(event)
287
+ # 尝试使用 alt_message
288
+ if alt_message and alt_message != message_text:
289
+ command_matched = await _process_text_for_command(event, alt_message)
290
+ if command_matched:
265
291
  return
266
292
 
293
+ # 如果都没有匹配,检查是否是等待回复的消息
294
+ await self._check_pending_reply(event)
295
+ return
296
+
297
+
298
+ async def _try_execute_command(self, event: Dict[str, Any], original_text: str, check_text: str) -> bool:
299
+ """
300
+ 尝试执行命令
301
+
302
+ {!--< internal-use >!--}
303
+ 内部使用的方法,用于尝试解析和执行命令
304
+
305
+ :param event: 消息事件数据
306
+ :param original_text: 原始文本内容
307
+ :param check_text: 用于检查的文本内容(可能已转换为小写)
308
+ :return: 是否成功执行命令
309
+ """
310
+ prefix = self.prefix if self.case_sensitive else self.prefix.lower()
311
+
267
312
  # 解析命令和参数
268
313
  command_text = check_text[len(prefix):].strip()
269
314
  parts = command_text.split()
270
315
  if not parts:
271
- return
316
+ return False
272
317
 
273
318
  cmd_name = parts[0]
274
319
  args = parts[1:] if len(parts) > 1 else []
@@ -323,6 +368,10 @@ class CommandHandler:
323
368
  except Exception as e:
324
369
  logger.error(f"命令执行错误: {e}")
325
370
  await self._send_command_error(event, str(e))
371
+
372
+ return True
373
+
374
+ return False
326
375
 
327
376
  async def _check_pending_reply(self, event: Dict[str, Any]):
328
377
  """
@@ -486,4 +535,4 @@ class CommandHandler:
486
535
  help_lines.append(f" {self.prefix}{cmd_name} - {help_text}")
487
536
  return "\n".join(help_lines)
488
537
 
489
- command = CommandHandler()
538
+ command = CommandHandler()
@@ -0,0 +1,113 @@
1
+ # type: ignore
2
+ #
3
+ # Auto-generated type stub for command.py
4
+ # DO NOT EDIT MANUALLY - Generated by generate-type-stubs.py
5
+ #
6
+
7
+ """
8
+ ErisPulse 命令处理模块
9
+
10
+ 提供基于装饰器的命令注册和处理功能
11
+
12
+ {!--< tips >!--}
13
+ 1. 支持命令别名和命令组
14
+ 2. 支持命令权限控制
15
+ 3. 支持命令帮助系统
16
+ 4. 支持等待用户回复交互
17
+ {!--< /tips >!--}
18
+ """
19
+
20
+ from .base import BaseEventHandler
21
+ from .. import adapter, config, logger
22
+ from typing import Callable, Union, List, Dict, Any, Optional, Awaitable
23
+ import asyncio
24
+
25
+ class CommandHandler:
26
+ """
27
+ 命令处理器
28
+
29
+ 提供命令注册、处理和管理功能
30
+ """
31
+ def __init__(self: None) -> ...:
32
+ ...
33
+ def __call__(self: object, name: Union[(str, List[str])] = ..., aliases: List[str] = ..., group: str = ..., priority: int = ..., permission: Callable = ..., help: str = ..., usage: str = ..., hidden: bool = ...) -> ...:
34
+ """
35
+ 命令装饰器
36
+
37
+ :param name: 命令名称,可以是字符串或字符串列表
38
+ :param aliases: 命令别名列表
39
+ :param group: 命令组名称
40
+ :param priority: 处理器优先级
41
+ :param permission: 权限检查函数,返回True时允许执行命令
42
+ :param help: 命令帮助信息
43
+ :param usage: 命令使用方法
44
+ :param hidden: 是否在帮助中隐藏命令
45
+ :return: 装饰器函数
46
+ """
47
+ ...
48
+ def unregister(self: object, handler: Callable) -> bool:
49
+ """
50
+ 注销命令处理器
51
+
52
+ :param handler: 要注销的命令处理器
53
+ :return: 是否成功注销
54
+ """
55
+ ...
56
+ async def wait_reply(self: object, event: Dict[(str, Any)], prompt: str = ..., timeout: float = ..., callback: Callable[([Dict[(str, Any)]], Awaitable[Any])] = ..., validator: Callable[([Dict[(str, Any)]], bool)] = ...) -> Optional[Dict[(str, Any)]]:
57
+ """
58
+ 等待用户回复
59
+
60
+ :param event: 原始事件数据
61
+ :param prompt: 提示消息,如果提供会发送给用户
62
+ :param timeout: 等待超时时间(秒)
63
+ :param callback: 回调函数,当收到回复时执行
64
+ :param validator: 验证函数,用于验证回复是否有效
65
+ :return: 用户回复的事件数据,如果超时则返回None
66
+ """
67
+ ...
68
+ async def _check_pending_reply(self: object, event: Dict[(str, Any)]) -> ...:
69
+ """
70
+ 检查是否是等待回复的消息
71
+
72
+ :param event: 消息事件数据
73
+ """
74
+ ...
75
+ def get_command(self: object, name: str) -> Optional[Dict]:
76
+ """
77
+ 获取命令信息
78
+
79
+ :param name: 命令名称
80
+ :return: 命令信息字典,如果不存在则返回None
81
+ """
82
+ ...
83
+ def get_commands(self: object) -> Dict[(str, Dict)]:
84
+ """
85
+ 获取所有命令
86
+
87
+ :return: 命令信息字典
88
+ """
89
+ ...
90
+ def get_group_commands(self: object, group: str) -> List[str]:
91
+ """
92
+ 获取命令组中的命令
93
+
94
+ :param group: 命令组名称
95
+ :return: 命令名称列表
96
+ """
97
+ ...
98
+ def get_visible_commands(self: object) -> Dict[(str, Dict)]:
99
+ """
100
+ 获取所有可见命令(非隐藏命令)
101
+
102
+ :return: 可见命令信息字典
103
+ """
104
+ ...
105
+ def help(self: object, command_name: str = ..., show_hidden: bool = ...) -> str:
106
+ """
107
+ 生成帮助信息
108
+
109
+ :param command_name: 命令名称,如果为None则生成所有命令的帮助
110
+ :param show_hidden: 是否显示隐藏命令
111
+ :return: 帮助信息字符串
112
+ """
113
+ ...
@@ -0,0 +1,43 @@
1
+ # type: ignore
2
+ #
3
+ # Auto-generated type stub for exceptions.py
4
+ # DO NOT EDIT MANUALLY - Generated by generate-type-stubs.py
5
+ #
6
+
7
+ """
8
+ ErisPulse 事件系统异常处理模块
9
+
10
+ 提供事件系统中可能发生的各种异常类型定义
11
+ """
12
+
13
+ class EventException(Exception):
14
+ """
15
+ 事件系统基础异常
16
+
17
+ 所有事件系统相关异常的基类
18
+ """
19
+ ...
20
+
21
+ class CommandException(EventException):
22
+ """
23
+ 命令处理异常
24
+
25
+ 当命令处理过程中发生错误时抛出
26
+ """
27
+ ...
28
+
29
+ class EventHandlerException(EventException):
30
+ """
31
+ 事件处理器异常
32
+
33
+ 当事件处理器执行过程中发生错误时抛出
34
+ """
35
+ ...
36
+
37
+ class EventNotFoundException(EventException):
38
+ """
39
+ 事件未找到异常
40
+
41
+ 当尝试获取不存在的事件处理器时抛出
42
+ """
43
+ ...