fix: treat Discord voice attachments as records#8036
Open
p1930n wants to merge 2 commits intoAstrBotDevs:masterfrom
Open
fix: treat Discord voice attachments as records#8036p1930n wants to merge 2 commits intoAstrBotDevs:masterfrom
p1930n wants to merge 2 commits intoAstrBotDevs:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds support for audio attachments in the Discord platform adapter by mapping them to the Record component and provides unit tests for this functionality. The review feedback identifies a potential regression in message sending because the Record component is not handled by the platform's message parser. Additionally, optimizations were suggested to pass the already computed content type to the audio detection logic to avoid redundant processing.
Author
|
Fixed in abf78b4. Addressed all three review points:
|
Author
|
Fixed in abf78b4.
|
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.
Fixes #7580.
Modifications / 改动点
This PR fixes Discord voice-message handling by mapping audio attachments to
Recordinstead of genericFilecomponents. The adapter now detects audio attachments by normalizedaudio/*content type, with a filename-extension fallback for Discord attachments that do not expose a content type.It also keeps the outgoing path compatible with the new component type by allowing
DiscordPlatformEvent._parse_to_discord()to sendRecordcomponents as Discord files. Image attachments still map toImage, and non-audio non-image attachments still map toFile.Screenshots or Test Results / 运行截图或测试结果
astrbot:issue-7580-local:[ComponentType.Record].docker run --rm -v "D:\AstrBot - PRs\AstrBot_issue_7580:/workspace" -w /workspace astrbot:issue-7580-local sh -lc "python -m pip install -q pytest pytest-asyncio && python -m pytest tests/test_discord_adapter.py tests/test_mattermost_adapter.py tests/test_telegram_adapter.py -q"17 passed, 1 warningdocker run --rm -v "D:\AstrBot - PRs\AstrBot_issue_7580:/workspace" -w /workspace astrbot:issue-7580-local sh -lc "python -m pip install -q ruff && ruff check astrbot/core/platform/sources/discord/discord_platform_adapter.py astrbot/core/platform/sources/discord/discord_platform_event.py tests/test_discord_adapter.py && ruff format --check astrbot/core/platform/sources/discord/discord_platform_adapter.py astrbot/core/platform/sources/discord/discord_platform_event.py tests/test_discord_adapter.py"All checks passed!3 files already formattedChecklist / 检查清单
requirements.txtandpyproject.toml. / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到requirements.txt和pyproject.toml文件相应位置。Summary by Sourcery
Handle Discord voice attachments as audio records instead of generic files while preserving compatibility with outbound Discord messages.
New Features:
Bug Fixes:
Enhancements:
Tests: