diff --git a/README.md b/README.md index e48456a..6396e73 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ index -- 主入口 ## 📔 使用说明 1.【必要】在`Yunzai-Bot`安装mongodb、axios(0.27.2)、代理工具(tunnel)、TwitterAPI依赖 -> pnpm add mongodb axios tunnel twitter-api-v2 -w +> pnpm add axios tunnel twitter-api-v2 -w 2.【必要】下载插件 > git clone https://gitee.com/kyrzy0416/rconsole-plugin.git ./plugins/rconsole-plugin/ @@ -56,67 +56,26 @@ sudo apt-get install ffmpeg # Windows 参考:https://www.jianshu.com/p/5015a477de3c ```` -## 🧑‍🌾 进阶 -【可选】备注:考虑到不是所有电脑都有mongodb,如果要开启`#我靠`功能,需要进行以下操作: +## 🧑‍🌾 【可选】进阶内容 +这个功能由[烦烦同学](https://github.com/nilfunc +)提出的需求,正好符合插件的宗旨`为朋友所写的功能`。在使用这个功能之前需要安装以下: +在Yunzai主目录使用以下命令 +> pnpm add mongoose -w -### 使用Python、Mongodb爬虫三次元图片 -首先去test文件跑python代码(要安装`requirements.txt`要求的依赖) -> python3 ./test/main.py +安装Mongodb(别看错了,下载`4.`版本): +> 官网地址:https://www.mongodb.com/try/download/community -需要把以下代码(apps/mystery.js)注释取消: -```javascript -// in apps/mystery.js +### 使用Mongoose进行自定义对话 +需要把代码(apps/rchat.js)注释取消(因为不是每个人都想装mongodb): +> 注释的地方例如:// import mongoose from "mongoose"; +> 取消注释快捷键:`ctrl + /` -// Mongodb初始化 -import mongodb from 'mongodb' - -// Mongodb初始化 -function initMongo () { - const MongoClient = mongodb.MongoClient - const url = 'mongodb://localhost:27017/' - return new Promise((resolve, reject) => { - MongoClient.connect(url, (err, db) => { - const dbo = db.db('test') - if (err) { - throw err // 和调用 reject(err) 效果类似 - } - let collection = dbo.collection('temp') - resolve(collection) - }) - }) -} - -const mongo = initMongo() -// ... -{ - reg: '^#我靠', fnc: 'tuiimg' -} -// ... -async tuiimg (e) { - const MAX_SIZE = this.mysteryConfig.tuiimg.count - this.reply('这群早晚被你整没了...') - let images = [] - const template = { - nickname: this.e.sender.card || this.e.user_id, user_id: this.e.user_id - } - await mongo.then(conn => { - return conn.aggregate([ { $sample: { size: MAX_SIZE } } ]).toArray() - }).then((result) => { - result.forEach((item) => { - images.push({ - message: segment.image(item.url), ...template - }) - }) - }) - return !!(await this.reply(await Bot.makeForwardMsg(images), false, { - recallMsg: recallTime - })) -} -``` - -> 备注: -> 1. linux/windows系统下自己装一个mongodb,上一个密码(不上有风险) -> 2. `test/main.py`爬取链接(要有python环境、配合mongodb使用) +### 进阶内容使用说明 +❓ 询问:@机器人 (问题) +➕增加问题:@机器人 add(问题) +❌删除问题:@机器人 del(问题) +⭕更新问题:@机器人 update(问题) +![help](./img/example6.png) ### 其他进阶操作 【可选】相关配置(apps/tools.js): diff --git a/apps/mystery.js b/apps/mystery.js index f4841e3..135e5e3 100644 --- a/apps/mystery.js +++ b/apps/mystery.js @@ -1,32 +1,10 @@ // 主库 import { segment } from "oicq"; -import common from "../../../lib/common/common.js"; import fetch from "node-fetch"; // 配置文件 import config from "../model/index.js"; // 其他库 import _ from "lodash"; -// import mongodb from 'mongodb' - -// Mongodb初始化 -// function initMongo () { -// const MongoClient = mongodb.MongoClient -// const url = 'mongodb://localhost:27017/' -// return new Promise((resolve, reject) => { -// MongoClient.connect(url, (err, db) => { -// const dbo = db.db('test') -// if (err) { -// throw err // 和调用 reject(err) 效果类似 -// } -// let collection = dbo.collection('temp') -// resolve(collection) -// }) -// }) -// } -// -// const mongo = initMongo() -// 60s后撤回 -const recallTime = 109; export class mystery extends plugin { constructor() { @@ -52,9 +30,6 @@ export class mystery extends plugin { reg: "^#(啊?|啊?)$", fnc: "aaa", }, - // { - // reg: '^#我靠', fnc: 'tuiimg' - // } ], }); this.mysteryConfig = config.getConfig("mystery"); @@ -271,27 +246,6 @@ export class mystery extends plugin { return true; } - // async tuiimg (e) { - // const MAX_SIZE = this.mysteryConfig.tuiimg.count - // this.reply('这群早晚被你整没了...') - // let images = [] - // const template = { - // nickname: this.e.sender.card || this.e.user_id, user_id: this.e.user_id - // } - // await mongo.then(conn => { - // return conn.aggregate([ { $sample: { size: MAX_SIZE } } ]).toArray() - // }).then((result) => { - // result.forEach((item) => { - // images.push({ - // message: segment.image(item.url), ...template - // }) - // }) - // }) - // return !!(await this.reply(await Bot.makeForwardMsg(images), false, { - // recallMsg: recallTime - // })) - // } - // 正则:获取图片 getCos6Img(string) { const imgRex = /\/([\w].*?).(jpg|JPG|png|PNG|gif|GIF|jpeg|JPEG|svg)/g; diff --git a/apps/rchat.js b/apps/rchat.js new file mode 100644 index 0000000..f2c6a90 --- /dev/null +++ b/apps/rchat.js @@ -0,0 +1,111 @@ +// import mongoose from "mongoose"; + +// mongoose.connect("mongodb://127.0.0.1:27017/rconsole"); +// const Chat = mongoose.model("chats", new mongoose.Schema({ q: String, ans: String })); + +export class rchat extends plugin { + constructor(e) { + super({ + name: "自定义回复", + dsc: "R插件插件自定义回复", + event: "message", + priority: 500, + rule: [ + // { + // reg: (e === undefined ? false : e.atme) + // ? "^[^add|del|update](.*)" + // : "#rchat(.*)", + // fnc: "queryChat", + // }, + // { + // reg: (e === undefined ? false : e.atme) ? "add(.*)" : "#rchat add(.*)", + // fnc: "addCustomContent", + // }, + // { + // reg: (e === undefined ? false : e.atme) ? "del(.*)" : "#rchat del(.*)", + // fnc: "delCustomContent", + // }, + // { + // reg: (e === undefined ? false : e.atme) ? "update(.*)" : "#rchat update(.*)", + // fnc: "updateCustomContent", + // }, + ], + }); + } + + // async queryChat(e) { + // // 获取到想要聊天的内容 + // const content = e.msg.trim(); + // // 模糊查询 + // await Chat.find({ q: new RegExp(content) }).then(res => { + // // 原答案 + // // console.log(res); + // for (let epoch of res) { + // if (epoch.q.trim() === content) { + // e.reply(epoch.ans); + // return true; + // } + // } + // // 回复最接近的结果 + // e.reply(res[0].ans); + // }); + // } + // + // async addCustomContent(e) { + // const q = /add*(.*)/.exec(e.msg)[1].trim(); + // await new Chat({ q, ans: "" }).save(); + // await e.reply(`问题:${q},需要怎么回答?`, false, { at: true }); + // this.setContext("addCustomAns"); + // } + // + // async addCustomAns() { + // // 如果不回复或者回复其他 + // if (!this.e.msg) { + // return true; + // } + // // 当前消息 + // const curMsg = this.e; + // // 上一个消息 + // const preMsg = this.getContext(); + // // console.log(preMsg) + // // console.log(preMsg.addCustomAns) + // const q = /add*(.*)/.exec(preMsg.addCustomAns.msg)[1].trim(); + // const ans = curMsg.msg.trim(); + // await Chat.updateOne({ q }, { ans }); + // this.finish("addCustomAns"); + // } + // + // async delCustomContent(e) { + // const removeContent = /del*(.*)/.exec(e.msg)[1].trim(); + // await Chat.deleteOne({ q: removeContent }).then(res => { + // e.reply(`已经删除${removeContent}`); + // }); + // return true; + // } + // + // async updateCustomContent(e) { + // const updateContent = /update*(.*)/.exec(e.msg)[1].trim(); + // await Chat.findOne({ q: updateContent }).then(res => { + // e.reply(`我觉得:${res.q},应该回答${res.ans},你觉得我该怎么回答?`); + // }); + // this.setContext("updateCustomAns"); + // return true; + // } + // + // async updateCustomAns() { + // // 如果不回复或者回复其他 + // if (!this.e.msg) { + // return true; + // } + // // 当前消息 + // const curMsg = this.e; + // // 上一个消息 + // const preMsg = this.getContext(); + // const q = /update*(.*)/.exec(preMsg.updateCustomAns.msg)[1].trim(); + // const ans = curMsg.msg.trim(); + // await Chat.findOneAndUpdate({ q }, { $set: { ans } }).then(res => { + // curMsg.reply(`明白了,${q},应该回答${ans}`); + // }); + // this.finish("updateCustomAns"); + // } +} diff --git a/apps/tools.js b/apps/tools.js index de7ba7a..2919325 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -12,13 +12,12 @@ import HttpProxyAgent from "https-proxy-agent"; import { mkdirsSync } from "../utils/file.js"; import { downloadBFile, getDownloadUrl, mergeFileToMp4, getDynamic } from "../utils/bilibili.js"; import { parseUrl, parseM3u8, downloadM3u8Videos, mergeAcFileToMp4 } from "../utils/acfun.js"; -import { transMap, douyinTypeMap } from "../utils/constant.js" +import { transMap, douyinTypeMap } from "../utils/constant.js"; import { retry } from "../utils/common.js"; import config from "../model/index.js"; - export class tools extends plugin { - constructor () { + constructor() { super({ name: "工具和学习类", dsc: "工具相关指令", @@ -63,8 +62,8 @@ export class tools extends plugin { }, { reg: "(.*)(doi.org)", - fnc: "literature" - } + fnc: "literature", + }, ], }); // http://api.tuwei.space/girl @@ -73,12 +72,12 @@ export class tools extends plugin { // 视频保存路径 this.defaultPath = this.toolsConfig.defaultPath; // redis的key - this.redisKey = `Yz:tools:cache:${ this.group_id }`; + this.redisKey = `Yz:tools:cache:${this.group_id}`; // 代理接口 // TODO 填写服务器的内网ID和clash的端口 this.proxyAddr = this.toolsConfig.proxyAddr; this.proxyPort = this.toolsConfig.proxyPort; - this.myProxy = `http://${ this.proxyAddr }:${ this.proxyPort }`; + this.myProxy = `http://${this.proxyAddr}:${this.proxyPort}`; // console.log(this.myProxy) // 加载百度翻译配置 this.translateAppId = this.toolsConfig.translateAppId; @@ -88,7 +87,7 @@ export class tools extends plugin { } // 翻译插件 - async trans (e) { + async trans(e) { const languageReg = /翻(.)/g; const msg = e.msg.trim(); const language = languageReg.exec(msg); @@ -103,20 +102,20 @@ export class tools extends plugin { // let url = `http://api.fanyi.baidu.com/api/trans/vip/translate?from=auto&to=${ transMap[language[1]] }&appid=APP ID&salt=自定义&sign=${ md5("APP ID" + place + "自定义" + "密钥") }&q=${ place }`; let url = `http://api.fanyi.baidu.com/api/trans/vip/translate?from=auto&to=${ transMap[language[1]] - }&appid=${ this.translateAppId }&salt=rconsole&sign=${ md5( + }&appid=${this.translateAppId}&salt=rconsole&sign=${md5( this.translateAppId + place + "rconsole" + this.translateSecret - ) }&q=${ place }`; + )}&q=${place}`; // console.log(url) await fetch(url) .then(resp => resp.json()) .then(text => text.trans_result) - .then(res => this.reply(`${ res[0].dst }`, true)) + .then(res => this.reply(`${res[0].dst}`, true)) .catch(err => logger.error(err)); return true; } // 抖音解析 - async douyin (e) { + async douyin(e) { const urlRex = /(http:|https:)\/\/v.douyin.com\/[A-Za-z\d._?%&+\-=\/#]*/g; const douUrl = urlRex.exec(e.msg.trim())[0]; @@ -124,15 +123,15 @@ export class tools extends plugin { const douRex = /.*video\/(\d+)\/(.*?)/g; const douId = douRex.exec(res)[1]; // const url = `https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=${ douId }`; - const url = `https://www.iesdouyin.com/aweme/v1/web/aweme/detail/?aweme_id=${ douId }&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333`; + const url = `https://www.iesdouyin.com/aweme/v1/web/aweme/detail/?aweme_id=${douId}&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333`; // 默认重试3次,每次间隔1s (防止SyntaxError: Unexpected token b in JSON at position 0) retry( - await (function () { - return fetch(url).then(resp => resp.json()) - }) + await function () { + return fetch(url).then(resp => resp.json()); + } ).then(async resp_json => { const item = resp_json.aweme_detail; - e.reply(`识别:抖音, ${ item.desc }`); + e.reply(`识别:抖音, ${item.desc}`); const url_type_code = item.aweme_type; const url_type = douyinTypeMap[url_type_code]; if (url_type === "video") { @@ -140,7 +139,7 @@ export class tools extends plugin { this.downloadVideo(url_2).then(video => { e.reply( segment.video( - `${ this.defaultPath }${ this.e.group_id || this.e.user_id }/temp.mp4` + `${this.defaultPath}${this.e.group_id || this.e.user_id}/temp.mp4` ) ); }); @@ -155,21 +154,21 @@ export class tools extends plugin { message: segment.image(i.url_list[0]), nickname: this.e.sender.card || this.e.user_id, user_id: this.e.user_id, - }) + }); // 有水印图片列表 // watermark_image_list.push(i.download_url_list[0]); // e.reply(segment.image(i.url_list[0])); } // console.log(no_watermark_image_list) - await this.reply(await Bot.makeForwardMsg(no_watermark_image_list)) + await this.reply(await Bot.makeForwardMsg(no_watermark_image_list)); } - }) + }); }); return true; } // tiktok解析 - async tiktok (e) { + async tiktok(e) { const urlRex = /(http:|https:)\/\/www.tiktok.com\/[A-Za-z\d._?%&+\-=\/#@]*/g; const urlShortRex = /(http:|https:)\/\/vt.tiktok.com\/[A-Za-z\d._?%&+\-=\/#]*/g; let url = e.msg.trim(); @@ -189,7 +188,7 @@ export class tools extends plugin { } const idVideo = await this.getIdVideo(url); // API链接 - const API_URL = `https://api16-normal-c-useast1a.tiktokv.com/aweme/v1/feed/?aweme_id=${ idVideo }&version_code=262&app_name=musical_ly&channel=App&device_id=null&os_version=14.4.2&device_platform=iphone&device_type=iPhone9`; + const API_URL = `https://api16-normal-c-useast1a.tiktokv.com/aweme/v1/feed/?aweme_id=${idVideo}&version_code=262&app_name=musical_ly&channel=App&device_id=null&os_version=14.4.2&device_platform=iphone&device_type=iPhone9`; await axios .get(API_URL, { @@ -210,11 +209,11 @@ export class tools extends plugin { }) .then(resp => { const data = resp.data.aweme_list[0]; - e.reply(`识别:tiktok, ${ data.desc }`); + e.reply(`识别:tiktok, ${data.desc}`); this.downloadVideo(data.video.play_addr.url_list[0], true).then(video => { e.reply( segment.video( - `${ this.defaultPath }${ this.e.group_id || this.e.user_id }/temp.mp4` + `${this.defaultPath}${this.e.group_id || this.e.user_id}/temp.mp4` ) ); }); @@ -223,7 +222,7 @@ export class tools extends plugin { } // bilibi解析 - async bili (e) { + async bili(e) { const urlRex = /(http:|https:)\/\/www.bilibili.com\/[A-Za-z\d._?%&+\-=\/#]*/g; const bShortRex = /(http:|https:)\/\/b23.tv\/[A-Za-z\d._?%&+\-=\/#]*/g; let url = e.msg.trim(); @@ -247,7 +246,7 @@ export class tools extends plugin { // console.log(dynamicId) getDynamic(dynamicId).then(resp => { if (resp.dynamicSrc.length > 0) { - e.reply(`识别:哔哩哔哩动态, ${ resp.dynamicDesc }`); + e.reply(`识别:哔哩哔哩动态, ${resp.dynamicDesc}`); // let dynamicSrcMsg = [] // resp.dynamicSrc.forEach(item => { // dynamicSrcMsg.push({ @@ -266,7 +265,7 @@ export class tools extends plugin { return true; } - const path = `${ this.defaultPath }${ this.e.group_id || this.e.user_id }/`; + const path = `${this.defaultPath}${this.e.group_id || this.e.user_id}/`; if (!fs.existsSync(path)) { mkdirsSync(path); } @@ -278,12 +277,12 @@ export class tools extends plugin { // 获取视频信息,然后发送 fetch( videoId.startsWith("BV") - ? `${ baseVideoInfo }?bvid=${ videoId }` - : `${ baseVideoInfo }?aid=${ videoId }` + ? `${baseVideoInfo}?bvid=${videoId}` + : `${baseVideoInfo}?aid=${videoId}` ) .then(resp => resp.json()) .then(resp => { - e.reply(`识别:哔哩哔哩, ${ resp.data.title }`).catch(err => { + e.reply(`识别:哔哩哔哩, ${resp.data.title}`).catch(err => { e.reply("解析失败,重试一下"); console.log(err); }); @@ -292,9 +291,9 @@ export class tools extends plugin { await getDownloadUrl(url) .then(data => { - this.downBili(`${ path }temp`, data.videoUrl, data.audioUrl) + this.downBili(`${path}temp`, data.videoUrl, data.audioUrl) .then(data => { - e.reply(segment.video(`${ path }temp.mp4`)); + e.reply(segment.video(`${path}temp.mp4`)); }) .catch(err => { console.log(err); @@ -309,9 +308,9 @@ export class tools extends plugin { } // 百科 - async wiki (e) { + async wiki(e) { const key = e.msg.replace(/#|百科|wiki/g, "").trim(); - const url = `https://xiaoapi.cn/API/bk.php?m=json&type=sg&msg=${ encodeURI(key) }`; + const url = `https://xiaoapi.cn/API/bk.php?m=json&type=sg&msg=${encodeURI(key)}`; // const url2 = 'https://api.jikipedia.com/go/auto_complete' Promise.all([ // axios.post(url2, { @@ -345,8 +344,8 @@ export class tools extends plugin { const data = res[0]; // const data2 = res[0] const template = ` - 解释:${ _.get(data, "msg") }\n - 详情:${ _.get(data, "more") }\n + 解释:${_.get(data, "msg")}\n + 详情:${_.get(data, "more")}\n `; // 小鸡解释:${ _.get(data2, 'content') } e.reply(template); @@ -356,7 +355,7 @@ export class tools extends plugin { // 小蓝鸟解析 // 例子:https://twitter.com/chonkyanimalx/status/1595834168000204800 - async twitter (e) { + async twitter(e) { // 配置参数及解析 const reg = /https?:\/\/twitter.com\/[0-9-a-zA-Z_]{1,20}\/status\/([0-9]*)/; const twitterUrl = reg.exec(e.msg); @@ -371,11 +370,11 @@ export class tools extends plugin { .singleTweet(id, { "media.fields": "duration_ms,height,media_key,preview_image_url,public_metrics,type,url,width,alt_text,variants", - expansions: [ "entities.mentions.username", "attachments.media_keys" ], + expansions: ["entities.mentions.username", "attachments.media_keys"], }) .then(resp => { - e.reply(`识别:小蓝鸟学习版,${ resp.data.text }`); - const downloadPath = `${ this.defaultPath }${ this.e.group_id || this.e.user_id }`; + e.reply(`识别:小蓝鸟学习版,${resp.data.text}`); + const downloadPath = `${this.defaultPath}${this.e.group_id || this.e.user_id}`; // 创建文件夹(如果没有过这个群) if (!fs.existsSync(downloadPath)) { mkdirsSync(downloadPath); @@ -384,15 +383,15 @@ export class tools extends plugin { for (let item of resp.includes.media) { if (item.type === "photo") { // 图片 - const filePath = `${ downloadPath }/${ item.url.split("/").pop() }`; + const filePath = `${downloadPath}/${item.url.split("/").pop()}`; this.downloadImg(item.url, downloadPath).then(_ => { e.reply(segment.image(fs.readFileSync(filePath))); - fs.unlinkSync(filePath) + fs.unlinkSync(filePath); }); } else if (item.type === "video") { // 视频 this.downloadVideo(resp.includes.media[0].variants[0].url, true).then(_ => { - e.reply(segment.video(`${ downloadPath }/temp.mp4`)); + e.reply(segment.video(`${downloadPath}/temp.mp4`)); }); } } @@ -401,9 +400,9 @@ export class tools extends plugin { } // 视频解析 - async tx (e) { + async tx(e) { const url = e.msg; - const data = await (await fetch(`https://xian.txma.cn/API/jx_txjx.php?url=${ url }`)).json(); + const data = await (await fetch(`https://xian.txma.cn/API/jx_txjx.php?url=${url}`)).json(); const k = data.url; const name = data.title; if (k && name) { @@ -420,7 +419,7 @@ export class tools extends plugin { } // 请求参数 - async douyinRequest (url) { + async douyinRequest(url) { const params = { headers: { "User-Agent": @@ -442,12 +441,12 @@ export class tools extends plugin { } // 工具:根URL据下载视频 / 音频 - async downloadVideo (url, isProxy = false) { - const groupPath = `${ this.defaultPath }${ this.e.group_id || this.e.user_id }`; + async downloadVideo(url, isProxy = false) { + const groupPath = `${this.defaultPath}${this.e.group_id || this.e.user_id}`; if (!fs.existsSync(groupPath)) { mkdirsSync(groupPath); } - const target = `${ groupPath }/temp.mp4`; + const target = `${groupPath}/temp.mp4`; // 待优化 if (fs.existsSync(target)) { console.log(`视频已存在`); @@ -477,7 +476,7 @@ export class tools extends plugin { }), }); } - console.log(`开始下载: ${ url }`); + console.log(`开始下载: ${url}`); const writer = fs.createWriteStream(target); res.data.pipe(writer); @@ -488,7 +487,7 @@ export class tools extends plugin { } // 工具:找到tiktok的视频id - async getIdVideo (url) { + async getIdVideo(url) { const matching = url.includes("/video/"); if (!matching) { this.e.reply("没找到,正在获取随机视频!"); @@ -499,8 +498,8 @@ export class tools extends plugin { } // acfun解析 - async acfun (e) { - const path = `${ this.defaultPath }${ this.e.group_id || this.e.user_id }/temp/`; + async acfun(e) { + const path = `${this.defaultPath}${this.e.group_id || this.e.user_id}/temp/`; if (!fs.existsSync(path)) { mkdirsSync(path); } @@ -508,15 +507,15 @@ export class tools extends plugin { let inputMsg = e.msg; // 适配手机分享:https://m.acfun.cn/v/?ac=32838812&sid=d2b0991bd6ad9c09 if (inputMsg.includes("m.acfun.cn")) { - inputMsg = `https://www.acfun.cn/v/ac${ /ac=([^&?]*)/.exec(inputMsg)[1] }`; + inputMsg = `https://www.acfun.cn/v/ac${/ac=([^&?]*)/.exec(inputMsg)[1]}`; } parseUrl(inputMsg).then(res => { - e.reply(`识别:猴山,${ res.videoName }`); + e.reply(`识别:猴山,${res.videoName}`); parseM3u8(res.urlM3u8s[res.urlM3u8s.length - 1]).then(res2 => { downloadM3u8Videos(res2.m3u8FullUrls, path).then(_ => { - mergeAcFileToMp4(res2.tsNames, path, `${ path }out.mp4`).then(_ => { - e.reply(segment.video(`${ path }out.mp4`)); + mergeAcFileToMp4(res2.tsNames, path, `${path}out.mp4`).then(_ => { + e.reply(segment.video(`${path}out.mp4`)); }); }); }); @@ -525,11 +524,11 @@ export class tools extends plugin { } // 小红书解析 - async redbook (e) { + async redbook(e) { const msgUrl = /(http:|https:)\/\/(xhslink|xiaohongshu).com\/[A-Za-z\d._?%&+\-=\/#@]*/.exec( e.msg )[0]; - const url = `https://dlpanda.com/zh-CN/xhs?url=${ msgUrl }`; + const url = `https://dlpanda.com/zh-CN/xhs?url=${msgUrl}`; await axios .get(url, { @@ -546,13 +545,13 @@ export class tools extends plugin { const reg = / { - const filepath = `${ downloadPath }/${ /com\/(.*)\?/.exec(addr)[1] }.jpg`; + const filepath = `${downloadPath}/${/com\/(.*)\?/.exec(addr)[1]}.jpg`; const writer = fs.createWriteStream(filepath); resp.data.pipe(writer); return new Promise((resolve, reject) => { @@ -581,8 +580,8 @@ export class tools extends plugin { } // 文献解析 - async literature (e) { - const litReg = /(http:|https:)\/\/doi.org\/[A-Za-z\d._?%&+\-=\/#@]*/ + async literature(e) { + const litReg = /(http:|https:)\/\/doi.org\/[A-Za-z\d._?%&+\-=\/#@]*/; const url = litReg.exec(e.msg.trim())[0]; const waitList = [ "https://sci-hub.se/", @@ -594,15 +593,15 @@ export class tools extends plugin { "https://sci-hub.ru/", ]; const flag = /doi.org\/(.*)/.exec(url)[1]; - const newWaitList = waitList.map((item) => { + const newWaitList = waitList.map(item => { return item + flag; }); await Promise.race(newWaitList).then(resp => { - e.reply(resp) - }) + e.reply(resp); + }); } - async downBili (title, videoUrl, audioUrl) { + async downBili(title, videoUrl, audioUrl) { return Promise.all([ downloadBFile( videoUrl, @@ -634,9 +633,9 @@ export class tools extends plugin { } // 工具:下载一张网络图片 - async downloadImg (img, dir) { + async downloadImg(img, dir) { const filename = img.split("/").pop(); - const filepath = `${ dir }/${ filename }`; + const filepath = `${dir}/${filename}`; const writer = fs.createWriteStream(filepath); return axios .get(img, { @@ -660,7 +659,7 @@ export class tools extends plugin { resolve(filepath); }); }); - writer.on("error", (err) => { + writer.on("error", err => { fs.unlink(filepath, () => { reject(err); }); @@ -670,7 +669,7 @@ export class tools extends plugin { } // 工具:下载pdf文件 - async downloadPDF (url, filename) { + async downloadPDF(url, filename) { return axios({ url: url, responseType: "stream", @@ -678,7 +677,7 @@ export class tools extends plugin { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36", }, - }).then((response) => { + }).then(response => { const writer = fs.createWriteStream(filename); response.data.pipe(writer); return new Promise((resolve, reject) => { diff --git a/config/help.yaml b/config/help.yaml index 50ce1bd..fc0ffc2 100644 --- a/config/help.yaml +++ b/config/help.yaml @@ -33,8 +33,8 @@ title: "#啊?" desc: 啊? - icon: pic5 - title: "#我靠" - desc: 神秘的芒果 + title: "@" + desc: 自定义对话 - group: 工具类合集 list: - icon: translate diff --git a/config/version.yaml b/config/version.yaml index a13819f..cb6ab07 100644 --- a/config/version.yaml +++ b/config/version.yaml @@ -1,13 +1,12 @@ - { - version: 1.0.6, + version: 1.0.7, data: [ + 增加自定义对话进阶功能, 增加SCI论文解析, 适配锅巴插件,方便查看和修改配置, 增加小红书的图片解析, 添加#R帮助获取插件帮助, 添加#R版本获取插件版本, - 更新风控缓解、重构系统文件、增加部分接口撤回操作 - 添加抖音实时监听分享链接, ], } \ No newline at end of file diff --git a/img/example6.png b/img/example6.png new file mode 100644 index 0000000..09429cc Binary files /dev/null and b/img/example6.png differ diff --git a/resources/img/icon/pic4.png b/resources/img/icon/pic4.png index 680f0df..cdc9b67 100644 Binary files a/resources/img/icon/pic4.png and b/resources/img/icon/pic4.png differ diff --git a/resources/img/icon/pic5.png b/resources/img/icon/pic5.png index cdc9b67..616236e 100644 Binary files a/resources/img/icon/pic5.png and b/resources/img/icon/pic5.png differ