@arcaelas/whatsapp 2.2.0 → 3.0.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/build/cjs/decorators.d.ts +9 -0
- package/build/cjs/decorators.js +26 -0
- package/build/cjs/decorators.js.map +1 -0
- package/build/cjs/index.d.ts +6 -10
- package/build/cjs/index.js +11 -10
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/lib/bot/decorator.d.ts +77 -0
- package/build/cjs/lib/bot/decorator.js +219 -0
- package/build/cjs/lib/bot/decorator.js.map +1 -0
- package/build/cjs/lib/bot/decorators.d.ts +113 -0
- package/build/cjs/lib/bot/decorators.js +253 -0
- package/build/cjs/lib/bot/decorators.js.map +1 -0
- package/build/cjs/lib/bot/index.d.ts +3 -0
- package/build/cjs/lib/bot/index.js +20 -0
- package/build/cjs/lib/bot/index.js.map +1 -0
- package/build/cjs/lib/chat/index.d.ts +227 -0
- package/build/cjs/lib/chat/index.js +324 -0
- package/build/cjs/lib/chat/index.js.map +1 -0
- package/build/cjs/lib/contact/index.d.ts +203 -0
- package/build/cjs/lib/contact/index.js +226 -0
- package/build/cjs/lib/contact/index.js.map +1 -0
- package/build/cjs/lib/message/index.d.ts +237 -0
- package/build/cjs/lib/message/index.js +685 -0
- package/build/cjs/lib/message/index.js.map +1 -0
- package/build/cjs/lib/store/engine/index.d.ts +34 -0
- package/build/cjs/lib/store/engine/index.js +13 -0
- package/build/cjs/lib/store/engine/index.js.map +1 -0
- package/build/cjs/lib/store/engine/lib/file_system/index.d.ts +56 -0
- package/build/cjs/lib/store/engine/lib/file_system/index.js +160 -0
- package/build/cjs/lib/store/engine/lib/file_system/index.js.map +1 -0
- package/build/cjs/lib/store/engine/lib/redis/index.d.ts +82 -0
- package/build/cjs/lib/store/engine/lib/redis/index.js +132 -0
- package/build/cjs/lib/store/engine/lib/redis/index.js.map +1 -0
- package/build/cjs/lib/store/index.d.ts +22 -0
- package/build/cjs/lib/store/index.js +38 -0
- package/build/cjs/lib/store/index.js.map +1 -0
- package/build/cjs/lib/whatsapp/index.d.ts +179 -0
- package/build/cjs/lib/whatsapp/index.js +754 -0
- package/build/cjs/lib/whatsapp/index.js.map +1 -0
- package/build/esm/decorators.d.ts +9 -0
- package/build/esm/decorators.js +9 -0
- package/build/esm/decorators.js.map +1 -0
- package/build/esm/index.d.ts +6 -10
- package/build/esm/index.js +4 -6
- package/build/esm/index.js.map +1 -1
- package/build/esm/lib/bot/decorator.d.ts +77 -0
- package/build/esm/lib/bot/decorator.js +210 -0
- package/build/esm/lib/bot/decorator.js.map +1 -0
- package/build/esm/lib/bot/decorators.d.ts +113 -0
- package/build/esm/lib/bot/decorators.js +242 -0
- package/build/esm/lib/bot/decorators.js.map +1 -0
- package/build/esm/lib/bot/index.d.ts +3 -0
- package/build/esm/lib/bot/index.js +3 -0
- package/build/esm/lib/bot/index.js.map +1 -0
- package/build/esm/lib/chat/index.d.ts +227 -0
- package/build/esm/lib/chat/index.js +319 -0
- package/build/esm/lib/chat/index.js.map +1 -0
- package/build/esm/lib/contact/index.d.ts +203 -0
- package/build/esm/lib/contact/index.js +221 -0
- package/build/esm/lib/contact/index.js.map +1 -0
- package/build/esm/lib/message/index.d.ts +237 -0
- package/build/esm/lib/message/index.js +673 -0
- package/build/esm/lib/message/index.js.map +1 -0
- package/build/esm/lib/store/engine/index.d.ts +34 -0
- package/build/esm/lib/store/engine/index.js +8 -0
- package/build/esm/lib/store/engine/index.js.map +1 -0
- package/build/esm/lib/store/engine/lib/file_system/index.d.ts +56 -0
- package/build/esm/lib/store/engine/lib/file_system/index.js +156 -0
- package/build/esm/lib/store/engine/lib/file_system/index.js.map +1 -0
- package/build/esm/lib/store/engine/lib/redis/index.d.ts +82 -0
- package/build/esm/lib/store/engine/lib/redis/index.js +128 -0
- package/build/esm/lib/store/engine/lib/redis/index.js.map +1 -0
- package/build/esm/lib/store/index.d.ts +22 -0
- package/build/esm/lib/store/index.js +31 -0
- package/build/esm/lib/store/index.js.map +1 -0
- package/build/esm/lib/whatsapp/index.d.ts +179 -0
- package/build/esm/lib/whatsapp/index.js +714 -0
- package/build/esm/lib/whatsapp/index.js.map +1 -0
- package/package.json +8 -6
- package/build/cjs/Chat.d.ts +0 -317
- package/build/cjs/Chat.js +0 -275
- package/build/cjs/Chat.js.map +0 -1
- package/build/cjs/Contact.d.ts +0 -1163
- package/build/cjs/Contact.js +0 -162
- package/build/cjs/Contact.js.map +0 -1
- package/build/cjs/Message.d.ts +0 -902
- package/build/cjs/Message.js +0 -515
- package/build/cjs/Message.js.map +0 -1
- package/build/cjs/WhatsApp.d.ts +0 -80
- package/build/cjs/WhatsApp.js +0 -412
- package/build/cjs/WhatsApp.js.map +0 -1
- package/build/cjs/store/driver/FileEngine.d.ts +0 -34
- package/build/cjs/store/driver/FileEngine.js +0 -86
- package/build/cjs/store/driver/FileEngine.js.map +0 -1
- package/build/cjs/store/driver/RedisEngine.d.ts +0 -47
- package/build/cjs/store/driver/RedisEngine.js +0 -70
- package/build/cjs/store/driver/RedisEngine.js.map +0 -1
- package/build/cjs/store/engine.d.ts +0 -53
- package/build/cjs/store/engine.js +0 -7
- package/build/cjs/store/engine.js.map +0 -1
- package/build/cjs/store/index.d.ts +0 -8
- package/build/cjs/store/index.js +0 -12
- package/build/cjs/store/index.js.map +0 -1
- package/build/esm/Chat.d.ts +0 -317
- package/build/esm/Chat.js +0 -270
- package/build/esm/Chat.js.map +0 -1
- package/build/esm/Contact.d.ts +0 -1163
- package/build/esm/Contact.js +0 -157
- package/build/esm/Contact.js.map +0 -1
- package/build/esm/Message.d.ts +0 -902
- package/build/esm/Message.js +0 -510
- package/build/esm/Message.js.map +0 -1
- package/build/esm/WhatsApp.d.ts +0 -80
- package/build/esm/WhatsApp.js +0 -372
- package/build/esm/WhatsApp.js.map +0 -1
- package/build/esm/store/driver/FileEngine.d.ts +0 -34
- package/build/esm/store/driver/FileEngine.js +0 -82
- package/build/esm/store/driver/FileEngine.js.map +0 -1
- package/build/esm/store/driver/RedisEngine.d.ts +0 -47
- package/build/esm/store/driver/RedisEngine.js +0 -66
- package/build/esm/store/driver/RedisEngine.js.map +0 -1
- package/build/esm/store/engine.d.ts +0 -53
- package/build/esm/store/engine.js +0 -6
- package/build/esm/store/engine.js.map +0 -1
- package/build/esm/store/index.d.ts +0 -8
- package/build/esm/store/index.js +0 -7
- package/build/esm/store/index.js.map +0 -1
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file contact/index.ts
|
|
3
|
+
* @description Entidad Contact — lectura/escritura documental sobre `wa.engine`.
|
|
4
|
+
* Contact entity — documental read/write over `wa.engine`.
|
|
5
|
+
*/
|
|
6
|
+
import { jidNormalizedUser } from 'baileys';
|
|
7
|
+
import { deserialize, serialize } from '../../lib/store/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Clase base del contacto (forma pública, solo lectura).
|
|
10
|
+
* Base Contact class (public shape, read-only).
|
|
11
|
+
*/
|
|
12
|
+
export class Contact {
|
|
13
|
+
constructor(raw, chat) {
|
|
14
|
+
this._raw = raw;
|
|
15
|
+
this.chat = chat;
|
|
16
|
+
}
|
|
17
|
+
/** JID único. / Unique JID. */
|
|
18
|
+
get id() {
|
|
19
|
+
return this._raw.id;
|
|
20
|
+
}
|
|
21
|
+
/** JID (alias). / JID (alias). */
|
|
22
|
+
get jid() {
|
|
23
|
+
return this._raw.id;
|
|
24
|
+
}
|
|
25
|
+
/** LID si está disponible. / LID when available. */
|
|
26
|
+
get lid() {
|
|
27
|
+
return this._raw.lid ?? null;
|
|
28
|
+
}
|
|
29
|
+
/** Nombre: local → push → teléfono. / Name: local → push → phone. */
|
|
30
|
+
get name() {
|
|
31
|
+
return this._raw.name ?? this._raw.notify ?? this._raw.id.split('@')[0];
|
|
32
|
+
}
|
|
33
|
+
/** Número sin formato. / Raw phone number. */
|
|
34
|
+
get phone() {
|
|
35
|
+
return this._raw.id.split('@')[0];
|
|
36
|
+
}
|
|
37
|
+
/** URL de foto de perfil. / Profile picture URL. */
|
|
38
|
+
get photo() {
|
|
39
|
+
return this._raw.img_url ?? null;
|
|
40
|
+
}
|
|
41
|
+
/** Bio del contacto. / Contact bio. */
|
|
42
|
+
get content() {
|
|
43
|
+
return this._raw.status ?? '';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Factoría de Contact ligada al contexto WhatsApp.
|
|
48
|
+
* Context-bound Contact factory.
|
|
49
|
+
*
|
|
50
|
+
* @param wa - Instancia principal / Main WhatsApp instance
|
|
51
|
+
*/
|
|
52
|
+
export function contact(wa) {
|
|
53
|
+
/**
|
|
54
|
+
* Descubre el JID canónico y el LID (cuando aplica) de un número consultando al socket.
|
|
55
|
+
* Discovers the canonical JID and LID (when applicable) of a phone number via the socket.
|
|
56
|
+
*/
|
|
57
|
+
async function discover_by_phone(phone) {
|
|
58
|
+
let result = null;
|
|
59
|
+
if (wa._socket && phone.length > 0) {
|
|
60
|
+
const found = (await wa._socket.onWhatsApp(phone))?.[0];
|
|
61
|
+
if (found?.exists) {
|
|
62
|
+
result = { jid: jidNormalizedUser(found.jid), lid: found.lid ?? null };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Obtiene foto y bio del contacto desde el socket.
|
|
69
|
+
* Fetches profile picture and bio from the socket.
|
|
70
|
+
*/
|
|
71
|
+
async function fetch_profile_data(id) {
|
|
72
|
+
let img_url = null;
|
|
73
|
+
let status = null;
|
|
74
|
+
if (wa._socket) {
|
|
75
|
+
try {
|
|
76
|
+
img_url = (await wa._socket.profilePictureUrl(id, 'image')) ?? null;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
/* may not exist */
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const result = await wa._socket.fetchStatus(id);
|
|
83
|
+
const data = result?.[0];
|
|
84
|
+
status = data?.status?.status ?? null;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
/* may fail */
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return { img_url, status };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Carga la instancia Chat 1:1 del contacto. Si no existe en engine, fabrica una mínima.
|
|
94
|
+
* Loads the 1:1 Chat instance for a contact. Falls back to a minimal instance if missing.
|
|
95
|
+
*/
|
|
96
|
+
async function load_chat_for(jid, fallback_name) {
|
|
97
|
+
const cached = deserialize(await wa.engine.get(`/chat/${jid}`));
|
|
98
|
+
return new wa.Chat(cached ?? { id: jid, name: fallback_name });
|
|
99
|
+
}
|
|
100
|
+
return class _Contact extends Contact {
|
|
101
|
+
constructor(raw, chat) {
|
|
102
|
+
super(raw, chat);
|
|
103
|
+
}
|
|
104
|
+
/** true si la instancia representa la cuenta autenticada. / true if this instance is the authenticated account. */
|
|
105
|
+
get me() {
|
|
106
|
+
const self_id = wa._socket?.user?.id;
|
|
107
|
+
return Boolean(self_id) && jidNormalizedUser(self_id) === this.id;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Obtiene un contacto. Dispatch inteligente:
|
|
111
|
+
* - Si `uid` contiene `@` → se interpreta como JID (`@s.whatsapp.net` / `@g.us`) o LID (`@lid`) y se resuelve con el mapping.
|
|
112
|
+
* - Si no contiene `@` → se limpian los dígitos y se consulta `socket.onWhatsApp(phone)` para obtener el JID canónico.
|
|
113
|
+
*
|
|
114
|
+
* Retrieves a contact. Smart dispatch:
|
|
115
|
+
* - If `uid` contains `@` → treated as JID or LID, resolved via mapping.
|
|
116
|
+
* - If `uid` lacks `@` → digits are extracted and `socket.onWhatsApp(phone)` resolves the canonical JID.
|
|
117
|
+
*/
|
|
118
|
+
static async get(uid) {
|
|
119
|
+
let result = null;
|
|
120
|
+
let jid = null;
|
|
121
|
+
let lid = null;
|
|
122
|
+
if (uid.includes('@')) {
|
|
123
|
+
jid = await wa._resolve_jid(uid);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
const discovered = await discover_by_phone(uid.replace(/\D+/g, ''));
|
|
127
|
+
if (discovered) {
|
|
128
|
+
jid = discovered.jid;
|
|
129
|
+
lid = discovered.lid;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (jid && !jid.endsWith('@g.us')) {
|
|
133
|
+
const cached = deserialize(await wa.engine.get(`/contact/${jid}`));
|
|
134
|
+
if (cached) {
|
|
135
|
+
const fallback_name = cached.name ?? cached.notify ?? jid.split('@')[0];
|
|
136
|
+
result = new _Contact(cached, await load_chat_for(jid, fallback_name));
|
|
137
|
+
}
|
|
138
|
+
else if (wa._socket) {
|
|
139
|
+
const needs_check = !lid && !uid.endsWith('@lid');
|
|
140
|
+
const discovered = needs_check
|
|
141
|
+
? await discover_by_phone(jid.split('@')[0])
|
|
142
|
+
: { jid, lid };
|
|
143
|
+
if (discovered) {
|
|
144
|
+
const { img_url, status } = await fetch_profile_data(discovered.jid);
|
|
145
|
+
const raw = {
|
|
146
|
+
id: discovered.jid,
|
|
147
|
+
lid: discovered.lid,
|
|
148
|
+
name: null,
|
|
149
|
+
notify: null,
|
|
150
|
+
verified_name: null,
|
|
151
|
+
img_url,
|
|
152
|
+
status,
|
|
153
|
+
};
|
|
154
|
+
await wa.engine.set(`/contact/${discovered.jid}`, serialize(raw));
|
|
155
|
+
if (discovered.lid) {
|
|
156
|
+
await wa.engine.set(`/lid/${discovered.lid}`, serialize(discovered.jid));
|
|
157
|
+
}
|
|
158
|
+
result = new _Contact(raw, await load_chat_for(discovered.jid, discovered.jid.split('@')[0]));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Pagina los contactos persistidos por mtime DESC, pre-cargando el chat de cada uno.
|
|
166
|
+
* Paginates persisted contacts by mtime DESC, pre-loading the chat of each one.
|
|
167
|
+
*/
|
|
168
|
+
static async list(offset = 0, limit = 50) {
|
|
169
|
+
const contacts = [];
|
|
170
|
+
for (const raw of await wa.engine.list('/contact', offset, limit)) {
|
|
171
|
+
const parsed = deserialize(raw);
|
|
172
|
+
if (parsed) {
|
|
173
|
+
const fallback_name = parsed.name ?? parsed.notify ?? parsed.id.split('@')[0];
|
|
174
|
+
contacts.push(new _Contact(parsed, await load_chat_for(parsed.id, fallback_name)));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return contacts;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Renombra localmente un contacto por id.
|
|
181
|
+
* Renames a contact locally by id.
|
|
182
|
+
*/
|
|
183
|
+
static async rename(uid, name) {
|
|
184
|
+
const c = await _Contact.get(uid);
|
|
185
|
+
return c ? c.rename(name) : false;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Re-hidrata los datos del contacto por id desde el socket.
|
|
189
|
+
* Re-hydrates contact data from the socket by id.
|
|
190
|
+
*/
|
|
191
|
+
static async refresh(uid) {
|
|
192
|
+
const c = await _Contact.get(uid);
|
|
193
|
+
return c ? c.refresh() : null;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Renombra el contacto localmente (solo agenda del dispositivo).
|
|
197
|
+
* Renames the contact locally (device address book only).
|
|
198
|
+
*/
|
|
199
|
+
async rename(name) {
|
|
200
|
+
this._raw.name = name;
|
|
201
|
+
await wa.engine.set(`/contact/${this.id}`, serialize(this._raw));
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Re-hidrata foto y bio desde el socket.
|
|
206
|
+
* Re-hydrates profile picture and bio from the socket.
|
|
207
|
+
*/
|
|
208
|
+
async refresh() {
|
|
209
|
+
let ok = false;
|
|
210
|
+
if (wa._socket) {
|
|
211
|
+
const { img_url, status } = await fetch_profile_data(this.id);
|
|
212
|
+
this._raw.img_url = img_url;
|
|
213
|
+
this._raw.status = status;
|
|
214
|
+
await wa.engine.set(`/contact/${this.id}`, serialize(this._raw));
|
|
215
|
+
ok = true;
|
|
216
|
+
}
|
|
217
|
+
return ok ? this : null;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/contact/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAiBrD;;;GAGG;AACH,MAAM,OAAO,OAAO;IAMlB,YAAY,GAAgB,EAAE,IAAU;QACtC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,+BAA+B;IAC/B,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACtB,CAAC;IACD,kCAAkC;IAClC,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACtB,CAAC;IACD,oDAAoD;IACpD,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC;IAC/B,CAAC;IACD,qEAAqE;IACrE,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;IACD,8CAA8C;IAC9C,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IACD,oDAAoD;IACpD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,IAAI,CAAC,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EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;gBACjE,EAAE,GAAG,IAAI,CAAC;YACZ,CAAC;YACD,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file message/index.ts
|
|
3
|
+
* @description Entidad Message — una sola clase base que recibe `{wa, doc}` en el constructor.
|
|
4
|
+
* Subclases especializadas (Text, Image, Video, Audio, Gps, Poll) override `content()` según su tipo.
|
|
5
|
+
*/
|
|
6
|
+
import { type WAMessage } from 'baileys';
|
|
7
|
+
import { Readable } from 'node:stream';
|
|
8
|
+
import { Chat } from '../../lib/chat/index.js';
|
|
9
|
+
import { Contact } from '../../lib/contact/index.js';
|
|
10
|
+
import type { WhatsApp } from '../../lib/whatsapp/index.js';
|
|
11
|
+
/** Destino aceptado por `forward`: CID (string), Chat o Contact. */
|
|
12
|
+
export type ForwardTarget = string | Chat | Contact;
|
|
13
|
+
/** Tipos de mensaje internos (no expuestos como getter público). */
|
|
14
|
+
export type MessageType = 'text' | 'image' | 'video' | 'audio' | 'location' | 'poll';
|
|
15
|
+
export declare enum MessageStatus {
|
|
16
|
+
ERROR = 0,
|
|
17
|
+
PENDING = 1,
|
|
18
|
+
SERVER_ACK = 2,
|
|
19
|
+
DELIVERED = 3,
|
|
20
|
+
READ = 4,
|
|
21
|
+
PLAYED = 5
|
|
22
|
+
}
|
|
23
|
+
export interface SendOptions {
|
|
24
|
+
mid?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface SendMediaOptions extends SendOptions {
|
|
27
|
+
caption?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface SendAudioOptions extends SendOptions {
|
|
30
|
+
ptt?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface LocationOptions {
|
|
33
|
+
lat: number;
|
|
34
|
+
lng: number;
|
|
35
|
+
live?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface PollOptions {
|
|
38
|
+
content: string;
|
|
39
|
+
options: Array<{
|
|
40
|
+
content: string;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Documento persistido del mensaje.
|
|
45
|
+
*/
|
|
46
|
+
export interface IMessage {
|
|
47
|
+
id: string;
|
|
48
|
+
cid: string;
|
|
49
|
+
mid: string | null;
|
|
50
|
+
me: boolean;
|
|
51
|
+
type: MessageType;
|
|
52
|
+
author: string;
|
|
53
|
+
status: MessageStatus;
|
|
54
|
+
starred: boolean;
|
|
55
|
+
forwarded: boolean;
|
|
56
|
+
created_at: number;
|
|
57
|
+
deleted_at: number | null;
|
|
58
|
+
mime: string;
|
|
59
|
+
caption: string;
|
|
60
|
+
edited: boolean;
|
|
61
|
+
raw: WAMessage;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Construye el documento IMessage desde el raw de baileys.
|
|
65
|
+
*/
|
|
66
|
+
export declare function build_message_doc(raw: WAMessage, self_id?: string, edited?: boolean): IMessage;
|
|
67
|
+
/**
|
|
68
|
+
* Clase base del mensaje. Una sola clase — toda la API de instancia vive aquí.
|
|
69
|
+
* Base message class. Single class — all instance API lives here.
|
|
70
|
+
*/
|
|
71
|
+
export declare class Message {
|
|
72
|
+
/** @internal */
|
|
73
|
+
protected readonly _wa: WhatsApp;
|
|
74
|
+
/** @internal */
|
|
75
|
+
protected readonly _doc: IMessage;
|
|
76
|
+
constructor(options: {
|
|
77
|
+
wa: WhatsApp;
|
|
78
|
+
doc: IMessage;
|
|
79
|
+
});
|
|
80
|
+
get id(): string;
|
|
81
|
+
get cid(): string;
|
|
82
|
+
get type(): MessageType;
|
|
83
|
+
/** JID del autor del mensaje. Para acceso síncrono sin hidratar el Contact. */
|
|
84
|
+
get from(): string;
|
|
85
|
+
/** MIME type del contenido. `text/plain` para texto, `application/json` para location/poll, mimetype real para media. */
|
|
86
|
+
get mime(): string;
|
|
87
|
+
get mid(): string | null;
|
|
88
|
+
get me(): boolean;
|
|
89
|
+
get caption(): string;
|
|
90
|
+
get starred(): boolean;
|
|
91
|
+
get forwarded(): boolean;
|
|
92
|
+
get once(): boolean;
|
|
93
|
+
get created_at(): number;
|
|
94
|
+
get deleted_at(): number | null;
|
|
95
|
+
get status(): MessageStatus;
|
|
96
|
+
get edited(): boolean;
|
|
97
|
+
/** Contacto del autor (resuelve vía `wa.Contact.get`; fallback a instancia mínima). */
|
|
98
|
+
author(): Promise<InstanceType<typeof this._wa.Contact>>;
|
|
99
|
+
/** Chat al que pertenece el mensaje. */
|
|
100
|
+
chat(): Promise<InstanceType<typeof this._wa.Chat>>;
|
|
101
|
+
/** Contenido sin parsear, directo del engine. Las subclases override según su tipo. */
|
|
102
|
+
content(): Promise<Buffer>;
|
|
103
|
+
/**
|
|
104
|
+
* Devuelve un `Readable` con los bytes del mensaje. Para media (image/video/audio)
|
|
105
|
+
* lee desde el cache del engine o, si falta, descarga desde baileys. Para text/location/poll
|
|
106
|
+
* retorna el mismo binario que `content()` envuelto en un Readable.
|
|
107
|
+
* Returns a `Readable` of the message bytes. For media (image/video/audio) it reads
|
|
108
|
+
* from the engine cache or, if missing, downloads from baileys. For text/location/poll
|
|
109
|
+
* it wraps the `content()` buffer in a Readable.
|
|
110
|
+
*/
|
|
111
|
+
stream(): Promise<Readable>;
|
|
112
|
+
/** Reacciona al mensaje (emoji vacío para retirar). */
|
|
113
|
+
react(emoji: string): Promise<boolean>;
|
|
114
|
+
/** Reenvía el mensaje a un destino (CID, Chat o Contact). */
|
|
115
|
+
forward(target: ForwardTarget): Promise<boolean>;
|
|
116
|
+
/** Marca el mensaje como leído. */
|
|
117
|
+
seen(): Promise<boolean>;
|
|
118
|
+
/** Destaca/retira destacado del mensaje. */
|
|
119
|
+
star(value: boolean): Promise<boolean>;
|
|
120
|
+
/** Elimina el mensaje. `all=true` (default) borra para todos; `all=false` borra sólo en mi dispositivo. */
|
|
121
|
+
delete(all?: boolean): Promise<boolean>;
|
|
122
|
+
/** Edita el texto/caption del mensaje (solo propios editables). */
|
|
123
|
+
edit(text: string): Promise<boolean>;
|
|
124
|
+
/** Observa cambios sobre este mensaje. Retorna unsubscribe. / Watches this message. Returns unsubscribe. */
|
|
125
|
+
watch(handler: (msg: Message) => void): () => void;
|
|
126
|
+
/** Responde con texto. */
|
|
127
|
+
text(caption: string, opts?: SendOptions): Promise<Message | null>;
|
|
128
|
+
/** Responde con imagen. */
|
|
129
|
+
image(buf: Buffer, opts?: SendMediaOptions): Promise<Message | null>;
|
|
130
|
+
/** Responde con video. */
|
|
131
|
+
video(buf: Buffer, opts?: SendMediaOptions): Promise<Message | null>;
|
|
132
|
+
/** Responde con audio. */
|
|
133
|
+
audio(buf: Buffer, opts?: SendAudioOptions): Promise<Message | null>;
|
|
134
|
+
/** Responde con ubicación. */
|
|
135
|
+
location(loc: LocationOptions, opts?: SendOptions): Promise<Message | null>;
|
|
136
|
+
/** Responde con encuesta. */
|
|
137
|
+
poll(poll: PollOptions, opts?: SendOptions): Promise<Message | null>;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Mensaje de texto. Override `content()` para retornar el caption como Buffer sin pasar por engine.
|
|
141
|
+
* Text message. Overrides `content()` returning caption as Buffer directly.
|
|
142
|
+
*/
|
|
143
|
+
export declare class Text extends Message {
|
|
144
|
+
content(): Promise<Buffer>;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Mensaje de imagen. Hereda `stream()` de la clase base; `content()` drena el stream.
|
|
148
|
+
* Image message. Inherits `stream()` from the base class; `content()` drains the stream.
|
|
149
|
+
*/
|
|
150
|
+
export declare class Image extends Message {
|
|
151
|
+
content(): Promise<Buffer>;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Mensaje de video. Hereda `stream()` de la clase base; `content()` drena el stream.
|
|
155
|
+
* Video message. Inherits `stream()` from the base class; `content()` drains the stream.
|
|
156
|
+
*/
|
|
157
|
+
export declare class Video extends Message {
|
|
158
|
+
content(): Promise<Buffer>;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Mensaje de audio. Hereda `stream()` de la clase base; `content()` drena el stream.
|
|
162
|
+
* `ptt` indica si es nota de voz (push-to-talk).
|
|
163
|
+
* Audio message. Inherits `stream()` from the base class; `content()` drains the stream.
|
|
164
|
+
* `ptt` flags voice notes.
|
|
165
|
+
*/
|
|
166
|
+
export declare class Audio extends Message {
|
|
167
|
+
/** true si es nota de voz (push-to-talk). / true if push-to-talk voice note. */
|
|
168
|
+
get ptt(): boolean;
|
|
169
|
+
content(): Promise<Buffer>;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Mensaje de ubicación. Agrega getters sync `lat`, `lng`, `link` derivados del raw.
|
|
173
|
+
* Location message. Adds sync getters `lat`, `lng`, `link` derived from raw.
|
|
174
|
+
*/
|
|
175
|
+
export declare class Gps extends Message {
|
|
176
|
+
private get _loc();
|
|
177
|
+
/** Latitud en grados. / Latitude in degrees. */
|
|
178
|
+
get lat(): number;
|
|
179
|
+
/** Longitud en grados. / Longitude in degrees. */
|
|
180
|
+
get lng(): number;
|
|
181
|
+
/** URL de Google Maps apuntando a la coordenada. / Google Maps URL for the coordinate. */
|
|
182
|
+
get link(): string;
|
|
183
|
+
/** true si es ubicación en tiempo real. / true when live location. */
|
|
184
|
+
get live(): boolean;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Mensaje de encuesta. `caption` es la pregunta (heredada); agrega `options[]` con conteo y `multiple`.
|
|
188
|
+
* Poll message. `caption` is the question (inherited); adds `options[]` with counts and `multiple`.
|
|
189
|
+
*/
|
|
190
|
+
export declare class Poll extends Message {
|
|
191
|
+
private get _poll();
|
|
192
|
+
/** true si admite múltiples respuestas. / true if it accepts multiple answers. */
|
|
193
|
+
get multiple(): boolean;
|
|
194
|
+
/** Opciones con conteo de votos actualizado. / Options with up-to-date vote counts. */
|
|
195
|
+
get options(): {
|
|
196
|
+
content: string;
|
|
197
|
+
count: number;
|
|
198
|
+
}[];
|
|
199
|
+
/**
|
|
200
|
+
* Vota en la encuesta. Acepta un índice o lista de índices (para `multiple`).
|
|
201
|
+
* Votes in the poll. Accepts a single index or list (for `multiple`).
|
|
202
|
+
*/
|
|
203
|
+
select(index: number | number[]): Promise<boolean>;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Factoría que enlaza los statics a `wa` y expone las subclases.
|
|
207
|
+
* Factory binding statics to `wa` and exposing subclasses.
|
|
208
|
+
*/
|
|
209
|
+
export declare function message(wa: WhatsApp): {
|
|
210
|
+
Text: typeof Text;
|
|
211
|
+
Image: typeof Image;
|
|
212
|
+
Video: typeof Video;
|
|
213
|
+
Audio: typeof Audio;
|
|
214
|
+
Gps: typeof Gps;
|
|
215
|
+
Poll: typeof Poll;
|
|
216
|
+
build_message_doc: typeof build_message_doc;
|
|
217
|
+
build_instance: (doc: IMessage) => Promise<Message>;
|
|
218
|
+
/** Obtiene un mensaje por CID/MID. */
|
|
219
|
+
get(cid: string, mid: string): Promise<Message | null>;
|
|
220
|
+
/** Pagina mensajes de un chat. */
|
|
221
|
+
list(cid: string, offset?: number, limit?: number): Promise<Message[]>;
|
|
222
|
+
/** Cuenta mensajes de un chat. */
|
|
223
|
+
count(cid: string): Promise<number>;
|
|
224
|
+
text(cid: string, caption: string, opts?: SendOptions): Promise<Message | null>;
|
|
225
|
+
image(cid: string, buf: Buffer, opts?: SendMediaOptions): Promise<Message | null>;
|
|
226
|
+
video(cid: string, buf: Buffer, opts?: SendMediaOptions): Promise<Message | null>;
|
|
227
|
+
audio(cid: string, buf: Buffer, opts?: SendAudioOptions): Promise<Message | null>;
|
|
228
|
+
location(cid: string, loc: LocationOptions, opts?: SendOptions): Promise<Message | null>;
|
|
229
|
+
poll(cid: string, p: PollOptions, opts?: SendOptions): Promise<Message | null>;
|
|
230
|
+
edit(cid: string, mid: string, text: string): Promise<boolean>;
|
|
231
|
+
delete(cid: string, mid: string, all?: boolean): Promise<boolean>;
|
|
232
|
+
react(cid: string, mid: string, emoji: string): Promise<boolean>;
|
|
233
|
+
forward(cid: string, mid: string, target: ForwardTarget): Promise<boolean>;
|
|
234
|
+
seen(cid: string, mid: string): Promise<boolean>;
|
|
235
|
+
star(cid: string, mid: string, value: boolean): Promise<boolean>;
|
|
236
|
+
watch(cid: string, mid: string, handler: (msg: Message) => void): () => void;
|
|
237
|
+
};
|