sauruspro-bail 5.0.0 → 5.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.
Files changed (39) hide show
  1. package/README.md +8 -9
  2. package/docs/CHANGELOG.md +25 -4
  3. package/docs/SPR.md +2 -2
  4. package/lib/Defaults/index.js +5 -1
  5. package/lib/Socket/dinonic-handler.d.ts +27 -0
  6. package/lib/Socket/dinonic-handler.js +882 -0
  7. package/lib/Socket/index.js +5 -1
  8. package/lib/Socket/messages-recv.js +26 -0
  9. package/lib/Socket/messages-send.js +25 -0
  10. package/lib/Utils/MessageBuilder.d.ts +215 -0
  11. package/lib/Utils/MessageBuilder.js +3991 -0
  12. package/lib/Utils/a2ui.d.ts +202 -0
  13. package/lib/Utils/a2ui.js +732 -0
  14. package/lib/Utils/airich-registry.js +3 -0
  15. package/lib/Utils/baileys-event-stream.js +58 -0
  16. package/lib/Utils/bot-signature.d.ts +22 -0
  17. package/lib/Utils/bot-signature.js +124 -0
  18. package/lib/Utils/{dinolith-spr.js → dinonic-spr.js} +1 -1
  19. package/lib/Utils/extras.d.ts +449 -0
  20. package/lib/Utils/extras.js +1377 -0
  21. package/lib/Utils/html-app.d.ts +39 -0
  22. package/lib/Utils/html-app.js +291 -0
  23. package/lib/Utils/index.js +14 -2
  24. package/lib/Utils/metaai.d.ts +438 -0
  25. package/lib/Utils/metaai.js +911 -0
  26. package/lib/Utils/modern-messages.d.ts +150 -0
  27. package/lib/Utils/modern-messages.js +496 -0
  28. package/lib/Utils/native-flow.d.ts +14 -0
  29. package/lib/Utils/native-flow.js +118 -0
  30. package/lib/Utils/newsletter-status.js +9 -53
  31. package/lib/Utils/payment-messages.d.ts +59 -0
  32. package/lib/Utils/payment-messages.js +156 -0
  33. package/lib/Utils/scheduled-message.d.ts +82 -0
  34. package/lib/Utils/scheduled-message.js +113 -0
  35. package/lib/Utils/status-stickers.d.ts +78 -0
  36. package/lib/Utils/status-stickers.js +261 -0
  37. package/lib/index.js +2 -2
  38. package/package.json +4 -4
  39. /package/lib/Utils/{dinolith-spr.d.ts → dinonic-spr.d.ts} +0 -0
@@ -5,7 +5,8 @@ import { makeInteropSocket } from './interop.js'
5
5
  import { makePrivacySocket } from './privacy.js'
6
6
  import { makeGraphQLSocket } from './graphql.js'
7
7
  import { makeMessageBuilderSocket } from './message-builder.js'
8
- import { sPR } from '../Utils/dinolith-spr.js'
8
+ import { sPR } from '../Utils/dinonic-spr.js'
9
+ import * as DinonicBuilder from '../Utils/MessageBuilder.js'
9
10
  import {
10
11
  makeNewsletterStatusSender,
11
12
  makeNewsletterStatusReactionSender,
@@ -32,6 +33,9 @@ const makeWASocket = (config) => {
32
33
  clientWithBuilder.Toolkit = MB.Toolkit;
33
34
  clientWithBuilder.MessageBuilder = MB;
34
35
 
36
+ // Builder by Saurus (A2UI, AIRich, Button, ButtonV2, Carousel, Toolkit)
37
+ clientWithBuilder.DinonicBuilder = DinonicBuilder;
38
+
35
39
  // SPR (Selective Relay)
36
40
  clientWithBuilder.sPR = (jid, message, options) => sPR(clientWithBuilder, jid, message, options);
37
41
  clientWithBuilder.relayMessageSelective = clientWithBuilder.sPR;
@@ -1563,6 +1563,20 @@ export const makeMessagesRecvSocket = (config) => {
1563
1563
  }
1564
1564
  }
1565
1565
  cleanMessage(msg, authState.creds.me.id, authState.creds.me.lid);
1566
+ if (config.autoReadStatus && msg.key.remoteJid === 'status@broadcast' && !msg.key.fromMe) {
1567
+ try {
1568
+ const participant = msg.key.participant || msg.key.remoteJid;
1569
+ await sendReceipt('status@broadcast', participant, [msg.key.id], 'read');
1570
+ }
1571
+ catch (_) { }
1572
+ }
1573
+ if (config.autoReadMessages && msg.key.remoteJid !== 'status@broadcast' && !msg.key.fromMe) {
1574
+ try {
1575
+ const participant = msg.key.participant || undefined;
1576
+ await sendReceipt(msg.key.remoteJid, participant, [msg.key.id], 'read');
1577
+ }
1578
+ catch (_) { }
1579
+ }
1566
1580
  await upsertMessage(msg, node.attrs.offline ? 'append' : 'notify');
1567
1581
  });
