@ryuhan/baileys 1.2.9 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +581 -95
- package/index.cjs +2 -2
- package/lib/Types/Message.d.ts +199 -9
- package/lib/Utils/index.d.ts +0 -1
- package/lib/Utils/index.js +0 -1
- package/lib/Utils/messages.js +16 -15
- package/lib/index.d.ts +0 -18
- package/lib/index.js +1 -28
- package/package.json +13 -6
- package/lib/Utils/apocalypse-api.js +0 -196
- package/lib/Utils/apocalypse.d.ts +0 -116
- package/lib/Utils/apocalypse.js +0 -275
package/index.cjs
CHANGED
|
@@ -144,11 +144,11 @@ const _functions = [
|
|
|
144
144
|
'toReadable','transferDevice','trimUndefined','unixTimestampSeconds',
|
|
145
145
|
'unpadRandomMax16','updateMessageWithEventResponse','updateMessageWithPollUpdate',
|
|
146
146
|
'updateMessageWithReaction','updateMessageWithReceipt','uploadWithNodeHttp',
|
|
147
|
-
'useMultiFileAuthState','writeRandomPadMax16','makeNewsletterUtils','resolveJid','resolveJids','
|
|
147
|
+
'useMultiFileAuthState','writeRandomPadMax16','makeNewsletterUtils','resolveJid','resolveJids','binaryNodeToString',
|
|
148
148
|
];
|
|
149
149
|
|
|
150
150
|
const _constants = [
|
|
151
|
-
'Browsers','
|
|
151
|
+
'Browsers','BufferJSON','CALL_AUDIO_PREFIX','CALL_VIDEO_PREFIX','Curve',
|
|
152
152
|
'DEFAULT_CACHE_TTLS','DEFAULT_CONNECTION_CONFIG','DEFAULT_ORIGIN',
|
|
153
153
|
'DEF_CALLBACK_PREFIX','DEF_TAG_PREFIX','DICT_VERSION','DisconnectReason',
|
|
154
154
|
'INITIAL_PREKEY_COUNT','KEY_BUNDLE_TYPE','MEDIA_HKDF_KEY_MAPPING','MEDIA_KEYS',
|
package/lib/Types/Message.d.ts
CHANGED
|
@@ -75,6 +75,67 @@ type Contextable = {
|
|
|
75
75
|
/** add contextInfo to the message */
|
|
76
76
|
contextInfo?: proto.IContextInfo;
|
|
77
77
|
};
|
|
78
|
+
|
|
79
|
+
type Listable = {
|
|
80
|
+
/** Sections of the List */
|
|
81
|
+
sections?: proto.Message.ListMessage.ISection[];
|
|
82
|
+
/** Title of a List Message only */
|
|
83
|
+
title?: string;
|
|
84
|
+
/** Text of the button on the list (required) */
|
|
85
|
+
buttonText?: string;
|
|
86
|
+
/** ListType of a List Message only */
|
|
87
|
+
listType?: proto.Message.ListMessage.ListType;
|
|
88
|
+
/** Description of the list */
|
|
89
|
+
text?: string;
|
|
90
|
+
/** Footer text */
|
|
91
|
+
footer?: string;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
type ProductListable = {
|
|
95
|
+
/** Product list sections */
|
|
96
|
+
productList?: proto.Message.ListMessage.IProductSection[];
|
|
97
|
+
/** Thumbnail for product list */
|
|
98
|
+
thumbnail?: WAMediaUpload;
|
|
99
|
+
/** Business owner JID */
|
|
100
|
+
businessOwnerJid?: string;
|
|
101
|
+
/** Title of product list */
|
|
102
|
+
title?: string;
|
|
103
|
+
/** Button text */
|
|
104
|
+
buttonText?: string;
|
|
105
|
+
/** Footer text */
|
|
106
|
+
footer?: string;
|
|
107
|
+
/** Description */
|
|
108
|
+
text?: string;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
type Buttonable = {
|
|
112
|
+
/** add buttons to the message */
|
|
113
|
+
buttons?: proto.Message.ButtonsMessage.IButton[];
|
|
114
|
+
/** Title for button message */
|
|
115
|
+
title?: string;
|
|
116
|
+
/** Footer text */
|
|
117
|
+
footer?: string;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
type Templatable = {
|
|
121
|
+
/** add template buttons to the message */
|
|
122
|
+
templateButtons?: proto.IHydratedTemplateButton[];
|
|
123
|
+
/** Footer text */
|
|
124
|
+
footer?: string;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
type Interactiveable = {
|
|
128
|
+
/** add interactive buttons to the message */
|
|
129
|
+
interactiveButtons?: proto.Message.InteractiveMessage.NativeFlowMessage.INativeFlowButton[];
|
|
130
|
+
/** Title */
|
|
131
|
+
title?: string;
|
|
132
|
+
/** Subtitle */
|
|
133
|
+
subtitle?: string;
|
|
134
|
+
/** Footer text */
|
|
135
|
+
footer?: string;
|
|
136
|
+
/** Has media attachment */
|
|
137
|
+
media?: boolean;
|
|
138
|
+
};
|
|
78
139
|
type ViewOnce = {
|
|
79
140
|
viewOnce?: boolean;
|
|
80
141
|
};
|
|
@@ -105,6 +166,91 @@ export type EventMessageOptions = {
|
|
|
105
166
|
extraGuestsAllowed?: boolean;
|
|
106
167
|
messageSecret?: Uint8Array<ArrayBufferLike>;
|
|
107
168
|
};
|
|
169
|
+
|
|
170
|
+
export type PollResultOptions = {
|
|
171
|
+
name: string;
|
|
172
|
+
values: [string, number][]; // [optionName, voteCount][]
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export type AlbumMessage = {
|
|
176
|
+
image?: WAMediaUpload;
|
|
177
|
+
video?: WAMediaUpload;
|
|
178
|
+
caption?: string;
|
|
179
|
+
}[];
|
|
180
|
+
|
|
181
|
+
export type Sticker = {
|
|
182
|
+
data: WAMediaUpload;
|
|
183
|
+
emojis?: string[];
|
|
184
|
+
accessibilityLabel?: string;
|
|
185
|
+
isAnimated?: boolean;
|
|
186
|
+
isLottie?: boolean;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export type StickerPack = {
|
|
190
|
+
stickers: Sticker[];
|
|
191
|
+
cover: WAMediaUpload;
|
|
192
|
+
name: string;
|
|
193
|
+
publisher: string;
|
|
194
|
+
description?: string;
|
|
195
|
+
packId?: string;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export type AdminInviteInfo = {
|
|
199
|
+
jid: string;
|
|
200
|
+
name: string;
|
|
201
|
+
caption: string;
|
|
202
|
+
expiration: number;
|
|
203
|
+
jpegThumbnail?: string;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export type PaymentInfo = {
|
|
207
|
+
note: string;
|
|
208
|
+
currency?: string;
|
|
209
|
+
offset?: number;
|
|
210
|
+
amount?: number;
|
|
211
|
+
expiry?: number;
|
|
212
|
+
from?: string;
|
|
213
|
+
image?: {
|
|
214
|
+
placeholderArgb: number;
|
|
215
|
+
textArgb: number;
|
|
216
|
+
subtextArgb: number;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export type PaymentInviteInfo = {
|
|
221
|
+
type: number;
|
|
222
|
+
expiry: number;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
|
226
|
+
productImage: WAMediaUpload;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export type OrderMessage = proto.Message.IOrderMessage;
|
|
230
|
+
|
|
231
|
+
export type Carousel = {
|
|
232
|
+
image?: WAMediaUpload;
|
|
233
|
+
video?: WAMediaUpload;
|
|
234
|
+
product?: WASendableProduct;
|
|
235
|
+
title?: string;
|
|
236
|
+
body?: string;
|
|
237
|
+
footer?: string;
|
|
238
|
+
buttons?: proto.Message.InteractiveMessage.NativeFlowMessage.INativeFlowButton[];
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
export type ShopSurface = 'FB' | 'IG' | 'WA' | 'WA_WEB';
|
|
242
|
+
|
|
243
|
+
export type ShopInfo = {
|
|
244
|
+
surface: ShopSurface;
|
|
245
|
+
id: string;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export type CollectionInfo = {
|
|
249
|
+
bizJid: string;
|
|
250
|
+
id: string;
|
|
251
|
+
version?: number;
|
|
252
|
+
};
|
|
253
|
+
|
|
108
254
|
type SharePhoneNumber = {
|
|
109
255
|
sharePhoneNumber: boolean;
|
|
110
256
|
};
|
|
@@ -115,14 +261,14 @@ export type AnyMediaMessageContent = (({
|
|
|
115
261
|
image: WAMediaUpload;
|
|
116
262
|
caption?: string;
|
|
117
263
|
jpegThumbnail?: string;
|
|
118
|
-
} & Mentionable & Contextable & WithDimensions) | ({
|
|
264
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & WithDimensions) | ({
|
|
119
265
|
video: WAMediaUpload;
|
|
120
266
|
caption?: string;
|
|
121
267
|
gifPlayback?: boolean;
|
|
122
268
|
jpegThumbnail?: string;
|
|
123
269
|
/** if set to true, will send as a `video note` */
|
|
124
270
|
ptv?: boolean;
|
|
125
|
-
} & Mentionable & Contextable & WithDimensions) | {
|
|
271
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & WithDimensions) | {
|
|
126
272
|
audio: WAMediaUpload;
|
|
127
273
|
/** if set to true, will send as a `voice note` */
|
|
128
274
|
ptt?: boolean;
|
|
@@ -136,13 +282,21 @@ export type AnyMediaMessageContent = (({
|
|
|
136
282
|
mimetype: string;
|
|
137
283
|
fileName?: string;
|
|
138
284
|
caption?: string;
|
|
139
|
-
} & Contextable)) & {
|
|
285
|
+
} & Contextable & Buttonable & Templatable & Interactiveable)) & {
|
|
140
286
|
mimetype?: string;
|
|
141
287
|
} & Editable;
|
|
142
288
|
export type ButtonReplyInfo = {
|
|
143
|
-
displayText
|
|
144
|
-
id
|
|
145
|
-
index
|
|
289
|
+
displayText?: string;
|
|
290
|
+
id?: string;
|
|
291
|
+
index?: number;
|
|
292
|
+
title?: string;
|
|
293
|
+
description?: string;
|
|
294
|
+
rowId?: string;
|
|
295
|
+
nativeFlows?: {
|
|
296
|
+
name?: string;
|
|
297
|
+
paramsJson?: string;
|
|
298
|
+
version?: number;
|
|
299
|
+
};
|
|
146
300
|
};
|
|
147
301
|
export type GroupInviteInfo = {
|
|
148
302
|
inviteCode: string;
|
|
@@ -157,11 +311,47 @@ export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapsh
|
|
|
157
311
|
export type AnyRegularMessageContent = (({
|
|
158
312
|
text: string;
|
|
159
313
|
linkPreview?: WAUrlInfo | null;
|
|
160
|
-
} & Mentionable & Contextable & Editable) | AnyMediaMessageContent | {
|
|
314
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Listable & ProductListable & Editable) | AnyMediaMessageContent | {
|
|
161
315
|
event: EventMessageOptions;
|
|
162
316
|
} | ({
|
|
163
317
|
poll: PollMessageOptions;
|
|
164
|
-
} & Mentionable & Contextable & Editable) | {
|
|
318
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Listable & ProductListable & Editable) | {
|
|
319
|
+
pollResult: PollResultOptions;
|
|
320
|
+
} | {
|
|
321
|
+
album: AlbumMessage;
|
|
322
|
+
} | {
|
|
323
|
+
stickerPack: StickerPack;
|
|
324
|
+
} | {
|
|
325
|
+
order: OrderMessage;
|
|
326
|
+
} | {
|
|
327
|
+
payment: PaymentInfo;
|
|
328
|
+
} | {
|
|
329
|
+
paymentInvite: PaymentInviteInfo;
|
|
330
|
+
} | {
|
|
331
|
+
adminInvite: AdminInviteInfo;
|
|
332
|
+
} | {
|
|
333
|
+
shop: ShopInfo;
|
|
334
|
+
title?: string;
|
|
335
|
+
subtitle?: string;
|
|
336
|
+
footer?: string;
|
|
337
|
+
text?: string;
|
|
338
|
+
caption?: string;
|
|
339
|
+
media?: boolean;
|
|
340
|
+
} | {
|
|
341
|
+
collection: CollectionInfo;
|
|
342
|
+
title?: string;
|
|
343
|
+
subtitle?: string;
|
|
344
|
+
footer?: string;
|
|
345
|
+
text?: string;
|
|
346
|
+
caption?: string;
|
|
347
|
+
hasMediaAttachment?: boolean;
|
|
348
|
+
} | {
|
|
349
|
+
cards: Carousel[];
|
|
350
|
+
title?: string;
|
|
351
|
+
subtitle?: string;
|
|
352
|
+
footer?: string;
|
|
353
|
+
text?: string;
|
|
354
|
+
} | {
|
|
165
355
|
contacts: {
|
|
166
356
|
displayName?: string;
|
|
167
357
|
contacts: proto.Message.IContactMessage[];
|
|
@@ -172,7 +362,7 @@ export type AnyRegularMessageContent = (({
|
|
|
172
362
|
react: proto.Message.IReactionMessage;
|
|
173
363
|
} | {
|
|
174
364
|
buttonReply: ButtonReplyInfo;
|
|
175
|
-
type: 'template' | 'plain';
|
|
365
|
+
type: 'template' | 'plain' | 'list' | 'interactive';
|
|
176
366
|
} | {
|
|
177
367
|
groupInvite: GroupInviteInfo;
|
|
178
368
|
} | {
|
package/lib/Utils/index.d.ts
CHANGED
package/lib/Utils/index.js
CHANGED
package/lib/Utils/messages.js
CHANGED
|
@@ -998,44 +998,46 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
998
998
|
};
|
|
999
999
|
if ('text' in message) {
|
|
1000
1000
|
interactiveMessage.body = { text: message.text };
|
|
1001
|
+
interactiveMessage.header = {
|
|
1002
|
+
title: message.title,
|
|
1003
|
+
subtitle: message.subtitle,
|
|
1004
|
+
hasMediaAttachment: message?.media ?? false
|
|
1005
|
+
};
|
|
1001
1006
|
}
|
|
1002
1007
|
else if ('caption' in message) {
|
|
1003
1008
|
interactiveMessage.body = { text: message.caption };
|
|
1004
1009
|
interactiveMessage.header = {
|
|
1005
1010
|
title: message.title,
|
|
1006
1011
|
subtitle: message.subtitle,
|
|
1007
|
-
hasMediaAttachment: message?.media ?? false
|
|
1012
|
+
hasMediaAttachment: message?.media ?? false
|
|
1008
1013
|
};
|
|
1009
1014
|
Object.assign(interactiveMessage.header, m);
|
|
1010
1015
|
}
|
|
1011
1016
|
if ('footer' in message && !!message.footer) {
|
|
1012
1017
|
interactiveMessage.footer = { text: message.footer };
|
|
1013
1018
|
}
|
|
1014
|
-
if ('title' in message && !!message.title) {
|
|
1015
|
-
interactiveMessage.header = {
|
|
1016
|
-
title: message.title,
|
|
1017
|
-
subtitle: message.subtitle,
|
|
1018
|
-
hasMediaAttachment: message?.media ?? false,
|
|
1019
|
-
};
|
|
1020
|
-
Object.assign(interactiveMessage.header, m);
|
|
1021
|
-
}
|
|
1022
1019
|
if ('contextInfo' in message && !!message.contextInfo) {
|
|
1023
1020
|
interactiveMessage.contextInfo = message.contextInfo;
|
|
1024
1021
|
}
|
|
1025
1022
|
if ('mentions' in message && !!message.mentions) {
|
|
1026
|
-
interactiveMessage.contextInfo = { mentionedJid: message.mentions };
|
|
1023
|
+
interactiveMessage.contextInfo = { ...interactiveMessage.contextInfo, mentionedJid: message.mentions };
|
|
1027
1024
|
}
|
|
1028
1025
|
m = { interactiveMessage };
|
|
1029
1026
|
}
|
|
1030
1027
|
else if ('shop' in message && !!message.shop) {
|
|
1031
1028
|
const interactiveMessage = {
|
|
1032
1029
|
shopStorefrontMessage: proto.Message.InteractiveMessage.ShopMessage.fromObject({
|
|
1033
|
-
surface: message.shop,
|
|
1034
|
-
id: message.id
|
|
1030
|
+
surface: message.shop.surface,
|
|
1031
|
+
id: message.shop.id
|
|
1035
1032
|
})
|
|
1036
1033
|
};
|
|
1037
1034
|
if ('text' in message) {
|
|
1038
1035
|
interactiveMessage.body = { text: message.text };
|
|
1036
|
+
interactiveMessage.header = {
|
|
1037
|
+
title: message.title,
|
|
1038
|
+
subtitle: message.subtitle,
|
|
1039
|
+
hasMediaAttachment: false
|
|
1040
|
+
};
|
|
1039
1041
|
}
|
|
1040
1042
|
else if ('caption' in message) {
|
|
1041
1043
|
interactiveMessage.body = { text: message.caption };
|
|
@@ -1049,13 +1051,12 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1049
1051
|
if ('footer' in message && !!message.footer) {
|
|
1050
1052
|
interactiveMessage.footer = { text: message.footer };
|
|
1051
1053
|
}
|
|
1052
|
-
if ('title' in message && !!message.title) {
|
|
1054
|
+
if ('title' in message && !!message.title && !interactiveMessage.header) {
|
|
1053
1055
|
interactiveMessage.header = {
|
|
1054
1056
|
title: message.title,
|
|
1055
1057
|
subtitle: message.subtitle,
|
|
1056
|
-
hasMediaAttachment: message?.media ?? false
|
|
1058
|
+
hasMediaAttachment: message?.media ?? false
|
|
1057
1059
|
};
|
|
1058
|
-
Object.assign(interactiveMessage.header, m);
|
|
1059
1060
|
}
|
|
1060
1061
|
if ('contextInfo' in message && !!message.contextInfo) {
|
|
1061
1062
|
interactiveMessage.contextInfo = message.contextInfo;
|
package/lib/index.d.ts
CHANGED
|
@@ -10,21 +10,3 @@ export type WASocket = ReturnType<typeof makeWASocket>;
|
|
|
10
10
|
export { makeWASocket };
|
|
11
11
|
export default makeWASocket;
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
13
|
-
// ── Global Apocalypse declaration ────────────────────────────────────────────
|
|
14
|
-
// Tersedia otomatis setelah require/import baileys, tanpa import eksplisit.
|
|
15
|
-
//
|
|
16
|
-
// Tanpa API key:
|
|
17
|
-
// await apocalypse.get('/search/spotify', { q: 'swim' })
|
|
18
|
-
//
|
|
19
|
-
// Dengan API key — buat instance sendiri:
|
|
20
|
-
// const api = createApocalypse({ apiKey: 'NEMOPHILA' })
|
|
21
|
-
// await api.get('/search/spotify', { q: 'swim' })
|
|
22
|
-
//
|
|
23
|
-
// Dari config/setting global:
|
|
24
|
-
// const api = createApocalypse({ apiKey: global.apikey })
|
|
25
|
-
// await api.get('/search/spotify', { q: 'swim' })
|
|
26
|
-
declare global {
|
|
27
|
-
var apocalypse: import('./Utils/apocalypse.js').ApocalypseClient;
|
|
28
|
-
var createApocalypse: typeof import('./Utils/apocalypse.js').createApocalypse;
|
|
29
|
-
}
|
|
30
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
package/lib/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const _rimuru = {
|
|
|
6
6
|
title: chalk.bold.hex('#00BFFF')('💧 Rimuru Baileys ') + chalk.hex('#0080FF')('| Modified Edition'),
|
|
7
7
|
pair : chalk.hex('#0080FF')('⌘ Pairing Code : ') + chalk.bold.white('MURUSAMA'),
|
|
8
8
|
repo : chalk.hex('#0080FF')('❖ GitHub : ') + chalk.bold.cyan('@ryuhandev'),
|
|
9
|
-
note : chalk.dim.hex('#00BFFF')('
|
|
9
|
+
note : chalk.dim.hex('#00BFFF')(' WhatsApp Multi-Device Library'),
|
|
10
10
|
};
|
|
11
11
|
console.log(_rimuru.line);
|
|
12
12
|
console.log(_rimuru.title);
|
|
@@ -16,33 +16,6 @@ console.log(_rimuru.note);
|
|
|
16
16
|
console.log(_rimuru.line);
|
|
17
17
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
18
18
|
|
|
19
|
-
import { apocalypse as _apocalypseInstance, createApocalypse as _createApocalypse } from './Utils/apocalypse.js';
|
|
20
|
-
|
|
21
|
-
// ── Global Apocalypse API ─────────────────────────────────────────────────────
|
|
22
|
-
// Semua tersedia TANPA import, otomatis setelah require('@ryuhan/baileys'):
|
|
23
|
-
//
|
|
24
|
-
// // Tanpa API key:
|
|
25
|
-
// await apocalypse.get('/search/spotify', { q: 'swim' })
|
|
26
|
-
//
|
|
27
|
-
// // Dengan API key — buat instance sendiri:
|
|
28
|
-
// const api = createApocalypse({ apiKey: 'NEMOPHILA' })
|
|
29
|
-
// await api.get('/search/spotify', { q: 'swim' })
|
|
30
|
-
//
|
|
31
|
-
// // Dari config/setting global:
|
|
32
|
-
// const api = createApocalypse({ apiKey: global.apikey })
|
|
33
|
-
// await api.get('/search/spotify', { q: 'swim' })
|
|
34
|
-
//
|
|
35
|
-
// // Set key ke global instance:
|
|
36
|
-
// apocalypse.setKey('NEMOPHILA')
|
|
37
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
38
|
-
if (typeof globalThis.apocalypse === 'undefined') {
|
|
39
|
-
globalThis.apocalypse = _apocalypseInstance;
|
|
40
|
-
}
|
|
41
|
-
if (typeof globalThis.createApocalypse === 'undefined') {
|
|
42
|
-
globalThis.createApocalypse = _createApocalypse;
|
|
43
|
-
}
|
|
44
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
45
|
-
|
|
46
19
|
import makeWASocket from './Socket/index.js';
|
|
47
20
|
export * from '../WAProto/index.js';
|
|
48
21
|
export { proto } from '../WAProto/index.js';
|
package/package.json
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryuhan/baileys",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "2.0.2",
|
|
5
|
+
"description": "💧 Rimuru Baileys - WhatsApp Multi-Device Library with intelligent @lid/@jid mapping",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"whatsapp",
|
|
8
8
|
"automation",
|
|
9
|
-
"
|
|
9
|
+
"baileys",
|
|
10
10
|
"rimuru",
|
|
11
|
-
"
|
|
11
|
+
"ryuhan",
|
|
12
|
+
"whatsapp-api",
|
|
13
|
+
"multi-device",
|
|
14
|
+
"lid-mapping",
|
|
15
|
+
"jid-resolution"
|
|
12
16
|
],
|
|
13
17
|
"homepage": "https://github.com/ryuhandev/rimuru-baileys/",
|
|
14
18
|
"repository": {
|
|
15
19
|
"url": "https://github.com/ryuhandev/rimuru-baileys.git"
|
|
16
20
|
},
|
|
17
21
|
"license": "MIT",
|
|
18
|
-
"author": "ryuhan",
|
|
22
|
+
"author": "ryuhan <hanzthespike@gmail.com>",
|
|
19
23
|
"main": "./index.cjs",
|
|
20
24
|
"module": "./lib/index.js",
|
|
21
25
|
"types": "./index.d.ts",
|
|
@@ -46,7 +50,10 @@
|
|
|
46
50
|
"index.cjs",
|
|
47
51
|
"index.d.ts"
|
|
48
52
|
],
|
|
49
|
-
"scripts": {
|
|
53
|
+
"scripts": {
|
|
54
|
+
"lint": "eslint lib --ext .js,.ts",
|
|
55
|
+
"lint:fix": "eslint lib --fix --ext .js,.ts"
|
|
56
|
+
},
|
|
50
57
|
"dependencies": {
|
|
51
58
|
"@cacheable/node-cache": "^1.4.0",
|
|
52
59
|
"@hapi/boom": "^9.1.3",
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* apocalypse-api.js
|
|
3
|
-
* Client untuk API https://api.apocalypse.web.id
|
|
4
|
-
*
|
|
5
|
-
* Pola URL:
|
|
6
|
-
* /{kategori}/{endpoint}?{param}={value}
|
|
7
|
-
* /{kategori}/{sub}/{endpoint}?{param}={value}
|
|
8
|
-
*
|
|
9
|
-
* Contoh:
|
|
10
|
-
* await apocalypse.get('/search/spotify?q=swim')
|
|
11
|
-
* await apocalypse.get('/search/youtube?q=hello')
|
|
12
|
-
* await apocalypse.get('/downloader/tiktok?url=https://...')
|
|
13
|
-
* await apocalypse.get('/manga/jagoanmanga/search?q=killer+peter')
|
|
14
|
-
* await apocalypse.get('/ai/gpt?text=hello')
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const BASE_URL = 'https://api.apocalypse.web.id';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Buat Apocalypse API client.
|
|
21
|
-
*
|
|
22
|
-
* @param {object} [options]
|
|
23
|
-
* @param {string} [options.apiKey] — API key jika diperlukan
|
|
24
|
-
* @param {number} [options.timeout=15000] — timeout dalam ms
|
|
25
|
-
* @param {object} [options.headers] — header tambahan
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* import { createApocalypseApi } from '@ryuhan/baileys';
|
|
29
|
-
* const apocalypse = createApocalypseApi();
|
|
30
|
-
*
|
|
31
|
-
* // Atau dengan API key:
|
|
32
|
-
* const apocalypse = createApocalypseApi({ apiKey: 'your-key' });
|
|
33
|
-
*/
|
|
34
|
-
export function createApocalypseApi(options = {}) {
|
|
35
|
-
const {
|
|
36
|
-
apiKey,
|
|
37
|
-
timeout = 15000,
|
|
38
|
-
headers: extraHeaders = {}
|
|
39
|
-
} = options;
|
|
40
|
-
|
|
41
|
-
const baseHeaders = {
|
|
42
|
-
'Accept': 'application/json',
|
|
43
|
-
'User-Agent': 'ryuhan-baileys/1.2.9-nl',
|
|
44
|
-
...(apiKey ? { 'Authorization': `Bearer ${apiKey}`, 'x-api-key': apiKey } : {}),
|
|
45
|
-
...extraHeaders
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Fetch dengan timeout.
|
|
50
|
-
*/
|
|
51
|
-
async function _fetch(url, opts = {}) {
|
|
52
|
-
const controller = new AbortController();
|
|
53
|
-
const timer = setTimeout(() => controller.abort(), timeout);
|
|
54
|
-
try {
|
|
55
|
-
const res = await fetch(url, {
|
|
56
|
-
...opts,
|
|
57
|
-
signal: controller.signal,
|
|
58
|
-
headers: { ...baseHeaders, ...(opts.headers || {}) }
|
|
59
|
-
});
|
|
60
|
-
if (!res.ok) {
|
|
61
|
-
const errText = await res.text().catch(() => '');
|
|
62
|
-
throw new Error(`Apocalypse API error ${res.status}: ${errText || res.statusText}`);
|
|
63
|
-
}
|
|
64
|
-
const ct = res.headers.get('content-type') || '';
|
|
65
|
-
if (ct.includes('application/json')) {
|
|
66
|
-
return await res.json();
|
|
67
|
-
}
|
|
68
|
-
// Buffer untuk response binary (gambar, audio, video)
|
|
69
|
-
return await res.arrayBuffer().then(buf => Buffer.from(buf));
|
|
70
|
-
} finally {
|
|
71
|
-
clearTimeout(timer);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Normalise path — pastikan leading slash ada.
|
|
77
|
-
*/
|
|
78
|
-
function _url(path) {
|
|
79
|
-
const p = path.startsWith('/') ? path : `/${path}`;
|
|
80
|
-
return `${BASE_URL}${p}`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// ── Public methods ──────────────────────────────────────────────────────
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* GET request ke Apocalypse API.
|
|
87
|
-
*
|
|
88
|
-
* @param {string} path — path + query string, contoh: '/search/spotify?q=swim'
|
|
89
|
-
* @returns {Promise<object|Buffer>}
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* const res = await apocalypse.get('/search/spotify?q=swim')
|
|
93
|
-
* const res = await apocalypse.get('/manga/jagoanmanga/search?q=killer+peter')
|
|
94
|
-
*/
|
|
95
|
-
async function get(path) {
|
|
96
|
-
return _fetch(_url(path));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* GET dengan params object — otomatis di-encode ke query string.
|
|
101
|
-
*
|
|
102
|
-
* @param {string} path — path tanpa query string
|
|
103
|
-
* @param {object} [params] — query params
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* const res = await apocalypse.fetch('/search/spotify', { q: 'swim' })
|
|
107
|
-
* const res = await apocalypse.fetch('/manga/jagoanmanga/search', { q: 'killer peter' })
|
|
108
|
-
* const res = await apocalypse.fetch('/downloader/tiktok', { url: 'https://...' })
|
|
109
|
-
*/
|
|
110
|
-
async function fetchApi(path, params = {}) {
|
|
111
|
-
const base = path.startsWith('/') ? path : `/${path}`;
|
|
112
|
-
const qs = new URLSearchParams(
|
|
113
|
-
Object.fromEntries(
|
|
114
|
-
Object.entries(params)
|
|
115
|
-
.filter(([, v]) => v !== undefined && v !== null)
|
|
116
|
-
.map(([k, v]) => [k, String(v)])
|
|
117
|
-
)
|
|
118
|
-
).toString();
|
|
119
|
-
const full = qs ? `${BASE_URL}${base}?${qs}` : `${BASE_URL}${base}`;
|
|
120
|
-
return _fetch(full);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* POST request.
|
|
125
|
-
*
|
|
126
|
-
* @param {string} path
|
|
127
|
-
* @param {object} [body]
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* const res = await apocalypse.post('/ai/gpt', { text: 'hello' })
|
|
131
|
-
*/
|
|
132
|
-
async function post(path, body = {}) {
|
|
133
|
-
return _fetch(_url(path), {
|
|
134
|
-
method: 'POST',
|
|
135
|
-
headers: { 'Content-Type': 'application/json' },
|
|
136
|
-
body: JSON.stringify(body)
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// ── Shorthand helpers ───────────────────────────────────────────────────
|
|
141
|
-
|
|
142
|
-
/** Search wrapper — apocalypse.search('spotify', 'swim') */
|
|
143
|
-
async function search(endpoint, query) {
|
|
144
|
-
return fetchApi(`/search/${endpoint}`, { q: query });
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/** Downloader wrapper — apocalypse.download('tiktok', url) */
|
|
148
|
-
async function download(endpoint, url) {
|
|
149
|
-
return fetchApi(`/downloader/${endpoint}`, { url });
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/** AI wrapper — apocalypse.ai('gpt', text) */
|
|
153
|
-
async function ai(endpoint, text, extra = {}) {
|
|
154
|
-
return fetchApi(`/ai/${endpoint}`, { text, ...extra });
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/** Sticker wrapper — apocalypse.sticker(endpoint, url) */
|
|
158
|
-
async function sticker(endpoint, url) {
|
|
159
|
-
return fetchApi(`/sticker/${endpoint}`, { url });
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/** Manga wrapper — apocalypse.manga('jagoanmanga', 'search', { q: 'killer' }) */
|
|
163
|
-
async function manga(site, endpoint, params = {}) {
|
|
164
|
-
return fetchApi(`/manga/${site}/${endpoint}`, params);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/** Game wrapper — apocalypse.game(endpoint, params) */
|
|
168
|
-
async function game(endpoint, params = {}) {
|
|
169
|
-
return fetchApi(`/game/${endpoint}`, params);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return {
|
|
173
|
-
// Core
|
|
174
|
-
get,
|
|
175
|
-
fetch: fetchApi,
|
|
176
|
-
post,
|
|
177
|
-
// Shorthands
|
|
178
|
-
search,
|
|
179
|
-
download,
|
|
180
|
-
ai,
|
|
181
|
-
sticker,
|
|
182
|
-
manga,
|
|
183
|
-
game,
|
|
184
|
-
// Expose base URL
|
|
185
|
-
BASE_URL,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Instance default tanpa API key — siap pakai langsung.
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* import { apocalypse } from '@ryuhan/baileys';
|
|
194
|
-
* const res = await apocalypse.get('/search/spotify?q=swim');
|
|
195
|
-
*/
|
|
196
|
-
export const apocalypse = createApocalypseApi();
|