@satorijs/adapter-lark 3.10.0 → 3.10.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/lib/index.cjs CHANGED
@@ -136,11 +136,23 @@ async function adaptSession(bot, body) {
136
136
  session.type = "interaction/command";
137
137
  let content = body.event.action.value.content;
138
138
  const args = [], options = /* @__PURE__ */ Object.create(null);
139
+ const setOption = /* @__PURE__ */ __name((key, value) => {
140
+ if (key in options) {
141
+ options[key] += "," + value;
142
+ } else {
143
+ options[key] = value;
144
+ }
145
+ }, "setOption");
139
146
  for (const [key, value] of Object.entries(body.event.action.form_value ?? {})) {
140
- if (+key * 0 === 0) {
147
+ if (key.startsWith("@@")) {
148
+ if (value) args.push(key.slice(2));
149
+ } else if (key.startsWith("@")) {
150
+ const [_key] = key.slice(1).split("=", 1);
151
+ setOption(_key, key.slice(2 + _key.length));
152
+ } else if (+key * 0 === 0) {
141
153
  args[+key] = value;
142
154
  } else {
143
- options[key] = value;
155
+ setOption(key, value);
144
156
  }
145
157
  }
146
158
  const toArg = /* @__PURE__ */ __name((value) => {
@@ -155,9 +167,9 @@ async function adaptSession(bot, body) {
155
167
  }
156
168
  for (const [key, value] of Object.entries(options)) {
157
169
  if (value === true) {
158
- content += ` --${key}`;
170
+ content += ` --${key} 1`;
159
171
  } else if (value === false) {
160
- content += ` --no-${key}`;
172
+ content += ` --${key} 0`;
161
173
  } else {
162
174
  content += ` --${key} ${toArg(value)}`;
163
175
  }
@@ -638,7 +650,7 @@ var LarkMessageEncoder = class extends import_core3.MessageEncoder {
638
650
  await this.render(children);
639
651
  this.card?.elements.push({
640
652
  tag: "checker",
641
- name: attrs.name,
653
+ name: (attrs.argument ? "@@" : attrs.option ? `@${attrs.option}=` : "") + attrs.name,
642
654
  checked: attrs.checked,
643
655
  text: {
644
656
  tag: "plain_text",
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.0",
4
+ "version": "3.10.1",
5
5
  "type": "module",
6
6
  "main": "lib/index.cjs",
7
7
  "types": "lib/index.d.ts",
package/src/message.ts CHANGED
@@ -266,7 +266,7 @@ export class LarkMessageEncoder<C extends Context = Context> extends MessageEnco
266
266
  await this.render(children)
267
267
  this.card?.elements.push({
268
268
  tag: 'checker',
269
- name: attrs.name,
269
+ name: (attrs.argument ? '@@' : attrs.option ? `@${attrs.option}=` : '') + attrs.name,
270
270
  checked: attrs.checked,
271
271
  text: {
272
272
  tag: 'plain_text',
package/src/utils.ts CHANGED
@@ -256,11 +256,23 @@ export async function adaptSession<C extends Context>(bot: LarkBot<C>, body: Eve
256
256
  session.type = 'interaction/command'
257
257
  let content = body.event.action.value.content
258
258
  const args: any[] = [], options = Object.create(null)
259
+ const setOption = (key: string, value: any) => {
260
+ if (key in options) {
261
+ options[key] += ',' + value
262
+ } else {
263
+ options[key] = value
264
+ }
265
+ }
259
266
  for (const [key, value] of Object.entries(body.event.action.form_value ?? {})) {
260
- if (+key * 0 === 0) {
267
+ if (key.startsWith('@@')) {
268
+ if (value) args.push(key.slice(2))
269
+ } else if (key.startsWith('@')) {
270
+ const [_key] = key.slice(1).split('=', 1)
271
+ setOption(_key, key.slice(2 + _key.length))
272
+ } else if (+key * 0 === 0) {
261
273
  args[+key] = value
262
274
  } else {
263
- options[key] = value
275
+ setOption(key, value)
264
276
  }
265
277
  }
266
278
  const toArg = (value: any) => {
@@ -275,9 +287,9 @@ export async function adaptSession<C extends Context>(bot: LarkBot<C>, body: Eve
275
287
  }
276
288
  for (const [key, value] of Object.entries(options)) {
277
289
  if (value === true) {
278
- content += ` --${key}`
290
+ content += ` --${key} 1`
279
291
  } else if (value === false) {
280
- content += ` --no-${key}`
292
+ content += ` --${key} 0`
281
293
  } else {
282
294
  content += ` --${key} ${toArg(value)}`
283
295
  }