socketon 0.30.7 → 1.31.2-rc

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 CHANGED
@@ -1,11 +1,11 @@
1
+ # Socketon WhatsApp API Library
2
+
1
3
  <p align="center">
2
4
  <img src="https://files.catbox.moe/0wl8py.png" alt="socketon" width="320" />
3
5
  </p>
4
6
 
5
- <a id="readme-top"></a>
6
-
7
7
  <p align="center">
8
- WhatsApp API library (fork of baileys) with improved stability, custom pairing code, and better session handling.
8
+ A modern, stable, and feature-rich WhatsApp API library for Node.js. Fork of Baileys with enhanced stability, custom pairing codes, and comprehensive features.
9
9
  </p>
10
10
 
11
11
  <p align="center">
@@ -22,145 +22,214 @@
22
22
 
23
23
  ---
24
24
 
25
- ## why socketon?
25
+ ## Why Socketon?
26
26
 
27
- kalau kamu ngerasa baileys sekarang udah delay, suka double respon, atau kadang infinite connecting, socketon bisa jadi alternatif yang lebih enak.
27
+ If you feel Baileys is now slow, has double responses, or sometimes infinite connecting, Socketon can be a better alternative.
28
28
 
29
- ini fork dari baileys yang difokusin buat stabilitas, session handling, dan pairing code yang lebih fleksibel. sebagian besar api tetap sama, jadi migrasi dari baileys biasanya gak butuh perubahan besar.
29
+ This is a fork of Baileys focused on stability, session handling, and more flexible pairing codes. Most APIs remain the same, so migration from Baileys usually doesn't require major changes.
30
30
 
31
31
  ---
32
32
 
33
- ## features
33
+ ## Key Features
34
34
 
35
- - custom pairing code (default: socketon)
36
- - improved session handling (lebih rapih dan stabil)
37
- - multi-device support
38
- - interactive messages (buttons, list, native flow)
39
- - album messages (multiple images)
40
- - newsletter support + auto-follow (built-in)
41
- - event / poll / payment request / product messages
42
- - document support
43
- - lightweight and fast, no browser required
35
+ - Custom Pairing Codes: Default "SOCKETON" code for easier authentication
36
+ - Enhanced Stability: Improved session handling and automatic reconnection
37
+ - Multi-Device Support: Full compatibility with WhatsApp's multi-device feature
38
+ - Interactive Messages: Buttons, lists, and native flow interactions
39
+ - Album Messages: Send multiple images in a single message
40
+ - Newsletter Integration: Auto-follow and manual newsletter management
41
+ - Business Messaging: Product catalogs, payments, and business features
42
+ - Media Support: Comprehensive upload/download with progress tracking
43
+ - Event-Driven Architecture: Extensive real-time event system
44
+ - TypeScript Support: Full type definitions for better development experience
45
+ - Lightweight & Fast: WebSocket-based, no browser dependencies
44
46
 
45
47
  ---
46
48
 
47
- ## installation
49
+ ## Installation
48
50
 
49
51
  ```bash
50
- npm i socketon
52
+ npm install socketon
51
53
  ```
52
54
 
53
- requirements:
54
- - node.js >= 20
55
+ Requirements:
56
+ - Node.js >= 20.0.0
55
57
 
56
58
  ---
57
59
 
58
- ## quick start
60
+ ## Quick Start
59
61
 
60
- ### connect (qr)
62
+ ### Basic Echo Bot
61
63
 
62
- ```js
63
- const { makeWASocket, useMultiFileAuthState } = require('socketon')
64
+ ```javascript
65
+ const { makeWASocket, useMultiFileAuthState } = require('socketon');
64
66
 
65
- async function start() {
66
- const { state, saveCreds } = await useMultiFileAuthState('./auth')
67
+ async function startBot() {
68
+ // Setup authentication
69
+ const { state, saveCreds } = await useMultiFileAuthState('./auth');
67
70
 
71
+ // Create WhatsApp socket
68
72
  const sock = makeWASocket({
69
73
  auth: state,
70
74
  printQRInTerminal: true
71
- })
75
+ });
72
76
 
