@pontalabs/baileys 1.1.8 → 1.1.10
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 +117 -0
- package/lib/Socket/messages-send.js +10 -0
- package/lib/Utils/index.d.ts +1 -0
- package/lib/Utils/index.js +1 -0
- package/lib/Utils/mbuilder.d.ts +55 -0
- package/lib/Utils/mbuilder.js +3211 -0
- package/lib/Utils/messages.js +4 -0
- package/lib/Utils/rich-message-utils.d.ts +2 -1
- package/lib/Utils/rich-message-utils.js +52 -0
- package/package.json +4 -2
package/lib/Utils/messages.js
CHANGED
|
@@ -591,6 +591,10 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
591
591
|
hasNonNullishProperty(message, 'richPost') ||
|
|
592
592
|
hasNonNullishProperty(message, 'tip') ||
|
|
593
593
|
hasNonNullishProperty(message, 'suggest') ||
|
|
594
|
+
hasNonNullishProperty(message, 'widget') ||
|
|
595
|
+
hasNonNullishProperty(message, 'footerAction') ||
|
|
596
|
+
hasNonNullishProperty(message, 'metadata') ||
|
|
597
|
+
hasNonNullishProperty(message, 'foaText') ||
|
|
594
598
|
hasNonNullishProperty(message, 'contentText')) {
|
|
595
599
|
m = prepareRichResponseMessage(message);
|
|
596
600
|
}
|
|
@@ -770,6 +770,27 @@ const makeSuggestSection = (suggestion) => {
|
|
|
770
770
|
};
|
|
771
771
|
};
|
|
772
772
|
|
|
773
|
+
/** Rich AI primitives tambahan dari builder 4.7. */
|
|
774
|
+
const makeMetadataSub = (text, typename = 'GenAIMetadataTextPrimitive', prefix = '') => ({
|
|
775
|
+
sub: { messageType: RichSubMessageType.TEXT, messageText: text },
|
|
776
|
+
section: { view_model: { primitive: { text: prefix + text, __typename: typename }, __typename: 'GenAISingleLayoutViewModel' } }
|
|
777
|
+
});
|
|
778
|
+
const makeWidgetSection = (data) => {
|
|
779
|
+
const items = Array.isArray(data) ? data : [data];
|
|
780
|
+
const widgets = items.map(item => ({
|
|
781
|
+
__typename: 'GenAI3PExtWidgetPrimitive',
|
|
782
|
+
header: { __typename: 'GenAI3PExtWidgetStandardHeader', title: item?.title ?? '', ...(item?.header ?? {}) },
|
|
783
|
+
body: { __typename: 'GenAI3PExtCalendarEventList', sections: item?.sections ?? [],
|
|
784
|
+
ctas: (item?.actions ?? []).map(action => ({ __typename: 'GenAI3PExtWidgetCTA', label: action?.label ?? '', state: action?.state ?? 'PENDING', kind: action?.kind ?? 'OTHER', tool_call_id: action?.tool_call_id ?? action?.id ?? '', ...(action?.toast ? { toast: { __typename: 'GenAI3PExtWidgetToast', label: action.toast.label ?? action.label ?? '' } } : {}) })), ...(item?.body ?? {}) }
|
|
785
|
+
}));
|
|
786
|
+
return { view_model: widgets.length > 1 ? { primitives: widgets, __typename: 'GenAIHScrollLayoutViewModel' } : { primitive: widgets[0], __typename: 'GenAISingleLayoutViewModel' } };
|
|
787
|
+
};
|
|
788
|
+
const makeFooterActionSection = (data) => {
|
|
789
|
+
const items = Array.isArray(data) ? data : [data];
|
|
790
|
+
const actions = items.map(item => ({ __typename: 'GenAIFooterActionPrimitive', cta_text: item?.text ?? item?.cta_text ?? '', cta_type: item?.type ?? item?.cta_type ?? 'OPEN_URL', cta_url: item?.url ?? item?.cta_url ?? '' }));
|
|
791
|
+
return { view_model: actions.length > 1 ? { primitives: actions, __typename: 'GenAIHScrollLayoutViewModel' } : { primitive: actions[0], __typename: 'GenAISingleLayoutViewModel' } };
|
|
792
|
+
};
|
|
793
|
+
|
|
773
794
|
/** Normalize input tabel: terima array 2D biasa (native ponta) ATAU
|
|
774
795
|
* shorthand README/1.1.5-style { title?, headers?, rows }. */
|
|
775
796
|
const normalizeTableInput = (t, fallbackTitle, fallbackNoHeading) => {
|
|
@@ -804,6 +825,7 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
804
825
|
map: mapContent, latex, contentItems,
|
|
805
826
|
// sub-types baru (prefixed 'rich' agar tidak konflik dengan media biasa)
|
|
806
827
|
richImage, richVideo, reels, source, richProduct, richPost, tip, suggest,
|
|
828
|
+
richWidget, widget, richFooterAction, footerAction, richMetadata, metadata, richFOAText, foaText,
|
|
807
829
|
// opsi tambahan (belum ada di versi ponta.zip semula)
|
|
808
830
|
aiForwarded
|
|
809
831
|
} = content;
|
|
@@ -888,6 +910,10 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
888
910
|
if (sub.suggest != null) {
|
|
889
911
|
return push(null, makeSuggestSection(sub.suggest));
|
|
890
912
|
}
|
|
913
|
+
if (sub.widget != null) return push(null, makeWidgetSection(sub.widget));
|
|
914
|
+
if (sub.footerAction != null) return push(null, makeFooterActionSection(sub.footerAction));
|
|
915
|
+
if (sub.metadata != null) { const built = makeMetadataSub(sub.metadata); return push(built.sub, built.section); }
|
|
916
|
+
if (sub.foaText != null) { const built = makeMetadataSub(sub.foaText, 'FOATextPrimitive'); return push(built.sub, built.section); }
|
|
891
917
|
// passthrough — kalau sudah bentuk proto submessage manual
|
|
892
918
|
return push(sub, buildUnifiedSection(sub));
|
|
893
919
|
};
|
|
@@ -921,6 +947,10 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
921
947
|
if (contentText) buildOne({ text: contentText }); // ← setelah produk/post, tampil di bawah card
|
|
922
948
|
if (tip) buildOne({ tip });
|
|
923
949
|
if (suggest) buildOne({ suggest });
|
|
950
|
+
if (richWidget ?? widget) buildOne({ widget: richWidget ?? widget });
|
|
951
|
+
if (richFooterAction ?? footerAction) buildOne({ footerAction: richFooterAction ?? footerAction });
|
|
952
|
+
if (richMetadata ?? metadata) buildOne({ metadata: richMetadata ?? metadata });
|
|
953
|
+
if (richFOAText ?? foaText) buildOne({ foaText: richFOAText ?? foaText });
|
|
924
954
|
|
|
925
955
|
/* links — bisa dikombinasi dengan tipe lain di atas */
|
|
926
956
|
if (links && Array.isArray(links)) {
|
|
@@ -1487,6 +1517,23 @@ const mapVideoField = (data) => {
|
|
|
1487
1517
|
* jadi item internal fork ({richImage},{richVideo},{suggest}, dst). */
|
|
1488
1518
|
const translateReadmeItem = (item) => {
|
|
1489
1519
|
const out = {};
|
|
1520
|
+
// Builder aliases: build.* returns lightweight items that can be passed
|
|
1521
|
+
// directly to sendMessage({ items: [...] }).
|
|
1522
|
+
if (item.richText != null) { out.text = item.richText; }
|
|
1523
|
+
if (item.richFOAText != null) { out.foaText = item.richFOAText; }
|
|
1524
|
+
if (item.richCode != null) { out.code = item.richCode; out.language = item.language; }
|
|
1525
|
+
if (item.richTable != null) { out.table = item.richTable; }
|
|
1526
|
+
if (item.richSource != null) { out.source = item.richSource; }
|
|
1527
|
+
if (item.richReels != null) { out.reels = item.richReels; }
|
|
1528
|
+
if (item.richImage != null) { out.richImage = item.richImage; }
|
|
1529
|
+
if (item.richVideo != null) { out.richVideo = mapVideoField(item.richVideo); }
|
|
1530
|
+
if (item.richProduct != null) { out.richProduct = mapProductFields(item.richProduct); }
|
|
1531
|
+
if (item.richPost != null) { out.richPost = mapPostFields(item.richPost); }
|
|
1532
|
+
if (item.richMetadata != null) { out.metadata = item.richMetadata; }
|
|
1533
|
+
if (item.richTip != null) { out.tip = item.richTip; }
|
|
1534
|
+
if (item.richWidget != null) { out.widget = item.richWidget; }
|
|
1535
|
+
if (item.richFooterAction != null) { out.footerAction = item.richFooterAction; }
|
|
1536
|
+
if (item.richSuggest != null) { out.suggest = item.richSuggest; }
|
|
1490
1537
|
if (item.text != null) { out.text = item.text; if (item.inlineEntities) out.inlineEntities = item.inlineEntities; }
|
|
1491
1538
|
if (item.code != null) { out.code = item.code; out.language = item.language; }
|
|
1492
1539
|
if (item.table != null) {
|
|
@@ -1577,6 +1624,11 @@ export const applyReadmeRichAliases = (message) => {
|
|
|
1577
1624
|
message.tip = message.richTip;
|
|
1578
1625
|
delete message.richTip;
|
|
1579
1626
|
}
|
|
1627
|
+
// Builder 4.7 aliases; shortcut lama tidak diubah.
|
|
1628
|
+
if (message.richWidget != null && message.widget == null) { message.widget = message.richWidget; delete message.richWidget; }
|
|
1629
|
+
if (message.richFooterAction != null && message.footerAction == null) { message.footerAction = message.richFooterAction; delete message.richFooterAction; }
|
|
1630
|
+
if (message.richMetadata != null && message.metadata == null) { message.metadata = message.richMetadata; delete message.richMetadata; }
|
|
1631
|
+
if (message.richFOAText != null && message.foaText == null) { message.foaText = message.richFOAText; delete message.richFOAText; }
|
|
1580
1632
|
// richFooter -> footerText
|
|
1581
1633
|
if (message.richFooter != null && message.footerText == null) {
|
|
1582
1634
|
message.footerText = message.richFooter;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pontalabs/baileys",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.10",
|
|
5
5
|
"description": "PontaLabs Baileys is a lightweight, modern, and customizable WhatsApp Web API library built on Baileys.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"whatsapp",
|
|
@@ -53,7 +53,9 @@
|
|
|
53
53
|
"pino": "^9.6",
|
|
54
54
|
"protobufjs": "^7.5.6",
|
|
55
55
|
"whatsapp-rust-bridge": "0.5.4",
|
|
56
|
-
"ws": "^8.13.0"
|
|
56
|
+
"ws": "^8.13.0",
|
|
57
|
+
"sharp": "^0.34.3",
|
|
58
|
+
"fluent-ffmpeg": "^2.1.3"
|
|
57
59
|
},
|
|
58
60
|
"devDependencies": {
|
|
59
61
|
"@eslint/eslintrc": "^3.3.1",
|