@yaoyuanchao/dingtalk 1.4.17 → 1.4.19
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/package.json +1 -1
- package/src/channel.ts +8 -1
- package/src/config-schema.ts +2 -2
- package/src/monitor.ts +34 -0
- package/src/types.ts +2 -0
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -427,7 +427,14 @@ export const dingtalkPlugin = {
|
|
|
427
427
|
}
|
|
428
428
|
|
|
429
429
|
console.log(`[dingtalk] sendAttachment success: ${filename}`);
|
|
430
|
-
|
|
430
|
+
// Return format compatible with SDK expectations
|
|
431
|
+
return {
|
|
432
|
+
ok: true,
|
|
433
|
+
channel: 'dingtalk',
|
|
434
|
+
filename,
|
|
435
|
+
// SDK expects content array format for tool results
|
|
436
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: true, filename }) }],
|
|
437
|
+
};
|
|
431
438
|
},
|
|
432
439
|
},
|
|
433
440
|
|
package/src/config-schema.ts
CHANGED
|
@@ -81,8 +81,8 @@ export const dingTalkConfigSchema = z.object({
|
|
|
81
81
|
' - chunk: Split into multiple messages (default, same as official channels)\n' +
|
|
82
82
|
' - file: Convert to .md file and send as attachment'
|
|
83
83
|
),
|
|
84
|
-
longTextThreshold: z.number().int().positive().default(
|
|
85
|
-
.describe('Character threshold for longTextMode=file (default
|
|
84
|
+
longTextThreshold: z.number().int().positive().default(8000).optional()
|
|
85
|
+
.describe('Character threshold for longTextMode=file (default 8000)'),
|
|
86
86
|
}).strict();
|
|
87
87
|
|
|
88
88
|
// 导出配置类型
|
package/src/monitor.ts
CHANGED
|
@@ -152,6 +152,40 @@ async function extractMessageContent(
|
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
case 'link': {
|
|
156
|
+
// Link card message - contains title, text, messageUrl, and optional picUrl
|
|
157
|
+
// Structure: msg.link = { title, text, messageUrl, picUrl }
|
|
158
|
+
const linkContent = msg.link || content;
|
|
159
|
+
log?.info?.("[dingtalk] link message received: " + JSON.stringify(linkContent));
|
|
160
|
+
|
|
161
|
+
if (linkContent) {
|
|
162
|
+
const title = linkContent.title || '';
|
|
163
|
+
const text = linkContent.text || '';
|
|
164
|
+
const messageUrl = linkContent.messageUrl || '';
|
|
165
|
+
const picUrl = linkContent.picUrl || '';
|
|
166
|
+
|
|
167
|
+
// Combine all parts into a readable format
|
|
168
|
+
const parts: string[] = [];
|
|
169
|
+
if (title) parts.push(`[链接] ${title}`);
|
|
170
|
+
if (text) parts.push(text);
|
|
171
|
+
if (messageUrl) parts.push(`链接: ${messageUrl}`);
|
|
172
|
+
if (picUrl) parts.push(`配图: ${picUrl}`);
|
|
173
|
+
|
|
174
|
+
const resultText = parts.join('\n') || '[链接卡片]';
|
|
175
|
+
log?.info?.("[dingtalk] Extracted link message: " + resultText.slice(0, 100));
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
text: resultText,
|
|
179
|
+
messageType: 'link',
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
text: '[链接卡片]',
|
|
185
|
+
messageType: 'link',
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
155
189
|
case 'chatRecord': {
|
|
156
190
|
// Chat record collection - contains multiple forwarded messages
|
|
157
191
|
// Structure: content.chatRecord is a JSON string containing an array of messages
|
package/src/types.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface DingTalkRobotMessage {
|
|
|
18
18
|
text?: { content: string; isReplyMsg?: boolean; repliedMsg?: any };
|
|
19
19
|
richText?: unknown;
|
|
20
20
|
picture?: { downloadCode: string };
|
|
21
|
+
/** Link card message content */
|
|
22
|
+
link?: { title?: string; text?: string; messageUrl?: string; picUrl?: string };
|
|
21
23
|
/** Generic content field used by audio/video/file message types */
|
|
22
24
|
content?: any;
|
|
23
25
|
atUsers?: Array<{ dingtalkId: string; staffId?: string }>;
|