@vinzsocket/baileys 3.2.14 → 3.3.1

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.
Files changed (227) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1337 -2685
  3. package/WAProto/WAProto.proto +916 -360
  4. package/WAProto/fix-imports.js +18 -22
  5. package/WAProto/index.d.ts +0 -14015
  6. package/WAProto/index.js +80576 -45941
  7. package/lib/Defaults/index.d.ts +14 -15
  8. package/lib/Defaults/index.d.ts.map +1 -1
  9. package/lib/Defaults/index.js +110 -99
  10. package/lib/Defaults/index.js.map +1 -1
  11. package/lib/Modded/message_builder.js +2330 -0
  12. package/lib/Signal/Group/group_cipher.js.map +1 -1
  13. package/lib/Signal/Group/keyhelper.d.ts.map +1 -1
  14. package/lib/Signal/Group/keyhelper.js.map +1 -1
  15. package/lib/Signal/Group/sender-chain-key.js.map +1 -1
  16. package/lib/Signal/Group/sender-key-message.js.map +1 -1
  17. package/lib/Signal/Group/sender-message-key.js.map +1 -1
  18. package/lib/Signal/libsignal.d.ts.map +1 -1
  19. package/lib/Signal/libsignal.js +17 -45
  20. package/lib/Signal/libsignal.js.map +1 -1
  21. package/lib/Signal/lid-mapping.d.ts +0 -4
  22. package/lib/Signal/lid-mapping.d.ts.map +1 -1
  23. package/lib/Signal/lid-mapping.js +0 -6
  24. package/lib/Signal/lid-mapping.js.map +1 -1
  25. package/lib/Socket/business.d.ts +532 -213
  26. package/lib/Socket/business.d.ts.map +1 -1
  27. package/lib/Socket/business.js +401 -358
  28. package/lib/Socket/chats.d.ts +2 -15
  29. package/lib/Socket/chats.d.ts.map +1 -1
  30. package/lib/Socket/chats.js +39 -241
  31. package/lib/Socket/chats.js.map +1 -1
  32. package/lib/Socket/communities.d.ts +641 -269
  33. package/lib/Socket/communities.d.ts.map +1 -1
  34. package/lib/Socket/dugong.d.ts +127 -315
  35. package/lib/Socket/dugong.d.ts.map +1 -0
  36. package/lib/Socket/dugong.js +749 -610
  37. package/lib/Socket/dugong.js.map +1 -0
  38. package/lib/Socket/groups.d.ts +2 -13
  39. package/lib/Socket/groups.d.ts.map +1 -1
  40. package/lib/Socket/groups.js +1 -21
  41. package/lib/Socket/groups.js.map +1 -1
  42. package/lib/Socket/index.d.ts +631 -256
  43. package/lib/Socket/index.d.ts.map +1 -1
  44. package/lib/Socket/index.js +12 -9
  45. package/lib/Socket/index.js.map +1 -1
  46. package/lib/Socket/messages-recv.d.ts +58 -23
  47. package/lib/Socket/messages-recv.d.ts.map +1 -1
  48. package/lib/Socket/messages-recv.js +181 -645
  49. package/lib/Socket/messages-recv.js.map +1 -1
  50. package/lib/Socket/messages-send.d.ts +575 -201
  51. package/lib/Socket/messages-send.d.ts.map +1 -1
  52. package/lib/Socket/messages-send.js +1552 -1185
  53. package/lib/Socket/messages-send.js.map +1 -1
  54. package/lib/Socket/mex.d.ts.map +1 -1
  55. package/lib/Socket/mex.js +8 -2
  56. package/lib/Socket/mex.js.map +1 -1
  57. package/lib/Socket/newsletter.d.ts +18 -11
  58. package/lib/Socket/newsletter.d.ts.map +1 -1
  59. package/lib/Socket/newsletter.js +440 -165
  60. package/lib/Socket/newsletter.js.map +1 -1
  61. package/lib/Socket/socket.d.ts +2 -6
  62. package/lib/Socket/socket.d.ts.map +1 -1
  63. package/lib/Socket/socket.js +25 -56
  64. package/lib/Socket/socket.js.map +1 -1
  65. package/lib/Types/Auth.d.ts +0 -1
  66. package/lib/Types/Auth.d.ts.map +1 -1
  67. package/lib/Types/Bussines.d.ts +34 -22
  68. package/lib/Types/Call.d.ts +1 -1
  69. package/lib/Types/Call.d.ts.map +1 -1
  70. package/lib/Types/Chat.d.ts +0 -1
  71. package/lib/Types/Chat.d.ts.map +1 -1
  72. package/lib/Types/Contact.d.ts +0 -2
  73. package/lib/Types/Contact.d.ts.map +1 -1
  74. package/lib/Types/Events.d.ts +1 -20
  75. package/lib/Types/Events.d.ts.map +1 -1
  76. package/lib/Types/GroupMetadata.d.ts +1 -4
  77. package/lib/Types/GroupMetadata.d.ts.map +1 -1
  78. package/lib/Types/Message.d.ts +348 -294
  79. package/lib/Types/Message.d.ts.map +1 -1
  80. package/lib/Types/Message.js.map +1 -1
  81. package/lib/Types/{Mex.d.ts → Newsletter.d.ts} +5 -11
  82. package/lib/Types/Newsletter.d.ts.map +1 -0
  83. package/lib/Types/{Mex.js → Newsletter.js} +3 -9
  84. package/lib/Types/Newsletter.js.map +1 -0
  85. package/lib/Types/Signal.d.ts +1 -12
  86. package/lib/Types/Signal.d.ts.map +1 -1
  87. package/lib/Types/Socket.d.ts +148 -126
  88. package/lib/Types/Socket.d.ts.map +1 -1
  89. package/lib/Types/State.d.ts +0 -58
  90. package/lib/Types/State.d.ts.map +1 -1
  91. package/lib/Types/State.js +0 -43
  92. package/lib/Types/State.js.map +1 -1
  93. package/lib/Types/index.d.ts +52 -51
  94. package/lib/Types/index.d.ts.map +1 -1
  95. package/lib/Types/index.js +30 -23
  96. package/lib/Types/index.js.map +1 -1
  97. package/lib/Utils/auth-utils.d.ts +0 -5
  98. package/lib/Utils/auth-utils.d.ts.map +1 -1
  99. package/lib/Utils/auth-utils.js +0 -12
  100. package/lib/Utils/auth-utils.js.map +1 -1
  101. package/lib/Utils/chat-utils.d.ts +4 -34
  102. package/lib/Utils/chat-utils.d.ts.map +1 -1
  103. package/lib/Utils/chat-utils.js +20 -80
  104. package/lib/Utils/chat-utils.js.map +1 -1
  105. package/lib/Utils/crypto.d.ts +12 -12
  106. package/lib/Utils/crypto.d.ts.map +1 -1
  107. package/lib/Utils/crypto.js.map +1 -1
  108. package/lib/Utils/decode-wa-message.d.ts +0 -18
  109. package/lib/Utils/decode-wa-message.d.ts.map +1 -1
  110. package/lib/Utils/decode-wa-message.js +0 -34
  111. package/lib/Utils/decode-wa-message.js.map +1 -1
  112. package/lib/Utils/event-buffer.d.ts +0 -2
  113. package/lib/Utils/event-buffer.d.ts.map +1 -1
  114. package/lib/Utils/event-buffer.js +1 -49
  115. package/lib/Utils/event-buffer.js.map +1 -1
  116. package/lib/Utils/generics.d.ts +2 -2
  117. package/lib/Utils/generics.d.ts.map +1 -1
  118. package/lib/Utils/generics.js +0 -9
  119. package/lib/Utils/generics.js.map +1 -1
  120. package/lib/Utils/history.d.ts +0 -2
  121. package/lib/Utils/history.d.ts.map +1 -1
  122. package/lib/Utils/history.js +9 -12
  123. package/lib/Utils/history.js.map +1 -1
  124. package/lib/Utils/identity-change-handler.d.ts +0 -7
  125. package/lib/Utils/identity-change-handler.d.ts.map +1 -1
  126. package/lib/Utils/identity-change-handler.js +0 -1
  127. package/lib/Utils/identity-change-handler.js.map +1 -1
  128. package/lib/Utils/index.d.ts +23 -23
  129. package/lib/Utils/index.d.ts.map +1 -1
  130. package/lib/Utils/index.js +2 -3
  131. package/lib/Utils/index.js.map +1 -1
  132. package/lib/Utils/link-preview.js +2 -2
  133. package/lib/Utils/link-preview.js.map +1 -1
  134. package/lib/Utils/logger.d.ts +2 -1
  135. package/lib/Utils/logger.d.ts.map +1 -1
  136. package/lib/Utils/message-retry-manager.d.ts +0 -5
  137. package/lib/Utils/message-retry-manager.d.ts.map +1 -1
  138. package/lib/Utils/message-retry-manager.js +0 -40
  139. package/lib/Utils/message-retry-manager.js.map +1 -1
  140. package/lib/Utils/messages-media.d.ts +13 -16
  141. package/lib/Utils/messages-media.d.ts.map +1 -1
  142. package/lib/Utils/messages-media.js +79 -85
  143. package/lib/Utils/messages-media.js.map +1 -1
  144. package/lib/Utils/messages.d.ts +1 -16
  145. package/lib/Utils/messages.d.ts.map +1 -1
  146. package/lib/Utils/messages.js +1121 -1021
  147. package/lib/Utils/messages.js.map +1 -1
  148. package/lib/Utils/noise-handler.d.ts +1 -1
  149. package/lib/Utils/process-message.d.ts.map +1 -1
  150. package/lib/Utils/process-message.js +1 -103
  151. package/lib/Utils/process-message.js.map +1 -1
  152. package/lib/Utils/rich-messages.d.ts +277 -0
  153. package/lib/Utils/rich-messages.d.ts.map +1 -0
  154. package/lib/Utils/rich-messages.js +1144 -0
  155. package/lib/Utils/rich-messages.js.map +1 -0
  156. package/lib/Utils/signal.d.ts +0 -13
  157. package/lib/Utils/signal.d.ts.map +1 -1
  158. package/lib/Utils/signal.js +0 -42
  159. package/lib/Utils/signal.js.map +1 -1
  160. package/lib/Utils/sticker-pack.d.ts +10 -0
  161. package/lib/Utils/sticker-pack.js +111 -0
  162. package/lib/Utils/sync-action-utils.d.ts.map +1 -1
  163. package/lib/Utils/sync-action-utils.js +0 -1
  164. package/lib/Utils/sync-action-utils.js.map +1 -1
  165. package/lib/Utils/tc-token-utils.d.ts +1 -26
  166. package/lib/Utils/tc-token-utils.d.ts.map +1 -1
  167. package/lib/Utils/tc-token-utils.js +4 -149
  168. package/lib/Utils/tc-token-utils.js.map +1 -1
  169. package/lib/Utils/validate-connection.d.ts.map +1 -1
  170. package/lib/Utils/validate-connection.js +0 -3
  171. package/lib/Utils/validate-connection.js.map +1 -1
  172. package/lib/VoIP/audio-feeder.d.ts +15 -0
  173. package/lib/VoIP/audio-feeder.js +132 -0
  174. package/lib/VoIP/index.js +277 -0
  175. package/lib/VoIP/relay-transport.d.ts +43 -0
  176. package/lib/VoIP/relay-transport.js +559 -0
  177. package/lib/VoIP/signaling.js +594 -0
  178. package/lib/VoIP/types.d.ts +69 -0
  179. package/lib/VoIP/types.js +17 -0
  180. package/lib/VoIP/wasm-engine.d.ts +103 -0
  181. package/lib/VoIP/wasm-engine.js +1214 -0
  182. package/lib/VoIP/worker-bootstrap.js +1042 -0
  183. package/lib/WABinary/decode.d.ts +1 -1
  184. package/lib/WABinary/decode.d.ts.map +1 -1
  185. package/lib/WABinary/generic-utils.d.ts +3 -1
  186. package/lib/WABinary/generic-utils.d.ts.map +1 -1
  187. package/lib/WABinary/generic-utils.js +78 -0
  188. package/lib/WABinary/generic-utils.js.map +1 -1
  189. package/lib/WAM/encode.d.ts +1 -1
  190. package/lib/WAM/encode.d.ts.map +1 -1
  191. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -1
  192. package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -26
  193. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -1
  194. package/lib/WAUSync/Protocols/index.d.ts +0 -1
  195. package/lib/WAUSync/Protocols/index.d.ts.map +1 -1
  196. package/lib/WAUSync/Protocols/index.js +0 -1
  197. package/lib/WAUSync/Protocols/index.js.map +1 -1
  198. package/lib/WAUSync/USyncQuery.d.ts +0 -1
  199. package/lib/WAUSync/USyncQuery.d.ts.map +1 -1
  200. package/lib/WAUSync/USyncQuery.js +2 -6
  201. package/lib/WAUSync/USyncQuery.js.map +1 -1
  202. package/lib/WAUSync/USyncUser.d.ts +0 -4
  203. package/lib/WAUSync/USyncUser.d.ts.map +1 -1
  204. package/lib/WAUSync/USyncUser.js +0 -8
  205. package/lib/WAUSync/USyncUser.js.map +1 -1
  206. package/lib/assets/wasm/loader.js +5 -0
  207. package/lib/assets/wasm/whatsapp.wasm +0 -0
  208. package/lib/assets/wasm/worker-modules.js +273 -0
  209. package/lib/index.d.ts +1 -0
  210. package/lib/index.d.ts.map +1 -1
  211. package/lib/index.js +3 -0
  212. package/lib/index.js.map +1 -1
  213. package/package.json +29 -92
  214. package/engine-requirements.js +0 -27
  215. package/lib/Types/Mex.d.ts.map +0 -1
  216. package/lib/Types/Mex.js.map +0 -1
  217. package/lib/Utils/companion-reg-client-utils.d.ts +0 -17
  218. package/lib/Utils/companion-reg-client-utils.d.ts.map +0 -1
  219. package/lib/Utils/companion-reg-client-utils.js +0 -35
  220. package/lib/Utils/companion-reg-client-utils.js.map +0 -1
  221. package/lib/Utils/mention.d.ts +0 -14
  222. package/lib/Utils/mention.js +0 -138
  223. package/lib/Utils/story-card.js +0 -107
  224. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +0 -10
  225. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +0 -1
  226. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +0 -25
  227. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +0 -1
