@prototypevip/baileys 0.1.3 → 0.1.5
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/HELPERS.md +107 -0
- package/lib/Socket/index.js +30 -15
- package/lib/Utils/index.js +4 -0
- package/lib/Utils/messages-media.js +6 -3
- package/lib/Utils/messages.js +1 -0
- package/lib/Utils/modern-messages.js +10 -0
- package/lib/Utils/newsletter-status.js +652 -0
- package/lib/Utils/prototype-helpers.js +610 -0
- package/lib/Utils/status-helpers.js +143 -0
- package/package.json +11 -4
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status helpers — personal stories + group status
|
|
3
|
+
* Sources:
|
|
4
|
+
* - baileys.wiki Broadcasts (status@broadcast + statusJidList)
|
|
5
|
+
* - WhiskeySockets/Baileys Discussion #2318 (groupStatusMessageV2)
|
|
6
|
+
* - c4bal/wolfsocket groupStatus patterns
|
|
7
|
+
*/
|
|
8
|
+
import { generateWAMessage, generateWAMessageFromContent, prepareWAMessageMedia } from "./messages.js";
|
|
9
|
+
import { generateMessageIDV2, unixTimestampSeconds } from "./generics.js";
|
|
10
|
+
import { jidNormalizedUser, isJidGroup } from "../WABinary/jid-utils.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Personal WhatsApp Status (story) → status@broadcast
|
|
14
|
+
* @param {object} sock
|
|
15
|
+
* @param {object} content - same shape as sendMessage content (text/image/video/audio)
|
|
16
|
+
* @param {string[]} [statusJidList] - audience JIDs
|
|
17
|
+
* @param {object} [options]
|
|
18
|
+
*/
|
|
19
|
+
export async function sendPersonalStatus(sock, content, statusJidList = [], options = {}) {
|
|
20
|
+
const list = Array.isArray(statusJidList) ? statusJidList.filter(Boolean) : [];
|
|
21
|
+
return sock.sendMessage(
|
|
22
|
+
"status@broadcast",
|
|
23
|
+
content,
|
|
24
|
+
{
|
|
25
|
+
...options,
|
|
26
|
+
broadcast: true,
|
|
27
|
+
statusJidList: list.length ? list : options.statusJidList,
|
|
28
|
+
backgroundColor: options.backgroundColor,
|
|
29
|
+
font: options.font,
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Group Status (story visible inside one group) via groupStatusMessageV2
|
|
36
|
+
* @param {object} sock
|
|
37
|
+
* @param {string} groupJid - must end with @g.us
|
|
38
|
+
* @param {object} content - { text } | { image, caption } | { video, caption } | { audio }
|
|
39
|
+
* @param {object} [options]
|
|
40
|
+
*/
|
|
41
|
+
export async function sendGroupStatus(sock, groupJid, content, options = {}) {
|
|
42
|
+
if (!isJidGroup(groupJid)) {
|
|
43
|
+
throw new TypeError("sendGroupStatus requires a group JID (@g.us)");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const senderJid = jidNormalizedUser(sock.user?.id);
|
|
47
|
+
const colorArgb = (options.backgroundColorArgb ?? options.colorArgb ?? 0xff23313a) >>> 0;
|
|
48
|
+
const font = options.font ?? 1;
|
|
49
|
+
|
|
50
|
+
// Prefer high-level flag if upstream sendMessage already supports groupStatus
|
|
51
|
+
if (typeof sock.sendMessage === "function" && content && (content.image || content.video || content.audio || content.text)) {
|
|
52
|
+
try {
|
|
53
|
+
// Path A: c4bal-style flag
|
|
54
|
+
if (content.image || content.video || content.audio) {
|
|
55
|
+
return await sock.sendMessage(
|
|
56
|
+
groupJid,
|
|
57
|
+
{ ...content, groupStatus: true },
|
|
58
|
+
options
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
} catch (_) {
|
|
62
|
+
/* fall through to V2 payload */
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const contextInfo = {
|
|
67
|
+
forwardingScore: 0,
|
|
68
|
+
featureEligibilities: {
|
|
69
|
+
canBeReshared: true,
|
|
70
|
+
canReceiveMultiReact: true,
|
|
71
|
+
},
|
|
72
|
+
pairedMediaType: 0,
|
|
73
|
+
statusSourceType: 4,
|
|
74
|
+
statusAttributions: [{ type: 10 }],
|
|
75
|
+
isGroupStatus: true,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Media path: prepare media then send with isGroupStatus context
|
|
79
|
+
if (content.image || content.video || content.audio || content.sticker) {
|
|
80
|
+
const mediaContent = { ...content };
|
|
81
|
+
delete mediaContent.groupStatus;
|
|
82
|
+
const prepared = await generateWAMessage(groupJid, mediaContent, {
|
|
83
|
+
userJid: senderJid,
|
|
84
|
+
upload: sock.waUploadToServer,
|
|
85
|
+
logger: sock.logger,
|
|
86
|
+
...options,
|
|
87
|
+
});
|
|
88
|
+
const key = Object.keys(prepared.message || {}).find((k) => k.endsWith("Message"));
|
|
89
|
+
if (key && prepared.message[key]) {
|
|
90
|
+
prepared.message[key].contextInfo = {
|
|
91
|
+
...(prepared.message[key].contextInfo || {}),
|
|
92
|
+
...contextInfo,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
await sock.relayMessage(groupJid, prepared.message, {
|
|
96
|
+
messageId: prepared.key.id,
|
|
97
|
+
});
|
|
98
|
+
return prepared;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Text path: groupStatusMessageV2 wrapper (#2318)
|
|
102
|
+
const text = content.text || content.caption || " ";
|
|
103
|
+
const innerContent = {
|
|
104
|
+
extendedTextMessage: {
|
|
105
|
+
text,
|
|
106
|
+
font,
|
|
107
|
+
backgroundArgb: colorArgb,
|
|
108
|
+
contextInfo: {
|
|
109
|
+
forwardingScore: 0,
|
|
110
|
+
featureEligibilities: {
|
|
111
|
+
canBeReshared: true,
|
|
112
|
+
canReceiveMultiReact: true,
|
|
113
|
+
},
|
|
114
|
+
pairedMediaType: 0,
|
|
115
|
+
isGroupStatus: true,
|
|
116
|
+
statusAttributions: [
|
|
117
|
+
{
|
|
118
|
+
type: 6,
|
|
119
|
+
groupStatus: { authorJid: senderJid },
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const messageContent = {
|
|
127
|
+
groupStatusMessageV2: {
|
|
128
|
+
message: innerContent,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const generated = generateWAMessageFromContent(groupJid, messageContent, {
|
|
133
|
+
userJid: senderJid,
|
|
134
|
+
messageId: options.messageId || generateMessageIDV2(senderJid),
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
await sock.relayMessage(groupJid, generated.message, {
|
|
138
|
+
messageId: generated.key.id,
|
|
139
|
+
});
|
|
140
|
+
return generated;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export default { sendPersonalStatus, sendGroupStatus };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prototypevip/baileys",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Baileys fork (@prototypevip/baileys) — clean
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "Baileys fork (@prototypevip/baileys) — clean + Channel/Group/Personal Status + Interactive Buttons/Lists/Album/Carousel + Rich code responses + Call Invites helpers (0.1.5)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"files": [
|
|
21
21
|
"lib/**/*",
|
|
22
22
|
"WAProto/**/*",
|
|
23
|
-
"engine-requirements.js"
|
|
23
|
+
"engine-requirements.js",
|
|
24
|
+
"HELPERS.md"
|
|
24
25
|
],
|
|
25
26
|
"keywords": [
|
|
26
27
|
"automation",
|
|
@@ -34,7 +35,13 @@
|
|
|
34
35
|
"whatsapp-bot",
|
|
35
36
|
"whatsapp-chat",
|
|
36
37
|
"whatsapp-group",
|
|
37
|
-
"whatsapp-web"
|
|
38
|
+
"whatsapp-web",
|
|
39
|
+
"interactive-messages",
|
|
40
|
+
"buttons",
|
|
41
|
+
"album",
|
|
42
|
+
"native-flow",
|
|
43
|
+
"call-invite",
|
|
44
|
+
"rich-response"
|
|
38
45
|
],
|
|
39
46
|
"homepage": "https://github.com/GSK-F/baileys",
|
|
40
47
|
"author": "The Prototype",
|