@areumtecnologia/baileys 1.1.0 → 1.1.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/handlers/groups.js +5 -0
- package/index.js +11 -2
- package/package.json +2 -2
- package/utils/message-normalizer.js +7 -2
package/handlers/groups.js
CHANGED
|
@@ -53,6 +53,11 @@ class GroupHandler {
|
|
|
53
53
|
this.client._validateConnection();
|
|
54
54
|
return this.client.sock.groupMetadata(groupId);
|
|
55
55
|
}
|
|
56
|
+
/** Obtém a URL da foto de perfil de um grupo. */
|
|
57
|
+
async getProfilePicture(jid) {
|
|
58
|
+
this.client._validateConnection();
|
|
59
|
+
return this.client.sock.profilePictureUrl(jid, 'image');
|
|
60
|
+
}
|
|
56
61
|
|
|
57
62
|
/** Cria um novo grupo a partir de uma lista de jids. */
|
|
58
63
|
async create(subject, participantsJids) {
|
package/index.js
CHANGED
|
@@ -168,7 +168,16 @@ class Client extends EventEmitter {
|
|
|
168
168
|
break;
|
|
169
169
|
|
|
170
170
|
case 'open':
|
|
171
|
-
|
|
171
|
+
const wid = this.sock.user.id.replace(/:.*?@/, "@");
|
|
172
|
+
const statusMessage = await this.sock.fetchStatus(wid);
|
|
173
|
+
this.user = {
|
|
174
|
+
id: wid,
|
|
175
|
+
lid: this.sock.user.lid.replace(/:.*?@/, "@"),
|
|
176
|
+
name: this.sock.user.name,
|
|
177
|
+
slogan: statusMessage[0]?.status || null,
|
|
178
|
+
picture: await this.sock.profilePictureUrl(wid),
|
|
179
|
+
business: await this.sock.getBusinessProfile(wid),
|
|
180
|
+
};
|
|
172
181
|
this.qrCode = null; // Limpa o QR code após a conexão
|
|
173
182
|
this.connected = true;
|
|
174
183
|
this.manualDisconnect = false;
|
|
@@ -327,7 +336,7 @@ class Client extends EventEmitter {
|
|
|
327
336
|
}
|
|
328
337
|
}
|
|
329
338
|
} catch (error) {
|
|
330
|
-
this.emit(ClientEvent.ERROR, error);
|
|
339
|
+
this.emit(ClientEvent.ERROR, { error, event });
|
|
331
340
|
}
|
|
332
341
|
|
|
333
342
|
});
|
package/package.json
CHANGED
|
@@ -36,7 +36,7 @@ class MessageNormalizer {
|
|
|
36
36
|
const fromMe = rawMessage.key.fromMe;
|
|
37
37
|
const chatLid = [rawMessage.key.remoteJid, rawMessage.key.remoteJidAlt].find(jid => jid && jid.includes('@lid'))?.replace(/:.*?@/, "@");
|
|
38
38
|
const chatId = [rawMessage.key.remoteJid, rawMessage.key.remoteJidAlt].find(jid => jid && !jid.includes('@lid'))?.replace(/:.*?@/, "@");
|
|
39
|
-
const isGroup = chatId
|
|
39
|
+
const isGroup = chatId?.endsWith('@g.us');
|
|
40
40
|
const groupMetadata = isGroup ? await client.groups.getMetadata(chatId) : null;
|
|
41
41
|
const groupParticipants = groupMetadata?.participants;
|
|
42
42
|
const from = fromMe ? clientJid : chatId;
|
|
@@ -209,11 +209,16 @@ class MessageNormalizer {
|
|
|
209
209
|
pollUpdate.pollCreationMessageKey.remoteJid,
|
|
210
210
|
pollUpdate.pollCreationMessageKey.id
|
|
211
211
|
);
|
|
212
|
+
|
|
213
|
+
if (!creationMsg) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
|
|
212
217
|
creationMsg.raw.message.pollCreationMessage = creationMsg.raw.message.pollCreationMessage ? creationMsg.raw.message.pollCreationMessage :
|
|
213
218
|
creationMsg.raw.message.pollCreationMessageV3;
|
|
214
219
|
|
|
215
220
|
// Verifica se a mensagem de criação existe e tem a estrutura correta
|
|
216
|
-
if (!creationMsg) {
|
|
221
|
+
if (!creationMsg.raw.message.pollCreationMessage) {
|
|
217
222
|
console.warn("Mensagem de criação da enquete não encontrada na store ou sem estrutura válida");
|
|
218
223
|
return {
|
|
219
224
|
pollCreationMessageId: pollUpdate.pollCreationMessageKey?.id,
|