File size: 4,988 Bytes
7ab1947 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
import {common} from '../model/index.js'
import fetch from "node-fetch";
import plugin from '../../../lib/plugins/plugin.js'
const apis = [
'https://img.xjh.me/random_img.php',
'https://www.dmoe.cc/random.php',
'https://api.vvhan.com/api/acgimg',
'https://www.dmoe.cc/random.php',
'http://api.caonm.net/api/dm/index.php',
'https://api.ghser.com/random/api.php',
'https://api.yfzy.top/laifentu.php',
'https://api.yimian.xyz/img',
'https://api.yfzy.top/laifentu.php',
'https://api.dujin.org/pic/yuanshen',
'https://api.dujin.org/pic/',
'https://t.mwm.moe/pc',
'https://t.mwm.moe/mp',
'https://t.mwm.moe/fj',
'http://www.98qy.com/sjbz/api.php',
'http://www.98qy.com/sjbz/api.php',
'http://www.98qy.com/sjbz/api.php',
'https://www.dmoe.cc/random.php',
'https://api.dujin.org/pic/yuanshen/',
'https://service-5z0sdahv-1306777571.sh.apigw.tencentcs.com/release/',
'https://service-5z0sdahv-1306777571.sh.apigw.tencentcs.com/release/',
'https://service-rivjlduv-1306777571.sh.apigw.tencentcs.com/release/',
'https://img.paulzzh.tech/touhou/random',
'https://blog.paulzzh.com/archives/50.html',
'https://api.paugram.com/wallpaper/',
'https://api.r10086.com/img-api.php?type=动漫综合1',
'https://api.r10086.com/img-api.php?zsy=%E9%AC%BC%E7%81%AD%E4%B9%8B%E5%88%83',
'https://api.r10086.com/PPT/PPT.php?PPT=%E9%AC%BC%E7%81%AD%E4%B9%8B%E5%88%83',
'http://img.xjh.me/random_img.php?tctype=acg&return=302',
'http://img.xjh.me/random_img.php?type=bg&ctype=acg&return=302',
'http://api.mtyqx.cn/tapi/random.php',
'http://img.xjh.me/random_img.php?type=bg&ctype=nature&return=302',
'http://www.dmoe.cc/random.php',
'https://img.paulzzh.tech/touhou/random',
'https://api.ouyangqiqi.cn/dm/img.php',
'https://api.ouyangqiqi.com/img.php',
'http://dmapi.ikun.icu/img-webp.php',
'https://api.btstu.cn/sjbz/api.php',
'https://api.btstu.cn/sjbz/api.php',
'https://www.dmoe.cc/random.php',
'https://api.yimian.xyz/img',
'https://api.yimian.xyz/img?type=moe',
'https://api.yimian.xyz/img?type=moe&size=1920x1080',
'https://img.paulzzh.com/touhou/random',
'https://acg.404.kim/api.php',
'https://api.ghser.com/random/api.php',
]
let useapi = apis
export class xy_sjt extends plugin {
constructor() {
super({
name: '随机图',
dsc: '二次元图',
event: 'message',
priority: 8888,
rule: [{
reg: '^(.*)(点|份|看看|康康|看|康|想要|需要|哒咩|来点)(二次元|美图|涩图|涩涩|色色|随机图|高清图|p站|acg|ACG|setu|萌图|插画|壁纸|壁纸|漫画)(\\d+张)?(.*)$',
fnc: 'txsjt'
}]
})
}
async txsjt(e) {
let image = []
let res = []
let img
let number = e.msg.match(/\d+/)
if (number) {
number = Number(number[0])
number = number < 2 ? 2 : number > 10 ? 10 : number
} else {
number = 1
}
for (let i = 0; i < number; i++) {
let flag = 1
img = await getImg(e)
if (!img.includes('http')) {
img = 'https:' + img
}
if (i == 0) {
res.push(img)
image.push(segment.image(img))
} else {
for (let val of res) {
if (val == img) {
flag = 0
}
}
if (flag == 1) {
image.push(segment.image(img))
} else {
number++
}
}
}
//logger.mark(number)
if(e.isGroup) {
number > 1 ? common.getforwardMsg(e, image, '点击显示随机涩图', 0, false, true) : e.reply(image)
}else{
for (let i = 0; i < image.length; i++){
e.reply(image[i])
}
}
}
}
async function getImg(e) {
let res = await response()
let i = 0
while (!res && i < apis.length) {
res = await response()
i++
}
if (i > apis.length) return e.reply('接口失效')
let img = res.img || res.imgurl || res.pic?.[0] || res
return img
}
async function response() {
let num = Math.round(Math.random() * (useapi.length - 1))
logger.warn(`尝试请求接口:${useapi[num]}`)
try {
let res = await fetch(useapi[num])
if (!res.ok) {
logger.warn(useapi[num] + ',接口失效')
useapi.splice(num, 1)
return false
}
if (res.headers.get('content-type').includes('json')) {
res = await res.json()
return res
}
return useapi[num]
} catch (err) {
logger.warn(useapi[num] + ',接口失效')
useapi.splice(num, 1)
return false
}
} |