@zhin.js/adapter-icqq 8.0.7 → 8.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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @zhin.js/adapter-icqq
2
2
 
3
+ ## 8.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [63253bb]
8
+ - Updated dependencies [6fb24dd]
9
+ - Updated dependencies [d162216]
10
+ - Updated dependencies [7427818]
11
+ - Updated dependencies [90da255]
12
+ - Updated dependencies [8e973dc]
13
+ - Updated dependencies [953cfe1]
14
+ - Updated dependencies [0e73866]
15
+ - @zhin.js/plugin-runtime@1.1.6
16
+ - @zhin.js/core@1.5.8
17
+ - @zhin.js/adapter@1.1.8
18
+ - @zhin.js/agent@1.1.9
19
+ - zhin.js@6.0.8
20
+ - @zhin.js/command@1.0.12
21
+
22
+ ## 8.0.8
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [36cb1ca]
27
+ - @zhin.js/core@1.5.7
28
+ - @zhin.js/agent@1.1.8
29
+ - zhin.js@6.0.7
30
+
3
31
  ## 8.0.7
4
32
 
5
33
  ### Patch Changes
package/lib/cq-message.js CHANGED
@@ -76,6 +76,9 @@ function pushCqSegment(segments, type, arg) {
76
76
  case "reply":
77
77
  segments.push({ type: "reply", data: { message_id: arg } });
78
78
  break;
79
+ case "json":
80
+ segments.push({ type: "json", data: { text: arg } });
81
+ break;
79
82
  default:
80
83
  segments.push({ type, data: { text: `[${type}:${arg}]` } });
81
84
  break;
@@ -159,6 +162,8 @@ export function toCqString(content) {
159
162
  }
160
163
  case "reply":
161
164
  return `[reply:${data.message_id ?? data.id}]`;
165
+ case "json":
166
+ return `[json:${data.text ?? ''}]`;
162
167
  default:
163
168
  return segment.toString(seg);
164
169
  }
package/lib/endpoint.js CHANGED
@@ -32,9 +32,9 @@ export class IcqqIpcEndpoint {
32
32
  deleteFriend: (userId) => this.deleteFriend(userId),
33
33
  });
34
34
  control = Object.freeze({
35
- recall: (messageId) => this.recallMessage(messageId),
36
- addReaction: (messageId, emoji) => this.addReaction(messageId, emoji),
37
- removeReaction: (messageId, reactionId) => this.removeReaction(messageId, reactionId),
35
+ recall: (message) => this.recallMessage(message.id),
36
+ addReaction: (message, emoji) => this.addReaction(message.id, emoji),
37
+ removeReaction: (message, reactionId) => this.removeReaction(message.id, reactionId),
38
38
  });
39
39
  #open = false;
40
40
  #started = false;
package/lib/protocol.js CHANGED
@@ -300,6 +300,8 @@ export function formatOutboundBody(payload) {
300
300
  const arg = resolveCqMediaArg('video', item.data);
301
301
  return arg ? `[video:${arg}]` : '';
302
302
  }
303
+ case 'share':
304
+ return formatMusicShareJson(item.data);
303
305
  default:
304
306
  return String(item.data?.text ?? '');
305
307
  }
@@ -315,3 +317,44 @@ function isWireSegment(value) {
315
317
  && value !== null
316
318
  && typeof value.type === 'string';
317
319
  }
320
+ function formatMusicShareJson(data) {
321
+ if (!data)
322
+ return '';
323
+ const config = data.config;
324
+ const title = String(data.title ?? '');
325
+ const desc = String(data.artist ?? '');
326
+ const jumpUrl = String(data.url ?? '');
327
+ const musicUrl = String(data.audio ?? '');
328
+ const preview = String(data.image ?? '');
329
+ const tag = config?.appid === 100497308 ? 'QQ音乐'
330
+ : config?.appid === 100495085 ? '网易云音乐'
331
+ : config?.appid === 100243533 ? '酷我音乐'
332
+ : config?.appid === 205141 ? '酷狗音乐'
333
+ : '音乐';
334
+ const json = {
335
+ app: 'com.tencent.structmsg',
336
+ view: 'music',
337
+ ver: '0.0.0.1',
338
+ desc: 'music',
339
+ prompt: `[分享]${title}`,
340
+ meta: {
341
+ music: {
342
+ action: '',
343
+ android_pkg_name: config?.package ?? '',
344
+ app_type: 1,
345
+ appid: config?.appid ?? 0,
346
+ ctime: 0,
347
+ desc,
348
+ jumpUrl,
349
+ musicUrl,
350
+ preview,
351
+ sourceMsgId: '0',
352
+ source_icon: config?.icon ?? '',
353
+ source_url: '',
354
+ tag,
355
+ title,
356
+ },
357
+ },
358
+ };
359
+ return `[json:${JSON.stringify(json)}]`;
360
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-icqq",
3
- "version": "8.0.7",
3
+ "version": "8.0.9",
4
4
  "description": "Zhin.js ICQQ adapter for Plugin Runtime (IPC daemon client)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -34,20 +34,20 @@
34
34
  "directory": "plugins/adapters/icqq"
35
35
  },
36
36
  "dependencies": {
37
- "@zhin.js/adapter": "1.1.7",
38
- "@zhin.js/command": "1.0.11",
39
- "@zhin.js/core": "1.5.6",
37
+ "@zhin.js/adapter": "1.1.8",
38
+ "@zhin.js/command": "1.0.12",
39
+ "@zhin.js/core": "1.5.8",
40
40
  "@zhin.js/im-contract": "1.0.3",
41
41
  "@zhin.js/logger": "1.0.76",
42
- "@zhin.js/plugin-runtime": "1.1.5"
42
+ "@zhin.js/plugin-runtime": "1.1.6"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "zod": "^4.0.0",
46
- "@zhin.js/adapter": "1.1.7",
47
- "@zhin.js/agent": "1.1.7",
48
- "@zhin.js/core": "1.5.6",
49
- "@zhin.js/plugin-runtime": "1.1.5",
50
- "zhin.js": "6.0.6"
46
+ "@zhin.js/adapter": "1.1.8",
47
+ "@zhin.js/agent": "1.1.9",
48
+ "@zhin.js/core": "1.5.8",
49
+ "@zhin.js/plugin-runtime": "1.1.6",
50
+ "zhin.js": "6.0.8"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "zhin.js": {
@@ -65,8 +65,8 @@
65
65
  "typescript": "^6.0.3",
66
66
  "vitest": "^4.1.10",
67
67
  "zod": "^4.4.3",
68
- "@zhin.js/agent": "1.1.7",
69
- "zhin.js": "6.0.6"
68
+ "@zhin.js/agent": "1.1.9",
69
+ "zhin.js": "6.0.8"
70
70
  },
71
71
  "files": [
72
72
  "adapters",
package/src/cq-message.ts CHANGED
@@ -83,6 +83,9 @@ function pushCqSegment(segments: MessageSegment[], type: string, arg: string): v
83
83
  case "reply":
84
84
  segments.push({ type: "reply", data: { message_id: arg } });
85
85
  break;
86
+ case "json":
87
+ segments.push({ type: "json", data: { text: arg } });
88
+ break;
86
89
  default:
87
90
  segments.push({ type, data: { text: `[${type}:${arg}]` } });
88
91
  break;
@@ -167,6 +170,8 @@ export function toCqString(content: SendContent): string {
167
170
  }
168
171
  case "reply":
169
172
  return `[reply:${data.message_id ?? data.id}]`;
173
+ case "json":
174
+ return `[json:${data.text ?? ''}]`;
170
175
  default:
171
176
  return segment.toString(seg);
172
177
  }
package/src/endpoint.ts CHANGED
@@ -8,6 +8,7 @@ import type {
8
8
  EndpointSendRequest,
9
9
  } from '@zhin.js/adapter';
10
10
  import type { MessageGateway } from '@zhin.js/core/runtime';
11
+ import type { MessageRef } from '@zhin.js/im-contract';
11
12
  import { formatCompact, getAdapterLogger, truncatePreview } from '@zhin.js/logger';
12
13
  import type { CapabilityId } from '@zhin.js/plugin-runtime';
13
14
  import { registerIcqqAgentEndpoint } from './icqq-agent-deps.js';
@@ -113,10 +114,10 @@ export class IcqqIpcEndpoint implements EndpointInstance {
113
114
  deleteFriend: (userId) => this.deleteFriend(userId),
114
115
  });
115
116
  readonly control: EndpointControl = Object.freeze({
116
- recall: (messageId: string) => this.recallMessage(messageId),
117
- addReaction: (messageId: string, emoji: string) => this.addReaction(messageId, emoji),
118
- removeReaction: (messageId: string, reactionId: string) =>
119
- this.removeReaction(messageId, reactionId),
117
+ recall: (message: MessageRef) => this.recallMessage(message.id),
118
+ addReaction: (message: MessageRef, emoji: string) => this.addReaction(message.id, emoji),
119
+ removeReaction: (message: MessageRef, reactionId: string) =>
120
+ this.removeReaction(message.id, reactionId),
120
121
  });
121
122
  #open = false;
122
123
  #started = false;
package/src/protocol.ts CHANGED
@@ -454,6 +454,8 @@ export function formatOutboundBody(payload: unknown): string {
454
454
  const arg = resolveCqMediaArg('video', item.data);
455
455
  return arg ? `[video:${arg}]` : '';
456
456
  }
457
+ case 'share':
458
+ return formatMusicShareJson(item.data);
457
459
  default:
458
460
  return String(item.data?.text ?? '');
459
461
  }
@@ -471,3 +473,49 @@ function isWireSegment(value: unknown): value is IcqqWireSegment {
471
473
  && value !== null
472
474
  && typeof (value as { type?: unknown }).type === 'string';
473
475
  }
476
+
477
+ function formatMusicShareJson(data: Record<string, unknown> | undefined): string {
478
+ if (!data) return '';
479
+ const config = data.config as {
480
+ appid?: number;
481
+ package?: string;
482
+ icon?: string;
483
+ sign?: string;
484
+ } | undefined;
485
+ const title = String(data.title ?? '');
486
+ const desc = String(data.artist ?? '');
487
+ const jumpUrl = String(data.url ?? '');
488
+ const musicUrl = String(data.audio ?? '');
489
+ const preview = String(data.image ?? '');
490
+ const tag = config?.appid === 100497308 ? 'QQ音乐'
491
+ : config?.appid === 100495085 ? '网易云音乐'
492
+ : config?.appid === 100243533 ? '酷我音乐'
493
+ : config?.appid === 205141 ? '酷狗音乐'
494
+ : '音乐';
495
+ const json = {
496
+ app: 'com.tencent.structmsg',
497
+ view: 'music',
498
+ ver: '0.0.0.1',
499
+ desc: 'music',
500
+ prompt: `[分享]${title}`,
501
+ meta: {
502
+ music: {
503
+ action: '',
504
+ android_pkg_name: config?.package ?? '',
505
+ app_type: 1,
506
+ appid: config?.appid ?? 0,
507
+ ctime: 0,
508
+ desc,
509
+ jumpUrl,
510
+ musicUrl,
511
+ preview,
512
+ sourceMsgId: '0',
513
+ source_icon: config?.icon ?? '',
514
+ source_url: '',
515
+ tag,
516
+ title,
517
+ },
518
+ },
519
+ };
520
+ return `[json:${JSON.stringify(json)}]`;
521
+ }