@fazzcode/baileys 0.1.7 → 2.4.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.
- package/LICENSE +21 -0
- package/README.MD +1420 -103
- package/WAProto/WAProto.proto +5311 -0
- package/WAProto/index.js +83385 -119575
- package/lib/Defaults/index.js +117 -124
- package/lib/KeyDB/BinarySearch.js +20 -0
- package/lib/KeyDB/KeyedDB.js +167 -0
- package/lib/KeyDB/index.js +4 -0
- package/lib/Signal/Group/ciphertext-message.js +12 -14
- package/lib/Signal/Group/group-session-builder.js +10 -42
- package/lib/Signal/Group/group_cipher.js +75 -87
- package/lib/Signal/Group/index.js +13 -57
- package/lib/Signal/Group/keyhelper.js +17 -52
- package/lib/Signal/Group/sender-chain-key.js +27 -33
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -63
- package/lib/Signal/Group/sender-key-message.js +65 -66
- package/lib/Signal/Group/sender-key-name.js +45 -44
- package/lib/Signal/Group/sender-key-record.js +39 -49
- package/lib/Signal/Group/sender-key-state.js +80 -93
- package/lib/Signal/Group/sender-message-key.js +27 -28
- package/lib/Signal/libsignal.js +313 -163
- package/lib/Signal/lid-mapping.js +155 -0
- package/lib/Socket/Client/index.js +4 -19
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +52 -0
- package/lib/Socket/business.js +359 -242
- package/lib/Socket/chats.js +851 -830
- package/lib/Socket/communities.js +413 -0
- package/lib/Socket/groups.js +304 -309
- package/lib/Socket/index.js +15 -9
- package/lib/Socket/messages-recv.js +1107 -1054
- package/lib/Socket/messages-send.js +709 -414
- package/lib/Socket/mex.js +45 -0
- package/lib/Socket/newsletter.js +232 -318
- package/lib/Socket/socket.js +789 -599
- package/lib/Store/index.js +6 -10
- package/lib/Store/make-cache-manager-store.js +73 -81
- package/lib/Store/make-in-memory-store.js +286 -423
- package/lib/Store/make-ordered-dictionary.js +77 -79
- package/lib/Store/object-repository.js +24 -26
- package/lib/Types/Auth.js +3 -2
- package/lib/Types/Bussines.js +3 -0
- package/lib/Types/Call.js +3 -2
- package/lib/Types/Chat.js +9 -4
- package/lib/Types/Contact.js +3 -2
- package/lib/Types/Events.js +3 -2
- package/lib/Types/GroupMetadata.js +3 -2
- package/lib/Types/Label.js +24 -26
- package/lib/Types/LabelAssociation.js +6 -8
- package/lib/Types/Message.js +12 -9
- package/lib/Types/Newsletter.js +31 -30
- package/lib/Types/Newsletter.js.bak +33 -0
- package/lib/Types/Product.js +3 -2
- package/lib/Types/Signal.js +3 -2
- package/lib/Types/Socket.js +4 -2
- package/lib/Types/State.js +11 -2
- package/lib/Types/USync.js +3 -2
- package/lib/Types/index.js +27 -41
- package/lib/Utils/auth-utils.js +211 -198
- package/lib/Utils/baileys-event-stream.js +42 -61
- package/lib/Utils/browser-utils.js +25 -0
- package/lib/Utils/business.js +213 -214
- package/lib/Utils/chat-utils.js +710 -687
- package/lib/Utils/crypto.js +112 -133
- package/lib/Utils/decode-wa-message.js +252 -183
- package/lib/Utils/event-buffer.js +510 -496
- package/lib/Utils/generics.js +328 -356
- package/lib/Utils/history.js +83 -92
- package/lib/Utils/index.js +21 -33
- package/lib/Utils/link-preview.js +71 -83
- package/lib/Utils/logger.js +5 -7
- package/lib/Utils/lt-hash.js +40 -46
- package/lib/Utils/make-mutex.js +34 -41
- package/lib/Utils/message-retry-manager.js +113 -0
- package/lib/Utils/messages-media.js +548 -678
- package/lib/Utils/messages.js +352 -249
- package/lib/Utils/noise-handler.js +138 -149
- package/lib/Utils/pre-key-manager.js +85 -0
- package/lib/Utils/process-message.js +323 -303
- package/lib/Utils/signal.js +148 -138
- package/lib/Utils/use-multi-file-auth-state.js +98 -67
- package/lib/Utils/validate-connection.js +183 -188
- package/lib/WABinary/constants.js +1298 -35
- package/lib/WABinary/decode.js +237 -249
- package/lib/WABinary/encode.js +208 -218
- package/lib/WABinary/generic-utils.js +53 -57
- package/lib/WABinary/index.js +7 -21
- package/lib/WABinary/jid-utils.js +89 -58
- package/lib/WABinary/types.js +3 -2
- package/lib/WAM/BinaryInfo.js +10 -12
- package/lib/WAM/constants.js +22851 -15348
- package/lib/WAM/encode.js +135 -136
- package/lib/WAM/index.js +5 -19
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +28 -30
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +49 -53
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -28
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +36 -39
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -50
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +26 -20
- package/lib/WAUSync/Protocols/index.js +6 -20
- package/lib/WAUSync/USyncQuery.js +86 -85
- package/lib/WAUSync/USyncUser.js +23 -25
- package/lib/WAUSync/index.js +5 -19
- package/lib/index.js +32 -34
- package/package.json +99 -105
- package/engine-requirements.js +0 -10
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/index.d.ts +0 -53
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/group-session-builder.d.ts +0 -14
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts +0 -10
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
- package/lib/Signal/Group/sender-key-message.d.ts +0 -18
- package/lib/Signal/Group/sender-key-name.d.ts +0 -17
- package/lib/Signal/Group/sender-key-record.d.ts +0 -30
- package/lib/Signal/Group/sender-key-state.d.ts +0 -38
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Signal/libsignal.d.ts +0 -3
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/index.d.ts +0 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.d.ts +0 -12
- package/lib/Socket/Client/web-socket-client.js +0 -62
- package/lib/Socket/business.d.ts +0 -171
- package/lib/Socket/chats.d.ts +0 -80
- package/lib/Socket/dugong.d.ts +0 -219
- package/lib/Socket/dugong.js +0 -441
- package/lib/Socket/groups.d.ts +0 -115
- package/lib/Socket/index.d.ts +0 -173
- package/lib/Socket/messages-recv.d.ts +0 -161
- package/lib/Socket/messages-send.d.ts +0 -149
- package/lib/Socket/newsletter.d.ts +0 -134
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/socket.d.ts +0 -43
- package/lib/Socket/usync.d.ts +0 -36
- package/lib/Socket/usync.js +0 -70
- package/lib/Store/index.d.ts +0 -3
- package/lib/Store/make-cache-manager-store.d.ts +0 -13
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -110
- package/lib/Types/Call.d.ts +0 -13
- package/lib/Types/Chat.d.ts +0 -102
- package/lib/Types/Contact.d.ts +0 -19
- package/lib/Types/Events.d.ts +0 -157
- package/lib/Types/GroupMetadata.d.ts +0 -55
- package/lib/Types/Label.d.ts +0 -35
- package/lib/Types/LabelAssociation.d.ts +0 -29
- package/lib/Types/Message.d.ts +0 -273
- package/lib/Types/Newsletter.d.ts +0 -92
- package/lib/Types/Product.d.ts +0 -78
- package/lib/Types/Signal.d.ts +0 -57
- package/lib/Types/Socket.d.ts +0 -111
- package/lib/Types/State.d.ts +0 -27
- package/lib/Types/USync.d.ts +0 -25
- package/lib/Types/index.d.ts +0 -57
- package/lib/Utils/auth-utils.d.ts +0 -18
- package/lib/Utils/baileys-event-stream.d.ts +0 -16
- package/lib/Utils/business.d.ts +0 -22
- package/lib/Utils/chat-utils.d.ts +0 -71
- package/lib/Utils/crypto.d.ts +0 -41
- package/lib/Utils/decode-wa-message.d.ts +0 -19
- package/lib/Utils/event-buffer.d.ts +0 -35
- package/lib/Utils/generics.d.ts +0 -92
- package/lib/Utils/history.d.ts +0 -15
- package/lib/Utils/index.d.ts +0 -17
- package/lib/Utils/link-preview.d.ts +0 -21
- package/lib/Utils/logger.d.ts +0 -4
- package/lib/Utils/lt-hash.d.ts +0 -12
- package/lib/Utils/make-mutex.d.ts +0 -7
- package/lib/Utils/messages-media.d.ts +0 -116
- package/lib/Utils/messages.d.ts +0 -77
- package/lib/Utils/noise-handler.d.ts +0 -21
- package/lib/Utils/process-message.d.ts +0 -41
- package/lib/Utils/signal.d.ts +0 -32
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
- package/lib/Utils/validate-connection.d.ts +0 -11
- package/lib/WABinary/constants.d.ts +0 -27
- package/lib/WABinary/decode.d.ts +0 -7
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/generic-utils.d.ts +0 -16
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -31
- package/lib/WABinary/types.d.ts +0 -18
- package/lib/WAM/BinaryInfo.d.ts +0 -17
- package/lib/WAM/constants.d.ts +0 -38
- package/lib/WAM/encode.d.ts +0 -3
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
- package/lib/WAUSync/Protocols/index.d.ts +0 -4
- package/lib/WAUSync/USyncQuery.d.ts +0 -28
- package/lib/WAUSync/USyncUser.d.ts +0 -12
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/index.d.ts +0 -12
package/lib/Socket/dugong.d.ts
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
// dugong.d.ts
|
|
2
|
-
import { proto } from '../../WAProto';
|
|
3
|
-
|
|
4
|
-
declare namespace kikyy {
|
|
5
|
-
interface MediaUploadOptions {
|
|
6
|
-
fileEncSha256?: Buffer;
|
|
7
|
-
mediaType?: string;
|
|
8
|
-
newsletter?: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type WAMediaUploadFunction = (
|
|
12
|
-
stream: Buffer | NodeJS.ReadableStream,
|
|
13
|
-
options?: MediaUploadOptions
|
|
14
|
-
) => Promise<{ url: string; directPath: string }>;
|
|
15
|
-
|
|
16
|
-
interface WAMessageContentGenerationOptions {
|
|
17
|
-
upload?: WAMediaUploadFunction;
|
|
18
|
-
mediaCache?: any;
|
|
19
|
-
options?: any;
|
|
20
|
-
logger?: any;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface StickerMessage {
|
|
24
|
-
url: string;
|
|
25
|
-
fileSha256: Buffer | string;
|
|
26
|
-
fileEncSha256: Buffer | string;
|
|
27
|
-
mediaKey: Buffer | string;
|
|
28
|
-
mimetype: string;
|
|
29
|
-
directPath: string;
|
|
30
|
-
fileLength: number | string;
|
|
31
|
-
mediaKeyTimestamp: number | string;
|
|
32
|
-
isAnimated?: boolean;
|
|
33
|
-
stickerSentTs?: number | string;
|
|
34
|
-
isAvatar?: boolean;
|
|
35
|
-
isAiSticker?: boolean;
|
|
36
|
-
isLottie?: boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface PaymentMessage {
|
|
40
|
-
amount: number;
|
|
41
|
-
currency?: string;
|
|
42
|
-
from?: string;
|
|
43
|
-
expiry?: number;
|
|
44
|
-
sticker?: { stickerMessage: StickerMessage };
|
|
45
|
-
note?: string;
|
|
46
|
-
background?: {
|
|
47
|
-
id?: string;
|
|
48
|
-
fileLength?: string;
|
|
49
|
-
width?: number;
|
|
50
|
-
height?: number;
|
|
51
|
-
mimetype?: string;
|
|
52
|
-
placeholderArgb?: number;
|
|
53
|
-
textArgb?: number;
|
|
54
|
-
subtextArgb?: number;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
interface ProductMessage {
|
|
59
|
-
title: string;
|
|
60
|
-
description: string;
|
|
61
|
-
thumbnail: Buffer | { url: string };
|
|
62
|
-
productId: string;
|
|
63
|
-
retailerId: string;
|
|
64
|
-
url: string;
|
|
65
|
-
body?: string;
|
|
66
|
-
footer?: string;
|
|
67
|
-
buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
|
|
68
|
-
priceAmount1000?: number | null;
|
|
69
|
-
currencyCode?: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
interface InteractiveMessage {
|
|
73
|
-
title: string;
|
|
74
|
-
footer?: string;
|
|
75
|
-
thumbnail?: string;
|
|
76
|
-
image?: string | Buffer | { url: string };
|
|
77
|
-
video?: string | Buffer | { url: string };
|
|
78
|
-
document?: Buffer;
|
|
79
|
-
mimetype?: string;
|
|
80
|
-
fileName?: string;
|
|
81
|
-
jpegThumbnail?: Buffer; // Hanya Buffer saja
|
|
82
|
-
contextInfo?: {
|
|
83
|
-
mentionedJid?: string[];
|
|
84
|
-
forwardingScore?: number;
|
|
85
|
-
isForwarded?: boolean;
|
|
86
|
-
externalAdReply?: {
|
|
87
|
-
title?: string;
|
|
88
|
-
body?: string;
|
|
89
|
-
mediaType?: number;
|
|
90
|
-
thumbnailUrl?: string;
|
|
91
|
-
mediaUrl?: string;
|
|
92
|
-
sourceUrl?: string;
|
|
93
|
-
showAdAttribution?: boolean;
|
|
94
|
-
renderLargerThumbnail?: boolean;
|
|
95
|
-
[key: string]: any;
|
|
96
|
-
};
|
|
97
|
-
[key: string]: any;
|
|
98
|
-
};
|
|
99
|
-
externalAdReply?: {
|
|
100
|
-
title?: string;
|
|
101
|
-
body?: string;
|
|
102
|
-
mediaType?: number;
|
|
103
|
-
thumbnailUrl?: string;
|
|
104
|
-
mediaUrl?: string;
|
|
105
|
-
sourceUrl?: string;
|
|
106
|
-
showAdAttribution?: boolean;
|
|
107
|
-
renderLargerThumbnail?: boolean;
|
|
108
|
-
[key: string]: any;
|
|
109
|
-
};
|
|
110
|
-
buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
|
|
111
|
-
nativeFlowMessage?: {
|
|
112
|
-
messageParamsJson?: string;
|
|
113
|
-
buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
|
|
114
|
-
[key: string]: any;
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
interface AlbumItem {
|
|
119
|
-
image?: { url: string; caption?: string };
|
|
120
|
-
video?: { url: string; caption?: string };
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
interface EventMessageLocation {
|
|
124
|
-
degreesLatitude: number;
|
|
125
|
-
degreesLongitude: number;
|
|
126
|
-
name: string;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
interface EventMessage {
|
|
130
|
-
isCanceled?: boolean;
|
|
131
|
-
name: string;
|
|
132
|
-
description: string;
|
|
133
|
-
location?: EventMessageLocation;
|
|
134
|
-
joinLink?: string;
|
|
135
|
-
startTime?: string | number;
|
|
136
|
-
endTime?: string | number;
|
|
137
|
-
extraGuestsAllowed?: boolean;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
interface PollVote {
|
|
141
|
-
optionName: string;
|
|
142
|
-
optionVoteCount: string | number;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
interface PollResultMessage {
|
|
146
|
-
name: string;
|
|
147
|
-
pollVotes: PollVote[];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
interface MessageContent {
|
|
151
|
-
requestPaymentMessage?: PaymentMessage;
|
|
152
|
-
productMessage?: ProductMessage;
|
|
153
|
-
interactiveMessage?: InteractiveMessage;
|
|
154
|
-
albumMessage?: AlbumItem[];
|
|
155
|
-
eventMessage?: EventMessage;
|
|
156
|
-
pollResultMessage?: PollResultMessage;
|
|
157
|
-
sender?: string;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
interface MessageOptions {
|
|
161
|
-
quoted?: proto.IWebMessageInfo;
|
|
162
|
-
filter?: boolean;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
interface Utils {
|
|
166
|
-
prepareWAMessageMedia: (media: any, options: WAMessageContentGenerationOptions) => Promise<any>;
|
|
167
|
-
generateWAMessageContent: (content: any, options: WAMessageContentGenerationOptions) => Promise<any>;
|
|
168
|
-
generateWAMessageFromContent: (jid: string, content: any, options?: any) => Promise<any>;
|
|
169
|
-
generateWAMessage: (jid: string, content: any, options?: any) => Promise<any>;
|
|
170
|
-
generateMessageID: () => string;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
declare class kikyy {
|
|
175
|
-
constructor(
|
|
176
|
-
utils: kikyy.Utils,
|
|
177
|
-
waUploadToServer: kikyy.WAMediaUploadFunction,
|
|
178
|
-
relayMessageFn?: (jid: string, content: any, options?: any) => Promise<any>
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
detectType(content: kikyy.MessageContent): 'PAYMENT' | 'PRODUCT' | 'INTERACTIVE' | 'ALBUM' | 'EVENT' | 'POLL_RESULT' | null;
|
|
182
|
-
|
|
183
|
-
handlePayment(
|
|
184
|
-
content: { requestPaymentMessage: kikyy.PaymentMessage },
|
|
185
|
-
quoted?: proto.IWebMessageInfo
|
|
186
|
-
): Promise<{ requestPaymentMessage: proto.Message.RequestPaymentMessage }>;
|
|
187
|
-
|
|
188
|
-
handleProduct(
|
|
189
|
-
content: { productMessage: kikyy.ProductMessage },
|
|
190
|
-
jid: string,
|
|
191
|
-
quoted?: proto.IWebMessageInfo
|
|
192
|
-
): Promise<{ viewOnceMessage: proto.Message.ViewOnceMessage }>;
|
|
193
|
-
|
|
194
|
-
handleInteractive(
|
|
195
|
-
content: { interactiveMessage: kikyy.InteractiveMessage },
|
|
196
|
-
jid: string,
|
|
197
|
-
quoted?: proto.IWebMessageInfo
|
|
198
|
-
): Promise<{ interactiveMessage: proto.Message.InteractiveMessage }>;
|
|
199
|
-
|
|
200
|
-
handleAlbum(
|
|
201
|
-
content: { albumMessage: kikyy.AlbumItem[] },
|
|
202
|
-
jid: string,
|
|
203
|
-
quoted?: proto.IWebMessageInfo
|
|
204
|
-
): Promise<any>;
|
|
205
|
-
|
|
206
|
-
handleEvent(
|
|
207
|
-
content: { eventMessage: kikyy.EventMessage },
|
|
208
|
-
jid: string,
|
|
209
|
-
quoted?: proto.IWebMessageInfo
|
|
210
|
-
): Promise<any>;
|
|
211
|
-
|
|
212
|
-
handlePollResult(
|
|
213
|
-
content: { pollResultMessage: kikyy.PollResultMessage },
|
|
214
|
-
jid: string,
|
|
215
|
-
quoted?: proto.IWebMessageInfo
|
|
216
|
-
): Promise<any>;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export = kikyy;
|
package/lib/Socket/dugong.js
DELETED
|
@@ -1,441 +0,0 @@
|
|
|
1
|
-
// "kikyy dugonggg", ah dejavu (r)
|
|
2
|
-
// tanggal 14 agustus 2025 makassar
|
|
3
|
-
// telegram: @tskiofc & @kyuucode
|
|
4
|
-
|
|
5
|
-
const WAProto = require('../../WAProto').proto;
|
|
6
|
-
const crypto = require('crypto');
|
|
7
|
-
|
|
8
|
-
class kikyy {
|
|
9
|
-
constructor(utils, waUploadToServer, relayMessageFn) {
|
|
10
|
-
this.utils = utils;
|
|
11
|
-
this.relayMessage = relayMessageFn
|
|
12
|
-
this.waUploadToServer = waUploadToServer;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
detectType(content) {
|
|
16
|
-
if (content.requestPaymentMessage) return 'PAYMENT';
|
|
17
|
-
if (content.productMessage) return 'PRODUCT';
|
|
18
|
-
if (content.interactiveMessage) return 'INTERACTIVE';
|
|
19
|
-
if (content.albumMessage) return 'ALBUM';
|
|
20
|
-
if (content.eventMessage) return 'EVENT';
|
|
21
|
-
if (content.pollResultMessage) return 'POLL_RESULT'
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async handlePayment(content, quoted) {
|
|
26
|
-
const data = content.requestPaymentMessage;
|
|
27
|
-
let notes = {};
|
|
28
|
-
|
|
29
|
-
if (data.sticker?.stickerMessage) {
|
|
30
|
-
notes = {
|
|
31
|
-
stickerMessage: {
|
|
32
|
-
...data.sticker.stickerMessage,
|
|
33
|
-
contextInfo: {
|
|
34
|
-
stanzaId: quoted?.key?.id,
|
|
35
|
-
participant: quoted?.key?.participant || content.sender,
|
|
36
|
-
quotedMessage: quoted?.message
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
} else if (data.note) {
|
|
41
|
-
notes = {
|
|
42
|
-
extendedTextMessage: {
|
|
43
|
-
text: data.note,
|
|
44
|
-
contextInfo: {
|
|
45
|
-
stanzaId: quoted?.key?.id,
|
|
46
|
-
participant: quoted?.key?.participant || content.sender,
|
|
47
|
-
quotedMessage: quoted?.message
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
requestPaymentMessage: WAProto.Message.RequestPaymentMessage.fromObject({
|
|
55
|
-
expiryTimestamp: data.expiry || 0,
|
|
56
|
-
amount1000: data.amount || 0,
|
|
57
|
-
currencyCodeIso4217: data.currency || "IDR",
|
|
58
|
-
requestFrom: data.from || "0@s.whatsapp.net",
|
|
59
|
-
noteMessage: notes,
|
|
60
|
-
background: data.background ?? {
|
|
61
|
-
id: "DEFAULT",
|
|
62
|
-
placeholderArgb: 0xFFF0F0F0
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async handleProduct(content, jid, quoted) {
|
|
69
|
-
const {
|
|
70
|
-
title,
|
|
71
|
-
description,
|
|
72
|
-
thumbnail,
|
|
73
|
-
productId,
|
|
74
|
-
retailerId,
|
|
75
|
-
url,
|
|
76
|
-
body = "",
|
|
77
|
-
footer = "",
|
|
78
|
-
buttons = [],
|
|
79
|
-
priceAmount1000 = null,
|
|
80
|
-
currencyCode = "IDR"
|
|
81
|
-
} = content.productMessage;
|
|
82
|
-
|
|
83
|
-
let productImage;
|
|
84
|
-
|
|
85
|
-
if (Buffer.isBuffer(thumbnail)) {
|
|
86
|
-
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
87
|
-
{ image: thumbnail },
|
|
88
|
-
{ upload: this.waUploadToServer }
|
|
89
|
-
);
|
|
90
|
-
productImage = imageMessage;
|
|
91
|
-
} else if (typeof thumbnail === 'object' && thumbnail.url) {
|
|
92
|
-
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
93
|
-
{ image: { url: thumbnail.url }},
|
|
94
|
-
{ upload: this.waUploadToServer }
|
|
95
|
-
);
|
|
96
|
-
productImage = imageMessage;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
viewOnceMessage: {
|
|
101
|
-
message: {
|
|
102
|
-
interactiveMessage: {
|
|
103
|
-
body: { text: body },
|
|
104
|
-
footer: { text: footer },
|
|
105
|
-
header: {
|
|
106
|
-
title,
|
|
107
|
-
hasMediaAttachment: true,
|
|
108
|
-
productMessage: {
|
|
109
|
-
product: {
|
|
110
|
-
productImage,
|
|
111
|
-
productId,
|
|
112
|
-
title,
|
|
113
|
-
description,
|
|
114
|
-
currencyCode,
|
|
115
|
-
priceAmount1000,
|
|
116
|
-
retailerId,
|
|
117
|
-
url,
|
|
118
|
-
productImageCount: 1
|
|
119
|
-
},
|
|
120
|
-
businessOwnerJid: "0@s.whatsapp.net"
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
nativeFlowMessage: { buttons }
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async handleInteractive(content, jid, quoted) {
|
|
131
|
-
const {
|
|
132
|
-
title,
|
|
133
|
-
footer,
|
|
134
|
-
thumbnail,
|
|
135
|
-
image,
|
|
136
|
-
video,
|
|
137
|
-
document,
|
|
138
|
-
mimetype,
|
|
139
|
-
fileName,
|
|
140
|
-
jpegThumbnail,
|
|
141
|
-
contextInfo,
|
|
142
|
-
externalAdReply,
|
|
143
|
-
buttons = [],
|
|
144
|
-
nativeFlowMessage
|
|
145
|
-
} = content.interactiveMessage;
|
|
146
|
-
|
|
147
|
-
let media = null;
|
|
148
|
-
let mediaType = null;
|
|
149
|
-
|
|
150
|
-
if (thumbnail) {
|
|
151
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
152
|
-
{ image: { url: thumbnail } },
|
|
153
|
-
{ upload: this.waUploadToServer }
|
|
154
|
-
);
|
|
155
|
-
mediaType = 'image';
|
|
156
|
-
} else if (image) {
|
|
157
|
-
if (typeof image === 'object' && image.url) {
|
|
158
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
159
|
-
{ image: { url: image.url } },
|
|
160
|
-
{ upload: this.waUploadToServer }
|
|
161
|
-
);
|
|
162
|
-
} else {
|
|
163
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
164
|
-
{ image: image },
|
|
165
|
-
{ upload: this.waUploadToServer }
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
mediaType = 'image';
|
|
169
|
-
} else if (video) {
|
|
170
|
-
if (typeof video === 'object' && video.url) {
|
|
171
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
172
|
-
{ video: { url: video.url } },
|
|
173
|
-
{ upload: this.waUploadToServer }
|
|
174
|
-
);
|
|
175
|
-
} else {
|
|
176
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
177
|
-
{ video: video },
|
|
178
|
-
{ upload: this.waUploadToServer }
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
mediaType = 'video';
|
|
182
|
-
} else if (document) {
|
|
183
|
-
let documentPayload = { document: document };
|
|
184
|
-
|
|
185
|
-
if (jpegThumbnail) {
|
|
186
|
-
if (typeof jpegThumbnail === 'object' && jpegThumbnail.url) {
|
|
187
|
-
documentPayload.jpegThumbnail = { url: jpegThumbnail.url };
|
|
188
|
-
} else {
|
|
189
|
-
documentPayload.jpegThumbnail = jpegThumbnail;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
media = await this.utils.prepareWAMessageMedia(
|
|
194
|
-
documentPayload,
|
|
195
|
-
{ upload: this.waUploadToServer }
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
if (fileName) {
|
|
199
|
-
media.documentMessage.fileName = fileName;
|
|
200
|
-
}
|
|
201
|
-
if (mimetype) {
|
|
202
|
-
media.documentMessage.mimetype = mimetype;
|
|
203
|
-
}
|
|
204
|
-
mediaType = 'document';
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
let interactiveMessage = {
|
|
208
|
-
body: { text: title || "" },
|
|
209
|
-
footer: { text: footer || "" }
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
if (buttons && buttons.length > 0) {
|
|
213
|
-
interactiveMessage.nativeFlowMessage = {
|
|
214
|
-
buttons: buttons
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
if (nativeFlowMessage) {
|
|
218
|
-
interactiveMessage.nativeFlowMessage = {
|
|
219
|
-
...interactiveMessage.nativeFlowMessage,
|
|
220
|
-
...nativeFlowMessage
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
} else if (nativeFlowMessage) {
|
|
224
|
-
interactiveMessage.nativeFlowMessage = nativeFlowMessage;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (media) {
|
|
228
|
-
interactiveMessage.header = {
|
|
229
|
-
title: "",
|
|
230
|
-
hasMediaAttachment: true,
|
|
231
|
-
...media
|
|
232
|
-
};
|
|
233
|
-
} else {
|
|
234
|
-
interactiveMessage.header = {
|
|
235
|
-
title: "",
|
|
236
|
-
hasMediaAttachment: false
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
let finalContextInfo = {};
|
|
241
|
-
|
|
242
|
-
if (contextInfo) {
|
|
243
|
-
finalContextInfo = {
|
|
244
|
-
mentionedJid: contextInfo.mentionedJid || [],
|
|
245
|
-
forwardingScore: contextInfo.forwardingScore || 0,
|
|
246
|
-
isForwarded: contextInfo.isForwarded || false,
|
|
247
|
-
...contextInfo
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if (externalAdReply) {
|
|
252
|
-
finalContextInfo.externalAdReply = {
|
|
253
|
-
title: externalAdReply.title || "",
|
|
254
|
-
body: externalAdReply.body || "",
|
|
255
|
-
mediaType: externalAdReply.mediaType || 1,
|
|
256
|
-
thumbnailUrl: externalAdReply.thumbnailUrl || "",
|
|
257
|
-
mediaUrl: externalAdReply.mediaUrl || "",
|
|
258
|
-
sourceUrl: externalAdReply.sourceUrl || "",
|
|
259
|
-
showAdAttribution: externalAdReply.showAdAttribution || false,
|
|
260
|
-
renderLargerThumbnail: externalAdReply.renderLargerThumbnail || false,
|
|
261
|
-
...externalAdReply
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (Object.keys(finalContextInfo).length > 0) {
|
|
266
|
-
interactiveMessage.contextInfo = finalContextInfo;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return {
|
|
270
|
-
interactiveMessage: interactiveMessage
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
async handleAlbum(content, jid, quoted) {
|
|
275
|
-
const array = content.albumMessage;
|
|
276
|
-
const album = await this.utils.generateWAMessageFromContent(jid, {
|
|
277
|
-
messageContextInfo: {
|
|
278
|
-
messageSecret: crypto.randomBytes(32),
|
|
279
|
-
},
|
|
280
|
-
albumMessage: {
|
|
281
|
-
expectedImageCount: array.filter((a) => a.hasOwnProperty("image")).length,
|
|
282
|
-
expectedVideoCount: array.filter((a) => a.hasOwnProperty("video")).length,
|
|
283
|
-
},
|
|
284
|
-
}, {
|
|
285
|
-
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
286
|
-
quoted,
|
|
287
|
-
upload: this.waUploadToServer
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
await this.relayMessage(jid, album.message, {
|
|
291
|
-
messageId: album.key.id,
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
for (let content of array) {
|
|
295
|
-
const img = await this.utils.generateWAMessage(jid, content, {
|
|
296
|
-
upload: this.waUploadToServer,
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
img.message.messageContextInfo = {
|
|
300
|
-
messageSecret: crypto.randomBytes(32),
|
|
301
|
-
messageAssociation: {
|
|
302
|
-
associationType: 1,
|
|
303
|
-
parentMessageKey: album.key,
|
|
304
|
-
},
|
|
305
|
-
participant: "0@s.whatsapp.net",
|
|
306
|
-
remoteJid: "status@broadcast",
|
|
307
|
-
forwardingScore: 99999,
|
|
308
|
-
isForwarded: true,
|
|
309
|
-
mentionedJid: [jid],
|
|
310
|
-
starred: true,
|
|
311
|
-
labels: ["Y", "Important"],
|
|
312
|
-
isHighlighted: true,
|
|
313
|
-
businessMessageForwardInfo: {
|
|
314
|
-
businessOwnerJid: jid,
|
|
315
|
-
},
|
|
316
|
-
dataSharingContext: {
|
|
317
|
-
showMmDisclosure: true,
|
|
318
|
-
},
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
img.message.forwardedNewsletterMessageInfo = {
|
|
322
|
-
newsletterJid: "0@newsletter",
|
|
323
|
-
serverMessageId: 1,
|
|
324
|
-
newsletterName: `WhatsApp`,
|
|
325
|
-
contentType: 1,
|
|
326
|
-
timestamp: new Date().toISOString(),
|
|
327
|
-
senderName: "kikyy dugonggg",
|
|
328
|
-
content: "Text Message",
|
|
329
|
-
priority: "high",
|
|
330
|
-
status: "sent",
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
img.message.disappearingMode = {
|
|
334
|
-
initiator: 3,
|
|
335
|
-
trigger: 4,
|
|
336
|
-
initiatorDeviceJid: jid,
|
|
337
|
-
initiatedByExternalService: true,
|
|
338
|
-
initiatedByUserDevice: true,
|
|
339
|
-
initiatedBySystem: true,
|
|
340
|
-
initiatedByServer: true,
|
|
341
|
-
initiatedByAdmin: true,
|
|
342
|
-
initiatedByUser: true,
|
|
343
|
-
initiatedByApp: true,
|
|
344
|
-
initiatedByBot: true,
|
|
345
|
-
initiatedByMe: true,
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
await this.relayMessage(jid, img.message, {
|
|
349
|
-
messageId: img.key.id,
|
|
350
|
-
quoted: {
|
|
351
|
-
key: {
|
|
352
|
-
remoteJid: album.key.remoteJid,
|
|
353
|
-
id: album.key.id,
|
|
354
|
-
fromMe: true,
|
|
355
|
-
participant: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
356
|
-
},
|
|
357
|
-
message: album.message,
|
|
358
|
-
},
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
return album;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
async handleEvent(content, jid, quoted) {
|
|
365
|
-
const eventData = content.eventMessage;
|
|
366
|
-
|
|
367
|
-
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
368
|
-
viewOnceMessage: {
|
|
369
|
-
message: {
|
|
370
|
-
messageContextInfo: {
|
|
371
|
-
deviceListMetadata: {},
|
|
372
|
-
deviceListMetadataVersion: 2,
|
|
373
|
-
messageSecret: crypto.randomBytes(32),
|
|
374
|
-
supportPayload: JSON.stringify({
|
|
375
|
-
version: 2,
|
|
376
|
-
is_ai_message: true,
|
|
377
|
-
should_show_system_message: true,
|
|
378
|
-
ticket_id: crypto.randomBytes(16).toString('hex')
|
|
379
|
-
})
|
|
380
|
-
},
|
|
381
|
-
eventMessage: {
|
|
382
|
-
contextInfo: {
|
|
383
|
-
mentionedJid: [jid],
|
|
384
|
-
participant: jid,
|
|
385
|
-
remoteJid: "status@broadcast",
|
|
386
|
-
forwardedNewsletterMessageInfo: {
|
|
387
|
-
newsletterName: "shenvn.",
|
|
388
|
-
newsletterJid: "120363297591152843@newsletter",
|
|
389
|
-
serverMessageId: 1
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
isCanceled: eventData.isCanceled || false,
|
|
393
|
-
name: eventData.name,
|
|
394
|
-
description: eventData.description,
|
|
395
|
-
location: eventData.location || {
|
|
396
|
-
degreesLatitude: 0,
|
|
397
|
-
degreesLongitude: 0,
|
|
398
|
-
name: "Location"
|
|
399
|
-
},
|
|
400
|
-
joinLink: eventData.joinLink || '',
|
|
401
|
-
startTime: typeof eventData.startTime === 'string' ? parseInt(eventData.startTime) : eventData.startTime || Date.now(),
|
|
402
|
-
endTime: typeof eventData.endTime === 'string' ? parseInt(eventData.endTime) : eventData.endTime || Date.now() + 3600000,
|
|
403
|
-
extraGuestsAllowed: eventData.extraGuestsAllowed !== false
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}, { quoted });
|
|
408
|
-
|
|
409
|
-
await this.relayMessage(jid, msg.message, {
|
|
410
|
-
messageId: msg.key.id
|
|
411
|
-
});
|
|
412
|
-
return msg;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
async handlePollResult(content, jid, quoted) {
|
|
416
|
-
const pollData = content.pollResultMessage;
|
|
417
|
-
|
|
418
|
-
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
419
|
-
pollResultSnapshotMessage: {
|
|
420
|
-
name: pollData.name,
|
|
421
|
-
pollVotes: pollData.pollVotes.map(vote => ({
|
|
422
|
-
optionName: vote.optionName,
|
|
423
|
-
optionVoteCount: typeof vote.optionVoteCount === 'number'
|
|
424
|
-
? vote.optionVoteCount.toString()
|
|
425
|
-
: vote.optionVoteCount
|
|
426
|
-
}))
|
|
427
|
-
}
|
|
428
|
-
}, {
|
|
429
|
-
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
430
|
-
quoted
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
await this.relayMessage(jid, msg.message, {
|
|
434
|
-
messageId: msg.key.id
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
return msg;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
module.exports = kikyy;
|