Skip to content

Commit

Permalink
fix: 修复无法使用url发送图片
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmomn committed Nov 8, 2024
1 parent 555886d commit 020f67c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions coolq/cqcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ func (bot *CQBot) ConvertElement(spec *onebot.Spec, elem msg.Element, sourceType
func (bot *CQBot) makeImageOrVideoElem(elem msg.Element, video bool, sourceType message.SourceType) (message.IMessageElement, error) {
f := elem.Get("file")
u := elem.Get("url")
if strings.HasPrefix(f, "http") {
if strings.HasPrefix(u, "http") {
hash := md5.Sum([]byte(f))
cacheFile := path.Join(global.CachePath, hex.EncodeToString(hash[:])+".cache")
maxSize := int64(maxImageSize)
Expand All @@ -901,7 +901,7 @@ func (bot *CQBot) makeImageOrVideoElem(elem msg.Element, video bool, sourceType
_ = os.Remove(cacheFile)
}
{
r := download.Request{URL: f, Limit: maxSize}
r := download.Request{URL: u, Limit: maxSize}
if err := r.WriteToFileMultiThreading(cacheFile, thread); err != nil {
return nil, err
}
Expand Down

0 comments on commit 020f67c

Please sign in to comment.