mioku-plugin-media 2.1.1 → 2.2.1

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.1.1",
3
+ "version": "2.2.1",
4
4
  "description": "流媒体解析插件,支持哔哩哔哩、抖音、小红书和快手平台",
5
5
  "main": "index.ts",
6
6
  "type": "module",
@@ -19,6 +19,28 @@
19
19
  "config",
20
20
  "ai"
21
21
  ],
22
+ "accessHooks": [
23
+ {
24
+ "id": "哔哩哔哩视频解析",
25
+ "match": "/(?:bilibili\\.com|b23\\.tv|bili2233\\.cn)/",
26
+ "description": "匹配消息中包含的 B站 链接"
27
+ },
28
+ {
29
+ "id": "抖音媒体解析",
30
+ "match": "/(?:douyin\\.com|iesdouyin\\.com)/",
31
+ "description": "匹配消息中包含的 抖音 链接"
32
+ },
33
+ {
34
+ "id": "快手媒体解析",
35
+ "match": "/(?:kuaishou\\.com|chenzhongtech\\.com)/",
36
+ "description": "匹配消息中包含的 快手 链接"
37
+ },
38
+ {
39
+ "id": "小红书媒体解析",
40
+ "match": "/(?:xiaohongshu\\.com|xhslink\\.com)/",
41
+ "description": "匹配消息中包含的 小红书 链接"
42
+ }
43
+ ],
22
44
  "help": {
23
45
  "title": "媒体解析",
24
46
  "description": "自动识别并解析哔哩哔哩、抖音、小红书、快手的视频/图文链接",
@@ -38,5 +60,8 @@
38
60
  "mioku": "workspace:*",
39
61
  "mioki": "^0.16.0"
40
62
  }
63
+ },
64
+ "devDependencies": {
65
+ "jiti": "^2.7.0"
41
66
  }
42
67
  }
@@ -1,8 +1,5 @@
1
1
  import type { MiokiContext } from "mioki";
2
2
  import type { MediaConfig } from "../types";
3
- import type { ParsedMediaUrl } from "../platforms/types";
4
- import type { ParsedMediaResult } from "../types";
5
- import type { SendNodeElement, SendNodeContentElement } from "napcat-sdk";
6
3
 
7
4
  function normalizeErrorMessage(error: unknown): string {
8
5
  if (error instanceof Error && error.message) {
@@ -28,33 +25,4 @@ export async function handleMediaError(options: {
28
25
  const { ctx, error, platform } = options;
29
26
  const errorMessage = normalizeErrorMessage(error);
30
27
  ctx.logger.error(`[media] ${platform} 解析失败: ${errorMessage}`);
31
-
32
- // 尝试获取 bot 发送错误信息给用户
33
- const selfId = event?.self_id != null ? Number(event.self_id) : undefined;
34
- const bot =
35
- selfId != null && typeof ctx?.pickBot === "function"
36
- ? ctx.pickBot(selfId)
37
- : undefined;
38
-
39
- if (!bot) return;
40
-
41
- const nickname = String(
42
- ctx?.bot?.nickname || event?.sender?.card || event?.sender?.nickname || "媒体解析",
43
- );
44
- const userId = String(selfId || ctx?.bot?.bot_id || 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
  }