@xmanrui/dsh-im 4.5.0 → 4.6.0
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/client.js +4 -1
- package/lib/index.js +247 -239
- package/package.json +1 -1
- package/src/channels/dingtalk/dingtalk-bridge.mjs +166 -20
- package/src/channels/dingtalk/dingtalk-card-stream.mjs +9 -2
- package/src/channels/dingtalk/state-store.mjs +98 -0
- package/src/channels/discord/discord-api.mjs +7 -0
- package/src/channels/discord/discord-runtime.mjs +97 -2
- package/src/channels/feishu/bridge.mjs +11 -5
- package/src/channels/feishu/message-utils.mjs +229 -0
- package/src/channels/qq/qq-bridge.mjs +48 -6
- package/src/channels/shared/batch-input.mjs +3 -3
- package/src/channels/shared/harness-client.mjs +82 -30
- package/src/channels/shared/i18n-en/shared-c.mjs +6 -4
- package/src/channels/shared/image-prompt.mjs +51 -0
- package/src/channels/shared/semantic/reply-reference.mjs +153 -0
- package/src/channels/shared/session-reply-recovery.mjs +104 -0
- package/src/channels/shared/session-title.mjs +1 -1
- package/src/channels/shared/text-harness-bridge.mjs +12 -6
- package/src/channels/slack/manifest.mjs +3 -0
- package/src/channels/slack/slack-api.mjs +18 -0
- package/src/channels/slack/slack-runtime.mjs +56 -0
- package/src/channels/telegram/telegram-runtime.mjs +117 -2
- package/src/channels/wecom/wecom-bridge.mjs +49 -7
- package/src/channels/weixin/state-store.mjs +110 -0
- package/src/channels/weixin/weixin-api.mjs +86 -2
- package/src/channels/weixin/weixin-bridge.mjs +96 -9
- package/src/channels/weixin/weixin-runtime.mjs +26 -6
- package/src/channels/whatsapp/whatsapp-runtime.mjs +56 -0
|
@@ -96,6 +96,60 @@ function messageText(content) {
|
|
|
96
96
|
?? '';
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
function whatsappReplyAttachment(kind, media, fallbackName) {
|
|
100
|
+
if (!media || typeof media !== 'object') return null;
|
|
101
|
+
const name = typeof media.fileName === 'string' && media.fileName
|
|
102
|
+
? media.fileName : typeof fallbackName === 'string' && fallbackName
|
|
103
|
+
? fallbackName : undefined;
|
|
104
|
+
return { kind, ...(name ? { name } : {}) };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function whatsappReplyAttachments(content) {
|
|
108
|
+
const attachments = [];
|
|
109
|
+
if (content?.imageMessage) {
|
|
110
|
+
attachments.push(whatsappReplyAttachment('image', content.imageMessage));
|
|
111
|
+
}
|
|
112
|
+
if (content?.documentMessage) {
|
|
113
|
+
const mediaType = typeof content.documentMessage.mimetype === 'string'
|
|
114
|
+
? content.documentMessage.mimetype.toLowerCase() : '';
|
|
115
|
+
attachments.push(whatsappReplyAttachment(
|
|
116
|
+
mediaType.startsWith('image/') ? 'image' : 'file',
|
|
117
|
+
content.documentMessage,
|
|
118
|
+
));
|
|
119
|
+
}
|
|
120
|
+
if (content?.audioMessage) {
|
|
121
|
+
attachments.push(whatsappReplyAttachment('audio', content.audioMessage));
|
|
122
|
+
}
|
|
123
|
+
if (content?.videoMessage) {
|
|
124
|
+
attachments.push(whatsappReplyAttachment('video', content.videoMessage));
|
|
125
|
+
}
|
|
126
|
+
if (content?.stickerMessage) {
|
|
127
|
+
const mediaType = typeof content.stickerMessage.mimetype === 'string'
|
|
128
|
+
? content.stickerMessage.mimetype.toLowerCase() : '';
|
|
129
|
+
attachments.push(whatsappReplyAttachment(
|
|
130
|
+
mediaType.startsWith('video/') || content.stickerMessage.isAnimated === true
|
|
131
|
+
? 'video' : 'image',
|
|
132
|
+
content.stickerMessage,
|
|
133
|
+
));
|
|
134
|
+
}
|
|
135
|
+
return attachments.filter(Boolean);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function whatsappReplyReference(context) {
|
|
139
|
+
if (!context?.quotedMessage || typeof context.quotedMessage !== 'object') return undefined;
|
|
140
|
+
const content = normalizeMessageContent(context.quotedMessage);
|
|
141
|
+
const messageId = typeof context.stanzaId === 'string' && context.stanzaId
|
|
142
|
+
? context.stanzaId : undefined;
|
|
143
|
+
const authorId = typeof context.participant === 'string' && context.participant
|
|
144
|
+
? context.participant : undefined;
|
|
145
|
+
return {
|
|
146
|
+
...(messageId ? { messageId } : {}),
|
|
147
|
+
...(authorId ? { authorId } : {}),
|
|
148
|
+
content: messageText(content),
|
|
149
|
+
attachments: whatsappReplyAttachments(content),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
99
153
|
function mediaSize(value) {
|
|
100
154
|
if (Number.isSafeInteger(value) && value >= 0) return value;
|
|
101
155
|
let converted;
|
|
@@ -260,6 +314,7 @@ export function normalizeWhatsappMessage(message, accountJid, {
|
|
|
260
314
|
&& areJidsSameUser(context.participant, accountJid);
|
|
261
315
|
const image = whatsappImageSource(message, content, download, { viewOnce });
|
|
262
316
|
const file = whatsappFileSource(message, content, download);
|
|
317
|
+
const replyTo = whatsappReplyReference(context);
|
|
263
318
|
return {
|
|
264
319
|
messageId: `${remoteJid}:${messageId}`,
|
|
265
320
|
providerMessageId: messageId,
|
|
@@ -274,6 +329,7 @@ export function normalizeWhatsappMessage(message, accountJid, {
|
|
|
274
329
|
|| typeof content?.extendedTextMessage?.text === 'string',
|
|
275
330
|
images: image ? [image] : [],
|
|
276
331
|
files: file ? [file] : [],
|
|
332
|
+
...(replyTo ? { replyTo } : {}),
|
|
277
333
|
addressed: !group || fromMe || mentioned || replyToSelf,
|
|
278
334
|
selfChat,
|
|
279
335
|
replyTarget: { jid: remoteJid, quoted: message, selfChat },
|