AstrBot
AstrBot copied to clipboard
Improve: 优化 Gewechat 下文件回调逻辑
优化了 #1182
Motivation
当前 gewechat 适配器对文件、图片、语音、视频文件的发送逻辑强依赖于文件路径在 data/temp 文件夹下。对插件开发非常不友好,并且图片处理时,会将图片从原路径复制到 data/temp 下,导致文件重复。
Modifications
引入了一个简单的注册令牌机制,发送文件、图片、语音、视频文件前需要向回调服务注册文件并获得单次文件令牌。然后通过令牌访问文件。
此举提高了安全性、减少了副作用。
Check
- [x] 😊 我的 Commit Message 符合良好的规范
- [x] 👀 我的更改经过良好的测试
- [x] 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了
requirements.txt和pyproject.toml文件相应位置。 - [x] 😮 我的更改没有引入恶意代码
好的,这是翻译成中文的 pull request 总结:
Sourcery 总结
重构 Gewechat 适配器的文件处理机制,使用基于令牌的系统,而不是依赖直接文件路径访问。
增强功能:
- 引入文件注册机制,使用一次性令牌通过回调服务器提供文件(图像、视频、语音、通用文件)。
- 移除发送文件前必须位于
data/temp目录的要求。 - 避免在发送图像文件之前将其复制到
data/temp目录。
Original summary in English
Summary by Sourcery
Refactor the Gewechat adapter's file handling mechanism to use a token-based system instead of relying on direct file path access.
Enhancements:
- Introduce a file registration mechanism using single-use tokens for serving files (images, videos, voice, general files) via the callback server.
- Remove the requirement for files to be located in the
data/tempdirectory before sending. - Avoid copying image files to the
data/tempdirectory before sending.