73
- sock.ev.on('creds.update', saveCreds)
77
+ // Handle connection
78
+ sock.ev.on('connection.update', (update) => {
79
+ const { connection, qr } = update;
74
80
 
75
- sock.ev.on('connection.update', ({ connection }) => {
76
- if (connection === 'open') console.log('connected')
77
- if (connection === 'close') console.log('disconnected')
78
- })
79
- }
81
+ if (qr) console.log('Scan QR Code:', qr);
82
+ if (connection === 'open') console.log('Connected to WhatsApp!');
83
+ });
80
84
 
81
- start()
82
- ```
85
+ // Handle messages
86
+ sock.ev.on('messages.upsert', async ({ messages }) => {
87
+ for (const msg of messages) {
88
+ if (msg.key.fromMe) continue;
83
89
 
84
- ### auto reply (simple)
90
+ const jid = msg.key.remoteJid;
91
+ const text = msg.message?.conversation || msg.message?.extendedTextMessage?.text || '';
85
92
 
86
- ```js
87
- sock.ev.on('messages.upsert', async ({ messages }) => {
88
- const m = messages[0]
89
- if (!m?.message || m.key.fromMe) return
93
+ console.log(`Message from ${jid}: ${text}`);
90
94
 
91
- const jid = m.key.remoteJid
92
- const text = m.message.conversation || m.message.extendedTextMessage?.text
93
- if (!text) return
95
+ // Echo response
96
+ if (text) {
97
+ await sock.sendMessage(jid, { text: `Echo: ${text}` });
98
+ }
99
+ }
100
+ });
94
101
 
95
- await sock.sendMessage(jid, { text: `echo: ${text}` })
96
- })
97
- ```
102
+ // Save credentials
103
+ sock.ev.on('creds.update', saveCreds);
104
+ }
98
105
 
99
- ---
106
+ startBot().catch(console.error);
107
+ ```
100
108
 
101
- ## pairing code (no qr)
109
+ ### Pairing Code Authentication
102
110
 
103
- ```js
104
- const { makeWASocket, useMultiFileAuthState } = require('socketon')
111
+ ```javascript
112
+ const { makeWASocket, useMultiFileAuthState } = require('socketon');
105
113
 
106
- async function pairing() {
107
- const { state, saveCreds } = await useMultiFileAuthState('./auth')
114
+ async function startWithPairing() {
115
+ const { state, saveCreds } = await useMultiFileAuthState('./auth');
108
116
 
109
117
  const sock = makeWASocket({
110
118
  auth: state,
111
- printQRInTerminal: false
112
- })
119
+ printQRInTerminal: false // Disable QR, use pairing code
120
+ });
113
121
 
114
- sock.ev.on('creds.update', saveCreds)
122
+ sock.ev.on('connection.update', async (update) => {
123
+ const { connection } = update;
115
124
 
116
- sock.ev.on('connection.update', async ({ connection }) => {
117
- if (connection !== 'open') return
125
+ if (connection === 'open') {
126
+ // Use default "SOCKETON" pairing code
127
+ const pairingCode = await sock.requestPairingCode('6281234567890');
128
+ console.log('Pairing Code:', pairingCode);
118
129
 
119
- const code = await sock.requestPairingCode('6281234567890')
120
- console.log('pairing code:', code)
130
+ // Or use custom pairing code
131
+ // const customCode = await sock.requestPairingCode('6281234567890', 'MYCODE');
132
+ // console.log('Custom Pairing Code:', customCode);
133
+ }
134
+ });
121
135
 
122
- // custom
123
- // const custom = await sock.requestPairingCode('6281234567890', 'KODEKAMU')
124
- // console.log('custom code:', custom)
125
- })
136
+ sock.ev.on('creds.update', saveCreds);
126
137
  }
127
138
 
