@wahooks/channel 0.5.2 → 0.6.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.
- package/dist/index.js +12 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -353,8 +353,10 @@ function connectWebSocket() {
|
|
|
353
353
|
// so the reply tool can use it directly as a chat ID
|
|
354
354
|
const from = payload.from ?? "";
|
|
355
355
|
const text = payload.body ?? payload.text ?? "";
|
|
356
|
+
const hasMedia = payload.hasMedia === true;
|
|
357
|
+
const media = payload.media;
|
|
356
358
|
const messageId = payload.id?._serialized ?? payload.id ?? `msg_${Date.now()}`;
|
|
357
|
-
if (!from || !text)
|
|
359
|
+
if (!from || (!text && !hasMedia))
|
|
358
360
|
return;
|
|
359
361
|
// Sender gating (compare bare number against allow list)
|
|
360
362
|
const bareNumber = from.replace(/@.*$/, "");
|
|
@@ -377,18 +379,25 @@ function connectWebSocket() {
|
|
|
377
379
|
console.error(`[wahooks-channel] Permission verdict: ${permMatch[1]} ${permMatch[2]}`);
|
|
378
380
|
return;
|
|
379
381
|
}
|
|
382
|
+
// Build message content for Claude
|
|
383
|
+
let content = text;
|
|
384
|
+
if (hasMedia && media?.url) {
|
|
385
|
+
const mime = media.mimetype ?? "unknown";
|
|
386
|
+
content = `${text ? text + "\n\n" : ""}[Attached: ${mime}]\nDownload URL: ${media.url}`;
|
|
387
|
+
}
|
|
380
388
|
// Forward to Claude Code
|
|
381
389
|
await mcp.notification({
|
|
382
390
|
method: "notifications/claude/channel",
|
|
383
391
|
params: {
|
|
384
|
-
content
|
|
392
|
+
content,
|
|
385
393
|
meta: {
|
|
386
394
|
from,
|
|
387
395
|
message_id: messageId,
|
|
396
|
+
...(hasMedia ? { has_media: "true", media_type: media?.mimetype ?? "unknown" } : {}),
|
|
388
397
|
},
|
|
389
398
|
},
|
|
390
399
|
});
|
|
391
|
-
console.error(`[wahooks-channel] Message from ${from}: ${text.slice(0, 80)}`);
|
|
400
|
+
console.error(`[wahooks-channel] Message from ${from}: ${text.slice(0, 80)}${hasMedia ? " [+media]" : ""}`);
|
|
392
401
|
}
|
|
393
402
|
catch (err) {
|
|
394
403
|
console.error("[wahooks-channel] Event parse error:", err);
|