@vanzxy/baileys 1.6.2 → 1.6.4

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.

Potentially problematic release.


This version of @vanzxy/baileys might be problematic. Click here for more details.

Files changed (51) hide show
  1. package/NOTICE.md +50 -0
  2. package/lib/Utils/A2UI.js +217 -0
  3. package/lib/Utils/MessageBuilder.js +332 -46
  4. package/lib/Utils/MessageBuilder_d.ts +45 -0
  5. package/lib/Utils/PersistentStore.js +592 -0
  6. package/lib/Utils/PersistentStore_d.ts +60 -0
  7. package/lib/Utils/anti-delete.d.ts +68 -0
  8. package/lib/Utils/anti-delete.js +185 -0
  9. package/lib/Utils/auto-reply.d.ts +47 -0
  10. package/lib/Utils/auto-reply.js +155 -0
  11. package/lib/Utils/button-helper-utils.js +314 -0
  12. package/lib/Utils/button-sender.js +817 -0
  13. package/lib/Utils/chat-history-helpers.d.ts +21 -0
  14. package/lib/Utils/chat-history-helpers.js +71 -0
  15. package/lib/Utils/index.d.ts +11 -0
  16. package/lib/Utils/index.js +16 -0
  17. package/lib/Utils/media-messages.d.ts +18 -0
  18. package/lib/Utils/media-messages.js +71 -0
  19. package/lib/Utils/media-set.d.ts +13 -0
  20. package/lib/Utils/media-set.js +165 -0
  21. package/lib/Utils/message-kind.js +139 -0
  22. package/lib/Utils/message-search.d.ts +44 -0
  23. package/lib/Utils/message-search.js +174 -0
  24. package/lib/Utils/scheduling.d.ts +42 -0
  25. package/lib/Utils/scheduling.js +140 -0
  26. package/lib/Utils/status.d.ts +50 -0
  27. package/lib/Utils/status.js +108 -0
  28. package/lib/Utils/stickerpack.d.ts +51 -0
  29. package/lib/Utils/stickerpack.js +276 -0
  30. package/lib/Utils/templates.d.ts +76 -0
  31. package/lib/Utils/templates.js +151 -0
  32. package/lib/Utils/use-sqlite-auth-state.js +28 -1
  33. package/lib/Utils/vcard.d.ts +58 -0
  34. package/lib/Utils/vcard.js +94 -0
  35. package/lib/VoIP/audio-feeder.d.ts +15 -0
  36. package/lib/VoIP/audio-feeder.js +132 -0
  37. package/lib/VoIP/index.js +277 -0
  38. package/lib/VoIP/relay-transport.d.ts +43 -0
  39. package/lib/VoIP/relay-transport.js +559 -0
  40. package/lib/VoIP/signaling.js +624 -0
  41. package/lib/VoIP/types.d.ts +69 -0
  42. package/lib/VoIP/types.js +17 -0
  43. package/lib/VoIP/wasm-engine.d.ts +103 -0
  44. package/lib/VoIP/wasm-engine.js +1214 -0
  45. package/lib/VoIP/worker-bootstrap.js +1042 -0
  46. package/lib/WABinary/generic-utils.js +8 -0
  47. package/lib/assets/wasm/loader.js +5 -0
  48. package/lib/assets/wasm/whatsapp.wasm +0 -0
  49. package/lib/assets/wasm/worker-modules.js +273 -0
  50. package/lib/index.js +4 -0
  51. package/package.json +22 -1
