From 6581394ae1bcc4e4e437c0481e50f24e10b8df5a Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Mon, 28 Sep 2020 18:45:34 +0800 Subject: [PATCH] fix [CQ:record] & docs set_group_portrait --- docs/cqhttp.md | 22 ++++++++++++++++++++++ global/fs.go | 5 +++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/cqhttp.md b/docs/cqhttp.md index 5614553..38c212e 100644 --- a/docs/cqhttp.md +++ b/docs/cqhttp.md @@ -268,6 +268,28 @@ Type: `cardimage` | group_id | int64 | 群号 | | group_name | string | 新名 | +### 设置群头像 + +终结点: `/set_group_portrait` + +**参数** + +| 字段 | 类型 | 说明 | +| -------- | ------ | ---- | +| group_id | int64 | 群号 | +| file | string | 图片文件名 | +| cache | int | 表示是否使用已缓存的文件 | + +[1]`file` 参数支持以下几种格式: + +- 绝对路径,例如 `file:///C:\\Users\Richard\Pictures\1.png`,格式使用 [`file` URI](https://tools.ietf.org/html/rfc8089) +- 网络 URL,例如 `http://i1.piimg.com/567571/fdd6e7b6d93f1ef0.jpg` +- Base64 编码,例如 `base64://iVBORw0KGgoAAAANSUhEUgAAABQAAAAVCAIAAADJt1n/AAAAKElEQVQ4EWPk5+RmIBcwkasRpG9UM4mhNxpgowFGMARGEwnBIEJVAAAdBgBNAZf+QAAAAABJRU5ErkJggg==` + +[2]`cache`参数: 通过网络 URL 发送时有效,`1`表示使用缓存,`0`关闭关闭缓存,默认 为`1` + +[3] 目前这个API在登录一段时间后因cookie失效而失效,请考虑后使用 + ### 获取图片信息 终结点: `/get_image` diff --git a/global/fs.go b/global/fs.go index 9aa164d..4939952 100644 --- a/global/fs.go +++ b/global/fs.go @@ -53,7 +53,7 @@ func IsAMRorSILK(b []byte) bool { } func FindFile(f, cache, PATH string) (data []byte, err error) { - data, err = nil, errors.New("can't find the file: "+f) + data, err = nil, errors.New("syntax error") if strings.HasPrefix(f, "http") || strings.HasPrefix(f, "https") { if cache == "" { cache = "1" @@ -74,7 +74,8 @@ func FindFile(f, cache, PATH string) (data []byte, err error) { return nil, err } } else if strings.HasPrefix(f, "file") { - fu, err := url.Parse(f) + var fu *url.URL + fu, err = url.Parse(f) if err != nil { return nil, err }