lintonxue00 commited on
Commit
1ddfaa0
1 Parent(s): 470b8de

Upload randomimages.js

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