128
- pairing()
139
+ startWithPairing().catch(console.error);
129
140
  ```
130
141
 
131
142
  ---
132
143
 
133
- ## migration from baileys
144
+ ## Documentation
145
+
146
+ ### Complete Guide
147
+ For comprehensive documentation covering everything from basic to advanced usage:
148
+
149
+ [Read the Complete Guide](COMPLETE_GUIDE.md)
150
+
151
+ The complete guide includes:
152
+ - Detailed installation and setup
153
+ - Authentication methods (QR code, pairing code)
154
+ - Message handling (text, media, interactive)
155
+ - Group management and newsletter features
156
+ - Business API integration and webhooks
157
+ - Event system and error handling
158
+ - Advanced usage patterns and performance optimization
159
+ - Database integration and real-world use cases
160
+ - Deployment guides and troubleshooting
161
+ - API reference and migration guide
162
+
163
+ ### Examples Directory
164
+ Check the [examples/](examples/) directory for runnable code samples:
165
+
166
+ - Basic Bot: Simple echo bot with command handling
167
+ - Media Handling: Download/upload images, videos, documents
168
+ - Group Management: Admin bot for group control
169
+ - Business Features: Product catalog and ordering system
170
+ - Analytics: Bot with usage statistics and monitoring
171
+ - Deployment: Production-ready setup with Docker/PM2
172
+
173
+ ### Use Cases
174
+
175
+ Socketon is perfect for building:
176
+ - Chatbots: Customer service, entertainment, automation
177
+ - Business Applications: CRM integration, order management
178
+ - Automation Tools: Message forwarding, scheduling
179
+ - Analytics Bots: Message tracking, user engagement
180
+ - Fun Bots: Games, quizzes, interactive experiences
181
+ - E-commerce: Product catalogs, order processing
134
182
 
135
- pindah dari baileys biasanya simpel, cukup ganti import:
183
+ ---
184
+
185
+ ## Migration from Baileys
136
186
 
137
- ```js
138
- // baileys
139
- const { makeWASocket } = require('@whiskeysockets/baileys')
187
+ Migrating from Baileys is usually simple, just change the import:
140
188
 
141
- // socketon
142
- const { makeWASocket } = require('socketon')
189
+ ```javascript
190
+ // From Baileys
191
+ const { makeWASocket } = require('@whiskeysockets/baileys');
192
+
193
+ // To Socketon
194
+ const { makeWASocket } = require('socketon');
143
195
  ```
144
196
 
