mioku-plugin-music 3.0.2 → 3.0.3
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/README.md +3 -3
- package/index.ts +9 -9
- package/package.json +1 -1
- package/runtime-core/fallback.ts +2 -1
- package/runtime-core/message.ts +14 -12
- package/runtime-core/service.ts +2 -2
package/README.md
CHANGED
package/index.ts
CHANGED
|
@@ -57,33 +57,33 @@ export default definePlugin({
|
|
|
57
57
|
const react = (event: any) => runtime.tryReactToCommandMessage(ctx, event);
|
|
58
58
|
|
|
59
59
|
ctx.command({
|
|
60
|
-
name: "点歌",
|
|
61
|
-
match: /^\/?点歌\s*(.+)$/,
|
|
62
60
|
prefixes: false,
|
|
61
|
+
name: "点歌",
|
|
62
|
+
match: /^点歌\s*(.+)$/,
|
|
63
63
|
description: "搜索歌曲/歌手/专辑,返回最多 15 条结果图片列表",
|
|
64
|
-
usage: "
|
|
64
|
+
usage: ".点歌 晴天",
|
|
65
65
|
handler: async ({ event, match }) => {
|
|
66
66
|
await react(event);
|
|
67
67
|
await runtime.searchAndSendList(ctx, event, match![1].trim());
|
|
68
68
|
},
|
|
69
69
|
});
|
|
70
70
|
ctx.command({
|
|
71
|
-
name: "听",
|
|
72
|
-
match: /^\/?听\s*(\d{1,2})$/,
|
|
73
71
|
prefixes: false,
|
|
72
|
+
name: "听",
|
|
73
|
+
match: /^听\s*(\d{1,2})$/,
|
|
74
74
|
description: "发送上次搜索列表中的指定歌曲语音",
|
|
75
|
-
usage: "
|
|
75
|
+
usage: ".听1",
|
|
76
76
|
handler: async ({ event, match }) => {
|
|
77
77
|
await react(event);
|
|
78
78
|
await runtime.sendByIndex(ctx, event, Number(match![1]), false);
|
|
79
79
|
},
|
|
80
80
|
});
|
|
81
81
|
ctx.command({
|
|
82
|
-
name: "原曲",
|
|
83
|
-
match: /^\/?原曲\s*(\d{1,2})$/,
|
|
84
82
|
prefixes: false,
|
|
83
|
+
name: "原曲",
|
|
84
|
+
match: /^原曲\s*(\d{1,2})$/,
|
|
85
85
|
description: "发送上次搜索列表中的指定歌曲原曲文件",
|
|
86
|
-
usage: "
|
|
86
|
+
usage: ".原曲1",
|
|
87
87
|
handler: async ({ event, match }) => {
|
|
88
88
|
await react(event);
|
|
89
89
|
await runtime.sendByIndex(ctx, event, Number(match![1]), true);
|
package/package.json
CHANGED
package/runtime-core/fallback.ts
CHANGED
package/runtime-core/message.ts
CHANGED
|
@@ -22,15 +22,17 @@ function normalizeFileSource(file: string): string {
|
|
|
22
22
|
|
|
23
23
|
function getBotAndTarget(ctx: any, event: any): {
|
|
24
24
|
bot: any;
|
|
25
|
-
groupId?:
|
|
26
|
-
userId?:
|
|
25
|
+
groupId?: string;
|
|
26
|
+
userId?: string;
|
|
27
27
|
} {
|
|
28
28
|
const bot = event?.bot;
|
|
29
|
+
const groupId = String(event?.group_id ?? "").trim();
|
|
30
|
+
const userId = String(event?.user_id ?? "").trim();
|
|
29
31
|
|
|
30
32
|
return {
|
|
31
33
|
bot,
|
|
32
|
-
groupId: event?.message_type === "group" ?
|
|
33
|
-
userId: event?.message_type !== "group" ?
|
|
34
|
+
groupId: event?.message_type === "group" ? groupId : undefined,
|
|
35
|
+
userId: event?.message_type !== "group" ? userId : undefined,
|
|
34
36
|
};
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -44,11 +46,11 @@ export async function sendTextMessage(
|
|
|
44
46
|
|
|
45
47
|
payload.push(ctx.segment.text(text));
|
|
46
48
|
|
|
47
|
-
if (bot && groupId != null) {
|
|
49
|
+
if (bot && groupId != null && groupId !== "") {
|
|
48
50
|
await bot.sendGroupMsg(groupId, payload);
|
|
49
51
|
return;
|
|
50
52
|
}
|
|
51
|
-
if (bot && userId != null) {
|
|
53
|
+
if (bot && userId != null && userId !== "") {
|
|
52
54
|
await bot.sendPrivateMsg(userId, payload);
|
|
53
55
|
return;
|
|
54
56
|
}
|
|
@@ -69,11 +71,11 @@ export async function sendImageMessage(
|
|
|
69
71
|
const payload: any[] = [];
|
|
70
72
|
payload.push(ctx.segment.image(normalizeFileSource(source)));
|
|
71
73
|
|
|
72
|
-
if (bot && groupId != null) {
|
|
74
|
+
if (bot && groupId != null && groupId !== "") {
|
|
73
75
|
await bot.sendGroupMsg(groupId, payload);
|
|
74
76
|
return;
|
|
75
77
|
}
|
|
76
|
-
if (bot && userId != null) {
|
|
78
|
+
if (bot && userId != null && userId !== "") {
|
|
77
79
|
await bot.sendPrivateMsg(userId, payload);
|
|
78
80
|
return;
|
|
79
81
|
}
|
|
@@ -106,11 +108,11 @@ export async function sendFileMessage(
|
|
|
106
108
|
const payload: any[] = [];
|
|
107
109
|
payload.push(ctx.segment.file(normalizeFileSource(source), { name: fileName }));
|
|
108
110
|
|
|
109
|
-
if (bot && groupId != null) {
|
|
111
|
+
if (bot && groupId != null && groupId !== "") {
|
|
110
112
|
await bot.sendGroupMsg(groupId, payload);
|
|
111
113
|
return;
|
|
112
114
|
}
|
|
113
|
-
if (bot && userId != null) {
|
|
115
|
+
if (bot && userId != null && userId !== "") {
|
|
114
116
|
await bot.sendPrivateMsg(userId, payload);
|
|
115
117
|
return;
|
|
116
118
|
}
|
|
@@ -174,11 +176,11 @@ export async function sendRecordMessage(
|
|
|
174
176
|
const payload: any[] = [];
|
|
175
177
|
payload.push(ctx.segment.record(normalizeFileSource(source)));
|
|
176
178
|
|
|
177
|
-
if (bot && groupId != null) {
|
|
179
|
+
if (bot && groupId != null && groupId !== "") {
|
|
178
180
|
await bot.sendGroupMsg(groupId, payload);
|
|
179
181
|
return;
|
|
180
182
|
}
|
|
181
|
-
if (bot && userId != null) {
|
|
183
|
+
if (bot && userId != null && userId !== "") {
|
|
182
184
|
await bot.sendPrivateMsg(userId, payload);
|
|
183
185
|
return;
|
|
184
186
|
}
|
package/runtime-core/service.ts
CHANGED
|
@@ -346,8 +346,8 @@ export class MusicPluginRuntime {
|
|
|
346
346
|
return;
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
const messageId =
|
|
350
|
-
if (!
|
|
349
|
+
const messageId = String(event?.message_id ?? "").trim();
|
|
350
|
+
if (!messageId) {
|
|
351
351
|
return;
|
|
352
352
|
}
|
|
353
353
|
|