zaileys 0.28.92-dev → 0.28.94-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.
- package/LICENSE +1 -1
- package/README.md +77 -8
- package/dist/Modules/Action.d.ts +14 -0
- package/dist/Modules/Action.js +16 -0
- package/dist/Modules/Client.d.ts +36 -0
- package/dist/Modules/Client.js +274 -0
- package/dist/Modules/Config.d.ts +72 -0
- package/dist/Modules/Config.js +75 -0
- package/dist/Modules/Utils.d.ts +2 -0
- package/dist/Modules/Utils.js +26 -0
- package/dist/Parser/Message.d.ts +18 -0
- package/dist/Parser/Message.js +127 -0
- package/dist/Types/Action.d.ts +9 -0
- package/dist/Types/Action.js +2 -0
- package/dist/Types/General.d.ts +38 -0
- package/dist/Types/General.js +2 -0
- package/dist/Types/Message.d.ts +44 -0
- package/dist/Types/Message.js +2 -0
- package/dist/index.d.ts +3 -183
- package/dist/index.js +6 -102
- package/package.json +52 -41
- package/demo/ai/tools.js +0 -28
- package/demo/ai/you.js +0 -30
- package/demo/index.js +0 -26
- package/demo/package.json +0 -16
- package/demo/pnpm-lock.yaml +0 -1222
- package/demo/screenshot.png +0 -0
- package/dist/index.d.mts +0 -183
- package/dist/index.mjs +0 -102
- package/docs.css +0 -10
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,11 +1,80 @@
|
|
|
1
|
-
<p align="center"><img src="https://socialify.git.ci/
|
|
1
|
+
<p align="center"><img src="https://socialify.git.ci/zeative/zaileys/image?description=1&descriptionEditable=Zaileys%20is%20a%20simplified%20version%20of%20the%20Baileys%20package%20%0Awhich%20is%20easier%20and%20faster.&font=KoHo&forks=1&issues=1&language=1&name=1&owner=1&pattern=Circuit%20Board&pulls=1&stargazers=1&theme=Auto" alt="project-image"></p>
|
|
2
2
|
|
|
3
|
-
<h1 align="center" id="title">Zaileys - Typescript/Javascript WhatsApp NodeJS API</h1>
|
|
3
|
+
<h1 align="center" id="title">Zaileys - Simplify Typescript/Javascript WhatsApp NodeJS API</h1>
|
|
4
4
|
|
|
5
|
-
<
|
|
5
|
+
<div align='center'>
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
[](https://www.npmjs.com/package/zaileys)
|
|
8
|
+
[](https://www.npmjs.com/package/zaileys)
|
|
9
|
+
[](https://www.npmjs.com/package/zaileys)
|
|
10
|
+
[](https://www.npmjs.com/package/zaileys)
|
|
11
|
+
[](https://github.com/zeative/zaileys)
|
|
12
|
+
<br>
|
|
13
|
+
[](https://github.com/zeative/zaileys)
|
|
14
|
+
[](https://github.com/zeative/zaileys)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
Zaileys is a powerful and flexible WhatsApp API library for Node.js, built on top of Baileys. It simplifies the process of integrating WhatsApp functionalities into your applications, providing a comprehensive set of features for building robust and scalable WhatsApp-based solutions.
|
|
19
|
+
|
|
20
|
+
**Key Features:**
|
|
21
|
+
|
|
22
|
+
* **Multi-Device Support:** Leverage the latest WhatsApp multi-device features for enhanced reliability and performance.
|
|
23
|
+
* **Comprehensive API:** Access a wide range of WhatsApp functionalities, including sending and receiving messages, media handling, group management, and more.
|
|
24
|
+
* **Easy to Use:** Designed with developer experience in mind, Zaileys offers a clean and intuitive API that is easy to learn and use.
|
|
25
|
+
* **Highly Customizable:** Adapt the library to your specific needs with flexible configuration options and modular design.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install zaileys
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### Import Client
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { Client } from 'zaileys';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Basic Example
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { Client } from 'zaileys';
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Features
|
|
49
|
+
|
|
50
|
+
- **Simple Client Initialization**: Easy setup with the `Client` class.
|
|
51
|
+
- **Effortless Connection Management**: Connect and reconnect to WhatsApp with built-in functions.
|
|
52
|
+
- **Versatile Message Handling**: Send and receive text, media, and interactive messages.
|
|
53
|
+
- **Group Management**: Create, join, and manage WhatsApp groups.
|
|
54
|
+
- **Contact Management**: Interact with contacts, block/unblock, and manage your contact list.
|
|
55
|
+
- **Real-time Event Handling**: Get notified of events in real-time using a simple event listener system.
|
|
56
|
+
- **Advanced Media Support**: Send and receive various types of media messages, including images, videos, audio, documents, and stickers.
|
|
57
|
+
- **Location and Live Location Sharing**: Share and receive locations and live locations.
|
|
58
|
+
- **Interactive Messages**: Send and receive interactive messages like buttons, lists, and quick reply buttons.
|
|
59
|
+
- **Presence Management**: Manage your online presence with presence features.
|
|
60
|
+
- **Device Synchronization**: Leverage multi-device features for seamless device synchronization.
|
|
61
|
+
|
|
62
|
+
## Contributing
|
|
63
|
+
|
|
64
|
+
Contributions are welcome! Please follow these steps to contribute:
|
|
65
|
+
|
|
66
|
+
1. Fork the repository.
|
|
67
|
+
2. Create a new branch for your feature or bug fix (`git checkout -b feature/your-feature-name` or `git checkout -b fix/bug-description`).
|
|
68
|
+
3. Make your changes and commit them (`git commit -m 'Add some AmazingFeature'`).
|
|
69
|
+
4. Push your changes to your forked repository (`git push origin feature/your-feature-name`).
|
|
70
|
+
5. Submit a pull request to the main repository.
|
|
71
|
+
|
|
72
|
+
Please ensure your code follows the project's coding standards and includes appropriate tests.
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
This project is licensed under the [MIT License](LICENSE) - see the [LICENSE](LICENSE) file for details.
|
|
77
|
+
|
|
78
|
+
## Acknowledgements
|
|
79
|
+
|
|
80
|
+
- [Baileys](https://github.com/WhiskeySockets/Baileys) - The WhatsApp Web API library this project is based on.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import EventEmitter from "events";
|
|
3
|
+
import { Client } from "./Client";
|
|
4
|
+
type ActionType = {
|
|
5
|
+
config: Client["config"];
|
|
6
|
+
socket: Client["socket"];
|
|
7
|
+
store: Client["store"];
|
|
8
|
+
};
|
|
9
|
+
export declare class Action extends EventEmitter {
|
|
10
|
+
private provider;
|
|
11
|
+
constructor();
|
|
12
|
+
protected setProvider(provider: ActionType): void;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Action = void 0;
|
|
7
|
+
const events_1 = __importDefault(require("events"));
|
|
8
|
+
class Action extends events_1.default {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
setProvider(provider) {
|
|
13
|
+
this.provider = provider;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.Action = Action;
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
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;
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 {};
|