mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🌈 style: 整理类别
This commit is contained in:
parent
1e8d806573
commit
3e19288ed8
35
apps/cat.js
35
apps/cat.js
@ -1,35 +0,0 @@
|
|||||||
// 主库
|
|
||||||
import { segment } from 'oicq'
|
|
||||||
import fetch from 'node-fetch'
|
|
||||||
// 配置文件库
|
|
||||||
import config from '../model/index.js'
|
|
||||||
|
|
||||||
export class cat extends plugin {
|
|
||||||
constructor () {
|
|
||||||
super({
|
|
||||||
name: '猫',
|
|
||||||
dsc: '猫相关指令',
|
|
||||||
event: 'message.group',
|
|
||||||
priority: 500,
|
|
||||||
rule: [
|
|
||||||
{
|
|
||||||
reg: '^#(cat)$', fnc: 'cat'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
this.catConfig = config.getConfig('cat')
|
|
||||||
}
|
|
||||||
|
|
||||||
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)) ]
|
|
||||||
e.reply('涩图也不看了,就看猫是吧, 探索中...')
|
|
||||||
reqRes.forEach(item => {
|
|
||||||
images.push({
|
|
||||||
message: segment.image(item), nickname: this.e.sender.card || this.e.user_id, user_id: this.e.user_id
|
|
||||||
})
|
|
||||||
})
|
|
||||||
return !!(await this.reply(await Bot.makeForwardMsg(images)))
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
// 主库
|
|
||||||
import { segment } from 'oicq'
|
|
||||||
import fetch from 'node-fetch'
|
|
||||||
// 爬虫库
|
|
||||||
import puppeteer from '../../../lib/puppeteer/puppeteer.js'
|
|
||||||
|
|
||||||
export class doctor extends plugin {
|
|
||||||
constructor () {
|
|
||||||
super({
|
|
||||||
name: '医药查询',
|
|
||||||
dsc: '医药相关指令',
|
|
||||||
event: 'message.group',
|
|
||||||
priority: 500,
|
|
||||||
rule: [
|
|
||||||
{
|
|
||||||
reg: '^#*医药查询 (.*)$',
|
|
||||||
fnc: 'doctor'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async doctor (e) {
|
|
||||||
let keyword = e.msg.split(' ')[1]
|
|
||||||
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)
|
|
||||||
let msg = []
|
|
||||||
for (const element of res) {
|
|
||||||
const title = this.removeTag(element.title)
|
|
||||||
const template = `
|
|
||||||
${ 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 }`)
|
|
||||||
let buff = await page.screenshot({
|
|
||||||
fullPage: true, type: 'jpeg', omitBackground: false, quality: 90
|
|
||||||
})
|
|
||||||
browser.close()
|
|
||||||
await e.reply(segment.image(buff))
|
|
||||||
}
|
|
||||||
msg.push({
|
|
||||||
message: { type: 'text', text: `${ template }` }, nickname: Bot.nickname, user_id: Bot.uin
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/** 最后回复消息 */
|
|
||||||
return !!this.reply(await Bot.makeForwardMsg(msg))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除标签
|
|
||||||
removeTag (title) {
|
|
||||||
const titleRex = /<[^>]+>/g
|
|
||||||
return title.replace(titleRex, '')
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
import _ from 'lodash'
|
|
||||||
import fetch from 'node-fetch'
|
|
||||||
|
|
||||||
export class hotSearch extends plugin {
|
|
||||||
constructor () {
|
|
||||||
super({
|
|
||||||
name: '热搜查询',
|
|
||||||
dsc: '热搜相关指令',
|
|
||||||
event: 'message.group',
|
|
||||||
priority: 500,
|
|
||||||
rule: [
|
|
||||||
{
|
|
||||||
reg: '^#(热搜)(.*)$', fnc: 'hotSearch'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async hotSearch (e) {
|
|
||||||
let keyword = e.msg.replace(/#|热搜/g, '').trim()
|
|
||||||
console.log(keyword)
|
|
||||||
// 虎扑/知乎/36氪/百度/哔哩哔哩/贴吧/微博/抖音/豆瓣/少数派/IT资讯/微信
|
|
||||||
let url = 'https://api.vvhan.com/api/hotlist?type='
|
|
||||||
switch (keyword) {
|
|
||||||
case '虎扑':
|
|
||||||
url += 'hupu'
|
|
||||||
break
|
|
||||||
case '知乎':
|
|
||||||
url += 'zhihuHot'
|
|
||||||
break
|
|
||||||
case '36氪':
|
|
||||||
url += '36Ke'
|
|
||||||
break
|
|
||||||
case '百度':
|
|
||||||
url += 'baiduRD'
|
|
||||||
break
|
|
||||||
case '哔哩哔哩':
|
|
||||||
url += 'bili'
|
|
||||||
break
|
|
||||||
case '贴吧':
|
|
||||||
url += 'baiduRY'
|
|
||||||
break
|
|
||||||
case '微博':
|
|
||||||
url += 'wbHot'
|
|
||||||
break
|
|
||||||
case '抖音':
|
|
||||||
url += 'douyinHot'
|
|
||||||
break
|
|
||||||
case '豆瓣':
|
|
||||||
url += 'douban'
|
|
||||||
break
|
|
||||||
case '少数派':
|
|
||||||
url += 'ssPai'
|
|
||||||
break
|
|
||||||
case 'IT资讯':
|
|
||||||
url += 'itInfo'
|
|
||||||
break
|
|
||||||
case '微信':
|
|
||||||
url += 'wxHot'
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
url += 'history'
|
|
||||||
break
|
|
||||||
}
|
|
||||||
let sendTemplate = {
|
|
||||||
nickname: this.e.sender.card || this.e.user_id, user_id: this.e.user_id
|
|
||||||
}
|
|
||||||
let msg = []
|
|
||||||
await fetch(url)
|
|
||||||
.then((resp) => resp.json())
|
|
||||||
.then((resp) => {
|
|
||||||
for (let element of resp.data) {
|
|
||||||
if (_.isUndefined(element)) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
const template = `
|
|
||||||
标题:${ _.isNull(element.title) ? '暂无' : element.title}\n
|
|
||||||
简介:${ _.isNull(element.desc) ? '暂无' : element.desc }\n
|
|
||||||
热度:${ _.isNull(element.hot) ? '暂无' : element.hot}\n
|
|
||||||
访问详情:${ _.isNull(element.url) ? '暂无' : element.url}\n
|
|
||||||
`;
|
|
||||||
msg.push({
|
|
||||||
message: { type: 'text', text: `${ template }` },
|
|
||||||
...sendTemplate
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((err) => logger.error(err))
|
|
||||||
return !!this.reply(await Bot.makeForwardMsg(msg))
|
|
||||||
}
|
|
||||||
}
|
|
199
apps/query.js
Normal file
199
apps/query.js
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
// 主库
|
||||||
|
import { segment } from 'oicq'
|
||||||
|
import fetch from 'node-fetch'
|
||||||
|
// 爬虫库
|
||||||
|
import puppeteer from '../../../lib/puppeteer/puppeteer.js'
|
||||||
|
import config from "../model";
|
||||||
|
import _ from 'lodash'
|
||||||
|
|
||||||
|
export class query extends plugin {
|
||||||
|
constructor () {
|
||||||
|
super({
|
||||||
|
name: '查询类',
|
||||||
|
dsc: '查询相关指令',
|
||||||
|
event: 'message.group',
|
||||||
|
priority: 500,
|
||||||
|
rule: [
|
||||||
|
{
|
||||||
|
reg: '^#*医药查询 (.*)$',
|
||||||
|
fnc: 'doctor'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
reg: '^#(cat)$',
|
||||||
|
fnc: 'cat'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
reg: '^#电脑软件推荐$', /** 执行方法 */
|
||||||
|
fnc: 'computerRecommended'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
reg: '^#安卓软件推荐$', /** 执行方法 */
|
||||||
|
fnc: 'androidRecommended'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
reg: '^#(热搜)(.*)$',
|
||||||
|
fnc: 'hotSearch'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
this.catConfig = config.getConfig('query')
|
||||||
|
}
|
||||||
|
|
||||||
|
async doctor (e) {
|
||||||
|
let keyword = e.msg.split(' ')[1]
|
||||||
|
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)
|
||||||
|
let msg = []
|
||||||
|
for (const element of res) {
|
||||||
|
const title = this.removeTag(element.title)
|
||||||
|
const template = `
|
||||||
|
${ 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 }`)
|
||||||
|
let buff = await page.screenshot({
|
||||||
|
fullPage: true, type: 'jpeg', omitBackground: false, quality: 90
|
||||||
|
})
|
||||||
|
browser.close()
|
||||||
|
await e.reply(segment.image(buff))
|
||||||
|
}
|
||||||
|
msg.push({
|
||||||
|
message: { type: 'text', text: `${ template }` }, nickname: Bot.nickname, user_id: Bot.uin
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/** 最后回复消息 */
|
||||||
|
return !!this.reply(await Bot.makeForwardMsg(msg))
|
||||||
|
}
|
||||||
|
|
||||||
|
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)) ]
|
||||||
|
e.reply('涩图也不看了,就看猫是吧, 探索中...')
|
||||||
|
reqRes.forEach(item => {
|
||||||
|
images.push({
|
||||||
|
message: segment.image(item), nickname: this.e.sender.card || this.e.user_id, user_id: this.e.user_id
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return !!(await this.reply(await Bot.makeForwardMsg(images)))
|
||||||
|
}
|
||||||
|
|
||||||
|
async computerRecommended (e) {
|
||||||
|
let url = 'https://www.ghxi.com/ghapi?type=query&n=pc'
|
||||||
|
/** 调用接口获取数据 */
|
||||||
|
let res = await fetch(url).catch((err) => logger.error(err))
|
||||||
|
|
||||||
|
/** 接口结果,json字符串转对象 */
|
||||||
|
res = await res.json()
|
||||||
|
let msg = []
|
||||||
|
res.data.list.forEach((element) => {
|
||||||
|
const template = `推荐软件:${ element.title }\n地址:${ element.url }\n`
|
||||||
|
msg.push({
|
||||||
|
message: { type: 'text', text: `${ template }` }, nickname: Bot.nickname, user_id: Bot.uin
|
||||||
|
})
|
||||||
|
})
|
||||||
|
/** 最后回复消息 */
|
||||||
|
return !!this.reply(await Bot.makeForwardMsg(msg))
|
||||||
|
}
|
||||||
|
|
||||||
|
async androidRecommended (e) {
|
||||||
|
let url = 'https://www.ghxi.com/ghapi?type=query&n=and'
|
||||||
|
let res = await fetch(url).catch((err) => logger.error(err))
|
||||||
|
res = await res.json()
|
||||||
|
let msg = []
|
||||||
|
res.data.list.forEach((element) => {
|
||||||
|
const template = `推荐软件:${ element.title }\n地址:${ element.url }\n`
|
||||||
|
msg.push({
|
||||||
|
message: { type: 'text', text: `${ template }` }, nickname: Bot.nickname, user_id: Bot.uin
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return !!this.reply(await Bot.makeForwardMsg(msg))
|
||||||
|
}
|
||||||
|
|
||||||
|
async hotSearch (e) {
|
||||||
|
let keyword = e.msg.replace(/#|热搜/g, '').trim()
|
||||||
|
console.log(keyword)
|
||||||
|
// 虎扑/知乎/36氪/百度/哔哩哔哩/贴吧/微博/抖音/豆瓣/少数派/IT资讯/微信
|
||||||
|
let url = 'https://api.vvhan.com/api/hotlist?type='
|
||||||
|
switch (keyword) {
|
||||||
|
case '虎扑':
|
||||||
|
url += 'hupu'
|
||||||
|
break
|
||||||
|
case '知乎':
|
||||||
|
url += 'zhihuHot'
|
||||||
|
break
|
||||||
|
case '36氪':
|
||||||
|
url += '36Ke'
|
||||||
|
break
|
||||||
|
case '百度':
|
||||||
|
url += 'baiduRD'
|
||||||
|
break
|
||||||
|
case '哔哩哔哩':
|
||||||
|
url += 'bili'
|
||||||
|
break
|
||||||
|
case '贴吧':
|
||||||
|
url += 'baiduRY'
|
||||||
|
break
|
||||||
|
case '微博':
|
||||||
|
url += 'wbHot'
|
||||||
|
break
|
||||||
|
case '抖音':
|
||||||
|
url += 'douyinHot'
|
||||||
|
break
|
||||||
|
case '豆瓣':
|
||||||
|
url += 'douban'
|
||||||
|
break
|
||||||
|
case '少数派':
|
||||||
|
url += 'ssPai'
|
||||||
|
break
|
||||||
|
case 'IT资讯':
|
||||||
|
url += 'itInfo'
|
||||||
|
break
|
||||||
|
case '微信':
|
||||||
|
url += 'wxHot'
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
url += 'history'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
let sendTemplate = {
|
||||||
|
nickname: this.e.sender.card || this.e.user_id, user_id: this.e.user_id
|
||||||
|
}
|
||||||
|
let msg = []
|
||||||
|
await fetch(url)
|
||||||
|
.then((resp) => resp.json())
|
||||||
|
.then((resp) => {
|
||||||
|
for (let element of resp.data) {
|
||||||
|
if (_.isUndefined(element)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const template = `
|
||||||
|
标题:${ _.isNull(element.title) ? '暂无' : element.title}\n
|
||||||
|
简介:${ _.isNull(element.desc) ? '暂无' : element.desc }\n
|
||||||
|
热度:${ _.isNull(element.hot) ? '暂无' : element.hot}\n
|
||||||
|
访问详情:${ _.isNull(element.url) ? '暂无' : element.url}\n
|
||||||
|
`;
|
||||||
|
msg.push({
|
||||||
|
message: { type: 'text', text: `${ template }` },
|
||||||
|
...sendTemplate
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => logger.error(err))
|
||||||
|
return !!this.reply(await Bot.makeForwardMsg(msg))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 删除标签
|
||||||
|
removeTag (title) {
|
||||||
|
const titleRex = /<[^>]+>/g
|
||||||
|
return title.replace(titleRex, '')
|
||||||
|
}
|
||||||
|
}
|
@ -1,55 +0,0 @@
|
|||||||
import fetch from 'node-fetch'
|
|
||||||
|
|
||||||
export class recommend extends plugin {
|
|
||||||
constructor () {
|
|
||||||
super({
|
|
||||||
name: '推荐软件',
|
|
||||||
dsc: '推荐相关指令',
|
|
||||||
event: 'message.group',
|
|
||||||
priority: 500,
|
|
||||||
rule: [
|
|
||||||
{
|
|
||||||
/** 命令正则匹配 */
|
|
||||||
reg: '^#电脑软件推荐$', /** 执行方法 */
|
|
||||||
fnc: 'computerRecommended'
|
|
||||||
}, {
|
|
||||||
/** 命令正则匹配 */
|
|
||||||
reg: '^#安卓软件推荐$', /** 执行方法 */
|
|
||||||
fnc: 'androidRecommended'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async computerRecommended (e) {
|
|
||||||
let url = 'https://www.ghxi.com/ghapi?type=query&n=pc'
|
|
||||||
/** 调用接口获取数据 */
|
|
||||||
let res = await fetch(url).catch((err) => logger.error(err))
|
|
||||||
|
|
||||||
/** 接口结果,json字符串转对象 */
|
|
||||||
res = await res.json()
|
|
||||||
let msg = []
|
|
||||||
res.data.list.forEach((element) => {
|
|
||||||
const template = `推荐软件:${ element.title }\n地址:${ element.url }\n`
|
|
||||||
msg.push({
|
|
||||||
message: { type: 'text', text: `${ template }` }, nickname: Bot.nickname, user_id: Bot.uin
|
|
||||||
})
|
|
||||||
})
|
|
||||||
/** 最后回复消息 */
|
|
||||||
return !!this.reply(await Bot.makeForwardMsg(msg))
|
|
||||||
}
|
|
||||||
|
|
||||||
async androidRecommended (e) {
|
|
||||||
let url = 'https://www.ghxi.com/ghapi?type=query&n=and'
|
|
||||||
let res = await fetch(url).catch((err) => logger.error(err))
|
|
||||||
res = await res.json()
|
|
||||||
let msg = []
|
|
||||||
res.data.list.forEach((element) => {
|
|
||||||
const template = `推荐软件:${ element.title }\n地址:${ element.url }\n`
|
|
||||||
msg.push({
|
|
||||||
message: { type: 'text', text: `${ template }` }, nickname: Bot.nickname, user_id: Bot.uin
|
|
||||||
})
|
|
||||||
})
|
|
||||||
return !!this.reply(await Bot.makeForwardMsg(msg))
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +1,20 @@
|
|||||||
- group: 医学功能
|
- group: 查询类功能
|
||||||
list:
|
list:
|
||||||
- icon: doctor
|
- icon: query
|
||||||
title: "#医药查询 疾病/症状/医院/医生/药品"
|
title: "#医药查询 疾病/症状/医院/医生/药品"
|
||||||
desc: 便利的医药查询功能
|
desc: 便利的医药查询功能
|
||||||
- group: 猫猫图
|
|
||||||
list:
|
|
||||||
- icon: cat
|
- icon: cat
|
||||||
title: "#猫猫|cat 开始吸猫"
|
title: "#猫猫|cat 开始吸猫"
|
||||||
desc: 猫咪图捕捉
|
desc: 猫咪图捕捉
|
||||||
|
- icon: hot
|
||||||
|
title: "#热搜 虎扑/知乎/36氪/百度/哔哩哔哩/贴吧/微博/抖音/豆瓣/少数派/IT资讯/微信"
|
||||||
|
desc: 开局五子棋游戏
|
||||||
|
- icon: computer
|
||||||
|
title: "#电脑软件推荐"
|
||||||
|
desc: 推荐PC软件
|
||||||
|
- icon: android
|
||||||
|
title: "#安卓软件推荐"
|
||||||
|
desc: 推荐安卓软件
|
||||||
- group: 神秘功能合集
|
- group: 神秘功能合集
|
||||||
list:
|
list:
|
||||||
- icon: pic1
|
- icon: pic1
|
||||||
@ -25,11 +32,6 @@
|
|||||||
- icon: pic5
|
- icon: pic5
|
||||||
title: "#沃日吗"
|
title: "#沃日吗"
|
||||||
desc: 什么鬼?
|
desc: 什么鬼?
|
||||||
- group: 热搜功能合集
|
|
||||||
list:
|
|
||||||
- icon: hot
|
|
||||||
title: "#热搜 虎扑/知乎/36氪/百度/哔哩哔哩/贴吧/微博/抖音/豆瓣/少数派/IT资讯/微信"
|
|
||||||
desc: 开局五子棋游戏
|
|
||||||
- group: 工具类合集
|
- group: 工具类合集
|
||||||
list:
|
list:
|
||||||
- icon: translate
|
- icon: translate
|
||||||
@ -38,12 +40,6 @@
|
|||||||
- icon: 百科
|
- icon: 百科
|
||||||
title: "#百科/wiki xxx"
|
title: "#百科/wiki xxx"
|
||||||
desc: 百度百科/搜狗百科
|
desc: 百度百科/搜狗百科
|
||||||
- icon: computer
|
|
||||||
title: "#电脑软件推荐"
|
|
||||||
desc: 推荐PC软件
|
|
||||||
- icon: android
|
|
||||||
title: "#安卓软件推荐"
|
|
||||||
desc: 推荐安卓软件
|
|
||||||
- icon: tiktok
|
- icon: tiktok
|
||||||
title: "xxxv.douyin.com"
|
title: "xxxv.douyin.com"
|
||||||
desc: 抖音分享实时下载
|
desc: 抖音分享实时下载
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 6.7 KiB |
Loading…
x
Reference in New Issue
Block a user