@areumtecnologia/baileys 1.0.3 → 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;
@@ -216,29 +220,12 @@ class MessageHandler {
216
220
  // MÉTODOS INTERATIVOS E OUTROS
217
221
  // =================================================================================================
218
222
  /** Envia acoes */
219
- async sendTyping(jid) {
220
- try {
221
- this.client._validateConnection();
222
- const verifiedJid = await this.client.users.isOnWhatsApp(jid);
223
- if (verifiedJid && verifiedJid.exists) {
224
-
225
- await this.client.sock.presenceSubscribe(jid)
226
- await this.client.sock.sendPresenceUpdate('available', jid)
227
- await Utils.delay(500);
228
-
229
- await this.client.sock.sendPresenceUpdate('composing', jid)
230
- await Utils.delay(5000)
231
223
 
232
- return await this.client.sock.sendPresenceUpdate('paused', jid)
233
- }
234
- else {
235
- return verifiedJid;
236
- }
237
-
238
- } catch (error) {
239
- throw error;
240
- }
224
+ // Metodo para enviar notificacao "digitando"
225
+ composing(jid, ts) {
226
+ return this.client.sock.sendPresenceUpdate('composing', jid);
241
227
  }
228
+
242
229
  /** Marca mensagens como lidas. */
243
230
  async read(messageKey) {
244
231
  this.client._validateConnection();
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.3",
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;