@milerliu/feishu 0.1.10 → 0.1.11

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/package.json +1 -1
  2. package/src/send.ts +15 -46
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milerliu/feishu",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "description": "OpenClaw Feishu/Lark channel plugin",
6
6
  "license": "MIT",
package/src/send.ts CHANGED
@@ -101,60 +101,29 @@ export async function sendStreamingMessageFeishu(params: {
101
101
  return sendCardFeishu({ cfg, to, card: fallbackCard });
102
102
  }
103
103
 
104
- // Stream content updates using Feishu message patch API
105
- const chunkSize = 300;
104
+ // Send multiple messages with delay to simulate streaming effect
105
+ const chunkSize = 500;
106
106
  const chunks: string[] = [];
107
107
  for (let i = 0; i < messageText.length; i += chunkSize) {
108
108
  chunks.push(messageText.slice(i, i + chunkSize));
109
109
  }
110
110
 
111
- // Send updates with small delay
112
- for (let i = 0; i < chunks.length; i++) {
113
- const partialContent = chunks.slice(0, i + 1).join("");
114
-
115
- const updateCard = {
116
- header: {
117
- title: {
118
- tag: "plain_text",
119
- content: "AI 回复",
120
- },
121
- },
122
- config: {
123
- wide_screen_mode: true,
124
- streaming_update: true,
125
- },
126
- elements: [
127
- {
128
- tag: "markdown",
129
- content: partialContent,
130
- },
131
- ],
132
- };
133
-
134
- const updateContent = JSON.stringify(updateCard);
135
-
136
- try {
137
- // Use im v1 message patch API for card updates
138
- const updateResponse = await (client as any).im.v1.message.patch({
139
- path: { message_id: messageId },
140
- data: {
141
- msg_type: "interactive",
142
- content: updateContent,
143
- },
144
- });
145
-
146
- if (updateResponse.code !== 0) {
147
- console.error(`Message patch failed: ${updateResponse.msg}`);
148
- }
149
- } catch (err) {
150
- console.error(`Message patch error: ${err}`);
151
- }
111
+ // Send first message
112
+ const firstCard = buildMarkdownCard(chunks[0]);
113
+ const firstResult = await sendCardFeishu({ cfg, to, card: firstCard });
152
114
 
153
- if (i < chunks.length - 1) {
154
- await new Promise((resolve) => setTimeout(resolve, 150));
155
- }
115
+ // Send remaining chunks as separate messages
116
+ for (let i = 1; i < chunks.length; i++) {
117
+ await new Promise((resolve) => setTimeout(resolve, 100));
118
+ const chunkCard = buildMarkdownCard(chunks[i]);
119
+ await sendCardFeishu({ cfg, to, card: chunkCard });
156
120
  }
157
121
 
122
+ return {
123
+ messageId: firstResult.messageId,
124
+ chatId: receiveId,
125
+ };
126
+
158
127
  return {
159
128
  messageId,
160
129
  chatId: receiveId,