@systemzero/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.
@@ -11,8 +11,8 @@ import { USyncQuery, USyncUser } from '../WAUSync/index.js';
11
11
  import { makeNewsletterSocket } from './newsletter.js';
12
12
  import Hzxx from './hzxx.js';
13
13
  import { randomBytes } from 'crypto';
14
- import normalizeSystem from './normalize.js';
15
14
  import axios from 'axios';
15
+
16
16
  const META_AI_BOT_JID = '867051314767696@bot';
17
17
  const META_AI_BOT_NAME = 'Meta AI';
18
18
  const META_AI_CREATOR_NAME = 'Meta';
@@ -27,6 +27,18 @@ const CODE_TOKEN_REGEX = /\b(?:async|await|break|case|catch|class|const|continue
27
27
  function _randomId(prefix = 'systemzr') {
28
28
  return `${prefix}-${Date.now()}-${randomBytes(6).toString('hex')}`; }
29
29
 
30
+ if (typeof global.matchAll === 'undefined') {
31
+ String.prototype.matchAll = function(regex) {
32
+ const globalRegex = new RegExp(regex, regex.global ? undefined : 'g');
33
+ const matches = [];
34
+ let match;
35
+ while ((match = globalRegex.exec(this)) !== null) {
36
+ matches.push(match);
37
+ }
38
+ return matches;
39
+ };
40
+ }
41
+
30
42
  function _getHighlightType(token) {
31
43
  if (/^["'`]/.test(token)) return STRING_HIGHLIGHT;
32
44
  if (/^\d/.test(token)) return NUMBER_HIGHLIGHT;
@@ -174,10 +186,10 @@ const getButtonArgs = (message) => {
174
186
  'call_permission_request', 'wa_payment_transaction_details',
175
187
  'automated_greeting_message_view_catalog'
176
188
  ];
177
- if (nativeFlow && (firstButtonName === 'review_and_pay' || firstButtonName === 'payment_info' || firstButtonName === 'galaxy_message')) {
189
+ if (nativeFlow && (firstButtonName === 'review_and_pay' || firstButtonName === 'payment_info')) {
178
190
  return {
179
191
  tag: 'biz',
180
- attrs: { native_flow_name: firstButtonName === 'review_and_pay' ? 'order_details' : (firstButtonName === 'galaxy_message' ? 'galaxy_message' : firstButtonName) }
192
+ attrs: { native_flow_name: firstButtonName === 'review_and_pay' ? 'order_details' : firstButtonName }
181
193
  };
182
194
  } else if (stickerPack) {
183
195
  return {
@@ -224,7 +236,6 @@ const getButtonType = (message) => {
224
236
  else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'review_and_pay') return 'review_and_pay';
225
237
  else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'review_order') return 'review_order';
226
238
  else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_info') return 'payment_info';
227
- else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'galaxy_message') return 'galaxy_message';
228
239
  else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_status') return 'payment_status';
229
240
  else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_method') return 'payment_method';
230
241
  else if (message.interactiveMessage && message.interactiveMessage?.nativeFlowMessage) return 'interactive';
@@ -236,7 +247,7 @@ export const makeMessagesSocket = (config) => {
236
247
  const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: httpRequestOptions, patchMessageBeforeSending, cachedGroupMetadata, enableRecentMessageCache, maxMsgRetryCount } = config;
237
248
  const sock = makeNewsletterSocket(config);
238
249
  const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, sendNode, groupMetadata, groupToggleEphemeral } = sock;
239
- normalizeSystem.bindSocket(sock, config.store);
250
+
240
251
  const userDevicesCache = config.userDevicesCache ||
241
252
  new NodeCache({
242
253
  stdTTL: DEFAULT_CACHE_TTLS.USER_DEVICES,
@@ -794,7 +805,189 @@ export const makeMessagesSocket = (config) => {
794
805
  const waUploadToServer = getWAUploadToServer(config, refreshMediaConn);
795
806
  const waitForMsgMediaUpdate = bindWaitForEvent(ev, 'messages.media-update');
796
807
  const hzxx = new Hzxx(Utils, waUploadToServer, relayMessage);
797
-
808
+
809
+ const sendMessage = async (jid, content, options = {}) => {
810
+ const userJid = authState.creds.me.id;
811
+ if (typeof hzxx.buildMessageContent === 'function') {
812
+ content = await hzxx.buildMessageContent(content);
813
+ }
814
+ const { filter = false, quoted } = options;
815
+ const getParticipantAttr = () => filter ? { participant: { jid } } : {};
816
+ if (content && content.interactiveButtons) {
817
+ const formattedButtons = content.interactiveButtons.map(btn => {
818
+ if (btn.name === 'payment_info' || btn.name === 'review_and_pay') {
819
+ try {
820
+ const params = JSON.parse(btn.buttonParamsJson);
821
+ if (btn.name !== 'galaxy_message') {
822
+ params.currency = params.currency || 'BRL';
823
+ params.total_amount = params.total_amount || { value: 0, offset: 100 };
824
+ params.reference_id = params.reference_id || randomBytes(4).toString('hex').toUpperCase();
825
+ params.type = params.type || 'physical-goods';
826
+ if (!params.order) {
827
+ params.order = {
828
+ status: 'pending',
829
+ subtotal: params.total_amount,
830
+ order_type: 'ORDER',
831
+ items: [{
832
+ name: 'Fatura via Pix',
833
+ amount: params.total_amount,
834
+ quantity: 1,
835
+ sale_amount: params.total_amount
836
+ }]
837
+ };
838
+ }
839
+ }
840
+ btn.buttonParamsJson = JSON.stringify(params);
841
+ } catch (e) {
842
+ logger.error({ err: e }, "Erro ao processar JSON de Botao Nativo");
843
+ }
844
+ }
845
+ return btn;
846
+ });
847
+
848
+ const rawMessage = {
849
+ messageContextInfo: { messageSecret: randomBytes(32) },
850
+ interactiveMessage: {
851
+ nativeFlowMessage: { buttons: formattedButtons },
852
+ contextInfo: options.quoted ? {
853
+ stanzaId: options.quoted.key.id,
854
+ participant: options.quoted.sender || options.quoted.key?.participant,
855
+ quotedMessage: options.quoted.message
856
+ } : {}
857
+ }
858
+ };
859
+
860
+ if (content.text) {
861
+ rawMessage.interactiveMessage.body = { text: content.text };
862
+ }
863
+
864
+ const msgId = generateMessageIDV2(sock.user?.id);
865
+ return await relayMessage(jid, rawMessage, { messageId: msgId, ...getParticipantAttr() });
866
+ }
867
+
868
+ const messageType = hzxx.detectType(content);
869
+
870
+ if (messageType) {
871
+ switch(messageType) {
872
+ case 'PAYMENT':
873
+ const paymentContent = await hzxx.handlePayment(content, quoted);
874
+ return await relayMessage(jid, paymentContent, { messageId: generateMessageIDV2(), ...getParticipantAttr() });
875
+ case 'PRODUCT':
876
+ const productContent = await hzxx.handleProduct(content, jid, quoted);
877
+ const productMsg = generateWAMessageFromContent(jid, productContent, { ...options, quoted });
878
+ return await relayMessage(jid, productMsg.message, { messageId: productMsg.key.id, ...getParticipantAttr() });
879
+ case 'INTERACTIVE':
880
+ const interactiveContent = await hzxx.handleInteractive(content, jid, quoted);
881
+ const interactiveMsg = generateWAMessageFromContent(jid, interactiveContent, { ...options, quoted });
882
+
883
+ if (!interactiveMsg.message.messageContextInfo) {
884
+ interactiveMsg.message.messageContextInfo = {};
885
+ }
886
+ interactiveMsg.message.messageContextInfo.deviceListMetadata = {};
887
+ interactiveMsg.message.messageContextInfo.deviceListMetadataVersion = 2;
888
+
889
+ return await relayMessage(jid, interactiveMsg.message, { messageId: interactiveMsg.key.id, ...getParticipantAttr() });
890
+ case 'ALBUM':
891
+ return await hzxx.handleAlbum(content, jid, quoted);
892
+ case 'EVENT':
893
+ return await hzxx.handleEvent(content, jid, quoted);
894
+ case 'POLL_RESULT':
895
+ return await hzxx.handlePollResult(content, jid, quoted);
896
+ case 'GROUP_STORY':
897
+ return await hzxx.handleGroupStory(content, jid, quoted);
898
+ }
899
+ }
900
+ if (typeof content === 'object' &&
901
+ 'disappearingMessagesInChat' in content &&
902
+ typeof content['disappearingMessagesInChat'] !== 'undefined' &&
903
+ isJidGroup(jid)) {
904
+ const { disappearingMessagesInChat } = content;
905
+ const value = typeof disappearingMessagesInChat === 'boolean'
906
+ ? disappearingMessagesInChat
907
+ ? WA_DEFAULT_EPHEMERAL
908
+ : 0
909
+ : disappearingMessagesInChat;
910
+ await groupToggleEphemeral(jid, value);
911
+ }
912
+ else {
913
+ const fullMsg = await generateWAMessage(jid, content, {
914
+ logger,
915
+ userJid,
916
+ getUrlInfo: text => getUrlInfo(text, {
917
+ thumbnailWidth: linkPreviewImageThumbnailWidth,
918
+ fetchOpts: {
919
+ timeout: 3000,
920
+ ...(httpRequestOptions || {})
921
+ },
922
+ logger,
923
+ uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
924
+ }),
925
+ getProfilePicUrl: sock.profilePictureUrl,
926
+ getCallLink: sock.createCallLink,
927
+ upload: waUploadToServer,
928
+ mediaCache: config.mediaCache,
929
+ options: config.options,
930
+ messageId: generateMessageIDV2(sock.user?.id),
931
+ ...options
932
+ });
933
+ const isEventMsg = 'event' in content && !!content.event;
934
+ const isDeleteMsg = 'delete' in content && !!content.delete;
935
+ const isEditMsg = 'edit' in content && !!content.edit;
936
+ const isPinMsg = 'pin' in content && !!content.pin;
937
+ const isPollMessage = 'poll' in content && !!content.poll;
938
+
939
+ const isAiMsg = 'ai' in content && !!content.ai;
940
+
941
+ const additionalAttributes = {};
942
+ const additionalNodes = [];
943
+ if (isDeleteMsg) {
944
+ if (isJidGroup(content.delete?.remoteJid) && !content.delete?.fromMe) {
945
+ additionalAttributes.edit = '8';
946
+ } else {
947
+ additionalAttributes.edit = '7';
948
+ }
949
+ } else if (isEditMsg) {
950
+ additionalAttributes.edit = '1';
951
+ } else if (isPinMsg) {
952
+ additionalAttributes.edit = '2';
953
+ } else if (isPollMessage) {
954
+ additionalNodes.push({ tag: 'meta', attrs: { polltype: 'creation' } });
955
+ } else if (isEventMsg) {
956
+ additionalNodes.push({ tag: 'meta', attrs: { event_type: 'creation' } });
957
+ }
958
+
959
+ if (isAiMsg) {
960
+ additionalNodes.push({ tag: 'bot', attrs: { biz_bot: '1' } });
961
+ }
962
+
963
+ await relayMessage(jid, fullMsg.message, {
964
+ messageId: fullMsg.key.id,
965
+ useCachedGroupMetadata: options.useCachedGroupMetadata,
966
+ additionalAttributes,
967
+ statusJidList: options.statusJidList,
968
+ additionalNodes
969
+ });
970
+ if (config.emitOwnEvents) {
971
+ process.nextTick(async () => {
972
+ await processingMutex.mutex(() => upsertMessage(fullMsg, 'append'));
973
+ });
974
+ }
975
+ return fullMsg;
976
+ }
977
+ };
978
+
979
+ const sendPerplexity = async (jid, prompt, options = {}) => {
980
+ try {
981
+ const response = await axios.post('https://systemzone.store/api/post-perplexity', { q: prompt }, { timeout: 30000 });
982
+ if (!response.data || !response.data.status) {
983
+ throw new Error('retorno de dados invalidos.');
984
+ }
985
+ return await sendMessage(jid, { text: response.data.result || 'Sem resposta.' }, options);
986
+ } catch (e) {
987
+ return await sendMessage(jid, { text: `❌ Erro IA: ${e.message || e}` }, options);
988
+ }
989
+ };
990
+
798
991
  const sendRichReels = async (jid, title, headerText, query, reels, options = {}) => {
799
992
  const unified = {
800
993
  response_id: `reels-${Date.now()}`,
@@ -875,68 +1068,6 @@ export const makeMessagesSocket = (config) => {
875
1068
  return await relayMessage(jid, rawMessage, { messageId: msgId });
876
1069
  };
877
1070
 
878
- const sendMessageWrapper = async (jid, content, options = {}) => {
879
- return await sock.sendMessage(jid, content, options);
880
- };
881
-
882
- const sendPerplexity = async (jid, prompt, options = {}) => {
883
- try {
884
- const response = await axios.post('https://systemzone.store/api/post-perplexity', { q: prompt }, { timeout: 30000 });
885
- if (!response.data || !response.data.status) {
886
- throw new Error('retorno de dados invalidos.');
887
- }
888
- return await sendMessageWrapper(jid, { text: response.data.result || 'Sem resposta.' }, options);
889
- } catch (e) {
890
- return await sendMessageWrapper(jid, { text: `Erro IA: ${e.message || e}` }, options);
891
- }
892
- };
893
-
894
- const sendFormulario = async (jid, textBody, flowId, screenName, dataParams = {}, buttonCta = '__localize:FLOWS_SIGN_UP_BUTTON_TITLE', flowToken = 'T0ZGRVJfU0lHTlVQ', options = {}) => {
895
- const rawMessage = {
896
- messageContextInfo: {
897
- deviceListMetadata: {},
898
- deviceListMetadataVersion: 2,
899
- messageSecret: randomBytes(32)
900
- },
901
- interactiveMessage: {
902
- body: { text: textBody },
903
- nativeFlowMessage: {
904
- buttons: [{
905
- name: 'galaxy_message',
906
- buttonParamsJson: JSON.stringify({
907
- flow_message_version: '4',
908
- flow_id: String(flowId),
909
- flow_action_payload: {
910
- screen: screenName,
911
- data: dataParams
912
- },
913
- well_version: 'V700',
914
- flow_cta: buttonCta,
915
- flow_action: 'navigate',
916
- flow_token: flowToken
917
- })
918
- }],
919
- messageParamsJson: '{}'
920
- }
921
- }
922
- };
923
-
924
- const finalMessage = { viewOnceMessage: { message: rawMessage } };
925
- const msgId = generateMessageIDV2(sock.user?.id);
926
-
927
- const participantAttr = options.quoted ? {
928
- stanzaId: options.quoted.key.id,
929
- participant: options.quoted.sender || options.quoted.key?.participant,
930
- quotedMessage: options.quoted.message
931
- } : undefined;
932
-
933
- if (participantAttr) {
934
- finalMessage.viewOnceMessage.message.interactiveMessage.contextInfo = participantAttr;
935
- }
936
-
937
- return await relayMessage(jid, finalMessage, { messageId: msgId });
938
- };
939
-
940
1071
  return {
941
1072
  ...sock,
942
1073
  getPrivacyTokens,
@@ -960,8 +1091,6 @@ export const makeMessagesSocket = (config) => {
960
1091
  makeTable,
961
1092
  sendRichReels,
962
1093
  sendPerplexity,
963
- sendFormulario,
964
- normalizeSystem,
965
1094
  sendRichText: async (remoteJid, text, quoted = null) => sendRich(remoteJid, [makeText(text)], quoted),
966
1095
  sendRichCode: async (remoteJid, title, language, code, quoted = null) => {
967
1096
  const parts = [];
@@ -1017,6 +1146,7 @@ export const makeMessagesSocket = (config) => {
1017
1146
  }
1018
1147
  content.directPath = media.directPath;
1019
1148
  content.url = getUrlFromDirectPath(content.directPath);
1149
+ logger.debug({ directPath: media.directPath, key: result.key }, 'media update successful');
1020
1150
  } catch (err) {
1021
1151
  error = err;
1022
1152
  }
@@ -1029,202 +1159,34 @@ export const makeMessagesSocket = (config) => {
1029
1159
  ev.emit('messages.update', [{ key: message.key, update: { message: message.message } }]);
1030
1160
  return message;
1031
1161
  },
1032
-
1033
- sendMessage: async (jid, content, options = {}) => {
1034
- const cleanTarget = normalizeSystem.cleanId(jid);
1035
- const mappedLid = normalizeSystem.jidLidMemoryCache.get(cleanTarget);
1036
- if (mappedLid) {
1037
- const signalId = signalRepository.jidToSignalProtocolAddress(mappedLid);
1038
- const hasLidSession = peerSessionsCache.get(signalId) || (await signalRepository.validateSession(mappedLid)).exists;
1039
- if (cleanTarget.includes('@s.whatsapp.net') && hasLidSession) {
1040
- jid = mappedLid;
1041
- } else if (cleanTarget.includes('@lid') && !hasLidSession) {
1042
- const mappedPn = normalizeSystem.jidLidMemoryCache.get(cleanTarget);
1043
- if (mappedPn) jid = mappedPn;
1044
- }
1045
- }
1046
-
1047
- const userJid = authState.creds.me.id;
1048
- const { filter = false, quoted } = options;
1049
- const getParticipantAttr = () => filter ? { participant: { jid } } : {};
1050
- if (content && content.interactiveButtons) {
1051
- const formattedButtons = content.interactiveButtons.map(btn => {
1052
- if (btn.name === 'payment_info' || btn.name === 'review_and_pay' || btn.name === 'galaxy_message') {
1053
- try {
1054
- const params = JSON.parse(btn.buttonParamsJson);
1055
-
1056
- if (btn.name !== 'galaxy_message') {
1057
- params.currency = params.currency || 'BRL';
1058
- params.total_amount = params.total_amount || { value: 0, offset: 100 };
1059
- params.reference_id = params.reference_id || randomBytes(4).toString('hex').toUpperCase();
1060
- params.type = params.type || 'physical-goods';
1061
- if (!params.order) {
1062
- params.order = {
1063
- status: 'pending',
1064
- subtotal: params.total_amount,
1065
- order_type: 'ORDER',
1066
- items: [{
1067
- name: 'Fatura via Pix',
1068
- amount: params.total_amount,
1069
- quantity: 1,
1070
- sale_amount: params.total_amount
1071
- }]
1072
- };
1073
- }
1074
- }
1075
-
1076
- btn.buttonParamsJson = JSON.stringify(params);
1077
- } catch (e) {
1078
- logger.error({ err: e }, "Erro ao processar JSON de Pagamento");
1079
- }
1080
- }
1081
- return btn;
1162
+ sendMessage,
1163
+ sendVitrine: async function(jid, title, description, productId, imageBuffer, options = {}) {
1164
+ try {
1165
+ const tempMsg = await generateWAMessage(jid, { image: imageBuffer }, {
1166
+ userJid: authState.creds.me.id,
1167
+ upload: waUploadToServer,
1168
+ logger
1082
1169
  });
1083
-
1084
- const rawMessage = {
1085
- messageContextInfo: {
1086
- deviceListMetadata: {},
1087
- deviceListMetadataVersion: 2,
1088
- messageSecret: randomBytes(32)
1089
- },
1090
- interactiveMessage: {
1091
- nativeFlowMessage: {
1092
- buttons: formattedButtons,
1093
- messageParamsJson: '{}'
1094
- },
1095
- contextInfo: options.quoted ? {
1096
- stanzaId: options.quoted.key.id,
1097
- participant: options.quoted.sender || options.quoted.key?.participant,
1098
- quotedMessage: options.quoted.message
1099
- } : {}
1100
- }
1101
- };
1102
-
1103
- if (content.text) {
1104
- rawMessage.interactiveMessage.body = { text: content.text };
1105
- }
1106
-
1107
- const finalMessage = {
1108
- viewOnceMessage: {
1109
- message: rawMessage
1110
- }
1111
- };
1112
-
1113
- const msgId = generateMessageIDV2(sock.user?.id);
1114
- return await relayMessage(jid, finalMessage, { messageId: msgId, ...getParticipantAttr() });
1115
- }
1116
1170
 
1117
- if (typeof hzxx.buildMessageContent === 'function') {
1118
- content = await hzxx.buildMessageContent(content);
1119
- }
1120
- const messageType = hzxx.detectType(content);
1121
-
1122
- if (messageType) {
1123
- switch(messageType) {
1124
- case 'PAYMENT':
1125
- const paymentContent = await hzxx.handlePayment(content, quoted);
1126
- return await relayMessage(jid, paymentContent, { messageId: generateMessageIDV2(), ...getParticipantAttr() });
1127
- case 'PRODUCT':
1128
- const productContent = await hzxx.handleProduct(content, jid, quoted);
1129
- const productMsg = generateWAMessageFromContent(jid, productContent, { ...options, quoted });
1130
- return await relayMessage(jid, productMsg.message, { messageId: productMsg.key.id, ...getParticipantAttr() });
1131
- case 'INTERACTIVE':
1132
- const interactiveContent = await hzxx.handleInteractive(content, jid, quoted);
1133
- const interactiveMsg = generateWAMessageFromContent(jid, interactiveContent, { ...options, quoted });
1134
-
1135
- if (!interactiveMsg.message.messageContextInfo) {
1136
- interactiveMsg.message.messageContextInfo = {};
1137
- }
1138
- interactiveMsg.message.messageContextInfo.deviceListMetadata = {};
1139
- interactiveMsg.message.messageContextInfo.deviceListMetadataVersion = 2;
1171
+ const productImage = tempMsg.message.imageMessage;
1140
1172
 
1141
- return await relayMessage(jid, interactiveMsg.message, { messageId: interactiveMsg.key.id, ...getParticipantAttr() });
1142
- case 'ALBUM':
1143
- return await hzxx.handleAlbum(content, jid, quoted);
1144
- case 'EVENT':
1145
- return await hzxx.handleEvent(content, jid, quoted);
1146
- case 'POLL_RESULT':
1147
- return await hzxx.handlePollResult(content, jid, quoted);
1148
- case 'GROUP_STORY':
1149
- return await hzxx.handleGroupStory(content, jid, quoted);
1150
- }
1151
- }
1152
- if (typeof content === 'object' &&
1153
- 'disappearingMessagesInChat' in content &&
1154
- typeof content['disappearingMessagesInChat'] !== 'undefined' &&
1155
- isJidGroup(jid)) {
1156
- const { disappearingMessagesInChat } = content;
1157
- const value = typeof disappearingMessagesInChat === 'boolean'
1158
- ? disappearingMessagesInChat
1159
- ? WA_DEFAULT_EPHEMERAL
1160
- : 0
1161
- : disappearingMessagesInChat;
1162
- await groupToggleEphemeral(jid, value);
1163
- }
1164
- else {
1165
- const fullMsg = await generateWAMessage(jid, content, {
1166
- logger,
1167
- userJid,
1168
- getUrlInfo: text => getUrlInfo(text, {
1169
- thumbnailWidth: linkPreviewImageThumbnailWidth,
1170
- fetchOpts: {
1171
- timeout: 3000,
1172
- ...(httpRequestOptions || {})
1173
+ const productMsg = generateWAMessageFromContent(jid, {
1174
+ productMessage: {
1175
+ product: {
1176
+ productImage: productImage,
1177
+ productId: String(productId),
1178
+ title: title,
1179
+ description: description,
1180
+ productImageCount: 1
1173
1181
  },
1174
- logger,
1175
- uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
1176
- }),
1177
- getProfilePicUrl: sock.profilePictureUrl,
1178
- getCallLink: sock.createCallLink,
1179
- upload: waUploadToServer,
1180
- mediaCache: config.mediaCache,
1181
- options: config.options,
1182
- messageId: generateMessageIDV2(sock.user?.id),
1183
- ...options
1184
- });
1185
- const isEventMsg = 'event' in content && !!content.event;
1186
- const isDeleteMsg = 'delete' in content && !!content.delete;
1187
- const isEditMsg = 'edit' in content && !!content.edit;
1188
- const isPinMsg = 'pin' in content && !!content.pin;
1189
- const isPollMessage = 'poll' in content && !!content.poll;
1190
-
1191
- const isAiMsg = 'ai' in content && !!content.ai;
1192
-
1193
- const additionalAttributes = {};
1194
- const additionalNodes = [];
1195
- if (isDeleteMsg) {
1196
- if (isJidGroup(content.delete?.remoteJid) && !content.delete?.fromMe) {
1197
- additionalAttributes.edit = '8';
1198
- } else {
1199
- additionalAttributes.edit = '7';
1182
+ businessOwnerJid: authState.creds.me.id.split(':')[0] + '@s.whatsapp.net'
1200
1183
  }
1201
- } else if (isEditMsg) {
1202
- additionalAttributes.edit = '1';
1203
- } else if (isPinMsg) {
1204
- additionalAttributes.edit = '2';
1205
- } else if (isPollMessage) {
1206
- additionalNodes.push({ tag: 'meta', attrs: { polltype: 'creation' } });
1207
- } else if (isEventMsg) {
1208
- additionalNodes.push({ tag: 'meta', attrs: { event_type: 'creation' } });
1209
- }
1184
+ }, { userJid: authState.creds.me.id, quoted: options.quoted });
1210
1185
 
1211
- if (isAiMsg) {
1212
- additionalNodes.push({ tag: 'bot', attrs: { biz_bot: '1' } });
1213
- }
1214
-
1215
- await relayMessage(jid, fullMsg.message, {
1216
- messageId: fullMsg.key.id,
1217
- useCachedGroupMetadata: options.useCachedGroupMetadata,
1218
- additionalAttributes,
1219
- statusJidList: options.statusJidList,
1220
- additionalNodes
1221
- });
1222
- if (config.emitOwnEvents) {
1223
- process.nextTick(async () => {
1224
- await processingMutex.mutex(() => upsertMessage(fullMsg, 'append'));
1225
- });
1226
- }
1227
- return fullMsg;
1186
+ return await relayMessage(jid, productMsg.message, { messageId: productMsg.key.id });
1187
+ } catch (e) {
1188
+ logger.error({ err: e }, "Erro ao enviar vitrine");
1189
+ throw e;
1228
1190
  }
1229
1191
  }
1230
1192
  };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@systemzero/baileys",
3
3
  "type": "module",
4
- "version": "1.0.2",
5
- "description": "System-zero baileys bot",
4
+ "version": "1.0.4",
5
+ "description": "System-zero baileys bot ultra",
6
6
  "keywords": [
7
7
  "whatsapp",
8
8
  "automation",