whatsauto.js 2.0.0 โ 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 +171 -138
- package/dist/WhatsApp/AutoWA.d.ts.map +1 -1
- package/dist/WhatsApp/AutoWA.js +0 -1
- package/dist/WhatsApp/index.d.ts +3 -0
- package/dist/WhatsApp/index.d.ts.map +1 -1
- package/dist/WhatsApp/index.js +17 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,177 +1,210 @@
|
|
|
1
|
-
# WhatsAuto.js -
|
|
1
|
+
# WhatsAuto.js - Lightweight WhatsApp Automation
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**WhatsAuto.js** is a powerful, lightweight, and easy-to-use library for building WhatsApp automation applications using Node.js. Built on top of the robust [Baileys](https://github.com/WhiskeySockets/Baileys) library, it provides a high-level, Object-Oriented interface to interact with WhatsApp without the overhead of browser automation tools like Selenium or Puppeteer.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## โจ Features
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- **๐ Lightweight & Fast**: Runs directly on Node.js using WebSocket connections. No browser required.
|
|
8
|
+
- **๐ Flexible Authentication**: Supports both **QR Code** scanning and **Pairing Code** (phone number) login methods.
|
|
9
|
+
- **๐ฆ Object-Oriented Design**: Clean class-based architecture (`AutoWA`) making it easy to manage sessions and logic.
|
|
10
|
+
- **๐ฌ Rich Message Support**: Send and receive Text, Images, Videos, Audio (Voice Notes), Documents, and Stickers easily.
|
|
11
|
+
- **โก Event-Driven**: Listen to real-time events like `message`, `group-participants.update`, `connection.update`, etc.
|
|
12
|
+
- **๐ฅ Group Management**: Create tools to manage groups (add, remove, promote, demote members).
|
|
13
|
+
- **๐ ๏ธ Developer Friendly**: Written in TypeScript with full type definitions included.
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
---
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
npm i whatsauto.js@latest
|
|
13
|
-
```
|
|
17
|
+
## ๐ฅ Installation
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
Install the package via npm:
|
|
16
20
|
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
// or
|
|
20
|
-
import { AutoWA } from "whatsauto.js";
|
|
21
|
+
```bash
|
|
22
|
+
npm install whatsauto.js
|
|
21
23
|
```
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
---
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
const { default: AutoWA } = require("whatsauto.js");
|
|
27
|
-
```
|
|
27
|
+
## ๐ Quick Start
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
### 1. Initialize a Client
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
You can start a session using either a QR Code (default) or a Pairing Code.
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
**Option A: Using QR Code**
|
|
34
|
+
```ts
|
|
35
|
+
import { AutoWA } from "whatsauto.js";
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
const client = new AutoWA("my-session", {
|
|
38
|
+
printQR: true, // Prints QR code in the terminal
|
|
39
|
+
logging: true, // Enable logs
|
|
40
|
+
});
|
|
36
41
|
|
|
37
|
-
|
|
42
|
+
client.initialize();
|
|
38
43
|
|
|
39
|
-
|
|
44
|
+
client.on("connected", () => {
|
|
45
|
+
console.log("โ
Client is ready!");
|
|
46
|
+
});
|
|
47
|
+
```
|
|
40
48
|
|
|
49
|
+
**Option B: Using Pairing Code**
|
|
41
50
|
```ts
|
|
42
|
-
import AutoWA from "whatsauto.js";
|
|
43
|
-
|
|
44
|
-
// using QR (default)
|
|
45
|
-
const autoWA = new AutoWA("session_name", { printQR: true });
|
|
46
|
-
// or
|
|
47
|
-
const autoWA = new AutoWA("session_name");
|
|
48
|
-
// or, using pair code (experimental)
|
|
49
|
-
const autoWA = new AutoWA("session_name", { phoneNumber: "628xxxx" });
|
|
51
|
+
import { AutoWA } from "whatsauto.js";
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
const client = new AutoWA("my-session", {
|
|
54
|
+
phoneNumber: "6281234567890", // Your phone number (Country Code + Number)
|
|
53
55
|
});
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
client.initialize();
|
|
58
|
+
|
|
59
|
+
client.on("pairing-code", (code) => {
|
|
60
|
+
console.log(`๐ Pairing Code: ${code}`);
|
|
57
61
|
});
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
client.on("connected", () => {
|
|
64
|
+
console.log("โ
Client is ready!");
|
|
65
|
+
});
|
|
61
66
|
```
|
|
62
67
|
|
|
63
|
-
###
|
|
68
|
+
### 2. Handling Messages
|
|
69
|
+
|
|
70
|
+
Listen to the `message` event to handle incoming messages. The `msg` object comes with built-in helper methods!
|
|
64
71
|
|
|
65
72
|
```ts
|
|
66
|
-
{
|
|
67
|
-
|
|
68
|
-
* Print logs into Terminal
|
|
69
|
-
*/
|
|
70
|
-
logging?: boolean; // true (default), false
|
|
71
|
-
/**
|
|
72
|
-
* Print QR Code into Terminal
|
|
73
|
-
*/
|
|
74
|
-
printQR?: boolean; // true (default), false
|
|
75
|
-
/**
|
|
76
|
-
* Phone number for session with pairing code
|
|
77
|
-
*/
|
|
78
|
-
phoneNumber?: string; // 62822xxxxx (62 is your country code)
|
|
79
|
-
}
|
|
80
|
-
```
|
|
73
|
+
client.on("message", async (msg) => {
|
|
74
|
+
if (msg.key.fromMe) return; // Ignore messages from yourself
|
|
81
75
|
|
|
82
|
-
|
|
76
|
+
console.log(`๐ฉ New Message from ${msg.from}: ${msg.text}`);
|
|
83
77
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
await msg.read();
|
|
88
|
-
|
|
89
|
-
if (msg.text == "react")
|
|
90
|
-
// react this message
|
|
91
|
-
await msg.react("๐พ");
|
|
92
|
-
|
|
93
|
-
if (msg.text == "text")
|
|
94
|
-
// reply this message with text
|
|
95
|
-
await msg.replyWithText("Hello!");
|
|
96
|
-
|
|
97
|
-
if (msg.text == "image")
|
|
98
|
-
// reply this message with image
|
|
99
|
-
await msg.replyWithImage("https://picsum.photos/536/354");
|
|
100
|
-
|
|
101
|
-
if (msg.text == "video")
|
|
102
|
-
// reply this message with video
|
|
103
|
-
await msg.replyWithVideo(
|
|
104
|
-
"https://github.com/rafaelreis-hotmart/Audio-Sample-files/raw/master/sample.mp4"
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
if (msg.text == "audio")
|
|
108
|
-
// reply this message with audio
|
|
109
|
-
await msg.replyWithAudio(
|
|
110
|
-
"https://github.com/rafaelreis-hotmart/Audio-Sample-files/raw/master/sample.mp3"
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
if (msg.text == "sticker") {
|
|
114
|
-
// convert this message to sticker buffer (if its has media)
|
|
115
|
-
const [sticker, hasMedia] = await msg.toSticker();
|
|
116
|
-
// or
|
|
117
|
-
// const sticker = await msg.toSticker({ pack: "whatsauto.js", author: "freack21" });
|
|
118
|
-
if (hasMedia) {
|
|
119
|
-
// reply this message with audio
|
|
120
|
-
await msg.replyWithSticker(sticker);
|
|
121
|
-
}
|
|
78
|
+
if (msg.text === "!ping") {
|
|
79
|
+
// Reply directly using the message object
|
|
80
|
+
await msg.replyWithText("Pong! ๐");
|
|
122
81
|
}
|
|
123
82
|
|
|
124
|
-
if (msg.text
|
|
125
|
-
//
|
|
126
|
-
await msg.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// reply this message with recording presence
|
|
132
|
-
await msg.replyWithRecording(async () => {
|
|
133
|
-
await msg.replyWithText("This is recording"); // action to take while recording
|
|
134
|
-
});
|
|
83
|
+
if (msg.text === "!sticker" && msg.hasMedia) {
|
|
84
|
+
// Convert received image/video to sticker
|
|
85
|
+
const [stickerBuffer] = await msg.toSticker({ pack: "MyBot", author: "Me" });
|
|
86
|
+
if (stickerBuffer) {
|
|
87
|
+
await msg.replyWithSticker(stickerBuffer);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
135
90
|
});
|
|
136
91
|
```
|
|
137
92
|
|
|
138
|
-
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## ๐ Core Concepts & API
|
|
96
|
+
|
|
97
|
+
### `AutoWA` Class
|
|
98
|
+
The main entry point for the library.
|
|
99
|
+
|
|
100
|
+
**Constructor**
|
|
101
|
+
`new AutoWA(sessionId: string, options?: IWAutoSessionConfig)`
|
|
102
|
+
|
|
103
|
+
- `sessionId`: Unique identifier for the session (auth credentials will be saved under this name).
|
|
104
|
+
- `options`:
|
|
105
|
+
- `printQR`: (boolean) Auto-print QR in terminal.
|
|
106
|
+
- `phoneNumber`: (string) Use pairing code with this number.
|
|
107
|
+
- `logging`: (boolean) Enable/disable console logs.
|
|
108
|
+
|
|
109
|
+
**Main Methods**
|
|
110
|
+
| Method | Description |
|
|
111
|
+
| :--- | :--- |
|
|
112
|
+
| `initialize()` | Starts the WhatsApp connection. |
|
|
113
|
+
| `destroy(full?)` | Stops the session. If `full` is true, deletes session files. |
|
|
114
|
+
| `sendText({ to, text })` | Sends a text message. |
|
|
115
|
+
| `sendImage({ to, media, text })` | Sends an image (URL or Buffer). |
|
|
116
|
+
| `sendVideo({ to, media, text })` | Sends a video. |
|
|
117
|
+
| `sendAudio({ to, media, voiceNote })` | Sends audio. Set `voiceNote: true` for PTT (Push-to-Talk). |
|
|
118
|
+
| `sendDocument({ to, media, filename })` | Sends a file/document. |
|
|
119
|
+
| `sendSticker({ to, sticker })` | Sends a sticker (Buffer). |
|
|
120
|
+
| `getProfileInfo(jid)` | Get status and profile picture of a user. |
|
|
121
|
+
| `getGroupInfo(jid)` | Get group metadata (participants, description, etc.). |
|
|
122
|
+
|
|
123
|
+
**Group Management Methods**
|
|
124
|
+
- `addMemberToGroup({ to, participants })`
|
|
125
|
+
- `removeMemberFromGroup({ to, participants })`
|
|
126
|
+
- `promoteMemberGroup({ to, participants })`
|
|
127
|
+
- `demoteMemberGroup({ to, participants })`
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### `IWAutoMessage` Object
|
|
132
|
+
When an event triggers, you receive an `IWAutoMessage` object. It wraps the raw Baileys message with useful properties and methods.
|
|
133
|
+
|
|
134
|
+
**Properties**
|
|
135
|
+
- `from`: Sender's JID.
|
|
136
|
+
- `text`: Message content (Text/Caption).
|
|
137
|
+
- `hasMedia`: Boolean, true if message contains media.
|
|
138
|
+
- `mediaType`: 'image', 'video', 'audio', etc.
|
|
139
|
+
- `isGroup`: Boolean.
|
|
140
|
+
- `isStory`: Boolean.
|
|
141
|
+
- `quotedMessage`: The message this message is replying to (if any).
|
|
142
|
+
|
|
143
|
+
**Helper Methods (Context-Aware)**
|
|
144
|
+
These methods automatically reply to the current message (quote it).
|
|
145
|
+
|
|
146
|
+
- `msg.replyWithText("Hello")`
|
|
147
|
+
- `msg.replyWithImage("http://...", { text: "Caption" })`
|
|
148
|
+
- `msg.replyWithSticker(buffer)`
|
|
149
|
+
- `msg.react("โค๏ธ")`
|
|
150
|
+
- `msg.read()` - Mark as read.
|
|
151
|
+
- `msg.downloadMedia()` - Downloads media to disk or buffer.
|
|
152
|
+
- `msg.toSticker()` - Converts the message's media to a sticker buffer.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## โก Events (`client.on`)
|
|
157
|
+
|
|
158
|
+
| Event Name | Description |
|
|
159
|
+
| :--- | :--- |
|
|
160
|
+
| `qr` | Emitted when a new QR code is generated. Access the QR string as the first argument. |
|
|
161
|
+
| `pairing-code` | Emitted when a pairing code is requested. |
|
|
162
|
+
| `connecting` | Connection is being established. |
|
|
163
|
+
| `connected` | Client is successfully connected to WhatsApp. |
|
|
164
|
+
| `disconnected` | Client disconnected. |
|
|
165
|
+
| `message` | Emitted for **ALL** incoming messages (private, group, status). |
|
|
166
|
+
| `group-message` | Emitted only for group messages. |
|
|
167
|
+
| `private-message` | Emitted only for private chats. |
|
|
168
|
+
| `message-deleted` | Emitted when a message is deleted (Revoke). |
|
|
169
|
+
| `group-participants.update`| Emitted when members join, leave, or are promoted/demoted in a group. |
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## ๐ ๏ธ Advanced Usage
|
|
174
|
+
|
|
175
|
+
### Handling Media
|
|
176
|
+
Downloading media from a message is simple:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
client.on("message", async (msg) => {
|
|
180
|
+
if (msg.hasMedia) {
|
|
181
|
+
// defaults: saves to 'my_media.{ext}' in current dir
|
|
182
|
+
const filePath = await msg.downloadMedia();
|
|
183
|
+
console.log(`Media saved at: ${filePath}`);
|
|
184
|
+
|
|
185
|
+
// OR get as buffer
|
|
186
|
+
// const buffer = await msg.downloadMedia({ asBuffer: true });
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
```
|
|
139
190
|
|
|
191
|
+
### Group Member Updates
|
|
192
|
+
Welcome new members:
|
|
140
193
|
```ts
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
"message-received", // => passing IWAutoMessage;
|
|
151
|
-
"group-message-received", // => passing IWAutoMessage;
|
|
152
|
-
"private-message-received", // => passing IWAutoMessage;
|
|
153
|
-
"message-sent", // => passing IWAutoMessage;
|
|
154
|
-
"group-message-sent", // => passing IWAutoMessage;
|
|
155
|
-
"private-message-sent", // => passing IWAutoMessage;
|
|
156
|
-
"story", // => passing IWAutoMessage;
|
|
157
|
-
"story-received", // => passing IWAutoMessage;
|
|
158
|
-
"story-sent", // => passing IWAutoMessage;
|
|
159
|
-
"reaction", // => passing IWAutoMessage;
|
|
160
|
-
"reaction-received", // => passing IWAutoMessage;
|
|
161
|
-
"reaction-sent", // => passing IWAutoMessage;
|
|
162
|
-
"group-reaction", // => passing IWAutoMessage;
|
|
163
|
-
"group-reaction-received", // => passing IWAutoMessage;
|
|
164
|
-
"group-reaction-sent", // => passing IWAutoMessage;
|
|
165
|
-
"private-reaction", // => passing IWAutoMessage;
|
|
166
|
-
"private-reaction-received", // => passing IWAutoMessage;
|
|
167
|
-
"private-reaction-sent", // => passing IWAutoMessage;
|
|
168
|
-
|
|
169
|
-
"message-updated", // => passing WAutoMessageUpdated;
|
|
170
|
-
"group-member-update", // => passing IGroupMemberUpdate;
|
|
171
|
-
|
|
172
|
-
"message-deleted", // => passing IWAutoDeleteMessage;
|
|
194
|
+
client.on("group-member-update", async (update) => {
|
|
195
|
+
if (update.action === "add") {
|
|
196
|
+
// update.id = Group JID
|
|
197
|
+
// update.participants = Array of new members
|
|
198
|
+
|
|
199
|
+
// You can reply directly to the update event!
|
|
200
|
+
await update.replyWithText(`Welcome to the group! ๐`);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
173
203
|
```
|
|
174
204
|
|
|
175
|
-
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## ๐ License
|
|
176
208
|
|
|
177
|
-
This library is
|
|
209
|
+
This library is essentially a wrapper around Baileys and is provided for educational purposes. Use responsibly.
|
|
210
|
+
ISC License.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoWA.d.ts","sourceRoot":"","sources":["../../src/WhatsApp/AutoWA.ts"],"names":[],"mappings":"AAGA,OAAqB,EACnB,QAAQ,EAMR,SAAS,EAEV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAyB,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAEL,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EAEb,8BAA8B,EAC9B,eAAe,EACf,gBAAgB,EAEhB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAU3B,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAE3C,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAUxC,qBAAa,MAAM;IACV,MAAM,EA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AM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;CAG3D"}
|
package/dist/WhatsApp/AutoWA.js
CHANGED
|
@@ -474,7 +474,6 @@ export class AutoWA {
|
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
async downloadMedia(msg, opts, ext) {
|
|
477
|
-
this.logger.debug(JSON.stringify(msg, null, 2));
|
|
478
477
|
const filePath = path.join(process.cwd(), (opts.path || "my_media") + "." + ext);
|
|
479
478
|
const buf = await downloadMediaMessage(msg, "buffer", {});
|
|
480
479
|
if (opts.asBuffer)
|
package/dist/WhatsApp/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { AutoWA } from "./AutoWA.js";
|
|
2
2
|
export * from "./AutoWA.js";
|
|
3
3
|
export declare const sessions: Map<string, AutoWA>;
|
|
4
|
+
export declare const session: (sessionId: string) => AutoWA;
|
|
5
|
+
export declare const sessionsList: () => string[];
|
|
6
|
+
export declare function loadSessions(): Promise<void>;
|
|
4
7
|
export default AutoWA;
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/WhatsApp/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/WhatsApp/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,cAAc,aAAa,CAAC;AAE5B,eAAO,MAAM,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,CAAC;AAEvD,eAAO,MAAM,OAAO,cAAe,MAAM,WAA4B,CAAC;AAEtE,eAAO,MAAM,YAAY,gBAAoC,CAAC;AAE9D,wBAAsB,YAAY,kBAajC;AAED,eAAe,MAAM,CAAC"}
|
package/dist/WhatsApp/index.js
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
1
3
|
import { AutoWA } from "./AutoWA.js";
|
|
4
|
+
import { CREDENTIALS } from "../Defaults/index.js";
|
|
2
5
|
export * from "./AutoWA.js";
|
|
3
6
|
export const sessions = new Map();
|
|
7
|
+
export const session = (sessionId) => sessions.get(sessionId);
|
|
8
|
+
export const sessionsList = () => Array.from(sessions.keys());
|
|
9
|
+
export async function loadSessions() {
|
|
10
|
+
const dir = path.resolve(CREDENTIALS.DIR_NAME);
|
|
11
|
+
if (!fs.existsSync(dir))
|
|
12
|
+
return;
|
|
13
|
+
const files = fs.readdirSync(dir);
|
|
14
|
+
for (const file of files) {
|
|
15
|
+
const sessionId = file.replace(CREDENTIALS.PREFIX, "");
|
|
16
|
+
const client = new AutoWA(sessionId);
|
|
17
|
+
await client.initialize();
|
|
18
|
+
sessions.set(sessionId, client);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
4
21
|
export default AutoWA;
|