Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对于 adapter-discord 发送网络图片的简化建议 #280

Closed
dragon-fish opened this issue May 29, 2021 · 6 comments · Fixed by #282
Closed

对于 adapter-discord 发送网络图片的简化建议 #280

dragon-fish opened this issue May 29, 2021 · 6 comments · Fixed by #282
Assignees

Comments

@dragon-fish
Copy link
Member

Is your feature request related to a problem? Please describe.

目前 adapter-discord 发送网络图片的方式是先下载图片,然后上传到 dc,这个过程会有些耗时,而且极容易受到网络环境影响从而发送失败。

Describe the solution you'd like

当发送网络图片时,发送一个 head 请求,如果返回的 contentType 是图片,则直接发送链接。

discord 自身会自动将图片链接转换成图片,且由此自动转的图片是不会因原链接过期而无法显示的。

此举可以从一定程度上节约时间,提高图片发送的成功率。

Describe alternatives you've considered

如果链接以 .jpg/gif/xxx 等结尾,跳过 head 请求检查媒体类型,直接发链接。(缺乏泛用性)

Additional context

@XxLittleCxX
Copy link
Member

你的意思是发送 embed 形式的图片吗

@dragon-fish
Copy link
Member Author

你的意思是发送 embed 形式的图片吗

就是 segment.image

@XxLittleCxX
Copy link
Member

我记得之前做过, discord 到 qq 的网络巨慢, 还可能失败

@dragon-fish
Copy link
Member Author

那就这样,先尝试发图,一旦超时就直接发链接

dragon-fish added a commit that referenced this issue May 29, 2021
dragon-fish added a commit that referenced this issue May 29, 2021
dragon-fish added a commit that referenced this issue May 29, 2021
dragon-fish added a commit that referenced this issue May 29, 2021
dragon-fish added a commit that referenced this issue May 29, 2021
dragon-fish added a commit that referenced this issue May 29, 2021
@shigma
Copy link
Member

shigma commented Jun 13, 2021

我建议加一个配置项 downloadMode,它允许下面的值:

  • always:永远下载后上传
  • head:发送一个 head 请求并根据结果决定是否下载(默认)
  • never:永远直接发送链接

@dragon-fish dragon-fish linked a pull request Jun 22, 2021 that will close this issue
@dragon-fish dragon-fish self-assigned this Jun 22, 2021
@dragon-fish
Copy link
Member Author

新增了一个 App 配置项 discord.urlImageSendMode: 'auto' | 'direct' | 'download'

segment.image 新增支持 mode 属性

@shigma shigma closed this as completed in 12207bd Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants