koishi-plugin-codec-tools 1.1.0 → 1.1.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.
Files changed (2) hide show
  1. package/lib/index.js +10 -2
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -16,24 +16,31 @@ exports.name = 'codec-tools';
16
16
  exports.using = ['i18n'];
17
17
  exports.Config = koishi_1.Schema.object({}).i18n({ 'zh-CN': {} });
18
18
  async function getImageUrl(session) {
19
+ console.log('session.elements:', JSON.stringify(session.elements, null, 2));
19
20
  let imageUrl = null;
20
21
  session.elements.forEach(el => {
21
22
  if (el.type === 'image' && el.attrs?.src) {
22
23
  imageUrl = el.attrs.src;
24
+ console.log('找到当前消息图片:', imageUrl);
23
25
  }
24
26
  });
25
27
  if (imageUrl)
26
28
  return imageUrl;
27
29
  if (session.quote) {
30
+ console.log('尝试获取引用消息:', session.quote.messageId);
28
31
  try {
29
32
  const msg = await session.bot.getMessage(session.channelId, session.quote.messageId);
33
+ console.log('引用消息内容:', JSON.stringify(msg.elements, null, 2));
30
34
  msg.elements.forEach(el => {
31
35
  if (el.type === 'image' && el.attrs?.src) {
32
36
  imageUrl = el.attrs.src;
37
+ console.log('找到引用消息图片:', imageUrl);
33
38
  }
34
39
  });
35
40
  }
36
- catch (e) { }
41
+ catch (e) {
42
+ console.error('获取引用消息失败:', e);
43
+ }
37
44
  }
38
45
  return imageUrl;
39
46
  }
@@ -51,6 +58,7 @@ function apply(ctx, config) {
51
58
  if (!session)
52
59
  return;
53
60
  const imageUrl = await getImageUrl(session);
61
+ console.log('最终获取到的图片URL:', imageUrl);
54
62
  if (!imageUrl) {
55
63
  await session.send(session.text('.no-image'), { quote: session.messageId });
56
64
  return;
@@ -76,7 +84,7 @@ function apply(ctx, config) {
76
84
  await session.send(session.text('.barcode-content', { content: barcodeResult.text }), { quote: session.messageId });
77
85
  }
78
86
  catch (e) {
79
- console.error(e);
87
+ console.error('解析失败:', e);
80
88
  await session.send(session.text('.no-code'), { quote: session.messageId });
81
89
  }
82
90
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-codec-tools",
3
3
  "description": "编码&解码 URL/Base64/Unicode 和条形码/二维码的 Koishi 插件",
4
- "version": "1.1.0",
4
+ "version": "1.1.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [