-
Notifications
You must be signed in to change notification settings - Fork 4
/
开团.js
176 lines (156 loc) · 4.96 KB
/
开团.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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import plugin from '../../lib/plugins/plugin.js'
import common from '../../lib/common/common.js';
import fs from 'fs';
import { segment } from "oicq";
import fetch from "node-fetch";
const _path = process.cwd();//云崽目录
let interval = 4;//开团间隔,单位秒
let mode = 1;//图片模式,0是网络接口,1是本地
let path = `${_path}/resources/kunkun`//图片路径
let kunkun = [7578658303] //坤坤歌单(网易云)
var ikunyl = [
'小黑子香精煎鱼食不食?',
'小黑子食不食油饼?',
'你干嘛~~~哎哟~~~',
'我家哥哥下蛋你别吃',
'一小黑子树脂666~',
'巅峰产生虚伪的拥护,\n黄昏见证真正的信徒',
'又黑我家哥哥?',
] //ikun语录,可以自行添加
let timer = {};
let list = [];
if(fs.existsSync(path)){
list = fs.readdirSync(`${path}`);
}
let addphoto = false;
export class ikun extends plugin {
constructor() {
super({
name: '开团',
dsc: '小黑子露出鸡脚了吧?',
/** https://oicqjs.github.io/oicq/#events */
event: 'message',
priority: 3000,
rule: [
{
reg: '^((.*)鸡你太美(.*)|(.*)寄你太美(.*)|(.*)小黑子(.*)|(.*)鲲鲲(.*)|(.*)鸽鸽(.*))$',
fnc: 'jtm'
},
{
reg: '^#*开团$',
fnc: 'kaituan'
},
{
reg: '^#*(别发了|住手|报警了)$',
fnc: 'stopkaituan'
},
{
reg: '^#*鸡叫$',
fnc: 'jijiao'
},
{
reg: '^#*添加kun图$',
fnc: 'add'
},
{
reg: '(.*)',
fnc: 'photo',
log: false
}
]
})
}
async jtm(e) {
let photo;
if (mode == 0) {
photo = `http://25252.xyz/j` //接口调用
} else if (mode == 1) {
if (!fs.existsSync(path)) {
cancel(e);
e.reply("没有找到本地图库路径");
}
if (list.length == 0) {
cancel(e);
e.reply("本地图库为空");
}
let name = list[parseInt(Math.random() * list.length, 10)];
photo = `${path}/${name}`;
} else {
cancel(e);
return false
};//你填非0|1模式干哈
let msg = segment.image(photo)//配置消息
if (e.isGroup) {
await Bot.pickGroup(e.group_id).sendMsg(msg);
} else {
await Bot.pickFriend(e.user_id).sendMsg(msg);
}
return true;
}
async stopkaituan(e) {
cancel(e);
e.reply('我是ikun相信我')//停止提示
return true;
}
async kaituan(e) {
let id;
if (e.isGroup) {
id = e.group_id;
} else id = e.user_id;
if (!timer[id]) {
let sjyl = parseInt(Math.random() * (ikunyl.length), 10); //随机ikun语录
e.reply(ikunyl[sjyl]);
timer[id] = setInterval(() => {
this.jtm(e);
}, interval * 1000);
} else {
let msg = [
segment.at(e.user_id),
"小黑子露出鸡脚了吧"
]
e.reply(msg);
}
return true;
}
async jijiao(e) {
let jijiao = await (await fetch(`https://api.yimian.xyz/msc/?type=playlist&id=${kunkun}&random=true`)).json(); //歌曲接口调用
console.log('随机鸡叫,歌名为:' + jijiao[0].name);
let sjyl = parseInt(Math.random() * (ikunyl.length), 10); //随机ikun语录
e.reply(ikunyl[sjyl]);
e.reply(segment.record(jijiao[0].url)); //随机鸡叫
return true; //返回true 阻挡消息不再往下
}
async add(e){
if(!e.isMaster){
return false;
}
addphoto = true;
e.reply("请发送图片,可以一次性发送多张图片哦");
return true;
}
async photo(e){
if(!e.img || !addphoto){
return false;
}
for(let i of e.message){
if(i.type !== 'image') continue;
await common.downFile(i.url,`${path}/${i.file}`)
}
e.reply("录入成功!")
addphoto = false;
return true;
}
}
function cancel(e){
if (e.isGroup) {
if (timer[e.group_id]) {
clearInterval(timer[e.group_id]);
delete timer[e.group_id];
}
} else {
if (timer[e.user_id]) {
clearInterval(timer[e.user_id]);
delete timer[e.user_id];
}
}
}