mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🎈 perf: 更新小红书逻辑
This commit is contained in:
parent
7674435b8e
commit
527ed23612
@ -507,27 +507,26 @@ export class tools extends plugin {
|
|||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
proxy: false,
|
proxy: false,
|
||||||
})
|
})
|
||||||
.then(resp => {
|
.then(async resp => {
|
||||||
const reg = /<img(.*)src="\/\/ci\.xiaohongshu\.com(.*?)"/g;
|
const reg = /<img(.*)src="\/\/ci\.xiaohongshu\.com(.*?)"/g;
|
||||||
let res = "";
|
|
||||||
|
|
||||||
const downloadPath = `${ this.defaultPath }${ this.e.group_id || this.e.user_id }`;
|
const downloadPath = `${ this.defaultPath }${ this.e.group_id || this.e.user_id }`;
|
||||||
// 创建文件夹(如果没有过这个群)
|
// 创建文件夹(如果没有过这个群)
|
||||||
if (!fs.existsSync(downloadPath)) {
|
if (!fs.existsSync(downloadPath)) {
|
||||||
mkdirsSync(downloadPath);
|
mkdirsSync(downloadPath);
|
||||||
}
|
}
|
||||||
while ((res = reg.exec(resp.data))) {
|
const res = resp.data.match(reg)
|
||||||
const addr = `https://ci.xiaohongshu.com${ res[2] }`;
|
const imagesPath = res.map(item => {
|
||||||
axios
|
const addr = `https:${item.split('"')[3]}`;
|
||||||
.get(addr, {
|
return axios.get(addr, {
|
||||||
headers: {
|
headers: {
|
||||||
"User-Agent":
|
"User-Agent":
|
||||||
"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Mobile Safari/537.36",
|
"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Mobile Safari/537.36",
|
||||||
},
|
},
|
||||||
responseType: "stream",
|
responseType: "stream",
|
||||||
})
|
})
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
const filepath = `${ downloadPath }/${ /com\/(.*)\?/.exec(addr)[1] }.jpg`;
|
const filepath = `${downloadPath}/${/com\/(.*)\?/.exec(addr)[1]}.jpg`;
|
||||||
const writer = fs.createWriteStream(filepath);
|
const writer = fs.createWriteStream(filepath);
|
||||||
resp.data.pipe(writer);
|
resp.data.pipe(writer);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -535,11 +534,17 @@ export class tools extends plugin {
|
|||||||
writer.on("error", reject);
|
writer.on("error", reject);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(filepath => {
|
})
|
||||||
e.reply(segment.image(fs.readFileSync(filepath)));
|
const images = await Promise.all(imagesPath).then(paths => {
|
||||||
fs.unlinkSync(filepath);
|
return paths.map(item => {
|
||||||
});
|
return {
|
||||||
}
|
message: segment.image(fs.readFileSync(item)),
|
||||||
|
nickname: e.sender.card || e.user_id,
|
||||||
|
user_id: e.user_id,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
await this.reply(await Bot.makeForwardMsg(images));
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -60,6 +60,7 @@ class RConfig {
|
|||||||
const watcher = chokidar.watch(file)
|
const watcher = chokidar.watch(file)
|
||||||
|
|
||||||
watcher.on('change', (path) => {
|
watcher.on('change', (path) => {
|
||||||
|
delete
|
||||||
logger.mark(`[修改配置文件][${name}]`)
|
logger.mark(`[修改配置文件][${name}]`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user