@areumtecnologia/baileys 1.0.2 → 1.0.4

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.
@@ -36,6 +36,10 @@ class MessageHandler {
36
36
  this.client._validateConnection();
37
37
  const verifiedJid = await this.client.users.isOnWhatsApp(jid);
38
38
  if (verifiedJid && verifiedJid.exists) {
39
+ if (options.composing) {
40
+ this.client.sock.sendPresenceUpdate('composing', verifiedJid.jid);
41
+ await new Promise(r => setTimeout(() => r(true), options.composing?.timeout));
42
+ }
39
43
  const msg = await this.client.sock.sendMessage(verifiedJid.jid, content, options);
40
44
  const nmsg = await MessageNormalizer.normalize(msg, this.client);
41
45
  return nmsg;
@@ -99,11 +103,12 @@ class MessageHandler {
99
103
  }
100
104
 
101
105
  /** Envia um documento. */
102
- async sendDocument(jid, media, mimetype, fileName = 'file', options = {}) {
106
+ async sendDocument(jid, media, mimetype, fileName = '', caption = '', options = {}) {
103
107
  const content = {
104
108
  document: typeof media === 'string' ? { url: media } : media,
105
109
  mimetype,
106
- fileName
110
+ fileName,
111
+ caption
107
112
  };
108
113
  return this.sendMessage(jid, content, options);
109
114
  }
@@ -215,29 +220,12 @@ class MessageHandler {
215
220
  // MÉTODOS INTERATIVOS E OUTROS
216
221
  // =================================================================================================
217
222
  /** Envia acoes */
218
- async sendTyping(jid) {
219
- try {
220
- this.client._validateConnection();
221
- const verifiedJid = await this.client.users.isOnWhatsApp(jid);
222
- if (verifiedJid && verifiedJid.exists) {
223
-
224
- await this.client.sock.presenceSubscribe(jid)
225
- await this.client.sock.sendPresenceUpdate('available', jid)
226
- await Utils.delay(500);
227
-
228
- await this.client.sock.sendPresenceUpdate('composing', jid)
229
- await Utils.delay(5000)
230
-
231
- return await this.client.sock.sendPresenceUpdate('paused', jid)
232
- }
233
- else {
234
- return verifiedJid;
235
- }
236
223
 
237
- } catch (error) {
238
- throw error;
239
- }
224
+ // Metodo para enviar notificacao "digitando"
225
+ composing(jid, ts) {
226
+ return this.client.sock.sendPresenceUpdate('composing', jid);
240
227
  }
228
+
241
229
  /** Marca mensagens como lidas. */
242
230
  async read(messageKey) {
243
231
  this.client._validateConnection();
@@ -341,7 +329,7 @@ class MessageHandler {
341
329
  };
342
330
 
343
331
  return {
344
- type: mimetype,
332
+ mimetype,
345
333
  extension,
346
334
  buffer,
347
335
 
package/index.js CHANGED
@@ -416,6 +416,10 @@ class Client extends EventEmitter {
416
416
  return false;
417
417
  }
418
418
  }
419
+ // Metodo para enviar notificacao "digitando"
420
+ composing(jid, ts) {
421
+ return this.sock.sendPresenceUpdate('composing', jid);
422
+ }
419
423
 
420
424
  }
421
425
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@areumtecnologia/baileys",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "More baileys fork",
5
5
  "license": "ISC",
6
6
  "author": "Áreum Tecnologia",
@@ -31,7 +31,7 @@ class MessageNormalizer {
31
31
  const type = this._getFriendlyType(rawMessage.message);
32
32
  const messageContent = rawMessage.message[originalType];
33
33
  const contextInfo = messageContent?.contextInfo;
34
- const chatId = rawMessage.key.remoteJid.includes('@lid') ? rawMessage.key.remoteJidAlt : rawMessage.key.remoteJid;
34
+ const chatId = rawMessage.key.remoteJid.includes('@lid') ? rawMessage.key.remoteJidAlt?.replace(/:.*?@/, "@") : rawMessage.key.remoteJid;
35
35
  const isGroup = chatId.endsWith('@g.us');
36
36
  const clientJid = client.jidNormalizedUser(client.sock.user.id);
37
37
  const from = isGroup ? rawMessage.key.participant : rawMessage.key.fromMe ? clientJid : chatId;