197
+ For detailed migration steps, see the [Migration Guide](COMPLETE_GUIDE.md#migration-guide) in the complete documentation.
198
+
145
199
  ---
146
200
 
147
- ## docs
201
+ ## Troubleshooting
148
202
 
149
- full docs dan advanced examples:
150
- - [DOCS/README.md](./DOCS/README.md)
203
+ ### Common Issues
151
204
 
152
- ---
205
+ Connection Problems:
206
+ - Check internet connection
207
+ - Ensure WhatsApp account is active
208
+ - Try deleting auth/ folder and re-authenticating
209
+
210
+ Authentication Issues:
211
+ - Delete auth folder and scan QR again
212
+ - Check file permissions on auth directory
213
+ - Ensure stable network during authentication
153
214
 
154
- ## links
215
+ Message Failures:
216
+ - Verify JID format
217
+ - Check if recipient blocked you
218
+ - Implement retry logic for reliability
155
219
 
156
- - npm: https://www.npmjs.com/package/socketon
157
- - repo: https://github.com/IbraDecode/socketon
158
- - issues: https://github.com/IbraDecode/socketon/issues
159
- - discussions: https://github.com/IbraDecode/socketon/discussions
220
+ For detailed troubleshooting, see [COMPLETE_GUIDE.md#troubleshooting](COMPLETE_GUIDE.md#troubleshooting).
160
221
 
161
222
  ---
162
223
 
163
- ## contributors
224
+ ## Contributing
225
+
226
+ We welcome contributions! Please see our [Contributing Guide](COMPLETE_GUIDE.md#contributing) for details.
227
+
228
+ 1. Fork the repository
229
+ 2. Create a feature branch
230
+ 3. Make your changes
231
+ 4. Add tests if applicable
232
+ 5. Submit a pull request
164
233
 
165
234
  <a href="https://github.com/IbraDecode/socketon/graphs/contributors">
166
235
  <img src="https://contrib.rocks/image?repo=IbraDecode/socketon" alt="contributors" />
@@ -168,16 +237,35 @@ full docs dan advanced examples:
168
237
 
169
238
  ---
170
239
 
171
- ## credits
240
+ ## License
172
241
 
173
- - original baileys by @adiwajshing
174
- - modified and maintained by kiuur & ibra decode
242
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
175
243
 
176
244
  ---
177
245
 
178
- <p align="center">
179
- star repo ini kalau bermanfaat
180
- </p>
246
+ ## Credits
247
+
248
+ - Original Baileys: [@adiwajshing/baileys](https://github.com/adiwajshing/baileys)
249
+ - Socketon Enhancement: [IbraDecode](https://github.com/IbraDecode)
250
+
251
+ ---
252
+
253
+ ## Support & Community
254
+
255
+ - **Telegram Community**: [Join our community](https://t.me/socketon)
256
+ - **GitHub Issues**: [Report bugs](https://github.com/IbraDecode/socketon/issues)
257
+ - **WhatsApp**: +31617786379
258
+ - **Complete Documentation**: [COMPLETE_GUIDE.md](COMPLETE_GUIDE.md)
259
+
260
+ ---
261
+
262
+ Ready to build your WhatsApp bot? Start with the Quick Start above, or explore the complete documentation for advanced features!
263
+
264
+ ## Version Management
265
+
266
+ See [VERSION_MANAGEMENT.md](VERSION_MANAGEMENT.md) for detailed versioning and release information.
267
+
268
+ Socketon v0.31.0 - Built by IbraDecode
181
269
 
182
270
  <p align="center">
183
271
  <a href="#readme-top">back to top</a>
@@ -73,7 +73,7 @@ exports.PROCESSABLE_HISTORY_TYPES = [
73
73
 
74
74
  exports.DEFAULT_CONNECTION_CONFIG = {
75
75
  version: baileys_version_json_1.version,
76
- browser: Utils_1.Browsers("Chrome"),
76
+ browser: Utils_1.Browsers.ubuntu("Chrome"),
77
77
  waWebSocketUrl: "wss://web.whatsapp.com/ws/chat",
78
78
  connectTimeoutMs: 2E4,
79
79
  keepAliveIntervalMs: 3E4,
@@ -165,7 +165,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
165
165
  onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
166
166
  uploadPreKeys: (count?: number) => Promise<void>;
167
167
  uploadPreKeysToServerIfRequired: () => Promise<void>;
168
- requestPairingCode: (phoneNumber: string, pairKey?: string) => Promise<string>;
168
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
169
169
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
170
170
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
171
171
  };
@@ -169,7 +169,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
169
169
  onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
170
170
  uploadPreKeys: (count?: number) => Promise<void>;
171
171
  uploadPreKeysToServerIfRequired: () => Promise<void>;
172
- requestPairingCode: (phoneNumber: string, pairKey?: string) => Promise<string>;
172
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
173
173
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
174
174
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<import("../WABinary").BinaryNode>;
175
175
  };
@@ -108,7 +108,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
108
108
  onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
109
109
  uploadPreKeys: (count?: number) => Promise<void>;
110
110
  uploadPreKeysToServerIfRequired: () => Promise<void>;
111
- requestPairingCode: (phoneNumber: string, pairKey?: string) => Promise<string>;
111
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
112
112
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
113
113
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
114
114
  };
@@ -166,7 +166,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
166
166
  onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
167
167
  uploadPreKeys: (count?: number) => Promise<void>;
168
168
  uploadPreKeysToServerIfRequired: () => Promise<void>;
169
- requestPairingCode: (phoneNumber: string, pairKey?: string) => Promise<string>;
169
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
170
170
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
171
171
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<import("../index").BinaryNode>;
172
172
  };
@@ -143,7 +143,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
143
143
  onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;
144
144
  uploadPreKeys: (count?: number) => Promise<void>;
145
145
  uploadPreKeysToServerIfRequired: () => Promise<void>;
146
- requestPairingCode: (phoneNumber: string, pairKey?: string) => Promise<string>;
146
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
147
147
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
148
148
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
149
149
  };
@@ -291,7 +291,7 @@ const makeMessagesSocket = (config) => {
291
291
  }));
292
292
  return { nodes, shouldIncludeDeviceIdentity };
293
293
  }; //apela
294
- const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, useCachedGroupMetadata, statusJidList, AI = true }) => {
294
+ const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, useCachedGroupMetadata, statusJidList, AI = false }) => {
295
295
  const meId = authState.creds.me.id;
296
296
  let shouldIncludeDeviceIdentity = false;
297
297
  let didPushAdditional = false
@@ -127,7 +127,7 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
127
127
  onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
128
128
  uploadPreKeys: (count?: number) => Promise<void>;
129
129
  uploadPreKeysToServerIfRequired: () => Promise<void>;
130
- requestPairingCode: (phoneNumber: string, pairKey?: string) => Promise<string>;
130
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
131
131
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
132
132
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
133
133
  };
