@arcaelas/whatsapp 4.4.0 → 5.1.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/index.d.ts +6 -4
- package/build/cjs/index.js +22 -2
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/lib/bot/decorator.d.ts +2 -0
- package/build/cjs/lib/bot/decorator.js +6 -0
- package/build/cjs/lib/bot/decorator.js.map +1 -1
- package/build/cjs/lib/chat/index.d.ts +340 -204
- package/build/cjs/lib/chat/index.js +225 -213
- package/build/cjs/lib/chat/index.js.map +1 -1
- package/build/cjs/lib/contact/index.d.ts +162 -179
- package/build/cjs/lib/contact/index.js +96 -190
- package/build/cjs/lib/contact/index.js.map +1 -1
- package/build/cjs/lib/internal.d.ts +40 -0
- package/build/cjs/lib/internal.js +39 -0
- package/build/cjs/lib/internal.js.map +1 -0
- package/build/cjs/lib/message/index.d.ts +463 -278
- package/build/cjs/lib/message/index.js +830 -710
- package/build/cjs/lib/message/index.js.map +1 -1
- package/build/cjs/lib/status/index.d.ts +60 -70
- package/build/cjs/lib/status/index.js +106 -111
- package/build/cjs/lib/status/index.js.map +1 -1
- package/build/cjs/lib/store/engine/index.d.ts +21 -7
- package/build/cjs/lib/store/engine/index.js +6 -3
- package/build/cjs/lib/store/engine/index.js.map +1 -1
- package/build/cjs/lib/store/engine/lib/file_system/index.d.ts +38 -8
- package/build/cjs/lib/store/engine/lib/file_system/index.js +92 -67
- package/build/cjs/lib/store/engine/lib/file_system/index.js.map +1 -1
- package/build/cjs/lib/store/engine/lib/index.d.ts +112 -0
- package/build/cjs/lib/store/engine/lib/index.js +213 -0
- package/build/cjs/lib/store/engine/lib/index.js.map +1 -0
- package/build/cjs/lib/store/engine/lib/redis/index.d.ts +28 -13
- package/build/cjs/lib/store/engine/lib/redis/index.js +56 -42
- package/build/cjs/lib/store/engine/lib/redis/index.js.map +1 -1
- package/build/cjs/lib/store/engine/lib/s3/index.d.ts +44 -1
- package/build/cjs/lib/store/engine/lib/s3/index.js +112 -64
- package/build/cjs/lib/store/engine/lib/s3/index.js.map +1 -1
- package/build/cjs/lib/store/engine/lib/sqlite/index.d.ts +98 -0
- package/build/cjs/lib/store/engine/lib/sqlite/index.js +114 -0
- package/build/cjs/lib/store/engine/lib/sqlite/index.js.map +1 -0
- package/build/cjs/lib/store/index.d.ts +7 -3
- package/build/cjs/lib/store/index.js +14 -4
- package/build/cjs/lib/store/index.js.map +1 -1
- package/build/cjs/lib/whatsapp/index.d.ts +117 -63
- package/build/cjs/lib/whatsapp/index.js +404 -184
- package/build/cjs/lib/whatsapp/index.js.map +1 -1
- package/build/cjs/test.d.ts +1 -0
- package/build/cjs/test.js +72 -0
- package/build/cjs/test.js.map +1 -0
- package/build/esm/index.d.ts +6 -4
- package/build/esm/index.js +5 -2
- package/build/esm/index.js.map +1 -1
- package/build/esm/lib/bot/decorator.d.ts +2 -0
- package/build/esm/lib/bot/decorator.js +6 -0
- package/build/esm/lib/bot/decorator.js.map +1 -1
- package/build/esm/lib/chat/index.d.ts +340 -204
- package/build/esm/lib/chat/index.js +225 -213
- package/build/esm/lib/chat/index.js.map +1 -1
- package/build/esm/lib/contact/index.d.ts +162 -179
- package/build/esm/lib/contact/index.js +96 -189
- package/build/esm/lib/contact/index.js.map +1 -1
- package/build/esm/lib/internal.d.ts +40 -0
- package/build/esm/lib/internal.js +35 -0
- package/build/esm/lib/internal.js.map +1 -0
- package/build/esm/lib/message/index.d.ts +463 -278
- package/build/esm/lib/message/index.js +825 -705
- package/build/esm/lib/message/index.js.map +1 -1
- package/build/esm/lib/status/index.d.ts +60 -70
- package/build/esm/lib/status/index.js +105 -110
- package/build/esm/lib/status/index.js.map +1 -1
- package/build/esm/lib/store/engine/index.d.ts +21 -7
- package/build/esm/lib/store/engine/index.js +4 -2
- package/build/esm/lib/store/engine/index.js.map +1 -1
- package/build/esm/lib/store/engine/lib/file_system/index.d.ts +38 -8
- package/build/esm/lib/store/engine/lib/file_system/index.js +92 -67
- package/build/esm/lib/store/engine/lib/file_system/index.js.map +1 -1
- package/build/esm/lib/store/engine/lib/index.d.ts +112 -0
- package/build/esm/lib/store/engine/lib/index.js +206 -0
- package/build/esm/lib/store/engine/lib/index.js.map +1 -0
- package/build/esm/lib/store/engine/lib/redis/index.d.ts +28 -13
- package/build/esm/lib/store/engine/lib/redis/index.js +54 -40
- package/build/esm/lib/store/engine/lib/redis/index.js.map +1 -1
- package/build/esm/lib/store/engine/lib/s3/index.d.ts +44 -1
- package/build/esm/lib/store/engine/lib/s3/index.js +111 -63
- package/build/esm/lib/store/engine/lib/s3/index.js.map +1 -1
- package/build/esm/lib/store/engine/lib/sqlite/index.d.ts +98 -0
- package/build/esm/lib/store/engine/lib/sqlite/index.js +110 -0
- package/build/esm/lib/store/engine/lib/sqlite/index.js.map +1 -0
- package/build/esm/lib/store/index.d.ts +7 -3
- package/build/esm/lib/store/index.js +13 -4
- package/build/esm/lib/store/index.js.map +1 -1
- package/build/esm/lib/whatsapp/index.d.ts +117 -63
- package/build/esm/lib/whatsapp/index.js +406 -186
- package/build/esm/lib/whatsapp/index.js.map +1 -1
- package/build/esm/test.d.ts +1 -0
- package/build/esm/test.js +67 -0
- package/build/esm/test.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,333 +1,544 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file message/index.ts
|
|
3
|
-
* @description Entidad Message —
|
|
4
|
-
*
|
|
3
|
+
* @description Entidad Message — clase base con getters puros y subclases por tipo
|
|
4
|
+
* (Text, Image, Video, Audio, Sticker, Document, Location, Poll, VCard, Event);
|
|
5
|
+
* `message(wa, raw)` evalúa el tipo y retorna la instancia correcta.
|
|
6
|
+
* Message entity — pure-getter base class with per-type subclasses;
|
|
7
|
+
* `message(wa, raw)` evaluates the type and returns the right instance.
|
|
5
8
|
*/
|
|
6
9
|
import { type WAMessage } from 'baileys';
|
|
7
10
|
import { Readable } from 'node:stream';
|
|
8
|
-
import { Chat
|
|
9
|
-
import { Contact
|
|
11
|
+
import { Chat } from '../../lib/chat';
|
|
12
|
+
import { Contact } from '../../lib/contact';
|
|
10
13
|
import type { WhatsApp } from '../../lib/whatsapp';
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
type
|
|
14
|
-
type ContactInstance = InstanceType<ReturnType<typeof contact>>;
|
|
15
|
-
/** Tipos de mensaje internos (no expuestos como getter público). */
|
|
16
|
-
export type MessageType = 'text' | 'image' | 'video' | 'audio' | 'location' | 'poll' | 'document' | 'vcard' | 'event';
|
|
17
|
-
export declare enum MessageStatus {
|
|
18
|
-
ERROR = 0,
|
|
19
|
-
PENDING = 1,
|
|
20
|
-
SERVER_ACK = 2,
|
|
21
|
-
DELIVERED = 3,
|
|
22
|
-
READ = 4,
|
|
23
|
-
PLAYED = 5
|
|
24
|
-
}
|
|
25
|
-
export interface SendOptions {
|
|
14
|
+
/** Estados legibles indexados por el status numérico de baileys. / Readable states indexed by the baileys numeric status. */
|
|
15
|
+
declare const STATUS: readonly ["error", "pending", "sent", "delivered", "read", "played"];
|
|
16
|
+
type SendExtra = {
|
|
26
17
|
mid?: string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
caption?: string;
|
|
30
|
-
}
|
|
31
|
-
export interface SendAudioOptions extends SendOptions {
|
|
32
|
-
ptt?: boolean;
|
|
33
|
-
}
|
|
34
|
-
export interface SendPollOptions extends SendOptions {
|
|
35
|
-
/** true para selección múltiple; default false (single). / true for multi-select; default false (single). */
|
|
36
|
-
multiple?: boolean;
|
|
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
|
-
}
|
|
67
|
-
export interface LocationOptions {
|
|
68
|
-
lat: number;
|
|
69
|
-
lng: number;
|
|
70
|
-
live?: boolean;
|
|
71
|
-
}
|
|
72
|
-
export interface PollOptions {
|
|
73
|
-
content: string;
|
|
74
|
-
options: Array<{
|
|
75
|
-
content: string;
|
|
76
|
-
}>;
|
|
77
|
-
}
|
|
18
|
+
once?: boolean;
|
|
19
|
+
};
|
|
78
20
|
/**
|
|
79
|
-
*
|
|
21
|
+
* Clase base del mensaje: recibe el cliente y el raw, deriva el estado con getters y
|
|
22
|
+
* opera contra WhatsApp con sus métodos. Los estáticos reciben el cliente como primer
|
|
23
|
+
* argumento (`Message.text(wa, cid, …)`).
|
|
24
|
+
* Base message class: receives the client and the raw, derives state via getters and
|
|
25
|
+
* operates against WhatsApp with its methods. Statics take the client as their first
|
|
26
|
+
* argument (`Message.text(wa, cid, …)`).
|
|
80
27
|
*/
|
|
81
|
-
export
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
28
|
+
export declare class Message {
|
|
29
|
+
readonly _wa: WhatsApp;
|
|
30
|
+
readonly _raw: {
|
|
31
|
+
id: string;
|
|
32
|
+
cid: string;
|
|
33
|
+
mid: string | null;
|
|
34
|
+
me: boolean;
|
|
35
|
+
type: 'text' | 'image' | 'video' | 'audio' | 'sticker' | 'document' | 'location' | 'poll' | 'vcard' | 'event';
|
|
36
|
+
author: string;
|
|
37
|
+
status: number;
|
|
38
|
+
starred: boolean;
|
|
39
|
+
forwarded: boolean;
|
|
40
|
+
created_at: number;
|
|
41
|
+
deleted_at: number | null;
|
|
42
|
+
mime: string;
|
|
43
|
+
caption: string;
|
|
44
|
+
edited: boolean;
|
|
45
|
+
multiple?: boolean;
|
|
46
|
+
reactions?: {
|
|
47
|
+
author: string;
|
|
48
|
+
emoji: string;
|
|
49
|
+
at: number;
|
|
50
|
+
}[];
|
|
51
|
+
viewed?: boolean | null;
|
|
52
|
+
raw: WAMessage;
|
|
53
|
+
};
|
|
96
54
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* own-poll echo, losing the discriminator).
|
|
55
|
+
* @internal Cliente dueño y documento persistido. `status`, `created_at` y
|
|
56
|
+
* `deleted_at` guardan los valores numéricos del protocolo; los getters los
|
|
57
|
+
* presentan legibles. `viewed` existe únicamente en los status broadcast (Feed).
|
|
58
|
+
* Owner client and persisted document. `status`, `created_at` and `deleted_at`
|
|
59
|
+
* keep the protocol numeric values; getters expose them readable. `viewed` only
|
|
60
|
+
* exists on status broadcasts (Feed).
|
|
104
61
|
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
62
|
+
constructor(_wa: WhatsApp, _raw: {
|
|
63
|
+
id: string;
|
|
64
|
+
cid: string;
|
|
65
|
+
mid: string | null;
|
|
66
|
+
me: boolean;
|
|
67
|
+
type: 'text' | 'image' | 'video' | 'audio' | 'sticker' | 'document' | 'location' | 'poll' | 'vcard' | 'event';
|
|
68
|
+
author: string;
|
|
69
|
+
status: number;
|
|
70
|
+
starred: boolean;
|
|
71
|
+
forwarded: boolean;
|
|
72
|
+
created_at: number;
|
|
73
|
+
deleted_at: number | null;
|
|
74
|
+
mime: string;
|
|
75
|
+
caption: string;
|
|
76
|
+
edited: boolean;
|
|
77
|
+
multiple?: boolean;
|
|
78
|
+
reactions?: {
|
|
79
|
+
author: string;
|
|
80
|
+
emoji: string;
|
|
81
|
+
at: number;
|
|
82
|
+
}[];
|
|
83
|
+
viewed?: boolean | null;
|
|
84
|
+
raw: WAMessage;
|
|
128
85
|
});
|
|
86
|
+
/** Identificador del mensaje. / Message identifier. */
|
|
129
87
|
get id(): string;
|
|
88
|
+
/** Identificador del chat del mensaje. / Message chat identifier. */
|
|
130
89
|
get cid(): string;
|
|
131
|
-
|
|
132
|
-
/** JID del autor del mensaje. Para acceso síncrono sin hidratar el Contact. */
|
|
133
|
-
get from(): string;
|
|
134
|
-
/** MIME type del contenido. `text/plain` para texto, `application/json` para location/poll, mimetype real para media. */
|
|
135
|
-
get mime(): string;
|
|
90
|
+
/** Identificador del mensaje citado, o null. / Quoted message identifier, or null. */
|
|
136
91
|
get mid(): string | null;
|
|
92
|
+
/** JID del autor, para acceso síncrono. / Author JID, for sync access. */
|
|
93
|
+
get from(): string;
|
|
94
|
+
/** true si soy el autor. / true when I am the author. */
|
|
137
95
|
get me(): boolean;
|
|
96
|
+
/** Tipo del mensaje. / Message type. */
|
|
97
|
+
get type(): Message['_raw']['type'];
|
|
98
|
+
/** MIME: text/plain en texto, text/json en poll/location/vcard/event, real en media. / MIME: text/plain for text, text/json for poll/location/vcard/event, actual for media. */
|
|
99
|
+
get mime(): string;
|
|
100
|
+
/** Texto del mensaje o caption del media. / Message text or media caption. */
|
|
138
101
|
get caption(): string;
|
|
102
|
+
/** Estado legible del mensaje. / Readable message state. */
|
|
103
|
+
get status(): (typeof STATUS)[number];
|
|
104
|
+
/** true si el mensaje fue visto. / true when the message was seen. */
|
|
105
|
+
get read(): boolean;
|
|
106
|
+
/** true si está destacado. / true when starred. */
|
|
139
107
|
get starred(): boolean;
|
|
108
|
+
/** true si fue reenviado. / true when forwarded. */
|
|
140
109
|
get forwarded(): boolean;
|
|
141
|
-
|
|
142
|
-
get created_at(): number;
|
|
143
|
-
get deleted_at(): number | null;
|
|
144
|
-
get status(): MessageStatus;
|
|
110
|
+
/** true si fue editado. / true when edited. */
|
|
145
111
|
get edited(): boolean;
|
|
112
|
+
/** true si es de una sola lectura (view-once). / true when view-once. */
|
|
113
|
+
get once(): boolean;
|
|
114
|
+
/** Fecha de creación en ISO UTC. / Creation date as ISO UTC. */
|
|
115
|
+
get created_at(): string;
|
|
116
|
+
/** Vencimiento del mensaje temporal en ISO UTC, o null. / Ephemeral expiration as ISO UTC, or null. */
|
|
117
|
+
get expires_at(): string | null;
|
|
118
|
+
/**
|
|
119
|
+
* Contacto autor del mensaje, desde el engine (ficha mínima si no está persistido).
|
|
120
|
+
* Message author contact, from the engine (minimal card when not persisted).
|
|
121
|
+
*
|
|
122
|
+
* @returns Contacto / Contact
|
|
123
|
+
*/
|
|
124
|
+
author(): Promise<InstanceType<WhatsApp['Contact']>>;
|
|
125
|
+
/**
|
|
126
|
+
* Chat al que pertenece el mensaje.
|
|
127
|
+
* Chat the message belongs to.
|
|
128
|
+
*
|
|
129
|
+
* @returns Chat / Chat
|
|
130
|
+
*/
|
|
131
|
+
chat(): Promise<InstanceType<WhatsApp['Chat']>>;
|
|
146
132
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* Instance-memoized: first call hits the engine; subsequent calls reuse the
|
|
152
|
-
* same promise without further round-trips.
|
|
133
|
+
* Mensaje citado cuando hay `mid`, o null.
|
|
134
|
+
* Quoted message when `mid` exists, or null.
|
|
135
|
+
*
|
|
136
|
+
* @returns Mensaje citado o null / Quoted message or null
|
|
153
137
|
*/
|
|
154
|
-
|
|
138
|
+
message(): Promise<Message | null>;
|
|
155
139
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
140
|
+
* Contenido del mensaje: texto como su caption, media como binario, y
|
|
141
|
+
* poll/location/vcard/event como JSON.
|
|
142
|
+
* Message content: text as its caption, media as binary, and
|
|
143
|
+
* poll/location/vcard/event as JSON.
|
|
144
|
+
*
|
|
145
|
+
* @returns Buffer del contenido / Content buffer
|
|
160
146
|
*/
|
|
161
|
-
chat(): Promise<ChatInstance>;
|
|
162
|
-
/** Contenido sin parsear, directo del engine. Las subclases override según su tipo. */
|
|
163
147
|
content(): Promise<Buffer>;
|
|
164
148
|
/**
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* from the engine cache or, if missing, downloads from baileys. For text/location/poll
|
|
170
|
-
* it wraps the `content()` buffer in a Readable.
|
|
149
|
+
* Stream del contenido; para media descarga de baileys si el cache falta.
|
|
150
|
+
* Content stream; media falls back to a baileys download when the cache is missing.
|
|
151
|
+
*
|
|
152
|
+
* @returns Readable del contenido / Content readable
|
|
171
153
|
*/
|
|
172
154
|
stream(): Promise<Readable>;
|
|
173
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* Reacciones del mensaje agrupadas por emoji con su conteo.
|
|
157
|
+
* Message reactions grouped by emoji with their count.
|
|
158
|
+
*
|
|
159
|
+
* @returns Conteo por emoji / Per-emoji count
|
|
160
|
+
*/
|
|
161
|
+
reactions(): Promise<{
|
|
162
|
+
emoji: string;
|
|
163
|
+
count: number;
|
|
164
|
+
}[]>;
|
|
165
|
+
/**
|
|
166
|
+
* Reacciona al mensaje; el emoji vacío retira la reacción.
|
|
167
|
+
* Reacts to the message; an empty emoji removes the reaction.
|
|
168
|
+
*
|
|
169
|
+
* @param emoji - Emoji o '' / Emoji or ''
|
|
170
|
+
* @returns true si se envió / true when sent
|
|
171
|
+
*/
|
|
174
172
|
react(emoji: string): Promise<boolean>;
|
|
175
|
-
/**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Destaca o quita el destacado del mensaje.
|
|
175
|
+
* Stars or unstars the message.
|
|
176
|
+
*
|
|
177
|
+
* @param value - true destaca / true stars
|
|
178
|
+
* @returns true si se envió / true when sent
|
|
179
|
+
*/
|
|
180
180
|
star(value: boolean): Promise<boolean>;
|
|
181
|
-
/**
|
|
181
|
+
/**
|
|
182
|
+
* Marca el mensaje como leído.
|
|
183
|
+
* Marks the message as read.
|
|
184
|
+
*
|
|
185
|
+
* @returns true si se envió / true when sent
|
|
186
|
+
*/
|
|
187
|
+
seen(): Promise<boolean>;
|
|
188
|
+
/**
|
|
189
|
+
* Edita el caption del mensaje propio (texto, imagen o video).
|
|
190
|
+
* Edits the own message caption (text, image or video).
|
|
191
|
+
*
|
|
192
|
+
* @param caption - Texto nuevo / New text
|
|
193
|
+
* @returns true si se editó / true when edited
|
|
194
|
+
*/
|
|
195
|
+
edit(caption: string): Promise<boolean>;
|
|
196
|
+
/**
|
|
197
|
+
* Reenvía el mensaje a otro chat.
|
|
198
|
+
* Forwards the message to another chat.
|
|
199
|
+
*
|
|
200
|
+
* @param target - CID, Chat o Contact destino / Target CID, Chat or Contact
|
|
201
|
+
* @returns true si se reenvió / true when forwarded
|
|
202
|
+
*/
|
|
203
|
+
forward(target: string | Chat | Contact): Promise<boolean>;
|
|
204
|
+
/**
|
|
205
|
+
* Elimina el mensaje: solo en mi dispositivo por defecto, para todos con `true`.
|
|
206
|
+
* Deletes the message: this device only by default, for everyone with `true`.
|
|
207
|
+
*
|
|
208
|
+
* @param all - true elimina para todos / true deletes for everyone
|
|
209
|
+
* @returns true si se eliminó / true when deleted
|
|
210
|
+
*/
|
|
182
211
|
delete(all?: boolean): Promise<boolean>;
|
|
183
|
-
/**
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
/** Responde con
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
/** Responde con audio. */
|
|
194
|
-
audio(buf: Buffer,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
/** Responde con
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
212
|
+
/** Responde con texto. / Replies with text. */
|
|
213
|
+
text(caption: string, extra?: Omit<SendExtra, 'mid'>): Promise<Message | null>;
|
|
214
|
+
/** Responde con imagen. / Replies with an image. */
|
|
215
|
+
image(buf: Buffer, extra?: Omit<SendExtra, 'mid'> & {
|
|
216
|
+
caption?: string;
|
|
217
|
+
}): Promise<Message | null>;
|
|
218
|
+
/** Responde con video. / Replies with a video. */
|
|
219
|
+
video(buf: Buffer, extra?: Omit<SendExtra, 'mid'> & {
|
|
220
|
+
caption?: string;
|
|
221
|
+
}): Promise<Message | null>;
|
|
222
|
+
/** Responde con audio. / Replies with audio. */
|
|
223
|
+
audio(buf: Buffer, extra?: Omit<SendExtra, 'mid'> & {
|
|
224
|
+
ptt?: boolean;
|
|
225
|
+
}): Promise<Message | null>;
|
|
226
|
+
/** Responde con ubicación. / Replies with a location. */
|
|
227
|
+
location(loc: {
|
|
228
|
+
lat: number;
|
|
229
|
+
lng: number;
|
|
230
|
+
}, extra?: Omit<SendExtra, 'mid'>): Promise<Message | null>;
|
|
231
|
+
/** Responde con encuesta. / Replies with a poll. */
|
|
232
|
+
poll(input: {
|
|
233
|
+
content: string;
|
|
234
|
+
options: {
|
|
235
|
+
content: string;
|
|
236
|
+
}[];
|
|
237
|
+
}, extra?: Omit<SendExtra, 'mid'> & {
|
|
238
|
+
multiple?: boolean;
|
|
239
|
+
}): Promise<Message | null>;
|
|
240
|
+
/** Responde con documento. / Replies with a document. */
|
|
241
|
+
document(buf: Buffer, extra: Omit<SendExtra, 'mid'> & {
|
|
242
|
+
file_name: string;
|
|
243
|
+
mimetype?: string;
|
|
244
|
+
caption?: string;
|
|
245
|
+
}): Promise<Message | null>;
|
|
246
|
+
/** Responde con tarjeta(s) de contacto. / Replies with contact card(s). */
|
|
247
|
+
vcard(contacts: {
|
|
248
|
+
name: string;
|
|
249
|
+
phone: string;
|
|
250
|
+
}[], extra?: Omit<SendExtra, 'mid'>): Promise<Message | null>;
|
|
251
|
+
/** Responde con evento. / Replies with an event. */
|
|
252
|
+
event(data: {
|
|
253
|
+
name: string;
|
|
254
|
+
caption?: string;
|
|
255
|
+
start: Date;
|
|
256
|
+
end?: Date;
|
|
257
|
+
place?: {
|
|
258
|
+
lat: number;
|
|
259
|
+
lng: number;
|
|
260
|
+
};
|
|
261
|
+
}, extra?: Omit<SendExtra, 'mid'>): Promise<Message | null>;
|
|
262
|
+
/**
|
|
263
|
+
* Obtiene un mensaje por chat y id.
|
|
264
|
+
* Retrieves a message by chat and id.
|
|
265
|
+
*
|
|
266
|
+
* @param wa - Cliente dueño / Owner client
|
|
267
|
+
* @param cid - Identificador del chat / Chat identifier
|
|
268
|
+
* @param mid - Identificador del mensaje / Message identifier
|
|
269
|
+
* @returns Mensaje o null / Message or null
|
|
270
|
+
*/
|
|
271
|
+
static get(wa: WhatsApp, cid: string, mid: string): Promise<Message | null>;
|
|
272
|
+
/**
|
|
273
|
+
* Pagina los mensajes de un chat desde el más reciente.
|
|
274
|
+
* Paginates chat messages from the most recent one.
|
|
275
|
+
*
|
|
276
|
+
* @param wa - Cliente dueño / Owner client
|
|
277
|
+
* @param cid - Identificador del chat / Chat identifier
|
|
278
|
+
* @param offset - Desplazamiento / Offset
|
|
279
|
+
* @param limit - Tamaño de página / Page size
|
|
280
|
+
* @returns Página de mensajes / Message page
|
|
281
|
+
*/
|
|
282
|
+
static list(wa: WhatsApp, cid: string, offset?: number, limit?: number): Promise<Message[]>;
|
|
283
|
+
/** Envía texto. / Sends text. */
|
|
284
|
+
static text(wa: WhatsApp, cid: string, caption: string, extra?: SendExtra): Promise<Message | null>;
|
|
285
|
+
/** Envía imagen. / Sends an image. */
|
|
286
|
+
static image(wa: WhatsApp, cid: string, buf: Buffer, extra?: SendExtra & {
|
|
287
|
+
caption?: string;
|
|
288
|
+
}): Promise<Message | null>;
|
|
289
|
+
/** Envía video. / Sends a video. */
|
|
290
|
+
static video(wa: WhatsApp, cid: string, buf: Buffer, extra?: SendExtra & {
|
|
291
|
+
caption?: string;
|
|
292
|
+
}): Promise<Message | null>;
|
|
293
|
+
/** Envía audio. / Sends audio. */
|
|
294
|
+
static audio(wa: WhatsApp, cid: string, buf: Buffer, extra?: SendExtra & {
|
|
295
|
+
ptt?: boolean;
|
|
296
|
+
}): Promise<Message | null>;
|
|
297
|
+
/** Envía ubicación. / Sends a location. */
|
|
298
|
+
static location(wa: WhatsApp, cid: string, loc: {
|
|
299
|
+
lat: number;
|
|
300
|
+
lng: number;
|
|
301
|
+
}, extra?: SendExtra): Promise<Message | null>;
|
|
302
|
+
/** Envía encuesta. / Sends a poll. */
|
|
303
|
+
static poll(wa: WhatsApp, cid: string, input: {
|
|
304
|
+
content: string;
|
|
305
|
+
options: {
|
|
306
|
+
content: string;
|
|
307
|
+
}[];
|
|
308
|
+
}, extra?: SendExtra & {
|
|
309
|
+
multiple?: boolean;
|
|
310
|
+
}): Promise<Message | null>;
|
|
311
|
+
/** Envía documento. / Sends a document. */
|
|
312
|
+
static document(wa: WhatsApp, cid: string, buf: Buffer, extra: SendExtra & {
|
|
313
|
+
file_name: string;
|
|
314
|
+
mimetype?: string;
|
|
315
|
+
caption?: string;
|
|
316
|
+
}): Promise<Message | null>;
|
|
317
|
+
/** Envía tarjeta(s) de contacto. / Sends contact card(s). */
|
|
318
|
+
static vcard(wa: WhatsApp, cid: string, contacts: {
|
|
319
|
+
name: string;
|
|
320
|
+
phone: string;
|
|
321
|
+
}[], extra?: SendExtra): Promise<Message | null>;
|
|
322
|
+
/** Envía evento. / Sends an event. */
|
|
323
|
+
static event(wa: WhatsApp, cid: string, data: {
|
|
324
|
+
name: string;
|
|
325
|
+
caption?: string;
|
|
326
|
+
start: Date;
|
|
327
|
+
end?: Date;
|
|
328
|
+
place?: {
|
|
329
|
+
lat: number;
|
|
330
|
+
lng: number;
|
|
331
|
+
};
|
|
332
|
+
}, extra?: SendExtra): Promise<Message | null>;
|
|
333
|
+
/** Reacciona a un mensaje por id. / Reacts to a message by id. */
|
|
334
|
+
static react(wa: WhatsApp, cid: string, mid: string, emoji: string): Promise<boolean>;
|
|
335
|
+
/** Destaca un mensaje por id. / Stars a message by id. */
|
|
336
|
+
static star(wa: WhatsApp, cid: string, mid: string, value: boolean): Promise<boolean>;
|
|
337
|
+
/** Marca un mensaje como leído por id. / Marks a message as read by id. */
|
|
338
|
+
static seen(wa: WhatsApp, cid: string, mid: string): Promise<boolean>;
|
|
339
|
+
/** Edita un mensaje por id. / Edits a message by id. */
|
|
340
|
+
static edit(wa: WhatsApp, cid: string, mid: string, caption: string): Promise<boolean>;
|
|
341
|
+
/** Reenvía un mensaje por id. / Forwards a message by id. */
|
|
342
|
+
static forward(wa: WhatsApp, cid: string, mid: string, target: string | Chat | Contact): Promise<boolean>;
|
|
343
|
+
/** Elimina un mensaje por id. / Deletes a message by id. */
|
|
344
|
+
static delete(wa: WhatsApp, cid: string, mid: string, all?: boolean): Promise<boolean>;
|
|
345
|
+
/** Reacciones de un mensaje por id. / Reactions of a message by id. */
|
|
346
|
+
static reactions(wa: WhatsApp, cid: string, mid: string): Promise<{
|
|
347
|
+
emoji: string;
|
|
348
|
+
count: number;
|
|
349
|
+
}[]>;
|
|
205
350
|
}
|
|
206
351
|
/**
|
|
207
|
-
* Mensaje de texto
|
|
208
|
-
* Text message
|
|
352
|
+
* Mensaje de texto; `preview()` expone la tarjeta del enlace embebido.
|
|
353
|
+
* Text message; `preview()` exposes the embedded link card.
|
|
209
354
|
*/
|
|
210
355
|
export declare class Text extends Message {
|
|
211
|
-
|
|
356
|
+
/**
|
|
357
|
+
* Preview del enlace del texto, o null cuando no trae metadata.
|
|
358
|
+
* Text link preview, or null when it carries no metadata.
|
|
359
|
+
*
|
|
360
|
+
* @returns { link, name, content, thumb } o null / { link, name, content, thumb } or null
|
|
361
|
+
*/
|
|
362
|
+
preview(): Promise<{
|
|
363
|
+
link: string;
|
|
364
|
+
name: string | null;
|
|
365
|
+
content: string | null;
|
|
366
|
+
thumb: Buffer | null;
|
|
367
|
+
} | null>;
|
|
212
368
|
}
|
|
213
369
|
/**
|
|
214
|
-
* Mensaje de imagen
|
|
215
|
-
* Image message
|
|
370
|
+
* Mensaje de imagen: dimensiones, peso y miniatura.
|
|
371
|
+
* Image message: dimensions, size and thumbnail.
|
|
216
372
|
*/
|
|
217
373
|
export declare class Image extends Message {
|
|
374
|
+
/** @internal */
|
|
375
|
+
private get _media();
|
|
376
|
+
/** Ancho en píxeles. / Width in pixels. */
|
|
377
|
+
get width(): number;
|
|
378
|
+
/** Alto en píxeles. / Height in pixels. */
|
|
379
|
+
get height(): number;
|
|
380
|
+
/** Peso en bytes. / Size in bytes. */
|
|
381
|
+
get size(): number;
|
|
382
|
+
/**
|
|
383
|
+
* Miniatura JPEG embebida, o null.
|
|
384
|
+
* Embedded JPEG thumbnail, or null.
|
|
385
|
+
*
|
|
386
|
+
* @returns Buffer de la miniatura o null / Thumbnail buffer or null
|
|
387
|
+
*/
|
|
388
|
+
thumb(): Promise<Buffer | null>;
|
|
218
389
|
content(): Promise<Buffer>;
|
|
219
390
|
}
|
|
220
391
|
/**
|
|
221
|
-
* Mensaje de video
|
|
222
|
-
* Video message
|
|
392
|
+
* Mensaje de video: dimensiones, duración, peso y miniatura.
|
|
393
|
+
* Video message: dimensions, duration, size and thumbnail.
|
|
223
394
|
*/
|
|
224
395
|
export declare class Video extends Message {
|
|
396
|
+
/** @internal */
|
|
397
|
+
private get _media();
|
|
398
|
+
/** Ancho en píxeles. / Width in pixels. */
|
|
399
|
+
get width(): number;
|
|
400
|
+
/** Alto en píxeles. / Height in pixels. */
|
|
401
|
+
get height(): number;
|
|
402
|
+
/** Duración en segundos. / Duration in seconds. */
|
|
403
|
+
get duration(): number;
|
|
404
|
+
/** Peso en bytes. / Size in bytes. */
|
|
405
|
+
get size(): number;
|
|
406
|
+
/**
|
|
407
|
+
* Miniatura JPEG embebida, o null.
|
|
408
|
+
* Embedded JPEG thumbnail, or null.
|
|
409
|
+
*
|
|
410
|
+
* @returns Buffer de la miniatura o null / Thumbnail buffer or null
|
|
411
|
+
*/
|
|
412
|
+
thumb(): Promise<Buffer | null>;
|
|
225
413
|
content(): Promise<Buffer>;
|
|
226
414
|
}
|
|
227
415
|
/**
|
|
228
|
-
* Mensaje de audio
|
|
229
|
-
*
|
|
230
|
-
* Audio message. Inherits `stream()` from the base class; `content()` drains the stream.
|
|
231
|
-
* `ptt` flags voice notes.
|
|
416
|
+
* Mensaje de audio: nota de voz o archivo, con forma de onda del protocolo.
|
|
417
|
+
* Audio message: voice note or file, with the protocol waveform.
|
|
232
418
|
*/
|
|
233
419
|
export declare class Audio extends Message {
|
|
234
|
-
/**
|
|
420
|
+
/** @internal */
|
|
421
|
+
private get _media();
|
|
422
|
+
/** true si es nota de voz. / true when push-to-talk. */
|
|
235
423
|
get ptt(): boolean;
|
|
424
|
+
/** Duración en segundos. / Duration in seconds. */
|
|
425
|
+
get duration(): number;
|
|
426
|
+
/** Peso en bytes. / Size in bytes. */
|
|
427
|
+
get size(): number;
|
|
428
|
+
/** Forma de onda 0-100 lista para pintar. / Paint-ready 0-100 waveform. */
|
|
429
|
+
get waveform(): number[];
|
|
236
430
|
content(): Promise<Buffer>;
|
|
237
431
|
}
|
|
238
432
|
/**
|
|
239
|
-
* Mensaje de
|
|
240
|
-
*
|
|
433
|
+
* Mensaje de sticker: dimensiones, peso y animación.
|
|
434
|
+
* Sticker message: dimensions, size and animation.
|
|
241
435
|
*/
|
|
242
|
-
export declare class
|
|
436
|
+
export declare class Sticker extends Message {
|
|
437
|
+
/** @internal */
|
|
438
|
+
private get _media();
|
|
439
|
+
/** Ancho en píxeles. / Width in pixels. */
|
|
440
|
+
get width(): number;
|
|
441
|
+
/** Alto en píxeles. / Height in pixels. */
|
|
442
|
+
get height(): number;
|
|
443
|
+
/** true si el sticker es animado. / true when animated. */
|
|
444
|
+
get animated(): boolean;
|
|
445
|
+
/** Peso en bytes. / Size in bytes. */
|
|
446
|
+
get size(): number;
|
|
447
|
+
content(): Promise<Buffer>;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Mensaje de documento; el MIME real vive en `mime` de la base.
|
|
451
|
+
* Document message; the actual MIME lives in the base `mime`.
|
|
452
|
+
*/
|
|
453
|
+
export declare class Document extends Message {
|
|
454
|
+
/** Peso en bytes. / Size in bytes. */
|
|
455
|
+
get size(): number;
|
|
456
|
+
content(): Promise<Buffer>;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Mensaje de ubicación, fija o en vivo.
|
|
460
|
+
* Location message, static or live.
|
|
461
|
+
*/
|
|
462
|
+
export declare class Location extends Message {
|
|
463
|
+
/** @internal */
|
|
243
464
|
private get _loc();
|
|
244
465
|
/** Latitud en grados. / Latitude in degrees. */
|
|
245
466
|
get lat(): number;
|
|
246
467
|
/** Longitud en grados. / Longitude in degrees. */
|
|
247
468
|
get lng(): number;
|
|
248
|
-
/** URL de Google Maps apuntando a la coordenada. / Google Maps URL for the coordinate. */
|
|
249
|
-
get link(): string;
|
|
250
469
|
/** true si es ubicación en tiempo real. / true when live location. */
|
|
251
470
|
get live(): boolean;
|
|
471
|
+
/** URL de Google Maps de la coordenada. / Google Maps URL for the coordinate. */
|
|
472
|
+
get link(): string;
|
|
252
473
|
}
|
|
253
474
|
/**
|
|
254
|
-
* Mensaje de encuesta
|
|
255
|
-
* Poll message
|
|
475
|
+
* Mensaje de encuesta: opciones con conteo, votos por contacto y voto propio.
|
|
476
|
+
* Poll message: options with counts, per-contact votes and self-voting.
|
|
256
477
|
*/
|
|
257
478
|
export declare class Poll extends Message {
|
|
479
|
+
/** @internal */
|
|
258
480
|
private get _poll();
|
|
259
|
-
/**
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
* fallback al `selectableOptionsCount` del proto (polls foráneos o de UI móvil).
|
|
263
|
-
* true if the poll accepts multiple answers. Prefers the persisted send-time
|
|
264
|
-
* flag (own polls, since WhatsApp drops the discriminator on echo); falls back
|
|
265
|
-
* to the proto `selectableOptionsCount` (foreign or mobile-UI polls).
|
|
266
|
-
*/
|
|
481
|
+
/** @internal Updates de voto con los bytes normalizados post-engine. / Vote updates with post-engine normalized bytes. */
|
|
482
|
+
private get _updates();
|
|
483
|
+
/** true si admite varias respuestas. / true when multi-select. */
|
|
267
484
|
get multiple(): boolean;
|
|
268
|
-
/** Opciones con conteo de votos
|
|
485
|
+
/** Opciones con su conteo de votos. / Options with their vote counts. */
|
|
269
486
|
get options(): {
|
|
270
|
-
|
|
487
|
+
name: string;
|
|
271
488
|
count: number;
|
|
272
489
|
}[];
|
|
273
490
|
/**
|
|
274
|
-
*
|
|
275
|
-
*
|
|
491
|
+
* Votos individuales: opción elegida y teléfono del votante.
|
|
492
|
+
* Individual votes: chosen option and voter phone.
|
|
493
|
+
*
|
|
494
|
+
* @returns Lista de votos / Vote list
|
|
495
|
+
*/
|
|
496
|
+
votes(): Promise<{
|
|
497
|
+
name: string;
|
|
498
|
+
contact: string;
|
|
499
|
+
}[]>;
|
|
500
|
+
/**
|
|
501
|
+
* Vota en la encuesta con uno o varios índices. Cifra el voto (HMAC+AES-GCM) y lo
|
|
502
|
+
* enruta al chat @lid con la identidad LID propia. Best-effort: el voto entrante
|
|
503
|
+
* descifra correcto, pero WhatsApp no propaga el voto emitido desde un dispositivo
|
|
504
|
+
* vinculado (companion).
|
|
505
|
+
* Votes in the poll with one or more indexes. Encrypts the vote (HMAC+AES-GCM) and
|
|
506
|
+
* routes it to the @lid chat with the own LID identity. Best-effort: incoming votes
|
|
507
|
+
* decrypt fine, but WhatsApp does not propagate votes emitted from a linked
|
|
508
|
+
* (companion) device.
|
|
509
|
+
*
|
|
510
|
+
* @param index - Índice o índices de la opción / Option index or indexes
|
|
511
|
+
* @returns true si el voto se emitió / true when the vote was relayed
|
|
276
512
|
*/
|
|
277
513
|
select(index: number | number[]): Promise<boolean>;
|
|
278
514
|
}
|
|
279
515
|
/**
|
|
280
|
-
* Mensaje de
|
|
281
|
-
*
|
|
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.
|
|
516
|
+
* Mensaje de tarjeta(s) de contacto.
|
|
517
|
+
* Contact card(s) message.
|
|
306
518
|
*/
|
|
307
519
|
export declare class VCard extends Message {
|
|
308
|
-
/** Contactos de la tarjeta
|
|
520
|
+
/** Contactos de la tarjeta. / Card contacts. */
|
|
309
521
|
get contacts(): {
|
|
310
522
|
name: string;
|
|
311
523
|
phone: string;
|
|
312
524
|
}[];
|
|
313
525
|
}
|
|
314
526
|
/**
|
|
315
|
-
* Mensaje de evento de calendario
|
|
316
|
-
*
|
|
317
|
-
* Calendar event message (`eventMessage`): name, description, date range,
|
|
318
|
-
* cancellation state, join link and location.
|
|
527
|
+
* Mensaje de evento de calendario.
|
|
528
|
+
* Calendar event message.
|
|
319
529
|
*/
|
|
320
530
|
export declare class Event extends Message {
|
|
531
|
+
/** @internal */
|
|
321
532
|
private get _event();
|
|
322
533
|
/** Nombre del evento. / Event name. */
|
|
323
534
|
get name(): string;
|
|
324
|
-
/**
|
|
325
|
-
get start():
|
|
326
|
-
/**
|
|
327
|
-
get end():
|
|
328
|
-
/** true si
|
|
535
|
+
/** Inicio en ISO UTC. / Start as ISO UTC. */
|
|
536
|
+
get start(): string;
|
|
537
|
+
/** Fin en ISO UTC, o null. / End as ISO UTC, or null. */
|
|
538
|
+
get end(): string | null;
|
|
539
|
+
/** true si fue cancelado. / true when canceled. */
|
|
329
540
|
get canceled(): boolean;
|
|
330
|
-
/** Link de unión
|
|
541
|
+
/** Link de unión, si aplica. / Join link, if any. */
|
|
331
542
|
get link(): string;
|
|
332
543
|
/** Ubicación del evento, o null. / Event location, or null. */
|
|
333
544
|
get place(): {
|
|
@@ -336,42 +547,16 @@ export declare class Event extends Message {
|
|
|
336
547
|
} | null;
|
|
337
548
|
}
|
|
338
549
|
/**
|
|
339
|
-
* Factoría
|
|
340
|
-
*
|
|
550
|
+
* Factoría de Message: evalúa el tipo y retorna la instancia de la subclase correcta.
|
|
551
|
+
* Acepta el documento persistido o el mensaje crudo de baileys — en ese caso el
|
|
552
|
+
* documento se deriva aquí mismo (id, tipo, autor, caption, mime, fechas).
|
|
553
|
+
* Message factory: evaluates the type and returns the right subclass instance. Accepts
|
|
554
|
+
* the persisted document or the raw baileys message — in that case the document is
|
|
555
|
+
* derived right here (id, type, author, caption, mime, dates).
|
|
556
|
+
*
|
|
557
|
+
* @param wa - Instancia principal / Main WhatsApp instance
|
|
558
|
+
* @param raw - Documento persistido o WAMessage crudo / Persisted document or raw WAMessage
|
|
559
|
+
* @returns Instancia del tipo correcto / Right-type instance
|
|
341
560
|
*/
|
|
342
|
-
export declare function message(wa: WhatsApp):
|
|
343
|
-
Text: typeof Text;
|
|
344
|
-
Image: typeof Image;
|
|
345
|
-
Video: typeof Video;
|
|
346
|
-
Audio: typeof Audio;
|
|
347
|
-
Gps: typeof Gps;
|
|
348
|
-
Poll: typeof Poll;
|
|
349
|
-
Document: typeof Document;
|
|
350
|
-
VCard: typeof VCard;
|
|
351
|
-
Event: typeof Event;
|
|
352
|
-
build_message_doc: typeof build_message_doc;
|
|
353
|
-
build_instance: (doc: IMessage) => Promise<Message>;
|
|
354
|
-
/** Obtiene un mensaje por CID/MID. */
|
|
355
|
-
get(cid: string, mid: string): Promise<Message | null>;
|
|
356
|
-
/** Pagina mensajes de un chat. */
|
|
357
|
-
list(cid: string, offset?: number, limit?: number): Promise<Message[]>;
|
|
358
|
-
/** Cuenta mensajes de un chat. */
|
|
359
|
-
count(cid: string): Promise<number>;
|
|
360
|
-
text(cid: string, caption: string, opts?: SendOptions): Promise<Message | null>;
|
|
361
|
-
image(cid: string, buf: Buffer, opts?: SendMediaOptions): Promise<Message | null>;
|
|
362
|
-
video(cid: string, buf: Buffer, opts?: SendMediaOptions): Promise<Message | null>;
|
|
363
|
-
audio(cid: string, buf: Buffer, opts?: SendAudioOptions): Promise<Message | null>;
|
|
364
|
-
location(cid: string, loc: LocationOptions, opts?: SendOptions): Promise<Message | null>;
|
|
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>;
|
|
369
|
-
edit(cid: string, mid: string, text: string): Promise<boolean>;
|
|
370
|
-
delete(cid: string, mid: string, all?: boolean): Promise<boolean>;
|
|
371
|
-
react(cid: string, mid: string, emoji: string): Promise<boolean>;
|
|
372
|
-
forward(cid: string, mid: string, target: ForwardTarget): Promise<boolean>;
|
|
373
|
-
seen(cid: string, mid: string): Promise<boolean>;
|
|
374
|
-
star(cid: string, mid: string, value: boolean): Promise<boolean>;
|
|
375
|
-
watch(cid: string, mid: string, handler: (msg: Message) => void): () => void;
|
|
376
|
-
};
|
|
561
|
+
export declare function message(wa: WhatsApp, raw: Message['_raw'] | WAMessage): Message;
|
|
377
562
|
export {};
|