feat: 新增小红书解析

This commit is contained in:
zhiyu1998 2023-02-10 15:55:25 +08:00
parent 3c8a145aa7
commit 9e1298b57c
9 changed files with 35 additions and 15 deletions

View File

@ -9,7 +9,7 @@
个人团队用的<a href="https://gitee.com/Le-niao/Yunzai-Bot" target="_blank">Yunzai-Bot</a>插件,插件的各种业务来源于周围人
<img src="https://cdn.jsdelivr.net/gh/xianxincoder/xianxincoder/assets/github-contribution-grid-snake.svg">
</div>
![](../../../../Downloads/iShot_2023-02-10_15.54.06.png)
## 🗃️文件架构
apps -- 业务核心
@ -27,6 +27,7 @@ index -- 主入口
![help](./img/example.png)
![help](./img/example2.png)
![help](./img/example3.png)
![help](./img/example4.png)
## 🤺BUG及时交流群
![help](./img/community.jpg)

View File

@ -441,19 +441,32 @@ export class tools extends plugin {
const reg = /<img(.*)src="\/\/ci\.xiaohongshu\.com(.*?)"/g
let res = '';
let images = [];
while (res = reg.exec(resp.data)) {
console.log(`https://ci.xiaohongshu.com${res[2]}`)
images.push({
message: segment.image(`https://ci.xiaohongshu.com${res[2]}`),
nickname: e.sender.card || e.user_id,
user_id: e.user_id
})
const downloadPath = `${ this.defaultPath }${ this.e.group_id || this.e.user_id }`;
// 创建文件夹(如果没有过这个群)
if (!fs.existsSync(downloadPath)) {
mkdirsSync(downloadPath);
}
if (images.length > 0) {
e.reply(Bot.makeForwardMsg(images))
} else {
e.reply("解析失败,重新解析下");
while (res = reg.exec(resp.data)) {
const addr = `https://ci.xiaohongshu.com${res[2]}`
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",
},
responseType: "stream",
}).then(resp => {
const filepath = `${downloadPath}/${/com\/(.*)\?/.exec(addr)[1]}.jpg`
const writer = fs.createWriteStream(filepath);
resp.data.pipe(writer)
return new Promise((resolve, reject) => {
writer.on('finish', () => resolve(filepath));
writer.on('error', reject);
});
})
.then( filepath => {
e.reply(segment.image(fs.readFileSync(filepath)))
fs.unlinkSync(filepath)
})
}
})

View File

@ -52,6 +52,12 @@
- icon: 推特
title: "twitter"
desc: 推特学习版分享实时下载
- icon: acfun
title: "acfun"
desc: 猴山分享实时下载
- icon: redbook
title: "小红书"
desc: 小红书分享实时下载
- group: 其他指令[实验]
list:
- icon: update

View File

@ -1,8 +1,8 @@
- {
version: 1.0.2,
version: 1.0.3,
data:
[
更改单个组件<span class="cmd">#任助理</span>架构为插件架构,
增加<span class="cmd">#小红书</span>的图片解析,
添加<span class="cmd">#R帮助</span>获取插件帮助,
添加<span class="cmd">#R版本</span>获取插件版本,
更新风控缓解、重构系统文件、增加部分接口撤回操作

BIN
img/example4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 354 KiB

After

Width:  |  Height:  |  Size: 376 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 KiB

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB