mioku-plugin-media 2.2.0 → 2.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mioku-plugin-media",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "流媒体解析插件,支持哔哩哔哩、抖音、小红书和快手平台",
5
5
  "main": "index.ts",
6
6
  "type": "module",
package/runtime.ts CHANGED
@@ -10,11 +10,11 @@ const PLUGIN_NAME = "media";
10
10
  export function setMediaRuntimeState(
11
11
  nextState: Partial<MediaRuntimeState>,
12
12
  ): MediaRuntimeState {
13
- return setPluginRuntimeState<MediaRuntimeState>(PLUGIN_NAME, nextState);
13
+ return setPluginRuntimeState(PLUGIN_NAME, nextState) as MediaRuntimeState;
14
14
  }
15
15
 
16
16
  export function getMediaRuntimeState(): MediaRuntimeState {
17
- return getPluginRuntimeState<MediaRuntimeState>(PLUGIN_NAME);
17
+ return getPluginRuntimeState(PLUGIN_NAME) as MediaRuntimeState;
18
18
  }
19
19
 
20
20
  export function resetMediaRuntimeState(): void {
package/skills.ts CHANGED
@@ -31,7 +31,9 @@ const mediaSkills: AISkill[] = [
31
31
  required: ["url"],
32
32
  },
33
33
  handler: async (args: any, runtimeCtx?: any) => {
34
- const runtime = getMediaRuntimeState();
34
+ const runtime = getMediaRuntimeState() as unknown as {
35
+ amagiClient?: Parameters<typeof resolveMedia>[0];
36
+ };
35
37
  if (!runtime.amagiClient) {
36
38
  return "媒体解析插件尚未初始化";
37
39
  }
@@ -55,7 +57,7 @@ const mediaSkills: AISkill[] = [
55
57
  }
56
58
  }
57
59
 
58
- const result = await resolveMedia(runtime.amagiClient, parsed);
60
+ const result = await resolveMedia(runtime.amagiClient as any, parsed);
59
61
  const info = buildInfoMessage(parsed, result);
60
62
 
61
63
  const ctx = runtimeCtx?.ctx;
@@ -22,39 +22,7 @@ export async function handleMediaError(options: {
22
22
  platform: string;
23
23
  config: MediaConfig;
24
24
  }): Promise<void> {
25
- const { ctx, event, error, platform } = options;
25
+ const { ctx, error, platform } = options;
26
26
  const errorMessage = normalizeErrorMessage(error);
27
27
  ctx.logger.error(`[media] ${platform} 解析失败: ${errorMessage}`);
28
-
29
- // 尝试获取 bot 发送错误信息给用户
30
- const selfId = event?.self_id != null ? Number(event.self_id) : undefined;
31
- const bot =
32
- selfId != null && typeof ctx?.pickBot === "function"
33
- ? ctx.pickBot(selfId)
34
- : undefined;
35
-
36
- if (!bot) return;
37
-
38
- const nickname = String(
39
- ctx?.bot?.nickname ||
40
- event?.sender?.card ||
41
- event?.sender?.nickname ||
42
- "媒体解析",
43
- );
44
- const userId = String(selfId || event?.self_id || 0);
45
-
46
- // 构建错误提示消息
47
- const errorText = `【${platform}】解析失败\n${errorMessage}`;
48
-
49
- try {
50
- if (event?.message_type === "group" && event?.group_id != null) {
51
- await bot.sendGroupMsg(event.group_id, [ctx.segment.text(errorText)]);
52
- return;
53
- }
54
- if (event?.user_id != null) {
55
- await bot.sendPrivateMsg(event.user_id, [ctx.segment.text(errorText)]);
56
- }
57
- } catch {
58
- // ignore send errors
59
- }
60
28
  }