@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
package/build/cjs/WhatsApp.js
DELETED
|
@@ -1,412 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file WhatsApp.ts
|
|
4
|
-
* @description Clase principal que gestiona la conexión y eventos de WhatsApp
|
|
5
|
-
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
-
var ownKeys = function(o) {
|
|
24
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
-
var ar = [];
|
|
26
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
return ownKeys(o);
|
|
30
|
-
};
|
|
31
|
-
return function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
})();
|
|
39
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
-
};
|
|
42
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.WhatsApp = void 0;
|
|
44
|
-
const baileys_1 = require("baileys");
|
|
45
|
-
const node_events_1 = require("node:events");
|
|
46
|
-
const pino_1 = __importDefault(require("pino"));
|
|
47
|
-
const QRCode = __importStar(require("qrcode"));
|
|
48
|
-
const Chat_1 = require("./Chat");
|
|
49
|
-
const Contact_1 = require("./Contact");
|
|
50
|
-
const Message_1 = require("./Message");
|
|
51
|
-
const store_1 = require("./store");
|
|
52
|
-
/**
|
|
53
|
-
* @description
|
|
54
|
-
* Clase principal para gestionar la conexión con WhatsApp.
|
|
55
|
-
* Main class for managing the WhatsApp connection.
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* const { event, pair, Contact, Chat, Message } = new WhatsApp({ phone: '5491112345678' });
|
|
59
|
-
* event.on('open', () => console.log('Conectado'));
|
|
60
|
-
* await pair((code) => console.log('Código:', code));
|
|
61
|
-
*/
|
|
62
|
-
class WhatsApp {
|
|
63
|
-
constructor(options = {}) {
|
|
64
|
-
this._socket = null;
|
|
65
|
-
/**
|
|
66
|
-
* @description Conecta a WhatsApp.
|
|
67
|
-
* Connects to WhatsApp.
|
|
68
|
-
* - Con phone: callback recibe código de 8 dígitos (una vez)
|
|
69
|
-
* - Sin phone: callback recibe QR como Buffer PNG (periódicamente)
|
|
70
|
-
*/
|
|
71
|
-
this.pair = async (callback) => {
|
|
72
|
-
const { version } = await (0, baileys_1.fetchLatestBaileysVersion)();
|
|
73
|
-
const stored = await this.engine.get('session/creds');
|
|
74
|
-
const creds = stored ? JSON.parse(stored, baileys_1.BufferJSON.reviver) : (0, baileys_1.initAuthCreds)();
|
|
75
|
-
let code_sent = false;
|
|
76
|
-
const connect = async () => {
|
|
77
|
-
this._socket = (0, baileys_1.makeWASocket)({
|
|
78
|
-
version,
|
|
79
|
-
auth: {
|
|
80
|
-
creds,
|
|
81
|
-
keys: {
|
|
82
|
-
get: async (type, ids) => {
|
|
83
|
-
const data = {};
|
|
84
|
-
for (const id of ids) {
|
|
85
|
-
const stored = await this.engine.get(`session/${type}/${id}`);
|
|
86
|
-
if (stored) {
|
|
87
|
-
let value = JSON.parse(stored, baileys_1.BufferJSON.reviver);
|
|
88
|
-
if (type === 'app-state-sync-key')
|
|
89
|
-
value = baileys_1.proto.Message.AppStateSyncKeyData.create(value);
|
|
90
|
-
data[id] = value;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return data;
|
|
94
|
-
},
|
|
95
|
-
set: async (data) => {
|
|
96
|
-
for (const category in data) {
|
|
97
|
-
for (const id in data[category]) {
|
|
98
|
-
const value = data[category][id];
|
|
99
|
-
await this.engine.set(`session/${category}/${id}`, value ? JSON.stringify(value, baileys_1.BufferJSON.replacer) : null);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
browser: baileys_1.Browsers.windows('Chrome'),
|
|
106
|
-
printQRInTerminal: false,
|
|
107
|
-
logger: (0, pino_1.default)({ level: 'silent' }),
|
|
108
|
-
syncFullHistory: false,
|
|
109
|
-
markOnlineOnConnect: false,
|
|
110
|
-
});
|
|
111
|
-
const socket = this._socket;
|
|
112
|
-
socket.ev.on('creds.update', () => this.engine.set('session/creds', JSON.stringify(creds, baileys_1.BufferJSON.replacer)));
|
|
113
|
-
socket.ev.on('connection.update', async (update) => {
|
|
114
|
-
const { connection, lastDisconnect, qr } = update;
|
|
115
|
-
if (qr && !creds.registered) {
|
|
116
|
-
if (this._phone && !code_sent) {
|
|
117
|
-
code_sent = true;
|
|
118
|
-
await callback(await socket.requestPairingCode(this._phone));
|
|
119
|
-
}
|
|
120
|
-
else if (!this._phone) {
|
|
121
|
-
await callback(await QRCode.toBuffer(qr, { type: 'png', margin: 2 }));
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (connection === 'open') {
|
|
125
|
-
this.event.emit('open');
|
|
126
|
-
}
|
|
127
|
-
else if (connection === 'close') {
|
|
128
|
-
this._socket = null;
|
|
129
|
-
if (lastDisconnect?.error?.output?.statusCode === baileys_1.DisconnectReason.loggedOut) {
|
|
130
|
-
this.event.emit('error', new Error('Logged out'));
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
this.event.emit('close');
|
|
134
|
-
setTimeout(connect, 3000);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
138
|
-
// CONTACTS
|
|
139
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
140
|
-
socket.ev.on('contacts.upsert', async (contacts) => {
|
|
141
|
-
for (const c of contacts) {
|
|
142
|
-
if (!c.id)
|
|
143
|
-
continue;
|
|
144
|
-
const existing = await this.engine.get(`contact/${c.id}/index`);
|
|
145
|
-
const raw = {
|
|
146
|
-
id: c.id,
|
|
147
|
-
lid: c.lid ?? null,
|
|
148
|
-
name: c.name ?? null,
|
|
149
|
-
notify: c.notify ?? null,
|
|
150
|
-
verifiedName: c.verifiedName ?? null,
|
|
151
|
-
imgUrl: c.imgUrl ?? null,
|
|
152
|
-
status: c.status ?? null,
|
|
153
|
-
};
|
|
154
|
-
await this.engine.set(`contact/${c.id}/index`, JSON.stringify(raw, baileys_1.BufferJSON.replacer));
|
|
155
|
-
if (raw.lid)
|
|
156
|
-
await this.engine.set(`lid/${raw.lid}`, raw.id);
|
|
157
|
-
this.event.emit(existing ? 'contact:updated' : 'contact:created', new this.Contact(raw));
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
socket.ev.on('contacts.update', async (contacts) => {
|
|
161
|
-
for (const c of contacts) {
|
|
162
|
-
if (!c.id)
|
|
163
|
-
continue;
|
|
164
|
-
const stored = await this.engine.get(`contact/${c.id}/index`);
|
|
165
|
-
if (!stored)
|
|
166
|
-
continue;
|
|
167
|
-
const raw = JSON.parse(stored, baileys_1.BufferJSON.reviver);
|
|
168
|
-
if (c.notify)
|
|
169
|
-
raw.notify = c.notify;
|
|
170
|
-
if (c.name)
|
|
171
|
-
raw.name = c.name;
|
|
172
|
-
if (c.imgUrl)
|
|
173
|
-
raw.imgUrl = c.imgUrl;
|
|
174
|
-
if (c.status)
|
|
175
|
-
raw.status = c.status;
|
|
176
|
-
if (c.lid)
|
|
177
|
-
raw.lid = c.lid;
|
|
178
|
-
await this.engine.set(`contact/${c.id}/index`, JSON.stringify(raw, baileys_1.BufferJSON.replacer));
|
|
179
|
-
if (raw.lid)
|
|
180
|
-
await this.engine.set(`lid/${raw.lid}`, raw.id);
|
|
181
|
-
this.event.emit('contact:updated', new this.Contact(raw));
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
socket.ev.on('lid-mapping.update', async ({ lid, pn }) => {
|
|
185
|
-
await this.engine.set(`lid/${lid}`, pn);
|
|
186
|
-
await this.engine.set(`lid/${pn}`, lid);
|
|
187
|
-
});
|
|
188
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
189
|
-
// CHATS
|
|
190
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
191
|
-
socket.ev.on('chats.upsert', async (chats) => {
|
|
192
|
-
for (const ch of chats) {
|
|
193
|
-
const existing = await this.engine.get(`chat/${ch.id}/index`);
|
|
194
|
-
const raw = existing
|
|
195
|
-
? JSON.parse(existing, baileys_1.BufferJSON.reviver)
|
|
196
|
-
: {
|
|
197
|
-
id: ch.id,
|
|
198
|
-
name: ch.name ?? null,
|
|
199
|
-
archived: ch.archived ?? null,
|
|
200
|
-
pinned: ch.pinned ?? null,
|
|
201
|
-
muteEndTime: ch.muteEndTime ?? null,
|
|
202
|
-
unreadCount: ch.unreadCount ?? null,
|
|
203
|
-
readOnly: ch.readOnly ?? null,
|
|
204
|
-
};
|
|
205
|
-
if (ch.name)
|
|
206
|
-
raw.name = ch.name;
|
|
207
|
-
await this.engine.set(`chat/${ch.id}/index`, JSON.stringify(raw, baileys_1.BufferJSON.replacer));
|
|
208
|
-
this.event.emit(existing ? 'chat:updated' : 'chat:created', new this.Chat(raw));
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
socket.ev.on('chats.update', async (chats) => {
|
|
212
|
-
for (const ch of chats) {
|
|
213
|
-
if (!ch.id)
|
|
214
|
-
continue;
|
|
215
|
-
const stored = await this.engine.get(`chat/${ch.id}/index`);
|
|
216
|
-
const raw = stored ? JSON.parse(stored, baileys_1.BufferJSON.reviver) : { id: ch.id, name: ch.name ?? null };
|
|
217
|
-
let has_specific_event = false;
|
|
218
|
-
if (ch.name !== undefined)
|
|
219
|
-
raw.name = ch.name ?? raw.name;
|
|
220
|
-
if ('pinned' in ch) {
|
|
221
|
-
raw.pinned = ch.pinned ?? null;
|
|
222
|
-
has_specific_event = true;
|
|
223
|
-
}
|
|
224
|
-
if (ch.archived !== undefined) {
|
|
225
|
-
raw.archived = ch.archived ?? false;
|
|
226
|
-
has_specific_event = true;
|
|
227
|
-
}
|
|
228
|
-
if ('muteEndTime' in ch) {
|
|
229
|
-
raw.muteEndTime = ch.muteEndTime ? Number(ch.muteEndTime) : null;
|
|
230
|
-
has_specific_event = true;
|
|
231
|
-
}
|
|
232
|
-
if (ch.unreadCount !== undefined)
|
|
233
|
-
raw.unreadCount = ch.unreadCount;
|
|
234
|
-
await this.engine.set(`chat/${ch.id}/index`, JSON.stringify(raw, baileys_1.BufferJSON.replacer));
|
|
235
|
-
const instance = new this.Chat({ ...raw });
|
|
236
|
-
if ('pinned' in ch)
|
|
237
|
-
this.event.emit('chat:pinned', instance);
|
|
238
|
-
if (ch.archived !== undefined)
|
|
239
|
-
this.event.emit('chat:archived', instance);
|
|
240
|
-
if ('muteEndTime' in ch)
|
|
241
|
-
this.event.emit('chat:muted', instance);
|
|
242
|
-
if (!has_specific_event)
|
|
243
|
-
this.event.emit(stored ? 'chat:updated' : 'chat:created', instance);
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
socket.ev.on('chats.delete', async (ids) => {
|
|
247
|
-
for (const cid of ids) {
|
|
248
|
-
await this.engine.set(`chat/${cid}`, null);
|
|
249
|
-
this.event.emit('chat:deleted', cid);
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
253
|
-
// MESSAGES
|
|
254
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
255
|
-
socket.ev.on('messages.upsert', async ({ messages }) => {
|
|
256
|
-
for (const msg of messages) {
|
|
257
|
-
if (!msg.key?.remoteJid || !msg.key.id)
|
|
258
|
-
continue;
|
|
259
|
-
const cid = msg.key.remoteJidAlt || msg.key.remoteJid;
|
|
260
|
-
const mid = msg.key.id;
|
|
261
|
-
const content_type = (0, baileys_1.getContentType)(msg.message ?? {});
|
|
262
|
-
if (content_type === 'reactionMessage' || content_type === 'pollUpdateMessage')
|
|
263
|
-
continue;
|
|
264
|
-
// ─── PROTOCOL MESSAGE (ediciones y eliminaciones) ───
|
|
265
|
-
if (content_type === 'protocolMessage') {
|
|
266
|
-
const protocol = msg.message?.protocolMessage;
|
|
267
|
-
if (!protocol?.key?.id)
|
|
268
|
-
continue;
|
|
269
|
-
const target_mid = protocol.key.id;
|
|
270
|
-
const target_cid = protocol.key.remoteJid ?? cid;
|
|
271
|
-
if (protocol.type === baileys_1.proto.Message.ProtocolMessage.Type.MESSAGE_EDIT) {
|
|
272
|
-
const edited_msg = protocol.editedMessage;
|
|
273
|
-
if (!edited_msg)
|
|
274
|
-
continue;
|
|
275
|
-
const stored_index = await this.engine.get(`chat/${target_cid}/message/${target_mid}/index`);
|
|
276
|
-
const stored_raw = await this.engine.get(`chat/${target_cid}/message/${target_mid}/raw`);
|
|
277
|
-
if (!stored_index || !stored_raw)
|
|
278
|
-
continue;
|
|
279
|
-
const index = JSON.parse(stored_index, baileys_1.BufferJSON.reviver);
|
|
280
|
-
const raw = JSON.parse(stored_raw, baileys_1.BufferJSON.reviver);
|
|
281
|
-
raw.message = edited_msg;
|
|
282
|
-
index.edited = true;
|
|
283
|
-
index.caption = this.Message._build_index(raw).caption;
|
|
284
|
-
await this.engine.set(`chat/${target_cid}/message/${target_mid}/index`, JSON.stringify(index, baileys_1.BufferJSON.replacer));
|
|
285
|
-
await this.engine.set(`chat/${target_cid}/message/${target_mid}/raw`, JSON.stringify(raw, baileys_1.BufferJSON.replacer));
|
|
286
|
-
const instance = new this.Message({ index, raw });
|
|
287
|
-
this.Message._notify(target_cid, target_mid);
|
|
288
|
-
this.event.emit('message:updated', instance);
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
if (protocol.type === baileys_1.proto.Message.ProtocolMessage.Type.REVOKE) {
|
|
292
|
-
await this.Message._remove_from_index(target_cid, target_mid);
|
|
293
|
-
await this.engine.set(`chat/${target_cid}/message/${target_mid}`, null);
|
|
294
|
-
this.event.emit('message:deleted', target_cid, target_mid);
|
|
295
|
-
}
|
|
296
|
-
continue;
|
|
297
|
-
}
|
|
298
|
-
// ─── MENSAJE NUEVO ───
|
|
299
|
-
const index = this.Message._build_index(msg);
|
|
300
|
-
await this.engine.set(`chat/${cid}/message/${mid}/index`, JSON.stringify(index, baileys_1.BufferJSON.replacer));
|
|
301
|
-
await this.engine.set(`chat/${cid}/message/${mid}/raw`, JSON.stringify(msg, baileys_1.BufferJSON.replacer));
|
|
302
|
-
let content = Buffer.alloc(0);
|
|
303
|
-
if (index.type === 'text') {
|
|
304
|
-
const raw_content = msg.message?.[content_type];
|
|
305
|
-
content = Buffer.from(typeof raw_content === 'string' ? raw_content : raw_content?.text ?? raw_content?.caption ?? '', 'utf-8');
|
|
306
|
-
}
|
|
307
|
-
else if (index.type === 'location') {
|
|
308
|
-
const loc = msg.message?.locationMessage ?? msg.message?.liveLocationMessage;
|
|
309
|
-
content = Buffer.from(JSON.stringify({ lat: loc?.degreesLatitude, lng: loc?.degreesLongitude }), 'utf-8');
|
|
310
|
-
}
|
|
311
|
-
else if (index.type === 'poll') {
|
|
312
|
-
const poll = msg.message?.pollCreationMessage ?? msg.message?.pollCreationMessageV2 ?? msg.message?.pollCreationMessageV3;
|
|
313
|
-
content = Buffer.from(JSON.stringify({ content: poll?.name ?? '', options: poll?.options?.map((o) => ({ content: o.optionName })) ?? [] }), 'utf-8');
|
|
314
|
-
}
|
|
315
|
-
else if (['image', 'video', 'audio'].includes(index.type) && this._socket) {
|
|
316
|
-
try {
|
|
317
|
-
const buffer = await (0, baileys_1.downloadMediaMessage)(msg, 'buffer', {});
|
|
318
|
-
if (Buffer.isBuffer(buffer))
|
|
319
|
-
content = buffer;
|
|
320
|
-
}
|
|
321
|
-
catch { /* media download may fail */ }
|
|
322
|
-
}
|
|
323
|
-
if (content.length)
|
|
324
|
-
await this.engine.set(`chat/${cid}/message/${mid}/content`, content.toString('base64'));
|
|
325
|
-
await this.Message._add_to_index(cid, mid, index.created_at);
|
|
326
|
-
const instance = new this.Message({ index, raw: msg });
|
|
327
|
-
if (content.length)
|
|
328
|
-
instance.content = async () => content;
|
|
329
|
-
this.Message._notify(cid, mid);
|
|
330
|
-
this.event.emit('message:created', instance);
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
socket.ev.on('messages.update', async (updates) => {
|
|
334
|
-
for (const { key, update } of updates) {
|
|
335
|
-
if (!key.remoteJid || !key.id)
|
|
336
|
-
continue;
|
|
337
|
-
const stored_raw = await this.engine.get(`chat/${key.remoteJid}/message/${key.id}/raw`);
|
|
338
|
-
const stored_index = await this.engine.get(`chat/${key.remoteJid}/message/${key.id}/index`);
|
|
339
|
-
if (!stored_index)
|
|
340
|
-
continue;
|
|
341
|
-
const index = JSON.parse(stored_index, baileys_1.BufferJSON.reviver);
|
|
342
|
-
const raw = stored_raw ? JSON.parse(stored_raw, baileys_1.BufferJSON.reviver) : { key };
|
|
343
|
-
if (update.message?.editedMessage?.message) {
|
|
344
|
-
raw.message = update.message.editedMessage.message;
|
|
345
|
-
index.edited = true;
|
|
346
|
-
index.caption = this.Message._build_index(raw).caption;
|
|
347
|
-
await this.engine.set(`chat/${key.remoteJid}/message/${key.id}/index`, JSON.stringify(index, baileys_1.BufferJSON.replacer));
|
|
348
|
-
await this.engine.set(`chat/${key.remoteJid}/message/${key.id}/raw`, JSON.stringify(raw, baileys_1.BufferJSON.replacer));
|
|
349
|
-
const instance = new this.Message({ index, raw });
|
|
350
|
-
this.Message._notify(key.remoteJid, key.id);
|
|
351
|
-
this.event.emit('message:updated', instance);
|
|
352
|
-
continue;
|
|
353
|
-
}
|
|
354
|
-
if (update.status !== undefined) {
|
|
355
|
-
raw.status = update.status;
|
|
356
|
-
index.status = raw.status;
|
|
357
|
-
await this.engine.set(`chat/${key.remoteJid}/message/${key.id}/index`, JSON.stringify(index, baileys_1.BufferJSON.replacer));
|
|
358
|
-
await this.engine.set(`chat/${key.remoteJid}/message/${key.id}/raw`, JSON.stringify(raw, baileys_1.BufferJSON.replacer));
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
socket.ev.on('messages.reaction', async (reactions) => {
|
|
363
|
-
for (const { key, reaction } of reactions) {
|
|
364
|
-
if (key.remoteJid && key.id)
|
|
365
|
-
this.event.emit('message:reacted', key.remoteJid, key.id, reaction.text ?? '');
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
};
|
|
369
|
-
await connect();
|
|
370
|
-
};
|
|
371
|
-
this._phone = options.phone?.toString();
|
|
372
|
-
this.engine = options.engine ?? new store_1.FileEngine(this._phone ? `.baileys/${this._phone}` : '.baileys/default');
|
|
373
|
-
this.event = new node_events_1.EventEmitter();
|
|
374
|
-
this.Contact = (0, Contact_1.contact)(this);
|
|
375
|
-
this.Chat = (0, Chat_1.chat)(this);
|
|
376
|
-
this.Message = (0, Message_1.message)(this);
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* @description Retorna el socket de Baileys (null si no está conectado).
|
|
380
|
-
* Returns the Baileys socket (null if disconnected).
|
|
381
|
-
*/
|
|
382
|
-
get socket() {
|
|
383
|
-
return this._socket;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* @description Normaliza cualquier identificador (JID, LID, phone) a JID.
|
|
387
|
-
* Normalizes any identifier (JID, LID, phone) to JID format.
|
|
388
|
-
* @param uid Identificador: JID, LID (@lid), o numero de telefono.
|
|
389
|
-
*/
|
|
390
|
-
async resolveJID(uid) {
|
|
391
|
-
if (uid.endsWith('@g.us'))
|
|
392
|
-
return uid;
|
|
393
|
-
if (uid.endsWith('@s.whatsapp.net'))
|
|
394
|
-
return uid;
|
|
395
|
-
if (uid.endsWith('@lid')) {
|
|
396
|
-
const lid_number = uid.split('@')[0];
|
|
397
|
-
const direct = await this.engine.get(`lid/${uid}`);
|
|
398
|
-
if (direct)
|
|
399
|
-
return direct.includes('@') ? direct : `${direct}@s.whatsapp.net`;
|
|
400
|
-
const reverse = await this.engine.get(`session/lid-mapping/${lid_number}_reverse`);
|
|
401
|
-
if (reverse) {
|
|
402
|
-
const phone = JSON.parse(reverse);
|
|
403
|
-
return `${phone}@s.whatsapp.net`;
|
|
404
|
-
}
|
|
405
|
-
return null;
|
|
406
|
-
}
|
|
407
|
-
const cleaned = uid.replace(/\D/g, '');
|
|
408
|
-
return cleaned ? `${cleaned}@s.whatsapp.net` : null;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
exports.WhatsApp = WhatsApp;
|
|
412
|
-
//# sourceMappingURL=WhatsApp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WhatsApp.js","sour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G,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;YACnD,IAAI,MAAM;gBAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,iBAAiB,CAAC;YAC9E,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAuB,UAAU,UAAU,CAAC,CAAC;YACnF,IAAI,OAAO,EAAE,CAAC;gBACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAClC,OAAO,GAAG,KAAK,iBAAiB,CAAC;YACrC,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvC,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,CAAC;CAwTJ;AAxWD,4BAwWC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file store/driver/FileEngine.ts
|
|
3
|
-
* @description Engine de persistencia en sistema de archivos local
|
|
4
|
-
*/
|
|
5
|
-
import type { Engine } from '../../store/engine';
|
|
6
|
-
/**
|
|
7
|
-
* @description
|
|
8
|
-
* Engine de persistencia en sistema de archivos.
|
|
9
|
-
* Almacena texto plano (JSON stringified).
|
|
10
|
-
*
|
|
11
|
-
* Filesystem persistence engine.
|
|
12
|
-
* Stores plain text (JSON stringified).
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const engine = new FileEngine('.baileys/5491112345678');
|
|
16
|
-
* await engine.set('contact/123', '{"name":"John"}');
|
|
17
|
-
* const data = await engine.get('contact/123');
|
|
18
|
-
*/
|
|
19
|
-
export declare class FileEngine implements Engine {
|
|
20
|
-
private readonly _base;
|
|
21
|
-
constructor(_base?: string);
|
|
22
|
-
/** @description Obtiene un valor por su key. / Retrieves a value by its key. */
|
|
23
|
-
get(key: string): Promise<string | null>;
|
|
24
|
-
/**
|
|
25
|
-
* @description Guarda o elimina un valor. Si value es null, elimina la key como archivo y como directorio recursivamente.
|
|
26
|
-
* Saves or deletes a value. If value is null, removes the key as file and as directory recursively.
|
|
27
|
-
*/
|
|
28
|
-
set(key: string, value: string | null): Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* @description Lista keys bajo un prefijo, ordenados por más reciente.
|
|
31
|
-
* Lists keys under a prefix, ordered by most recent.
|
|
32
|
-
*/
|
|
33
|
-
list(prefix: string, offset?: number, limit?: number): Promise<string[]>;
|
|
34
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file store/driver/FileEngine.ts
|
|
4
|
-
* @description Engine de persistencia en sistema de archivos local
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.FileEngine = void 0;
|
|
8
|
-
const promises_1 = require("node:fs/promises");
|
|
9
|
-
const node_path_1 = require("node:path");
|
|
10
|
-
/**
|
|
11
|
-
* @description
|
|
12
|
-
* Engine de persistencia en sistema de archivos.
|
|
13
|
-
* Almacena texto plano (JSON stringified).
|
|
14
|
-
*
|
|
15
|
-
* Filesystem persistence engine.
|
|
16
|
-
* Stores plain text (JSON stringified).
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* const engine = new FileEngine('.baileys/5491112345678');
|
|
20
|
-
* await engine.set('contact/123', '{"name":"John"}');
|
|
21
|
-
* const data = await engine.get('contact/123');
|
|
22
|
-
*/
|
|
23
|
-
class FileEngine {
|
|
24
|
-
constructor(_base = '.baileys/default') {
|
|
25
|
-
this._base = _base;
|
|
26
|
-
}
|
|
27
|
-
/** @description Obtiene un valor por su key. / Retrieves a value by its key. */
|
|
28
|
-
async get(key) {
|
|
29
|
-
try {
|
|
30
|
-
return await (0, promises_1.readFile)((0, node_path_1.join)(this._base, key.replace(/@/g, '_at_')), 'utf-8');
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @description Guarda o elimina un valor. Si value es null, elimina la key como archivo y como directorio recursivamente.
|
|
38
|
-
* Saves or deletes a value. If value is null, removes the key as file and as directory recursively.
|
|
39
|
-
*/
|
|
40
|
-
async set(key, value) {
|
|
41
|
-
const path = (0, node_path_1.join)(this._base, key.replace(/@/g, '_at_'));
|
|
42
|
-
if (value) {
|
|
43
|
-
await (0, promises_1.mkdir)((0, node_path_1.dirname)(path), { recursive: true });
|
|
44
|
-
await (0, promises_1.writeFile)(path, value, 'utf-8');
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
try {
|
|
48
|
-
await (0, promises_1.rm)(path, { recursive: true, force: true });
|
|
49
|
-
}
|
|
50
|
-
catch { /* already deleted */ }
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @description Lista keys bajo un prefijo, ordenados por más reciente.
|
|
55
|
-
* Lists keys under a prefix, ordered by most recent.
|
|
56
|
-
*/
|
|
57
|
-
async list(prefix, offset = 0, limit = 50) {
|
|
58
|
-
const base = (0, node_path_1.join)(this._base, prefix.replace(/@/g, '_at_'));
|
|
59
|
-
try {
|
|
60
|
-
const items = [];
|
|
61
|
-
const entries = await (0, promises_1.readdir)(base, { withFileTypes: true, recursive: true });
|
|
62
|
-
for (const file of entries) {
|
|
63
|
-
if (!file.isFile())
|
|
64
|
-
continue;
|
|
65
|
-
const parent = file.parentPath || file.path || base;
|
|
66
|
-
const path = (0, node_path_1.join)(parent, file.name);
|
|
67
|
-
try {
|
|
68
|
-
items.push({
|
|
69
|
-
key: path.slice(this._base.length + 1).replace(/_at_/g, '@'),
|
|
70
|
-
mtime: (await (0, promises_1.stat)(path)).mtimeMs,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
catch { /* stat may fail for transient files */ }
|
|
74
|
-
}
|
|
75
|
-
return items
|
|
76
|
-
.sort((a, b) => b.mtime - a.mtime)
|
|
77
|
-
.slice(offset, offset + limit)
|
|
78
|
-
.map((f) => f.key);
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
return [];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
exports.FileEngine = FileEngine;
|
|
86
|
-
//# sourceMappingURL=FileEngine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileEngine.js","sourceRoot":"","sources":["../../../../src/store/driver/FileEngine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAiF;AACjF,yCAA0C;AAG1C;;;;;;;;;;;;GAYG;AACH,MAAa,UAAU;IACnB,YAA6B,QAAgB,kBAAkB;QAAlC,UAAK,GAAL,KAAK,CAA6B;IAAG,CAAC;IAEnE,gFAAgF;IAChF,KAAK,CAAC,GAAG,CAAC,GAAW;QACjB,IAAI,CAAC;YACD,OAAO,MAAM,IAAA,mBAAQ,EAAC,IAAA,gBAAI,EAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAChF,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAoB;QACvC,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QACzD,IAAI,KAAK,EAAE,CAAC;YACR,MAAM,IAAA,gBAAK,EAAC,IAAA,mBAAO,EAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC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,IAAI,CAAC,CAAC,CAAC,OAAO;qBACpC,CAAC,CAAC;gBACP,CAAC;gBAAC,MAAM,CAAC,CAAC,uCAAuC,CAAC,CAAC;YACvD,CAAC;YACD,OAAO,KAAK;iBACP,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;iBACjC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;iBAC7B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;CACJ;AAxDD,gCAwDC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file store/driver/RedisEngine.ts
|
|
3
|
-
* @description Engine de persistencia con Redis
|
|
4
|
-
*/
|
|
5
|
-
import type { Engine } from '../../store/engine';
|
|
6
|
-
/**
|
|
7
|
-
* @description Interface mínima del cliente Redis (compatible con ioredis y redis).
|
|
8
|
-
* Minimal Redis client interface (compatible with ioredis and redis).
|
|
9
|
-
*/
|
|
10
|
-
export interface RedisClient {
|
|
11
|
-
get(key: string): Promise<string | null>;
|
|
12
|
-
set(key: string, value: string): Promise<unknown>;
|
|
13
|
-
del(key: string | string[]): Promise<unknown>;
|
|
14
|
-
scan(cursor: number | string, ...args: unknown[]): Promise<[string, string[]]>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @description
|
|
18
|
-
* Engine de persistencia con Redis.
|
|
19
|
-
* Recibe una conexión existente de ioredis o redis.
|
|
20
|
-
*
|
|
21
|
-
* Redis persistence engine.
|
|
22
|
-
* Receives an existing ioredis or redis connection.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* import Redis from 'ioredis';
|
|
26
|
-
* const client = new Redis();
|
|
27
|
-
* const engine = new RedisEngine(client, 'wa:5491112345678');
|
|
28
|
-
* await engine.set('contact/123', '{"name":"John"}');
|
|
29
|
-
*/
|
|
30
|
-
export declare class RedisEngine implements Engine {
|
|
31
|
-
private readonly _client;
|
|
32
|
-
private readonly _prefix;
|
|
33
|
-
constructor(_client: RedisClient, _prefix?: string);
|
|
34
|
-
/** @description Obtiene un valor por su key. / Retrieves a value by its key. */
|
|
35
|
-
get(key: string): Promise<string | null>;
|
|
36
|
-
/**
|
|
37
|
-
* @description Guarda o elimina un valor. Si value es null, elimina la key y todas las sub-keys con ese prefijo.
|
|
38
|
-
* Saves or deletes a value. If value is null, deletes the key and all sub-keys matching the prefix.
|
|
39
|
-
*/
|
|
40
|
-
set(key: string, value: string | null): Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* @description Lista keys bajo un prefijo.
|
|
43
|
-
* Lists keys under a prefix.
|
|
44
|
-
* @note Redis SCAN no garantiza orden. / Redis SCAN does not guarantee order.
|
|
45
|
-
*/
|
|
46
|
-
list(prefix: string, offset?: number, limit?: number): Promise<string[]>;
|
|
47
|
-
}
|