1568
1582
  }
@@ -1604,6 +1618,18 @@ export const makeMessagesRecvSocket = (config) => {
1604
1618
  call.isGroup = infoChild.attrs.type === 'group' || !!infoChild.attrs['group-jid'];
1605
1619
  call.groupJid = infoChild.attrs['group-jid'];
1606
1620
  await callOfferCache.set(call.id, call);
1621
+ if (config.rejectCalls) {
1622
+ logger.info({ callId, from }, 'rejecting call automatically');
1623
+ try {
1624
+ await rejectCall(callId, from);
1625
+ if (config.callRejectMessage) {
1626
+ await sendMessage(from, typeof config.callRejectMessage === 'string' ? { text: config.callRejectMessage } : config.callRejectMessage);
1627
+ }
1628
+ }
1629
+ catch (err) {
1630
+ logger.error({ err }, 'failed to auto-reject call');
1631
+ }
1632
+ }
1607
1633
  }
1608
1634
  const existingCall = await callOfferCache.get(call.id);
1609
1635
  // use existing call info to populate this event
@@ -11,6 +11,7 @@ import { areJidsSameUser, getBinaryNodeChild, getBinaryNodeChildren, isHostedLid
11
11
  import { USyncQuery, USyncUser } from '../WAUSync/index.js';
12
12
  import { makeUsernameSocket } from './username.js';
13
13
  import imup from './luxu.js';
14
+ import DinonicHandler from './dinonic-handler.js';
14
15
  import * as Utils_1 from '../Utils/index.js';
15
16
  import { randomBytes, createHmac } from 'crypto';
16
17
 
@@ -1219,6 +1220,7 @@ export const makeMessagesSocket = (config) => {
1219
1220
  }
1220
1221
  });
1221
1222
 
