diff --git a/apps/cat.js b/apps/cat.js index 3a0642a..654aae5 100644 --- a/apps/cat.js +++ b/apps/cat.js @@ -23,7 +23,7 @@ export class cat extends plugin { async cat (e) { const numb = this.catConfig.count let images = [] - let reqRes = [...await fetch(`https://shibe.online/api/cats?count=${numb}`).then(data => data.json()), ...await fetch(`https://api.thecatapi.com/v1/images/search?limit=${numb}`).then(data => data.json()).then(json => json.map(item => item.url))] + let reqRes = [ ...await fetch(`https://shibe.online/api/cats?count=${ numb }`).then(data => data.json()), ...await fetch(`https://api.thecatapi.com/v1/images/search?limit=${ numb }`).then(data => data.json()).then(json => json.map(item => item.url)) ] e.reply('涩图也不看了,就看猫是吧, 探索中...') reqRes.forEach(item => { images.push({ diff --git a/apps/doctor.js b/apps/doctor.js index 5d4cace..f79c487 100644 --- a/apps/doctor.js +++ b/apps/doctor.js @@ -22,7 +22,7 @@ export class doctor extends plugin { async doctor (e) { let keyword = e.msg.split(' ')[1] - const url = `https://api2.dayi.org.cn/api/search2?keyword=${keyword}&pageNo=1&pageSize=10` + const url = `https://api2.dayi.org.cn/api/search2?keyword=${ keyword }&pageNo=1&pageSize=10` let res = await fetch(url) .then((resp) => resp.json()) .then((resp) => resp.list) @@ -30,15 +30,15 @@ export class doctor extends plugin { for (const element of res) { const title = this.removeTag(element.title) const template = ` - ${title}\n - 标签:${element.secondTitle}\n - 介绍:${element.introduction} + ${ title }\n + 标签:${ element.secondTitle }\n + 介绍:${ element.introduction } ` // 如果完全匹配,直接响应页面 if (title === keyword) { const browser = await puppeteer.browserInit() const page = await browser.newPage() - await page.goto(`https://www.dayi.org.cn/drug/${element.id}`) + await page.goto(`https://www.dayi.org.cn/drug/${ element.id }`) let buff = await page.screenshot({ fullPage: true, type: 'jpeg', omitBackground: false, quality: 90 }) @@ -46,7 +46,7 @@ export class doctor extends plugin { await e.reply(segment.image(buff)) } msg.push({ - message: { type: 'text', text: `${template}` }, nickname: Bot.nickname, user_id: Bot.uin + message: { type: 'text', text: `${ template }` }, nickname: Bot.nickname, user_id: Bot.uin }) } /** 最后回复消息 */ diff --git a/apps/help.js b/apps/help.js index 14ffd0f..46f57ed 100644 --- a/apps/help.js +++ b/apps/help.js @@ -3,44 +3,44 @@ import puppeteer from '../../../lib/puppeteer/puppeteer.js' import md5 from 'md5' let helpData = { - md5: '', - img: '' + md5: '', + img: '' } export class help extends plugin { - constructor (e) { - super({ - name: 'rconsole插件帮助', - dsc: 'rconsole插件帮助插件帮助', - event: 'message', - priority: 500, - rule: [ - { - reg: '^#*R(插件)?(命令|帮助|菜单|help|说明|功能|指令|使用说明)$', - fnc: 'help' - } - ] - }) - } + constructor (e) { + super({ + name: 'rconsole插件帮助', + dsc: 'rconsole插件帮助插件帮助', + event: 'message', + priority: 500, + rule: [ + { + reg: '^#*R(插件)?(命令|帮助|菜单|help|说明|功能|指令|使用说明)$', + fnc: 'help' + } + ] + }) + } - /** - * rule - 闲心插件帮助 - * @returns - */ - async help () { - let data = await Help.get(this.e) - if (!data) return - let img = await this.cache(data) - await this.reply(img) - } + /** + * rule - 闲心插件帮助 + * @returns + */ + async help () { + let data = await Help.get(this.e) + if (!data) return + let img = await this.cache(data) + await this.reply(img) + } - async cache (data) { - let tmp = md5(JSON.stringify(data)) - if (helpData.md5 == tmp) return helpData.img + async cache (data) { + let tmp = md5(JSON.stringify(data)) + if (helpData.md5 == tmp) return helpData.img - helpData.img = await puppeteer.screenshot('help', data) - helpData.md5 = tmp + helpData.img = await puppeteer.screenshot('help', data) + helpData.md5 = tmp - return helpData.img - } + return helpData.img + } } diff --git a/apps/hotSearch.js b/apps/hotSearch.js index 5d43628..ba69a03 100644 --- a/apps/hotSearch.js +++ b/apps/hotSearch.js @@ -68,13 +68,13 @@ export class hotSearch extends plugin { .catch((err) => logger.error(err)) res.forEach((element) => { const template = ` - 标题:${element.title}\n - 简介:${_.isNull(element.desc) ? '' : element.desc}\n - 热度:${element.hot}\n - 访问详情:${element.url}\n + 标题:${ element.title }\n + 简介:${ _.isNull(element.desc) ? '' : element.desc }\n + 热度:${ element.hot }\n + 访问详情:${ element.url }\n ` msg.push({ - message: { type: 'text', text: `${template}` }, nickname: Bot.nickname, user_id: Bot.uin + message: { type: 'text', text: `${ template }` }, nickname: Bot.nickname, user_id: Bot.uin }) }) return !!this.reply(await Bot.makeForwardMsg(msg)) diff --git a/apps/mystery.js b/apps/mystery.js index 44a9c41..3cf5c42 100644 --- a/apps/mystery.js +++ b/apps/mystery.js @@ -23,6 +23,7 @@ function initMongo () { }) }) } + const mongo = initMongo() // 60s后撤回 const recallTime = 109 @@ -61,7 +62,7 @@ export class mystery extends plugin { this.e.reply = async function (msgs, quote, data) { if (!msgs) return false - if (!Array.isArray(msgs)) msgs = [msgs] + if (!Array.isArray(msgs)) msgs = [ msgs ] let result = await oldReply(msgs, quote, data) if (!result || !result.message_id) { @@ -77,9 +78,9 @@ export class mystery extends plugin { if (isxml) { result = await oldReply(msgs, quote, data) } else { - let MsgList = [{ + let MsgList = [ { message: msgs, nickname: Bot.nickname, user_id: Bot.uin - }] + } ] let forwardMsg = await Bot.makeForwardMsg(MsgList) @@ -114,7 +115,7 @@ export class mystery extends plugin { // 请求 let images = [] let imgData = [] - let url = `https://www.cos6.net/wp-json/wp/v2/posts?page=${page}` + let url = `https://www.cos6.net/wp-json/wp/v2/posts?page=${ page }` await fetch(url) .then((resp) => { return resp.json() @@ -151,7 +152,7 @@ export class mystery extends plugin { } async cospro (e) { - let req = [...await fetch('https://imgapi.cn/cos2.php?return=jsonpro').then((resp) => resp.json()).then((json) => json.imgurls), ...await fetch('https://imgapi.cn/cos.php?return=jsonpro').then((resp) => resp.json()).then((json) => json.imgurls)] + let req = [ ...await fetch('https://imgapi.cn/cos2.php?return=jsonpro').then((resp) => resp.json()).then((json) => json.imgurls), ...await fetch('https://imgapi.cn/cos.php?return=jsonpro').then((resp) => resp.json()).then((json) => json.imgurls) ] e.reply('哪天克火掉一定是在这个群里面...') let images = [] req.forEach(item => { @@ -179,7 +180,7 @@ export class mystery extends plugin { // 请求 let images = [] let imgData = [] - let url = `https://yingtall.com/wp-json/wp/v2/posts?page=${page}` + let url = `https://yingtall.com/wp-json/wp/v2/posts?page=${ page }` await fetch(url) .then((resp) => { return resp.json() @@ -219,7 +220,7 @@ export class mystery extends plugin { async setu (e) { const numb = this.mysteryConfig.setu.count // 图源 - const urlList = ['https://iw233.cn/api.php?sort=random', 'https://iw233.cn/API/Random.php'] + const urlList = [ 'https://iw233.cn/api.php?sort=random', 'https://iw233.cn/API/Random.php' ] e.reply('探索中...') let images = [] for (let i = numb; i > 0; i--) { @@ -241,7 +242,7 @@ export class mystery extends plugin { 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() + return conn.aggregate([ { $sample: { size: MAX_SIZE } } ]).toArray() }).then((result) => { result.forEach((item) => { images.push({ diff --git a/apps/recommend.js b/apps/recommend.js index a0b15f0..6211990 100644 --- a/apps/recommend.js +++ b/apps/recommend.js @@ -30,9 +30,9 @@ export class recommend extends plugin { res = await res.json() let msg = [] res.data.list.forEach((element) => { - const template = `推荐软件:${element.title}\n地址:${element.url}\n` + const template = `推荐软件:${ element.title }\n地址:${ element.url }\n` msg.push({ - message: { type: 'text', text: `${template}` }, nickname: Bot.nickname, user_id: Bot.uin + message: { type: 'text', text: `${ template }` }, nickname: Bot.nickname, user_id: Bot.uin }) }) /** 最后回复消息 */ @@ -45,9 +45,9 @@ export class recommend extends plugin { res = await res.json() let msg = [] res.data.list.forEach((element) => { - const template = `推荐软件:${element.title}\n地址:${element.url}\n` + const template = `推荐软件:${ element.title }\n地址:${ element.url }\n` msg.push({ - message: { type: 'text', text: `${template}` }, nickname: Bot.nickname, user_id: Bot.uin + message: { type: 'text', text: `${ template }` }, nickname: Bot.nickname, user_id: Bot.uin }) }) return !!this.reply(await Bot.makeForwardMsg(msg)) diff --git a/apps/tools.js b/apps/tools.js index 2efd4a9..4190cf0 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -1,14 +1,14 @@ // 主库 import fetch from "node-fetch"; import fs from "node:fs"; -import {segment} from "oicq"; +import { segment } from "oicq"; // 其他库 import md5 from "md5"; import axios from "axios"; import path from 'path' export class tools extends plugin { - constructor() { + constructor () { super({ name: "工具和学习类", dsc: "工具相关指令", @@ -33,25 +33,25 @@ export class tools extends plugin { } // 翻译插件 - async trans(e) { + async trans (e) { let place = e.msg.replace(/#|翻译/g, "").trim(); let url = /[\u4E00-\u9FFF]+/g.test(place) - ? `http://api.fanyi.baidu.com/api/trans/vip/translate?from=zh&to=en&appid=20210422000794040&salt=542716863&sign=${md5( + ? `http://api.fanyi.baidu.com/api/trans/vip/translate?from=zh&to=en&appid=20210422000794040&salt=542716863&sign=${ md5( "20210422000794040" + place + "542716863" + "HooD_ndgwcGH6SAnxGrM" - )}&q=${place}` - : `http://api.fanyi.baidu.com/api/trans/vip/translate?from=en&to=zh&appid=20210422000794040&salt=542716863&sign=${md5( + ) }&q=${ place }` + : `http://api.fanyi.baidu.com/api/trans/vip/translate?from=en&to=zh&appid=20210422000794040&salt=542716863&sign=${ md5( "20210422000794040" + place + "542716863" + "HooD_ndgwcGH6SAnxGrM" - )}&q=${place}`; + ) }&q=${ place }`; 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]; e.reply("识别:抖音, 解析中..."); @@ -59,14 +59,14 @@ export class tools extends plugin { await this.douyinRequest(douUrl).then((res) => { 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/web/api/v2/aweme/iteminfo/?item_ids=${ douId }`; return fetch(url) .then((resp) => resp.json()) .then((json) => json.item_list[0]) .then((item) => item.video.play_addr.url_list[0]) .then((url) => { this.downloadVideo(url).then(video => { - e.reply(segment.video(`${this.defaultPath}${this.e.group_id || this.e.user_id}/temp.mp4`)); + e.reply(segment.video(`${ this.defaultPath }${ this.e.group_id || this.e.user_id }/temp.mp4`)); }) }); }); @@ -74,24 +74,24 @@ export class tools extends plugin { } // tiktok解析 - async tiktok(e) { + async tiktok (e) { const urlRex = /(http:|https:)\/\/www.tiktok.com\/[A-Za-z\d._?%&+\-=\/#]*/g; const url = urlRex.exec(e.msg.trim())[0] - const tiktokApi = `https://api.douyin.wtf/api?url=${url}&minimal=true` + const tiktokApi = `https://api.douyin.wtf/api?url=${ url }&minimal=true` e.reply("识别:tiktok, 解析中..."); fetch(tiktokApi) .then(resp => resp.json()) .then(json => { this.downloadVideo(json.wm_video_url.replace("https", "http")).then(video => { - e.reply(segment.video(`${this.defaultPath}${this.e.group_id || this.e.user_id}/temp.mp4`)) + e.reply(segment.video(`${ this.defaultPath }${ this.e.group_id || this.e.user_id }/temp.mp4`)) }) }) return true } // 请求参数 - async douyinRequest(url) { + async douyinRequest (url) { const params = { headers: { "User-Agent": @@ -113,11 +113,11 @@ export class tools extends plugin { } // 根URL据下载视频 / 音频 - async downloadVideo(url) { + async downloadVideo (url) { if (!fs.existsSync(this.defaultPath)) { this.mkdirsSync(this.defaultPath); } - const target = this.defaultPath + `${this.e.group_id || this.e.user_id}/temp.mp4` + const target = this.defaultPath + `${ this.e.group_id || this.e.user_id }/temp.mp4` // 待优化 if (fs.existsSync(target)) { console.log(`视频已存在`); @@ -130,7 +130,7 @@ export class tools extends plugin { }, responseType: "stream", }); - console.log(`开始下载: ${url}`); + console.log(`开始下载: ${ url }`); const writer = fs.createWriteStream(target); res.data.pipe(writer); @@ -141,7 +141,7 @@ export class tools extends plugin { } // 同步递归创建文件夹 - mkdirsSync(dirname) { + mkdirsSync (dirname) { if (fs.existsSync(dirname)) { return true; } else { @@ -153,7 +153,7 @@ export class tools extends plugin { } // 递归创建目录 异步方法 - mkdirs(dirname, callback) { + mkdirs (dirname, callback) { fs.exists(dirname, function (exists) { if (exists) { callback();