innovators-bot2 1.0.2 → 1.0.3
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/example.js +6 -8
- package/index.js +5 -9
- package/package.json +1 -1
package/example.js
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
const { WhatsAppClient } = require('./index')
|
|
2
2
|
const qrcode = require('qrcode-terminal')
|
|
3
3
|
const fs = require('fs');
|
|
4
|
-
const { text } = require('stream/consumers');
|
|
5
4
|
|
|
6
|
-
// Store logout states for different users
|
|
7
|
-
let logoutStates = {};
|
|
8
5
|
|
|
9
6
|
const client = new WhatsAppClient({ sessionName: ".Sessions" });
|
|
10
7
|
|
|
11
8
|
// Handle QR Code
|
|
12
9
|
client.on('qr', qr => {
|
|
10
|
+
console.log('QR Code received')
|
|
13
11
|
qrcode.generate(qr, { small: true })
|
|
14
12
|
})
|
|
15
13
|
|
|
16
14
|
// Handle connection events
|
|
17
|
-
client.on('connected', () => {
|
|
18
|
-
console.log('Client is ready!')
|
|
19
|
-
})
|
|
20
|
-
|
|
21
15
|
client.on('connecting', (message) => {
|
|
22
16
|
console.log('Client status:', message)
|
|
23
17
|
})
|
|
24
18
|
|
|
19
|
+
client.on('connected', (user) => {
|
|
20
|
+
console.log('Client is ready!', user)
|
|
21
|
+
})
|
|
22
|
+
|
|
25
23
|
client.on('disconnected', (error) => {
|
|
26
|
-
console.log('Client disconnected:'
|
|
24
|
+
console.log('Client disconnected:')
|
|
27
25
|
})
|
|
28
26
|
|
|
29
27
|
// Connect to WhatsApp
|
package/index.js
CHANGED
|
@@ -260,15 +260,11 @@ class WhatsAppClient extends EventEmitter {
|
|
|
260
260
|
// Handle credential updates
|
|
261
261
|
this.sock.ev.on('creds.update', saveCreds);
|
|
262
262
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
console.error('Error in connect:', error);
|
|
269
|
-
this.emit('error', error);
|
|
270
|
-
throw error;
|
|
271
|
-
}
|
|
263
|
+
} catch (error) {
|
|
264
|
+
console.error('Error in connect:', error);
|
|
265
|
+
this.emit('error', error);
|
|
266
|
+
throw error;
|
|
267
|
+
}
|
|
272
268
|
}
|
|
273
269
|
|
|
274
270
|
/**
|