zaileys 0.28.99-beta → 0.29.0-beta

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.
@@ -1,36 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { proto } from "@whiskeysockets/baileys";
5
- import { EventEmitter } from "events";
6
- import { FakeVerifiedEnum, ReplyActionType, SendActionType } from "../Types/Action";
7
- import { ClientConfig, ClientEvents } from "../Types/General";
8
- import { MessageBaseContent } from "../Types/Message";
9
- export declare class Client extends EventEmitter {
10
- private config;
11
- private authState;
12
- private authProvider;
13
- private socket;
14
- private store;
15
- private groupCache;
16
- private logger;
17
- protected temporaryMessage: MessageBaseContent<any> | null;
18
- protected parseMention: string[];
19
- constructor(config: ClientConfig);
20
- protected initialize(): Promise<void>;
21
- on<K extends keyof ClientEvents<typeof this.config.citation>>(event: K, listener: ClientEvents<typeof this.config.citation>[K]): this;
22
- emit<K extends keyof ClientEvents<typeof this.config.citation>>(event: K, ...args: Parameters<ClientEvents<typeof this.config.citation>[K]>): boolean;
23
- protected generateMentions(mentions: string[]): string[];
24
- protected generateFakeVerified(key: proto.IMessageKey, platform: FakeVerifiedEnum): {
25
- participant: "0@s.whatsapp.net" | "13135550002@s.whatsapp.net" | "18002428478@s.whatsapp.net" | "18772241042@s.whatsapp.net" | "447723442971@s.whatsapp.net" | "6285574670498@s.whatsapp.net";
26
- remoteJid?: string | null | undefined;
27
- fromMe?: boolean | null | undefined;
28
- id?: string | null | undefined;
29
- };
30
- sendText(text: string, payload?: ReplyActionType): Promise<void>;
31
- sendReply(text: string, payload?: ReplyActionType): Promise<void>;
32
- sendImage(image: string | Buffer, payload?: SendActionType): Promise<void>;
33
- sendVideo(video: string | Buffer, payload?: SendActionType): Promise<void>;
34
- sendAudio(audio: string | Buffer, payload?: SendActionType): Promise<void>;
35
- sendSticker(sticker: string | Buffer, payload?: SendActionType): Promise<void>;
36
- }
@@ -1,274 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Client = void 0;
30
- const baileys_1 = __importStar(require("@whiskeysockets/baileys"));
31
- const awesome_phonenumber_1 = require("awesome-phonenumber");
32
- const consola_1 = __importDefault(require("consola"));
33
- const events_1 = require("events");
34
- const node_cache_1 = __importDefault(require("node-cache"));
35
- const pino_1 = __importDefault(require("pino"));
36
- const Message_1 = require("../Parser/Message");
37
- const Config_1 = require("./Config");
38
- class Client extends events_1.EventEmitter {
39
- constructor(config) {
40
- var _a;
41
- super();
42
- this.groupCache = new node_cache_1.default({ stdTTL: 5 * 60, useClones: false });
43
- this.logger = (0, pino_1.default)({ level: "silent", enabled: false });
44
- this.config = config;
45
- this.config.showLogs = !!this.config.showLogs;
46
- this.config.autoOnline = !!this.config.autoOnline;
47
- this.config.authPath = this.config.authPath || ".zaileys";
48
- this.config.ignoreMe = this.config.ignoreMe == undefined ? true : this.config.ignoreMe;
49
- this.config.showLogs = this.config.showLogs == undefined ? true : this.config.showLogs;
50
- this.authProvider = (0, baileys_1.useMultiFileAuthState)(this.config.authPath + "/session");
51
- this.store = (0, baileys_1.makeInMemoryStore)({ logger: this.logger });
52
- (_a = this.store) === null || _a === void 0 ? void 0 : _a.readFromFile(this.config.authPath + "/memory.json");
53
- setInterval(() => {
54
- var _a;
55
- (_a = this.store) === null || _a === void 0 ? void 0 : _a.writeToFile(this.config.authPath + "/memory.json");
56
- }, 10000);
57
- const configKeys = Object.keys(this.config).length;
58
- if (configKeys)
59
- this.initialize();
60
- }
61
- async initialize() {
62
- var _a, _b, _c;
63
- console.clear();
64
- const { state, saveCreds } = await this.authProvider;
65
- this.authState = {
66
- load: state,
67
- save: saveCreds,
68
- };
69
- this.socket = (0, baileys_1.default)({
70
- logger: this.logger,
71
- printQRInTerminal: this.config.authType == "qr",
72
- markOnlineOnConnect: this.config.autoOnline,
73
- auth: { creds: this.authState.load.creds, keys: (0, baileys_1.makeCacheableSignalKeyStore)(this.authState.load.keys, this.logger) },
74
- version: [2, 3000, 1017531287],
75
- syncFullHistory: true,
76
- msgRetryCounterCache: new node_cache_1.default(),
77
- browser: baileys_1.Browsers.ubuntu(this.config.authType == "qr" ? "Zaileys Library" : "Firefox"),
78
- cachedGroupMetadata: async (jid) => this.groupCache.get(jid),
79
- getMessage: async (key) => {
80
- if (this.store) {
81
- const msg = await this.store.loadMessage(key.remoteJid, key.id);
82
- return (msg === null || msg === void 0 ? void 0 : msg.message) || undefined;
83
- }
84
- return baileys_1.proto.Message.fromObject({});
85
- },
86
- shouldSyncHistoryMessage: (messages) => {
87
- consola_1.default.warn(`Syncing message: ${messages.chunkOrder} ${messages.progress}%`);
88
- return !!messages.syncType;
89
- },
90
- });
91
- this.store.bind(this.socket.ev);
92
- if (this.config.authType == "pairing" && this.config.phoneNumber && !this.socket.authState.creds.registered) {
93
- if (!this.config.phoneNumber) {
94
- consola_1.default.warn("Nomor nya mana woe!");
95
- return;
96
- }
97
- if (!(0, awesome_phonenumber_1.parsePhoneNumber)("+" + this.config.phoneNumber.toString()).valid) {
98
- consola_1.default.warn("Nomor ga valid woe!");
99
- return;
100
- }
101
- setTimeout(async () => {
102
- if (this.config.authType == "pairing") {
103
- const code = await this.socket.requestPairingCode(this.config.phoneNumber.toString());
104
- consola_1.default.info("Nih kode nya: " + code);
105
- }
106
- }, 5000);
107
- }
108
- (_a = this.socket) === null || _a === void 0 ? void 0 : _a.ev.on("connection.update", (update) => {
109
- var _a, _b, _c;
110
- const { connection, lastDisconnect, qr } = update;
111
- this.emit("connection", { status: connection || "connecting" });
112
- if (this.config.authType == "qr" && qr) {
113
- consola_1.default.info("Nih bro qr nya: ");
114
- }
115
- if (connection === "close") {
116
- const code = (_b = (_a = lastDisconnect === null || lastDisconnect === void 0 ? void 0 : lastDisconnect.error) === null || _a === void 0 ? void 0 : _a.output) === null || _b === void 0 ? void 0 : _b.statusCode;
117
- const isReconnect = code !== baileys_1.DisconnectReason.loggedOut;
118
- consola_1.default.error(code, (_c = lastDisconnect === null || lastDisconnect === void 0 ? void 0 : lastDisconnect.error) === null || _c === void 0 ? void 0 : _c.message);
119
- if (code == 401 || code == 405 || code == 500) {
120
- consola_1.default.warn(`Bad session, please delete "${this.config.authPath}" folder and try again`);
121
- process.exit(1);
122
- }
123
- if (isReconnect)
124
- this.initialize();
125
- }
126
- else if (connection === "open") {
127
- consola_1.default.success("Opened connection");
128
- }
129
- });
130
- (_b = this.socket) === null || _b === void 0 ? void 0 : _b.ev.on("creds.update", this.authState.save);
131
- this.socket.ev.on("contacts.update", (update) => {
132
- var _a;
133
- for (let contact of update) {
134
- let id = (0, baileys_1.jidNormalizedUser)(contact.id);
135
- if (this.store && this.store.contacts)
136
- this.store.contacts[id] = { ...(((_a = this.store.contacts) === null || _a === void 0 ? void 0 : _a[id]) || {}), ...(contact || {}) };
137
- }
138
- });
139
- this.socket.ev.on("contacts.upsert", (update) => {
140
- for (let contact of update) {
141
- let id = (0, baileys_1.jidNormalizedUser)(contact.id);
142
- if (this.store && this.store.contacts)
143
- this.store.contacts[id] = { ...(contact || {}) };
144
- }
145
- });
146
- (_c = this.socket) === null || _c === void 0 ? void 0 : _c.ev.on("messages.upsert", async (upsert) => {
147
- const messages = upsert.messages;
148
- for (const msg of messages) {
149
- if (this.config.ignoreMe && msg.key.fromMe)
150
- continue;
151
- const provider = new Message_1.MessageParser({ message: msg, socket: this.socket, config: this.config, store: this.store });
152
- const handle = await provider.handle();
153
- if (handle) {
154
- if (this.config.autoRead) {
155
- await this.socket.readMessages([handle.key()]);
156
- }
157
- this.temporaryMessage = handle;
158
- if (this.config.autoMentions) {
159
- this.parseMention = handle.mentions;
160
- }
161
- this.emit("message", handle);
162
- }
163
- }
164
- });
165
- this.socket.ev.on("groups.update", async ([event]) => {
166
- const metadata = await this.socket.groupMetadata(event.id);
167
- this.groupCache.set(event.id, metadata);
168
- });
169
- this.socket.ev.on("group-participants.update", async (event) => {
170
- const metadata = await this.socket.groupMetadata(event.id);
171
- this.groupCache.set(event.id, metadata);
172
- });
173
- this.socket.ev.on("call", async (caller) => {
174
- for (const call of caller) {
175
- if (this.config.autoRejectCall) {
176
- await this.socket.rejectCall(call.id, call.from);
177
- }
178
- }
179
- });
180
- }
181
- on(event, listener) {
182
- return super.on(event, listener);
183
- }
184
- emit(event, ...args) {
185
- return super.emit(event, ...args);
186
- }
187
- // async sendText(text: string) {
188
- // this.socket.sendMessage(this?.temporaryMessage?.roomId!, { text });
189
- // }
190
- generateMentions(mentions) {
191
- const tags = ["@s.whatsapp.net", "@g.us", "@newsletter"];
192
- const mentioned = [];
193
- mentions === null || mentions === void 0 ? void 0 : mentions.forEach((x) => {
194
- tags.forEach((y) => {
195
- mentioned.push(x.slice(1) + y);
196
- });
197
- });
198
- return mentioned;
199
- }
200
- generateFakeVerified(key, platform) {
201
- return { ...key, participant: Config_1.VERIFIED_PLATFORM[platform] };
202
- }
203
- async sendText(text, payload) {
204
- var _a, _b, _c;
205
- if (payload === null || payload === void 0 ? void 0 : payload.footer) {
206
- let builder = (0, baileys_1.generateWAMessageFromContent)((_a = this.temporaryMessage) === null || _a === void 0 ? void 0 : _a.roomId, {
207
- interactiveMessage: {
208
- contextInfo: { mentionedJid: this.generateMentions(this.parseMention) },
209
- body: {
210
- text,
211
- },
212
- footer: {
213
- text: payload === null || payload === void 0 ? void 0 : payload.footer,
214
- },
215
- nativeFlowMessage: {},
216
- },
217
- }, { userJid: (_b = this === null || this === void 0 ? void 0 : this.temporaryMessage) === null || _b === void 0 ? void 0 : _b.roomId });
218
- await this.socket.relayMessage(builder.key.remoteJid, builder.message, { messageId: builder.key.id });
219
- }
220
- else {
221
- await this.socket.sendMessage((_c = this.temporaryMessage) === null || _c === void 0 ? void 0 : _c.roomId, { text });
222
- }
223
- }
224
- async sendReply(text, payload) {
225
- var _a, _b, _c, _d, _e, _f, _g;
226
- if (payload === null || payload === void 0 ? void 0 : payload.footer) {
227
- let builder = (0, baileys_1.generateWAMessageFromContent)((_a = this.temporaryMessage) === null || _a === void 0 ? void 0 : _a.roomId, {
228
- interactiveMessage: {
229
- contextInfo: { mentionedJid: this.generateMentions(this.parseMention) },
230
- body: {
231
- text,
232
- },
233
- footer: {
234
- text: payload === null || payload === void 0 ? void 0 : payload.footer,
235
- },
236
- nativeFlowMessage: {},
237
- },
238
- }, { quoted: { ...(_b = this.temporaryMessage) === null || _b === void 0 ? void 0 : _b.message(), key: this.generateFakeVerified((_c = this === null || this === void 0 ? void 0 : this.temporaryMessage) === null || _c === void 0 ? void 0 : _c.message().key, payload.fakeVerified) }, userJid: (_d = this === null || this === void 0 ? void 0 : this.temporaryMessage) === null || _d === void 0 ? void 0 : _d.roomId });
239
- await this.socket.relayMessage(builder.key.remoteJid, builder.message, { messageId: builder.key.id });
240
- }
241
- else {
242
- await this.socket.sendMessage((_e = this.temporaryMessage) === null || _e === void 0 ? void 0 : _e.roomId, { text }, { quoted: { ...(_f = this === null || this === void 0 ? void 0 : this.temporaryMessage) === null || _f === void 0 ? void 0 : _f.message(), key: this.generateFakeVerified((_g = this === null || this === void 0 ? void 0 : this.temporaryMessage) === null || _g === void 0 ? void 0 : _g.message().key, payload === null || payload === void 0 ? void 0 : payload.fakeVerified) } });
243
- }
244
- }
245
- async sendImage(image, payload) {
246
- var _a, _b;
247
- const imager = typeof image == "string" ? { image: { url: image } } : { image };
248
- this.socket.sendMessage((_a = this === null || this === void 0 ? void 0 : this.temporaryMessage) === null || _a === void 0 ? void 0 : _a.roomId, { ...imager }, {
249
- ...((payload === null || payload === void 0 ? void 0 : payload.asReply) && { quoted: (_b = this === null || this === void 0 ? void 0 : this.temporaryMessage) === null || _b === void 0 ? void 0 : _b.message() }),
250
- });
251
- }
252
- async sendVideo(video, payload) {
253
- var _a, _b;
254
- const videor = typeof video == "string" ? { video: { url: video } } : { video };
255
- this.socket.sendMessage((_a = this === null || this === void 0 ? void 0 : this.temporaryMessage) === null || _a === void 0 ? void 0 : _a.roomId, { ...videor }, {
256
- ...((payload === null || payload === void 0 ? void 0 : payload.asReply) && { quoted: (_b = this === null || this === void 0 ? void 0 : this.temporaryMessage) === null || _b === void 0 ? void 0 : _b.message() }),
257
- });
258
- }
259
- async sendAudio(audio, payload) {
260
- var _a, _b;
261
- const audior = typeof audio == "string" ? { audio: { url: audio } } : { audio };
262
- this.socket.sendMessage((_a = this.temporaryMessage) === null || _a === void 0 ? void 0 : _a.roomId, { ...audior }, {
263
- ...((payload === null || payload === void 0 ? void 0 : payload.asReply) && { quoted: (_b = this === null || this === void 0 ? void 0 : this.temporaryMessage) === null || _b === void 0 ? void 0 : _b.message() }),
264
- });
265
- }
266
- async sendSticker(sticker, payload) {
267
- var _a, _b;
268
- const stickerr = typeof sticker == "string" ? { sticker: { url: sticker } } : { sticker };
269
- this.socket.sendMessage((_a = this.temporaryMessage) === null || _a === void 0 ? void 0 : _a.roomId, { ...stickerr }, {
270
- ...((payload === null || payload === void 0 ? void 0 : payload.asReply) && { quoted: (_b = this === null || this === void 0 ? void 0 : this.temporaryMessage) === null || _b === void 0 ? void 0 : _b.message() }),
271
- });
272
- }
273
- }
274
- exports.Client = Client;
@@ -1,72 +0,0 @@
1
- export declare const MESSAGE_TYPE: {
2
- readonly text: "text";
3
- readonly conversation: "text";
4
- readonly imageMessage: "image";
5
- readonly contactMessage: "contact";
6
- readonly locationMessage: "location";
7
- readonly documentMessage: "document";
8
- readonly audioMessage: "audio";
9
- readonly videoMessage: "video";
10
- readonly protocolMessage: "protocol";
11
- readonly contactsArrayMessage: "contactsArray";
12
- readonly highlyStructuredMessage: "highlyStructured";
13
- readonly sendPaymentMessage: "sendPayment";
14
- readonly liveLocationMessage: "liveLocation";
15
- readonly requestPaymentMessage: "requestPayment";
16
- readonly declinePaymentRequestMessage: "declinePaymentRequest";
17
- readonly cancelPaymentRequestMessage: "cancelPaymentRequest";
18
- readonly templateMessage: "template";
19
- readonly stickerMessage: "sticker";
20
- readonly groupInviteMessage: "groupInvite";
21
- readonly templateButtonReplyMessage: "templateButtonReply";
22
- readonly productMessage: "product";
23
- readonly deviceSentMessage: "deviceSent";
24
- readonly listMessage: "list";
25
- readonly viewOnceMessage: "viewOnce";
26
- readonly orderMessage: "order";
27
- readonly listResponseMessage: "listResponse";
28
- readonly ephemeralMessage: "ephemeral";
29
- readonly invoiceMessage: "invoice";
30
- readonly buttonsMessage: "buttons";
31
- readonly buttonsResponseMessage: "buttonsResponse";
32
- readonly paymentInviteMessage: "paymentInvite";
33
- readonly interactiveMessage: "interactive";
34
- readonly reactionMessage: "reaction";
35
- readonly stickerSyncRmrMessage: "sticker";
36
- readonly interactiveResponseMessage: "interactiveResponse";
37
- readonly pollCreationMessage: "pollCreation";
38
- readonly pollUpdateMessage: "pollUpdate";
39
- readonly keepInChatMessage: "keepInChat";
40
- readonly documentWithCaptionMessage: "document";
41
- readonly requestPhoneNumberMessage: "requestPhoneNumber";
42
- readonly viewOnceMessageV2: "viewOnce";
43
- readonly encReactionMessage: "reaction";
44
- readonly editedMessage: "text";
45
- readonly viewOnceMessageV2Extension: "viewOnce";
46
- readonly pollCreationMessageV2: "pollCreation";
47
- readonly scheduledCallCreationMessage: "scheduledCallCreation";
48
- readonly groupMentionedMessage: "groupMentioned";
49
- readonly pinInChatMessage: "pinInChat";
50
- readonly pollCreationMessageV3: "pollCreation";
51
- readonly scheduledCallEditMessage: "scheduledCallEdit";
52
- readonly ptvMessage: "ptv";
53
- readonly botInvokeMessage: "botInvoke";
54
- readonly callLogMesssage: "callLog";
55
- readonly encCommentMessage: "encComment";
56
- readonly bcallMessage: "bcall";
57
- readonly lottieStickerMessage: "lottieSticker";
58
- readonly eventMessage: "event";
59
- readonly commentMessage: "comment";
60
- readonly newsletterAdminInviteMessage: "text";
61
- readonly extendedTextMessageWithParentKey: "text";
62
- readonly placeholderMessage: "placeholder";
63
- readonly encEventUpdateMessage: "encEventUpdate";
64
- };
65
- export declare const VERIFIED_PLATFORM: {
66
- readonly whatsapp: "0@s.whatsapp.net";
67
- readonly meta: "13135550002@s.whatsapp.net";
68
- readonly chatgpt: "18002428478@s.whatsapp.net";
69
- readonly copilot: "18772241042@s.whatsapp.net";
70
- readonly instagram: "447723442971@s.whatsapp.net";
71
- readonly tiktok: "6285574670498@s.whatsapp.net";
72
- };
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VERIFIED_PLATFORM = exports.MESSAGE_TYPE = void 0;
4
- exports.MESSAGE_TYPE = {
5
- text: "text",
6
- conversation: "text",
7
- imageMessage: "image",
8
- contactMessage: "contact",
9
- locationMessage: "location",
10
- documentMessage: "document",
11
- audioMessage: "audio",
12
- videoMessage: "video",
13
- protocolMessage: "protocol",
14
- contactsArrayMessage: "contactsArray",
15
- highlyStructuredMessage: "highlyStructured",
16
- sendPaymentMessage: "sendPayment",
17
- liveLocationMessage: "liveLocation",
18
- requestPaymentMessage: "requestPayment",
19
- declinePaymentRequestMessage: "declinePaymentRequest",
20
- cancelPaymentRequestMessage: "cancelPaymentRequest",
21
- templateMessage: "template",
22
- stickerMessage: "sticker",
23
- groupInviteMessage: "groupInvite",
24
- templateButtonReplyMessage: "templateButtonReply",
25
- productMessage: "product",
26
- deviceSentMessage: "deviceSent",
27
- listMessage: "list",
28
- viewOnceMessage: "viewOnce",
29
- orderMessage: "order",
30
- listResponseMessage: "listResponse",
31
- ephemeralMessage: "ephemeral",
32
- invoiceMessage: "invoice",
33
- buttonsMessage: "buttons",
34
- buttonsResponseMessage: "buttonsResponse",
35
- paymentInviteMessage: "paymentInvite",
36
- interactiveMessage: "interactive",
37
- reactionMessage: "reaction",
38
- stickerSyncRmrMessage: "sticker",
39
- interactiveResponseMessage: "interactiveResponse",
40
- pollCreationMessage: "pollCreation",
41
- pollUpdateMessage: "pollUpdate",
42
- keepInChatMessage: "keepInChat",
43
- documentWithCaptionMessage: "document",
44
- requestPhoneNumberMessage: "requestPhoneNumber",
45
- viewOnceMessageV2: "viewOnce",
46
- encReactionMessage: "reaction",
47
- editedMessage: "text",
48
- viewOnceMessageV2Extension: "viewOnce",
49
- pollCreationMessageV2: "pollCreation",
50
- scheduledCallCreationMessage: "scheduledCallCreation",
51
- groupMentionedMessage: "groupMentioned",
52
- pinInChatMessage: "pinInChat",
53
- pollCreationMessageV3: "pollCreation",
54
- scheduledCallEditMessage: "scheduledCallEdit",
55
- ptvMessage: "ptv",
56
- botInvokeMessage: "botInvoke",
57
- callLogMesssage: "callLog",
58
- encCommentMessage: "encComment",
59
- bcallMessage: "bcall",
60
- lottieStickerMessage: "lottieSticker",
61
- eventMessage: "event",
62
- commentMessage: "comment",
63
- newsletterAdminInviteMessage: "text",
64
- extendedTextMessageWithParentKey: "text",
65
- placeholderMessage: "placeholder",
66
- encEventUpdateMessage: "encEventUpdate",
67
- };
68
- exports.VERIFIED_PLATFORM = {
69
- whatsapp: "0@s.whatsapp.net",
70
- meta: "13135550002@s.whatsapp.net",
71
- chatgpt: "18002428478@s.whatsapp.net",
72
- copilot: "18772241042@s.whatsapp.net",
73
- instagram: "447723442971@s.whatsapp.net",
74
- tiktok: "6285574670498@s.whatsapp.net",
75
- };
@@ -1,2 +0,0 @@
1
- export declare const compareValue: (arr1: any[], arr2: any[]) => boolean;
2
- export declare const removeKeys: (obj: any, keys: any) => any;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeKeys = exports.compareValue = void 0;
4
- const compareValue = (arr1, arr2) => {
5
- const set1 = new Set(arr1);
6
- for (let item of arr2) {
7
- if (set1.has(item)) {
8
- return true;
9
- }
10
- }
11
- return false;
12
- };
13
- exports.compareValue = compareValue;
14
- const removeKeys = (obj, keys) => {
15
- if (Array.isArray(obj))
16
- return obj.map((item) => (0, exports.removeKeys)(item, keys));
17
- if (obj && typeof obj === "object") {
18
- return Object.keys(obj).reduce((acc, key) => {
19
- if (!keys.includes(key))
20
- acc[key] = (0, exports.removeKeys)(obj[key], keys);
21
- return acc;
22
- }, {});
23
- }
24
- return obj;
25
- };
26
- exports.removeKeys = removeKeys;
@@ -1,18 +0,0 @@
1
- import makeWASocket, { proto } from "@whiskeysockets/baileys";
2
- import { Client } from "../Modules/Client";
3
- import { MessageBaseContent } from "../Types/Message";
4
- interface MessageConfig {
5
- message: proto.IWebMessageInfo;
6
- socket: ReturnType<typeof makeWASocket>;
7
- config: Client["config"];
8
- store: Client["store"];
9
- }
10
- export declare class MessageParser {
11
- private socket;
12
- private message;
13
- private config;
14
- private store;
15
- constructor({ socket, message, config, store }: MessageConfig);
16
- handle<T>(payload?: proto.IWebMessageInfo): Promise<MessageBaseContent<T> | undefined>;
17
- }
18
- export {};
@@ -1,127 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageParser = void 0;
4
- const baileys_1 = require("@whiskeysockets/baileys");
5
- const Config_1 = require("../Modules/Config");
6
- const Utils_1 = require("../Modules/Utils");
7
- class MessageParser {
8
- constructor({ socket, message, config, store }) {
9
- this.socket = socket;
10
- this.message = message;
11
- this.config = config;
12
- this.store = store;
13
- }
14
- async handle(payload) {
15
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
16
- console.log(JSON.stringify(this.message, null, 2));
17
- const data = (0, Utils_1.removeKeys)(payload || this.message, ["senderKeyDistributionMessage", "messageContextInfo"]);
18
- if ((data === null || data === void 0 ? void 0 : data.messageStubType) || !Object.keys(data === null || data === void 0 ? void 0 : data.message).length)
19
- return;
20
- const messageData = data.ephemeralMessage || data;
21
- const isExtended = !!((_a = messageData.message) === null || _a === void 0 ? void 0 : _a.extendedTextMessage);
22
- const isEdited = !!((_c = (_b = messageData.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.editedMessage);
23
- const isBotInvoked = !!((_d = messageData.message) === null || _d === void 0 ? void 0 : _d.botInvokeMessage);
24
- const chatEdited = ((_g = (_f = (_e = messageData.message) === null || _e === void 0 ? void 0 : _e.protocolMessage) === null || _f === void 0 ? void 0 : _f.editedMessage) === null || _g === void 0 ? void 0 : _g.extendedTextMessage) || ((_j = (_h = messageData.message) === null || _h === void 0 ? void 0 : _h.protocolMessage) === null || _j === void 0 ? void 0 : _j.editedMessage);
25
- const originalType = isExtended
26
- ? Object.keys(messageData.message.extendedTextMessage)[0]
27
- : isEdited
28
- ? Object.keys(chatEdited)[0]
29
- : isBotInvoked
30
- ? Object.keys(messageData.message.botInvokeMessage.message.extendedTextMessage)[0]
31
- : Object.keys(messageData.message)[0];
32
- const chatRepliedId = isExtended ? (_m = (_l = (_k = messageData.message) === null || _k === void 0 ? void 0 : _k.extendedTextMessage) === null || _l === void 0 ? void 0 : _l.contextInfo) === null || _m === void 0 ? void 0 : _m.stanzaId : (_q = (_p = (_o = messageData.message) === null || _o === void 0 ? void 0 : _o[originalType]) === null || _p === void 0 ? void 0 : _p.contextInfo) === null || _q === void 0 ? void 0 : _q.stanzaId;
33
- let chatType = Config_1.MESSAGE_TYPE[originalType];
34
- if ((_s = (_r = messageData.message) === null || _r === void 0 ? void 0 : _r.protocolMessage) === null || _s === void 0 ? void 0 : _s.ephemeralExpiration)
35
- chatType = "ephemeral";
36
- const extract = isExtended
37
- ? messageData.message.extendedTextMessage[originalType]
38
- : isEdited
39
- ? chatEdited[originalType]
40
- : isBotInvoked
41
- ? messageData.message.botInvokeMessage.message.extendedTextMessage[originalType]
42
- : messageData.message[originalType];
43
- const text = typeof extract === "string" ? extract : (extract === null || extract === void 0 ? void 0 : extract.caption) || (extract === null || extract === void 0 ? void 0 : extract.text) || (extract === null || extract === void 0 ? void 0 : extract.name) || null;
44
- const mentions = (text === null || text === void 0 ? void 0 : text.match(/@\d+/g)) || null;
45
- const structure = {
46
- fromMe: messageData.key.fromMe,
47
- chatId: messageData.key.id,
48
- roomId: messageData.key.remoteJid,
49
- roomImage: async () => (await this.socket.profilePictureUrl(messageData.key.remoteJid, "image").catch(() => null)),
50
- senderId: messageData.participant || messageData.key.participant || messageData.key.remoteJid,
51
- senderName: messageData.pushName || messageData.verifiedBizName || null,
52
- senderDevice: (0, baileys_1.getDevice)(messageData.key.id),
53
- senderBio: async () => await this.socket
54
- .fetchStatus(messageData.key.participant || messageData.key.remoteJid)
55
- .then((x) => { var _a, _b; return (_b = (_a = x === null || x === void 0 ? void 0 : x[0]) === null || _a === void 0 ? void 0 : _a.status) === null || _b === void 0 ? void 0 : _b.status; })
56
- .catch(() => null),
57
- senderImage: async () => {
58
- const result = await this.socket.profilePictureUrl(messageData.key.participant || messageData.key.remoteJid, "image").catch(() => null);
59
- return result === undefined ? null : result;
60
- },
61
- senderBusiness: async () => (await this.socket.getBusinessProfile(messageData.key.participant || messageData.key.remoteJid).catch(() => null)),
62
- chatType,
63
- timestamp: Number((messageData.messageTimestamp.low || messageData.messageTimestamp || 0).toString()),
64
- text,
65
- command: (text === null || text === void 0 ? void 0 : text.startsWith(this.config.prefix)) ? (_t = text.split(" ")[0]) === null || _t === void 0 ? void 0 : _t.slice(1) : null,
66
- mentions,
67
- isGroup: messageData.key.remoteJid.endsWith("@g.us"),
68
- isStory: messageData.key.remoteJid.endsWith("@broadcast"),
69
- isEdited,
70
- isChannel: messageData.key.remoteJid.endsWith("@newsletter"),
71
- isBroadcast: !!messageData.broadcast,
72
- isEphemeral: chatType === "ephemeral" || !!((_w = (_v = (_u = messageData.message) === null || _u === void 0 ? void 0 : _u.extendedTextMessage) === null || _v === void 0 ? void 0 : _v.contextInfo) === null || _w === void 0 ? void 0 : _w.expiration),
73
- isForwarded: !!((_z = (_y = (_x = messageData.message) === null || _x === void 0 ? void 0 : _x.extendedTextMessage) === null || _y === void 0 ? void 0 : _y.contextInfo) === null || _z === void 0 ? void 0 : _z.isForwarded),
74
- citation: {},
75
- media: typeof extract !== "string" ? extract : null,
76
- reply: null,
77
- key: () => messageData.key,
78
- message: () => this.message,
79
- };
80
- if (structure.media) {
81
- structure.media = {
82
- ...structure.media,
83
- ...((structure.media.url || ((_1 = (_0 = messageData.message) === null || _0 === void 0 ? void 0 : _0.extendedTextMessage) === null || _1 === void 0 ? void 0 : _1.jpegThumbnail) || ((_2 = messageData.message) === null || _2 === void 0 ? void 0 : _2.newsletterAdminInviteMessage) || ((_3 = messageData.message) === null || _3 === void 0 ? void 0 : _3.orderMessage)) && {
84
- buffer: async () => await (0, baileys_1.downloadMediaMessage)(this.message, "buffer", {}).catch(() => null),
85
- stream: async () => await (0, baileys_1.downloadMediaMessage)(this.message, "stream", {}).catch(() => null),
86
- }),
87
- };
88
- structure.media =
89
- (0, Utils_1.removeKeys)(structure.media, [
90
- "url",
91
- "contextInfo",
92
- "fileSha256",
93
- "fileEncSha256",
94
- "mediaKey",
95
- "directPath",
96
- "waveform",
97
- "thumbnail",
98
- "jpegThumbnail",
99
- "thumbnailEncSha256",
100
- "thumbnailSha256",
101
- "thumbnailDirectPath",
102
- "firstFrameSidecar",
103
- "streamingSidecar",
104
- "scansSidecar",
105
- "callKey",
106
- "midQualityFileSha256",
107
- ]) || null;
108
- }
109
- if (this.config.citation) {
110
- const jidMapping = [(_4 = structure.roomId) === null || _4 === void 0 ? void 0 : _4.split("@")[0], (_5 = structure.senderId) === null || _5 === void 0 ? void 0 : _5.split("@")[0]];
111
- for (const key of Object.keys(this.config.citation)) {
112
- const citationKey = `is${key[0].toUpperCase()}${key.slice(1)}`;
113
- const output = await this.config.citation[key]();
114
- structure.citation = { ...(structure.citation || {}), [citationKey]: (0, Utils_1.compareValue)(output, jidMapping) };
115
- }
116
- }
117
- if (chatRepliedId) {
118
- const chatRepliedRoom = (_6 = this.store.messages[structure.roomId]) === null || _6 === void 0 ? void 0 : _6.get(chatRepliedId);
119
- const chatRepliedSender = (_7 = this.store.messages[structure.senderId]) === null || _7 === void 0 ? void 0 : _7.get(chatRepliedId);
120
- if (!chatRepliedRoom && !chatRepliedSender)
121
- return structure;
122
- structure.reply = (await this.handle(chatRepliedRoom || chatRepliedSender));
123
- }
124
- return structure;
125
- }
126
- }
127
- exports.MessageParser = MessageParser;
@@ -1,9 +0,0 @@
1
- import { VERIFIED_PLATFORM } from "../Modules/Config";
2
- export type FakeVerifiedEnum = keyof typeof VERIFIED_PLATFORM;
3
- export type SendActionType = {
4
- asReply?: boolean;
5
- };
6
- export type ReplyActionType = {
7
- footer?: string;
8
- fakeVerified?: FakeVerifiedEnum;
9
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });