lintonxue00 commited on
Commit
c8d4d9d
1 Parent(s): a45f3fe

Upload randomimages.js

Browse files
Files changed (1) hide show
  1. 不知道/回收站/5/randomimages.js +133 -0
不知道/回收站/5/randomimages.js ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ 'http://img.xjh.me/random_img.php?tctype=acg&return=302',
18
+ 'http://img.xjh.me/random_img.php?type=bg&ctype=acg&return=302',
19
+ 'http://api.mtyqx.cn/tapi/random.php',
20
+ 'http://img.xjh.me/random_img.php?type=bg&ctype=nature&return=302',
21
+ 'http://www.dmoe.cc/random.php',
22
+ 'https://img.paulzzh.tech/touhou/random',
23
+ 'https://api.ouyangqiqi.cn/dm/img.php',
24
+ 'https://api.ouyangqiqi.com/img.php',
25
+ 'http://dmapi.ikun.icu/img-webp.php',
26
+ 'https://api.btstu.cn/sjbz/api.php',
27
+ 'https://api.btstu.cn/sjbz/api.php',
28
+ 'https://www.dmoe.cc/random.php',
29
+ 'https://api.yimian.xyz/img',
30
+ 'https://api.yimian.xyz/img?type=moe',
31
+ 'https://api.yimian.xyz/img?type=moe&size=1920x1080',
32
+ 'https://img.paulzzh.com/touhou/random',
33
+ 'https://acg.404.kim/api.php',
34
+ 'https://api.ghser.com/random/api.php',
35
+ ]
36
+
37
+ let useapi = apis
38
+
39
+ export class xy_sjt extends plugin {
40
+ constructor() {
41
+ super({
42
+ name: '随机图',
43
+ dsc: '二次元图',
44
+ event: 'message',
45
+ priority: 88888,
46
+ rule: [{
47
+ reg: '^(点|份|看看|康康|看|康|想要|需要|哒咩|来点)(二次元|美图|涩图|涩涩|色色|随机图|高清图|p站|acg|ACG|setu|萌图|插画|壁纸|壁纸|漫画)(\\d+张)?$',
48
+ fnc: 'txsjt'
49
+ }]
50
+ })
51
+
52
+ }
53
+
54
+ async txsjt(e) {
55
+ let image = []
56
+ let res = []
57
+ let img
58
+ let number = e.msg.match(/\d+/)
59
+ if (number) {
60
+ number = Number(number[0])
61
+ number = number < 2 ? 2 : number > 10 ? 10 : number
62
+ } else {
63
+ number = 1
64
+ }
65
+ for (let i = 0; i < number; i++) {
66
+ let flag = 1
67
+ img = await getImg(e)
68
+ if (!img.includes('http')) {
69
+ img = 'https:' + img
70
+ }
71
+
72
+ if (i == 0) {
73
+ res.push(img)
74
+ image.push(segment.image(img))
75
+ } else {
76
+ for (let val of res) {
77
+ if (val == img) {
78
+ flag = 0
79
+ }
80
+ }
81
+ if (flag == 1) {
82
+ image.push(segment.image(img))
83
+ } else {
84
+ number++
85
+ }
86
+ }
87
+
88
+ }
89
+ //logger.mark(number)
90
+ if(e.isGroup) {
91
+ number > 1 ? common.getforwardMsg(e, image, '点击显示随机涩图', 0, false, true) : e.reply(image)
92
+ }else{
93
+ for (let i = 0; i < image.length; i++){
94
+ e.reply(image[i])
95
+ }
96
+ }
97
+ }
98
+ }
99
+
100
+ async function getImg(e) {
101
+ let res = await response()
102
+ let i = 0
103
+ while (!res && i < apis.length) {
104
+ res = await response()
105
+ i++
106
+ }
107
+ if (i > apis.length) return e.reply('接口失效')
108
+ let img = res.img || res.imgurl || res.pic?.[0] || res
109
+ return img
110
+ }
111
+
112
+
113
+ async function response() {
114
+ let num = Math.round(Math.random() * (useapi.length - 1))
115
+ logger.warn(`尝试请求接口:${useapi[num]}`)
116
+ try {
117
+ let res = await fetch(useapi[num])
118
+ if (!res.ok) {
119
+ logger.warn(useapi[num] + ',接口失效')
120
+ useapi.splice(num, 1)
121
+ return false
122
+ }
123
+ if (res.headers.get('content-type').includes('json')) {
124
+ res = await res.json()
125
+ return res
126
+ }
127
+ return useapi[num]
128
+ } catch (err) {
129
+ logger.warn(useapi[num] + ',接口失效')
130
+ useapi.splice(num, 1)
131
+ return false
132
+ }
133
+ }