ErisPulse 2.1.15.dev3__tar.gz → 2.2.0.dev0__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.
- erispulse-2.2.0.dev0/.github/tools/merge_md.py +226 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/.github/tools/update-api-docs.py +25 -34
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/.github/workflows/auto-tag-release.yml +6 -5
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/.gitignore +1 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/LICENSE +7 -1
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/PKG-INFO +7 -1
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/devs/test.py +16 -16
- erispulse-2.2.0.dev0/devs/test_cmd.py +124 -0
- erispulse-2.2.0.dev0/devs/test_event.py +100 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/AIDocs/ErisPulse-AdapterDev.md +1469 -394
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/AIDocs/ErisPulse-Core.md +2360 -747
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/AIDocs/ErisPulse-Full.md +1390 -406
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/AIDocs/ErisPulse-ModuleDev.md +1459 -388
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/CHANGELOG.md +39 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/Development/Module.md +0 -2
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/UseCore.md +172 -1
- erispulse-2.2.0.dev0/docs/api/ErisPulse/Core/Event/__init__.md +25 -0
- erispulse-2.2.0.dev0/docs/api/ErisPulse/Core/Event/base.md +84 -0
- erispulse-2.2.0.dev0/docs/api/ErisPulse/Core/Event/cmd.md +93 -0
- erispulse-2.2.0.dev0/docs/api/ErisPulse/Core/Event/exceptions.md +46 -0
- erispulse-2.2.0.dev0/docs/api/ErisPulse/Core/Event/manager.md +96 -0
- erispulse-2.2.0.dev0/docs/api/ErisPulse/Core/Event/message.md +69 -0
- erispulse-2.2.0.dev0/docs/api/ErisPulse/Core/Event/meta.md +69 -0
- erispulse-2.2.0.dev0/docs/api/ErisPulse/Core/Event/notice.md +78 -0
- erispulse-2.2.0.dev0/docs/api/ErisPulse/Core/Event/request.md +60 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/api/ErisPulse/Core/adapter.md +16 -16
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/api/ErisPulse/Core/config.md +3 -3
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/api/ErisPulse/Core/env.md +3 -3
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/api/ErisPulse/Core/erispulse_config.md +4 -4
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/api/ErisPulse/Core/exceptions.md +4 -4
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/api/ErisPulse/Core/logger.md +6 -6
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/api/ErisPulse/Core/mods.md +5 -5
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/api/ErisPulse/Core/router.md +7 -7
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/api/ErisPulse/Core/storage.md +5 -5
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/api/ErisPulse/__init__.md +15 -17
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/api/ErisPulse/__main__.md +148 -20
- erispulse-2.2.0.dev0/examples/example-module/MyModule/Core.py +91 -0
- erispulse-2.2.0.dev0/examples/example-module/README.md +29 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/packages.json +33 -5
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/pyproject.toml +1 -1
- erispulse-2.2.0.dev0/src/ErisPulse/Core/Event/__init__.py +49 -0
- erispulse-2.2.0.dev0/src/ErisPulse/Core/Event/base.py +118 -0
- erispulse-2.2.0.dev0/src/ErisPulse/Core/Event/cmd.py +212 -0
- erispulse-2.2.0.dev0/src/ErisPulse/Core/Event/exceptions.py +37 -0
- erispulse-2.2.0.dev0/src/ErisPulse/Core/Event/manager.py +128 -0
- erispulse-2.2.0.dev0/src/ErisPulse/Core/Event/message.py +91 -0
- erispulse-2.2.0.dev0/src/ErisPulse/Core/Event/meta.py +82 -0
- erispulse-2.2.0.dev0/src/ErisPulse/Core/Event/notice.py +97 -0
- erispulse-2.2.0.dev0/src/ErisPulse/Core/Event/request.py +67 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/src/ErisPulse/Core/__init__.py +4 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/src/ErisPulse/__init__.py +3 -1
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/src/ErisPulse/__main__.py +110 -43
- erispulse-2.1.15.dev3/.github/tools/merge_md.py +0 -141
- erispulse-2.1.15.dev3/examples/example-module/MyModule/Core.py +0 -31
- erispulse-2.1.15.dev3/examples/example-module/README.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/.github/ISSUE_TEMPLATE/module_submission.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/.github/assets/docs/install_pip.gif +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/.github/assets/erispulse_logo.png +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/.github/scripts/update_packages.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/.github/workflows/auto-update-packages.yml +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/.github/workflows/pypi-publish.yml +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/.python-version +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/.worker/worker.js +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/CODE_OF_CONDUCT.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/README.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/SECURITY.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/devs/test_adapter.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/devs/test_files/test.docx +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/devs/test_files/test.jpg +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/devs/test_files/test.mp4 +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/AIModuleGeneration.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/AdapterStandards/APIResponse.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/AdapterStandards/EventConversion.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/AdapterStandards/README.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/CLI.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/Development/Adapter.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/Development/CLI.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/Development/README.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/PlatformFeatures.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/StyleGuide/DocstringSpec.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/StyleGuide/README.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/docs/quick-start.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/examples/example-adapter/LICENSE +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/examples/example-adapter/MyAdapter/Core.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/examples/example-adapter/MyAdapter/__init__.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/examples/example-adapter/README.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/examples/example-adapter/pyproject.toml +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/examples/example-cli-module/LICENSE +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/examples/example-cli-module/README.md +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/examples/example-cli-module/my_cli_module/__init__.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/examples/example-cli-module/my_cli_module/cli.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/examples/example-cli-module/pyproject.toml +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/examples/example-module/LICENSE +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/examples/example-module/MyModule/__init__.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/examples/example-module/pyproject.toml +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/scripts/install/install.ps1 +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/scripts/install/install.sh +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/src/ErisPulse/Core/adapter.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/src/ErisPulse/Core/config.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/src/ErisPulse/Core/env.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/src/ErisPulse/Core/erispulse_config.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/src/ErisPulse/Core/exceptions.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/src/ErisPulse/Core/logger.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/src/ErisPulse/Core/mods.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/src/ErisPulse/Core/router.py +0 -0
- {erispulse-2.1.15.dev3 → erispulse-2.2.0.dev0}/src/ErisPulse/Core/storage.py +0 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
|
|
4
|
+
def merge_md_files(output_file, files_to_merge, title="文档合集"):
|
|
5
|
+
"""
|
|
6
|
+
合并多个Markdown文件
|
|
7
|
+
|
|
8
|
+
:param output_file: 输出文件路径
|
|
9
|
+
:param files_to_merge: 要合并的文件列表,包含文件路径和描述
|
|
10
|
+
:param title: 文档标题
|
|
11
|
+
"""
|
|
12
|
+
with open(output_file, 'w', encoding='utf-8') as outfile:
|
|
13
|
+
# 写入头部说明
|
|
14
|
+
outfile.write(f"# ErisPulse {title}\n\n")
|
|
15
|
+
outfile.write(f"**生成时间**: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n")
|
|
16
|
+
outfile.write("本文件由多个开发文档合并而成,用于辅助开发者理解 ErisPulse 的相关功能。\n\n")
|
|
17
|
+
|
|
18
|
+
# 写入目录
|
|
19
|
+
outfile.write("## 目录\n\n")
|
|
20
|
+
for i, file_info in enumerate(files_to_merge, 1):
|
|
21
|
+
filename = os.path.basename(file_info['path'])
|
|
22
|
+
outfile.write(f"{i}. [{file_info.get('description', filename)}](#{filename.replace('.', '').replace(' ', '-')})\n")
|
|
23
|
+
outfile.write("\n")
|
|
24
|
+
|
|
25
|
+
outfile.write("## 各文件对应内容说明\n\n")
|
|
26
|
+
outfile.write("| 文件名 | 作用 |\n")
|
|
27
|
+
outfile.write("|--------|------|\n")
|
|
28
|
+
|
|
29
|
+
# 写入文件说明
|
|
30
|
+
for file_info in files_to_merge:
|
|
31
|
+
filename = os.path.basename(file_info['path'])
|
|
32
|
+
outfile.write(f"| [{filename}](#{filename.replace('.', '').replace(' ', '-')}) | {file_info.get('description', '')} |\n")
|
|
33
|
+
|
|
34
|
+
outfile.write("\n---\n\n")
|
|
35
|
+
|
|
36
|
+
# 合并文件内容
|
|
37
|
+
for file_info in files_to_merge:
|
|
38
|
+
file_path = file_info['path']
|
|
39
|
+
if os.path.exists(file_path):
|
|
40
|
+
filename = os.path.basename(file_path)
|
|
41
|
+
outfile.write(f"<a id=\"{filename.replace('.', '').replace(' ', '-')}\"></a>\n")
|
|
42
|
+
outfile.write(f"## {file_info.get('description', filename)}\n\n")
|
|
43
|
+
|
|
44
|
+
with open(file_path, 'r', encoding='utf-8') as infile:
|
|
45
|
+
content = infile.read()
|
|
46
|
+
outfile.write(content)
|
|
47
|
+
outfile.write(f"\n\n---\n\n")
|
|
48
|
+
else:
|
|
49
|
+
print(f"文件不存在,跳过: {file_path}")
|
|
50
|
+
|
|
51
|
+
def merge_api_docs(api_dir, output_file):
|
|
52
|
+
"""
|
|
53
|
+
合并API文档
|
|
54
|
+
|
|
55
|
+
:param api_dir: API文档目录
|
|
56
|
+
:param output_file: 输出文件路径
|
|
57
|
+
"""
|
|
58
|
+
if not os.path.exists(api_dir):
|
|
59
|
+
print(f"API文档目录不存在: {api_dir}")
|
|
60
|
+
return
|
|
61
|
+
|
|
62
|
+
with open(output_file, 'a', encoding='utf-8') as outfile:
|
|
63
|
+
outfile.write("# API参考\n\n")
|
|
64
|
+
|
|
65
|
+
# 收集所有API文档文件
|
|
66
|
+
api_files = []
|
|
67
|
+
for root, _, files in os.walk(api_dir):
|
|
68
|
+
for file in files:
|
|
69
|
+
if file.endswith('.md'):
|
|
70
|
+
file_path = os.path.join(root, file)
|
|
71
|
+
api_files.append(file_path)
|
|
72
|
+
|
|
73
|
+
# 按路径排序以保持一致性
|
|
74
|
+
api_files.sort()
|
|
75
|
+
|
|
76
|
+
# 生成API文档目录
|
|
77
|
+
outfile.write("## API文档目录\n\n")
|
|
78
|
+
for file_path in api_files:
|
|
79
|
+
rel_path = os.path.relpath(file_path, api_dir)
|
|
80
|
+
anchor = rel_path.replace(os.sep, "_").replace(".md", "")
|
|
81
|
+
outfile.write(f"- [{rel_path}](#{anchor})\n")
|
|
82
|
+
outfile.write("\n---\n\n")
|
|
83
|
+
|
|
84
|
+
# 合并API文档内容
|
|
85
|
+
for file_path in api_files:
|
|
86
|
+
rel_path = os.path.relpath(file_path, api_dir)
|
|
87
|
+
anchor = rel_path.replace(os.sep, "_").replace(".md", "")
|
|
88
|
+
|
|
89
|
+
outfile.write(f"<a id=\"{anchor}\"></a>\n")
|
|
90
|
+
outfile.write(f"## {rel_path}\n\n")
|
|
91
|
+
|
|
92
|
+
try:
|
|
93
|
+
with open(file_path, 'r', encoding='utf-8') as infile:
|
|
94
|
+
content = infile.read()
|
|
95
|
+
# 移除原有标题,因为我们已经添加了
|
|
96
|
+
lines = content.split('\n')
|
|
97
|
+
if lines and lines[0].startswith('# '):
|
|
98
|
+
content = '\n'.join(lines[1:])
|
|
99
|
+
|
|
100
|
+
outfile.write(content)
|
|
101
|
+
outfile.write("\n\n")
|
|
102
|
+
except Exception as e:
|
|
103
|
+
outfile.write(f"无法读取文件 {file_path}: {str(e)}\n\n")
|
|
104
|
+
|
|
105
|
+
outfile.write("---\n")
|
|
106
|
+
|
|
107
|
+
def generate_full_document():
|
|
108
|
+
print("正在生成完整文档...")
|
|
109
|
+
|
|
110
|
+
# 要合并的文件
|
|
111
|
+
files_to_merge = [
|
|
112
|
+
{"path": "docs/quick-start.md", "description": "快速开始指南"},
|
|
113
|
+
{"path": "docs/UseCore.md", "description": "核心功能使用说明"},
|
|
114
|
+
{"path": "docs/PlatformFeatures.md", "description": "平台功能说明"},
|
|
115
|
+
{"path": "docs/Development/Module.md", "description": "模块开发指南"},
|
|
116
|
+
{"path": "docs/Development/Adapter.md", "description": "适配器开发指南"},
|
|
117
|
+
{"path": "docs/AdapterStandards/APIResponse.md", "description": "API响应标准"},
|
|
118
|
+
{"path": "docs/AdapterStandards/EventConversion.md", "description": "事件转换标准"},
|
|
119
|
+
]
|
|
120
|
+
|
|
121
|
+
# 过滤不存在的文件
|
|
122
|
+
existing_files = [f for f in files_to_merge if os.path.exists(f['path'])]
|
|
123
|
+
if len(existing_files) != len(files_to_merge):
|
|
124
|
+
print(f"警告: {len(files_to_merge) - len(existing_files)} 个文件不存在,已跳过")
|
|
125
|
+
|
|
126
|
+
output_file = "docs/AIDocs/ErisPulse-Full.md"
|
|
127
|
+
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
|
128
|
+
|
|
129
|
+
merge_md_files(output_file, existing_files, "完整开发文档")
|
|
130
|
+
merge_api_docs("docs/api", output_file)
|
|
131
|
+
|
|
132
|
+
print(f"完整文档生成完成,已保存到: {output_file}")
|
|
133
|
+
|
|
134
|
+
def generate_core_document():
|
|
135
|
+
print("正在生成核心功能文档...")
|
|
136
|
+
|
|
137
|
+
files_to_merge = [
|
|
138
|
+
{"path": "docs/quick-start.md", "description": "快速开始指南"},
|
|
139
|
+
{"path": "docs/UseCore.md", "description": "核心功能使用说明"},
|
|
140
|
+
{"path": "docs/PlatformFeatures.md", "description": "平台功能说明"},
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
# 过滤不存在的文件
|
|
144
|
+
existing_files = [f for f in files_to_merge if os.path.exists(f['path'])]
|
|
145
|
+
|
|
146
|
+
output_file = "docs/AIDocs/ErisPulse-Core.md"
|
|
147
|
+
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
|
148
|
+
|
|
149
|
+
merge_md_files(output_file, existing_files, "核心功能文档")
|
|
150
|
+
# 合并API文档
|
|
151
|
+
merge_api_docs("docs/api", output_file)
|
|
152
|
+
|
|
153
|
+
print(f"核心功能文档生成完成,已保存到: {output_file}")
|
|
154
|
+
|
|
155
|
+
def generate_dev_documents():
|
|
156
|
+
print("正在生成开发文档...")
|
|
157
|
+
|
|
158
|
+
# 模块开发文档
|
|
159
|
+
module_files = [
|
|
160
|
+
{"path": "docs/quick-start.md", "description": "快速开始指南"},
|
|
161
|
+
{"path": "docs/UseCore.md", "description": "核心功能使用说明"},
|
|
162
|
+
{"path": "docs/PlatformFeatures.md", "description": "平台支持的发送类型及差异性说明"},
|
|
163
|
+
{"path": "docs/Development/Module.md", "description": "模块开发指南"}
|
|
164
|
+
]
|
|
165
|
+
|
|
166
|
+
# 过滤不存在的文件
|
|
167
|
+
existing_module_files = [f for f in module_files if os.path.exists(f['path'])]
|
|
168
|
+
|
|
169
|
+
module_output = "docs/AIDocs/ErisPulse-ModuleDev.md"
|
|
170
|
+
os.makedirs(os.path.dirname(module_output), exist_ok=True)
|
|
171
|
+
merge_md_files(module_output, existing_module_files, "模块开发文档")
|
|
172
|
+
# 合并API文档
|
|
173
|
+
merge_api_docs("docs/api", module_output)
|
|
174
|
+
|
|
175
|
+
print(f"模块开发文档生成完成,已保存到: {module_output}")
|
|
176
|
+
|
|
177
|
+
# 适配器开发文档
|
|
178
|
+
adapter_files = [
|
|
179
|
+
{"path": "docs/quick-start.md", "description": "快速开始指南"},
|
|
180
|
+
{"path": "docs/UseCore.md", "description": "核心功能使用说明"},
|
|
181
|
+
{"path": "docs/Development/Adapter.md", "description": "适配器开发指南"},
|
|
182
|
+
{"path": "docs/AdapterStandards/APIResponse.md", "description": "API响应标准"},
|
|
183
|
+
{"path": "docs/AdapterStandards/EventConversion.md", "description": "事件转换标准"},
|
|
184
|
+
]
|
|
185
|
+
|
|
186
|
+
# 过滤不存在的文件
|
|
187
|
+
existing_adapter_files = [f for f in adapter_files if os.path.exists(f['path'])]
|
|
188
|
+
|
|
189
|
+
adapter_output = "docs/AIDocs/ErisPulse-AdapterDev.md"
|
|
190
|
+
os.makedirs(os.path.dirname(adapter_output), exist_ok=True)
|
|
191
|
+
merge_md_files(adapter_output, existing_adapter_files, "适配器开发文档")
|
|
192
|
+
# 合并API文档
|
|
193
|
+
merge_api_docs("docs/api", adapter_output)
|
|
194
|
+
|
|
195
|
+
print(f"适配器开发文档生成完成,已保存到: {adapter_output}")
|
|
196
|
+
|
|
197
|
+
def generate_custom_document(title, files, api_dirs, output_path):
|
|
198
|
+
"""
|
|
199
|
+
生成自定义文档
|
|
200
|
+
|
|
201
|
+
:param title: 文档标题
|
|
202
|
+
:param files: 要合并的文件列表
|
|
203
|
+
:param api_dirs: 要合并的API目录列表
|
|
204
|
+
:param output_path: 输出路径
|
|
205
|
+
"""
|
|
206
|
+
print(f"正在生成{title}...")
|
|
207
|
+
|
|
208
|
+
# 过滤不存在的文件
|
|
209
|
+
existing_files = [f for f in files if os.path.exists(f['path'])]
|
|
210
|
+
|
|
211
|
+
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
|
212
|
+
merge_md_files(output_path, existing_files, title)
|
|
213
|
+
|
|
214
|
+
# API文档
|
|
215
|
+
merge_api_docs("docs/api", output_path)
|
|
216
|
+
|
|
217
|
+
print(f"{title}生成完成,已保存到: {output_path}")
|
|
218
|
+
|
|
219
|
+
if __name__ == "__main__":
|
|
220
|
+
try:
|
|
221
|
+
generate_full_document()
|
|
222
|
+
generate_core_document()
|
|
223
|
+
generate_dev_documents()
|
|
224
|
+
print("所有文档生成完成")
|
|
225
|
+
except Exception as e:
|
|
226
|
+
print(f"文档生成过程中出现错误: {str(e)}")
|
|
@@ -102,7 +102,7 @@ def parse_python_file(file_path: str) -> Tuple[Optional[str], List[Dict], List[D
|
|
|
102
102
|
try:
|
|
103
103
|
module = ast.parse(source)
|
|
104
104
|
except SyntaxError:
|
|
105
|
-
print(f"
|
|
105
|
+
print(f"语法错误,跳过文件: {file_path}")
|
|
106
106
|
return None, [], []
|
|
107
107
|
|
|
108
108
|
# 提取模块文档
|
|
@@ -211,9 +211,9 @@ def generate_markdown(module_path: str, module_doc: Optional[str],
|
|
|
211
211
|
content = []
|
|
212
212
|
|
|
213
213
|
# 文档头部
|
|
214
|
-
content.append(f"""#
|
|
214
|
+
content.append(f"""# `{module_path}` 模块
|
|
215
215
|
|
|
216
|
-
<sup
|
|
216
|
+
<sup>更新时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}</sup>
|
|
217
217
|
|
|
218
218
|
---
|
|
219
219
|
|
|
@@ -229,9 +229,9 @@ def generate_markdown(module_path: str, module_doc: Optional[str],
|
|
|
229
229
|
|
|
230
230
|
# 函数部分
|
|
231
231
|
if functions:
|
|
232
|
-
content.append("##
|
|
232
|
+
content.append("## 函数列表\n")
|
|
233
233
|
for func in functions:
|
|
234
|
-
async_marker = "
|
|
234
|
+
async_marker = "async " if func["is_async"] else ""
|
|
235
235
|
content.append(f"""### {async_marker}`{func['signature']}`
|
|
236
236
|
|
|
237
237
|
{func['doc']}
|
|
@@ -241,7 +241,7 @@ def generate_markdown(module_path: str, module_doc: Optional[str],
|
|
|
241
241
|
|
|
242
242
|
# 类部分
|
|
243
243
|
if classes:
|
|
244
|
-
content.append("##
|
|
244
|
+
content.append("## 类列表\n")
|
|
245
245
|
for cls in classes:
|
|
246
246
|
content.append(f"""### `{cls['signature']}`
|
|
247
247
|
|
|
@@ -251,9 +251,9 @@ def generate_markdown(module_path: str, module_doc: Optional[str],
|
|
|
251
251
|
|
|
252
252
|
# 类方法
|
|
253
253
|
if cls["methods"]:
|
|
254
|
-
content.append("####
|
|
254
|
+
content.append("#### 方法列表\n")
|
|
255
255
|
for method in cls["methods"]:
|
|
256
|
-
async_marker = "
|
|
256
|
+
async_marker = "async " if method["is_async"] else ""
|
|
257
257
|
content.append(f"""##### {async_marker}`{method['signature']}`
|
|
258
258
|
|
|
259
259
|
{method['doc']}
|
|
@@ -480,8 +480,8 @@ def generate_html(module_path: str, module_doc: Optional[str],
|
|
|
480
480
|
<body>
|
|
481
481
|
<header>
|
|
482
482
|
<div class="container">
|
|
483
|
-
<h1
|
|
484
|
-
<p><small
|
|
483
|
+
<h1>`{module_path}` 模块</h1>
|
|
484
|
+
<p><small>更新时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}</small></p>
|
|
485
485
|
</div>
|
|
486
486
|
</header>
|
|
487
487
|
|
|
@@ -498,18 +498,18 @@ def generate_html(module_path: str, module_doc: Optional[str],
|
|
|
498
498
|
|
|
499
499
|
# 函数部分
|
|
500
500
|
if functions:
|
|
501
|
-
html_content.append("</section>\n\n<section>\n<h2
|
|
501
|
+
html_content.append("</section>\n\n<section>\n<h2>函数列表</h2>\n")
|
|
502
502
|
for func in functions:
|
|
503
|
-
async_marker = "
|
|
503
|
+
async_marker = "async " if func["is_async"] else ""
|
|
504
504
|
html_content.append(f"""<article>
|
|
505
|
-
<h3
|
|
505
|
+
<h3><code class="signature function-signature">{async_marker}{func['signature']}</code></h3>
|
|
506
506
|
<div>{func['doc']}</div>
|
|
507
507
|
</article>
|
|
508
508
|
""")
|
|
509
509
|
|
|
510
510
|
# 类部分
|
|
511
511
|
if classes:
|
|
512
|
-
html_content.append("</section>\n\n<section>\n<h2
|
|
512
|
+
html_content.append("</section>\n\n<section>\n<h2>类列表</h2>\n")
|
|
513
513
|
for cls in classes:
|
|
514
514
|
html_content.append(f"""<article>
|
|
515
515
|
<h3><code class="signature class-signature">{cls['signature']}</code></h3>
|
|
@@ -518,11 +518,11 @@ def generate_html(module_path: str, module_doc: Optional[str],
|
|
|
518
518
|
|
|
519
519
|
# 类方法
|
|
520
520
|
if cls["methods"]:
|
|
521
|
-
html_content.append("<h4
|
|
521
|
+
html_content.append("<h4>方法列表</h4>\n")
|
|
522
522
|
for method in cls["methods"]:
|
|
523
|
-
async_marker = "
|
|
523
|
+
async_marker = "async " if method["is_async"] else ""
|
|
524
524
|
html_content.append(f"""<article>
|
|
525
|
-
<h5
|
|
525
|
+
<h5><code class="signature method-signature">{async_marker}{method['signature']}</code></h5>
|
|
526
526
|
<div>{method['doc']}</div>
|
|
527
527
|
</article>
|
|
528
528
|
""")
|
|
@@ -539,7 +539,7 @@ def generate_html(module_path: str, module_doc: Optional[str],
|
|
|
539
539
|
</footer>
|
|
540
540
|
</body>
|
|
541
541
|
</html>""")
|
|
542
|
-
|
|
542
|
+
|
|
543
543
|
return "\n".join(html_content)
|
|
544
544
|
|
|
545
545
|
def generate_api_docs(src_dir: str, output_dir: str, format: str = "markdown"):
|
|
@@ -568,7 +568,7 @@ def generate_api_docs(src_dir: str, output_dir: str, format: str = "markdown"):
|
|
|
568
568
|
|
|
569
569
|
# 跳过没有文档的文件
|
|
570
570
|
if not module_doc and not classes and not functions:
|
|
571
|
-
print(f"
|
|
571
|
+
print(f"跳过无文档文件: {file_path}")
|
|
572
572
|
continue
|
|
573
573
|
|
|
574
574
|
# 生成内容
|
|
@@ -586,7 +586,7 @@ def generate_api_docs(src_dir: str, output_dir: str, format: str = "markdown"):
|
|
|
586
586
|
with open(output_path, "w", encoding="utf-8") as f:
|
|
587
587
|
f.write(content)
|
|
588
588
|
|
|
589
|
-
print(f"
|
|
589
|
+
print(f"已生成: {output_path}")
|
|
590
590
|
|
|
591
591
|
if __name__ == "__main__":
|
|
592
592
|
parser = argparse.ArgumentParser(description="API文档生成器")
|
|
@@ -597,20 +597,11 @@ if __name__ == "__main__":
|
|
|
597
597
|
|
|
598
598
|
args = parser.parse_args()
|
|
599
599
|
|
|
600
|
-
print(f"""
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
600
|
+
print(f"""源代码目录: {args.src}
|
|
601
|
+
输出目录: {args.output}
|
|
602
|
+
输出格式: {args.format}
|
|
603
|
+
正在生成API文档...""")
|
|
604
604
|
|
|
605
605
|
generate_api_docs(args.src, args.output, args.format)
|
|
606
606
|
|
|
607
|
-
print(f"
|
|
608
|
-
|
|
609
|
-
生成文档包含以下改进:
|
|
610
|
-
✨ 更现代化的样式和布局
|
|
611
|
-
📅 自动添加生成时间戳
|
|
612
|
-
🔖 使用emoji图标提高可读性
|
|
613
|
-
📝 优化了参数和返回值的显示方式
|
|
614
|
-
📱 响应式设计,适配移动设备
|
|
615
|
-
💡 改进了示例代码的展示方式
|
|
616
|
-
""")
|
|
607
|
+
print(f"API文档生成完成!")
|
|
@@ -96,15 +96,16 @@ jobs:
|
|
|
96
96
|
changelog="$changelog\n\n"
|
|
97
97
|
fi
|
|
98
98
|
|
|
99
|
-
#
|
|
99
|
+
# 贡献信息
|
|
100
100
|
changelog="${changelog}### 🧙♀️ 魔法贡献者\n\n"
|
|
101
101
|
while IFS= read -r contributor; do
|
|
102
|
-
|
|
102
|
+
escaped_contributor=$(echo "$contributor" | sed 's/>/\>/g' | sed 's/</\</g')
|
|
103
|
+
changelog="${changelog}- ${escaped_contributor}\n"
|
|
103
104
|
done <<< "$contributors"
|
|
104
|
-
|
|
105
|
-
# 添加提交信息
|
|
105
|
+
|
|
106
106
|
changelog="${changelog}\n### 📜 魔法卷轴更新\n\n"
|
|
107
|
-
|
|
107
|
+
escaped_commit_msg=$(echo "$commit_msg" | sed 's/#/\\#/g')
|
|
108
|
+
changelog="${changelog}- 最新提交: $escaped_commit_msg (by $commit_author, $commit_short)\n"
|
|
108
109
|
changelog="${changelog}- 变更文件: ${{ steps.changed_files.outputs.files }}\n"
|
|
109
110
|
|
|
110
111
|
if ! git rev-parse "$tag_name" >/dev/null 2>&1; then
|
|
@@ -28,4 +28,10 @@ This SDK's core adapter standardization layer strictly follows OneBot12 specific
|
|
|
28
28
|
- Message segment definitions
|
|
29
29
|
- Metadata definitions
|
|
30
30
|
|
|
31
|
-
This ensures consistent behavior and interoperability across all adapter implementations.
|
|
31
|
+
This ensures consistent behavior and interoperability across all adapter implementations.
|
|
32
|
+
|
|
33
|
+
感谢所有为开源社区做出贡献的开发者和作者
|
|
34
|
+
|
|
35
|
+
请尊重每一位开源作者的劳动成果,承诺在使用、修改和分发本软件时,将严格遵守相关许可证条款,并保留所有原始版权声明
|
|
36
|
+
|
|
37
|
+
开源精神的核心在于分享、协作与尊重。我们希望通过本项目,能够传承这一精神,为开源社区的发展贡献一份力量
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ErisPulse
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0.dev0
|
|
4
4
|
Summary: ErisPulse 是一个模块化、可扩展的异步 Python SDK 框架,主要用于构建高效、可维护的机器人应用程序。
|
|
5
5
|
Author-email: "艾莉丝·格雷拉特(WSu2059)" <wsu2059@qq.com>
|
|
6
6
|
License: MIT License
|
|
@@ -34,6 +34,12 @@ License: MIT License
|
|
|
34
34
|
- Metadata definitions
|
|
35
35
|
|
|
36
36
|
This ensures consistent behavior and interoperability across all adapter implementations.
|
|
37
|
+
|
|
38
|
+
感谢所有为开源社区做出贡献的开发者和作者
|
|
39
|
+
|
|
40
|
+
请尊重每一位开源作者的劳动成果,承诺在使用、修改和分发本软件时,将严格遵守相关许可证条款,并保留所有原始版权声明
|
|
41
|
+
|
|
42
|
+
开源精神的核心在于分享、协作与尊重。我们希望通过本项目,能够传承这一精神,为开源社区的发展贡献一份力量
|
|
37
43
|
License-File: LICENSE
|
|
38
44
|
Classifier: Development Status :: 5 - Production/Stable
|
|
39
45
|
Classifier: Intended Audience :: Developers
|
|
@@ -74,7 +74,7 @@ async def test_logger():
|
|
|
74
74
|
|
|
75
75
|
print(f"\n{Colors.GREEN}日志测试完成,请查看控制台和文件 {log_file} 的输出{Colors.END}")
|
|
76
76
|
|
|
77
|
-
async def
|
|
77
|
+
async def test_storage():
|
|
78
78
|
while True:
|
|
79
79
|
print(f"\n{Colors.CYAN}--- 环境配置测试 ---{Colors.END}")
|
|
80
80
|
print(f"{Colors.BLUE}1. 设置/获取单个配置项{Colors.END}")
|
|
@@ -91,36 +91,36 @@ async def test_env():
|
|
|
91
91
|
print(f"\n{Colors.YELLOW}--- 单个配置项测试 ---{Colors.END}")
|
|
92
92
|
key = input(f"{Colors.GREEN}请输入配置项名称: {Colors.END}").strip()
|
|
93
93
|
value = input(f"{Colors.GREEN}请输入{key}的值: {Colors.END}").strip()
|
|
94
|
-
sdk.
|
|
94
|
+
sdk.storage.set(key, value)
|
|
95
95
|
print(f"{Colors.GREEN}已设置 {key}={value}{Colors.END}")
|
|
96
|
-
print(f"{Colors.GREEN}读取测试: {key} = {sdk.
|
|
96
|
+
print(f"{Colors.GREEN}读取测试: {key} = {sdk.storage.get(key)}{Colors.END}")
|
|
97
97
|
|
|
98
98
|
elif choice == "2":
|
|
99
99
|
print(f"\n{Colors.YELLOW}--- 批量配置项测试 ---{Colors.END}")
|
|
100
100
|
count = input(f"{Colors.GREEN}请输入要批量设置的配置项数量(默认3): {Colors.END}") or "3"
|
|
101
101
|
items = {f"test_key_{i}": f"value_{i}" for i in range(1, int(count)+1)}
|
|
102
|
-
sdk.
|
|
102
|
+
sdk.storage.set_multi(items)
|
|
103
103
|
print(f"{Colors.GREEN}已批量设置 {len(items)} 个配置项{Colors.END}")
|
|
104
|
-
print(f"{Colors.GREEN}批量读取结果: {sdk.
|
|
104
|
+
print(f"{Colors.GREEN}批量读取结果: {sdk.storage.get_multi(list(items.keys()))}{Colors.END}")
|
|
105
105
|
|
|
106
106
|
elif choice == "3":
|
|
107
107
|
print(f"\n{Colors.YELLOW}--- 测试配置管理 ---{Colors.END}")
|
|
108
108
|
config_key = input(f"{Colors.GREEN}请输入配置项key: {Colors.END}") or None
|
|
109
109
|
config_value = input(f"{Colors.GREEN}请输入配置项value: {Colors.END}") or None
|
|
110
110
|
if config_key and config_value:
|
|
111
|
-
sdk.
|
|
111
|
+
sdk.storage.setConfig(config_key, config_value)
|
|
112
112
|
print(f"{Colors.GREEN}已设置 {config_key}={config_value}{Colors.END}")
|
|
113
|
-
print(f"{Colors.GREEN}读取测试: {config_key} = {sdk.
|
|
113
|
+
print(f"{Colors.GREEN}读取测试: {config_key} = {sdk.storage.getConfig(config_key)}{Colors.END}")
|
|
114
114
|
else:
|
|
115
115
|
print(f"{Colors.RED}请设置配置项key和value{Colors.END}")
|
|
116
116
|
|
|
117
117
|
elif choice == "4":
|
|
118
118
|
print(f"\n{Colors.YELLOW}--- 事务操作测试 ---{Colors.END}")
|
|
119
119
|
print(f"{Colors.YELLOW}开始事务...{Colors.END}")
|
|
120
|
-
with sdk.
|
|
121
|
-
sdk.
|
|
122
|
-
sdk.
|
|
123
|
-
print(f"{Colors.GREEN}事务中设置的值: tx_key1={sdk.
|
|
120
|
+
with sdk.storage.transaction():
|
|
121
|
+
sdk.storage.set("tx_key1", "value1")
|
|
122
|
+
sdk.storage.set("tx_key2", "value2")
|
|
123
|
+
print(f"{Colors.GREEN}事务中设置的值: tx_key1={sdk.storage.get('tx_key1')}{Colors.END}")
|
|
124
124
|
print(f"{Colors.GREEN}事务提交成功{Colors.END}")
|
|
125
125
|
|
|
126
126
|
elif choice == "5":
|
|
@@ -128,11 +128,11 @@ async def test_env():
|
|
|
128
128
|
try:
|
|
129
129
|
# 测试创建快照
|
|
130
130
|
snapshot_name = input(f"{Colors.GREEN}请输入快照名称(默认: test_snapshot): {Colors.END}") or "test_snapshot"
|
|
131
|
-
snapshot_path = sdk.
|
|
131
|
+
snapshot_path = sdk.storage.snapshot(snapshot_name)
|
|
132
132
|
print(f"{Colors.GREEN}✓ 快照创建成功: {snapshot_path}{Colors.END}")
|
|
133
133
|
|
|
134
134
|
# 测试列出快照
|
|
135
|
-
snapshots = sdk.
|
|
135
|
+
snapshots = sdk.storage.list_snapshots()
|
|
136
136
|
print(f"\n{Colors.CYAN}当前可用快照:{Colors.END}")
|
|
137
137
|
for i, (name, date, size) in enumerate(snapshots, 1):
|
|
138
138
|
print(f"{i}. {name} - {date.strftime('%Y-%m-%d %H:%M:%S')} ({size/1024:.1f} KB)")
|
|
@@ -142,7 +142,7 @@ async def test_env():
|
|
|
142
142
|
restore_choice = input(f"\n{Colors.GREEN}是否要测试恢复快照?(y/n): {Colors.END}").lower()
|
|
143
143
|
if restore_choice == 'y':
|
|
144
144
|
snap_name = snapshots[0][0] # 取第一个快照
|
|
145
|
-
if sdk.
|
|
145
|
+
if sdk.storage.restore(snap_name):
|
|
146
146
|
print(f"{Colors.GREEN}✓ 快照恢复成功: {snap_name}{Colors.END}")
|
|
147
147
|
else:
|
|
148
148
|
print(f"{Colors.RED}✗ 快照恢复失败{Colors.END}")
|
|
@@ -357,14 +357,14 @@ async def main():
|
|
|
357
357
|
if choice == "1":
|
|
358
358
|
print("\n核心模块列表:")
|
|
359
359
|
print("- logger: 日志记录系统")
|
|
360
|
-
print("-
|
|
360
|
+
print("- storage: 数据存储系统")
|
|
361
361
|
print("- exceptions: 异常处理系统")
|
|
362
362
|
print("- router: 路由管理")
|
|
363
363
|
print("- adapter: 适配器系统")
|
|
364
364
|
elif choice == "2":
|
|
365
365
|
await test_logger()
|
|
366
366
|
elif choice == "3":
|
|
367
|
-
await
|
|
367
|
+
await test_storage()
|
|
368
368
|
elif choice == "4":
|
|
369
369
|
await test_exceptions()
|
|
370
370
|
elif choice == "5":
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import json
|
|
3
|
+
from ErisPulse import sdk
|
|
4
|
+
from ErisPulse.Core.Event import command
|
|
5
|
+
|
|
6
|
+
echo_status = False
|
|
7
|
+
|
|
8
|
+
@command("test", help="测试命令", usage="/test [参数]")
|
|
9
|
+
async def test_command(event):
|
|
10
|
+
platform = event["platform"]
|
|
11
|
+
|
|
12
|
+
if event.get("detail_type") == "group":
|
|
13
|
+
type = "group"
|
|
14
|
+
id = event["group_id"]
|
|
15
|
+
else:
|
|
16
|
+
type = "user"
|
|
17
|
+
id = event["user_id"]
|
|
18
|
+
|
|
19
|
+
adapter = getattr(sdk.adapter, platform)
|
|
20
|
+
await adapter.Send.To(type, id).Text("收到测试命令")
|
|
21
|
+
sdk.logger.info(f"处理测试命令: {event}")
|
|
22
|
+
|
|
23
|
+
@command("help", help="帮助命令", usage="/help")
|
|
24
|
+
async def help_command(event):
|
|
25
|
+
platform = event["platform"]
|
|
26
|
+
|
|
27
|
+
if event.get("detail_type") == "group":
|
|
28
|
+
type = "group"
|
|
29
|
+
id = event["group_id"]
|
|
30
|
+
else:
|
|
31
|
+
type = "user"
|
|
32
|
+
id = event["user_id"]
|
|
33
|
+
|
|
34
|
+
adapter = getattr(sdk.adapter, platform)
|
|
35
|
+
await adapter.Send.To(type, id).Text(command.help())
|
|
36
|
+
|
|
37
|
+
@command("echo", help="控制事件回显", usage="/echo <on|off>")
|
|
38
|
+
async def echo_control_command(event):
|
|
39
|
+
platform = event["platform"]
|
|
40
|
+
|
|
41
|
+
if event.get("detail_type") == "group":
|
|
42
|
+
type = "group"
|
|
43
|
+
id = event["group_id"]
|
|
44
|
+
else:
|
|
45
|
+
type = "user"
|
|
46
|
+
id = event["user_id"]
|
|
47
|
+
|
|
48
|
+
adapter = getattr(sdk.adapter, platform)
|
|
49
|
+
|
|
50
|
+
# 解析参数
|
|
51
|
+
alt_message = event["alt_message"].strip()
|
|
52
|
+
args = alt_message.split()[1:]
|
|
53
|
+
|
|
54
|
+
global echo_status
|
|
55
|
+
|
|
56
|
+
if not args:
|
|
57
|
+
# 没有参数,显示当前状态
|
|
58
|
+
status_text = "开启" if echo_status else "关闭"
|
|
59
|
+
await adapter.Send.To(type, id).Text(f"Echo当前状态: {status_text}")
|
|
60
|
+
return
|
|
61
|
+
|
|
62
|
+
subcommand = args[0].lower()
|
|
63
|
+
|
|
64
|
+
if subcommand == "on":
|
|
65
|
+
echo_status = True
|
|
66
|
+
await adapter.Send.To(type, id).Text("Echo已开启")
|
|
67
|
+
elif subcommand == "off":
|
|
68
|
+
echo_status = False
|
|
69
|
+
await adapter.Send.To(type, id).Text("Echo已关闭")
|
|
70
|
+
else:
|
|
71
|
+
await adapter.Send.To(type, id).Text("无效参数,请使用 'on' 或 'off'")
|
|
72
|
+
|
|
73
|
+
@sdk.adapter.on("message")
|
|
74
|
+
async def echo_message(event):
|
|
75
|
+
global echo_status
|
|
76
|
+
platform = event["platform"]
|
|
77
|
+
|
|
78
|
+
if echo_status:
|
|
79
|
+
try:
|
|
80
|
+
adapter = getattr(sdk.adapter, platform)
|
|
81
|
+
|
|
82
|
+
if event.get("detail_type") == "group":
|
|
83
|
+
target_type = "group"
|
|
84
|
+
target_id = event["group_id"]
|
|
85
|
+
else:
|
|
86
|
+
target_type = "user"
|
|
87
|
+
target_id = event["user_id"]
|
|
88
|
+
|
|
89
|
+
event_copy = event.copy()
|
|
90
|
+
platform_raw_key = f"{platform}_raw"
|
|
91
|
+
if platform_raw_key in event_copy:
|
|
92
|
+
del event_copy[platform_raw_key]
|
|
93
|
+
|
|
94
|
+
event_str = json.dumps(event_copy, ensure_ascii=False, indent=2)
|
|
95
|
+
if len(event_str) > 1000:
|
|
96
|
+
event_str = event_str[:1000] + "... (内容过长已截断)"
|
|
97
|
+
|
|
98
|
+
await adapter.Send.To(target_type, target_id).Text(f"Event内容:\n{event_str}")
|
|
99
|
+
except Exception as e:
|
|
100
|
+
sdk.logger.error(f"Echo回显失败: {e}")
|
|
101
|
+
|
|
102
|
+
return event
|
|
103
|
+
|
|
104
|
+
async def main():
|
|
105
|
+
try:
|
|
106
|
+
isInit = await sdk.init_task()
|
|
107
|
+
|
|
108
|
+
if not isInit:
|
|
109
|
+
sdk.logger.error("ErisPulse 初始化失败,请检查日志")
|
|
110
|
+
return
|
|
111
|
+
|
|
112
|
+
await sdk.adapter.startup()
|
|
113
|
+
|
|
114
|
+
# 保持程序运行(不建议修改)
|
|
115
|
+
await asyncio.Event().wait()
|
|
116
|
+
except Exception as e:
|
|
117
|
+
sdk.logger.error(e)
|
|
118
|
+
except KeyboardInterrupt:
|
|
119
|
+
sdk.logger.info("正在停止程序")
|
|
120
|
+
finally:
|
|
121
|
+
await sdk.adapter.shutdown()
|
|
122
|
+
|
|
123
|
+
if __name__ == "__main__":
|
|
124
|
+
asyncio.run(main())
|