mioku-plugin-music 2.4.4 → 3.0.0
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/index.ts +1 -1
- package/package.json +4 -6
- package/render/search-list.ts +5 -5
- package/runtime-core/message.ts +7 -23
- package/runtime-core/service.ts +4 -10
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mioku-plugin-music",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "音乐插件:点歌、搜索音乐、听歌语音发送",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -57,14 +57,12 @@
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"mioku": "^0.
|
|
61
|
-
"
|
|
62
|
-
"mioku-service-
|
|
63
|
-
"mioku-service-netease": "^1.0.0"
|
|
60
|
+
"mioku": "^1.0.0",
|
|
61
|
+
"mioku-service-applemusic": "^3.0.0",
|
|
62
|
+
"mioku-service-netease": "^2.0.0"
|
|
64
63
|
},
|
|
65
64
|
"devDependencies": {
|
|
66
65
|
"mioku": "workspace:*",
|
|
67
|
-
"mioki": "^0.16.0",
|
|
68
66
|
"mioku-service-applemusic": "workspace:*",
|
|
69
67
|
"mioku-service-netease": "workspace:*"
|
|
70
68
|
}
|
package/render/search-list.ts
CHANGED
|
@@ -4,11 +4,11 @@ import { getMusicProviderLabel } from "../providers/provider-labels";
|
|
|
4
4
|
function escapeHtml(value: string): string {
|
|
5
5
|
const source = String(value || "");
|
|
6
6
|
return source
|
|
7
|
-
.replace(/&/g, "&")
|
|
8
|
-
.replace(/</g, "<")
|
|
9
|
-
.replace(/>/g, ">")
|
|
10
|
-
.replace(/"/g, """)
|
|
11
|
-
.replace(/'/g, "'");
|
|
7
|
+
.replace(/&/g, "&);")
|
|
8
|
+
.replace(/</g, "<);")
|
|
9
|
+
.replace(/>/g, ">);")
|
|
10
|
+
.replace(/"/g, "");")
|
|
11
|
+
.replace(/'/g, "');");
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function renderMusicSearchListHtml(search: MusicSearchResult): string {
|
package/runtime-core/message.ts
CHANGED
|
@@ -25,16 +25,12 @@ function getBotAndTarget(ctx: any, event: any): {
|
|
|
25
25
|
groupId?: number;
|
|
26
26
|
userId?: number;
|
|
27
27
|
} {
|
|
28
|
-
const
|
|
29
|
-
const bot =
|
|
30
|
-
selfId != null && typeof ctx?.pickBot === "function"
|
|
31
|
-
? ctx.pickBot(selfId)
|
|
32
|
-
: undefined;
|
|
28
|
+
const bot = event?.bot;
|
|
33
29
|
|
|
34
30
|
return {
|
|
35
31
|
bot,
|
|
36
|
-
groupId: event?.message_type === "group" ?
|
|
37
|
-
userId: event?.message_type !== "group" ?
|
|
32
|
+
groupId: event?.message_type === "group" ? event.group_id : undefined,
|
|
33
|
+
userId: event?.message_type !== "group" ? event?.user_id : undefined,
|
|
38
34
|
};
|
|
39
35
|
}
|
|
40
36
|
|
|
@@ -46,7 +42,7 @@ export async function sendTextMessage(
|
|
|
46
42
|
const { bot, groupId, userId } = getBotAndTarget(ctx, event);
|
|
47
43
|
const payload: any[] = [];
|
|
48
44
|
|
|
49
|
-
payload.push(ctx
|
|
45
|
+
payload.push(ctx.segment.text(text));
|
|
50
46
|
|
|
51
47
|
if (bot && groupId != null) {
|
|
52
48
|
await bot.sendGroupMsg(groupId, payload);
|
|
@@ -71,11 +67,7 @@ export async function sendImageMessage(
|
|
|
71
67
|
const { bot, groupId, userId } = getBotAndTarget(ctx, event);
|
|
72
68
|
const sendPayload = async (source: string) => {
|
|
73
69
|
const payload: any[] = [];
|
|
74
|
-
payload.push(
|
|
75
|
-
ctx?.segment?.image
|
|
76
|
-
? ctx.segment.image(normalizeFileSource(source))
|
|
77
|
-
: { type: "image", file: normalizeFileSource(source) },
|
|
78
|
-
);
|
|
70
|
+
payload.push(ctx.segment.image(normalizeFileSource(source)));
|
|
79
71
|
|
|
80
72
|
if (bot && groupId != null) {
|
|
81
73
|
await bot.sendGroupMsg(groupId, payload);
|
|
@@ -112,11 +104,7 @@ export async function sendFileMessage(
|
|
|
112
104
|
const { bot, groupId, userId } = getBotAndTarget(ctx, event);
|
|
113
105
|
const sendPayload = async (source: string) => {
|
|
114
106
|
const payload: any[] = [];
|
|
115
|
-
payload.push(
|
|
116
|
-
ctx?.segment?.file
|
|
117
|
-
? ctx.segment.file(normalizeFileSource(source), { name: fileName })
|
|
118
|
-
: { type: "file", file: normalizeFileSource(source), name: fileName },
|
|
119
|
-
);
|
|
107
|
+
payload.push(ctx.segment.file(normalizeFileSource(source), { name: fileName }));
|
|
120
108
|
|
|
121
109
|
if (bot && groupId != null) {
|
|
122
110
|
await bot.sendGroupMsg(groupId, payload);
|
|
@@ -184,11 +172,7 @@ export async function sendRecordMessage(
|
|
|
184
172
|
const { bot, groupId, userId } = getBotAndTarget(ctx, event);
|
|
185
173
|
const sendPayload = async (source: string) => {
|
|
186
174
|
const payload: any[] = [];
|
|
187
|
-
payload.push(
|
|
188
|
-
ctx?.segment?.record
|
|
189
|
-
? ctx.segment.record(normalizeFileSource(source))
|
|
190
|
-
: { type: "record", file: normalizeFileSource(source) },
|
|
191
|
-
);
|
|
175
|
+
payload.push(ctx.segment.record(normalizeFileSource(source)));
|
|
192
176
|
|
|
193
177
|
if (bot && groupId != null) {
|
|
194
178
|
await bot.sendGroupMsg(groupId, payload);
|
package/runtime-core/service.ts
CHANGED
|
@@ -414,19 +414,13 @@ export class MusicPluginRuntime {
|
|
|
414
414
|
return;
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
-
const
|
|
418
|
-
if (!
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
const bot =
|
|
423
|
-
typeof ctx?.pickBot === "function" ? ctx.pickBot(selfId) : undefined;
|
|
424
|
-
if (!bot || typeof bot.api !== "function") {
|
|
425
|
-
return;
|
|
417
|
+
const bot = event?.bot;
|
|
418
|
+
if (!bot || bot.adapter !== "onebotv11") {
|
|
419
|
+
return; // set_msg_emoji_like 是 onebot 专属特殊 API,icqq 不支持
|
|
426
420
|
}
|
|
427
421
|
|
|
428
422
|
try {
|
|
429
|
-
await bot.
|
|
423
|
+
await bot.sendApi("set_msg_emoji_like", {
|
|
430
424
|
message_id: messageId,
|
|
431
425
|
emoji_id: MusicPluginRuntime.COMMAND_REACTION_FACE_ID,
|
|
432
426
|
set: true,
|