aunubaileys 1.0.41 → 1.0.42
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/Defaults/index.d.ts +2 -0
- package/lib/Defaults/index.js +3 -0
- package/lib/Types/Message.d.ts +27 -0
- package/lib/Types/RichType.d.ts +2 -0
- package/lib/Types/RichType.js +22 -0
- package/lib/Utils/index.js +1 -0
- package/lib/Utils/messages.js +6 -1
- package/lib/Utils/rich-message-utils.d.ts +8 -0
- package/lib/Utils/rich-message-utils.js +339 -0
- package/lib/WABinary/constants.d.ts +39 -0
- package/lib/WABinary/constants.js +168 -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.42 / Baru di 1.0.42
|
|
68
|
+
|
|
69
|
+
- 🧑💻 **Full rich responses: highlighted code blocks + tables** — completing the simple `aiRich` branch that has existed since the 1.0.2–1.0.4 era. Send `{ code, language }`, `{ table, title }`, `{ links }`, or prebuilt `{ richResponse }` submessages and the message routes to the new rich response builder (`lib/Utils/rich-message-utils.js`, exported: `tokenizeCode`, `prepareRichResponseMessage`, `toUnified`): code is tokenized per language (keyword tables for 12 languages + a lexer) into highlight blocks, tables become header + body rows, and the `unifiedResponse` rendering payload is assembled automatically. Two adaptations from the source (@itsliaaa/baileys), recorded plainly: **(1)** the source's donation-link fallbacks are removed — a link without a `url` is skipped and no third-party label/URL is ever injected; **(2)** the 6.7.24 proto has **no** `botForwardedMessage` field and no `BotMetadata.verificationMetadata`/`botResponseId`, so on this base the rich response is sent as the Message's own `richResponseMessage` field (the same shape as the existing `aiRich` branch) and the v7 bot-proof apparatus is not fabricated; the enums follow this proto's nested layout.
|
|
70
|
+
|
|
67
71
|
### 🆕 What's new in 1.0.41 / Baru di 1.0.41
|
|
68
72
|
|
|
69
73
|
- 🏷️ **The biz binary node machinery, plus the `secureMetaServiceLabel` option** — the 6.7.24 base never had the `biz` companion node that official clients attach to business/interactive message stanzas. This release ports it in full from @itsliaaa/baileys: `getBizBinaryNode()` (`actual_actors`/`host_storage`/`privacy_mode_ts` attributes + a `quality_control` child, with `native_flow` variants for known flow buttons and a `list` variant for list messages) and the `shouldIncludeBizBinaryNode()` decider. `relayMessage` now attaches the node **automatically** for buttons/list/template/native-flow messages, and the content option `secureMetaServiceLabel: true` forces it onto any message (the secure Meta service label). Both functions are exported for consumers who need to inspect or build the node themselves.
|
package/lib/Defaults/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { proto } from '../../WAProto/index.js';
|
|
2
2
|
import type { MediaType, SocketConfig } from '../Types/index.js';
|
|
3
|
+
export declare const TEXT_ENCODER: TextEncoder;
|
|
4
|
+
export declare const LEXER_REGEX: RegExp;
|
|
3
5
|
export declare const UNAUTHORIZED_CODES: number[];
|
|
4
6
|
export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
5
7
|
export declare const DEF_CALLBACK_PREFIX = "CB:";
|
package/lib/Defaults/index.js
CHANGED
|
@@ -4,6 +4,9 @@ import { Browsers } from '../Utils/index.js';
|
|
|
4
4
|
import logger from '../Utils/logger.js';
|
|
5
5
|
import defaultVersion from './baileys-version.json' with { type: 'json' };
|
|
6
6
|
const { version } = defaultVersion;
|
|
7
|
+
export const TEXT_ENCODER = new TextEncoder();
|
|
8
|
+
// AunuBaileys: lexer untuk tokenisasi kode rich response (dari @itsliaaa/baileys)
|
|
9
|
+
export const LEXER_REGEX = /(\/\/.*|\/\*[\s\S]*?\*\/|#.*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`[\s\S]*?`)|(\b[a-zA-Z_]\w*\b)(?=\s*\()|(\b[a-zA-Z_]\w*\b)|(\b\d+(?:\.\d+)?\b)|(\s+|[^\w\s]+)/g;
|
|
7
10
|
export const UNAUTHORIZED_CODES = [401, 403, 419];
|
|
8
11
|
export const DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
9
12
|
export const DEF_CALLBACK_PREFIX = 'CB:';
|
package/lib/Types/Message.d.ts
CHANGED
|
@@ -242,6 +242,33 @@ export type AnyMessageContent = (AnyRegularMessageContent | {
|
|
|
242
242
|
ai?: boolean;
|
|
243
243
|
/** AunuBaileys: force the biz binary node (secure Meta service label) onto this message's stanza */
|
|
244
244
|
secureMetaServiceLabel?: boolean;
|
|
245
|
+
/** AunuBaileys: rich response — a highlighted code block (routes the whole message to the rich response builder) */
|
|
246
|
+
code?: string;
|
|
247
|
+
/** language for the rich response code block (default javascript) */
|
|
248
|
+
language?: string;
|
|
249
|
+
/** AunuBaileys: rich response — a table; first row is the heading unless noHeading is set */
|
|
250
|
+
table?: string[][];
|
|
251
|
+
/** title for the rich response table */
|
|
252
|
+
title?: string;
|
|
253
|
+
/** AunuBaileys: rich response — citation links (a link without url is skipped; no fallback is injected) */
|
|
254
|
+
links?: {
|
|
255
|
+
text: string;
|
|
256
|
+
url?: string;
|
|
257
|
+
title?: string;
|
|
258
|
+
displayName?: string;
|
|
259
|
+
sources?: {
|
|
260
|
+
displayName?: string;
|
|
261
|
+
subtitle?: string;
|
|
262
|
+
url?: string;
|
|
263
|
+
}[];
|
|
264
|
+
}[];
|
|
265
|
+
/** AunuBaileys: rich response — prebuilt submessages */
|
|
266
|
+
richResponse?: any[];
|
|
267
|
+
headerText?: string;
|
|
268
|
+
contentText?: string;
|
|
269
|
+
footerText?: string;
|
|
270
|
+
disclaimerText?: string;
|
|
271
|
+
noHeading?: boolean;
|
|
245
272
|
};
|
|
246
273
|
export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
|
|
247
274
|
type MinimalRelayOptions = {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export var CodeHighlightType;
|
|
2
|
+
(function (CodeHighlightType) {
|
|
3
|
+
CodeHighlightType[CodeHighlightType["DEFAULT"] = 0] = "DEFAULT";
|
|
4
|
+
CodeHighlightType[CodeHighlightType["KEYWORD"] = 1] = "KEYWORD";
|
|
5
|
+
CodeHighlightType[CodeHighlightType["METHOD"] = 2] = "METHOD";
|
|
6
|
+
CodeHighlightType[CodeHighlightType["STRING"] = 3] = "STRING";
|
|
7
|
+
CodeHighlightType[CodeHighlightType["NUMBER"] = 4] = "NUMBER";
|
|
8
|
+
CodeHighlightType[CodeHighlightType["COMMENT"] = 5] = "COMMENT";
|
|
9
|
+
})(CodeHighlightType || (CodeHighlightType = {}));
|
|
10
|
+
export var RichSubMessageType;
|
|
11
|
+
(function (RichSubMessageType) {
|
|
12
|
+
RichSubMessageType[RichSubMessageType["UNKNOWN"] = 0] = "UNKNOWN";
|
|
13
|
+
RichSubMessageType[RichSubMessageType["GRID_IMAGE"] = 1] = "GRID_IMAGE";
|
|
14
|
+
RichSubMessageType[RichSubMessageType["TEXT"] = 2] = "TEXT";
|
|
15
|
+
RichSubMessageType[RichSubMessageType["INLINE_IMAGE"] = 3] = "INLINE_IMAGE";
|
|
16
|
+
RichSubMessageType[RichSubMessageType["TABLE"] = 4] = "TABLE";
|
|
17
|
+
RichSubMessageType[RichSubMessageType["CODE"] = 5] = "CODE";
|
|
18
|
+
RichSubMessageType[RichSubMessageType["DYNAMIC"] = 6] = "DYNAMIC";
|
|
19
|
+
RichSubMessageType[RichSubMessageType["MAP"] = 7] = "MAP";
|
|
20
|
+
RichSubMessageType[RichSubMessageType["LATEX"] = 8] = "LATEX";
|
|
21
|
+
RichSubMessageType[RichSubMessageType["CONTENT_ITEMS"] = 9] = "CONTENT_ITEMS";
|
|
22
|
+
})(RichSubMessageType || (RichSubMessageType = {}));
|
package/lib/Utils/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './generics.js';
|
|
|
2
2
|
export * from './decode-wa-message.js';
|
|
3
3
|
export * from './messages.js';
|
|
4
4
|
export * from './messages-media.js';
|
|
5
|
+
export * from './rich-message-utils.js';
|
|
5
6
|
export * from './validate-connection.js';
|
|
6
7
|
export * from './crypto.js';
|
|
7
8
|
export * from './signal.js';
|
package/lib/Utils/messages.js
CHANGED
|
@@ -10,6 +10,7 @@ import { WAMessageStatus, WAProto } from '../Types/index.js';
|
|
|
10
10
|
import { isJidGroup, isJidNewsletter, isJidStatusBroadcast, jidNormalizedUser } from '../WABinary/index.js';
|
|
11
11
|
import { sha256 } from './crypto.js';
|
|
12
12
|
import { generateMessageIDV2, getKeyAuthor, unixTimestampSeconds } from './generics.js';
|
|
13
|
+
import { prepareRichResponseMessage } from './rich-message-utils.js';
|
|
13
14
|
import { downloadContentFromMessage, encryptedStream, generateThumbnail, getAudioDuration, getAudioWaveform, getRawMediaUploadData, getImageProcessingLibrary, getStream, toBuffer } from './messages-media.js';
|
|
14
15
|
const MIMETYPE_MAP = {
|
|
15
16
|
image: 'image/jpeg',
|
|
@@ -460,7 +461,11 @@ async function prepareStickerPackMessage(stickerPack, options) {
|
|
|
460
461
|
export const generateWAMessageContent = async (message, options) => {
|
|
461
462
|
var _a, _b;
|
|
462
463
|
let m = {};
|
|
463
|
-
|
|
464
|
+
// AunuBaileys: rich response — blok kode / tabel / tautan (dari @itsliaaa/baileys)
|
|
465
|
+
if ('code' in message || 'links' in message || 'table' in message || 'richResponse' in message) {
|
|
466
|
+
m = prepareRichResponseMessage(message);
|
|
467
|
+
}
|
|
468
|
+
else if ('text' in message) {
|
|
464
469
|
const extContent = { text: message.text };
|
|
465
470
|
let urlInfo = message.linkPreview;
|
|
466
471
|
if (typeof urlInfo === 'undefined') {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { proto } from '../../WAProto/index.js';
|
|
2
|
+
export declare const tokenizeCode: (code: string, language?: string) => {
|
|
3
|
+
highlightType: number;
|
|
4
|
+
codeContent: string;
|
|
5
|
+
}[];
|
|
6
|
+
export declare const toUnified: (submessages: any[], uuid?: string) => any;
|
|
7
|
+
export declare const prepareRichResponseMessage: (content: any) => any;
|
|
8
|
+
export declare const wrapToBotForwardedMessage: (richResponseMessage: proto.AIRichResponseMessage) => any;
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AunuBaileys: dukungan tabel & blok kode lewat richResponseMessage
|
|
3
|
+
* (dibungkus botForwardedMessage). Diadaptasi dari @itsliaaa/baileys —
|
|
4
|
+
* kredit untuk pembuat asli dipertahankan sesuai catatan mereka.
|
|
5
|
+
* Deviasi AunuBaileys: fallback link donasi sumber TIDAK ikut dibawa;
|
|
6
|
+
* tautan tanpa url dilewati, label kosong tetap kosong.
|
|
7
|
+
*/
|
|
8
|
+
import { randomUUID } from 'node:crypto';
|
|
9
|
+
import { LEXER_REGEX, TEXT_ENCODER } from '../Defaults/index.js';
|
|
10
|
+
import { LANGUAGE_KEYWORDS } from '../WABinary/constants.js';
|
|
11
|
+
import { CodeHighlightType, RichSubMessageType } from '../Types/RichType.js';
|
|
12
|
+
import { proto } from '../../WAProto/index.js';
|
|
13
|
+
import { unixTimestampSeconds } from './generics.js';
|
|
14
|
+
const NOOP = new Set([]);
|
|
15
|
+
export const tokenizeCode = (code, language = 'javascript') => {
|
|
16
|
+
const keywords = LANGUAGE_KEYWORDS[language] || NOOP;
|
|
17
|
+
const blocks = [];
|
|
18
|
+
LEXER_REGEX.lastIndex = 0;
|
|
19
|
+
let match;
|
|
20
|
+
while ((match = LEXER_REGEX.exec(code)) !== null) {
|
|
21
|
+
if (match[1]) {
|
|
22
|
+
blocks.push({ highlightType: CodeHighlightType.COMMENT, codeContent: match[1] });
|
|
23
|
+
}
|
|
24
|
+
else if (match[2]) {
|
|
25
|
+
blocks.push({ highlightType: CodeHighlightType.STRING, codeContent: match[2] });
|
|
26
|
+
}
|
|
27
|
+
else if (match[3]) {
|
|
28
|
+
blocks.push({
|
|
29
|
+
highlightType: keywords.has(match[3]) ? CodeHighlightType.KEYWORD : CodeHighlightType.METHOD,
|
|
30
|
+
codeContent: match[3],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else if (match[4]) {
|
|
34
|
+
blocks.push({
|
|
35
|
+
highlightType: keywords.has(match[4]) ? CodeHighlightType.KEYWORD : CodeHighlightType.DEFAULT,
|
|
36
|
+
codeContent: match[4],
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else if (match[5]) {
|
|
40
|
+
blocks.push({ highlightType: CodeHighlightType.NUMBER, codeContent: match[5] });
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
blocks.push({ highlightType: CodeHighlightType.DEFAULT, codeContent: match[6] });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return blocks;
|
|
47
|
+
};
|
|
48
|
+
// Lia@Changes 09-04-26 --- Inject buffer into unifiedResponse.data to support proper rendering of rich messages (ex: tables and code blocks)
|
|
49
|
+
export const toUnified = (submessages, uuid) => ({
|
|
50
|
+
response_id: uuid || randomUUID(),
|
|
51
|
+
sections: submessages.map((submessage, index) => {
|
|
52
|
+
switch (submessage.messageType) {
|
|
53
|
+
case RichSubMessageType.CODE:
|
|
54
|
+
const codeMetadata = submessage.codeMetadata;
|
|
55
|
+
return {
|
|
56
|
+
view_model: {
|
|
57
|
+
primitive: {
|
|
58
|
+
language: codeMetadata.codeLanguage,
|
|
59
|
+
code_blocks: codeMetadata.codeBlocks.map((block) => ({ content: block.codeContent, type: CodeHighlightType[block.highlightType] })),
|
|
60
|
+
__typename: 'GenAICodeUXPrimitive'
|
|
61
|
+
},
|
|
62
|
+
__typename: 'GenAISingleLayoutViewModel'
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
case RichSubMessageType.CONTENT_ITEMS:
|
|
66
|
+
return {};
|
|
67
|
+
case RichSubMessageType.INLINE_IMAGE:
|
|
68
|
+
return {};
|
|
69
|
+
case RichSubMessageType.LATEX:
|
|
70
|
+
return {};
|
|
71
|
+
case RichSubMessageType.TABLE:
|
|
72
|
+
const tableMetadata = submessage.tableMetadata;
|
|
73
|
+
return {
|
|
74
|
+
view_model: {
|
|
75
|
+
primitive: {
|
|
76
|
+
title: tableMetadata.title,
|
|
77
|
+
rows: tableMetadata.rows.map((row) => ({
|
|
78
|
+
is_header: row.isHeading,
|
|
79
|
+
cells: row.items,
|
|
80
|
+
markdown_cells: row.items.map((item) => ({ text: item }))
|
|
81
|
+
})),
|
|
82
|
+
__typename: 'GenATableUXPrimitive'
|
|
83
|
+
},
|
|
84
|
+
__typename: 'GenAISingleLayoutViewModel'
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
case RichSubMessageType.TEXT:
|
|
88
|
+
return {
|
|
89
|
+
view_model: {
|
|
90
|
+
primitive: {
|
|
91
|
+
text: submessage.messageText,
|
|
92
|
+
inline_entities: submessage.inlineEntities || [],
|
|
93
|
+
__typename: 'GenAIMarkdownTextUXPrimitive'
|
|
94
|
+
},
|
|
95
|
+
__typename: 'GenAISingleLayoutViewModel'
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return submessage;
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
export const prepareRichResponseMessage = (content) => {
|
|
103
|
+
let { alignment, code, contentText, disclaimerText, footerText, headerText, imageText, inlineImage, inlineVideo, items, language, latex, links, noHeading, posts, products, suggested, richResponse, table, tapLinkUrl, title } = content;
|
|
104
|
+
let submessages = [];
|
|
105
|
+
if (Array.isArray(richResponse)) {
|
|
106
|
+
submessages = richResponse.map((submessage) => {
|
|
107
|
+
if (submessage.text) {
|
|
108
|
+
return {
|
|
109
|
+
messageType: RichSubMessageType.TEXT,
|
|
110
|
+
messageText: submessage.text,
|
|
111
|
+
inlineEntities: submessage.inlineEntities
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
else if (submessage.code) {
|
|
115
|
+
return {
|
|
116
|
+
messageType: RichSubMessageType.CODE,
|
|
117
|
+
codeMetadata: {
|
|
118
|
+
codeLanguage: submessage.language,
|
|
119
|
+
codeBlocks: submessage.code
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
else if (submessage.items) {
|
|
124
|
+
return {
|
|
125
|
+
messageType: RichSubMessageType.CONTENT_ITEMS,
|
|
126
|
+
contentItemsMetadata: {
|
|
127
|
+
itemsMetadata: submessage.items,
|
|
128
|
+
contentType: proto.AIRichResponseMessage.AIRichResponseContentItemsMetadata.ContentType.CAROUSEL
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
else if (submessage.inlineImage) {
|
|
133
|
+
return {
|
|
134
|
+
messageType: RichSubMessageType.INLINE_IMAGE,
|
|
135
|
+
imageMetadata: {
|
|
136
|
+
imageUrl: submessage.inlineImage,
|
|
137
|
+
imageText: submessage.imageText,
|
|
138
|
+
alignment: submessage.alignment,
|
|
139
|
+
tapLinkUrl: submessage.tapLinkUrl
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
else if (submessage.inlineVideo) {
|
|
144
|
+
return {
|
|
145
|
+
messageType: RichSubMessageType.TEXT,
|
|
146
|
+
messageText: 'INLINE_VIDEO'
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
else if (submessage.latex) {
|
|
150
|
+
return {
|
|
151
|
+
messageType: RichSubMessageType.LATEX,
|
|
152
|
+
latexMetadata: {
|
|
153
|
+
text: submessage.text,
|
|
154
|
+
expressions: submessage.latex
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
else if (submessage.posts) {
|
|
159
|
+
return {
|
|
160
|
+
messageType: RichSubMessageType.TEXT,
|
|
161
|
+
messageText: 'POSTS'
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
else if (submessage.products) {
|
|
165
|
+
return {
|
|
166
|
+
messageType: RichSubMessageType.TEXT,
|
|
167
|
+
messageText: 'PRODUCTS'
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
else if (submessage.suggested) {
|
|
171
|
+
return {
|
|
172
|
+
messageType: RichSubMessageType.TEXT,
|
|
173
|
+
messageText: 'SUGGESTED_PROMPT'
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
else if (submessage.table) {
|
|
177
|
+
return {
|
|
178
|
+
messageType: RichSubMessageType.TABLE,
|
|
179
|
+
tableMetadata: {
|
|
180
|
+
title: submessage.title,
|
|
181
|
+
rows: submessage.table
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return submessage;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
if (headerText) {
|
|
190
|
+
submessages.push({
|
|
191
|
+
messageType: RichSubMessageType.TEXT,
|
|
192
|
+
messageText: headerText
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
if (contentText) {
|
|
196
|
+
submessages.push({
|
|
197
|
+
messageType: RichSubMessageType.TEXT,
|
|
198
|
+
messageText: contentText
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (code) {
|
|
202
|
+
language || (language = 'javascript');
|
|
203
|
+
submessages.push({
|
|
204
|
+
messageType: RichSubMessageType.CODE,
|
|
205
|
+
codeMetadata: {
|
|
206
|
+
codeLanguage: language,
|
|
207
|
+
codeBlocks: tokenizeCode(code, language)
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if (items) {
|
|
212
|
+
submessages.push({
|
|
213
|
+
messageType: RichSubMessageType.CONTENT_ITEMS,
|
|
214
|
+
contentItemsMetadata: {
|
|
215
|
+
itemsMetadata: items,
|
|
216
|
+
contentType: proto.AIRichResponseMessage.AIRichResponseContentItemsMetadata.ContentType.CAROUSEL
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (inlineImage) {
|
|
221
|
+
submessages.push({
|
|
222
|
+
messageType: RichSubMessageType.INLINE_IMAGE,
|
|
223
|
+
imageMetadata: {
|
|
224
|
+
imageUrl: inlineImage,
|
|
225
|
+
imageText,
|
|
226
|
+
alignment,
|
|
227
|
+
tapLinkUrl
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (inlineVideo) {
|
|
232
|
+
submessages.push({
|
|
233
|
+
messageType: RichSubMessageType.TEXT,
|
|
234
|
+
messageText: 'INLINE_VIDEO'
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
if (latex) {
|
|
238
|
+
submessages.push({
|
|
239
|
+
messageType: RichSubMessageType.LATEX,
|
|
240
|
+
latexMetadata: {
|
|
241
|
+
text,
|
|
242
|
+
expressions: latex
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
if (links) {
|
|
247
|
+
links.forEach((linkField, index) => {
|
|
248
|
+
const prefix = 'SS_' + index;
|
|
249
|
+
if (!linkField.url) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const url = linkField.url;
|
|
253
|
+
const sources = linkField.sources?.map((sourceField) => ({
|
|
254
|
+
source_type: 'THIRD_PARTY',
|
|
255
|
+
source_display_name: sourceField.displayName || '',
|
|
256
|
+
source_subtitle: sourceField.subtitle || '',
|
|
257
|
+
source_url: sourceField.url || url
|
|
258
|
+
}));
|
|
259
|
+
submessages.push({
|
|
260
|
+
messageType: RichSubMessageType.TEXT,
|
|
261
|
+
messageText: linkField.text + ` {{${prefix}}}¹{{/${prefix}}} `,
|
|
262
|
+
inlineEntities: [{
|
|
263
|
+
key: prefix,
|
|
264
|
+
metadata: {
|
|
265
|
+
reference_id: index + 1,
|
|
266
|
+
reference_url: url,
|
|
267
|
+
reference_title: linkField.title || '',
|
|
268
|
+
reference_display_name: linkField.displayName || '',
|
|
269
|
+
sources: sources || [],
|
|
270
|
+
__typename: 'GenAISearchCitationItem'
|
|
271
|
+
}
|
|
272
|
+
}]
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
if (posts) {
|
|
277
|
+
submessages.push({
|
|
278
|
+
messageType: RichSubMessageType.TEXT,
|
|
279
|
+
messageText: 'POSTS'
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
if (products) {
|
|
283
|
+
submessages.push({
|
|
284
|
+
messageType: RichSubMessageType.TEXT,
|
|
285
|
+
messageText: 'PRODUCTS'
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
if (suggested) {
|
|
289
|
+
submessages.push({
|
|
290
|
+
messageType: RichSubMessageType.TEXT,
|
|
291
|
+
messageText: 'SUGGESTED_PROMPT'
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
if (table) {
|
|
295
|
+
submessages.push({
|
|
296
|
+
messageType: RichSubMessageType.TABLE,
|
|
297
|
+
tableMetadata: {
|
|
298
|
+
title,
|
|
299
|
+
rows: table.map((items, index) => ({
|
|
300
|
+
isHeading: !noHeading && index == 0,
|
|
301
|
+
items
|
|
302
|
+
}))
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
if (footerText) {
|
|
307
|
+
submessages.push({
|
|
308
|
+
messageType: RichSubMessageType.TEXT,
|
|
309
|
+
messageText: footerText
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const uuid = randomUUID();
|
|
314
|
+
const unified = toUnified(submessages, uuid);
|
|
315
|
+
const richResponseMessage = proto.AIRichResponseMessage.create({
|
|
316
|
+
submessages,
|
|
317
|
+
messageType: proto.AIRichResponseMessage.AIRichResponseMessageType.AI_RICH_RESPONSE_TYPE_STANDARD,
|
|
318
|
+
unifiedResponse: {
|
|
319
|
+
data: TEXT_ENCODER.encode(JSON.stringify(unified)) // Lia@Note 25-04-26 --- Expects "ArrayBufferLike"
|
|
320
|
+
},
|
|
321
|
+
contextInfo: {
|
|
322
|
+
isForwarded: true,
|
|
323
|
+
forwardingScore: 1,
|
|
324
|
+
forwardedAiBotMessageInfo: { botJid: '867051314767696@bot' },
|
|
325
|
+
forwardOrigin: 4
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
// AunuBaileys: disclaimerText/botResponseId sumber menempel di botMetadata,
|
|
329
|
+
// yang tidak terwakili di proto 6.7.24 — keduanya tidak dibuat di sini.
|
|
330
|
+
void disclaimerText;
|
|
331
|
+
return wrapToBotForwardedMessage(richResponseMessage);
|
|
332
|
+
};
|
|
333
|
+
// AunuBaileys: proto 6.7.24 TIDAK punya field botForwardedMessage maupun
|
|
334
|
+
// BotMetadata.verificationMetadata/botResponseId — rich response di basis ini
|
|
335
|
+
// dikirim sebagai field richResponseMessage langsung pada Message (bentuk yang
|
|
336
|
+
// sama dengan cabang aiRich yang sudah ada), jadi pembungkusnya menyesuaikan.
|
|
337
|
+
export const wrapToBotForwardedMessage = (richResponseMessage) => ({
|
|
338
|
+
richResponseMessage
|
|
339
|
+
});
|
|
@@ -25,4 +25,43 @@ export declare const TOKEN_MAP: {
|
|
|
25
25
|
index: number;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
+
export const CPP_KEYWORDS: Set<string>;
|
|
29
|
+
export const CSS_KEYWORDS: Set<string>;
|
|
30
|
+
export const GO_KEYWORDS: Set<string>;
|
|
31
|
+
export const HTML_KEYWORDS: Set<string>;
|
|
32
|
+
export const JS_KEYWORDS: Set<string>;
|
|
33
|
+
export const PYTHON_KEYWORDS: Set<string>;
|
|
34
|
+
export const RUST_KEYWORDS: Set<string>;
|
|
35
|
+
export const C_KEYWORDS: Set<string>;
|
|
36
|
+
export const CSHARP_KEYWORDS: Set<string>;
|
|
37
|
+
export const BASH_KEYWORDS: Set<string>;
|
|
38
|
+
export const CMD_KEYWORDS: Set<string>;
|
|
39
|
+
export const POWERSHELL_KEYWORDS: Set<string>;
|
|
40
|
+
export const LANGUAGE_KEYWORDS: {
|
|
41
|
+
css: Set<string>;
|
|
42
|
+
html: Set<string>;
|
|
43
|
+
javascript: Set<string>;
|
|
44
|
+
typescript: Set<string>;
|
|
45
|
+
js: Set<string>;
|
|
46
|
+
ts: Set<string>;
|
|
47
|
+
python: Set<string>;
|
|
48
|
+
py: Set<string>;
|
|
49
|
+
go: Set<string>;
|
|
50
|
+
golang: Set<string>;
|
|
51
|
+
cpp: Set<string>;
|
|
52
|
+
'c++': Set<string>;
|
|
53
|
+
rust: Set<string>;
|
|
54
|
+
rs: Set<string>;
|
|
55
|
+
c: Set<string>;
|
|
56
|
+
h: Set<string>;
|
|
57
|
+
csharp: Set<string>;
|
|
58
|
+
cs: Set<string>;
|
|
59
|
+
bash: Set<string>;
|
|
60
|
+
sh: Set<string>;
|
|
61
|
+
zsh: Set<string>;
|
|
62
|
+
cmd: Set<string>;
|
|
63
|
+
bat: Set<string>;
|
|
64
|
+
powershell: Set<string>;
|
|
65
|
+
ps1: Set<string>;
|
|
66
|
+
};
|
|
28
67
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1298,4 +1298,172 @@ for (const [i, DOUBLE_BYTE_TOKEN] of DOUBLE_BYTE_TOKENS.entries()) {
|
|
|
1298
1298
|
TOKEN_MAP[element] = { dict: i, index: j };
|
|
1299
1299
|
}
|
|
1300
1300
|
}
|
|
1301
|
+
// AunuBaileys: tabel kata kunci untuk pewarnaan kode rich response (dari @itsliaaa/baileys)
|
|
1302
|
+
export const CPP_KEYWORDS = new Set([
|
|
1303
|
+
'alignas', 'alignof', 'and', 'and_eq', 'asm', 'auto', 'bitand', 'bitor', 'bool', 'break', 'case',
|
|
1304
|
+
'catch', 'char', 'class', 'compl', 'concept', 'const', 'consteval', 'constexpr', 'constinit',
|
|
1305
|
+
'const_cast', 'continue', 'co_await', 'co_return', 'co_yield', 'decltype', 'default', 'delete',
|
|
1306
|
+
'do', 'double', 'dynamic_cast', 'else', 'enum', 'explicit', 'export', 'extern', 'false', 'float',
|
|
1307
|
+
'for', 'friend', 'goto', 'if', 'inline', 'int', 'long', 'mutable', 'namespace', 'new', 'noexcept',
|
|
1308
|
+
'not', 'not_eq', 'nullptr', 'operator', 'or', 'or_eq', 'private', 'protected', 'public', 'register',
|
|
1309
|
+
'reinterpret_cast', 'requires', 'return', 'short', 'signed', 'sizeof', 'static', 'static_assert',
|
|
1310
|
+
'static_cast', 'struct', 'switch', 'template', 'this', 'thread_local', 'throw', 'true', 'try',
|
|
1311
|
+
'typedef', 'typeid', 'typename', 'union', 'unsigned', 'using', 'virtual', 'void', 'volatile',
|
|
1312
|
+
'wchar_t', 'while', 'xor', 'xor_eq'
|
|
1313
|
+
]);
|
|
1314
|
+
export const CSS_KEYWORDS = new Set([
|
|
1315
|
+
'import', 'media', 'font-face', 'keyframes', 'supports', 'charset',
|
|
1316
|
+
'important', 'root', 'hover', 'active', 'focus', 'visited', 'before', 'after',
|
|
1317
|
+
'not', 'nth-child', 'first-child', 'last-child', 'only-child',
|
|
1318
|
+
'none', 'inherit', 'initial', 'unset', 'auto', 'transparent', 'currentcolor'
|
|
1319
|
+
]);
|
|
1320
|
+
export const GO_KEYWORDS = new Set([
|
|
1321
|
+
'break', 'default', 'func', 'interface', 'select', 'case', 'defer', 'go', 'map', 'struct',
|
|
1322
|
+
'chan', 'else', 'goto', 'package', 'switch', 'const', 'fallthrough', 'if', 'range', 'type',
|
|
1323
|
+
'continue', 'for', 'import', 'return', 'var', 'true', 'false', 'nil'
|
|
1324
|
+
]);
|
|
1325
|
+
export const HTML_KEYWORDS = new Set([
|
|
1326
|
+
'html', 'head', 'body', 'title', 'meta', 'link', 'script', 'style',
|
|
1327
|
+
'header', 'footer', 'main', 'section', 'article', 'aside', 'nav',
|
|
1328
|
+
'div', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'a', 'img',
|
|
1329
|
+
'ul', 'ol', 'li', 'table', 'tr', 'td', 'th', 'thead', 'tbody',
|
|
1330
|
+
'form', 'input', 'button', 'select', 'textarea', 'label', 'option',
|
|
1331
|
+
'canvas', 'svg', 'iframe', 'video', 'audio', 'source'
|
|
1332
|
+
]);
|
|
1333
|
+
export const JS_KEYWORDS = new Set([
|
|
1334
|
+
'import', 'export', 'from', 'default', 'as',
|
|
1335
|
+
'const', 'let', 'var', 'function', 'class', 'extends', 'new',
|
|
1336
|
+
'return', 'if', 'else', 'for', 'while', 'do', 'switch', 'case', 'break', 'continue',
|
|
1337
|
+
'try', 'catch', 'finally', 'throw',
|
|
1338
|
+
'async', 'await', 'yield',
|
|
1339
|
+
'typeof', 'instanceof', 'in', 'of', 'delete', 'void',
|
|
1340
|
+
'true', 'false', 'null', 'undefined', 'NaN', 'Infinity',
|
|
1341
|
+
'this', 'super', 'static', 'get', 'set',
|
|
1342
|
+
'debugger', 'with'
|
|
1343
|
+
]);
|
|
1344
|
+
export const PYTHON_KEYWORDS = new Set([
|
|
1345
|
+
'import', 'from', 'as', 'def', 'class', 'return', 'if', 'elif', 'else',
|
|
1346
|
+
'for', 'while', 'break', 'continue', 'try', 'except', 'finally', 'raise',
|
|
1347
|
+
'with', 'yield', 'lambda', 'pass', 'del', 'global', 'nonlocal', 'assert',
|
|
1348
|
+
'True', 'False', 'None', 'and', 'or', 'not', 'in', 'is', 'async', 'await',
|
|
1349
|
+
'self', 'print'
|
|
1350
|
+
]);
|
|
1351
|
+
export const RUST_KEYWORDS = new Set([
|
|
1352
|
+
'as', 'break', 'const', 'continue', 'crate', 'else', 'enum', 'extern',
|
|
1353
|
+
'false', 'fn', 'for', 'if', 'impl', 'in', 'let', 'loop', 'match',
|
|
1354
|
+
'mod', 'move', 'mut', 'pub', 'ref', 'return', 'self', 'Self',
|
|
1355
|
+
'static', 'struct', 'super', 'trait', 'true', 'type', 'unsafe',
|
|
1356
|
+
'use', 'where', 'while', 'async', 'await', 'dyn',
|
|
1357
|
+
'abstract', 'become', 'box', 'do', 'final', 'macro',
|
|
1358
|
+
'override', 'priv', 'typeof', 'unsized', 'virtual', 'yield',
|
|
1359
|
+
'try'
|
|
1360
|
+
]);
|
|
1361
|
+
export const C_KEYWORDS = new Set([
|
|
1362
|
+
'auto', 'break', 'case', 'char', 'const', 'continue',
|
|
1363
|
+
'default', 'do', 'double', 'else', 'enum', 'extern',
|
|
1364
|
+
'float', 'for', 'goto', 'if', 'inline', 'int',
|
|
1365
|
+
'long', 'register', 'restrict', 'return', 'short',
|
|
1366
|
+
'signed', 'sizeof', 'static', 'struct', 'switch',
|
|
1367
|
+
'typedef', 'union', 'unsigned', 'void', 'volatile',
|
|
1368
|
+
'while',
|
|
1369
|
+
'_Alignas', '_Alignof', '_Atomic', '_Bool',
|
|
1370
|
+
'_Complex', '_Generic', '_Imaginary',
|
|
1371
|
+
'_Noreturn', '_Static_assert', '_Thread_local'
|
|
1372
|
+
]);
|
|
1373
|
+
export const CSHARP_KEYWORDS = new Set([
|
|
1374
|
+
'abstract', 'as', 'base', 'bool', 'break', 'byte',
|
|
1375
|
+
'case', 'catch', 'char', 'checked', 'class',
|
|
1376
|
+
'const', 'continue', 'decimal', 'default',
|
|
1377
|
+
'delegate', 'do', 'double', 'else', 'enum',
|
|
1378
|
+
'event', 'explicit', 'extern', 'false', 'finally',
|
|
1379
|
+
'fixed', 'float', 'for', 'foreach', 'goto',
|
|
1380
|
+
'if', 'implicit', 'in', 'int', 'interface',
|
|
1381
|
+
'internal', 'is', 'lock', 'long', 'namespace',
|
|
1382
|
+
'new', 'null', 'object', 'operator', 'out',
|
|
1383
|
+
'override', 'params', 'private', 'protected',
|
|
1384
|
+
'public', 'readonly', 'ref', 'return', 'sbyte',
|
|
1385
|
+
'sealed', 'short', 'sizeof', 'stackalloc',
|
|
1386
|
+
'static', 'string', 'struct', 'switch',
|
|
1387
|
+
'this', 'throw', 'true', 'try', 'typeof',
|
|
1388
|
+
'uint', 'ulong', 'unchecked', 'unsafe',
|
|
1389
|
+
'ushort', 'using', 'virtual', 'void',
|
|
1390
|
+
'volatile', 'while',
|
|
1391
|
+
'async', 'await', 'record', 'init',
|
|
1392
|
+
'required', 'file', 'global', 'nameof',
|
|
1393
|
+
'var', 'dynamic', 'partial', 'yield',
|
|
1394
|
+
'from', 'where', 'select', 'group',
|
|
1395
|
+
'orderby', 'join', 'let', 'into',
|
|
1396
|
+
'equals', 'by', 'ascending', 'descending'
|
|
1397
|
+
]);
|
|
1398
|
+
export const BASH_KEYWORDS = new Set([
|
|
1399
|
+
'if', 'then', 'else', 'elif', 'fi',
|
|
1400
|
+
'case', 'esac', 'for', 'while',
|
|
1401
|
+
'until', 'do', 'done', 'in',
|
|
1402
|
+
'function', 'select', 'time',
|
|
1403
|
+
'coproc',
|
|
1404
|
+
'echo', 'printf', 'read', 'cd',
|
|
1405
|
+
'pwd', 'exit', 'export', 'unset',
|
|
1406
|
+
'alias', 'unalias', 'source',
|
|
1407
|
+
'exec', 'eval', 'test', 'shift',
|
|
1408
|
+
'trap', 'wait', 'jobs', 'kill',
|
|
1409
|
+
'bg', 'fg', 'history', 'type',
|
|
1410
|
+
'ulimit', 'umask', 'set',
|
|
1411
|
+
'true', 'false'
|
|
1412
|
+
]);
|
|
1413
|
+
export const CMD_KEYWORDS = new Set([
|
|
1414
|
+
'echo', 'set', 'if', 'else',
|
|
1415
|
+
'for', 'in', 'do', 'goto',
|
|
1416
|
+
'call', 'exit', 'shift',
|
|
1417
|
+
'pause', 'start', 'title',
|
|
1418
|
+
'cls', 'rem',
|
|
1419
|
+
'dir', 'copy', 'move', 'del',
|
|
1420
|
+
'mkdir', 'rmdir', 'type',
|
|
1421
|
+
'ren', 'tasklist', 'taskkill',
|
|
1422
|
+
'ping', 'ipconfig', 'netstat',
|
|
1423
|
+
'shutdown'
|
|
1424
|
+
]);
|
|
1425
|
+
export const POWERSHELL_KEYWORDS = new Set([
|
|
1426
|
+
'function', 'filter', 'param',
|
|
1427
|
+
'begin', 'process', 'end',
|
|
1428
|
+
'if', 'else', 'elseif',
|
|
1429
|
+
'switch', 'foreach', 'for',
|
|
1430
|
+
'while', 'do', 'until',
|
|
1431
|
+
'break', 'continue', 'return',
|
|
1432
|
+
'throw', 'trap', 'try',
|
|
1433
|
+
'catch', 'finally',
|
|
1434
|
+
'$true', '$false', '$null',
|
|
1435
|
+
'Write-Host', 'Write-Output',
|
|
1436
|
+
'Get-Item', 'Set-Item',
|
|
1437
|
+
'Get-ChildItem', 'Remove-Item',
|
|
1438
|
+
'Copy-Item', 'Move-Item',
|
|
1439
|
+
'Test-Path', 'Invoke-Command'
|
|
1440
|
+
]);
|
|
1441
|
+
export const LANGUAGE_KEYWORDS = {
|
|
1442
|
+
css: CSS_KEYWORDS,
|
|
1443
|
+
html: HTML_KEYWORDS,
|
|
1444
|
+
javascript: JS_KEYWORDS,
|
|
1445
|
+
typescript: JS_KEYWORDS,
|
|
1446
|
+
js: JS_KEYWORDS,
|
|
1447
|
+
ts: JS_KEYWORDS,
|
|
1448
|
+
python: PYTHON_KEYWORDS,
|
|
1449
|
+
py: PYTHON_KEYWORDS,
|
|
1450
|
+
go: GO_KEYWORDS,
|
|
1451
|
+
golang: GO_KEYWORDS,
|
|
1452
|
+
cpp: CPP_KEYWORDS,
|
|
1453
|
+
'c++': CPP_KEYWORDS,
|
|
1454
|
+
rust: RUST_KEYWORDS,
|
|
1455
|
+
rs: RUST_KEYWORDS,
|
|
1456
|
+
c: C_KEYWORDS,
|
|
1457
|
+
h: C_KEYWORDS,
|
|
1458
|
+
csharp: CSHARP_KEYWORDS,
|
|
1459
|
+
cs: CSHARP_KEYWORDS,
|
|
1460
|
+
bash: BASH_KEYWORDS,
|
|
1461
|
+
sh: BASH_KEYWORDS,
|
|
1462
|
+
zsh: BASH_KEYWORDS,
|
|
1463
|
+
cmd: CMD_KEYWORDS,
|
|
1464
|
+
bat: CMD_KEYWORDS,
|
|
1465
|
+
powershell: POWERSHELL_KEYWORDS,
|
|
1466
|
+
ps1: POWERSHELL_KEYWORDS
|
|
1467
|
+
};
|
|
1468
|
+
|
|
1301
1469
|
//# sourceMappingURL=constants.js.map
|
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.42",
|
|
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",
|