refactor: 目录结构重组与 main.py 客户端类拆分 - #11
Open
VirTuaL-EnTitY wants to merge 1 commit into
Open
Conversation
将原有扁平代码按职责拆分为多个子包: 1. 拆分API客户端到clients/子包,按功能拆分独立模块 2. 将DG-LAB相关代码移入dglab/子包,统一设备管理逻辑 3. 群聊相关存储与功能移入group/子包 4. 媒体解析功能移入media/子包 5. 测试脚本统一放入tests/目录 6. 迁移废弃的media_cmds.py功能到media子包 7. 更新CI配置、文档与.gitignore适配新结构
👋 感谢贡献 CurrentCortex!@VirTuaL-EnTitY,你好!你的拉取请求 #11 已收到。 本次改动:46 个文件,+1095 / -1452 接下来会发生什么
期间你可以继续推送提交,机器人会自动跟进最新的改动。祝顺利合并! 🎉 |
🤖 AI 代码审查改动概述本次 PR 将项目从扁平结构重组为子包( 潜在风险
建议
以上内容由 AI 自动生成,仅供参考,最终以人工审查为准。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
本次更改幅度较大,请验证后再 合并
改动说明
对插件根目录进行结构性重组,把原本平铺在根目录的 11 个
dglab_*.py、media_parser.py、cross_group_memory.py、group_switch_store.py以及从main.py中拆出的 7 个 API 客户端类,按职责归入clients/、dglab/、media/、group/、tests/五个子包;main.py仅保留插件主类与必要常量。动机:根目录文件数过多(20+ 个平铺模块),
main.py单文件超过 5300 行,难以导航与维护。本次重构将同职责模块收拢进包,降低耦合、提升可读性。范围与兼容性:
_pages_api.py与main.py仍留在根目录,符合 AstrBot 插件加载约定。dglab/包内部 12 处from .dglab_xxx import兄弟引用保持不变;仅main.py对dglab/的引用从.dglab_xxx改为.dglab.dglab_xxx。主要变更:
__init__.py:clients/、dglab/(含docs/)、media/、group/、tests/main.py拆出到clients/:PixivAPIClient/HitokotoAPIClient/WeatherAPIClient/FemboyAPIClient/NeteaseAPIClient/KugouAPIClient/CommandParser及其异常类、配套 URL 常量、HITOKOTO_CATEGORIES、_format_api_key_not_configured/_remove_file_safemain.py:5339 行 → 4643 行(-696 行);导入区同步更新,仅保留PIXIV_ARTWORK_URL(仅主类使用)test_*.py移入tests/,并按新包结构改造 import(路径深度、stub 模块键名、sys.path、importlib路径)ci.yml测试 glob:test_*.py→tests/test_*.py.gitignore测试白名单:全部加tests/前缀media_cmds.py、orig_readme.md(经确认无引用)改动类型
自测清单
test_memory_and_switch.py33/33、test_dglab_protocol.py36/36、test_relay_pages.py41/41 全通过;test_reply_seg.py27/37、test_music_audio.py受本机 Python 3.14 / 无 ffmpeg 环境限制失败,CI 环境 Python 3.10 + ffmpeg 不受影响,已确认为环境问题而非重构回归)README.md与_conf_schema.json(本次无配置项 / 命令用法变更,无需更新)CHANGELOG.md的[Unreleased]小节追加条目(本次为内部结构调整,无用户可见行为变更,未追加;如需可在[Unreleased]的「变更」下补一条结构重组说明).gitignore白名单中登记(!tests/test_xxx.py)关联 Issue
#10