koishi-plugin-iirose-cut 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +6 -0
- package/lib/index.js +94 -0
- package/package.json +21 -0
- package/readme.md +5 -0
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.apply = exports.Config = exports.name = void 0;
|
|
4
|
+
const koishi_1 = require("koishi");
|
|
5
|
+
exports.name = 'iirose-cut';
|
|
6
|
+
exports.Config = koishi_1.Schema.object({});
|
|
7
|
+
function apply(ctx) {
|
|
8
|
+
const nowUserList = [];
|
|
9
|
+
const whiteList = [];
|
|
10
|
+
let status = false;
|
|
11
|
+
ctx.on('iirose/newMusic', (session, data) => {
|
|
12
|
+
if (!status) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const index = nowUserList.indexOf(data.owner);
|
|
16
|
+
const index2 = whiteList.indexOf(data.owner);
|
|
17
|
+
if (index > -1 || index2 > -1) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
ctx.emit('iirose/cut-one', {});
|
|
21
|
+
});
|
|
22
|
+
ctx.on('iirose/joinRoom', (session, data) => {
|
|
23
|
+
const index = nowUserList.indexOf(data.username);
|
|
24
|
+
if (index > -1) {
|
|
25
|
+
session.send({
|
|
26
|
+
public: {
|
|
27
|
+
message: '[IIROSE-CUT] 用户已存在白名单'
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
nowUserList.push(data.username);
|
|
32
|
+
});
|
|
33
|
+
ctx.on('iirose/leaveRoom', (session, data) => {
|
|
34
|
+
const index = nowUserList.indexOf(data.username);
|
|
35
|
+
if (index < 0) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
nowUserList.splice(index, 1);
|
|
39
|
+
});
|
|
40
|
+
ctx.command('iirose-cut', '花园自动切歌系统')
|
|
41
|
+
.option('add', '-a <艾特:string> 添加一个人到白名单', { type: /\[\*([\s\S]+)\*\]/ })
|
|
42
|
+
.option('del', '-d <艾特:string> 移除一个人到白名单', { type: /\[\*([\s\S]+)\*\]/ })
|
|
43
|
+
.option('on', '开启自动切歌')
|
|
44
|
+
.option('off', '关闭自动切歌')
|
|
45
|
+
.option('view', '查看当前的列表')
|
|
46
|
+
.action(v => {
|
|
47
|
+
if (v.session.platform !== 'iirose') {
|
|
48
|
+
return ' [IIROSE-CUT] 该平台不支持使用此插件';
|
|
49
|
+
}
|
|
50
|
+
if (v.options.hasOwnProperty('add')) {
|
|
51
|
+
const at = getAt(v.options.add);
|
|
52
|
+
const index = whiteList.indexOf(at);
|
|
53
|
+
if (index > -1) {
|
|
54
|
+
return '[IIROSE-CUT] 用户已存在白名单';
|
|
55
|
+
}
|
|
56
|
+
whiteList.push(at);
|
|
57
|
+
return '[IIROSE-CUT] 添加白名单成功';
|
|
58
|
+
}
|
|
59
|
+
if (v.options.hasOwnProperty('del')) {
|
|
60
|
+
const at = getAt(v.options.del);
|
|
61
|
+
const index = whiteList.indexOf(at);
|
|
62
|
+
if (index < 0) {
|
|
63
|
+
return '[IIROSE-CUT] 该用户不在白名单中';
|
|
64
|
+
}
|
|
65
|
+
whiteList.splice(index, 1);
|
|
66
|
+
}
|
|
67
|
+
if (v.options.hasOwnProperty('on')) {
|
|
68
|
+
status = true;
|
|
69
|
+
return '[IIROSE-CUT] 自动切歌已启动';
|
|
70
|
+
}
|
|
71
|
+
if (v.options.hasOwnProperty('off')) {
|
|
72
|
+
status = false;
|
|
73
|
+
return '[IIROSE-CUT] 自动切歌已关闭';
|
|
74
|
+
}
|
|
75
|
+
if (v.options.hasOwnProperty('view')) {
|
|
76
|
+
const nowUserListView = '当前房间人员列表:\n' + nowUserList.map(data => {
|
|
77
|
+
return `\n [*${data}*] `;
|
|
78
|
+
});
|
|
79
|
+
const whiteListView = '当前白名单人员列表' + whiteList.map(data => {
|
|
80
|
+
return `\n [*${data}*] `;
|
|
81
|
+
});
|
|
82
|
+
return '[IIROSE-CUT] \n\n' + nowUserListView + '\n\n' + whiteListView;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
exports.apply = apply;
|
|
87
|
+
const getAt = (message) => {
|
|
88
|
+
const reg = /\[\*([\s\S]+)\*\]/;
|
|
89
|
+
const a = reg.test(message);
|
|
90
|
+
if (!a) {
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
return message.match(reg)[1];
|
|
94
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "koishi-plugin-iirose-cut",
|
|
3
|
+
"description": "适用于的[IIROSE蔷薇花园](https://iirose.com/)自动切除退出房间的人所点的歌曲",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"typings": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"scripts": {},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"chatbot",
|
|
15
|
+
"koishi",
|
|
16
|
+
"plugin"
|
|
17
|
+
],
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"koishi": "4.14.1"
|
|
20
|
+
}
|
|
21
|
+
}
|