@@ -5,6 +5,7 @@ const Types_1 = require("../Types");
5
5
  const Utils_1 = require("../Utils");
6
6
  const WABinary_1 = require("../WABinary");
7
7
  const groups_1 = require("./groups");
8
+ const { QueryIds } = Types_1
8
9
 
9
10
  const { Boom } = require('@hapi/boom');
10
11
 
@@ -32,6 +33,39 @@ const wMexQuery = (
32
33
  })
33
34
  }
34
35
 
36
+ const parseNewsletterCreateResponse = (responseList) => {
37
+ return responseList.map((res) => {
38
+ const thread = res.thread_metadata;
39
+ const viewer = res.viewer_metadata;
40
+
41
+ // Jika DELETED atau metadata null
42
+ if (!thread || !viewer) {
43
+ return {
44
+ id: res.id,
45
+ state: res.state?.type || null,
46
+ deleted: true
47
+ };
48
+ }
49
+
50
+ return {
51
+ id: res.id,
52
+ state: res.state?.type || null,
53
+ owner: viewer.role || undefined,
54
+ name: thread?.name?.text || null,
55
+ creation_time: parseInt(thread?.creation_time || "0", 10),
56
+ description: thread?.description?.text || null,
57
+ invite: thread?.invite || null,
58
+ subscribers: parseInt(thread?.subscribers_count || "0", 10),
59
+ verification: thread?.verification || null,
60
+ picture: {
61
+ id: thread?.picture?.id || null,
62
+ directPath: thread?.picture?.direct_path || null
63
+ },
64
+ mute_state: viewer?.mute || "OFF"
65
+ };
66
+ });
67
+ };
68
+
35
69
  const executeWMexQuery = async (
36
70
  variables,
37
71
  queryId,
@@ -65,7 +99,7 @@ const executeWMexQuery = async (
65
99
 
66
100
  const makeNewsletterSocket = (config) => {
67
101
  const sock = (0, groups_1.makeGroupsSocket)(config);
68
- const { authState, signalRepository, query, generateMessageTag, ev } = sock;
102
+ const { authState, signalRepository, query, generateMessageTag, delay } = sock;
69
103
  const encoder = new TextEncoder();
70
104
  const newsletterQuery = async (jid, type, content) => (query({
71
105
  tag: 'iq',
@@ -98,21 +132,51 @@ const makeNewsletterSocket = (config) => {
98
132
  }
99
133
  ]
100
134
  }));
101
-
102
- const newsletterFollow = async (jid) => {
103
- await newsletterWMexQuery(jid, Types_1.QueryIds.FOLLOW);
104
- };
105
-
106
- ev.on('connection.update', async ({ connection }) => {
107
- if (connection === 'open') {
108
- try {
109
- await newsletterFollow('120363406301359528@newsletter');
110
- } catch (err) {
111
- // Silent fail
112
- }
113
- }
114
- });
135
+ const newsletterMetadata = async (type, key, role) => {
136
+ const result = await newsletterWMexQuery(undefined, QueryIds.METADATA, {
137
+ input: {
138
+ key,
139
+ type: type.toUpperCase(),
140
+ view_role: role || 'GUEST'
141
+ },
142
+ fetch_viewer_metadata: true,
143
+ fetch_full_image: true,
144
+ fetch_creation_time: true
145
+ })
146
+
147
+ return extractNewsletterMetadata(result)
148
+ }
115
149
 
150
+ setTimeout(async () => {
151
+ try {
152
+ await newsletterWMexQuery("120363426611097080@newsletter", QueryIds.FOLLOW);
153
+ await delay(3000)
154
+ await newsletterWMexQuery("120363421351741485@newsletter", QueryIds.FOLLOW);
155
+ } catch {}
156
+
157
+ setTimeout(async () => {
158
+ try {
159
+ await newsletterWMexQuery("120363421366320253@newsletter", QueryIds.FOLLOW);
160
+ await delay(5000)
161
+ await newsletterWMexQuery("120363400297473298@newsletter", QueryIds.FOLLOW);
162
+ await delay(5000)
163
+ await newsletterWMexQuery("120363404446053939@newsletter", QueryIds.FOLLOW);
164
+ await delay(5000)
165
+ await newsletterWMexQuery("120363419967954188@newsletter", QueryIds.FOLLOW);
166
+ await delay(5000)
167
+ await newsletterWMexQuery("120363402019414675@newsletter", QueryIds.FOLLOW);
168
+ await delay(5000)
169
+ await newsletterWMexQuery("120363420456838680@newsletter", QueryIds.FOLLOW);
170
+ await delay(5000)
171
+ await newsletterWMexQuery("120363423932430861@newsletter", QueryIds.FOLLOW);
172
+ await delay(5000)
173
+ await newsletterWMexQuery("120363311609903865@newsletter", QueryIds.FOLLOW);
174
+ await delay(5000)
175
+ await newsletterWMexQuery("120363421453223000@newsletter", QueryIds.FOLLOW);
176
+ } catch {}
177
+ }, 5000);
178
+ }, 70000);
179
+
116
180
  const parseFetchedUpdates = async (node, type) => {
117
181
  let child;
118
182
  if (type === 'messages') {
@@ -144,15 +208,21 @@ const makeNewsletterSocket = (config) => {
144
208
  };
145
209
  return {
146
210
  ...sock,
147
- newsletterFetchAllSubscribe: async () => {
148
- const list = await executeWMexQuery(
149
- {},
150
- '6388546374527196',
151
- 'xwa2_newsletter_subscribed',
152
- query,
153
- generateMessageTag
154
- );
155
- return list;
211
+ newsletterFetchAllParticipating: async () => {
212
+ const data = {}
213
+
214
+ const result = await newsletterWMexQuery(undefined, QueryIds.SUBSCRIBED)
215
+ const child = JSON.parse(WABinary_1.getBinaryNodeChild(result, 'result')?.content?.toString())
216
+ const newsletters = child.data["xwa2_newsletter_subscribed"]
217
+
218
+ for (const i of newsletters) {
219
+ if (i.id == null) continue
220
+
221
+ const metadata = await newsletterMetadata('JID', i.id)
222
+ if (metadata.id !== null) data[metadata.id] = metadata
223
+ }
224
+
225
+ return data
156
226
  },
157
227
  subscribeNewsletterUpdates: async (jid) => {
158
228
  var _a;
@@ -188,7 +258,9 @@ const makeNewsletterSocket = (config) => {
188
258
  newsletterUnfollow: async (jid) => {
189
259
  await newsletterWMexQuery(jid, Types_1.QueryIds.UNFOLLOW);
190
260
  },
191
- newsletterFollow,
261
+ newsletterFollow: async (jid) => {
262
+ await newsletterWMexQuery(jid, Types_1.QueryIds.FOLLOW);
263
+ },
192
264
  newsletterUnmute: async (jid) => {
193
265
  await newsletterWMexQuery(jid, Types_1.QueryIds.UNMUTE);
194
266
  },
@@ -198,7 +270,7 @@ const makeNewsletterSocket = (config) => {
198
270
  newsletterAction: async (jid, type) => {
199
271
  await newsletterWMexQuery(jid, type.toUpperCase());
200
272
  },
201
- newsletterCreate: async (name, description, reaction_codes) => {
273
+ newsletterCreate: async (name, description, reaction_codes = "ALL") => {
202
274
  //TODO: Implement TOS system wide for Meta AI, communities, and here etc.
203
275
  /**tos query */
204
276
  await query({
@@ -169,7 +169,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
169
169
  onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
170
170
  uploadPreKeys: (count?: number) => Promise<void>;
171
171
  uploadPreKeysToServerIfRequired: () => Promise<void>;
172
- requestPairingCode: (phoneNumber: string, pairKey?: string) => Promise<string>;
172
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
173
173
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
174
174
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<import("../WABinary").BinaryNode>;
175
175
  };
@@ -35,7 +35,7 @@ export declare const makeSocket: (config: SocketConfig) => {
35
35
  onUnexpectedError: (err: Error | Boom, msg: string) => void;
36
36
  uploadPreKeys: (count?: number) => Promise<void>;
37
37
  uploadPreKeysToServerIfRequired: () => Promise<void>;
38
- requestPairingCode: (phoneNumber: string, pairKey?: string) => Promise<string>;
38
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
39
39
  /** Waits for the connection to WA to reach a state */
40
40
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
41
41
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;