@satorijs/adapter-lark 3.10.2 → 3.10.4

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
  }
@@ -145,8 +147,10 @@ async function adaptSession(bot, body) {
145
147
  }, "setOption");
146
148
  for (const [key, value] of Object.entries(body.event.action.form_value ?? {})) {
147
149
  if (key.startsWith("@@")) {
148
- if (value) args.push(key.slice(2));
150
+ if (value === false) continue;
151
+ args.push(key.slice(2));
149
152
  } else if (key.startsWith("@")) {
153
+ if (value === false) continue;
150
154
  const [_key] = key.slice(1).split("=", 1);
151
155
  setOption(_key, key.slice(2 + _key.length));
152
156
  } else if (+key * 0 === 0) {
@@ -203,10 +207,12 @@ async function decodeMessage(bot, body, details = true) {
203
207
  text.split(" ").forEach((word) => {
204
208
  if (word.startsWith("@")) {
205
209
  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));
210
+ if (mention) {
211
+ content.push(import_core.h.at(mention.id, { name: mention.name }));
212
+ return;
213
+ }
209
214
  }
215
+ content.push(import_core.h.text(word));
210
216
  });
211
217
  break;
212
218
  }
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.4",
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
  }
@@ -265,8 +267,10 @@ export async function adaptSession<C extends Context>(bot: LarkBot<C>, body: Eve
265
267
  }
266
268
  for (const [key, value] of Object.entries(body.event.action.form_value ?? {})) {
267
269
  if (key.startsWith('@@')) {
268
- if (value) args.push(key.slice(2))
270
+ if (value === false) continue
271
+ args.push(key.slice(2))
269
272
  } else if (key.startsWith('@')) {
273
+ if (value === false) continue
270
274
  const [_key] = key.slice(1).split('=', 1)
271
275
  setOption(_key, key.slice(2 + _key.length))
272
276
  } else if (+key * 0 === 0) {
@@ -327,10 +331,12 @@ export async function decodeMessage<C extends Context = Context>(bot: LarkBot<C>
327
331
  text.split(' ').forEach((word) => {
328
332
  if (word.startsWith('@')) {
329
333
  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))
334
+ if (mention) {
335
+ content.push(h.at(mention.id, { name: mention.name }))
336
+ return
337
+ }
333
338
  }
339
+ content.push(h.text(word))
334
340
  })
335
341
  break
336
342
  }