@yaoyuanchao/dingtalk 1.4.18 → 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/monitor.ts +34 -0
- package/src/types.ts +2 -0
package/package.json
CHANGED
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 }>;
|