@badzz88/baileys 8.3.0 → 8.4.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 (213) hide show
  1. package/README.md +27 -27
  2. package/WAProto/GenerateStatics.sh +3 -0
  3. package/WAProto/WAProto.proto +6902 -0
  4. package/WAProto/fix-import.js +29 -0
  5. package/WAProto/fix-imports.js +85 -0
  6. package/WAProto/index.d.ts +79257 -0
  7. package/WAProto/index.js +204305 -131020
  8. package/engine-requirements.js +3 -4
  9. package/lib/Defaults/baileys-version.json +1 -1
  10. package/lib/Defaults/index.js +119 -136
  11. package/lib/Signal/Group/ciphertext-message.js +2 -5
  12. package/lib/Signal/Group/group-session-builder.js +7 -41
  13. package/lib/Signal/Group/group_cipher.js +37 -51
  14. package/lib/Signal/Group/index.js +12 -57
  15. package/lib/Signal/Group/keyhelper.js +7 -44
  16. package/lib/Signal/Group/sender-chain-key.js +7 -15
  17. package/lib/Signal/Group/sender-key-distribution-message.js +8 -11
  18. package/lib/Signal/Group/sender-key-message.js +9 -12
  19. package/lib/Signal/Group/sender-key-name.js +2 -5
  20. package/lib/Signal/Group/sender-key-record.js +9 -21
  21. package/lib/Signal/Group/sender-key-state.js +27 -42
  22. package/lib/Signal/Group/sender-message-key.js +4 -7
  23. package/lib/Signal/libsignal.js +347 -90
  24. package/lib/Signal/lid-mapping.js +277 -0
  25. package/lib/Socket/Client/index.js +3 -19
  26. package/lib/Socket/Client/types.js +11 -0
  27. package/lib/Socket/Client/websocket.js +54 -0
  28. package/lib/Socket/business.js +162 -43
  29. package/lib/Socket/chats.js +627 -404
  30. package/lib/Socket/communities.js +431 -0
  31. package/lib/Socket/community.js +392 -0
  32. package/lib/Socket/dugong.js +161 -8
  33. package/lib/Socket/groups.js +154 -160
  34. package/lib/Socket/index.js +11 -10
  35. package/lib/Socket/luxu.js +387 -0
  36. package/lib/Socket/messages-recv.js +1421 -615
  37. package/lib/Socket/messages-send.js +1150 -624
  38. package/lib/Socket/mex.js +42 -0
  39. package/lib/Socket/newsletter.js +139 -314
  40. package/lib/Socket/registration.js +2 -1
  41. package/lib/Socket/socket.js +544 -242
  42. package/lib/Store/index.js +10 -10
  43. package/lib/Store/keyed-db.js +108 -0
  44. package/lib/Store/make-cache-manager-store.js +43 -41
  45. package/lib/Store/make-in-memory-store.js +112 -341
  46. package/lib/Store/make-ordered-dictionary.js +14 -20
  47. package/lib/Store/object-repository.js +11 -6
  48. package/lib/Types/Auth.js +2 -2
  49. package/lib/Types/Bussines.js +2 -0
  50. package/lib/Types/Call.js +2 -2
  51. package/lib/Types/Chat.js +8 -4
  52. package/lib/Types/Contact.js +2 -2
  53. package/lib/Types/Events.js +2 -2
  54. package/lib/Types/GroupMetadata.js +2 -2
  55. package/lib/Types/Label.js +3 -5
  56. package/lib/Types/LabelAssociation.js +3 -5
  57. package/lib/Types/Message.js +11 -9
  58. package/lib/Types/Mex.js +37 -0
  59. package/lib/Types/Product.js +2 -2
  60. package/lib/Types/Signal.js +2 -2
  61. package/lib/Types/Socket.js +3 -2
  62. package/lib/Types/State.js +56 -2
  63. package/lib/Types/USync.js +2 -2
  64. package/lib/Types/index.js +15 -31
  65. package/lib/Utils/auth-utils.js +239 -143
  66. package/lib/Utils/browser-utils.js +48 -0
  67. package/lib/Utils/business.js +66 -69
  68. package/lib/Utils/chat-utils.js +396 -253
  69. package/lib/Utils/companion-reg-client-utils.js +35 -0
  70. package/lib/Utils/crypto.js +57 -90
  71. package/lib/Utils/decode-wa-message.js +236 -84
  72. package/lib/Utils/event-buffer.js +185 -77
  73. package/lib/Utils/generics.js +188 -283
  74. package/lib/Utils/history.js +93 -55
  75. package/lib/Utils/identity-change-handler.js +50 -0
  76. package/lib/Utils/index.js +23 -33
  77. package/lib/Utils/link-preview.js +16 -24
  78. package/lib/Utils/logger.js +3 -7
  79. package/lib/Utils/lt-hash.js +3 -46
  80. package/lib/Utils/make-mutex.js +24 -34
  81. package/lib/Utils/message-composer.js +273 -0
  82. package/lib/Utils/message-retry-manager.js +265 -0
  83. package/lib/Utils/messages-media.js +451 -482
  84. package/lib/Utils/messages.js +796 -359
  85. package/lib/Utils/noise-handler.js +145 -99
  86. package/lib/Utils/offline-node-processor.js +40 -0
  87. package/lib/Utils/pre-key-manager.js +106 -0
  88. package/lib/Utils/process-message.js +459 -150
  89. package/lib/Utils/reporting-utils.js +258 -0
  90. package/lib/Utils/signal.js +120 -72
  91. package/lib/Utils/stanza-ack.js +38 -0
  92. package/lib/Utils/sync-action-utils.js +49 -0
  93. package/lib/Utils/tc-token-utils.js +163 -0
  94. package/lib/Utils/use-multi-file-auth-state.js +29 -27
  95. package/lib/Utils/validate-connection.js +73 -99
  96. package/lib/WABinary/constants.js +1281 -20
  97. package/lib/WABinary/decode.js +52 -42
  98. package/lib/WABinary/encode.js +110 -155
  99. package/lib/WABinary/generic-utils.js +55 -49
  100. package/lib/WABinary/index.js +6 -21
  101. package/lib/WABinary/jid-utils.js +76 -40
  102. package/lib/WABinary/types.js +2 -2
  103. package/lib/WAM/BinaryInfo.js +2 -5
  104. package/lib/WAM/constants.js +19071 -11568
  105. package/lib/WAM/encode.js +17 -22
  106. package/lib/WAM/index.js +4 -19
  107. package/lib/WAUSync/Protocols/USyncContactProtocol.js +33 -13
  108. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +11 -14
  109. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -12
  110. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +9 -13
  111. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
  112. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +20 -22
  113. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +13 -8
  114. package/lib/WAUSync/Protocols/index.js +6 -20
  115. package/lib/WAUSync/USyncQuery.js +44 -35
  116. package/lib/WAUSync/USyncUser.js +10 -5
  117. package/lib/WAUSync/index.js +4 -19
  118. package/lib/index.js +39 -53
  119. package/package.json +134 -101
  120. package/lib/Defaults/index.d.ts +0 -53
  121. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  122. package/lib/Signal/Group/group-session-builder.d.ts +0 -14
  123. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  124. package/lib/Signal/Group/index.d.ts +0 -11
  125. package/lib/Signal/Group/keyhelper.d.ts +0 -10
  126. package/lib/Signal/Group/queue-job.d.ts +0 -1
  127. package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
  128. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
  129. package/lib/Signal/Group/sender-key-message.d.ts +0 -18
  130. package/lib/Signal/Group/sender-key-name.d.ts +0 -17
  131. package/lib/Signal/Group/sender-key-record.d.ts +0 -30
  132. package/lib/Signal/Group/sender-key-state.d.ts +0 -38
  133. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  134. package/lib/Signal/libsignal.d.ts +0 -3
  135. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
  136. package/lib/Socket/Client/index.d.ts +0 -3
  137. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  138. package/lib/Socket/Client/web-socket-client.d.ts +0 -12
  139. package/lib/Socket/business.d.ts +0 -171
  140. package/lib/Socket/chats.d.ts +0 -267
  141. package/lib/Socket/dugong.d.ts +0 -254
  142. package/lib/Socket/groups.d.ts +0 -115
  143. package/lib/Socket/index.d.ts +0 -173
  144. package/lib/Socket/messages-recv.d.ts +0 -161
  145. package/lib/Socket/messages-send.d.ts +0 -149
  146. package/lib/Socket/newsletter.d.ts +0 -134
  147. package/lib/Socket/registration.d.ts +0 -267
  148. package/lib/Socket/socket.d.ts +0 -43
  149. package/lib/Socket/usync.d.ts +0 -36
  150. package/lib/Store/index.d.ts +0 -3
  151. package/lib/Store/make-cache-manager-store.d.ts +0 -13
  152. package/lib/Store/make-in-memory-store.d.ts +0 -118
  153. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  154. package/lib/Store/object-repository.d.ts +0 -10
  155. package/lib/Types/Auth.d.ts +0 -110
  156. package/lib/Types/Call.d.ts +0 -13
  157. package/lib/Types/Chat.d.ts +0 -102
  158. package/lib/Types/Contact.d.ts +0 -19
  159. package/lib/Types/Events.d.ts +0 -157
  160. package/lib/Types/GroupMetadata.d.ts +0 -55
  161. package/lib/Types/Label.d.ts +0 -35
  162. package/lib/Types/LabelAssociation.d.ts +0 -29
  163. package/lib/Types/Message.d.ts +0 -273
  164. package/lib/Types/Newsletter.d.ts +0 -103
  165. package/lib/Types/Product.d.ts +0 -78
  166. package/lib/Types/Signal.d.ts +0 -57
  167. package/lib/Types/Socket.d.ts +0 -111
  168. package/lib/Types/State.d.ts +0 -27
  169. package/lib/Types/USync.d.ts +0 -25
  170. package/lib/Types/index.d.ts +0 -57
  171. package/lib/Utils/auth-utils.d.ts +0 -18
  172. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  173. package/lib/Utils/business.d.ts +0 -22
  174. package/lib/Utils/chat-utils.d.ts +0 -71
  175. package/lib/Utils/crypto.d.ts +0 -41
  176. package/lib/Utils/decode-wa-message.d.ts +0 -19
  177. package/lib/Utils/event-buffer.d.ts +0 -35
  178. package/lib/Utils/generics.d.ts +0 -92
  179. package/lib/Utils/history.d.ts +0 -15
  180. package/lib/Utils/index.d.ts +0 -17
  181. package/lib/Utils/link-preview.d.ts +0 -21
  182. package/lib/Utils/logger.d.ts +0 -4
  183. package/lib/Utils/lt-hash.d.ts +0 -12
  184. package/lib/Utils/make-mutex.d.ts +0 -7
  185. package/lib/Utils/messages-media.d.ts +0 -116
  186. package/lib/Utils/messages.d.ts +0 -77
  187. package/lib/Utils/noise-handler.d.ts +0 -21
  188. package/lib/Utils/process-message.d.ts +0 -41
  189. package/lib/Utils/signal.d.ts +0 -32
  190. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  191. package/lib/Utils/validate-connection.d.ts +0 -11
  192. package/lib/WABinary/constants.d.ts +0 -30
  193. package/lib/WABinary/decode.d.ts +0 -7
  194. package/lib/WABinary/encode.d.ts +0 -3
  195. package/lib/WABinary/generic-utils.d.ts +0 -17
  196. package/lib/WABinary/index.d.ts +0 -5
  197. package/lib/WABinary/jid-utils.d.ts +0 -31
  198. package/lib/WABinary/types.d.ts +0 -18
  199. package/lib/WAM/BinaryInfo.d.ts +0 -17
  200. package/lib/WAM/constants.d.ts +0 -38
  201. package/lib/WAM/encode.d.ts +0 -3
  202. package/lib/WAM/index.d.ts +0 -3
  203. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  204. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  205. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  206. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  207. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
  208. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
  209. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  210. package/lib/WAUSync/USyncQuery.d.ts +0 -28
  211. package/lib/WAUSync/USyncUser.d.ts +0 -12
  212. package/lib/WAUSync/index.d.ts +0 -3
  213. package/lib/index.d.ts +0 -12
