@arcaelas/whatsapp 3.4.0 → 4.2.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/build/cjs/lib/contact/index.d.ts +25 -10
- package/build/cjs/lib/contact/index.js +14 -1
- package/build/cjs/lib/contact/index.js.map +1 -1
- package/build/cjs/lib/message/index.d.ts +101 -1
- package/build/cjs/lib/message/index.js +189 -3
- package/build/cjs/lib/message/index.js.map +1 -1
- package/build/cjs/lib/whatsapp/index.d.ts +0 -3
- package/build/cjs/lib/whatsapp/index.js +16 -16
- package/build/cjs/lib/whatsapp/index.js.map +1 -1
- package/build/esm/lib/contact/index.d.ts +25 -10
- package/build/esm/lib/contact/index.js +14 -1
- package/build/esm/lib/contact/index.js.map +1 -1
- package/build/esm/lib/message/index.d.ts +101 -1
- package/build/esm/lib/message/index.js +185 -2
- package/build/esm/lib/message/index.js.map +1 -1
- package/build/esm/lib/whatsapp/index.d.ts +0 -3
- package/build/esm/lib/whatsapp/index.js +16 -16
- package/build/esm/lib/whatsapp/index.js.map +1 -1
- package/package.json +46 -46
- package/build/cjs/_index.d.ts +0 -14
- package/build/cjs/_index.js +0 -366
- package/build/cjs/_index.js.map +0 -1
- package/build/esm/_index.d.ts +0 -14
- package/build/esm/_index.js +0 -364
- package/build/esm/_index.js.map +0 -1
|
@@ -25,8 +25,8 @@ export interface IContactRaw {
|
|
|
25
25
|
export declare class Contact {
|
|
26
26
|
/** @internal Shape persistido. Uso interno (convención underscore). / Internal persisted shape. */
|
|
27
27
|
readonly _raw: IContactRaw;
|
|
28
|
-
/** Chat 1:1 asociado
|
|
29
|
-
readonly
|
|
28
|
+
/** @internal Chat 1:1 asociado ya hidratado. / Internal already-hydrated 1:1 chat. */
|
|
29
|
+
readonly _chat: Chat;
|
|
30
30
|
constructor(raw: IContactRaw, chat: Chat);
|
|
31
31
|
/** JID único. / Unique JID. */
|
|
32
32
|
get id(): string;
|
|
@@ -42,6 +42,13 @@ export declare class Contact {
|
|
|
42
42
|
get photo(): string | null;
|
|
43
43
|
/** Bio del contacto. / Contact bio. */
|
|
44
44
|
get content(): string;
|
|
45
|
+
/**
|
|
46
|
+
* Chat 1:1 asociado al contacto. Async por coherencia con `Message.chat()` /
|
|
47
|
+
* `Message.author()`, aunque la instancia ya está hidratada en memoria.
|
|
48
|
+
* 1:1 chat associated with the contact. Async for consistency with
|
|
49
|
+
* `Message.chat()` / `Message.author()`, though already hydrated in memory.
|
|
50
|
+
*/
|
|
51
|
+
chat(): Promise<Chat>;
|
|
45
52
|
}
|
|
46
53
|
/**
|
|
47
54
|
* Factoría de Contact ligada al contexto WhatsApp.
|
|
@@ -51,8 +58,10 @@ export declare class Contact {
|
|
|
51
58
|
*/
|
|
52
59
|
export declare function contact(wa: WhatsApp): {
|
|
53
60
|
new (raw: IContactRaw, chat: InstanceType<typeof wa.Chat>): {
|
|
54
|
-
/** Chat 1:1
|
|
55
|
-
readonly
|
|
61
|
+
/** @internal Chat 1:1 hidratado como subclase enriquecida. / Internal hydrated 1:1 chat as enriched subclass. */
|
|
62
|
+
readonly _chat: InstanceType<typeof wa.Chat>;
|
|
63
|
+
/** Chat 1:1 asociado (subclase enriquecida). / Associated 1:1 chat (enriched subclass). */
|
|
64
|
+
chat(): Promise<InstanceType<typeof wa.Chat>>;
|
|
56
65
|
/** true si la instancia representa la cuenta autenticada. / true if this instance is the authenticated account. */
|
|
57
66
|
get me(): boolean;
|
|
58
67
|
/**
|
|
@@ -92,8 +101,10 @@ export declare function contact(wa: WhatsApp): {
|
|
|
92
101
|
* - If `uid` lacks `@` → digits are extracted and `socket.onWhatsApp(phone)` resolves the canonical JID.
|
|
93
102
|
*/
|
|
94
103
|
get(uid: string): Promise<{
|
|
95
|
-
/** Chat 1:1
|
|
96
|
-
readonly
|
|
104
|
+
/** @internal Chat 1:1 hidratado como subclase enriquecida. / Internal hydrated 1:1 chat as enriched subclass. */
|
|
105
|
+
readonly _chat: InstanceType<typeof wa.Chat>;
|
|
106
|
+
/** Chat 1:1 asociado (subclase enriquecida). / Associated 1:1 chat (enriched subclass). */
|
|
107
|
+
chat(): Promise<InstanceType<typeof wa.Chat>>;
|
|
97
108
|
/** true si la instancia representa la cuenta autenticada. / true if this instance is the authenticated account. */
|
|
98
109
|
get me(): boolean;
|
|
99
110
|
/**
|
|
@@ -128,8 +139,10 @@ export declare function contact(wa: WhatsApp): {
|
|
|
128
139
|
* Paginates persisted contacts by mtime DESC, pre-loading the chat of each one.
|
|
129
140
|
*/
|
|
130
141
|
list(offset?: number, limit?: number): Promise<{
|
|
131
|
-
/** Chat 1:1
|
|
132
|
-
readonly
|
|
142
|
+
/** @internal Chat 1:1 hidratado como subclase enriquecida. / Internal hydrated 1:1 chat as enriched subclass. */
|
|
143
|
+
readonly _chat: InstanceType<typeof wa.Chat>;
|
|
144
|
+
/** Chat 1:1 asociado (subclase enriquecida). / Associated 1:1 chat (enriched subclass). */
|
|
145
|
+
chat(): Promise<InstanceType<typeof wa.Chat>>;
|
|
133
146
|
/** true si la instancia representa la cuenta autenticada. / true if this instance is the authenticated account. */
|
|
134
147
|
get me(): boolean;
|
|
135
148
|
/**
|
|
@@ -169,8 +182,10 @@ export declare function contact(wa: WhatsApp): {
|
|
|
169
182
|
* Re-hydrates contact data from the socket by id.
|
|
170
183
|
*/
|
|
171
184
|
refresh(uid: string): Promise<{
|
|
172
|
-
/** Chat 1:1
|
|
173
|
-
readonly
|
|
185
|
+
/** @internal Chat 1:1 hidratado como subclase enriquecida. / Internal hydrated 1:1 chat as enriched subclass. */
|
|
186
|
+
readonly _chat: InstanceType<typeof wa.Chat>;
|
|
187
|
+
/** Chat 1:1 asociado (subclase enriquecida). / Associated 1:1 chat (enriched subclass). */
|
|
188
|
+
chat(): Promise<InstanceType<typeof wa.Chat>>;
|
|
174
189
|
/** true si la instancia representa la cuenta autenticada. / true if this instance is the authenticated account. */
|
|
175
190
|
get me(): boolean;
|
|
176
191
|
/**
|
|
@@ -16,7 +16,7 @@ const store_1 = require("../../lib/store");
|
|
|
16
16
|
class Contact {
|
|
17
17
|
constructor(raw, chat) {
|
|
18
18
|
this._raw = raw;
|
|
19
|
-
this.
|
|
19
|
+
this._chat = chat;
|
|
20
20
|
}
|
|
21
21
|
/** JID único. / Unique JID. */
|
|
22
22
|
get id() {
|
|
@@ -46,6 +46,15 @@ class Contact {
|
|
|
46
46
|
get content() {
|
|
47
47
|
return this._raw.status ?? '';
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Chat 1:1 asociado al contacto. Async por coherencia con `Message.chat()` /
|
|
51
|
+
* `Message.author()`, aunque la instancia ya está hidratada en memoria.
|
|
52
|
+
* 1:1 chat associated with the contact. Async for consistency with
|
|
53
|
+
* `Message.chat()` / `Message.author()`, though already hydrated in memory.
|
|
54
|
+
*/
|
|
55
|
+
async chat() {
|
|
56
|
+
return this._chat;
|
|
57
|
+
}
|
|
49
58
|
}
|
|
50
59
|
exports.Contact = Contact;
|
|
51
60
|
/**
|
|
@@ -106,6 +115,10 @@ function contact(wa) {
|
|
|
106
115
|
constructor(raw, chat) {
|
|
107
116
|
super(raw, chat);
|
|
108
117
|
}
|
|
118
|
+
/** Chat 1:1 asociado (subclase enriquecida). / Associated 1:1 chat (enriched subclass). */
|
|
119
|
+
async chat() {
|
|
120
|
+
return this._chat;
|
|
121
|
+
}
|
|
109
122
|
/** true si la instancia representa la cuenta autenticada. / true if this instance is the authenticated account. */
|
|
110
123
|
get me() {
|
|
111
124
|
const self_id = wa._socket?.user?.id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/contact/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/contact/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAkFH,0BAoMC;AApRD,qCAA4C;AAE5C,uCAAqD;AAiBrD;;;GAGG;AACH,MAAa,O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;YACZ,CAAC;YACD,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -13,7 +13,7 @@ export type ForwardTarget = string | Chat | Contact;
|
|
|
13
13
|
type ChatInstance = InstanceType<ReturnType<typeof chat>>;
|
|
14
14
|
type ContactInstance = InstanceType<ReturnType<typeof contact>>;
|
|
15
15
|
/** Tipos de mensaje internos (no expuestos como getter público). */
|
|
16
|
-
export type MessageType = 'text' | 'image' | 'video' | 'audio' | 'location' | 'poll';
|
|
16
|
+
export type MessageType = 'text' | 'image' | 'video' | 'audio' | 'location' | 'poll' | 'document' | 'vcard' | 'event';
|
|
17
17
|
export declare enum MessageStatus {
|
|
18
18
|
ERROR = 0,
|
|
19
19
|
PENDING = 1,
|
|
@@ -35,6 +35,35 @@ export interface SendPollOptions extends SendOptions {
|
|
|
35
35
|
/** true para selección múltiple; default false (single). / true for multi-select; default false (single). */
|
|
36
36
|
multiple?: boolean;
|
|
37
37
|
}
|
|
38
|
+
export interface SendDocumentOptions extends SendOptions {
|
|
39
|
+
/** Nombre del archivo mostrado al receptor. / File name shown to the recipient. */
|
|
40
|
+
file_name: string;
|
|
41
|
+
/** MIME real del contenido; default `application/octet-stream`. / Real content MIME; defaults to `application/octet-stream`. */
|
|
42
|
+
mimetype?: string;
|
|
43
|
+
/** Texto adjunto opcional. / Optional attached caption. */
|
|
44
|
+
caption?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface VCardInput {
|
|
47
|
+
/** Nombre mostrado del contacto. / Contact display name. */
|
|
48
|
+
name: string;
|
|
49
|
+
/** Teléfono en formato internacional. / Phone in international format. */
|
|
50
|
+
phone: string;
|
|
51
|
+
}
|
|
52
|
+
export interface EventInput {
|
|
53
|
+
/** Nombre del evento. / Event name. */
|
|
54
|
+
name: string;
|
|
55
|
+
/** Descripción opcional (texto del evento, expuesto como `caption`). / Optional description (event text, exposed as `caption`). */
|
|
56
|
+
caption?: string;
|
|
57
|
+
/** Fecha/hora de inicio. / Start date/time. */
|
|
58
|
+
start: Date;
|
|
59
|
+
/** Fecha/hora de fin opcional. / Optional end date/time. */
|
|
60
|
+
end?: Date;
|
|
61
|
+
/** Ubicación opcional. / Optional location. */
|
|
62
|
+
place?: {
|
|
63
|
+
lat: number;
|
|
64
|
+
lng: number;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
38
67
|
export interface LocationOptions {
|
|
39
68
|
lat: number;
|
|
40
69
|
lng: number;
|
|
@@ -167,6 +196,12 @@ export declare class Message {
|
|
|
167
196
|
location(loc: LocationOptions, opts?: SendOptions): Promise<Message | null>;
|
|
168
197
|
/** Responde con encuesta. */
|
|
169
198
|
poll(poll: PollOptions, opts?: SendPollOptions): Promise<Message | null>;
|
|
199
|
+
/** Responde con documento. */
|
|
200
|
+
document(buf: Buffer, opts: SendDocumentOptions): Promise<Message | null>;
|
|
201
|
+
/** Responde con tarjeta(s) de contacto. */
|
|
202
|
+
vcard(contacts: VCardInput[], opts?: SendOptions): Promise<Message | null>;
|
|
203
|
+
/** Responde con evento. */
|
|
204
|
+
event(data: EventInput, opts?: SendOptions): Promise<Message | null>;
|
|
170
205
|
}
|
|
171
206
|
/**
|
|
172
207
|
* Mensaje de texto. Override `content()` para retornar el caption como Buffer sin pasar por engine.
|
|
@@ -241,6 +276,65 @@ export declare class Poll extends Message {
|
|
|
241
276
|
*/
|
|
242
277
|
select(index: number | number[]): Promise<boolean>;
|
|
243
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Mensaje de documento. WhatsApp permite enviar cualquier archivo (PDF, imagen,
|
|
281
|
+
* audio, video, etc.) como documento; lo que lo distingue de image/video/audio es
|
|
282
|
+
* el tipo de mensaje (`documentMessage`), no el mimetype. Hereda `stream()` de la
|
|
283
|
+
* clase base; `content()` drena el stream (cache → download).
|
|
284
|
+
* Document message. WhatsApp lets you send any file (PDF, image, audio, video…)
|
|
285
|
+
* as a document; what sets it apart from image/video/audio is the message type
|
|
286
|
+
* (`documentMessage`), not the mimetype. Inherits `stream()` from the base class;
|
|
287
|
+
* `content()` drains the stream (cache → download).
|
|
288
|
+
*/
|
|
289
|
+
export declare class Document extends Message {
|
|
290
|
+
private get _doc_msg();
|
|
291
|
+
/** Nombre del archivo. / File name. */
|
|
292
|
+
get file_name(): string;
|
|
293
|
+
/** Tamaño en bytes (0 si se desconoce). / Size in bytes (0 if unknown). */
|
|
294
|
+
get size(): number;
|
|
295
|
+
/** Número de páginas (PDF); 0 si no aplica. / Page count (PDF); 0 when not applicable. */
|
|
296
|
+
get pages(): number;
|
|
297
|
+
/** Título del documento. / Document title. */
|
|
298
|
+
get title(): string;
|
|
299
|
+
content(): Promise<Buffer>;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Mensaje de tarjeta(s) de contacto (vCard). Unifica `contactMessage` (uno) y
|
|
303
|
+
* `contactsArrayMessage` (varios) bajo una sola lista `contacts`.
|
|
304
|
+
* Contact card message (vCard). Unifies `contactMessage` (single) and
|
|
305
|
+
* `contactsArrayMessage` (multiple) under a single `contacts` list.
|
|
306
|
+
*/
|
|
307
|
+
export declare class VCard extends Message {
|
|
308
|
+
/** Contactos de la tarjeta con nombre y teléfono. / Card contacts with name and phone. */
|
|
309
|
+
get contacts(): {
|
|
310
|
+
name: string;
|
|
311
|
+
phone: string;
|
|
312
|
+
}[];
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Mensaje de evento de calendario (`eventMessage`): nombre, descripción, rango de
|
|
316
|
+
* fechas, estado de cancelación, link de unión y ubicación.
|
|
317
|
+
* Calendar event message (`eventMessage`): name, description, date range,
|
|
318
|
+
* cancellation state, join link and location.
|
|
319
|
+
*/
|
|
320
|
+
export declare class Event extends Message {
|
|
321
|
+
private get _event();
|
|
322
|
+
/** Nombre del evento. / Event name. */
|
|
323
|
+
get name(): string;
|
|
324
|
+
/** Epoch ms de inicio. / Start epoch ms. */
|
|
325
|
+
get start(): number;
|
|
326
|
+
/** Epoch ms de fin, o null. / End epoch ms, or null. */
|
|
327
|
+
get end(): number | null;
|
|
328
|
+
/** true si el evento fue cancelado. / true if the event was canceled. */
|
|
329
|
+
get canceled(): boolean;
|
|
330
|
+
/** Link de unión (audio/video), si aplica. / Join link (audio/video), if any. */
|
|
331
|
+
get link(): string;
|
|
332
|
+
/** Ubicación del evento, o null. / Event location, or null. */
|
|
333
|
+
get place(): {
|
|
334
|
+
lat: number;
|
|
335
|
+
lng: number;
|
|
336
|
+
} | null;
|
|
337
|
+
}
|
|
244
338
|
/**
|
|
245
339
|
* Factoría que enlaza los statics a `wa` y expone las subclases.
|
|
246
340
|
* Factory binding statics to `wa` and exposing subclasses.
|
|
@@ -252,6 +346,9 @@ export declare function message(wa: WhatsApp): {
|
|
|
252
346
|
Audio: typeof Audio;
|
|
253
347
|
Gps: typeof Gps;
|
|
254
348
|
Poll: typeof Poll;
|
|
349
|
+
Document: typeof Document;
|
|
350
|
+
VCard: typeof VCard;
|
|
351
|
+
Event: typeof Event;
|
|
255
352
|
build_message_doc: typeof build_message_doc;
|
|
256
353
|
build_instance: (doc: IMessage) => Promise<Message>;
|
|
257
354
|
/** Obtiene un mensaje por CID/MID. */
|
|
@@ -266,6 +363,9 @@ export declare function message(wa: WhatsApp): {
|
|
|
266
363
|
audio(cid: string, buf: Buffer, opts?: SendAudioOptions): Promise<Message | null>;
|
|
267
364
|
location(cid: string, loc: LocationOptions, opts?: SendOptions): Promise<Message | null>;
|
|
268
365
|
poll(cid: string, p: PollOptions, opts?: SendPollOptions): Promise<Message | null>;
|
|
366
|
+
document(cid: string, buf: Buffer, opts: SendDocumentOptions): Promise<Message | null>;
|
|
367
|
+
vcard(cid: string, contacts: VCardInput[], opts?: SendOptions): Promise<Message | null>;
|
|
368
|
+
event(cid: string, data: EventInput, opts?: SendOptions): Promise<Message | null>;
|
|
269
369
|
edit(cid: string, mid: string, text: string): Promise<boolean>;
|
|
270
370
|
delete(cid: string, mid: string, all?: boolean): Promise<boolean>;
|
|
271
371
|
react(cid: string, mid: string, emoji: string): Promise<boolean>;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Subclases especializadas (Text, Image, Video, Audio, Gps, Poll) override `content()` según su tipo.
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.Poll = exports.Gps = exports.Audio = exports.Video = exports.Image = exports.Text = exports.Message = exports.MessageStatus = void 0;
|
|
8
|
+
exports.Event = exports.VCard = exports.Document = exports.Poll = exports.Gps = exports.Audio = exports.Video = exports.Image = exports.Text = exports.Message = exports.MessageStatus = void 0;
|
|
9
9
|
exports.build_message_doc = build_message_doc;
|
|
10
10
|
exports.message = message;
|
|
11
11
|
const baileys_1 = require("baileys");
|
|
@@ -33,6 +33,11 @@ const MESSAGE_TYPE_MAP = {
|
|
|
33
33
|
pollCreationMessage: 'poll',
|
|
34
34
|
pollCreationMessageV2: 'poll',
|
|
35
35
|
pollCreationMessageV3: 'poll',
|
|
36
|
+
documentMessage: 'document',
|
|
37
|
+
documentWithCaptionMessage: 'document',
|
|
38
|
+
contactMessage: 'vcard',
|
|
39
|
+
contactsArrayMessage: 'vcard',
|
|
40
|
+
eventMessage: 'event',
|
|
36
41
|
};
|
|
37
42
|
/**
|
|
38
43
|
* Construye el documento IMessage desde el raw de baileys.
|
|
@@ -43,6 +48,7 @@ function build_message_doc(raw, self_id, edited = false) {
|
|
|
43
48
|
const unwrapped = msg.viewOnceMessage?.message ??
|
|
44
49
|
msg.viewOnceMessageV2?.message ??
|
|
45
50
|
msg.viewOnceMessageV2Extension?.message ??
|
|
51
|
+
msg.documentWithCaptionMessage?.message ??
|
|
46
52
|
msg;
|
|
47
53
|
const content_type = (0, baileys_1.getContentType)(unwrapped);
|
|
48
54
|
const msg_type = MESSAGE_TYPE_MAP[content_type ?? ''] ?? 'text';
|
|
@@ -54,9 +60,12 @@ function build_message_doc(raw, self_id, edited = false) {
|
|
|
54
60
|
? (Number(raw.ephemeralStartTimestamp) + ephemeral_duration) * 1000
|
|
55
61
|
: null;
|
|
56
62
|
let mime = 'text/plain';
|
|
57
|
-
if (msg_type === 'location' || msg_type === 'poll') {
|
|
63
|
+
if (msg_type === 'location' || msg_type === 'poll' || msg_type === 'event') {
|
|
58
64
|
mime = 'application/json';
|
|
59
65
|
}
|
|
66
|
+
else if (msg_type === 'vcard') {
|
|
67
|
+
mime = 'text/vcard';
|
|
68
|
+
}
|
|
60
69
|
else if (msg_type !== 'text' && typeof msg_content === 'object') {
|
|
61
70
|
mime = msg_content?.mimetype ?? 'application/octet-stream';
|
|
62
71
|
}
|
|
@@ -64,11 +73,15 @@ function build_message_doc(raw, self_id, edited = false) {
|
|
|
64
73
|
if (typeof msg_content === 'string') {
|
|
65
74
|
caption = msg_content;
|
|
66
75
|
}
|
|
76
|
+
else if (msg_type === 'event') {
|
|
77
|
+
caption = msg_content?.description ?? '';
|
|
78
|
+
}
|
|
67
79
|
else if (msg_content) {
|
|
68
80
|
caption =
|
|
69
81
|
msg_content.caption ??
|
|
70
82
|
msg_content.text ??
|
|
71
83
|
msg_content.name ??
|
|
84
|
+
msg_content.displayName ??
|
|
72
85
|
'';
|
|
73
86
|
}
|
|
74
87
|
const author = key.fromMe && self_id
|
|
@@ -219,7 +232,11 @@ class Message {
|
|
|
219
232
|
/** Reenvía el mensaje a un destino (CID, Chat o Contact). */
|
|
220
233
|
async forward(target) {
|
|
221
234
|
const { _wa, _doc } = this;
|
|
222
|
-
const to_cid = typeof target === 'string'
|
|
235
|
+
const to_cid = typeof target === 'string'
|
|
236
|
+
? target
|
|
237
|
+
: target instanceof chat_1.Chat
|
|
238
|
+
? target.id
|
|
239
|
+
: (await target.chat()).id;
|
|
223
240
|
let ok = false;
|
|
224
241
|
if (_wa._socket) {
|
|
225
242
|
const jid = await _wa._resolve_jid(to_cid);
|
|
@@ -383,6 +400,18 @@ class Message {
|
|
|
383
400
|
async poll(poll, opts = {}) {
|
|
384
401
|
return this._wa.Message.poll(this.cid, poll, { ...opts, mid: this.id });
|
|
385
402
|
}
|
|
403
|
+
/** Responde con documento. */
|
|
404
|
+
async document(buf, opts) {
|
|
405
|
+
return this._wa.Message.document(this.cid, buf, { ...opts, mid: this.id });
|
|
406
|
+
}
|
|
407
|
+
/** Responde con tarjeta(s) de contacto. */
|
|
408
|
+
async vcard(contacts, opts = {}) {
|
|
409
|
+
return this._wa.Message.vcard(this.cid, contacts, { ...opts, mid: this.id });
|
|
410
|
+
}
|
|
411
|
+
/** Responde con evento. */
|
|
412
|
+
async event(data, opts = {}) {
|
|
413
|
+
return this._wa.Message.event(this.cid, data, { ...opts, mid: this.id });
|
|
414
|
+
}
|
|
386
415
|
}
|
|
387
416
|
exports.Message = Message;
|
|
388
417
|
/**
|
|
@@ -615,6 +644,116 @@ class Poll extends Message {
|
|
|
615
644
|
}
|
|
616
645
|
}
|
|
617
646
|
exports.Poll = Poll;
|
|
647
|
+
/**
|
|
648
|
+
* Mensaje de documento. WhatsApp permite enviar cualquier archivo (PDF, imagen,
|
|
649
|
+
* audio, video, etc.) como documento; lo que lo distingue de image/video/audio es
|
|
650
|
+
* el tipo de mensaje (`documentMessage`), no el mimetype. Hereda `stream()` de la
|
|
651
|
+
* clase base; `content()` drena el stream (cache → download).
|
|
652
|
+
* Document message. WhatsApp lets you send any file (PDF, image, audio, video…)
|
|
653
|
+
* as a document; what sets it apart from image/video/audio is the message type
|
|
654
|
+
* (`documentMessage`), not the mimetype. Inherits `stream()` from the base class;
|
|
655
|
+
* `content()` drains the stream (cache → download).
|
|
656
|
+
*/
|
|
657
|
+
class Document extends Message {
|
|
658
|
+
get _doc_msg() {
|
|
659
|
+
const m = this._doc.raw.message;
|
|
660
|
+
return m?.documentMessage ?? m?.documentWithCaptionMessage?.message?.documentMessage;
|
|
661
|
+
}
|
|
662
|
+
/** Nombre del archivo. / File name. */
|
|
663
|
+
get file_name() {
|
|
664
|
+
return this._doc_msg?.fileName ?? '';
|
|
665
|
+
}
|
|
666
|
+
/** Tamaño en bytes (0 si se desconoce). / Size in bytes (0 if unknown). */
|
|
667
|
+
get size() {
|
|
668
|
+
return Number(this._doc_msg?.fileLength?.toString() ?? '0');
|
|
669
|
+
}
|
|
670
|
+
/** Número de páginas (PDF); 0 si no aplica. / Page count (PDF); 0 when not applicable. */
|
|
671
|
+
get pages() {
|
|
672
|
+
return this._doc_msg?.pageCount ?? 0;
|
|
673
|
+
}
|
|
674
|
+
/** Título del documento. / Document title. */
|
|
675
|
+
get title() {
|
|
676
|
+
return this._doc_msg?.title ?? '';
|
|
677
|
+
}
|
|
678
|
+
async content() {
|
|
679
|
+
return _drain(await this.stream());
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
exports.Document = Document;
|
|
683
|
+
/**
|
|
684
|
+
* Construye un vCard 3.0 mínimo con el teléfono enlazado como contacto de WhatsApp.
|
|
685
|
+
* Builds a minimal vCard 3.0 with the phone linked as a WhatsApp contact.
|
|
686
|
+
*
|
|
687
|
+
* @param name - Nombre mostrado / Display name
|
|
688
|
+
* @param phone - Teléfono en formato internacional / Phone in international format
|
|
689
|
+
* @returns String vCard (VCF) / vCard (VCF) string
|
|
690
|
+
*/
|
|
691
|
+
function build_vcard(name, phone) {
|
|
692
|
+
const waid = phone.replace(/\D+/g, '');
|
|
693
|
+
return [
|
|
694
|
+
'BEGIN:VCARD',
|
|
695
|
+
'VERSION:3.0',
|
|
696
|
+
`FN:${name}`,
|
|
697
|
+
`TEL;type=CELL;waid=${waid}:${phone}`,
|
|
698
|
+
'END:VCARD',
|
|
699
|
+
].join('\n');
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Mensaje de tarjeta(s) de contacto (vCard). Unifica `contactMessage` (uno) y
|
|
703
|
+
* `contactsArrayMessage` (varios) bajo una sola lista `contacts`.
|
|
704
|
+
* Contact card message (vCard). Unifies `contactMessage` (single) and
|
|
705
|
+
* `contactsArrayMessage` (multiple) under a single `contacts` list.
|
|
706
|
+
*/
|
|
707
|
+
class VCard extends Message {
|
|
708
|
+
/** Contactos de la tarjeta con nombre y teléfono. / Card contacts with name and phone. */
|
|
709
|
+
get contacts() {
|
|
710
|
+
const m = this._doc.raw.message;
|
|
711
|
+
const raw = m?.contactsArrayMessage?.contacts ?? (m?.contactMessage ? [m.contactMessage] : []);
|
|
712
|
+
return raw.map((c) => {
|
|
713
|
+
const tel = (c.vcard ?? '').match(/TEL[^:]*:(.+)/);
|
|
714
|
+
return { name: c.displayName ?? '', phone: tel ? tel[1].trim() : '' };
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
exports.VCard = VCard;
|
|
719
|
+
/**
|
|
720
|
+
* Mensaje de evento de calendario (`eventMessage`): nombre, descripción, rango de
|
|
721
|
+
* fechas, estado de cancelación, link de unión y ubicación.
|
|
722
|
+
* Calendar event message (`eventMessage`): name, description, date range,
|
|
723
|
+
* cancellation state, join link and location.
|
|
724
|
+
*/
|
|
725
|
+
class Event extends Message {
|
|
726
|
+
get _event() {
|
|
727
|
+
return this._doc.raw.message?.eventMessage;
|
|
728
|
+
}
|
|
729
|
+
/** Nombre del evento. / Event name. */
|
|
730
|
+
get name() {
|
|
731
|
+
return this._event?.name ?? '';
|
|
732
|
+
}
|
|
733
|
+
/** Epoch ms de inicio. / Start epoch ms. */
|
|
734
|
+
get start() {
|
|
735
|
+
return Number(this._event?.startTime?.toString() ?? '0') * 1000;
|
|
736
|
+
}
|
|
737
|
+
/** Epoch ms de fin, o null. / End epoch ms, or null. */
|
|
738
|
+
get end() {
|
|
739
|
+
const end = this._event?.endTime;
|
|
740
|
+
return end == null ? null : Number(end.toString()) * 1000;
|
|
741
|
+
}
|
|
742
|
+
/** true si el evento fue cancelado. / true if the event was canceled. */
|
|
743
|
+
get canceled() {
|
|
744
|
+
return this._event?.isCanceled ?? false;
|
|
745
|
+
}
|
|
746
|
+
/** Link de unión (audio/video), si aplica. / Join link (audio/video), if any. */
|
|
747
|
+
get link() {
|
|
748
|
+
return this._event?.joinLink ?? '';
|
|
749
|
+
}
|
|
750
|
+
/** Ubicación del evento, o null. / Event location, or null. */
|
|
751
|
+
get place() {
|
|
752
|
+
const loc = this._event?.location;
|
|
753
|
+
return loc ? { lat: loc.degreesLatitude ?? 0, lng: loc.degreesLongitude ?? 0 } : null;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
exports.Event = Event;
|
|
618
757
|
/**
|
|
619
758
|
* Factoría que enlaza los statics a `wa` y expone las subclases.
|
|
620
759
|
* Factory binding statics to `wa` and exposing subclasses.
|
|
@@ -640,6 +779,15 @@ function message(wa) {
|
|
|
640
779
|
if (doc.type === 'poll') {
|
|
641
780
|
return new Poll(opts);
|
|
642
781
|
}
|
|
782
|
+
if (doc.type === 'document') {
|
|
783
|
+
return new Document(opts);
|
|
784
|
+
}
|
|
785
|
+
if (doc.type === 'vcard') {
|
|
786
|
+
return new VCard(opts);
|
|
787
|
+
}
|
|
788
|
+
if (doc.type === 'event') {
|
|
789
|
+
return new Event(opts);
|
|
790
|
+
}
|
|
643
791
|
return new Message(opts);
|
|
644
792
|
}
|
|
645
793
|
async function send(cid, content, binary, reply_to, doc_overrides) {
|
|
@@ -680,6 +828,9 @@ function message(wa) {
|
|
|
680
828
|
Audio,
|
|
681
829
|
Gps,
|
|
682
830
|
Poll,
|
|
831
|
+
Document,
|
|
832
|
+
VCard,
|
|
833
|
+
Event,
|
|
683
834
|
// Helpers internos (usados por orquestador WhatsApp)
|
|
684
835
|
build_message_doc,
|
|
685
836
|
build_instance,
|
|
@@ -736,6 +887,41 @@ function message(wa) {
|
|
|
736
887
|
},
|
|
737
888
|
}, undefined, opts.mid, { multiple });
|
|
738
889
|
},
|
|
890
|
+
async document(cid, buf, opts) {
|
|
891
|
+
return send(cid, {
|
|
892
|
+
document: buf,
|
|
893
|
+
fileName: opts.file_name,
|
|
894
|
+
mimetype: opts.mimetype ?? 'application/octet-stream',
|
|
895
|
+
caption: opts.caption,
|
|
896
|
+
}, buf, opts.mid);
|
|
897
|
+
},
|
|
898
|
+
async vcard(cid, contacts, opts = {}) {
|
|
899
|
+
const built = contacts.map((c) => ({
|
|
900
|
+
displayName: c.name,
|
|
901
|
+
vcard: build_vcard(c.name, c.phone),
|
|
902
|
+
}));
|
|
903
|
+
const binary = Buffer.from(built.map((c) => c.vcard).join('\n'), 'utf-8');
|
|
904
|
+
return send(cid, { contacts: { contacts: built } }, binary, opts.mid);
|
|
905
|
+
},
|
|
906
|
+
async event(cid, data, opts = {}) {
|
|
907
|
+
const binary = Buffer.from(JSON.stringify({
|
|
908
|
+
name: data.name,
|
|
909
|
+
caption: data.caption,
|
|
910
|
+
start: data.start.getTime(),
|
|
911
|
+
end: data.end?.getTime() ?? null,
|
|
912
|
+
}), 'utf-8');
|
|
913
|
+
return send(cid, {
|
|
914
|
+
event: {
|
|
915
|
+
name: data.name,
|
|
916
|
+
description: data.caption,
|
|
917
|
+
startDate: data.start,
|
|
918
|
+
endDate: data.end,
|
|
919
|
+
location: data.place
|
|
920
|
+
? { degreesLatitude: data.place.lat, degreesLongitude: data.place.lng }
|
|
921
|
+
: undefined,
|
|
922
|
+
},
|
|
923
|
+
}, binary, opts.mid);
|
|
924
|
+
},
|
|
739
925
|
async edit(cid, mid, text) {
|
|
740
926
|
const m = await api.get(cid, mid);
|
|
741
927
|
return m ? m.edit(text) : false;
|