@satorijs/adapter-lark 3.10.2 → 3.10.3

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/lib/index.cjs CHANGED
@@ -71,10 +71,12 @@ async function adaptMessage(bot, data, session, details = true) {
71
71
  text.split(" ").forEach((word) => {
72
72
  if (word.startsWith("@")) {
73
73
  const mention = data.message.mentions.find((mention2) => mention2.key === word);
74
- content.push(import_core.h.at(mention.id.open_id, { name: mention.name }));
75
- } else {
76
- content.push(word);
74
+ if (mention) {
75
+ content.push(import_core.h.at(mention.id.open_id, { name: mention.name }));
76
+ return;
77
+ }
77
78
  }
79
+ content.push(word);
78
80
  });
79
81
  break;
80
82
  }
@@ -203,10 +205,12 @@ async function decodeMessage(bot, body, details = true) {
203
205
  text.split(" ").forEach((word) => {
204
206
  if (word.startsWith("@")) {
205
207
  const mention = body.mentions.find((mention2) => mention2.key === word);
206
- content.push(import_core.h.at(mention.id, { name: mention.name }));
207
- } else {
208
- content.push(import_core.h.text(word));
208
+ if (mention) {
209
+ content.push(import_core.h.at(mention.id, { name: mention.name }));
210
+ return;
211
+ }
209
212
  }
213
+ content.push(import_core.h.text(word));
210
214
  });
211
215
  break;
212
216
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@satorijs/adapter-lark",
3
3
  "description": "Lark (飞书) Adapter for Satorijs",
4
- "version": "3.10.2",
4
+ "version": "3.10.3",
5
5
  "type": "module",
6
6
  "main": "lib/index.cjs",
7
7
  "types": "lib/index.d.ts",
package/src/utils.ts CHANGED
@@ -188,10 +188,12 @@ export async function adaptMessage<C extends Context = Context>(
188
188
  text.split(' ').forEach((word) => {
189
189
  if (word.startsWith('@')) {
190
190
  const mention = data.message.mentions.find((mention) => mention.key === word)!
191
- content.push(h.at(mention.id.open_id, { name: mention.name }))
192
- } else {
193
- content.push(word)
191
+ if (mention) {
192
+ content.push(h.at(mention.id.open_id, { name: mention.name }))
193
+ return
194
+ }
194
195
  }
196
+ content.push(word)
195
197
  })
196
198
  break
197
199
  }
@@ -327,10 +329,12 @@ export async function decodeMessage<C extends Context = Context>(bot: LarkBot<C>
327
329
  text.split(' ').forEach((word) => {
328
330
  if (word.startsWith('@')) {
329
331
  const mention = body.mentions!.find((mention) => mention.key === word)!
330
- content.push(h.at(mention.id, { name: mention.name }))
331
- } else {
332
- content.push(h.text(word))
332
+ if (mention) {
333
+ content.push(h.at(mention.id, { name: mention.name }))
334
+ return
335
+ }
333
336
  }
337
+ content.push(h.text(word))
334
338
  })
335
339
  break
336
340
  }