@@ -0,0 +1,174 @@
1
+ // Vanz@Add --- ported from Bail-master addons/message-search.ts (type-only
2
+ // annotations dropped; behavior unchanged).
3
+ export const extractMessageText = (message) => {
4
+ const c = message.message;
5
+ if (!c)
6
+ return '';
7
+ if (c.conversation)
8
+ return c.conversation;
9
+ if (c.extendedTextMessage?.text)
10
+ return c.extendedTextMessage.text;
11
+ if (c.imageMessage?.caption)
12
+ return c.imageMessage.caption;
13
+ if (c.videoMessage?.caption)
14
+ return c.videoMessage.caption;
15
+ if (c.documentMessage?.caption)
16
+ return c.documentMessage.caption;
17
+ if (c.documentMessage?.fileName)
18
+ return c.documentMessage.fileName;
19
+ if (c.locationMessage?.name)
20
+ return c.locationMessage.name;
21
+ if (c.locationMessage?.address)
22
+ return c.locationMessage.address;
23
+ if (c.contactMessage?.displayName)
24
+ return c.contactMessage.displayName;
25
+ if (c.pollCreationMessage?.name)
26
+ return c.pollCreationMessage.name;
27
+ return '';
28
+ };
29
+ const getMessageType = (message) => {
30
+ const c = message.message;
31
+ if (!c)
32
+ return 'other';
33
+ if (c.conversation || c.extendedTextMessage)
34
+ return 'text';
35
+ if (c.imageMessage)
36
+ return 'image';
37
+ if (c.videoMessage)
38
+ return 'video';
39
+ if (c.documentMessage)
40
+ return 'document';
41
+ if (c.audioMessage)
42
+ return 'audio';
43
+ if (c.stickerMessage)
44
+ return 'sticker';
45
+ if (c.locationMessage || c.liveLocationMessage)
46
+ return 'location';
47
+ if (c.contactMessage || c.contactsArrayMessage)
48
+ return 'contact';
49
+ return 'other';
50
+ };
51
+ export const calculateRelevance = (query, text, position) => {
52
+ let score = 100;
53
+ if (text.toLowerCase() === query.toLowerCase())
54
+ score += 50;
55
+ score -= Math.min(position / 10, 20);
56
+ const lt = text.toLowerCase(), lq = query.toLowerCase();
57
+ if (position === 0 ||
58
+ lt[position - 1] === ' ' ||
59
+ lt[position + lq.length] === ' ' ||
60
+ position + lq.length === text.length)
61
+ score += 20;
62
+ return Math.max(score, 0);
63
+ };
64
+ /** Plain-text substring search with relevance-sorted results. */
65
+ export const searchMessages = (messages, query, options = {}) => {
66
+ const results = [];
67
+ const sq = options.caseSensitive ? query : query.toLowerCase();
68
+ for (const message of messages) {
69
+ if (options.jid && message.key.remoteJid !== options.jid)
70
+ continue;
71
+ const ts = message.messageTimestamp;
72
+ const mt = ts ? new Date((typeof ts === 'number' ? ts : Number(ts)) * 1000) : null;
73
+ if (options.fromDate && mt && mt < options.fromDate)
74
+ continue;
75
+ if (options.toDate && mt && mt > options.toDate)
76
+ continue;
77
+ if (options.fromSender && message.key.participant !== options.fromSender)
78
+ continue;
79
+ if (options.fromMe !== undefined && message.key.fromMe !== options.fromMe)
80
+ continue;
81
+ if (options.messageTypes?.length) {
82
+ if (!options.messageTypes.includes(getMessageType(message)))
83
+ continue;
84
+ }
85
+ const text = extractMessageText(message);
86
+ if (!text)
87
+ continue;
88
+ const st = options.caseSensitive ? text : text.toLowerCase();
89
+ const pos = st.indexOf(sq);
90
+ if (pos !== -1) {
91
+ results.push({
92
+ message,
93
+ matchedText: text.substring(Math.max(0, pos - 20), Math.min(text.length, pos + query.length + 20)),
94
+ matchPosition: pos,
95
+ relevanceScore: calculateRelevance(query, text, pos)
96
+ });
97
+ }
98
+ if (options.limit && results.length >= options.limit)
99
+ break;
100
+ }
101
+ return results.sort((a, b) => b.relevanceScore - a.relevanceScore);
102
+ };
103
+ /** Regex-based search (e.g. for commands/patterns), unordered by relevance. */
104
+ export const searchMessagesRegex = (messages, pattern, options = {}) => {
105
+ const results = [];
106
+ for (const message of messages) {
107
+ if (options.jid && message.key.remoteJid !== options.jid)
108
+ continue;
109
+ if (options.fromSender && message.key.participant !== options.fromSender)
110
+ continue;
111
+ if (options.fromMe !== undefined && message.key.fromMe !== options.fromMe)
112
+ continue;
113
+ if (options.messageTypes?.length) {
114
+ if (!options.messageTypes.includes(getMessageType(message)))
115
+ continue;
116
+ }
117
+ const text = extractMessageText(message);
118
+ if (!text)
119
+ continue;
120
+ const match = text.match(pattern);
121
+ if (match)
122
+ results.push({ message, matchedText: match[0], matchPosition: match.index ?? 0, relevanceScore: 100 });
123
+ if (options.limit && results.length >= options.limit)
124
+ break;
125
+ }
126
+ return results;
127
+ };
128
+ /** Standalone searchable index — feed it messages independently of the main Store. */
129
+ export class MessageSearchManager {
130
+ messages = [];
131
+ messageIndex = new Map();
132
+ addMessages(messages) {
133
+ for (const msg of messages) {
134
+ const id = msg.key.id;
135
+ if (id && !this.messageIndex.has(id)) {
136
+ this.messages.push(msg);
137
+ this.messageIndex.set(id, msg);
138
+ }
139
+ }
140
+ }
141
+ removeMessages(messageIds) {
142
+ const idSet = new Set(messageIds);
143
+ this.messages = this.messages.filter((m) => !idSet.has(m.key.id || ''));
144
+ for (const id of messageIds)
145
+ this.messageIndex.delete(id);
146
+ }
147
+ clear() {
148
+ this.messages = [];
149
+ this.messageIndex.clear();
150
+ }
151
+ get count() {
152
+ return this.messages.length;
153
+ }
154
+ search(query, options) {
155
+ return searchMessages(this.messages, query, options);
156
+ }
157
+ searchRegex(pattern, options) {
158
+ return searchMessagesRegex(this.messages, pattern, options);
159
+ }
160
+ getByJid(jid) {
161
+ return this.messages.filter((m) => m.key.remoteJid === jid);
162
+ }
163
+ getBySender(sender) {
164
+ return this.messages.filter((m) => m.key.participant === sender || m.key.remoteJid === sender);
165
+ }
166
+ getByType(type) {
167
+ return this.messages.filter((m) => getMessageType(m) === type);
168
+ }
169
+ getById(id) {
170
+ return this.messageIndex.get(id);
171
+ }
172
+ }
173
+ export const createMessageSearch = () => new MessageSearchManager();
174
+ //# sourceMappingURL=message-search.js.map
@@ -0,0 +1,42 @@
1
+ import type { WAMessage, AnyMessageContent } from '../Types/index.js';
2
+ export interface SchedulerOptions {
3
+ maxQueue?: number;
4
+ checkInterval?: number;
5
+ onSent?: (scheduled: ScheduledMessage, message?: WAMessage) => void;
6
+ onFailed?: (scheduled: ScheduledMessage, error: Error) => void;
7
+ }
8
+ export type ScheduledMessageStatus = 'pending' | 'sent' | 'failed' | 'cancelled';
9
+ export interface RepeatOptions {
10
+ repeatIntervalMs?: number;
11
+ maxRepeats?: number;
12
+ }
13
+ export interface ScheduledMessage {
14
+ id: string;
15
+ jid: string;
16
+ content: AnyMessageContent;
17
+ scheduledTime: Date;
18
+ createdAt: Date;
19
+ status: ScheduledMessageStatus;
20
+ messageId?: string;
21
+ error?: string;
22
+ repeatIntervalMs?: number;
23
+ maxRepeats?: number;
24
+ repeatCount?: number;
25
+ }
26
+ export declare class MessageScheduler {
27
+ private queue;
28
+ private timer;
29
+ private sendMessage;
30
+ private options;
31
+ constructor(sendMessage: (jid: string, content: AnyMessageContent) => Promise<WAMessage | undefined>, options?: SchedulerOptions);
32
+ schedule(jid: string, content: AnyMessageContent, scheduledTime: Date, repeatOptions?: RepeatOptions): ScheduledMessage;
33
+ scheduleDelay(jid: string, content: AnyMessageContent, delayMs: number, repeatOptions?: RepeatOptions): ScheduledMessage;
34
+ cancel(id: string): boolean;
35
+ cancelForJid(jid: string): number;
36
+ getPending(): ScheduledMessage[];
37
+ get(id: string): ScheduledMessage | undefined;
38
+ clearAll(): number;
39
+ stop(): void;
40
+ start(): void;
41
+ }
42
+ export declare const createMessageScheduler: (sendMessage: (jid: string, content: AnyMessageContent) => Promise<WAMessage | undefined>, options?: SchedulerOptions) => MessageScheduler;
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Vanz@Add --- ported from Bail-master addons/scheduling.ts + message-scheduler.ts.
3
+ * Bail-master shipped these as two separate, overlapping schedulers (one class-based
4
+ * with polling, one function-based with setTimeout + repeat support). Merged here into
5
+ * a single class-based scheduler so multiple independent instances can be bound to
6
+ * different sendMessage functions (e.g. multi-session bots), while keeping the
7
+ * repeat-interval/maxRepeats feature from the function-based version.
8
+ */
9
+ export class MessageScheduler {
10
+ queue = new Map();
11
+ timer = null;
12
+ sendMessage;
13
+ options;
14
+ constructor(sendMessage, options = {}) {
15
+ this.sendMessage = sendMessage;
16
+ this.options = {
17
+ maxQueue: options.maxQueue ?? 1000,
18
+ checkInterval: options.checkInterval ?? 1000,
19
+ onSent: options.onSent ?? (() => { }),
20
+ onFailed: options.onFailed ?? (() => { })
21
+ };
22
+ }
23
+ generateId() {
24
+ return `sched_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
25
+ }
26
+ /**
27
+ * Schedule a message for a specific Date. Pass `repeatIntervalMs` to
28
+ * re-queue the job that many ms after each send (optionally capped by
29
+ * `maxRepeats`).
30
+ */
31
+ schedule(jid, content, scheduledTime, repeatOptions) {
32
+ if (this.queue.size >= this.options.maxQueue)
33
+ throw new Error(`Maximum queue size (${this.options.maxQueue}) reached`);
34
+ if (scheduledTime.getTime() <= Date.now())
35
+ throw new Error('Scheduled time must be in the future');
36
+ const scheduled = {
37
+ id: this.generateId(),
38
+ jid,
39
+ content,
40
+ scheduledTime,
41
+ createdAt: new Date(),
42
+ status: 'pending',
43
+ repeatIntervalMs: repeatOptions?.repeatIntervalMs,
44
+ maxRepeats: repeatOptions?.maxRepeats,
45
+ repeatCount: 0
46
+ };
47
+ this.queue.set(scheduled.id, scheduled);
48
+ this.ensureTimerRunning();
49
+ return scheduled;
50
+ }
51
+ scheduleDelay(jid, content, delayMs, repeatOptions) {
52
+ return this.schedule(jid, content, new Date(Date.now() + delayMs), repeatOptions);
53
+ }
54
+ cancel(id) {
55
+ const s = this.queue.get(id);
56
+ if (s?.status === 'pending') {
57
+ s.status = 'cancelled';
58
+ this.queue.delete(id);
59
+ return true;
60
+ }
61
+ return false;
62
+ }
63
+ cancelForJid(jid) {
64
+ let cancelled = 0;
65
+ for (const [id, s] of this.queue) {
66
+ if (s.jid === jid && s.status === 'pending') {
67
+ s.status = 'cancelled';
68
+ this.queue.delete(id);
69
+ cancelled++;
70
+ }
71
+ }
72
+ return cancelled;
73
+ }
74
+ getPending() {
75
+ return Array.from(this.queue.values()).filter((s) => s.status === 'pending');
76
+ }
77
+ get(id) {
78
+ return this.queue.get(id);
79
+ }
80
+ clearAll() {
81
+ const count = this.queue.size;
82
+ this.queue.clear();
83
+ this.stopTimer();
84
+ return count;
85
+ }
86
+ async processQueue() {
87
+ const now = Date.now();
88
+ for (const [id, s] of this.queue) {
89
+ if (s.status !== 'pending')
90
+ continue;
91
+ if (s.scheduledTime.getTime() > now)
92
+ continue;
93
+ try {
94
+ const message = await this.sendMessage(s.jid, s.content);
95
+ s.messageId = message?.key?.id ?? undefined;
96
+ this.options.onSent(s, message);
97
+ // Handle repeating jobs — re-arm instead of removing from the queue.
98
+ if (s.repeatIntervalMs && s.repeatIntervalMs > 0) {
99
+ const nextCount = (s.repeatCount ?? 0) + 1;
100
+ if (s.maxRepeats === undefined || nextCount < s.maxRepeats) {
101
+ s.repeatCount = nextCount;
102
+ s.scheduledTime = new Date(Date.now() + s.repeatIntervalMs);
103
+ s.status = 'pending';
104
+ continue;
105
+ }
106
+ }
107
+ s.status = 'sent';
108
+ }
109
+ catch (error) {
110
+ s.status = 'failed';
111
+ s.error = error?.message || String(error);
112
+ this.options.onFailed(s, error);
113
+ }
114
+ this.queue.delete(id);
115
+ }
116
+ if (this.queue.size === 0)
117
+ this.stopTimer();
118
+ }
119
+ ensureTimerRunning() {
120
+ if (!this.timer) {
121
+ this.timer = setInterval(() => this.processQueue(), this.options.checkInterval);
122
+ this.timer?.unref?.();
123
+ }
124
+ }
125
+ stopTimer() {
126
+ if (this.timer) {
127
+ clearInterval(this.timer);
128
+ this.timer = null;
129
+ }
130
+ }
131
+ stop() {
132
+ this.stopTimer();
133
+ }
134
+ start() {
135
+ if (this.queue.size > 0)
136
+ this.ensureTimerRunning();
137
+ }
138
+ }
139
+ export const createMessageScheduler = (sendMessage, options) => new MessageScheduler(sendMessage, options);
140
+ //# sourceMappingURL=scheduling.js.map
@@ -0,0 +1,50 @@
1
+ import type { AnyMessageContent } from '../Types/index.js';
2
+ import type makeWASocket from '../Socket/index.js';
3
+ type WASocket = ReturnType<typeof makeWASocket>;
4
+ export declare const STATUS_BROADCAST_JID = "status@broadcast";
5
+ export declare const STATUS_BACKGROUNDS: {
6
+ solid: Record<string, string>;
7
+ gradient: Record<string, string[]>;
8
+ };
9
+ export declare const STATUS_FONTS: {
10
+ readonly SANS_SERIF: 0;
11
+ readonly SERIF: 1;
12
+ readonly NORICAN: 2;
13
+ readonly BRYNDAN: 3;
14
+ readonly BEBASNEUE: 4;
15
+ readonly OSWALD: 5;
16
+ readonly DAMION: 6;
17
+ readonly DANCING: 7;
18
+ readonly COMFORTAA: 8;
19
+ readonly EXOTWO: 9;
20
+ };
21
+ export type StatusFont = (typeof STATUS_FONTS)[keyof typeof STATUS_FONTS];
22
+ export declare const generateStatusMessageId: () => string;
23
+ export type TextStatusOptions = {
24
+ text: string;
25
+ backgroundColor?: string;
26
+ font?: StatusFont;
27
+ textColor?: string;
28
+ mentions?: string[];
29
+ };
30
+ export type MediaStatusOptions = {
31
+ caption?: string;
32
+ gifPlayback?: boolean;
33
+ waveform?: Uint8Array;
34
+ };
35
+ export declare const createTextStatus: (options: TextStatusOptions) => AnyMessageContent;
36
+ export declare const createImageStatus: (media: Buffer | string, options?: MediaStatusOptions) => AnyMessageContent;
37
+ export declare const createVideoStatus: (media: Buffer | string, options?: MediaStatusOptions) => AnyMessageContent;
38
+ export declare const createAudioStatus: (media: Buffer | string, options?: MediaStatusOptions) => AnyMessageContent;
39
+ export declare const getStatusJid: () => string;
40
+ export declare const StatusHelper: {
41
+ text: (text: string, backgroundColor?: string, font?: StatusFont) => AnyMessageContent;
42
+ image: (buffer: Buffer, caption?: string) => AnyMessageContent;
43
+ imageUrl: (url: string, caption?: string) => AnyMessageContent;
44
+ video: (buffer: Buffer, caption?: string) => AnyMessageContent;
45
+ videoUrl: (url: string, caption?: string) => AnyMessageContent;
46
+ gif: (buffer: Buffer, caption?: string) => AnyMessageContent;
47
+ voiceNote: (buffer: Buffer) => AnyMessageContent;
48
+ send: (sock: WASocket, content: AnyMessageContent, jidList?: string[]) => Promise<any>;
49
+ };
50
+ export {};
@@ -0,0 +1,108 @@
1
+ // Vanz@Add --- ported from Bail-master addons/status-helpers.ts (type-only
2
+ // annotations dropped; behavior unchanged). status-posting.ts (the other
3
+ // addon shipping identical STATUS_BACKGROUNDS/STATUS_FONTS/createXStatus/
4
+ // StatusHelper) additionally exposed `makeStatusMentionsAddon`, a
5
+ // socket-factory-style addon requiring deep internal wiring (authState,
6
+ // waUploadToServer, groupMetadata, generateWAMessageContent) matching
7
+ // Baileys' own makeXSocket pattern — left out of this port as too tightly
8
+ // coupled to socket internals to safely merge without live testing.
9
+ // Basic status mentions are still supported via createTextStatus's own
10
+ // `mentions` option (contextInfo.mentionedJid).
11
+ import { randomBytes } from 'crypto';
12
+ export const STATUS_BROADCAST_JID = 'status@broadcast';
13
+ export const STATUS_BACKGROUNDS = {
14
+ solid: {
15
+ green: '#25D366',
16
+ blue: '#34B7F1',
17
+ purple: '#8B5CF6',
18
+ red: '#EF4444',
19
+ orange: '#F97316',
20
+ yellow: '#EAB308',
21
+ pink: '#EC4899',
22
+ teal: '#14B8A6',
23
+ gray: '#6B7280',
24
+ black: '#000000',
25
+ white: '#FFFFFF'
26
+ },
27
+ gradient: {
28
+ sunset: ['#F97316', '#EF4444'],
29
+ ocean: ['#3B82F6', '#06B6D4'],
30
+ forest: ['#22C55E', '#10B981'],
31
+ purple: ['#8B5CF6', '#EC4899'],
32
+ midnight: ['#1E3A8A', '#4C1D95'],
33
+ aurora: ['#06B6D4', '#8B5CF6', '#EC4899']
34
+ }
35
+ };
36
+ export const STATUS_FONTS = {
37
+ SANS_SERIF: 0,
38
+ SERIF: 1,
39
+ NORICAN: 2,
40
+ BRYNDAN: 3,
41
+ BEBASNEUE: 4,
42
+ OSWALD: 5,
43
+ DAMION: 6,
44
+ DANCING: 7,
45
+ COMFORTAA: 8,
46
+ EXOTWO: 9
47
+ };
48
+ /** Generate a status message ID with a 4NY4W3B prefix. */
49
+ export const generateStatusMessageId = () => `4NY4W3B${randomBytes(16).toString('hex').toUpperCase()}`;
50
+ export const createTextStatus = (options) => ({
51
+ text: options.text,
52
+ backgroundColor: options.backgroundColor || STATUS_BACKGROUNDS.solid.green,
53
+ font: options.font ?? STATUS_FONTS.SANS_SERIF,
54
+ textColor: options.textColor || '#FFFFFF',
55
+ contextInfo: { mentionedJid: options.mentions || [], isForwarded: false }
56
+ });
57
+ export const createImageStatus = (media, options) => ({
58
+ image: typeof media === 'string' ? { url: media } : media,
59
+ caption: options?.caption || ''
60
+ });
61
+ export const createVideoStatus = (media, options) => ({
62
+ video: typeof media === 'string' ? { url: media } : media,
63
+ caption: options?.caption || '',
64
+ gifPlayback: options?.gifPlayback || false
65
+ });
66
+ export const createAudioStatus = (media, options) => ({
67
+ audio: typeof media === 'string' ? { url: media } : media,
68
+ ptt: true,
69
+ mimetype: 'audio/ogg; codecs=opus',
70
+ waveform: options?.waveform
71
+ });
72
+ export const getStatusJid = () => STATUS_BROADCAST_JID;
73
+ /** Convenience wrappers + a `send()` that routes group vs. individual/broadcast status delivery. */
74
+ export const StatusHelper = {
75
+ text: (text, backgroundColor, font) => createTextStatus({ text, backgroundColor, font }),
76
+ image: (buffer, caption) => createImageStatus(buffer, { caption }),
77
+ imageUrl: (url, caption) => createImageStatus(url, { caption }),
78
+ video: (buffer, caption) => createVideoStatus(buffer, { caption }),
79
+ videoUrl: (url, caption) => createVideoStatus(url, { caption }),
80
+ gif: (buffer, caption) => createVideoStatus(buffer, { caption, gifPlayback: true }),
81
+ voiceNote: (buffer) => createAudioStatus(buffer),
82
+ /**
83
+ * Send a status to specific JIDs (groups and/or individuals).
84
+ * Handles group status (groupStatus:true) and broadcast (status@broadcast) separately.
85
+ * Pass an empty jidList (or omit it) to broadcast to everyone.
86
+ */
87
+ send: async (sock, content, jidList = []) => {
88
+ const groups = jidList.filter((j) => j?.endsWith('@g.us'));
89
+ const individuals = jidList.filter((j) => j?.endsWith('@s.whatsapp.net') || j?.endsWith('@lid'));
90
+ let lastResult;
91
+ if (groups.length > 0) {
92
+ const groupContent = { ...content, groupStatus: true };
93
+ for (const groupJid of groups) {
94
+ lastResult = await sock.sendMessage(groupJid, groupContent, { messageId: generateStatusMessageId() });
95
+ }
96
+ }
97
+ if (individuals.length > 0 || jidList.length === 0) {
98
+ const result = await sock.sendMessage(STATUS_BROADCAST_JID, content, {
99
+ statusJidList: individuals.length > 0 ? individuals : undefined,
100
+ messageId: generateStatusMessageId()
101
+ });
102
+ if (!lastResult)
103
+ lastResult = result;
104
+ }
105
+ return lastResult;
106
+ }
107
+ };
108
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1,51 @@
1
+ import type { ILogger } from './logger.js';
2
+ import type { WAMediaUpload } from '../Types/index.js';
3
+ import { proto } from '../../WAProto/index.js';
4
+ export declare const isWebPBuffer: (buffer: Buffer) => boolean;
5
+ export declare const isAnimatedWebP: (buffer: Buffer) => boolean;
6
+ export declare const convertToWebP: (input: WAMediaUpload) => Promise<{
7
+ buffer: Buffer;
8
+ isAnimated: boolean;
9
+ }>;
10
+ export declare const generateStickerPackId: () => string;
11
+ export declare const buildStickerPackProto: (pack: {
12
+ name: string;
13
+ publisher: string;
14
+ packId?: string;
15
+ description?: string;
16
+ }) => {
17
+ name: string;
18
+ publisher: string;
19
+ packId: string;
20
+ description: string;
21
+ };
22
+ export declare const STICKER_PACK_MESSAGE_TYPE: 'sticker_pack';
23
+ export type ItsliaaaStickerInput = {
24
+ data: WAMediaUpload;
25
+ emojis?: string[];
26
+ accessibilityLabel?: string;
27
+ };
28
+ export type ItsliaaaStickerPackInput = {
29
+ cover: WAMediaUpload;
30
+ stickers: ItsliaaaStickerInput[];
31
+ name?: string;
32
+ publisher?: string;
33
+ description?: string;
34
+ };
35
+ export type ItsliaaaStickerPackOptions = {
36
+ logger?: ILogger;
37
+ upload: (filePath: string, opts: {
38
+ fileEncSha256B64: string;
39
+ mediaType: string;
40
+ timeoutMs?: number;
41
+ }) => Promise<{
42
+ directPath: string;
43
+ }>;
44
+ options?: RequestInit;
45
+ mediaUploadTimeoutMs?: number;
46
+ mediaCache?: {
47
+ get: (key: string) => Promise<Buffer | undefined>;
48
+ set: (key: string, value: Buffer) => void;
49
+ };
50
+ };
51
+ export declare const prepareStickerPackMessageItsliaaa: (message: ItsliaaaStickerPackInput, options: ItsliaaaStickerPackOptions) => Promise<proto.Message.IStickerPackMessage>;