1223
+ const dinonic = new DinonicHandler(Utils_1, waUploadToServer, relayMessage, config, sock);
1222
1224
  return {
1223
1225
  ...sock,
1224
1226
  userDevicesCache,
@@ -1331,9 +1333,32 @@ export const makeMessagesSocket = (config) => {
1331
1333
  await relayMessage(jid, message, { messageId });
1332
1334
  return { message, messageId };
1333
1335
  },
1336
+ sendStatusWhatsApp: async (content, jids = []) => {
1337
+ return await dinonic.sendStatusWhatsApp(content, jids);
1338
+ },
1339
+ getName: async (jid) => {
1340
+ return await dinonic.getName(jid);
1341
+ },
1334
1342
  sendMessage: async (jid, content, options = {}) => {
1335
1343
  const userJid = authState.creds.me.id;
1336
1344
  const luki = new imup(Utils_1, waUploadToServer, relayMessage);
1345
+ {
1346
+ // Handler Dinonic (by Saurus): Interactive/Carousel, Buttons, Flow, Group Story
1347
+ const dType = dinonic.detectType(content);
1348
+ if (dType === 'INTERACTIVE' || dType === 'BUTTONS' || dType === 'FLOW' || dType === 'GROUP_STORY') {
1349
+ const dQuoted = options.quoted;
1350
+ if (dType === 'GROUP_STORY') {
1351
+ return await dinonic.handleGroupStory(content, jid, dQuoted);
1352
+ }
1353
+ let dContent;
1354
+ if (dType === 'INTERACTIVE') dContent = await dinonic.handleInteractive(content, jid, dQuoted);
1355
+ else if (dType === 'FLOW') dContent = await dinonic.handleFlow(content, jid, dQuoted);
1356
+ else dContent = content.buttonsMessage ? content : { buttonsMessage: content };
1357
+ const dMsg = await Utils_1.generateWAMessageFromContent(jid, dContent, { quoted: dQuoted });
1358
+ await relayMessage(jid, dMsg.message, { messageId: dMsg.key.id });
1359
+ return dMsg;
1360
+ }
1361
+ }
1337
1362
  const {
1338
1363
  quoted,
1339
1364
  participant,
@@ -0,0 +1,215 @@
1
+ export declare const VERSION: "4.8";
2
+ export declare const MESSAGE_BUILDER_VERSION: "4.8";
3
+
4
+ export interface AIRichItemOptions {
5
+ id?: string;
6
+ replace?: string | number;
7
+ insertAt?: string | number;
8
+ }
9
+
10
+ export declare class AIRichError extends Error {
11
+ constructor(message: string, code: string, meta?: Record<string, any>);
12
+ code: string;
13
+ }
14
+
15
+ export declare class ItemNotFoundError extends AIRichError {
16
+ constructor(id: string, availableIds?: string[]);
17
+ id: string;
18
+ availableIds: string[];
19
+ }
20
+
21
+ export declare class DuplicateIdError extends AIRichError {
22
+ constructor(id: string);
23
+ id: string;
24
+ }
25
+
26
+ export declare class InvalidTargetError extends AIRichError {
27
+ constructor(message: string, meta?: Record<string, any>);
28
+ }
29
+
30
+ export declare class ContentValidationError extends AIRichError {
31
+ constructor(message: string, meta?: Record<string, any>);
32
+ }
33
+
34
+ export declare class Toolkit {
35
+ constructor();
36
+ static extractIE(text: string, options?: Record<string, any>): any;
37
+ static resize(buffer: Buffer, x: number, y: number, fit?: string): Promise<Buffer>;
38
+ static waitAllPromises(input: any): Promise<any>;
39
+ static fetchBuffer(url: string, options?: Record<string, any>, settings?: { silent?: boolean }): Promise<Buffer>;
40
+ static toUrl(client: any, path: any, mediaType?: string): Promise<any>;
41
+ static resolveMedia(client: any, media: any, mediaType?: string, options?: Record<string, any>): Promise<any>;
42
+ static getMp4Duration(buffer: Buffer, options?: { silent?: boolean }): number;
43
+ static getMp4Preview(videoBuffer: Buffer, options?: Record<string, any>): Promise<Buffer | string>;
44
+ static stringifyEscaped(obj: any): string;
45
+ }
46
+
47
+ declare class BaseBuilder {
48
+ setTitle(title: string): this;
49
+ setSubtitle(subtitle: string): this;
50
+ setBody(body: string): this;
51
+ setFooter(footer: string): this;
52
+ setContextInfo(obj: Record<string, any>): this;
53
+ addPayload(obj: Record<string, any>): this;
54
+ }
55
+
56
+ export declare class Button extends BaseBuilder {
57
+ constructor(client: any);
58
+ loadFrom(msg: any): this;
59
+ setVideo(path: any, options?: Record<string, any>): this;
60
+ setImage(path: any, options?: Record<string, any>): this;
61
+ setDocument(path: any, options?: Record<string, any>): this;
62
+ setMedia(obj: Record<string, any>): this;
63
+ clearButtons(): this;
64
+ setParams(obj: Record<string, any>): this;
65
+ addButton(name: string, params: Record<string, any> | string): this;
66
+ makeRow(header?: string, title?: string, description?: string, id?: string): this;
67
+ makeSection(title?: string, highlightLabel?: string): this;
68
+ addSelection(title: string, options?: Record<string, any>): this;
69
+ addReply(displayText?: string, id?: string, options?: Record<string, any>): this;
70
+ addCall(displayText?: string, id?: string, options?: Record<string, any>): this;
71
+ addReminder(displayText?: string, id?: string, options?: Record<string, any>): this;
72
+ addCancelReminder(displayText?: string, id?: string, options?: Record<string, any>): this;
73
+ addAddress(displayText?: string, id?: string, options?: Record<string, any>): this;
74
+ addLocation(options?: Record<string, any>): this;
75
+ addUrl(displayText?: string, url?: string, webviewInteraction?: boolean, options?: Record<string, any>): this;
76
+ addCopy(displayText?: string, copyCode?: string, options?: Record<string, any>): this;
77
+ static paramsList: Record<string, any>;
78
+ toCard(): Promise<any>;
79
+ build(jid: string, options?: Record<string, any>): Promise<any>;
80
+ send(jid: string, options?: Record<string, any>): Promise<any>;
81
+ }
82
+
83
+ export declare class ButtonV2 extends BaseBuilder {
84
+ constructor(client: any);
85
+ loadFrom(msg: any): this;
86
+ addButton(displayText?: string, buttonId?: string): this;
87
+ addRawButton(obj: Record<string, any>): this;
88
+ setRawThumbnail(thumbnail: string): this;
89
+ setThumbnail(path: any): this;
90
+ setMedia(obj: Record<string, any>): this;
91
+ build(jid: string, options?: Record<string, any>): Promise<any>;
92
+ send(jid: string, options?: Record<string, any>): Promise<any>;
93
+ }
94
+
95
+ export declare class Carousel extends BaseBuilder {
96
+ constructor(client: any);
97
+ loadFrom(msg: any): this;
98
+ addCard(card: any): this;
99
+ build(jid: string, options?: Record<string, any>): any;
100
+ send(jid: string, options?: Record<string, any>): Promise<any>;
101
+ }
102
+
103
+ export declare class AIRich extends BaseBuilder {
104
+ constructor(client: any, options?: { dynamic?: boolean; unsupportedTypeAlert?: boolean });
105
+ static readonly DEFAULT_BOT_JID: string;
106
+ static readonly MAP_DELTA: number;
107
+ static readonly LAYOUT_FIELDS: Readonly<Record<string, string>>;
108
+ static readonly SECTION_TYPENAME: string;
109
+ static readonly UNIFIED_RESPONSE_TYPENAME: string;
110
+ static tokenizer(code: string, lang?: string): any;
111
+ static toTableMetadata(rows: any[], options?: Record<string, any>): any;
112
+ static generateVerificationMetadata(): any;
113
+ static isMetaSignature(verificationMetadata: any): boolean;
114
+ static readonly PLACEHOLDER_MARKER: Buffer;
115
+ static wrapRichResponse(richResponseMessage: any, forwardWrapper?: boolean): any;
116
+ static newLayout(name: string, data: any, extra?: Record<string, any>): any;
117
+ static normalizeSection(section: any): any;
118
+ readonly isSignaturePreserved: boolean;
119
+ loadFrom(msg: any): this;
120
+ setResponseMeta(meta: Record<string, any>): this;
121
+ setResponseId(id: string): this;
122
+ refreshResponseId(): this;
123
+ setBotResponseId(id: string): this;
124
+ refreshBotResponseId(): this;
125
+ createAlert(type: string): any;
126
+ hasId(id: string): boolean;
127
+ getIds(): string[];
128
+ peek(id?: string | number): any;
129
+ assignId(target: string | number, id: string): this;
130
+ delete(target: string | number): this;
131
+ addSubmessage(submessage: any, options?: AIRichItemOptions): this;
132
+ addSection(section: any, options?: AIRichItemOptions & { text?: string; submessage?: any }): this;
133
+ addFooterSection(section: any): this;
134
+ addEmbeddedScreen(screen: any): this;
135
+ setBotMetadata(extra: Record<string, any>): this;
136
+ clearFooterSections(): this;
137
+ addText(text: string, options?: AIRichItemOptions & { hyperlink?: boolean; citation?: boolean; latex?: boolean }): this;
138
+ addFOAText(text: string, options?: AIRichItemOptions): this;
139
+ addCode(language: string, code: string, options?: AIRichItemOptions): this;
140
+ addTable(table: string[][], options?: AIRichItemOptions & { hyperlink?: boolean; citation?: boolean; latex?: boolean }): this;
141
+ addMap(
142
+ places: {
143
+ latitude: number;
144
+ longitude: number;
145
+ title?: string;
146
+ name?: string;
147
+ body?: string;
148
+ description?: string;
149
+ address?: string;
150
+ id?: string | number;
151
+ imageUrl?: string;
152
+ itemType?: string;
153
+ }[],
154
+ options?: AIRichItemOptions & {
155
+ center?: { latitude: number; longitude: number };
156
+ latitudeDelta?: number;
157
+ longitudeDelta?: number;
158
+ showInfoList?: boolean;
159
+ motivation?: string;
160
+ staticMapUrl?: string;
161
+ staticMapDarkUrl?: string;
162
+ }
163
+ ): this;
164
+ addSource(sources?: any[], options?: AIRichItemOptions): this;
165
+ addReels(reelsItems?: any, options?: AIRichItemOptions): this;
166
+ addImage(imageUrl: any, options?: AIRichItemOptions & { width?: number; height?: number; status?: string; update_text?: string; resolveUrl?: boolean }): this;
167
+ addVideo(videoUrl: any, options?: AIRichItemOptions & { autoFill?: boolean; status?: string; estimatedTime?: number }): this;
168
+ addProduct(data?: any, options?: AIRichItemOptions): this;
169
+ addPost(data?: any, options?: AIRichItemOptions): this;
170
+ addMetadata(text: string, options?: AIRichItemOptions): this;
171
+ addTip(text: string, options?: AIRichItemOptions): this;
172
+ addWidget(data: any, options?: AIRichItemOptions & { layout?: string }): this;
173
+ addFooterAction(data: any, options?: AIRichItemOptions & { layout?: string }): this;
174
+ addSuggest(suggestion: string | string[], options?: AIRichItemOptions & { scroll?: boolean; layout?: string }): this;
175
+ addHtml(html: string, options?: AIRichItemOptions & { title?: string; trusted_sources?: string[] }): this;
176
+ addA2UI(a2uiInstance: any, options?: AIRichItemOptions & { type?: string }): this;
177
+ build(jid: string, options?: Record<string, any>): Promise<any>;
178
+ buildEdit(targetJid: string, targetId: string, options?: Record<string, any>): Promise<any>;
179
+ send(jid: string, options?: Record<string, any>): Promise<any>;
180
+ sendEdit(jid?: string, id?: string, options?: Record<string, any>): Promise<any>;
181
+ readonly sections: any[];
182
+ readonly items: any[];
183
+ }
184
+
185
+ export declare function bind(client: any): any;
186
+
187
+ export declare const MessageBuilder: Readonly<{
188
+ VERSION: "4.8";
189
+ Button: typeof Button;
190
+ ButtonV2: typeof ButtonV2;
191
+ Carousel: typeof Carousel;
192
+ AIRich: typeof AIRich;
193
+ Toolkit: typeof Toolkit;
194
+ bind: typeof bind;
195
+ A2UI: any;
196
+ sendA2UI: any;
197
+ sendA2UIWidget: any;
198
+ sendBloksWidget: any;
199
+ sendHtmlApp: any;
200
+ sendHtmlDocument: any;
201
+ htmlSection: any;
202
+ checkHtmlApp: any;
203
+ autoHeight: any;
204
+ lockHeight: any;
205
+ scrollControls: any;
206
+ buildDefaultBizNodes: any;
207
+ AIRichError: typeof AIRichError;
208
+ ItemNotFoundError: typeof ItemNotFoundError;
209
+ DuplicateIdError: typeof DuplicateIdError;
210
+ InvalidTargetError: typeof InvalidTargetError;
211
+ ContentValidationError: typeof ContentValidationError;
212
+ }>;
213
+
214
+ export declare const MB: typeof MessageBuilder;
215
+ export default MessageBuilder;