koishi-plugin-iirose-cut 0.0.6 → 0.0.8
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.js +115 -89
- package/package.json +5 -7
package/lib/index.js
CHANGED
|
@@ -1,91 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name2 in all)
|
|
8
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
Config: () => Config,
|
|
24
|
+
apply: () => apply,
|
|
25
|
+
name: () => name
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
var import_koishi = require("koishi");
|
|
29
|
+
var name = "iirose-cut";
|
|
30
|
+
var Config = import_koishi.Schema.object({});
|
|
7
31
|
function apply(ctx) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
const index = nowUserList.indexOf(session.data.owner);
|
|
16
|
-
const index2 = whiteList.indexOf(session.data.owner);
|
|
17
|
-
if (index > -1 || index2 > -1) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
ctx.emit('iirose/cut-one', {});
|
|
21
|
-
});
|
|
22
|
-
ctx.on('iirose/joinRoom', (session) => {
|
|
23
|
-
const index = nowUserList.indexOf(session.data.username);
|
|
24
|
-
if (index > -1) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
nowUserList.push(session.data.username);
|
|
28
|
-
});
|
|
29
|
-
ctx.on('iirose/leaveRoom', (session) => {
|
|
30
|
-
const index = nowUserList.indexOf(session.data.username);
|
|
31
|
-
if (index < 0) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
nowUserList.splice(index, 1);
|
|
35
|
-
});
|
|
36
|
-
ctx.command('iirose-cut', '花园自动切歌系统')
|
|
37
|
-
.option('add', '-a <艾特:string> 添加一个人到白名单', { type: /\[\*([\s\S]+)\*\]/ })
|
|
38
|
-
.option('del', '-d <艾特:string> 移除一个人到白名单', { type: /\[\*([\s\S]+)\*\]/ })
|
|
39
|
-
.option('on', '开启自动切歌')
|
|
40
|
-
.option('off', '关闭自动切歌')
|
|
41
|
-
.option('view', '查看当前的列表')
|
|
42
|
-
.usage('\n注意:机器人需要**星标**权限\n每次插件启动时,房间列表会初始化为空,只有当有人主动退出与进入等操作的时候,才会对房间列表进行操作')
|
|
43
|
-
.action(v => {
|
|
44
|
-
if (v.session.platform !== 'iirose') {
|
|
45
|
-
return ' [IIROSE-CUT] 该平台不支持使用此插件';
|
|
46
|
-
}
|
|
47
|
-
if (v.options.hasOwnProperty('add')) {
|
|
48
|
-
const at = getAt(v.options.add);
|
|
49
|
-
const index = whiteList.indexOf(at);
|
|
50
|
-
if (index > -1) {
|
|
51
|
-
return '[IIROSE-CUT] 用户已存在白名单';
|
|
52
|
-
}
|
|
53
|
-
whiteList.push(at);
|
|
54
|
-
return '[IIROSE-CUT] 添加白名单成功';
|
|
55
|
-
}
|
|
56
|
-
if (v.options.hasOwnProperty('del')) {
|
|
57
|
-
const at = getAt(v.options.del);
|
|
58
|
-
const index = whiteList.indexOf(at);
|
|
59
|
-
if (index < 0) {
|
|
60
|
-
return '[IIROSE-CUT] 该用户不在白名单中';
|
|
61
|
-
}
|
|
62
|
-
whiteList.splice(index, 1);
|
|
63
|
-
}
|
|
64
|
-
if (v.options.hasOwnProperty('on')) {
|
|
65
|
-
status = true;
|
|
66
|
-
return '[IIROSE-CUT] 自动切歌已启动';
|
|
67
|
-
}
|
|
68
|
-
if (v.options.hasOwnProperty('off')) {
|
|
69
|
-
status = false;
|
|
70
|
-
return '[IIROSE-CUT] 自动切歌已关闭';
|
|
71
|
-
}
|
|
72
|
-
if (v.options.hasOwnProperty('view')) {
|
|
73
|
-
const nowUserListView = '当前房间人员列表:\n' + nowUserList.map(data => {
|
|
74
|
-
return `\n [*${data}*] `;
|
|
75
|
-
});
|
|
76
|
-
const whiteListView = '当前白名单人员列表:' + whiteList.map(data => {
|
|
77
|
-
return `\n [*${data}*] `;
|
|
78
|
-
});
|
|
79
|
-
return '[IIROSE-CUT] \n\n' + nowUserListView + '\n\n' + whiteListView;
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
exports.apply = apply;
|
|
84
|
-
const getAt = (message) => {
|
|
85
|
-
const reg = /\[\*([\s\S]+)\*\]/;
|
|
86
|
-
const a = reg.test(message);
|
|
87
|
-
if (!a) {
|
|
88
|
-
return '';
|
|
32
|
+
const nowUserList = [];
|
|
33
|
+
const whiteList = [];
|
|
34
|
+
let status = false;
|
|
35
|
+
ctx.on("iirose/newMusic", (session, data) => {
|
|
36
|
+
if (!status) {
|
|
37
|
+
return;
|
|
89
38
|
}
|
|
90
|
-
|
|
91
|
-
|
|
39
|
+
const index = nowUserList.indexOf(data.owner);
|
|
40
|
+
const index2 = whiteList.indexOf(data.owner);
|
|
41
|
+
if (index > -1 || index2 > -1) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
ctx.emit("iirose/cut-one", {});
|
|
45
|
+
});
|
|
46
|
+
ctx.on("iirose/joinRoom", (session, data) => {
|
|
47
|
+
const index = nowUserList.indexOf(data.username);
|
|
48
|
+
if (index > -1) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
nowUserList.push(data.username);
|
|
52
|
+
});
|
|
53
|
+
ctx.on("iirose/leaveRoom", (session, data) => {
|
|
54
|
+
const index = nowUserList.indexOf(data.username);
|
|
55
|
+
if (index < 0) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
nowUserList.splice(index, 1);
|
|
59
|
+
});
|
|
60
|
+
ctx.command("iirose", "花园工具");
|
|
61
|
+
ctx.command("iirose.cut", "花园自动切歌系统").option("add", "-a <艾特:string> 添加一个人到白名单", { type: /\[\*([\s\S]+)\*\]/ }).option("del", "-d <艾特:string> 移除一个人到白名单", { type: /\[\*([\s\S]+)\*\]/ }).option("on", "开启自动切歌").option("off", "关闭自动切歌").option("view", "查看当前的列表").usage("\n注意:机器人需要**星标**权限\n每次插件启动时,房间列表会初始化为空,只有当有人主动退出与进入等操作的时候,才会对房间列表进行操作").action((v) => {
|
|
62
|
+
if (v.session.platform !== "iirose") {
|
|
63
|
+
return " [IIROSE-CUT] 该平台不支持使用此插件";
|
|
64
|
+
}
|
|
65
|
+
if (v.options.hasOwnProperty("add")) {
|
|
66
|
+
const at = getAt(v.options.add);
|
|
67
|
+
const index = whiteList.indexOf(at);
|
|
68
|
+
if (index > -1) {
|
|
69
|
+
return "[IIROSE-CUT] 用户已存在白名单";
|
|
70
|
+
}
|
|
71
|
+
whiteList.push(at);
|
|
72
|
+
return "[IIROSE-CUT] 添加白名单成功";
|
|
73
|
+
}
|
|
74
|
+
if (v.options.hasOwnProperty("del")) {
|
|
75
|
+
const at = getAt(v.options.del);
|
|
76
|
+
const index = whiteList.indexOf(at);
|
|
77
|
+
if (index < 0) {
|
|
78
|
+
return "[IIROSE-CUT] 该用户不在白名单中";
|
|
79
|
+
}
|
|
80
|
+
whiteList.splice(index, 1);
|
|
81
|
+
}
|
|
82
|
+
if (v.options.hasOwnProperty("on")) {
|
|
83
|
+
status = true;
|
|
84
|
+
return "[IIROSE-CUT] 自动切歌已启动";
|
|
85
|
+
}
|
|
86
|
+
if (v.options.hasOwnProperty("off")) {
|
|
87
|
+
status = false;
|
|
88
|
+
return "[IIROSE-CUT] 自动切歌已关闭";
|
|
89
|
+
}
|
|
90
|
+
if (v.options.hasOwnProperty("view")) {
|
|
91
|
+
const nowUserListView = "当前房间人员列表:\n" + nowUserList.map((data) => {
|
|
92
|
+
return `
|
|
93
|
+
[*${data}*] `;
|
|
94
|
+
});
|
|
95
|
+
const whiteListView = "当前白名单人员列表:" + whiteList.map((data) => {
|
|
96
|
+
return `
|
|
97
|
+
[*${data}*] `;
|
|
98
|
+
});
|
|
99
|
+
return "[IIROSE-CUT] \n\n" + nowUserListView + "\n\n" + whiteListView;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
__name(apply, "apply");
|
|
104
|
+
var getAt = /* @__PURE__ */ __name((message) => {
|
|
105
|
+
const reg = /\[\*([\s\S]+)\*\]/;
|
|
106
|
+
const a = reg.test(message);
|
|
107
|
+
if (!a) {
|
|
108
|
+
return "";
|
|
109
|
+
}
|
|
110
|
+
return message.match(reg)[1];
|
|
111
|
+
}, "getAt");
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
Config,
|
|
115
|
+
apply,
|
|
116
|
+
name
|
|
117
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-iirose-cut",
|
|
3
3
|
"description": "适用于的[IIROSE蔷薇花园](https://iirose.com/)自动切除退出房间的人所点的歌曲",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.8",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -9,15 +9,13 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"scripts": {},
|
|
13
12
|
"keywords": [
|
|
14
13
|
"chatbot",
|
|
15
14
|
"koishi",
|
|
16
15
|
"plugin"
|
|
17
16
|
],
|
|
18
17
|
"peerDependencies": {
|
|
19
|
-
"koishi": "^4.
|
|
20
|
-
"koishi-plugin-adapter-iirose": "~0.
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
}
|
|
18
|
+
"koishi": "^4.18.7",
|
|
19
|
+
"koishi-plugin-adapter-iirose": "~0.3.63"
|
|
20
|
+
}
|
|
21
|
+
}
|