@@ -1,629 +1,768 @@
1
- // dugong.js — Harps-Baileys extended message builders v3.2.10
2
- // Handles: Payment, Product, Interactive (NF V7 full), Album, Event,
3
- // Poll Result, Group Status V2, Nested Legacy List, Multi-Select.
4
-
5
- import { randomBytes } from 'crypto';
6
- import { proto } from '../../WAProto/index.js';
7
- import { normalizeMentions } from '../Utils/mention.js';
8
- import { delay } from '../Utils/generics.js';
9
- import { isJidGroup, isPnUser, jidNormalizedUser, STORIES_JID } from '../WABinary/index.js';
10
-
11
- // ─── NF V7 Button Builders ────────────────────────────────────────────────────
12
-
13
- export const nfButtonUrl = ({ id, displayText, url, merchantUrl }) => ({
14
- name: 'cta_url',
15
- buttonParamsJson: JSON.stringify({ display_text: displayText, url, merchant_url: merchantUrl || url }),
16
- ...(id ? { id } : {})
17
- });
18
- export const nfButtonCall = ({ id, displayText, phoneNumber }) => ({
19
- name: 'cta_call',
20
- buttonParamsJson: JSON.stringify({ display_text: displayText, phone_number: phoneNumber }),
21
- ...(id ? { id } : {})
22
- });
23
- export const nfButtonCopy = ({ id, displayText, copyCode }) => ({
24
- name: 'cta_copy',
25
- buttonParamsJson: JSON.stringify({ display_text: displayText, copy_code: copyCode }),
26
- ...(id ? { id } : {})
27
- });
28
- export const nfButtonReminder = ({ id, displayText, title, notes, startTime, endTime, timezone = 'Asia/Jakarta' }) => ({
29
- name: 'cta_reminder',
30
- buttonParamsJson: JSON.stringify({ display_text: displayText, title, notes, start_timestamp: startTime, end_timestamp: endTime, timezone }),
31
- ...(id ? { id } : {})
32
- });
33
- export const nfButtonCancelReminder = ({ id, displayText, reminderKey }) => ({
34
- name: 'cta_cancel_reminder',
35
- buttonParamsJson: JSON.stringify({ display_text: displayText, reminder_key: reminderKey }),
36
- ...(id ? { id } : {})
37
- });
38
- export const nfButtonAddress = ({ id, displayText, label = '' }) => ({
39
- name: 'address_message',
40
- buttonParamsJson: JSON.stringify({ display_text: displayText, label }),
41
- ...(id ? { id } : {})
42
- });
43
- export const nfButtonLocation = ({ id, displayText }) => ({
44
- name: 'send_location',
45
- buttonParamsJson: JSON.stringify({ display_text: displayText }),
46
- ...(id ? { id } : {})
47
- });
48
- export const nfButtonQuickReply = ({ id, displayText, payload }) => ({
49
- name: 'quick_reply',
50
- buttonParamsJson: JSON.stringify({ display_text: displayText, id: id || payload || displayText }),
51
- ...(id ? { id } : {})
52
- });
53
-
54
- /**
55
- * Single-select dropdown.
56
- * sections: [{ title, highlight_label?, rows: [{id, title, description?}] }]
57
- */
58
- export const nfButtonSingleSelect = ({ id, displayText, sections = [] }) => ({
59
- name: 'single_select',
60
- buttonParamsJson: JSON.stringify({
61
- title: displayText,
62
- sections: sections.map(sec => ({
63
- title: sec.title || '',
64
- highlight_label: sec.highlight_label || '',
65
- rows: (sec.rows || []).map(r => ({
66
- id: r.id || r.rowId || '',
67
- title: r.title || '',
68
- ...(r.description ? { description: r.description } : {})
69
- }))
70
- }))
71
- }),
72
- ...(id ? { id } : {})
73
- });
74
-
75
- /**
76
- * Multi-select: beberapa single_select buttons sekaligus dalam 1 pesan.
77
- * selectors: [{ id?, displayText, sections }]
78
- * Returns: array of buttons
79
- */
80
- export const nfButtonMultiSelect = (selectors = []) =>
81
- selectors.map((sel, i) => nfButtonSingleSelect({
82
- id: sel.id || `select_${i}`,
83
- displayText: sel.displayText,
84
- sections: sel.sections
85
- }));
86
-
87
- export const nfButtonReviewPay = ({ id, currency = 'IDR', totalAmount1000, subtotal, tax, items = [], merchant = {} }) => ({
88
- name: 'review_and_pay',
89
- buttonParamsJson: JSON.stringify({ currency, total_amount: { value: totalAmount1000, offset: 1000 }, subtotal, tax, items, order: { status: 'pending', items }, merchant }),
90
- ...(id ? { id } : {})
91
- });
92
- export const nfButtonReviewOrder = ({ id, referenceId, type = 'ORDER', orderId }) => ({
93
- name: 'review_order',
94
- buttonParamsJson: JSON.stringify({ reference_id: referenceId, type, order_id: orderId }),
95
- ...(id ? { id } : {})
96
- });
97
- export const nfButtonMPM = ({ id, sections = [] }) => ({
98
- name: 'mpm',
99
- buttonParamsJson: JSON.stringify({
100
- sections: sections.map(sec => ({
101
- title: sec.title || '',
102
- product_items: (sec.productItems || []).map(p => ({ product_id: p.productId || p.product_id }))
103
- }))
104
- }),
105
- ...(id ? { id } : {})
106
- });
107
-
108
- // ─── Nested Legacy List Helper ────────────────────────────────────────────────
109
-
110
- /**
111
- * Build proto listMessage payload.
112
- * Row yang punya field `rows` sendiri otomatis di-flatten jadi section baru.
113
- */
114
- export const buildNestedListMessage = ({ title, buttonText, footer = '', sections = [] }) => {
115
- const flat = [];
116
- for (const sec of sections) {
117
- const topRows = [], childSecs = [];
118
- for (const row of (sec.rows || [])) {
119
- if (Array.isArray(row.rows) && row.rows.length > 0) {
120
- childSecs.push({
121
- title: row.title || '',
122
- rows: row.rows.map(r => ({ rowId: r.rowId || r.id || '', title: r.title || '', description: r.description || '' }))
123
- });
124
- } else {
125
- topRows.push({ rowId: row.rowId || row.id || '', title: row.title || '', description: row.description || '' });
126
- }
127
- }
128
- if (topRows.length) flat.push({ title: sec.title || '', rows: topRows });
129
- for (const cs of childSecs) flat.push(cs);
1
+ import crypto from "crypto";
2
+ import { proto } from "../../WAProto/index.js";
3
+ import {
4
+ delay,
5
+ generateMessageID,
6
+ generateWAMessage,
7
+ generateWAMessageContent,
8
+ generateWAMessageFromContent,
9
+ getUrlFromDirectPath,
10
+ normalizeMessageContent,
11
+ prepareWAMessageMedia,
12
+ } from "../Utils/index.js";
13
+ import {
14
+ isJidGroup,
15
+ isPnUser,
16
+ jidNormalizedUser,
17
+ STORIES_JID,
18
+ } from "../WABinary/index.js";
19
+ export class Dugong {
20
+ constructor(waUploadToServer, relayMessageFn, config, sock) {
21
+ this.relayMessage = relayMessageFn;
22
+ this.waUploadToServer = waUploadToServer;
23
+ this.config = config;
24
+ this.sock = sock;
25
+ }
26
+ detectType(content) {
27
+ if (content.requestPaymentMessage) return "PAYMENT";
28
+ if (content.productMessage) return "PRODUCT";
29
+ if (content.interactiveButtons) return "INTERACTIVE_BUTTONS";
30
+ if (content.interactiveMessage?.carouselMessage) return "CAROUSEL";
31
+ if (content.interactiveMessage) return "INTERACTIVE";
32
+ if (content.albumMessage || content.album) return "ALBUM";
33
+ if (content.eventMessage) return "EVENT";
34
+ if (content.pollResultMessage) return "POLL_RESULT";
35
+ if (content.groupStatusMessage) return "GROUP_STORY";
36
+ return null;
37
+ }
38
+ async handlePayment(content, quoted) {
39
+ const data = content.requestPaymentMessage;
40
+ let notes = {};
41
+ if (data.sticker?.stickerMessage) {
42
+ notes = {
43
+ stickerMessage: {
44
+ ...data.sticker.stickerMessage,
45
+ contextInfo: {
46
+ stanzaId: quoted?.key?.id,
47
+ participant: quoted?.key?.participant || content.sender,
48
+ quotedMessage: quoted?.message,
49
+ },
50
+ },
51
+ };
52
+ } else if (data.note) {
53
+ notes = {
54
+ extendedTextMessage: {
55
+ text: data.note,
56
+ contextInfo: {
57
+ stanzaId: quoted?.key?.id,
58
+ participant: quoted?.key?.participant || content.sender,
59
+ quotedMessage: quoted?.message,
60
+ },
61
+ },
62
+ };
63
+ }
64
+ return {
65
+ requestPaymentMessage: proto.Message.RequestPaymentMessage.fromObject({
66
+ expiryTimestamp: data.expiry || 0,
67
+ amount1000: data.amount || 0,
68
+ currencyCodeIso4217: data.currency || "IDR",
69
+ requestFrom: data.from || "0@s.whatsapp.net",
70
+ noteMessage: notes,
71
+ background: data.background ?? {
72
+ id: "DEFAULT",
73
+ placeholderArgb: 0xfff0f0f0,
74
+ },
75
+ }),
76
+ };
77
+ }
78
+ async handleProduct(content, _jid, _quoted) {
79
+ const {
80
+ title,
81
+ description,
82
+ thumbnail,
83
+ productId,
84
+ retailerId,
85
+ url,
86
+ body = "",
87
+ footer = "",
88
+ buttons = [],
89
+ priceAmount1000 = null,
90
+ currencyCode = "IDR",
91
+ } = content.productMessage;
92
+ let productImage;
93
+ if (Buffer.isBuffer(thumbnail)) {
94
+ const { imageMessage } = await generateWAMessageContent(
95
+ { image: thumbnail },
96
+ { upload: this.waUploadToServer },
97
+ );
98
+ productImage = imageMessage;
99
+ } else if (typeof thumbnail === "object" && thumbnail.url) {
100
+ const { imageMessage } = await generateWAMessageContent(
101
+ { image: { url: thumbnail.url } },
102
+ { upload: this.waUploadToServer },
103
+ );
104
+ productImage = imageMessage;
105
+ }
106
+ return {
107
+ viewOnceMessage: {
108
+ message: {
109
+ interactiveMessage: {
110
+ body: { text: body },
111
+ footer: { text: footer },
112
+ header: {
113
+ title,
114
+ hasMediaAttachment: true,
115
+ productMessage: {
116
+ product: {
117
+ productImage,
118
+ productId,
119
+ title,
120
+ description,
121
+ currencyCode,
122
+ priceAmount1000,
123
+ retailerId,
124
+ url,
125
+ productImageCount: 1,
126
+ },
127
+ businessOwnerJid: "0@s.whatsapp.net",
128
+ },
129
+ },
130
+ nativeFlowMessage: { buttons },
131
+ },
132
+ },
133
+ },
134
+ };
135
+ }
136
+ async handleInteractive(content, _jid, _quoted) {
137
+ const {
138
+ title,
139
+ footer,
140
+ thumbnail,
141
+ image,
142
+ video,
143
+ document,
144
+ mimetype,
145
+ fileName,
146
+ jpegThumbnail,
147
+ contextInfo,
148
+ externalAdReply,
149
+ buttons = [],
150
+ nativeFlowMessage,
151
+ header,
152
+ } = content.interactiveMessage;
153
+ let media = null;
154
+ let _mediaType = null;
155
+ if (thumbnail) {
156
+ media = await prepareWAMessageMedia(
157
+ { image: { url: thumbnail } },
158
+ { upload: this.waUploadToServer },
159
+ );
160
+ _mediaType = "image";
161
+ } else if (image) {
162
+ const src =
163
+ typeof image === "object" && image.url
164
+ ? { image: { url: image.url } }
165
+ : { image };
166
+ media = await prepareWAMessageMedia(src, {
167
+ upload: this.waUploadToServer,
168
+ });
169
+ _mediaType = "image";
170
+ } else if (video) {
171
+ const src =
172
+ typeof video === "object" && video.url
173
+ ? { video: { url: video.url } }
174
+ : { video };
175
+ media = await prepareWAMessageMedia(src, {
176
+ upload: this.waUploadToServer,
177
+ });
178
+ _mediaType = "video";
179
+ } else if (document) {
180
+ const docPayload = { document };
181
+ if (jpegThumbnail) {
182
+ docPayload.jpegThumbnail =
183
+ typeof jpegThumbnail === "object" && jpegThumbnail.url
184
+ ? { url: jpegThumbnail.url }
185
+ : jpegThumbnail;
186
+ }
187
+ media = await prepareWAMessageMedia(docPayload, {
188
+ upload: this.waUploadToServer,
189
+ });
190
+ if (fileName) media.documentMessage.fileName = fileName;
191
+ if (mimetype) media.documentMessage.mimetype = mimetype;
192
+ _mediaType = "document";
130
193
  }
131
- return { listMessage: { title, description: footer, buttonText, listType: 1, sections: flat } };
132
- };
133
-
134
- // ─── ExtendedMessageBuilder ───────────────────────────────────────────────────
135
-
136
- export class ExtendedMessageBuilder {
137
- constructor(utils, waUploadToServer, relayMessageFn) {
138
- this.utils = utils;
139
- this.relayMessage = relayMessageFn;
140
- this.waUploadToServer = waUploadToServer;
141
- this.bail = {
142
- generateWAMessageContent: this.utils.generateWAMessageContent,
143
- generateMessageID: this.utils.generateMessageID,
144
- getContentType: (msg) => Object.keys(msg.message || {})[0]
194
+ const interactiveMessage = {
195
+ body: { text: title || "" },
196
+ footer: { text: footer || "" },
197
+ };
198
+ if (buttons && buttons.length > 0) {
199
+ interactiveMessage.nativeFlowMessage = { buttons };
200
+ if (nativeFlowMessage) {
201
+ interactiveMessage.nativeFlowMessage = {
202
+ ...interactiveMessage.nativeFlowMessage,
203
+ ...nativeFlowMessage,
145
204
  };
205
+ }
206
+ } else if (nativeFlowMessage) {
207
+ interactiveMessage.nativeFlowMessage = nativeFlowMessage;
208
+ }
209
+ if (media) {
210
+ interactiveMessage.header = {
211
+ title: header || "",
212
+ hasMediaAttachment: true,
213
+ ...media,
214
+ };
215
+ } else {
216
+ interactiveMessage.header = {
217
+ title: header || "",
218
+ hasMediaAttachment: false,
219
+ };
220
+ }
221
+ const finalContextInfo = {};
222
+ if (contextInfo) {
223
+ Object.assign(finalContextInfo, {
224
+ mentionedJid: contextInfo.mentionedJid || [],
225
+ forwardingScore: contextInfo.forwardingScore || 0,
226
+ isForwarded: contextInfo.isForwarded || false,
227
+ ...contextInfo,
228
+ });
229
+ }
230
+ if (externalAdReply) {
231
+ finalContextInfo.externalAdReply = {
232
+ title: externalAdReply.title || "",
233
+ body: externalAdReply.body || "",
234
+ mediaType: externalAdReply.mediaType || 1,
235
+ thumbnailUrl: externalAdReply.thumbnailUrl || "",
236
+ mediaUrl: externalAdReply.mediaUrl || "",
237
+ sourceUrl: externalAdReply.sourceUrl || "",
238
+ showAdAttribution: externalAdReply.showAdAttribution || false,
239
+ renderLargerThumbnail: externalAdReply.renderLargerThumbnail || false,
240
+ ...externalAdReply,
241
+ };
146
242
  }
147
-
148
- detectType(content) {
149
- if (content.requestPaymentMessage) return 'PAYMENT';
150
- if (content.productMessage) return 'PRODUCT';
151
- if (content.interactiveMessage) return 'INTERACTIVE';
152
- if (content.albumMessage) return 'ALBUM';
153
- if (content.eventMessage) return 'EVENT';
154
- if (content.pollResultMessage) return 'POLL_RESULT';
155
- if (content.groupStatusMessage) return 'GROUP_STORY';
156
- if (content.nestedListMessage) return 'NESTED_LIST';
157
- if (content.multiSelectMessage) return 'MULTI_SELECT';
158
- return null;
243
+ if (Object.keys(finalContextInfo).length > 0) {
244
+ interactiveMessage.contextInfo = finalContextInfo;
159
245
  }
160
-
161
- async handlePayment(content, quoted) {
162
- const data = content.requestPaymentMessage;
163
- let notes = {};
164
- if (data.sticker?.stickerMessage) {
165
- notes = { stickerMessage: { ...data.sticker.stickerMessage, contextInfo: { stanzaId: quoted?.key?.id, participant: quoted?.key?.participant || content.sender, quotedMessage: quoted?.message } } };
166
- } else if (data.note) {
167
- notes = { extendedTextMessage: { text: data.note, contextInfo: { stanzaId: quoted?.key?.id, participant: quoted?.key?.participant || content.sender, quotedMessage: quoted?.message } } };
246
+ return { interactiveMessage };
247
+ }
248
+ async handleInteractiveButtons(content, _jid, _quoted) {
249
+ const {
250
+ text,
251
+ caption,
252
+ title,
253
+ subtitle,
254
+ footer,
255
+ interactiveButtons,
256
+ hasMediaAttachment,
257
+ image,
258
+ video,
259
+ document,
260
+ mimetype,
261
+ jpegThumbnail,
262
+ location,
263
+ product,
264
+ businessOwnerJid,
265
+ } = content;
266
+ const bodyText = text || caption || "";
267
+ const buttons = interactiveButtons.map((btn) => ({
268
+ name: btn.name,
269
+ buttonParamsJson:
270
+ typeof btn.buttonParamsJson === "string"
271
+ ? btn.buttonParamsJson
272
+ : JSON.stringify(btn.buttonParamsJson),
273
+ }));
274
+ let headerContent = {};
275
+ let mediaAttached =
276
+ typeof hasMediaAttachment === "boolean" ? hasMediaAttachment : false;
277
+ if (image) {
278
+ const src =
279
+ typeof image === "object" && image.url
280
+ ? { image: { url: image.url } }
281
+ : { image };
282
+ const uploaded = await prepareWAMessageMedia(src, {
283
+ upload: this.waUploadToServer,
284
+ });
285
+ headerContent = { ...uploaded };
286
+ mediaAttached =
287
+ typeof hasMediaAttachment === "boolean" ? hasMediaAttachment : true;
288
+ } else if (video) {
289
+ const src =
290
+ typeof video === "object" && video.url
291
+ ? { video: { url: video.url } }
292
+ : { video };
293
+ const uploaded = await prepareWAMessageMedia(src, {
294
+ upload: this.waUploadToServer,
295
+ });
296
+ headerContent = { ...uploaded };
297
+ mediaAttached =
298
+ typeof hasMediaAttachment === "boolean" ? hasMediaAttachment : true;
299
+ } else if (document) {
300
+ const docPayload =
301
+ typeof document === "object" && document.url
302
+ ? { document: { url: document.url } }
303
+ : { document };
304
+ if (mimetype) docPayload.mimetype = mimetype;
305
+ const uploaded = await prepareWAMessageMedia(docPayload, {
306
+ upload: this.waUploadToServer,
307
+ });
308
+ if (jpegThumbnail) {
309
+ uploaded.documentMessage.jpegThumbnail =
310
+ typeof jpegThumbnail === "string"
311
+ ? Buffer.from(jpegThumbnail, "base64")
312
+ : jpegThumbnail;
313
+ }
314
+ headerContent = { ...uploaded };
315
+ mediaAttached =
316
+ typeof hasMediaAttachment === "boolean" ? hasMediaAttachment : true;
317
+ } else if (location) {
318
+ headerContent = {
319
+ locationMessage: {
320
+ degreesLatitude:
321
+ location.degressLatitude || location.degreesLatitude || 0,
322
+ degreesLongitude:
323
+ location.degressLongitude || location.degreesLongitude || 0,
324
+ name: location.name || "",
325
+ },
326
+ };
327
+ mediaAttached =
328
+ typeof hasMediaAttachment === "boolean" ? hasMediaAttachment : true;
329
+ } else if (product) {
330
+ let productImage;
331
+ if (product.productImage) {
332
+ const imgSrc =
333
+ typeof product.productImage === "object" && product.productImage.url
334
+ ? { image: { url: product.productImage.url } }
335
+ : { image: product.productImage };
336
+ const uploaded = await prepareWAMessageMedia(imgSrc, {
337
+ upload: this.waUploadToServer,
338
+ });
339
+ productImage = uploaded.imageMessage;
340
+ }
341
+ headerContent = {
342
+ productMessage: {
343
+ product: {
344
+ productImage,
345
+ productId: product.productId,
346
+ title: product.title,
347
+ description: product.description,
348
+ currencyCode: product.currencyCode || "IDR",
349
+ priceAmount1000: product.priceAmount1000,
350
+ retailerId: product.retailerId,
351
+ url: product.url,
352
+ productImageCount: product.productImageCount || 1,
353
+ },
354
+ businessOwnerJid: businessOwnerJid || "0@s.whatsapp.net",
355
+ },
356
+ };
357
+ mediaAttached =
358
+ typeof hasMediaAttachment === "boolean" ? hasMediaAttachment : true;
359
+ }
360
+ const interactiveMessage = {
361
+ body: { text: bodyText },
362
+ footer: { text: footer || "" },
363
+ header: {
364
+ title: title || "",
365
+ subtitle: subtitle || "",
366
+ hasMediaAttachment: mediaAttached,
367
+ ...headerContent,
368
+ },
369
+ nativeFlowMessage: { buttons },
370
+ };
371
+ return {
372
+ viewOnceMessage: {
373
+ message: {
374
+ messageContextInfo: {
375
+ deviceListMetadata: {},
376
+ deviceListMetadataVersion: 2,
377
+ messageSecret: crypto.randomBytes(32),
378
+ },
379
+ interactiveMessage,
380
+ },
381
+ },
382
+ };
383
+ }
384
+ async handleCarousel(content, _jid, _quoted) {
385
+ const { interactiveMessage } = content;
386
+ const { body, footer, header, carouselMessage, contextInfo } =
387
+ interactiveMessage;
388
+ const processedCards = [];
389
+ for (const card of carouselMessage.cards) {
390
+ const cardMsg = {
391
+ body: card.body || { text: "" },
392
+ footer: card.footer || { text: "" },
393
+ header: {
394
+ title: card.header?.title || "",
395
+ hasMediaAttachment: false,
396
+ },
397
+ };
398
+ if (card.nativeFlowMessage) {
399
+ cardMsg.nativeFlowMessage = card.nativeFlowMessage;
400
+ }
401
+ if (
402
+ card.header?.imageMessage ||
403
+ card.header?.videoMessage ||
404
+ card.header?.documentMessage
405
+ ) {
406
+ let headerContent = {};
407
+ let mediaAttached = true;
408
+ if (card.header.imageMessage) {
409
+ const url = card.header.imageMessage.url || card.header.imageMessage;
410
+ const src =
411
+ typeof url === "string" ? { image: { url } } : { image: url };
412
+ const uploaded = await prepareWAMessageMedia(src, {
413
+ upload: this.waUploadToServer,
414
+ });
415
+ headerContent = { ...uploaded };
416
+ } else if (card.header.videoMessage) {
417
+ const url = card.header.videoMessage.url || card.header.videoMessage;
418
+ const src =
419
+ typeof url === "string" ? { video: { url } } : { video: url };
420
+ const uploaded = await prepareWAMessageMedia(src, {
421
+ upload: this.waUploadToServer,
422
+ });
423
+ headerContent = { ...uploaded };
424
+ } else if (card.header.documentMessage) {
425
+ const url =
426
+ card.header.documentMessage.url || card.header.documentMessage;
427
+ const src =
428
+ typeof url === "string" ? { document: { url } } : { document: url };
429
+ const uploaded = await prepareWAMessageMedia(src, {
430
+ upload: this.waUploadToServer,
431
+ });
432
+ headerContent = { ...uploaded };
168
433
  }
169
- return {
170
- requestPaymentMessage: proto.Message.RequestPaymentMessage.fromObject({
171
- expiryTimestamp: data.expiry || 0, amount1000: data.amount || 0,
172
- currencyCodeIso4217: data.currency || 'IDR', requestFrom: data.from || '0@s.whatsapp.net',
173
- noteMessage: notes, background: data.background ?? { id: 'DEFAULT', placeholderArgb: 0xFFF0F0F0 }
174
- })
434
+ cardMsg.header = {
435
+ title: card.header?.title || "",
436
+ hasMediaAttachment: mediaAttached,
437
+ ...headerContent,
175
438
  };
439
+ }
440
+ processedCards.push(cardMsg);
176
441
  }
177
-
178
- async handleProduct(content, jid, quoted) {
179
- const { title, description, thumbnail, productId, retailerId, url, body = '', footer = '', buttons = [], priceAmount1000 = null, currencyCode = 'IDR' } = content.productMessage;
180
- let productImage;
181
- if (Buffer.isBuffer(thumbnail)) {
182
- const { imageMessage } = await this.utils.generateWAMessageContent({ image: thumbnail }, { upload: this.waUploadToServer });
183
- productImage = imageMessage;
184
- } else if (thumbnail?.url) {
185
- const { imageMessage } = await this.utils.generateWAMessageContent({ image: { url: thumbnail.url } }, { upload: this.waUploadToServer });
186
- productImage = imageMessage;
187
- }
188
- return { viewOnceMessage: { message: { interactiveMessage: { body: { text: body }, footer: { text: footer }, header: { title, hasMediaAttachment: true, productMessage: { product: { productImage, productId, title, description, currencyCode, priceAmount1000, retailerId, url, productImageCount: 1 }, businessOwnerJid: '0@s.whatsapp.net' } }, nativeFlowMessage: { buttons } } } } };
442
+ const interactiveMsg = {
443
+ body: body || { text: "" },
444
+ footer: footer || { text: "" },
445
+ header: header || { title: "", hasMediaAttachment: false },
446
+ carouselMessage: {
447
+ cards: processedCards,
448
+ messageVersion: carouselMessage.messageVersion || 1,
449
+ carouselCardType: carouselMessage.carouselCardType ?? 1,
450
+ },
451
+ };
452
+ if (contextInfo) {
453
+ interactiveMsg.contextInfo = contextInfo;
189
454
  }
190
-
191
- async handleInteractive(content, jid, quoted, options = {}) {
192
- const { title, footer, thumbnail, image, video, document, mimetype, fileName, jpegThumbnail, contextInfo = {}, externalAdReply, buttons = [], nativeFlowMessage, header } = content.interactiveMessage;
193
- let media = null;
194
- if (thumbnail || image) {
195
- const src = thumbnail || image;
196
- media = await this.utils.prepareWAMessageMedia({ image: src?.url ? { url: src.url } : src }, { upload: this.waUploadToServer });
197
- } else if (video) {
198
- media = await this.utils.prepareWAMessageMedia({ video: video?.url ? { url: video.url } : video }, { upload: this.waUploadToServer });
199
- } else if (document) {
200
- let dp = { document };
201
- if (jpegThumbnail) dp.jpegThumbnail = jpegThumbnail?.url ? { url: jpegThumbnail.url } : jpegThumbnail;
202
- media = await this.utils.prepareWAMessageMedia(dp, { upload: this.waUploadToServer });
203
- if (fileName && media.documentMessage) media.documentMessage.fileName = fileName;
204
- if (mimetype && media.documentMessage) media.documentMessage.mimetype = mimetype;
205
- }
206
- let im = { body: { text: title || '' }, footer: { text: footer || '' } };
207
- if (buttons?.length) { im.nativeFlowMessage = { buttons }; if (nativeFlowMessage) im.nativeFlowMessage = { ...im.nativeFlowMessage, ...nativeFlowMessage }; }
208
- else if (nativeFlowMessage) im.nativeFlowMessage = nativeFlowMessage;
209
- im.header = media ? { title: header || '', hasMediaAttachment: true, ...media } : { title: header || '', hasMediaAttachment: false };
210
- let ci = { forwardingScore: contextInfo.forwardingScore || 0, isForwarded: contextInfo.isForwarded || false, ...contextInfo, mentionedJid: normalizeMentions(contextInfo.mentionedJid || options.mentions || []) };
211
- if (externalAdReply) ci.externalAdReply = { title: '', body: '', mediaType: 1, thumbnailUrl: '', mediaUrl: '', sourceUrl: '', showAdAttribution: false, renderLargerThumbnail: false, ...externalAdReply };
212
- if (!Array.isArray(ci.mentionedJid)) ci.mentionedJid = [ci.mentionedJid].filter(Boolean);
213
- if (Object.keys(ci).length) im.contextInfo = ci;
214
- return { interactiveMessage: im };
455
+ return {
456
+ viewOnceMessage: {
457
+ message: {
458
+ messageContextInfo: {
459
+ deviceListMetadata: {},
460
+ deviceListMetadataVersion: 2,
461
+ messageSecret: crypto.randomBytes(32),
462
+ },
463
+ interactiveMessage: interactiveMsg,
464
+ },
465
+ },
466
+ };
467
+ }
468
+ async handleAlbum(content, jid, quoted) {
469
+ const array = content.albumMessage || content.album;
470
+ const ctxInfo = content.contextInfo || {};
471
+ const album = await generateWAMessageFromContent(
472
+ jid,
473
+ {
474
+ messageContextInfo: {
475
+ messageSecret: crypto.randomBytes(32),
476
+ },
477
+ albumMessage: {
478
+ expectedImageCount: array.filter((a) => "image" in a).length,
479
+ expectedVideoCount: array.filter((a) => "video" in a).length,
480
+ },
481
+ },
482
+ {
483
+ userJid: jidNormalizedUser(this.sock.authState?.creds?.me?.id || ""),
484
+ quoted,
485
+ upload: this.waUploadToServer,
486
+ },
487
+ );
488
+ await this.relayMessage(jid, album.message, {
489
+ messageId: album.key.id,
490
+ });
491
+ for (let item of array) {
492
+ if (ctxInfo && Object.keys(ctxInfo).length > 0 && !item.contextInfo) {
493
+ item = { ...item, contextInfo: ctxInfo };
494
+ }
495
+ const img = await generateWAMessage(jid, item, {
496
+ upload: this.waUploadToServer,
497
+ userJid: jidNormalizedUser(this.sock.authState?.creds?.me?.id || ""),
498
+ });
499
+ img.message.messageContextInfo = {
500
+ messageSecret: crypto.randomBytes(32),
501
+ messageAssociation: {
502
+ associationType: 1,
503
+ parentMessageKey: album.key,
504
+ },
505
+ };
506
+ await this.relayMessage(jid, img.message, {
507
+ messageId: img.key.id,
508
+ });
215
509
  }
216
-
217
- /**
218
- * Multi-Select — 1 pesan dengan BEBERAPA tombol single_select.
219
- * Tiap selector = 1 tombol dropdown terpisah, buka bottom sheet sendiri.
220
- *
221
- * Gunakan dari plugin:
222
- * conn.sendMessage(jid, {
223
- * multiSelectMessage: {
224
- * title: 'Judul',
225
- * footer: 'Footer',
226
- * selectors: [
227
- * { displayText: '⚔️ Senjata', sections: [{ title: 'Melee', rows: [{ id:'sword', title:'Pedang' }] }] },
228
- * { displayText: '🛡️ Armor', sections: [{ title: 'Light', rows: [{ id:'cloth', title:'Cloth' }] }] },
229
- * ]
230
- * }
231
- * })
232
- */
233
- async handleMultiSelect(content, jid, quoted, options = {}) {
234
- const { title, footer, image, video, thumbnail, selectors = [], extraButtons = [], contextInfo = {}, header } = content.multiSelectMessage;
235
- const buttons = [...nfButtonMultiSelect(selectors), ...extraButtons];
236
- return this.handleInteractive({ interactiveMessage: { title, footer, image, video, thumbnail, header, contextInfo, buttons } }, jid, quoted, options);
510
+ return album;
511
+ }
512
+ async handleEvent(content, jid, quoted) {
513
+ const eventData = content.eventMessage;
514
+ const msg = await generateWAMessageFromContent(
515
+ jid,
516
+ {
517
+ viewOnceMessage: {
518
+ message: {
519
+ messageContextInfo: {
520
+ deviceListMetadata: {},
521
+ deviceListMetadataVersion: 2,
522
+ messageSecret: crypto.randomBytes(32),
523
+ },
524
+ eventMessage: {
525
+ isCanceled: eventData.isCanceled || false,
526
+ name: eventData.name,
527
+ description: eventData.description,
528
+ location: eventData.location || {
529
+ degreesLatitude: 0,
530
+ degreesLongitude: 0,
531
+ name: "Location",
532
+ },
533
+ joinLink: eventData.joinLink || "",
534
+ startTime:
535
+ typeof eventData.startTime === "string"
536
+ ? parseInt(eventData.startTime)
537
+ : eventData.startTime || Date.now(),
538
+ endTime:
539
+ typeof eventData.endTime === "string"
540
+ ? parseInt(eventData.endTime)
541
+ : eventData.endTime || Date.now() + 3600000,
542
+ extraGuestsAllowed: eventData.extraGuestsAllowed !== false,
543
+ },
544
+ },
545
+ },
546
+ },
547
+ {
548
+ quoted,
549
+ userJid: jidNormalizedUser(this.sock.authState?.creds?.me?.id || ""),
550
+ },
551
+ );
552
+ await this.relayMessage(jid, msg.message, {
553
+ messageId: msg.key.id,
554
+ });
555
+ return msg;
556
+ }
557
+ async handlePollResult(content, jid, quoted) {
558
+ const pollData = content.pollResultMessage;
559
+ const msg = await generateWAMessageFromContent(
560
+ jid,
561
+ {
562
+ pollResultSnapshotMessage: {
563
+ name: pollData.name,
564
+ pollVotes: pollData.pollVotes.map((vote) => ({
565
+ optionName: vote.optionName,
566
+ optionVoteCount:
567
+ typeof vote.optionVoteCount === "number"
568
+ ? vote.optionVoteCount.toString()
569
+ : vote.optionVoteCount,
570
+ })),
571
+ },
572
+ },
573
+ {
574
+ quoted,
575
+ userJid: jidNormalizedUser(this.sock.authState?.creds?.me?.id || ""),
576
+ },
577
+ );
578
+ await this.relayMessage(jid, msg.message, {
579
+ messageId: msg.key.id,
580
+ });
581
+ return msg;
582
+ }
583
+ async handleGroupStory(content, jid, _quoted, options = {}) {
584
+ const storyData = content.groupStatusMessage;
585
+ let waMsgContent;
586
+ if (storyData.message) {
587
+ waMsgContent = storyData;
588
+ } else {
589
+ waMsgContent = await generateWAMessageContent(storyData, {
590
+ upload: this.waUploadToServer,
591
+ });
237
592
  }
238
-
239
- /**
240
- * Nested List — legacy listMessage.
241
- * Row yang punya `.rows` otomatis di-flatten jadi section baru.
242
- *
243
- * conn.sendMessage(jid, {
244
- * nestedListMessage: {
245
- * title: 'Menu',
246
- * buttonText: 'Buka',
247
- * footer: '...',
248
- * sections: [
249
- * { title: 'Kategori A', rows: [
250
- * { rowId: 'a1', title: 'Item A1' },
251
- * { title: 'Sub-Kategori', rows: [ ← ini jadi section baru
252
- * { rowId: 'b1', title: 'Item B1' },
253
- * ]}
254
- * ]}
255
- * ]
256
- * }
257
- * })
258
- */
259
- async handleNestedList(content, jid, quoted) {
260
- const payload = buildNestedListMessage(content.nestedListMessage);
261
- return await this.utils.generateWAMessageFromContent(jid, {
262
- viewOnceMessage: { message: { messageContextInfo: { deviceListMetadata: {}, deviceListMetadataVersion: 2 }, ...payload } }
263
- }, { quoted });
593
+ const innerMsg = waMsgContent.message || waMsgContent;
594
+ const msgKey = Object.keys(innerMsg).find(
595
+ (k) => innerMsg[k] && typeof innerMsg[k] === "object",
596
+ );
597
+ if (msgKey) {
598
+ innerMsg[msgKey].contextInfo = innerMsg[msgKey].contextInfo || {};
599
+ innerMsg[msgKey].contextInfo.isGroupStatus = true;
600
+ if (!innerMsg[msgKey].contextInfo.statusSourceType) {
601
+ if (innerMsg.imageMessage)
602
+ innerMsg[msgKey].contextInfo.statusSourceType = 0;
603
+ else if (innerMsg.videoMessage)
604
+ innerMsg[msgKey].contextInfo.statusSourceType = 1;
605
+ else if (innerMsg.audioMessage)
606
+ innerMsg[msgKey].contextInfo.statusSourceType = 3;
607
+ else if (innerMsg.extendedTextMessage)
608
+ innerMsg[msgKey].contextInfo.statusSourceType = 4;
609
+ }
264
610
  }
265
-
266
- async handleAlbum(content, jid, quoted) {
267
- const array = content.albumMessage;
268
- const album = await this.utils.generateWAMessageFromContent(jid, {
269
- messageContextInfo: { messageSecret: randomBytes(32) },
270
- albumMessage: {
271
- expectedImageCount: array.filter(a => Object.hasOwn(a, 'image')).length,
272
- expectedVideoCount: array.filter(a => Object.hasOwn(a, 'video')).length
273
- }
274
- }, { userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net', quoted, upload: this.waUploadToServer });
275
- await this.relayMessage(jid, album.message, { messageId: album.key.id });
276
- for (const item of array) {
277
- const img = await this.utils.generateWAMessage(jid, item, { upload: this.waUploadToServer });
278
- img.message.messageContextInfo = { messageSecret: randomBytes(32), messageAssociation: { associationType: 1, parentMessageKey: album.key }, participant: jid, forwardingScore: 0, isForwarded: false };
279
- await this.relayMessage(jid, img.message, { messageId: img.key.id, quoted: { key: { remoteJid: album.key.remoteJid, id: album.key.id, fromMe: true, participant: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net' }, message: album.message } });
611
+ const finalMsg = {
612
+ groupStatusMessageV2: {
613
+ message: innerMsg,
614
+ },
615
+ };
616
+ return await this.relayMessage(jid, finalMsg, {
617
+ messageId: generateMessageID(),
618
+ });
619
+ }
620
+ async sendStatusWhatsApp(content, jids = []) {
621
+ const userJid = jidNormalizedUser(this.sock.authState.creds.me.id);
622
+ const allUsers = new Set();
623
+ allUsers.add(userJid);
624
+ for (const id of jids) {
625
+ if (isJidGroup(id)) {
626
+ try {
627
+ const metadata = await this.sock.groupMetadata(id);
628
+ metadata.participants.forEach((p) =>
629
+ allUsers.add(jidNormalizedUser(p.id)),
630
+ );
631
+ } catch (error) {
632
+ this.config.logger.error(
633
+ `Error getting metadata for group ${id}: ${error}`,
634
+ );
280
635
  }
281
- return album;
636
+ } else if (isPnUser(id)) {
637
+ allUsers.add(jidNormalizedUser(id));
638
+ }
282
639
  }
283
-
284
- async handleEvent(content, jid, quoted) {
285
- const e = content.eventMessage;
286
- const msg = await this.utils.generateWAMessageFromContent(jid, {
287
- viewOnceMessage: { message: { messageContextInfo: { deviceListMetadata: {}, deviceListMetadataVersion: 2, messageSecret: randomBytes(32), supportPayload: JSON.stringify({ version: 2, is_ai_message: true, should_show_system_message: true, ticket_id: randomBytes(16).toString('hex') }) }, eventMessage: { contextInfo: { mentionedJid: [jid], participant: jid, remoteJid: 'status@broadcast' }, isCanceled: e.isCanceled || false, name: e.name, description: e.description, location: e.location || { degreesLatitude: 0, degreesLongitude: 0, name: 'Location' }, joinLink: e.joinLink || '', startTime: typeof e.startTime === 'string' ? parseInt(e.startTime, 10) : e.startTime || Date.now(), endTime: typeof e.endTime === 'string' ? parseInt(e.endTime, 10) : e.endTime || Date.now() + 3600000, extraGuestsAllowed: e.extraGuestsAllowed !== false } } }
288
- }, { quoted });
289
- await this.relayMessage(jid, msg.message, { messageId: msg.key.id });
290
- return msg;
640
+ const uniqueUsers = Array.from(allUsers);
641
+ const getRandomHexColor = () =>
642
+ "#" +
643
+ Math.floor(Math.random() * 16777215)
644
+ .toString(16)
645
+ .padStart(6, "0");
646
+ const isMedia = content.image || content.video || content.audio;
647
+ const isAudio = !!content.audio;
648
+ const messageContent = { ...content };
649
+ if (isMedia && !isAudio) {
650
+ if (messageContent.text) {
651
+ messageContent.caption = messageContent.text;
652
+ delete messageContent.text;
653
+ }
654
+ delete messageContent.ptt;
655
+ delete messageContent.font;
656
+ delete messageContent.backgroundColor;
657
+ delete messageContent.textColor;
291
658
  }
292
-
293
- async handlePollResult(content, jid, quoted) {
294
- const p = content.pollResultMessage;
295
- const msg = await this.utils.generateWAMessageFromContent(jid, {
296
- pollResultSnapshotMessage: { name: p.name, pollVotes: p.pollVotes.map(v => ({ optionName: v.optionName, optionVoteCount: typeof v.optionVoteCount === 'number' ? v.optionVoteCount.toString() : v.optionVoteCount })) }
297
- }, { userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net', quoted });
298
- await this.relayMessage(jid, msg.message, { messageId: msg.key.id });
299
- return msg;
659
+ if (isAudio) {
660
+ delete messageContent.text;
661
+ delete messageContent.caption;
662
+ delete messageContent.font;
663
+ delete messageContent.textColor;
300
664
  }
301
-
302
- /**
303
- * Group Status V2 — kirim story/status ke grup.
304
- *
305
- * Format groupStatusMessage:
306
- *
307
- * // Teks biasa
308
- * { text: 'Halo grup!' }
309
- *
310
- * // Foto dengan caption
311
- * { image: Buffer | { url: '...' }, caption: 'Caption foto' }
312
- *
313
- * // Video dengan caption
314
- * { video: Buffer | { url: '...' }, caption: 'Caption video', gifPlayback?: true }
315
- *
316
- * // Audio (voice note)
317
- * { audio: Buffer | { url: '...' }, ptt: true, seconds: 10 }
318
- *
319
- * // Audio biasa (musik)
320
- * { audio: Buffer | { url: '...' }, ptt: false, mimetype: 'audio/mp4' }
321
- *
322
- * // Sticker
323
- * { sticker: Buffer | { url: '...' } }
324
- *
325
- * // Dokumen
326
- * { document: Buffer | { url: '...' }, mimetype: 'application/pdf', fileName: 'file.pdf', caption: 'Caption' }
327
- *
328
- * // Pre-built WAMessage (advanced)
329
- * { message: { imageMessage: { ... } } }
330
- *
331
- * // Raw relay (forward story)
332
- * { raw: <msgPayload> }
333
- *
334
- * Semua mode support field tambahan:
335
- * backgroundColor?: number (ARGB hex, untuk teks/audio)
336
- * textArgb?: number
337
- * font?: number (0-5)
338
- */
339
- /**
340
- * Group Status V2 — kirim story/status ke grup.
341
- * messageSecret wajib ada supaya WA client bisa decrypt & tampilkan konten.
342
- *
343
- * PATCH (v3.2.10): sekarang menyertakan `additionalNodes` via
344
- * buildInteractiveAdditionalNodes() di SETIAP relayMessage() call. Tanpa ini,
345
- * node <meta is_vsn2="1"/> (yang sudah punya cabang logic-nya sendiri di
346
- * Utils/messages.js buildInteractiveAdditionalNodes) tidak pernah benar-benar
347
- * terkirim ke server, sehingga klien penerima tidak tahu payload ini harus
348
- * dirender sebagai story/status grup — pesan tetap terkirim & ter-enkripsi
349
- * normal, tapi tidak pernah muncul sebagai ring status untuk member lain.
350
- */
351
- async handleGroupStory(content, jid) {
352
- const s = content.groupStatusMessage;
353
- const secret = randomBytes(32);
354
- const buildNodes = this.utils.buildInteractiveAdditionalNodes;
355
-
356
- // Mode 1: raw relay langsung
357
- if (s.raw) {
358
- const additionalNodes = buildNodes ? buildNodes(jid, s.raw) : [];
359
- return await this.relayMessage(jid, s.raw, {
360
- messageId: this.bail.generateMessageID(),
361
- additionalNodes
362
- });
363
- }
364
-
365
- // Mode 2: inner WAMessage sudah disiapkan — wrap dengan secret
366
- if (s.message) {
367
- const wrapped = {
368
- groupStatusMessageV2: {
369
- message: {
370
- messageContextInfo: {
371
- messageSecret: secret,
372
- deviceListMetadata: {},
373
- deviceListMetadataVersion: 2
374
- },
375
- ...s.message
376
- }
377
- }
378
- };
379
- const additionalNodes = buildNodes ? buildNodes(jid, wrapped) : [];
380
- return await this.relayMessage(jid, wrapped, {
381
- messageId: this.bail.generateMessageID(),
382
- additionalNodes
383
- });
384
- }
385
-
386
- // Mode 3: generate dari media/teks
387
- let innerMessage = {};
388
- const mentionCtx = (Array.isArray(s.mentions) && s.mentions.length)
389
- ? { contextInfo: { mentionedJid: s.mentions } }
390
- : {};
391
-
392
- if (s.text || (!s.image && !s.video && !s.gif && !s.audio && !s.sticker && !s.document)) {
393
- // Teks
394
- innerMessage = {
395
- extendedTextMessage: {
396
- text: s.text || s.caption || '',
397
- ...(typeof s.backgroundColor !== 'undefined' ? { backgroundArgb: s.backgroundColor } : {}),
398
- ...(typeof s.textArgb !== 'undefined' ? { textArgb: s.textArgb } : {}),
399
- ...(typeof s.font !== 'undefined' ? { font: s.font } : {}),
400
- ...mentionCtx
401
- }
402
- };
403
- } else if (s.image) {
404
- const media = await this.utils.prepareWAMessageMedia(
405
- { image: s.image },
406
- { upload: this.waUploadToServer }
407
- );
408
- if (s.caption) media.imageMessage.caption = s.caption;
409
- if (mentionCtx.contextInfo) media.imageMessage.contextInfo = { ...media.imageMessage.contextInfo, ...mentionCtx.contextInfo };
410
- innerMessage = media;
411
- } else if (s.card) {
412
- // Mode: canvas-rendered story card (gradient + title/body/footer text),
413
- // see lib/Utils/story-card.js. `s.card` accepts the same options as
414
- // renderStoryCard() — e.g. { title, body, footer, gradient, direction }.
415
- const cardBuffer = await this.utils.renderStoryCard(s.card);
416
- const media = await this.utils.prepareWAMessageMedia(
417
- { image: cardBuffer },
418
- { upload: this.waUploadToServer }
419
- );
420
- if (s.caption) media.imageMessage.caption = s.caption;
421
- if (mentionCtx.contextInfo) media.imageMessage.contextInfo = { ...media.imageMessage.contextInfo, ...mentionCtx.contextInfo };
422
- innerMessage = media;
423
- } else if (s.gif) {
424
- // Shorthand: { gif: Buffer | { url }, caption? } — dikirim sebagai video looping,
425
- // sama seperti representasi GIF asli WhatsApp.
426
- const media = await this.utils.prepareWAMessageMedia(
427
- { video: s.gif },
428
- { upload: this.waUploadToServer }
429
- );
430
- if (s.caption) media.videoMessage.caption = s.caption;
431
- media.videoMessage.gifPlayback = true;
432
- if (mentionCtx.contextInfo) media.videoMessage.contextInfo = { ...media.videoMessage.contextInfo, ...mentionCtx.contextInfo };
433
- innerMessage = media;
434
- } else if (s.video) {
435
- const media = await this.utils.prepareWAMessageMedia(
436
- { video: s.video },
437
- { upload: this.waUploadToServer }
438
- );
439
- if (s.caption) media.videoMessage.caption = s.caption;
440
- if (s.gifPlayback) media.videoMessage.gifPlayback = true;
441
- if (s.seconds) media.videoMessage.seconds = s.seconds;
442
- if (mentionCtx.contextInfo) media.videoMessage.contextInfo = { ...media.videoMessage.contextInfo, ...mentionCtx.contextInfo };
443
- innerMessage = media;
444
- } else if (s.audio) {
445
- const media = await this.utils.prepareWAMessageMedia(
446
- {
447
- audio: s.audio,
448
- ptt: s.ptt !== false,
449
- ...(s.seconds ? { seconds: s.seconds } : {}),
450
- ...(s.mimetype ? { mimetype: s.mimetype } : {})
451
- },
452
- {
453
- upload: this.waUploadToServer,
454
- // NOTE: backgroundColor harus lewat `options` (argumen ke-2), bukan payload
455
- // media — prepareWAMessageMedia() cuma hitung backgroundArgb untuk ptt audio
456
- // kalau options.backgroundColor keisi. Sebelumnya gak pernah diteruskan di sini,
457
- // jadi backgroundColor pada audio story selalu diam-diam diabaikan.
458
- ...(typeof s.backgroundColor !== 'undefined' ? { backgroundColor: s.backgroundColor } : {})
459
- }
460
- );
461
- if (mentionCtx.contextInfo) media.audioMessage.contextInfo = { ...media.audioMessage.contextInfo, ...mentionCtx.contextInfo };
462
- innerMessage = media;
463
- } else if (s.sticker) {
464
- const media = await this.utils.prepareWAMessageMedia(
465
- { sticker: s.sticker },
466
- { upload: this.waUploadToServer }
467
- );
468
- if (mentionCtx.contextInfo) media.stickerMessage.contextInfo = { ...media.stickerMessage.contextInfo, ...mentionCtx.contextInfo };
469
- innerMessage = media;
470
- } else if (s.document) {
471
- const media = await this.utils.prepareWAMessageMedia(
472
- {
473
- document: s.document,
474
- mimetype: s.mimetype || 'application/octet-stream',
475
- fileName: s.fileName || 'file'
476
- },
477
- { upload: this.waUploadToServer }
478
- );
479
- if (s.caption && media.documentMessage) media.documentMessage.caption = s.caption;
480
- if (s.fileName && media.documentMessage) media.documentMessage.fileName = s.fileName;
481
- if (mentionCtx.contextInfo && media.documentMessage) media.documentMessage.contextInfo = { ...media.documentMessage.contextInfo, ...mentionCtx.contextInfo };
482
- innerMessage = media;
483
- } else {
484
- innerMessage = await this.bail.generateWAMessageContent(s, { upload: this.waUploadToServer });
485
- }
486
-
487
- // Wrap dengan messageContextInfo + messageSecret — WAJIB supaya konten bisa ditampilkan
488
- const wrapped = {
489
- groupStatusMessageV2: {
490
- message: {
491
- messageContextInfo: {
492
- messageSecret: secret,
493
- deviceListMetadata: {},
494
- deviceListMetadataVersion: 2
495
- },
496
- ...innerMessage
497
- }
498
- }
665
+ const font = !isMedia
666
+ ? content.font || Math.floor(Math.random() * 9)
667
+ : undefined;
668
+ const textColor = !isMedia
669
+ ? content.textColor || getRandomHexColor()
670
+ : undefined;
671
+ const backgroundColor =
672
+ !isMedia || isAudio
673
+ ? content.backgroundColor || getRandomHexColor()
674
+ : undefined;
675
+ const ptt = isAudio
676
+ ? typeof content.ptt === "boolean"
677
+ ? content.ptt
678
+ : true
679
+ : undefined;
680
+ const { getUrlInfo } = await import("../Utils/link-preview.js");
681
+ const msg = await generateWAMessage(STORIES_JID, messageContent, {
682
+ logger: this.config.logger,
683
+ userJid,
684
+ getUrlInfo: (text) =>
685
+ getUrlInfo(text, {
686
+ thumbnailWidth: this.config.linkPreviewImageThumbnailWidth,
687
+ fetchOpts: { timeout: 3000, ...(this.config.options || {}) },
688
+ logger: this.config.logger,
689
+ uploadImage: this.config.generateHighQualityLinkPreview
690
+ ? this.waUploadToServer
691
+ : undefined,
692
+ }),
693
+ upload: this.waUploadToServer,
694
+ mediaCache: this.config.mediaCache,
695
+ options: this.config.options,
696
+ font,
697
+ textColor,
698
+ backgroundColor,
699
+ ptt,
700
+ });
701
+ await this.relayMessage(STORIES_JID, msg.message, {
702
+ messageId: msg.key.id,
703
+ statusJidList: uniqueUsers,
704
+ additionalNodes: [
705
+ {
706
+ tag: "meta",
707
+ attrs: {},
708
+ content: [
709
+ {
710
+ tag: "mentioned_users",
711
+ attrs: {},
712
+ content: jids.map((jid) => ({
713
+ tag: "to",
714
+ attrs: { jid: jidNormalizedUser(jid) },
715
+ })),
716
+ },
717
+ ],
718
+ },
719
+ ],
720
+ });
721
+ for (const id of jids) {
722
+ try {
723
+ const normalizedId = jidNormalizedUser(id);
724
+ const isPrivate = isPnUser(normalizedId);
725
+ const type = isPrivate
726
+ ? "statusMentionMessage"
727
+ : "groupStatusMentionMessage";
728
+ const protocolMessage = {
729
+ [type]: {
730
+ message: {
731
+ protocolMessage: {
732
+ key: msg.key,
733
+ type: 25,
734
+ },
735
+ },
736
+ },
737
+ messageContextInfo: {
738
+ messageSecret: crypto.randomBytes(32),
739
+ },
499
740
  };
500
-
501
- // Ini bagian yang tadinya hilang: <meta is_vsn2="1"/> baru benar-benar
502
- // terpasang lewat additionalNodes di bawah ini.
503
- const additionalNodes = buildNodes ? buildNodes(jid, wrapped) : [];
504
-
505
- return await this.relayMessage(jid, wrapped, {
506
- messageId: this.bail.generateMessageID(),
507
- additionalNodes
508
- });
509
- }
510
-
511
- /**
512
- * Kirim WhatsApp Status (story) beneran ke `status@broadcast`, lengkap dengan
513
- * statusJidList (siapa aja yang boleh lihat) dan status-mention follow-up
514
- * (biar penerima yang di-mention dapet notif). Mendukung SEMUA tipe media
515
- * (text/image/video/gif via video+gifPlayback/audio) — dipilih otomatis dari
516
- * field yang ada di `content`, sama seperti bawaan generateWAMessage().
517
- *
518
- * jids: campuran nomor pribadi & JID grup — kalau grup, semua member-nya
519
- * otomatis ditambahkan ke daftar penerima status (statusJidList) dan
520
- * masing-masing dikirimi status-mention.
521
- */
522
- async sendStatusWhatsApp(content, jids = []) {
523
- const { authState, groupMetadata, logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, httpRequestOptions, mediaCache, getUrlInfo } = this.utils;
524
- const userJid = jidNormalizedUser(authState.creds.me.id);
525
- const allUsers = new Set([userJid]);
526
- for (const id of jids) {
527
- if (isJidGroup(id)) {
528
- try {
529
- const metadata = await groupMetadata(id);
530
- metadata.participants.forEach(p => allUsers.add(jidNormalizedUser(p.id)));
531
- }
532
- catch (error) {
533
- logger?.error(`Error getting metadata for group ${id}: ${error}`);
534
- }
535
- }
536
- else if (isPnUser(id)) {
537
- allUsers.add(jidNormalizedUser(id));
538
- }
539
- }
540
- const uniqueUsers = Array.from(allUsers);
541
- const getRandomHexColor = () => '#' + Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0');
542
- const isMedia = !!(content.image || content.video || content.audio);
543
- const isAudio = !!content.audio;
544
- const messageContent = { ...content };
545
- if (isMedia && !isAudio) {
546
- if (messageContent.text) {
547
- messageContent.caption = messageContent.text;
548
- delete messageContent.text;
549
- }
550
- delete messageContent.ptt;
551
- delete messageContent.font;
552
- delete messageContent.backgroundColor;
553
- delete messageContent.textColor;
554
- }
555
- if (isAudio) {
556
- delete messageContent.text;
557
- delete messageContent.caption;
558
- delete messageContent.font;
559
- delete messageContent.textColor;
560
- }
561
- const font = !isMedia ? (content.font ?? Math.floor(Math.random() * 9)) : undefined;
562
- const textColor = !isMedia ? (content.textColor || getRandomHexColor()) : undefined;
563
- const backgroundColor = (!isMedia || isAudio) ? (content.backgroundColor || getRandomHexColor()) : undefined;
564
- const ptt = isAudio ? (typeof content.ptt === 'boolean' ? content.ptt : true) : undefined;
565
- const msg = await this.utils.generateWAMessage(STORIES_JID, messageContent, {
566
- logger,
567
- userJid,
568
- getUrlInfo: (text) => getUrlInfo(text, {
569
- thumbnailWidth: linkPreviewImageThumbnailWidth,
570
- fetchOpts: { timeout: 3000, ...(httpRequestOptions || {}) },
571
- logger,
572
- uploadImage: generateHighQualityLinkPreview ? this.waUploadToServer : undefined
573
- }),
574
- upload: this.waUploadToServer,
575
- mediaCache,
576
- options: httpRequestOptions,
577
- font,
578
- textColor,
579
- backgroundColor,
580
- ptt
581
- });
582
- await this.relayMessage(STORIES_JID, msg.message, {
583
- messageId: msg.key.id,
584
- statusJidList: uniqueUsers,
585
- additionalNodes: [
586
- {
587
- tag: 'meta',
588
- attrs: {},
589
- content: [
590
- {
591
- tag: 'mentioned_users',
592
- attrs: {},
593
- content: jids.map(jid => ({ tag: 'to', attrs: { jid: jidNormalizedUser(jid) } }))
594
- }
595
- ]
596
- }
597
- ]
741
+ const statusMsg = await generateWAMessageFromContent(
742
+ normalizedId,
743
+ protocolMessage,
744
+ {
745
+ userJid: jidNormalizedUser(
746
+ this.sock.authState?.creds?.me?.id || "",
747
+ ),
748
+ },
749
+ );
750
+ await this.relayMessage(normalizedId, statusMsg.message, {
751
+ additionalNodes: [
752
+ {
753
+ tag: "meta",
754
+ attrs: isPrivate
755
+ ? { is_status_mention: "true" }
756
+ : { is_group_status_mention: "true" },
757
+ },
758
+ ],
598
759
  });
599
- for (const id of jids) {
600
- try {
601
- const normalizedId = jidNormalizedUser(id);
602
- const isPrivate = isPnUser(normalizedId);
603
- const type = isPrivate ? 'statusMentionMessage' : 'groupStatusMentionMessage';
604
- const protocolMessage = {
605
- [type]: { message: { protocolMessage: { key: msg.key, type: 25 } } },
606
- messageContextInfo: { messageSecret: randomBytes(32) }
607
- };
608
- const statusMsg = await this.utils.generateWAMessageFromContent(normalizedId, protocolMessage, {
609
- userJid: jidNormalizedUser(authState?.creds?.me?.id || '')
610
- });
611
- await this.relayMessage(normalizedId, statusMsg.message, {
612
- additionalNodes: [
613
- {
614
- tag: 'meta',
615
- attrs: isPrivate ? { is_status_mention: 'true' } : { is_group_status_mention: 'true' }
616
- }
617
- ]
618
- });
619
- await delay(2000);
620
- }
621
- catch (error) {
622
- logger?.error(`Error sending to ${id}: ${error}`);
623
- }
624
- }
625
- return msg;
760
+ await delay(2000);
761
+ } catch (error) {
762
+ this.config.logger.error(`Error sending to ${id}: ${error}`);
763
+ }
626
764
  }
765
+ return msg;
766
+ }
627
767
  }
628
-
629
- export default ExtendedMessageBuilder;
768
+ //# sourceMappingURL=dugong.js.map