-
Notifications
You must be signed in to change notification settings - Fork 0
/
MadnessThursday.js
84 lines (64 loc) · 2.32 KB
/
MadnessThursday.js
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
import plugin from '../../lib/plugins/plugin.js'
import fetch from 'node-fetch'
import {
segment
} from 'oicq'
export class Crazy4 extends plugin {
constructor() {
super({
/** 功能名称 */
name: 'KFC疯狂星期四',
/** 功能描述 */
dsc: '获取网页疯狂星期四文案随机发送',
/** https://oicqjs.github.io/oicq/#events */
event: 'message',
/** 优先级,数字越小等级越高 */
priority: 1003,
rule: [{
/** 命令正则匹配 */
reg: '^#*(疯狂)*星期四$',
/** 执行方法 */
fnc: 'Crazy4'
}]
})
}
/**
*
* @param e oicq传递的事件参数e
*/
async Crazy4(e) {
let url = "https://www.sxsme.com.cn/gonglue/14216.html";
let response = await fetch(url); //调用接口获取数据
let res = await response.text();
let regFC4 = /<hr \/>([\s\S]*?)<hr \/>/g;
let textFC4 = res.match(regFC4);
let delFC4 = [];
for (const key in textFC4) {
if (textFC4[key].match(/<table([\s\S]*?)<\/table>/g)) {
textFC4[key] = textFC4[key].replace(/<table([\s\S]*?)<\/table>/g, "<hr /><hr />");
delFC4.push(key);
let temp = textFC4[key].match(regFC4);
for (const tempkey in temp) {
textFC4.push(temp[tempkey]);
}
}
}
for (const key in delFC4) {
textFC4.splice(delFC4[key], 1);
}
for (const key in textFC4) {
textFC4[key] = textFC4[key].replace(/<hr \/>|<p>|<\/p>| |\r|\n|<br \/>/g, "");
textFC4[key] = textFC4[key].replace(/\t/g, "\n");
if (textFC4[key].indexOf("\r")) {
textFC4[key] = textFC4[key].slice(1);
}
}
let imgregFC4 = /https:\/\/img.sxsme.com.cn\/uploadimg\/image\/[0-9]{7,8}\/[0-9A-Za-z_]{10,30}.jpg/g;
let imgFC4 = res.match(imgregFC4);
for (const key in imgFC4) {
textFC4.push(imgFC4[key]);
}
let FC4 = textFC4[Math.round(Math.random() * (textFC4.length - 1))];
await this.e.reply(FC4.includes("http") ? segment.image(FC4) : FC4);
}
}