Skip to content

Commit

Permalink
fix: CQ.img 传递参数错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsuk1ko committed Jul 20, 2024
1 parent 31775f1 commit 0af8975
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 2024

### 07-20 v3.17.5

- 修复B站动态解析无法发送含有图片的动态的问题 [#468](../../issues/468)

### 07-20 v3.17.4

- B站动态推送支持过滤转发自己的动态
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/bilibili/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const handleImgsByConfig = async urls => {
if (dynamicImgPreDl) {
const config = { timeout: imgPreDlTimeout * 1000 };
return dynamicMergeImgs
? (await dlAndMergeImgsIfCan(urls, config)).map(url => CQ.img(pathToFileURL(url)))
? (await dlAndMergeImgsIfCan(urls, config)).map(url => CQ.img(pathToFileURL(url).href))
: await Promise.all(urls.map(url => CQ.imgPreDl(url, undefined, config)));
}
return urls.map(url => CQ.img(url));
Expand Down
7 changes: 6 additions & 1 deletion src/utils/CQcode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ class CQCode {
* @param {'flash'|'show'} [type] 类型
*/
static img(file, type) {
if (!file) {
console.error('[error] CQ.img file empty');
return;
}
if (typeof file !== 'string') file = String(file);
// fix Lagrange ssl issue #467
if (file.startsWith('https://multimedia.nt.qq.com.cn/')) {
file = file.replace(/^https/, 'http');
Expand All @@ -140,7 +145,7 @@ class CQCode {
static async imgPreDl(url, type, config = {}) {
try {
const path = await dlImgToCache(url, config, true);
return new CQCode('image', { file: pathToFileURL(path), type }).toString();
return new CQCode('image', { file: pathToFileURL(path).href, type }).toString();
} catch (e) {
logError('[error] cq img pre-download');
logError(e);
Expand Down

0 comments on commit 0af8975

Please sign in to comment.