@wahooks/channel 0.9.0 → 0.9.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 +20 -32
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -316,8 +316,11 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
316
316
|
case "wahooks_reply":
|
|
317
317
|
case "wahooks_send": {
|
|
318
318
|
const chatId = toChatId(args.to);
|
|
319
|
-
//
|
|
320
|
-
api("POST", `/connections/${connectionId}/typing`, { chatId }).catch(() => { });
|
|
319
|
+
// Human-like: typing → random delay → stop typing → send
|
|
320
|
+
await api("POST", `/connections/${connectionId}/typing`, { chatId }).catch(() => { });
|
|
321
|
+
const delay = 1000 + Math.random() * 2000 + Math.min(args.text.length * 40, 4000);
|
|
322
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
323
|
+
await api("POST", `/connections/${connectionId}/typing/stop`, { chatId }).catch(() => { });
|
|
321
324
|
await api("POST", `/connections/${connectionId}/send`, {
|
|
322
325
|
chatId,
|
|
323
326
|
text: args.text,
|
|
@@ -325,40 +328,25 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
325
328
|
});
|
|
326
329
|
return { content: [{ type: "text", text: `Sent to ${args.to}` }] };
|
|
327
330
|
}
|
|
328
|
-
case "wahooks_send_image":
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
chatId: toChatId(args.to),
|
|
332
|
-
...media,
|
|
333
|
-
caption: args.caption,
|
|
334
|
-
});
|
|
335
|
-
return { content: [{ type: "text", text: `Image sent to ${args.to}` }] };
|
|
336
|
-
}
|
|
337
|
-
case "wahooks_send_document": {
|
|
338
|
-
const media = resolveMedia(args);
|
|
339
|
-
await api("POST", `/connections/${connectionId}/send-document`, {
|
|
340
|
-
chatId: toChatId(args.to),
|
|
341
|
-
...media,
|
|
342
|
-
caption: args.caption,
|
|
343
|
-
});
|
|
344
|
-
return { content: [{ type: "text", text: `Document sent to ${args.to}` }] };
|
|
345
|
-
}
|
|
346
|
-
case "wahooks_send_video": {
|
|
347
|
-
const media = resolveMedia(args);
|
|
348
|
-
await api("POST", `/connections/${connectionId}/send-video`, {
|
|
349
|
-
chatId: toChatId(args.to),
|
|
350
|
-
...media,
|
|
351
|
-
caption: args.caption,
|
|
352
|
-
});
|
|
353
|
-
return { content: [{ type: "text", text: `Video sent to ${args.to}` }] };
|
|
354
|
-
}
|
|
331
|
+
case "wahooks_send_image":
|
|
332
|
+
case "wahooks_send_document":
|
|
333
|
+
case "wahooks_send_video":
|
|
355
334
|
case "wahooks_send_audio": {
|
|
335
|
+
const chatId = toChatId(args.to);
|
|
356
336
|
const media = resolveMedia(args);
|
|
357
|
-
|
|
358
|
-
|
|
337
|
+
const endpoint = req.params.name.replace("wahooks_", "").replace("_", "-");
|
|
338
|
+
// Human-like: typing → delay → stop typing → send
|
|
339
|
+
await api("POST", `/connections/${connectionId}/typing`, { chatId }).catch(() => { });
|
|
340
|
+
await new Promise((r) => setTimeout(r, 1500 + Math.random() * 2000));
|
|
341
|
+
await api("POST", `/connections/${connectionId}/typing/stop`, { chatId }).catch(() => { });
|
|
342
|
+
await api("POST", `/connections/${connectionId}/${endpoint}`, {
|
|
343
|
+
chatId,
|
|
359
344
|
...media,
|
|
345
|
+
caption: args.caption,
|
|
346
|
+
filename: args.filename,
|
|
360
347
|
});
|
|
361
|
-
|
|
348
|
+
const type = endpoint.replace("send-", "");
|
|
349
|
+
return { content: [{ type: "text", text: `${type} sent to ${args.to}` }] };
|
|
362
350
|
}
|
|
363
351
|
case "wahooks_send_location": {
|
|
364
352
|
await api("POST", `/connections/${connectionId}/send-location`, {
|