@@ -0,0 +1,387 @@
1
+ import { proto } from '../../WAProto/index.js'
2
+ import * as Utils from '../Utils/index.js'
3
+ import crypto from 'crypto'
4
+
5
+ export default class imup {
6
+ constructor(utils, waUploadToServer, relayMessageFn) {
7
+ this.utils = utils
8
+ this.relayMessage = relayMessageFn
9
+ this.waUploadToServer = waUploadToServer
10
+ }
11
+
12
+ detectType(content) {
13
+ if (content.requestPaymentMessage) return 'PAYMENT'
14
+ if (content.productMessage) return 'PRODUCT'
15
+ if (content.albumMessage) return 'ALBUM'
16
+ if (content.eventMessage) return 'EVENT'
17
+ if (content.pollResultMessage) return 'POLL_RESULT'
18
+ if (content.orderMessage) return 'ORDER'
19
+ if (content.groupStatus) return 'GROUP_STATUS'
20
+ if (content.groupLabel) return 'GROUP_LABEL'
21
+ return null
22
+ }
23
+
24
+ async handlePayment(content, quoted) {
25
+ const data = content.requestPaymentMessage
26
+ let notes = {}
27
+
28
+ if (data.sticker?.stickerMessage) {
29
+ notes = {
30
+ stickerMessage: {
31
+ ...data.sticker.stickerMessage,
32
+ contextInfo: {
33
+ stanzaId: quoted?.key?.id,
34
+ participant: quoted?.key?.participant || content.sender,
35
+ quotedMessage: quoted?.message
36
+ }
37
+ }
38
+ }
39
+ } else if (data.note) {
40
+ notes = {
41
+ extendedTextMessage: {
42
+ text: data.note,
43
+ contextInfo: {
44
+ stanzaId: quoted?.key?.id,
45
+ participant: quoted?.key?.participant || content.sender,
46
+ quotedMessage: quoted?.message
47
+ }
48
+ }
49
+ }
50
+ }
51
+
52
+ return {
53
+ requestPaymentMessage: proto.Message.RequestPaymentMessage.fromObject({
54
+ expiryTimestamp: data.expiry || 0,
55
+ amount1000: data.amount || 0,
56
+ currencyCodeIso4217: data.currency || "IDR",
57
+ requestFrom: data.from || "0@s.whatsapp.net",
58
+ noteMessage: notes,
59
+ background: data.background?? {
60
+ id: "DEFAULT",
61
+ placeholderArgb: 0xFFF0F0F0
62
+ }
63
+ })
64
+ }
65
+ }
66
+
67
+ async handleProduct(content, jid, quoted) {
68
+ const {
69
+ title,
70
+ description,
71
+ thumbnail,
72
+ productId,
73
+ retailerId,
74
+ url,
75
+ body = "",
76
+ footer = "",
77
+ buttons = [],
78
+ priceAmount1000 = null,
79
+ currencyCode = "IDR"
80
+ } = content.productMessage
81
+
82
+ let productImage
83
+
84
+ if (Buffer.isBuffer(thumbnail)) {
85
+ const { imageMessage } = await this.utils.generateWAMessageContent(
86
+ { image: thumbnail },
87
+ { upload: this.waUploadToServer }
88
+ )
89
+ productImage = imageMessage
90
+ } else if (typeof thumbnail === 'object' && thumbnail.url) {
91
+ const { imageMessage } = await this.utils.generateWAMessageContent(
92
+ { image: { url: thumbnail.url } },
93
+ { upload: this.waUploadToServer }
94
+ )
95
+ productImage = imageMessage
96
+ }
97
+
98
+ return {
99
+ viewOnceMessage: {
100
+ message: {
101
+ interactiveMessage: {
102
+ body: { text: body },
103
+ footer: { text: footer },
104
+ header: {
105
+ title,
106
+ hasMediaAttachment: true,
107
+ productMessage: {
108
+ product: {
109
+ productImage,
110
+ productId,
111
+ title,
112
+ description,
113
+ currencyCode,
114
+ priceAmount1000,
115
+ retailerId,
116
+ url,
117
+ productImageCount: 1
118
+ },
119
+ businessOwnerJid: "0@s.whatsapp.net"
120
+ }
121
+ },
122
+ nativeFlowMessage: { buttons }
123
+ }
124
+ }
125
+ }
126
+ }
127
+ }
128
+
129
+ async handleAlbum(content, jid, quoted) {
130
+ const array = content.albumMessage
131
+ const album = await this.utils.generateWAMessageFromContent(jid, {
132
+ messageContextInfo: {
133
+ messageSecret: crypto.randomBytes(32),
134
+ },
135
+ albumMessage: {
136
+ expectedImageCount: array.filter((a) => a.hasOwnProperty("image")).length,
137
+ expectedVideoCount: array.filter((a) => a.hasOwnProperty("video")).length,
138
+ },
139
+ }, {
140
+ userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
141
+ quoted,
142
+ upload: this.waUploadToServer
143
+ })
144
+
145
+ await this.relayMessage(jid, album.message, {
146
+ messageId: album.key.id,
147
+ })
148
+
149
+ for (let content of array) {
150
+ const img = await this.utils.generateWAMessage(jid, content, {
151
+ upload: this.waUploadToServer,
152
+ })
153
+
154
+ img.message.messageContextInfo = {
155
+ messageSecret: crypto.randomBytes(32),
156
+ messageAssociation: {
157
+ associationType: 1,
158
+ parentMessageKey: album.key,
159
+ },
160
+ participant: "0@s.whatsapp.net",
161
+ remoteJid: "status@broadcast",
162
+ forwardingScore: 99999,
163
+ isForwarded: true,
164
+ mentionedJid: [jid],
165
+ starred: true,
166
+ labels: ["Y", "Important"],
167
+ isHighlighted: true,
168
+ businessMessageForwardInfo: {
169
+ businessOwnerJid: jid,
170
+ },
171
+ dataSharingContext: {
172
+ showMmDisclosure: true,
173
+ },
174
+ }
175
+
176
+ img.message.forwardedNewsletterMessageInfo = {
177
+ newsletterJid: "0@newsletter",
178
+ serverMessageId: 1,
179
+ newsletterName: `WhatsApp`,
180
+ contentType: 1,
181
+ timestamp: new Date().toISOString(),
182
+ senderName: "badzz-xyz",
183
+ contentType: "UPDATE_CARD",
184
+ priority: "high",
185
+ status: "sent",
186
+ }
187
+
188
+ img.message.disappearingMode = {
189
+ initiator: 3,
190
+ trigger: 4,
191
+ initiatorDeviceJid: jid,
192
+ initiatedByExternalService: true,
193
+ initiatedByUserDevice: true,
194
+ initiatedBySystem: true,
195
+ initiatedByServer: true,
196
+ initiatedByAdmin: true,
197
+ initiatedByUser: true,
198
+ initiatedByApp: true,
199
+ initiatedByBot: true,
200
+ initiatedByMe: true,
201
+ }
202
+
203
+ await this.relayMessage(jid, img.message, {
204
+ messageId: img.key.id,
205
+ quoted: {
206
+ key: {
207
+ remoteJid: album.key.remoteJid,
208
+ id: album.key.id,
209
+ fromMe: true,
210
+ participant: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
211
+ },
212
+ message: album.message,
213
+ },
214
+ })
215
+ }
216
+ return album
217
+ }
218
+
219
+ async handleEvent(content, jid, quoted) {
220
+ const eventData = content.eventMessage
221
+
222
+ const msg = await this.utils.generateWAMessageFromContent(jid, {
223
+ viewOnceMessage: {
224
+ message: {
225
+ messageContextInfo: {
226
+ deviceListMetadata: {},
227
+ deviceListMetadataVersion: 2,
228
+ messageSecret: crypto.randomBytes(32),
229
+ supportPayload: JSON.stringify({
230
+ version: 2,
231
+ is_ai_message: true,
232
+ should_show_system_message: true,
233
+ ticket_id: crypto.randomBytes(16).toString('hex')
234
+ })
235
+ },
236
+ eventMessage: {
237
+ contextInfo: {
238
+ mentionedJid: [jid],
239
+ participant: jid,
240
+ remoteJid: "status@broadcast",
241
+ forwardedNewsletterMessageInfo: {
242
+ newsletterName: "D | 7eppeli-Exloration",
243
+ newsletterJid: "120363421563597486@newsletter",
244
+ serverMessageId: 1
245
+ }
246
+ },
247
+ isCanceled: eventData.isCanceled || false,
248
+ name: eventData.name,
249
+ description: eventData.description,
250
+ location: eventData.location || {
251
+ degreesLatitude: 0,
252
+ degreesLongitude: 0,
253
+ name: "Location"
254
+ },
255
+ joinLink: eventData.joinLink || '',
256
+ startTime: typeof eventData.startTime === 'string'? parseInt(eventData.startTime) : eventData.startTime || Date.now(),
257
+ endTime: typeof eventData.endTime === 'string'? parseInt(eventData.endTime) : eventData.endTime || Date.now() + 3600000,
258
+ extraGuestsAllowed: eventData.extraGuestsAllowed!== false
259
+ }
260
+ }
261
+ }
262
+ }, { quoted })
263
+
264
+ await this.relayMessage(jid, msg.message, {
265
+ messageId: msg.key.id
266
+ })
267
+ return msg
268
+ }
269
+
270
+ async handlePollResult(content, jid, quoted) {
271
+ const pollData = content.pollResultMessage
272
+ const msg = await this.utils.generateWAMessageFromContent(jid, {
273
+ pollResultSnapshotMessage: {
274
+ name: pollData.name,
275
+ pollVotes: pollData.pollVotes.map(vote => ({
276
+ optionName: vote.optionName,
277
+ optionVoteCount: typeof vote.optionVoteCount === 'number'
278
+ ? vote.optionVoteCount.toString()
279
+ : vote.optionVoteCount
280
+ })),
281
+ contextInfo: {
282
+ isForwarded: true,
283
+ forwardingScore: 1,
284
+ forwardedNewsletterMessageInfo: {
285
+ newsletterName: pollData.newsletter.newsletterName || "120363399602691477@newsletter",
286
+ newsletterJid: pollData.newsletter.newsletterJid || "Newsletter",
287
+ serverMessageId: 1000,
288
+ contentType: "UPDATE"
289
+ }
290
+ }
291
+ }
292
+ }, {
293
+ userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
294
+ quoted
295
+ })
296
+
297
+ await this.relayMessage(jid, msg.message, {
298
+ messageId: msg.key.id
299
+ })
300
+
301
+ return msg
302
+ }
303
+
304
+ async handleOrderMessage(content, jid, quoted) {
305
+ const orderData = content.orderMessage
306
+
307
+ const Haha = await this.utils.generateWAMessageFromContent(jid, {
308
+ orderMessage: {
309
+ orderId: "7EPPELI25022008",
310
+ thumbnail: orderData.thumbnail || null,
311
+ itemCount: orderData.itemCount || 0,
312
+ status: "ACCEPTED",
313
+ surface: "CATALOG",
314
+ message: orderData.message,
315
+ orderTitle: orderData.orderTitle,
316
+ sellerJid: "0@whatsapp.net",
317
+ token: "7EPPELI_EXAMPLE_TOKEN",
318
+ totalAmount1000: orderData.totalAmount1000 || 0,
319
+ totalCurrencyCode: orderData.totalCurrencyCode || "IDR",
320
+ messageVersion: 2
321
+ }
322
+ }, { quoted: quoted })
323
+
324
+ await this.relayMessage(jid, Haha.message, {})
325
+ return Haha
326
+ }
327
+
328
+ async handleGroupStory(content, jid, quoted) {
329
+ const storyData = content.groupStatus
330
+ let messageContent
331
+
332
+ if (storyData.message) {
333
+ messageContent = storyData
334
+ } else {
335
+ if (typeof this.utils?.generateWAMessageContent === "function") {
336
+ messageContent = await this.utils.generateWAMessageContent(storyData, {
337
+ upload: this.waUploadToServer
338
+ })
339
+ } else {
340
+ messageContent = await Utils.generateWAMessageContent(storyData, {
341
+ upload: this.waUploadToServer
342
+ })
343
+ }
344
+ }
345
+
346
+ let msg = {
347
+ message: {
348
+ groupStatusMessageV2: {
349
+ message: messageContent.message || messageContent
350
+ }
351
+ }
352
+ }
353
+
354
+ return await this.relayMessage(jid, msg.message, {
355
+ messageId: this.utils.generateMessageID()
356
+ })
357
+ }
358
+
359
+ async handleGbLabel(content, jid) {
360
+ const x = content.groupLabel
361
+ if (!jid.endsWith('@g.us')) {
362
+ throw new Error('group required!')
363
+ }
364
+
365
+ const msg = this.utils.generateWAMessageFromContent(jid, {
366
+ protocolMessage: {
367
+ type: "GROUP_MEMBER_LABEL_CHANGE",
368
+ memberLabel: {
369
+ label: x.labelText.slice(0, 30)
370
+ }
371
+ }
372
+ }, {})
373
+
374
+ await this.relayMessage(jid, msg.message, {
375
+ additionalNodes: [
376
+ {
377
+ tag: 'meta',
378
+ attrs: {
379
+ tag_reason: 'user_update',
380
+ appdata: 'member_tag'
381
+ },
382
+ content: undefined
383
+ }
384
+ ]
385
+ })
386
+ }
387
+ }