🎈 perf: 更新小红书逻辑

This commit is contained in:
zhiyu1998 2023-03-06 23:42:28 +08:00
parent 7674435b8e
commit 527ed23612
2 changed files with 24 additions and 18 deletions

View File

@ -507,19 +507,18 @@ export class tools extends plugin {
timeout: 10000,
proxy: false,
})
.then(resp => {
.then(async resp => {
const reg = /<img(.*)src="\/\/ci\.xiaohongshu\.com(.*?)"/g;
let res = "";
const downloadPath = `${ this.defaultPath }${ this.e.group_id || this.e.user_id }`;
// 创建文件夹(如果没有过这个群)
if (!fs.existsSync(downloadPath)) {
mkdirsSync(downloadPath);
}
while ((res = reg.exec(resp.data))) {
const addr = `https://ci.xiaohongshu.com${ res[2] }`;
axios
.get(addr, {
const res = resp.data.match(reg)
const imagesPath = res.map(item => {
const addr = `https:${item.split('"')[3]}`;
return axios.get(addr, {
headers: {
"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",
@ -535,11 +534,17 @@ export class tools extends plugin {
writer.on("error", reject);
});
})
.then(filepath => {
e.reply(segment.image(fs.readFileSync(filepath)));
fs.unlinkSync(filepath);
});
})
const images = await Promise.all(imagesPath).then(paths => {
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;

View File

@ -60,6 +60,7 @@ class RConfig {
const watcher = chokidar.watch(file)
watcher.on('change', (path) => {
delete
logger.mark(`[修改配置文件][${name}]`)
})
}