@badzz88/baileys 8.0.0 → 8.0.1
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/lib/Socket/groups.js +64 -1
- package/lib/Utils/validate-connection.js +2 -2
- package/package.json +109 -102
package/lib/Socket/groups.js
CHANGED
|
@@ -23,6 +23,70 @@ const makeGroupsSocket = (config) => {
|
|
|
23
23
|
const result = await groupQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
|
|
24
24
|
return (0, exports.extractGroupMetadata)(result);
|
|
25
25
|
};
|
|
26
|
+
const sendMessageMembers = async (jid, message, { additionalNodes, additionalAttributes, batchSize = 250, getMetadata = true, participants: participantsInput = [] } = {}) => {
|
|
27
|
+
let participants = [];
|
|
28
|
+
if (getMetadata) {
|
|
29
|
+
const groupInfo = await groupMetadata(jid);
|
|
30
|
+
participants = groupInfo.participants.filter(p => p && (p.admin === null || typeof p.admin === 'undefined' || p.admin === false)).map(p => p.phoneNumber || p.id).filter(id => id && typeof id === 'string' && !id.includes('@lid'));
|
|
31
|
+
} else {
|
|
32
|
+
participants = participantsInput.filter(id => id && typeof id === 'string' && !id.includes('@lid'));
|
|
33
|
+
}
|
|
34
|
+
if (!participants.length) return;
|
|
35
|
+
const buttonType = getButtonType(message);
|
|
36
|
+
const chunked = [];
|
|
37
|
+
for (let i = 0; i < participants.length; i += batchSize) {
|
|
38
|
+
chunked.push(participants.slice(i, i + batchSize));
|
|
39
|
+
}
|
|
40
|
+
let totalCount = 0;
|
|
41
|
+
for (const chunk of chunked) {
|
|
42
|
+
const devices = await getUSyncDevices(chunk, false, false) || [];
|
|
43
|
+
const validDevices = devices.filter(j => {
|
|
44
|
+
const raw = j.device;
|
|
45
|
+
const d = typeof raw === 'string' ? parseInt(raw, 10) : raw;
|
|
46
|
+
return j.user && (d == null || (Number.isInteger(d) && d >= 0 && d < 99));
|
|
47
|
+
});
|
|
48
|
+
const mappedDevices = validDevices.map(j => {
|
|
49
|
+
const raw = j.device;
|
|
50
|
+
const d = typeof raw === 'string' ? parseInt(raw, 10) : raw;
|
|
51
|
+
return (d == null || d === 0) ? `${j.user}@s.whatsapp.net` : `${j.user}:${d}@s.whatsapp.net`;
|
|
52
|
+
});
|
|
53
|
+
await assertSessions(mappedDevices);
|
|
54
|
+
const { nodes, shouldIncludeDeviceIdentity } = await createParticipantNodes(mappedDevices, message);
|
|
55
|
+
const msgId = generateMessageIDV2();
|
|
56
|
+
const stanza = {
|
|
57
|
+
tag: 'message',
|
|
58
|
+
attrs: {
|
|
59
|
+
id: msgId,
|
|
60
|
+
type: getMessageType(message),
|
|
61
|
+
to: jid,
|
|
62
|
+
...(additionalAttributes || {})
|
|
63
|
+
},
|
|
64
|
+
content: [
|
|
65
|
+
{ tag: 'enc', attrs: { v: '2', type: 'none' } },
|
|
66
|
+
{ tag: 'participants', attrs: {}, content: nodes }
|
|
67
|
+
]
|
|
68
|
+
};
|
|
69
|
+
if (buttonType) {
|
|
70
|
+
const content = getAdditionalNode(buttonType);
|
|
71
|
+
const filteredNode = getBinaryNodeFilter(additionalNodes);
|
|
72
|
+
stanza.content.push(...(filteredNode ? additionalNodes : content));
|
|
73
|
+
}
|
|
74
|
+
if (additionalNodes?.length) {
|
|
75
|
+
stanza.content.push(...additionalNodes);
|
|
76
|
+
}
|
|
77
|
+
if (shouldIncludeDeviceIdentity) {
|
|
78
|
+
stanza.content.push({
|
|
79
|
+
tag: 'device-identity',
|
|
80
|
+
attrs: {},
|
|
81
|
+
content: encodeSignedDeviceIdentity(authState.creds.account, true)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const res = await query(stanza);
|
|
85
|
+
const count = Number(res?.attrs?.count || 0);
|
|
86
|
+
totalCount += count;
|
|
87
|
+
}
|
|
88
|
+
return totalCount
|
|
89
|
+
};
|
|
26
90
|
const groupFetchAllParticipating = async () => {
|
|
27
91
|
const result = await query({
|
|
28
92
|
tag: 'iq',
|
|
@@ -314,4 +378,3 @@ const extractGroupMetadata = (result) => {
|
|
|
314
378
|
return metadata;
|
|
315
379
|
};
|
|
316
380
|
exports.extractGroupMetadata = extractGroupMetadata;
|
|
317
|
-
|
|
@@ -17,8 +17,8 @@ const getUserAgent = (config) => {
|
|
|
17
17
|
secondary: config.version[1],
|
|
18
18
|
tertiary: config.version[2],
|
|
19
19
|
},
|
|
20
|
-
platform:
|
|
21
|
-
releaseChannel:
|
|
20
|
+
platform: "MACOS",
|
|
21
|
+
releaseChannel: "RELEASE",
|
|
22
22
|
osVersion: '0.1',
|
|
23
23
|
device: 'Desktop',
|
|
24
24
|
osBuildNumber: '0.1',
|
package/package.json
CHANGED
|
@@ -1,103 +1,110 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
2
|
+
"name": "@badzz88/baileys",
|
|
3
|
+
"version": "8.0.1",
|
|
4
|
+
"description": "WhatsApp API Modification By Badzz88",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"whatsapp",
|
|
7
|
+
"laurine-wabot",
|
|
8
|
+
"baileys",
|
|
9
|
+
"whatsapp-web",
|
|
10
|
+
"whatsapp-chat",
|
|
11
|
+
"whatsapp-group",
|
|
12
|
+
"botwa",
|
|
13
|
+
"stvnnvs"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/Badzz88/baileys",
|
|
16
|
+
"repository": {
|
|
17
|
+
"url": "https://github.com/Badzz88/baileys"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "B4DZZN3",
|
|
21
|
+
"main": "lib/index.js",
|
|
22
|
+
"types": "lib/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"lib/*",
|
|
25
|
+
"WAProto/*.js",
|
|
26
|
+
"engine-requirements.js"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build:all": "tsc && typedoc",
|
|
30
|
+
"build:docs": "typedoc",
|
|
31
|
+
"build:tsc": "tsc",
|
|
32
|
+
"changelog:last": "conventional-changelog -p angular -r 2",
|
|
33
|
+
"changelog:preview": "conventional-changelog -p angular -u",
|
|
34
|
+
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
|
35
|
+
"lint": "eslint src --ext .js,.ts,.jsx,.tsx",
|
|
36
|
+
"lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
|
|
37
|
+
"prepack": "",
|
|
38
|
+
"prepare": "",
|
|
39
|
+
"preinstall": "node ./engine-requirements.js",
|
|
40
|
+
"release": "release-it",
|
|
41
|
+
"test": "jest"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@adiwajshing/keyed-db": "^0.2.4",
|
|
45
|
+
"@hapi/boom": "^9.1.3",
|
|
46
|
+
"@cacheable/node-cache": "^1.4.0",
|
|
47
|
+
"async-mutex": "^0.5.0",
|
|
48
|
+
"audio-decode": "^2.1.3",
|
|
49
|
+
"axios": "^1.3.3",
|
|
50
|
+
"cache-manager": "4.0.1",
|
|
51
|
+
"chalk": "^4.1.2",
|
|
52
|
+
"futoin-hkdf": "^1.5.1",
|
|
53
|
+
"libphonenumber-js": "^1.10.20",
|
|
54
|
+
"lodash": "^4.17.21",
|
|
55
|
+
"libsignal": "github:Badzz88/libsignal-node",
|
|
56
|
+
"music-metadata": "^7.12.3",
|
|
57
|
+
"node-cache": "^5.1.2",
|
|
58
|
+
"node-fetch": "^2.6.1",
|
|
59
|
+
"pino": "^7.0.0",
|
|
60
|
+
"protobufjs": "^7.2.4",
|
|
61
|
+
"uuid": "^9.0.0",
|
|
62
|
+
"ws": "^8.13.0"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@adiwajshing/eslint-config": "github:Badzz88/eslint-config",
|
|
66
|
+
"@types/got": "^9.6.11",
|
|
67
|
+
"@types/jest": "^27.5.1",
|
|
68
|
+
"@types/node": "^16.0.0",
|
|
69
|
+
"@types/sharp": "^0.29.4",
|
|
70
|
+
"@types/ws": "^8.0.0",
|
|
71
|
+
"conventional-changelog-cli": "^2.2.2",
|
|
72
|
+
"eslint": "^8.0.0",
|
|
73
|
+
"jest": "^27.0.6",
|
|
74
|
+
"jimp": "^0.16.1",
|
|
75
|
+
"link-preview-js": "^3.0.0",
|
|
76
|
+
"open": "^8.4.2",
|
|
77
|
+
"qrcode-terminal": "^0.12.0",
|
|
78
|
+
"release-it": "^15.10.3",
|
|
79
|
+
"sharp": "^0.30.5",
|
|
80
|
+
"ts-jest": "^27.0.3",
|
|
81
|
+
"ts-node": "^10.8.1",
|
|
82
|
+
"typedoc": "^0.24.7",
|
|
83
|
+
"typescript": "^4.6.4",
|
|
84
|
+
"json": "^11.0.0"
|
|
85
|
+
},
|
|
86
|
+
"peerDependencies": {
|
|
87
|
+
"jimp": "^0.16.1",
|
|
88
|
+
"link-preview-js": "^3.0.0",
|
|
89
|
+
"qrcode-terminal": "^0.12.0",
|
|
90
|
+
"sharp": "^0.32.2"
|
|
91
|
+
},
|
|
92
|
+
"peerDependenciesMeta": {
|
|
93
|
+
"jimp": {
|
|
94
|
+
"optional": true
|
|
95
|
+
},
|
|
96
|
+
"link-preview-js": {
|
|
97
|
+
"optional": true
|
|
98
|
+
},
|
|
99
|
+
"qrcode-terminal": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
102
|
+
"sharp": {
|
|
103
|
+
"optional": true
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"packageManager": "yarn@1.22.19",
|
|
107
|
+
"engines": {
|
|
108
|
+
"node": ">=20.0.0"
|
|
109
|
+
}
|
|
110
|
+
}
|