mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 11:33:48 +08:00
drop cache file .cqimg.
This commit is contained in:
parent
84488f9bf1
commit
4c8b2e9f13
@ -1147,15 +1147,13 @@ func (bot *CQBot) makeImageOrVideoElem(d map[string]string, video, group bool) (
|
|||||||
exist = true
|
exist = true
|
||||||
rawPath = path.Join(global.ImagePathOld, f)
|
rawPath = path.Join(global.ImagePathOld, f)
|
||||||
}
|
}
|
||||||
if !exist && global.PathExists(rawPath+".cqimg") {
|
if !exist {
|
||||||
exist = true
|
if d["url"] != "" {
|
||||||
rawPath += ".cqimg"
|
|
||||||
}
|
|
||||||
if !exist && d["url"] != "" {
|
|
||||||
return bot.makeImageOrVideoElem(map[string]string{"file": d["url"]}, false, group)
|
return bot.makeImageOrVideoElem(map[string]string{"file": d["url"]}, false, group)
|
||||||
}
|
}
|
||||||
if exist {
|
return nil, errors.New("invalid image")
|
||||||
if path.Ext(rawPath) != ".image" && path.Ext(rawPath) != ".cqimg" {
|
}
|
||||||
|
if path.Ext(rawPath) != ".image" {
|
||||||
return &LocalImageElement{File: rawPath}, nil
|
return &LocalImageElement{File: rawPath}, nil
|
||||||
}
|
}
|
||||||
b, err := os.ReadFile(rawPath)
|
b, err := os.ReadFile(rawPath)
|
||||||
@ -1165,29 +1163,11 @@ func (bot *CQBot) makeImageOrVideoElem(d map[string]string, video, group bool) (
|
|||||||
if len(b) < 20 {
|
if len(b) < 20 {
|
||||||
return nil, errors.New("invalid local file")
|
return nil, errors.New("invalid local file")
|
||||||
}
|
}
|
||||||
var (
|
|
||||||
size int32
|
|
||||||
hash []byte
|
|
||||||
imageURL string
|
|
||||||
)
|
|
||||||
if path.Ext(rawPath) == ".cqimg" {
|
|
||||||
for _, line := range strings.Split(global.ReadAllText(rawPath), "\n") {
|
|
||||||
kv := strings.SplitN(line, "=", 2)
|
|
||||||
switch kv[0] {
|
|
||||||
case "md5":
|
|
||||||
hash, _ = hex.DecodeString(strings.ReplaceAll(kv[1], "\r", ""))
|
|
||||||
case "size":
|
|
||||||
t, _ := strconv.Atoi(strings.ReplaceAll(kv[1], "\r", ""))
|
|
||||||
size = int32(t)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
r := binary.NewReader(b)
|
r := binary.NewReader(b)
|
||||||
hash = r.ReadBytes(16)
|
hash := r.ReadBytes(16)
|
||||||
size = r.ReadInt32()
|
size := r.ReadInt32()
|
||||||
r.ReadString()
|
r.ReadString()
|
||||||
imageURL = r.ReadString()
|
imageURL := r.ReadString()
|
||||||
}
|
|
||||||
if size == 0 {
|
if size == 0 {
|
||||||
if imageURL != "" {
|
if imageURL != "" {
|
||||||
return bot.makeImageOrVideoElem(map[string]string{"file": imageURL}, false, group)
|
return bot.makeImageOrVideoElem(map[string]string{"file": imageURL}, false, group)
|
||||||
@ -1212,8 +1192,6 @@ func (bot *CQBot) makeImageOrVideoElem(d map[string]string, video, group bool) (
|
|||||||
}
|
}
|
||||||
return rsp, nil
|
return rsp, nil
|
||||||
}
|
}
|
||||||
return nil, errors.New("invalid image")
|
|
||||||
}
|
|
||||||
|
|
||||||
// makeShowPic 一种xml 方式发送的群消息图片
|
// makeShowPic 一种xml 方式发送的群消息图片
|
||||||
func (bot *CQBot) makeShowPic(elem message.IMessageElement, source string, brief string, icon string, minWidth int64, minHeight int64, maxWidth int64, maxHeight int64, group bool) ([]message.IMessageElement, error) {
|
func (bot *CQBot) makeShowPic(elem message.IMessageElement, source string, brief string, icon string, minWidth int64, minHeight int64, maxWidth int64, maxHeight int64, group bool) ([]message.IMessageElement, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user