koishi-plugin-iirose-cut 0.0.7 → 0.0.9
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/LICENSE +21 -0
- package/lib/index.d.ts +4 -1
- package/lib/index.js +83 -90
- package/package.json +15 -7
- package/readme.md +1 -1
- package/src/index.ts +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 IIROSE-Plugins
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Context, Schema } from 'koishi';
|
|
2
2
|
export declare const name = "iirose-cut";
|
|
3
|
+
export declare const inject: string[];
|
|
4
|
+
export declare const usage = "\n---\n\nBOT\u9700\u8981\u6709\u623F\u95F4\u6210\u5458\u7684\u661F\u6807\u6743\u9650 / \u7BA1\u7406\u6743\u9650\u3002\n\n\u5982\u679C\u4F60\u7684bot\u6CA1\u6709\u6743\u9650\uFF0C\u5219\u53EF\u4EE5\u53D1\u8D77cut\u6295\u7968\uFF0C\u8BF7\u4F7F\u7528 iirose-self-cut \u63D2\u4EF6\u3002\n\n---\n\n\u4F7F\u7528\u6307\u4EE4\u4EE5\u5207\u6B4C\uFF1A\n\n- iirose.media.cut \uFF1A \u7EC8\u6B62\u5F53\u524D\u6B4C\u66F2\n- iirose.media.cutall \uFF1A \u7EC8\u6B62\u6240\u6709\u6B4C\u66F2\n\n---\n\n\u672C\u63D2\u4EF6\u9700\u8981\u8C03\u7528\u8005\u9700\u8981\u81F3\u5C112\u7EA7\u6743\u9650\u3002\n\n\u5982\u679C\u4F60\u7684\u6743\u9650\u4E0D\u591F\uFF0C\u8BF7\u4F7F\u7528 change-auth-callme \u63D2\u4EF6\u6765\u63D0\u6743\u3002\n\n\u52A1\u5FC5\u4E0D\u8981\u4F7F\u75281\u7EA7\u6743\u9650\uFF0C\u5426\u5219\u53EF\u80FD\u4F1A\u5BFC\u81F4\n\n---\n";
|
|
3
5
|
export interface Config {
|
|
6
|
+
commandAuthority: number;
|
|
4
7
|
}
|
|
5
8
|
export declare const Config: Schema<Config>;
|
|
6
|
-
export declare function apply(ctx: Context): void;
|
|
9
|
+
export declare function apply(ctx: Context, config: Config): void;
|
package/lib/index.js
CHANGED
|
@@ -1,91 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
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.username);
|
|
24
|
-
if (index > -1) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
nowUserList.push(session.username);
|
|
28
|
-
});
|
|
29
|
-
ctx.on('iirose/leaveRoom', (session) => {
|
|
30
|
-
const index = nowUserList.indexOf(session.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 '';
|
|
89
|
-
}
|
|
90
|
-
return message.match(reg)[1];
|
|
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;
|
|
91
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
|
+
inject: () => inject,
|
|
26
|
+
name: () => name,
|
|
27
|
+
usage: () => usage
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(src_exports);
|
|
30
|
+
var import_koishi = require("koishi");
|
|
31
|
+
var name = "iirose-cut";
|
|
32
|
+
var inject = ["database"];
|
|
33
|
+
var usage = `
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
BOT需要有房间成员的星标权限 / 管理权限。
|
|
37
|
+
|
|
38
|
+
如果你的bot没有权限,则可以发起cut投票,请使用 iirose-self-cut 插件。
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
使用指令以切歌:
|
|
43
|
+
|
|
44
|
+
- iirose.media.cut : 终止当前歌曲
|
|
45
|
+
- iirose.media.cutall : 终止所有歌曲
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
本插件需要调用者需要至少2级权限。
|
|
50
|
+
|
|
51
|
+
如果你的权限不够,请使用 change-auth-callme 插件来提权。
|
|
52
|
+
|
|
53
|
+
务必不要使用1级权限,否则可能会导致
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
`;
|
|
57
|
+
var Config = import_koishi.Schema.object({
|
|
58
|
+
commandAuthority: import_koishi.Schema.number().role("slider").min(0).max(5).step(1).default(2).description("指令权限等级")
|
|
59
|
+
});
|
|
60
|
+
function apply(ctx, config) {
|
|
61
|
+
ctx.command("iirose.media.cut", "终止当前歌曲", { authority: config.commandAuthority }).action(async ({ session }) => {
|
|
62
|
+
if (session.platform !== "iirose") {
|
|
63
|
+
return "暂不支持其他平台。";
|
|
64
|
+
}
|
|
65
|
+
await session.bot.internal.cutOne();
|
|
66
|
+
return;
|
|
67
|
+
});
|
|
68
|
+
ctx.command("iirose.media.cutall", "终止所有歌曲", { authority: config.commandAuthority }).action(async ({ session }) => {
|
|
69
|
+
if (session.platform !== "iirose") {
|
|
70
|
+
return "暂不支持其他平台。";
|
|
71
|
+
}
|
|
72
|
+
await session.bot.internal.cutAll();
|
|
73
|
+
return;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
__name(apply, "apply");
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
Config,
|
|
80
|
+
apply,
|
|
81
|
+
inject,
|
|
82
|
+
name,
|
|
83
|
+
usage
|
|
84
|
+
});
|
package/package.json
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-iirose-cut",
|
|
3
|
-
"description": "适用于的[IIROSE蔷薇花园](https://iirose.com/)
|
|
4
|
-
"version": "0.0.
|
|
3
|
+
"description": "适用于的[IIROSE蔷薇花园](https://iirose.com/)切除退出房间的人所点的歌曲",
|
|
4
|
+
"version": "0.0.9",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"lib",
|
|
9
|
-
"
|
|
9
|
+
"src"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/iirose-plugins/koishi-plugin-iirose-cut/issues/new/choose"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/iirose-plugins/koishi-plugin-iirose-cut.git"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/iirose-plugins/koishi-plugin-iirose-cut",
|
|
12
20
|
"keywords": [
|
|
13
21
|
"chatbot",
|
|
14
22
|
"koishi",
|
|
15
|
-
"plugin"
|
|
23
|
+
"plugin",
|
|
24
|
+
"iirose-cut"
|
|
16
25
|
],
|
|
17
26
|
"peerDependencies": {
|
|
18
|
-
"koishi": "^4.
|
|
19
|
-
"koishi-plugin-adapter-iirose": "~0.3.28"
|
|
27
|
+
"koishi": "^4.18.7"
|
|
20
28
|
}
|
|
21
|
-
}
|
|
29
|
+
}
|
package/readme.md
CHANGED
package/src/index.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Context, Schema } from 'koishi';
|
|
2
|
+
|
|
3
|
+
export const name = 'iirose-cut';
|
|
4
|
+
|
|
5
|
+
export const inject = ['database'];
|
|
6
|
+
|
|
7
|
+
export const usage = `
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
BOT需要有房间成员的星标权限 / 管理权限。
|
|
11
|
+
|
|
12
|
+
如果你的bot没有权限,则可以发起cut投票,请使用 iirose-self-cut 插件。
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
使用指令以切歌:
|
|
17
|
+
|
|
18
|
+
- iirose.media.cut : 终止当前歌曲
|
|
19
|
+
- iirose.media.cutall : 终止所有歌曲
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
本插件需要调用者需要至少2级权限。
|
|
24
|
+
|
|
25
|
+
如果你的权限不够,请使用 change-auth-callme 插件来提权。
|
|
26
|
+
|
|
27
|
+
务必不要使用1级权限,否则可能会导致
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
export interface Config
|
|
33
|
+
{
|
|
34
|
+
commandAuthority: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const Config: Schema<Config> = Schema.object({
|
|
38
|
+
commandAuthority: Schema.number().role('slider').min(0).max(5).step(1).default(2).description("指令权限等级"),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export function apply(ctx: Context, config: Config)
|
|
42
|
+
{
|
|
43
|
+
ctx
|
|
44
|
+
.command('iirose.media.cut', '终止当前歌曲', { authority: config.commandAuthority })
|
|
45
|
+
.action(async ({ session }) =>
|
|
46
|
+
{
|
|
47
|
+
if (session.platform !== "iirose")
|
|
48
|
+
{
|
|
49
|
+
return "暂不支持其他平台。";
|
|
50
|
+
}
|
|
51
|
+
await session.bot.internal.cutOne();
|
|
52
|
+
return;
|
|
53
|
+
});
|
|
54
|
+
ctx
|
|
55
|
+
.command('iirose.media.cutall', '终止所有歌曲', { authority: config.commandAuthority })
|
|
56
|
+
.action(async ({ session }) =>
|
|
57
|
+
{
|
|
58
|
+
if (session.platform !== "iirose")
|
|
59
|
+
{
|
|
60
|
+
return "暂不支持其他平台。";
|
|
61
|
+
}
|
|
62
|
+
await session.bot.internal.cutAll();
|
|
63
|
+
return;
|
|
64
|
+
});
|
|
65
|
+
}
|