From 248ba84a0c39e8f7b202aadd3b3b6d5c02f7b432 Mon Sep 17 00:00:00 2001 From: Mrs4s <1844812067@qq.com> Date: Mon, 24 Aug 2020 14:47:24 +0800 Subject: [PATCH] fix bug. --- coolq/cqcode.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 5e8f6ae..4d01fd4 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -329,6 +329,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message. } var size int32 var hash []byte + var url string if path.Ext(rawPath) == ".cqimg" { for _, line := range strings.Split(global.ReadAllText(rawPath), "\n") { kv := strings.SplitN(line, "=", 2) @@ -344,8 +345,13 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message. r := binary.NewReader(b) hash = r.ReadBytes(16) size = r.ReadInt32() + r.ReadString() + url = r.ReadString() } if size == 0 { + if url != "" { + return bot.ToElement(t, map[string]string{"file": url}, group) + } return nil, errors.New("img size is 0") } if len(hash) != 16 {