openclaw-channel-dmwork 0.3.1 → 0.3.2
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 +2 -2
- package/src/inbound.ts +25 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-channel-dmwork",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "DMWork channel plugin for OpenClaw via WuKongIM WebSocket",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -49,4 +49,4 @@
|
|
|
49
49
|
"curve25519-js",
|
|
50
50
|
"md5-typescript"
|
|
51
51
|
]
|
|
52
|
-
}
|
|
52
|
+
}
|
package/src/inbound.ts
CHANGED
|
@@ -138,22 +138,36 @@ function resolveContent(payload: BotMessage["payload"], apiUrl?: string): Resolv
|
|
|
138
138
|
const makeFullUrl = (relUrl?: string) => {
|
|
139
139
|
if (!relUrl) return undefined;
|
|
140
140
|
if (relUrl.startsWith("http")) return relUrl;
|
|
141
|
-
|
|
141
|
+
// Build public file URL: strip /api suffix from apiUrl, strip "preview/" from path
|
|
142
|
+
// e.g. "file/preview/chat/xxx/img.jpg" → "https://host/file/chat/xxx/img.jpg"
|
|
143
|
+
const baseUrl = apiUrl?.replace(/\/+$/, "").replace(/\/api$/i, "") ?? "";
|
|
144
|
+
const cleanPath = relUrl.replace(/^file\/preview\//, "file/");
|
|
145
|
+
return `${baseUrl}/${cleanPath}`;
|
|
142
146
|
};
|
|
143
147
|
|
|
144
148
|
switch (payload.type) {
|
|
145
149
|
case MessageType.Text:
|
|
146
150
|
return { text: payload.content ?? "" };
|
|
147
|
-
case MessageType.Image:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
case MessageType.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
case MessageType.
|
|
156
|
-
|
|
151
|
+
case MessageType.Image: {
|
|
152
|
+
const imgUrl = makeFullUrl(payload.url);
|
|
153
|
+
return { text: `[图片]\n${imgUrl ?? ""}`.trim(), mediaUrl: imgUrl, mediaType: "image" };
|
|
154
|
+
}
|
|
155
|
+
case MessageType.GIF: {
|
|
156
|
+
const gifUrl = makeFullUrl(payload.url);
|
|
157
|
+
return { text: `[GIF]\n${gifUrl ?? ""}`.trim(), mediaUrl: gifUrl, mediaType: "image" };
|
|
158
|
+
}
|
|
159
|
+
case MessageType.Voice: {
|
|
160
|
+
const voiceUrl = makeFullUrl(payload.url);
|
|
161
|
+
return { text: `[语音消息]\n${voiceUrl ?? ""}`.trim(), mediaUrl: voiceUrl, mediaType: "audio" };
|
|
162
|
+
}
|
|
163
|
+
case MessageType.Video: {
|
|
164
|
+
const videoUrl = makeFullUrl(payload.url);
|
|
165
|
+
return { text: `[视频]\n${videoUrl ?? ""}`.trim(), mediaUrl: videoUrl, mediaType: "video" };
|
|
166
|
+
}
|
|
167
|
+
case MessageType.File: {
|
|
168
|
+
const fileUrl = makeFullUrl(payload.url);
|
|
169
|
+
return { text: `[文件: ${payload.name ?? "未知文件"}]\n${fileUrl ?? ""}`.trim(), mediaUrl: fileUrl, mediaType: "file" };
|
|
170
|
+
}
|
|
157
171
|
case MessageType.Location: {
|
|
158
172
|
const lat = payload.latitude ?? payload.lat;
|
|
159
173
|
const lng = payload.longitude ?? payload.lng ?? payload.lon;
|