@yaoyuanchao/dingtalk 1.4.0 → 1.4.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/monitor.ts +30 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaoyuanchao/dingtalk",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "type": "module",
5
5
  "description": "DingTalk channel plugin for Clawdbot with Stream Mode support",
6
6
  "license": "MIT",
package/src/monitor.ts CHANGED
@@ -152,11 +152,41 @@ async function extractMessageContent(
152
152
  };
153
153
  }
154
154
 
155
+ case 'chatRecord': {
156
+ // Chat record collection - contains multiple forwarded messages
157
+ const chatRecordContent = content || (msg as any).chatRecord;
158
+ log?.info?.("[dingtalk] chatRecord message received, raw structure: " + JSON.stringify(chatRecordContent));
159
+
160
+ if (chatRecordContent?.recordList && Array.isArray(chatRecordContent.recordList)) {
161
+ // Parse recordList into readable text
162
+ const records = chatRecordContent.recordList.map((record: any, idx: number) => {
163
+ const sender = record.senderNick || record.senderName || '未知用户';
164
+ const msgContent = record.text || record.content || '[不支持的消息类型]';
165
+ const time = record.createAt ? new Date(record.createAt).toLocaleString('zh-CN') : '';
166
+ return `[${idx + 1}] ${sender}${time ? ` (${time})` : ''}: ${msgContent}`;
167
+ });
168
+ const text = `[聊天记录合集 - ${records.length}条消息]\n${records.join('\n')}`;
169
+ return {
170
+ text,
171
+ messageType: 'chatRecord',
172
+ };
173
+ }
174
+
175
+ // Fallback if structure is different
176
+ log?.info?.("[dingtalk] chatRecord structure not recognized, full msg: " + JSON.stringify(msg));
177
+ return {
178
+ text: '[聊天记录合集]',
179
+ messageType: 'chatRecord',
180
+ };
181
+ }
182
+
155
183
  default: {
156
184
  // Fallback: try text.content for unknown message types
157
185
  const text = msg.text?.content?.trim() || '';
158
186
  if (!text) {
159
187
  log?.info?.("[dingtalk] Unknown msgtype: " + msgtype + ", no text content found");
188
+ // Log full message structure for debugging unknown types
189
+ log?.info?.("[dingtalk] Unknown msgtype full structure: " + JSON.stringify(msg).slice(0, 1000));
160
190
  }
161
191
  return {
162
192
  text: text || `[${msgtype}消息]`,