aunubaileys 1.0.49 โ 1.0.50
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 +4 -0
- package/lib/Socket/aunu-experimental.d.ts +39 -0
- package/lib/Socket/aunu-experimental.js +126 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,6 +64,10 @@ Everything else is pure upstream. When upstream moves, we rebase the patch layer
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
|
|
67
|
+
### ๐งช What's new in 1.0.50 / Baru di 1.0.50 โ EXPERIMENTAL
|
|
68
|
+
|
|
69
|
+
- ๐ **Six more experimental features.** (1) `sock.aunuCard(jid, options)` โ an interactive photo card: the header photo **does not open as a normal photo** when tapped, a title/name and text sit fused below it in the same bubble, and divider-separated buttons (`reply`/`url`/`copy`/`call`) sit underneath; the photo is uploaded from a Buffer/URL and embedded as the header, or supplied prebuilt as `imageMessage`. (2) `sock.aunuFakeQuote(jid, content, quote)` โ send a message carrying a fabricated quote, as if replying to someone. (3) `sock.aunuTypewriter(jid, text, options)` โ a typing effect: the message is sent in growing pieces by editing it on an interval until the full text stands. (4) `sock.aunuReactSequence(jid, key, emojis, options)` โ cycle reactions on one message. (5) `sock.aunuPostStatus(text, options)` โ a styled text status (background colour + font) in one call. (6) `sock.aunuPersonalCard(jid, targetJid, options)` โ the one-person form of 1.0.49's personalised tag-all: an own-profile-picture + name card for a single target, into a chat or as a DM. All experimental, like the features of 1.0.47/1.0.49.
|
|
70
|
+
|
|
67
71
|
### ๐งช What's new in 1.0.49 / Baru di 1.0.49 โ EXPERIMENTAL
|
|
68
72
|
|
|
69
73
|
- ๐ชช **Personalised tag-all: every member sees themselves.** New socket method `sock.aunuPersonalTagAll(groupJid, options)`: for EVERY group member the bot sends one card carrying **that member's own profile picture** and their own name, mentioning exactly them โ not one generic tag-all message. Pictures come from `profilePictureUrl` (the PN form is used when a member is LID-addressed and the LID store knows the pair); the caption is built from a template with `{name}`, `{number}`, `{mention}`, `{jid}` placeholders; names come from a consumer-supplied `getName` resolver when provided, falling back to the number. Members without a profile picture get a text card, or the `fallbackImage` when set. Built-in anti-spam pacing: a delay between sends (`delayMs`, default 1500) and a member cap (`maxMembers`, default 30); `dm: true` delivers each card to the member's private chat instead. Returns a `{ total, sent, failed, skipped }` summary. Experimental, like the five features of 1.0.47.
|
|
@@ -38,6 +38,39 @@ export interface AunuPersonalTagAllResult {
|
|
|
38
38
|
failed: { jid: string; error: string }[];
|
|
39
39
|
skipped: number;
|
|
40
40
|
}
|
|
41
|
+
export interface AunuCardButton {
|
|
42
|
+
type?: 'reply' | 'url' | 'copy' | 'call';
|
|
43
|
+
displayText?: string;
|
|
44
|
+
text?: string;
|
|
45
|
+
id?: string;
|
|
46
|
+
url?: string;
|
|
47
|
+
copyCode?: string;
|
|
48
|
+
phoneNumber?: string;
|
|
49
|
+
/** Raw native-flow passthrough. */
|
|
50
|
+
name?: string;
|
|
51
|
+
buttonParamsJson?: string | Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
export interface AunuCardOptions {
|
|
54
|
+
title?: string;
|
|
55
|
+
subtitle?: string;
|
|
56
|
+
/** Body text fused under the photo in the same bubble. */
|
|
57
|
+
text?: string;
|
|
58
|
+
footer?: string;
|
|
59
|
+
/** Header photo (Buffer or { url }); uploaded and embedded as the card header โ it does not open as a normal photo. */
|
|
60
|
+
image?: Buffer | { url: string };
|
|
61
|
+
/** Prebuilt imageMessage object, used as-is when provided. */
|
|
62
|
+
imageMessage?: Record<string, unknown>;
|
|
63
|
+
buttons?: AunuCardButton[];
|
|
64
|
+
messageOptions?: MiscMessageGenerationOptions;
|
|
65
|
+
}
|
|
66
|
+
export interface AunuFakeQuoteOptions {
|
|
67
|
+
/** JID the fabricated quote pretends to come from. Defaults to the chat JID. */
|
|
68
|
+
from?: string;
|
|
69
|
+
/** Text of the fabricated quoted message. */
|
|
70
|
+
text?: string;
|
|
71
|
+
id?: string;
|
|
72
|
+
quotedMessage?: Record<string, unknown>;
|
|
73
|
+
}
|
|
41
74
|
export interface AunuExperimentalAPI {
|
|
42
75
|
aunuWatermark: (text: string, tag: string) => string;
|
|
43
76
|
aunuReadWatermark: (text: string) => string | null;
|
|
@@ -50,5 +83,11 @@ export interface AunuExperimentalAPI {
|
|
|
50
83
|
aunuCancelSelfDestruct: (messageId: string) => boolean;
|
|
51
84
|
aunuDoctor: () => AunuDoctorReport;
|
|
52
85
|
aunuPersonalTagAll: (groupJid: string, options?: AunuPersonalTagAllOptions) => Promise<AunuPersonalTagAllResult>;
|
|
86
|
+
aunuCard: (jid: string, options?: AunuCardOptions) => Promise<any>;
|
|
87
|
+
aunuFakeQuote: (jid: string, content: Record<string, unknown>, quote?: AunuFakeQuoteOptions, options?: MiscMessageGenerationOptions) => Promise<any>;
|
|
88
|
+
aunuTypewriter: (jid: string, text: string, options?: { steps?: number; intervalMs?: number; messageOptions?: MiscMessageGenerationOptions }) => Promise<any>;
|
|
89
|
+
aunuReactSequence: (jid: string, key: Record<string, unknown>, emojis: string | string[], options?: { intervalMs?: number; messageOptions?: MiscMessageGenerationOptions }) => Promise<number>;
|
|
90
|
+
aunuPostStatus: (text: string, options?: { backgroundColor?: string; font?: number } & MiscMessageGenerationOptions) => Promise<any>;
|
|
91
|
+
aunuPersonalCard: (jid: string | null, targetJid: string, options?: AunuPersonalTagAllOptions) => Promise<any>;
|
|
53
92
|
}
|
|
54
93
|
export declare const attachAunuExperimental: <T>(sock: T) => T & AunuExperimentalAPI;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import baileysVersion from '../Defaults/baileys-version.json' with { type: 'json' };
|
|
2
2
|
import { appendWatermark, computeTypingDuration, extractWatermark, stripWatermark } from '../Utils/aunu-experimental.js';
|
|
3
3
|
import { isLidUser } from '../WABinary/jid-utils.js';
|
|
4
|
+
import { prepareWAMessageMedia } from '../Utils/messages.js';
|
|
5
|
+
import { randomBytes } from 'crypto';
|
|
4
6
|
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
5
7
|
/**
|
|
6
8
|
* AunuBaileys EXPERIMENTAL socket features โ these exist only in
|
|
@@ -25,6 +27,21 @@ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
25
27
|
* mentioning exactly them โ each member sees themselves, not a
|
|
26
28
|
* generic tag-all. Paced sends + a member cap guard against spam
|
|
27
29
|
* limits.
|
|
30
|
+
* 7. Photo card โ `aunuCard`: an interactive card whose header photo does
|
|
31
|
+
* NOT open as a normal photo when tapped; a title/name and text sit
|
|
32
|
+
* fused below it in the same bubble, with divider-separated buttons
|
|
33
|
+
* (reply/url/copy/call) underneath.
|
|
34
|
+
* 8. Fabricated quote โ `aunuFakeQuote`: send any content carrying a
|
|
35
|
+
* made-up quoted message, as if replying to someone.
|
|
36
|
+
* 9. Typewriter โ `aunuTypewriter`: send a message in growing pieces by
|
|
37
|
+
* editing it on an interval until the full text stands.
|
|
38
|
+
* 10. Reaction sequence โ `aunuReactSequence`: cycle reactions on one
|
|
39
|
+
* message (an animation effect).
|
|
40
|
+
* 11. Styled status โ `aunuPostStatus`: post a text status with a
|
|
41
|
+
* background colour and font in one call.
|
|
42
|
+
* 12. Personal card โ `aunuPersonalCard`: the one-person form of
|
|
43
|
+
* aunuPersonalTagAll (own profile picture + name card for one target,
|
|
44
|
+
* into a chat or as a DM).
|
|
28
45
|
*/
|
|
29
46
|
export const attachAunuExperimental = (sock) => {
|
|
30
47
|
const scheduled = new Map();
|
|
@@ -144,6 +161,115 @@ export const attachAunuExperimental = (sock) => {
|
|
|
144
161
|
}
|
|
145
162
|
return results;
|
|
146
163
|
};
|
|
164
|
+
const mapCardButton = (b) => {
|
|
165
|
+
if (!b) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
if (b.name) {
|
|
169
|
+
return { name: b.name, buttonParamsJson: typeof b.buttonParamsJson === 'string' ? b.buttonParamsJson : JSON.stringify(b.buttonParamsJson ?? {}) };
|
|
170
|
+
}
|
|
171
|
+
const display_text = b.displayText || b.text || '';
|
|
172
|
+
switch (b.type) {
|
|
173
|
+
case 'url':
|
|
174
|
+
return { name: 'cta_url', buttonParamsJson: JSON.stringify({ display_text, url: b.url || '', merchant_url: b.url || '' }) };
|
|
175
|
+
case 'copy':
|
|
176
|
+
return { name: 'cta_copy', buttonParamsJson: JSON.stringify({ display_text, id: b.id || 'copy', copy_code: b.copyCode || '' }) };
|
|
177
|
+
case 'call':
|
|
178
|
+
return { name: 'cta_call', buttonParamsJson: JSON.stringify({ display_text, id: b.phoneNumber || '' }) };
|
|
179
|
+
case 'reply':
|
|
180
|
+
default:
|
|
181
|
+
return { name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text, id: b.id || display_text }) };
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
sock.aunuCard = async (jid, options = {}) => {
|
|
185
|
+
let imageMessage = options.imageMessage;
|
|
186
|
+
if (!imageMessage && options.image) {
|
|
187
|
+
const prepared = await prepareWAMessageMedia({ image: options.image }, { upload: sock.waUploadToServer });
|
|
188
|
+
imageMessage = prepared.imageMessage;
|
|
189
|
+
}
|
|
190
|
+
const interactive = {
|
|
191
|
+
header: (options.title || options.subtitle || imageMessage)
|
|
192
|
+
? { title: options.title || '', subtitle: options.subtitle, hasMediaAttachment: !!imageMessage, imageMessage }
|
|
193
|
+
: undefined,
|
|
194
|
+
body: { text: options.text || '' },
|
|
195
|
+
footer: options.footer ? { text: options.footer } : undefined,
|
|
196
|
+
buttons: (options.buttons || []).map(mapCardButton).filter(Boolean)
|
|
197
|
+
};
|
|
198
|
+
return sock.sendMessage(jid, { interactive }, options.messageOptions || {});
|
|
199
|
+
};
|
|
200
|
+
sock.aunuFakeQuote = async (jid, content, quote = {}, options = {}) => {
|
|
201
|
+
const contextInfo = {
|
|
202
|
+
...(content?.contextInfo || {}),
|
|
203
|
+
stanzaId: quote.id || ('AUNU' + randomBytes(6).toString('hex').toUpperCase()),
|
|
204
|
+
participant: quote.from || jid,
|
|
205
|
+
quotedMessage: quote.quotedMessage || { conversation: quote.text || '' }
|
|
206
|
+
};
|
|
207
|
+
return sock.sendMessage(jid, { ...content, contextInfo }, options);
|
|
208
|
+
};
|
|
209
|
+
sock.aunuTypewriter = async (jid, text, options = {}) => {
|
|
210
|
+
const full = String(text ?? '');
|
|
211
|
+
const steps = Math.max(1, options.steps ?? 6);
|
|
212
|
+
const intervalMs = options.intervalMs ?? 700;
|
|
213
|
+
const chunk = Math.max(1, Math.ceil(full.length / steps));
|
|
214
|
+
const sentMsg = await sock.sendMessage(jid, { text: full.slice(0, chunk) }, options.messageOptions || {});
|
|
215
|
+
for (let upto = chunk * 2; upto < full.length + chunk; upto += chunk) {
|
|
216
|
+
if (intervalMs > 0) {
|
|
217
|
+
await delay(intervalMs);
|
|
218
|
+
}
|
|
219
|
+
await sock.sendMessage(jid, { text: full.slice(0, upto), edit: sentMsg.key }, options.messageOptions || {});
|
|
220
|
+
if (upto >= full.length) {
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return sentMsg;
|
|
225
|
+
};
|
|
226
|
+
sock.aunuReactSequence = async (jid, key, emojis, options = {}) => {
|
|
227
|
+
const intervalMs = options.intervalMs ?? 800;
|
|
228
|
+
const list = Array.isArray(emojis) ? emojis : [emojis];
|
|
229
|
+
let n = 0;
|
|
230
|
+
for (const emoji of list) {
|
|
231
|
+
if (n > 0 && intervalMs > 0) {
|
|
232
|
+
await delay(intervalMs);
|
|
233
|
+
}
|
|
234
|
+
await sock.sendMessage(jid, { react: { text: emoji, key } }, options.messageOptions || {});
|
|
235
|
+
n += 1;
|
|
236
|
+
}
|
|
237
|
+
return n;
|
|
238
|
+
};
|
|
239
|
+
sock.aunuPostStatus = async (text, options = {}) => {
|
|
240
|
+
const { backgroundColor = '#000000', font = 0, ...rest } = options;
|
|
241
|
+
return sock.sendMessage('status@broadcast', { text: String(text ?? '') }, { backgroundColor, font, ...rest });
|
|
242
|
+
};
|
|
243
|
+
sock.aunuPersonalCard = async (jid, targetJid, options = {}) => {
|
|
244
|
+
const pn = isLidUser(targetJid) ? (sock.aunuLid?.getPNForLID?.(targetJid) || targetJid) : targetJid;
|
|
245
|
+
const number = pn.split('@')[0].split(':')[0];
|
|
246
|
+
let name = number;
|
|
247
|
+
if (typeof options.getName === 'function') {
|
|
248
|
+
name = (await options.getName(targetJid)) || number;
|
|
249
|
+
}
|
|
250
|
+
const template = options.text || 'Hai {mention} ๐';
|
|
251
|
+
let caption = template
|
|
252
|
+
.replaceAll('{name}', name)
|
|
253
|
+
.replaceAll('{number}', number)
|
|
254
|
+
.replaceAll('{mention}', '@' + number)
|
|
255
|
+
.replaceAll('{jid}', targetJid);
|
|
256
|
+
if (!caption.includes('@' + number)) {
|
|
257
|
+
caption += ' @' + number;
|
|
258
|
+
}
|
|
259
|
+
let ppUrl;
|
|
260
|
+
try {
|
|
261
|
+
ppUrl = await sock.profilePictureUrl(pn, 'image');
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
ppUrl = undefined;
|
|
265
|
+
}
|
|
266
|
+
const content = ppUrl
|
|
267
|
+
? { image: { url: ppUrl }, caption, mentions: [targetJid] }
|
|
268
|
+
: options.fallbackImage
|
|
269
|
+
? { image: Buffer.isBuffer(options.fallbackImage) ? options.fallbackImage : { url: options.fallbackImage }, caption, mentions: [targetJid] }
|
|
270
|
+
: { text: caption, mentions: [targetJid] };
|
|
271
|
+
return sock.sendMessage(jid || pn, content, options.messageOptions || {});
|
|
272
|
+
};
|
|
147
273
|
sock.aunuDoctor = () => ({
|
|
148
274
|
experimental: true,
|
|
149
275
|
bundledWaVersion: Array.isArray(baileysVersion.version) ? baileysVersion.version.join('.') : null,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aunubaileys",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.50",
|
|
5
5
|
"description": "AunuBaileys \u2014 a WhatsApp Web API for bots that never sleep. Full upstream power with the beloved in-memory store restored and pairing that just works. Forged by AunuCore.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"whatsapp",
|