@nuiisweety/baileys 0.1.0 โ 0.1.2
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 +679 -3
- package/README.md.bak +410 -476
- package/lib/Socket/index.js +4 -4
- package/lib/Socket/index.js.bak +6 -6
- package/lib/Types/RichType.js +1 -1
- package/lib/Types/RichType.js.bak +23 -0
- package/lib/Utils/rich-message-utils.js +545 -140
- package/lib/Utils/rich-message-utils.js.bak +246 -0
- package/lib/WABinary/constants.js +102 -0
- package/lib/WABinary/constants.js.bak +1373 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<h1 align="center"
|
|
1
|
+
<h1 align="center">โจ@nuiisweety/baileys</h1>
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
<img src="https://raw.githubusercontent.com/NuiiS4TORU/-nuisockets/refs/heads/main/nuiisweety.png" width="100%"/>
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
[Buttons](#-buttons) ยท [List Message](#-list-message) ยท [Template Buttons](#๏ธ-template-buttons) ยท [Native Flow](#-native-flow) ยท [Carousel](#-carousel)
|
|
46
46
|
|
|
47
47
|
**๐ Rich Message (AI)**
|
|
48
|
-
[Code Block](#-code-block) ยท [Links](#-links-rich) ยท [Table](#-table-rich) ยท [Rich Response (Gabungan)](#-rich-response-gabungan)
|
|
48
|
+
[Code Block](#-code-block) ยท [Links](#-links-rich) ยท [Table](#-table-rich) ยท [Grid Image](#%EF%B8%8F-grid-image-rich) ยท [Inline Image](#%EF%B8%8F-inline-image-rich) ยท [Dynamic / GIF](#-dynamic--gif-rich) ยท [Map](#%EF%B8%8F-map-rich) ยท [LaTeX](#-latex-rich) ยท [Content Items](#-content-items-rich) ยท [Rich Response (Gabungan)](#-rich-response-gabungan) ยท [Terima & Decode](#-terima--decode-rich-message) ยท [Bahasa Kode](#-bahasa-yang-didukung)
|
|
49
49
|
|
|
50
50
|
**๐ Lainnya**
|
|
51
51
|
[List Reply](#-list-reply) ยท [Sticker Pack](#-sticker-pack) ยท [External Ad Reply](#-external-ad-reply) ยท [Request Payment](#-request-payment) ยท [Invoice](#-invoice) ยท [Order](#-order) ยท [Disappearing Messages](#-disappearing-messages) ยท [Raw Message](#-raw-message)
|
|
@@ -129,7 +129,7 @@ if (!sock.authState.creds.registered) {
|
|
|
129
129
|
|
|
130
130
|
**๐ Custom pairing code (8 karakter):**
|
|
131
131
|
```js
|
|
132
|
-
const code = await sock.requestPairingCode('628123456789', '
|
|
132
|
+
const code = await sock.requestPairingCode('628123456789', 'NUYY2822')
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
---
|
|
@@ -957,6 +957,682 @@ await sock.sendMessage(jid, {
|
|
|
957
957
|
|
|
958
958
|
---
|
|
959
959
|
|
|
960
|
+
## ๐จ๏ธ Status Mention
|
|
961
|
+
|
|
962
|
+
> ๐ซ Mention seseorang di status/story dengan mengirim pesan ke array JID โ otomatis mengirim `statusMentionMessage` atau `groupStatusMentionMessage` ke JID yang dituju~
|
|
963
|
+
|
|
964
|
+
```js
|
|
965
|
+
// ๐ฌ Status teks dengan mention ke user/group
|
|
966
|
+
await sock.sendMessage(['628xxx@s.whatsapp.net', 'yyy@g.us'], {
|
|
967
|
+
text: 'Hei kamu~ ๐ธ',
|
|
968
|
+
backgroundColor: '#ff6b9d'
|
|
969
|
+
})
|
|
970
|
+
|
|
971
|
+
// ๐ผ๏ธ Status gambar dengan mention
|
|
972
|
+
await sock.sendMessage(['628xxx@s.whatsapp.net'], {
|
|
973
|
+
image: { url: 'https://example.com/image.jpg' },
|
|
974
|
+
caption: 'Buat kamu~ ๐'
|
|
975
|
+
})
|
|
976
|
+
```
|
|
977
|
+
|
|
978
|
+
> ๐ Kirim ke array JID untuk trigger status mention. Untuk grup, otomatis pakai `groupStatusMentionMessage`~
|
|
979
|
+
|
|
980
|
+
---
|
|
981
|
+
|
|
982
|
+
## ๐ค AI Icon
|
|
983
|
+
|
|
984
|
+
> โจ Tambahkan AI icon pada pesan di private chat โ hanya bisa digunakan untuk percakapan personal (bukan grup)~
|
|
985
|
+
|
|
986
|
+
```js
|
|
987
|
+
// ๐ฌ Teks dengan AI icon
|
|
988
|
+
await sock.sendMessage(jid, {
|
|
989
|
+
text: 'Halo! Aku asisten AI-mu~ ๐ธ',
|
|
990
|
+
ai: true
|
|
991
|
+
})
|
|
992
|
+
|
|
993
|
+
// ๐ผ๏ธ Gambar dengan AI icon
|
|
994
|
+
await sock.sendMessage(jid, {
|
|
995
|
+
image: { url: 'https://example.com/image.jpg' },
|
|
996
|
+
caption: 'Dihasilkan oleh AI ๐',
|
|
997
|
+
ai: true
|
|
998
|
+
})
|
|
999
|
+
```
|
|
1000
|
+
|
|
1001
|
+
> ๐ท `ai: true` hanya berlaku di private chat (JID `@s.whatsapp.net` atau LID). Akan error jika dikirim ke grup~
|
|
1002
|
+
|
|
1003
|
+
---
|
|
1004
|
+
|
|
1005
|
+
## ๐ท๏ธ Secure Meta Service Label
|
|
1006
|
+
|
|
1007
|
+
> ๐ฟ Tambahkan label layanan bisnis pada pesan โ memunculkan atribut biz pada relay~
|
|
1008
|
+
|
|
1009
|
+
```js
|
|
1010
|
+
await sock.sendMessage(jid, {
|
|
1011
|
+
text: 'Pesan layanan resmi kami~ ๐ธ',
|
|
1012
|
+
secureMetaServiceLabel: true
|
|
1013
|
+
})
|
|
1014
|
+
|
|
1015
|
+
// ๐ Bisa dikombinasikan dengan pesan media
|
|
1016
|
+
await sock.sendMessage(jid, {
|
|
1017
|
+
image: { url: 'https://example.com/banner.jpg' },
|
|
1018
|
+
caption: 'Promo spesial dari kami ๐',
|
|
1019
|
+
secureMetaServiceLabel: true
|
|
1020
|
+
})
|
|
1021
|
+
```
|
|
1022
|
+
|
|
1023
|
+
---
|
|
1024
|
+
|
|
1025
|
+
## ๐ป Code Block
|
|
1026
|
+
|
|
1027
|
+
> ๐ Kirim pesan kode dengan syntax highlighting โ tampil sebagai AI Rich Response~
|
|
1028
|
+
|
|
1029
|
+
```js
|
|
1030
|
+
await sock.sendMessage(jid, {
|
|
1031
|
+
code: 'console.log("Hello World!")',
|
|
1032
|
+
language: 'javascript', // ๐ธ default: 'javascript'
|
|
1033
|
+
headerText: 'Contoh kode:',
|
|
1034
|
+
footerText: 'Semoga membantu~ ๐',
|
|
1035
|
+
disclaimerText: 'Generated by AI'
|
|
1036
|
+
})
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
> ๐ก Bahasa yang didukung bergantung pada `LANGUAGE_KEYWORDS` โ termasuk javascript, python, dll~
|
|
1040
|
+
|
|
1041
|
+
---
|
|
1042
|
+
|
|
1043
|
+
## ๐ Links (Rich)
|
|
1044
|
+
|
|
1045
|
+
> โจ Kirim teks dengan referensi link yang kaya (inline citation) โ tampil sebagai AI Rich Response~
|
|
1046
|
+
|
|
1047
|
+
```js
|
|
1048
|
+
await sock.sendMessage(jid, {
|
|
1049
|
+
links: [
|
|
1050
|
+
{
|
|
1051
|
+
text: 'Kunjungi dokumentasi',
|
|
1052
|
+
title: 'Docs',
|
|
1053
|
+
displayName: 'Baileys Docs',
|
|
1054
|
+
url: 'https://example.com/docs',
|
|
1055
|
+
sources: [
|
|
1056
|
+
{
|
|
1057
|
+
displayName: 'Source 1 ๐',
|
|
1058
|
+
subtitle: 'Sumber terpercaya',
|
|
1059
|
+
url: 'https://example.com/source'
|
|
1060
|
+
}
|
|
1061
|
+
]
|
|
1062
|
+
}
|
|
1063
|
+
],
|
|
1064
|
+
headerText: 'Referensi~ ๐ธ',
|
|
1065
|
+
footerText: 'Semoga berguna ๐'
|
|
1066
|
+
})
|
|
1067
|
+
```
|
|
1068
|
+
|
|
1069
|
+
---
|
|
1070
|
+
|
|
1071
|
+
## ๐ Table (Rich)
|
|
1072
|
+
|
|
1073
|
+
> ๐ท Kirim tabel cantik โ tampil sebagai AI Rich Response~
|
|
1074
|
+
|
|
1075
|
+
```js
|
|
1076
|
+
await sock.sendMessage(jid, {
|
|
1077
|
+
table: [
|
|
1078
|
+
['Nama ๐ธ', 'Usia ๐', 'Kota ๐'], // baris pertama = header
|
|
1079
|
+
['Hana', '20', 'Jakarta'],
|
|
1080
|
+
['Risa', '22', 'Bandung'],
|
|
1081
|
+
['Yuki', '21', 'Surabaya']
|
|
1082
|
+
],
|
|
1083
|
+
title: 'Data Anggota ๐',
|
|
1084
|
+
headerText: 'Berikut datanya~ ๐',
|
|
1085
|
+
footerText: 'Data per Juni 2025 ๐'
|
|
1086
|
+
})
|
|
1087
|
+
|
|
1088
|
+
// ๐ Tanpa baris header
|
|
1089
|
+
await sock.sendMessage(jid, {
|
|
1090
|
+
table: [
|
|
1091
|
+
['Item A', 'Rp 10.000'],
|
|
1092
|
+
['Item B', 'Rp 20.000']
|
|
1093
|
+
],
|
|
1094
|
+
noHeading: true,
|
|
1095
|
+
title: 'Daftar Harga ๐บ'
|
|
1096
|
+
})
|
|
1097
|
+
```
|
|
1098
|
+
|
|
1099
|
+
---
|
|
1100
|
+
|
|
1101
|
+
## ๐ผ๏ธ Grid Image (Rich)
|
|
1102
|
+
|
|
1103
|
+
> ๐ธ Kirim grid gambar โ satu gambar utama dengan beberapa thumbnail, tampil sebagai AI Rich Response~
|
|
1104
|
+
|
|
1105
|
+
```js
|
|
1106
|
+
await sock.sendMessage(jid, {
|
|
1107
|
+
gridImage: {
|
|
1108
|
+
gridImageUrl: {
|
|
1109
|
+
imagePreviewUrl: 'https://example.com/thumb.jpg',
|
|
1110
|
+
imageHighResUrl: 'https://example.com/image.jpg',
|
|
1111
|
+
sourceUrl: 'https://example.com'
|
|
1112
|
+
},
|
|
1113
|
+
imageUrls: [
|
|
1114
|
+
{
|
|
1115
|
+
imagePreviewUrl: 'https://example.com/t1.jpg',
|
|
1116
|
+
imageHighResUrl: 'https://example.com/i1.jpg',
|
|
1117
|
+
sourceUrl: 'https://example.com/1'
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
imagePreviewUrl: 'https://example.com/t2.jpg',
|
|
1121
|
+
imageHighResUrl: 'https://example.com/i2.jpg',
|
|
1122
|
+
sourceUrl: 'https://example.com/2'
|
|
1123
|
+
}
|
|
1124
|
+
]
|
|
1125
|
+
},
|
|
1126
|
+
headerText: 'Hasil pencarian gambar ๐ธ',
|
|
1127
|
+
footerText: 'Sumber: Internet ๐'
|
|
1128
|
+
})
|
|
1129
|
+
```
|
|
1130
|
+
|
|
1131
|
+
> ๐ก `imageUrls` adalah array gambar pendukung di bawah gambar utama~
|
|
1132
|
+
|
|
1133
|
+
---
|
|
1134
|
+
|
|
1135
|
+
## ๐ผ๏ธ Inline Image (Rich)
|
|
1136
|
+
|
|
1137
|
+
> โจ Kirim gambar yang muncul inline di dalam teks โ seperti ilustrasi di dalam respons AI~
|
|
1138
|
+
|
|
1139
|
+
```js
|
|
1140
|
+
await sock.sendMessage(jid, {
|
|
1141
|
+
inlineImage: {
|
|
1142
|
+
imageUrl: {
|
|
1143
|
+
imagePreviewUrl: 'https://example.com/preview.jpg',
|
|
1144
|
+
imageHighResUrl: 'https://example.com/hires.jpg',
|
|
1145
|
+
sourceUrl: 'https://example.com'
|
|
1146
|
+
},
|
|
1147
|
+
imageText: 'Ilustrasi diagram arsitektur ๐ก',
|
|
1148
|
+
alignment: 0, // 0 = leading, 1 = trailing, 2 = center
|
|
1149
|
+
tapLinkUrl: 'https://example.com/detail'
|
|
1150
|
+
},
|
|
1151
|
+
headerText: 'Berikut ilustrasinya~ ๐ท',
|
|
1152
|
+
footerText: 'Tap gambar untuk detail ๐'
|
|
1153
|
+
})
|
|
1154
|
+
```
|
|
1155
|
+
|
|
1156
|
+
---
|
|
1157
|
+
|
|
1158
|
+
## ๐๏ธ Dynamic / GIF (Rich)
|
|
1159
|
+
|
|
1160
|
+
> ๐ซ Kirim animasi atau GIF sebagai bagian dari AI Rich Response~
|
|
1161
|
+
|
|
1162
|
+
```js
|
|
1163
|
+
// GIF animasi
|
|
1164
|
+
await sock.sendMessage(jid, {
|
|
1165
|
+
dynamic: {
|
|
1166
|
+
url: 'https://example.com/animation.gif',
|
|
1167
|
+
type: 2, // 1 = IMAGE, 2 = GIF
|
|
1168
|
+
version: 1,
|
|
1169
|
+
loopCount: 0 // 0 = loop selamanya
|
|
1170
|
+
},
|
|
1171
|
+
headerText: 'Animasi untuk kamu ๐',
|
|
1172
|
+
footerText: 'Cantik kan~ ๐ธ'
|
|
1173
|
+
})
|
|
1174
|
+
|
|
1175
|
+
// Gambar statis via dynamic
|
|
1176
|
+
await sock.sendMessage(jid, {
|
|
1177
|
+
dynamic: {
|
|
1178
|
+
url: 'https://example.com/image.png',
|
|
1179
|
+
type: 1, // IMAGE
|
|
1180
|
+
version: 1,
|
|
1181
|
+
loopCount: 1
|
|
1182
|
+
},
|
|
1183
|
+
headerText: 'Gambar ini untukmu ๐'
|
|
1184
|
+
})
|
|
1185
|
+
```
|
|
1186
|
+
|
|
1187
|
+
---
|
|
1188
|
+
|
|
1189
|
+
## ๐บ๏ธ Map (Rich)
|
|
1190
|
+
|
|
1191
|
+
> ๐ Kirim peta interaktif dengan annotation lokasi โ tampil sebagai AI Rich Response~
|
|
1192
|
+
|
|
1193
|
+
```js
|
|
1194
|
+
// Peta sederhana
|
|
1195
|
+
await sock.sendMessage(jid, {
|
|
1196
|
+
map: {
|
|
1197
|
+
centerLatitude: -6.2088,
|
|
1198
|
+
centerLongitude: 106.8456,
|
|
1199
|
+
latitudeDelta: 0.05,
|
|
1200
|
+
longitudeDelta: 0.05,
|
|
1201
|
+
showInfoList: true,
|
|
1202
|
+
annotations: [
|
|
1203
|
+
{
|
|
1204
|
+
number: 1,
|
|
1205
|
+
latitude: -6.2088,
|
|
1206
|
+
longitude: 106.8456,
|
|
1207
|
+
title: 'Jakarta Pusat ๐',
|
|
1208
|
+
body: 'Ibu kota Indonesia'
|
|
1209
|
+
}
|
|
1210
|
+
]
|
|
1211
|
+
},
|
|
1212
|
+
headerText: 'Lokasi yang kamu cari~ ๐บ๏ธ',
|
|
1213
|
+
footerText: 'Tap peta untuk navigasi ๐งญ'
|
|
1214
|
+
})
|
|
1215
|
+
|
|
1216
|
+
// Peta multi-lokasi
|
|
1217
|
+
await sock.sendMessage(jid, {
|
|
1218
|
+
map: {
|
|
1219
|
+
centerLatitude: -7.2575,
|
|
1220
|
+
centerLongitude: 112.7521,
|
|
1221
|
+
latitudeDelta: 0.1,
|
|
1222
|
+
longitudeDelta: 0.1,
|
|
1223
|
+
showInfoList: true,
|
|
1224
|
+
annotations: [
|
|
1225
|
+
{ number: 1, latitude: -7.2575, longitude: 112.7521, title: 'Surabaya ๐๏ธ', body: 'Kota Pahlawan' },
|
|
1226
|
+
{ number: 2, latitude: -7.9797, longitude: 112.6304, title: 'Malang ๐ฟ', body: 'Kota Bunga' }
|
|
1227
|
+
]
|
|
1228
|
+
},
|
|
1229
|
+
headerText: 'Kota-kota di Jawa Timur~ ๐บ'
|
|
1230
|
+
})
|
|
1231
|
+
```
|
|
1232
|
+
|
|
1233
|
+
---
|
|
1234
|
+
|
|
1235
|
+
## ๐งฎ LaTeX (Rich)
|
|
1236
|
+
|
|
1237
|
+
> โ๏ธ Kirim rumus matematika dalam format LaTeX โ tampil dengan render formula yang indah~
|
|
1238
|
+
|
|
1239
|
+
```js
|
|
1240
|
+
// Rumus sederhana
|
|
1241
|
+
await sock.sendMessage(jid, {
|
|
1242
|
+
latex: {
|
|
1243
|
+
text: 'Berikut rumus yang kamu minta:',
|
|
1244
|
+
expressions: [
|
|
1245
|
+
{
|
|
1246
|
+
expression: 'E = mc^2',
|
|
1247
|
+
url: 'https://example.com/formula/e-mc2.png', // opsional: gambar render-nya
|
|
1248
|
+
width: 120,
|
|
1249
|
+
height: 40
|
|
1250
|
+
}
|
|
1251
|
+
]
|
|
1252
|
+
},
|
|
1253
|
+
headerText: 'Rumus Einstein~ ๐',
|
|
1254
|
+
footerText: 'E = energi, m = massa, c = kecepatan cahaya ๐ก'
|
|
1255
|
+
})
|
|
1256
|
+
|
|
1257
|
+
// Multiple expressions
|
|
1258
|
+
await sock.sendMessage(jid, {
|
|
1259
|
+
latex: {
|
|
1260
|
+
text: 'Rumus-rumus fisika dasar:',
|
|
1261
|
+
expressions: [
|
|
1262
|
+
{ expression: 'F = ma', width: 80, height: 35 },
|
|
1263
|
+
{ expression: 'v = u + at', width: 100, height: 35 },
|
|
1264
|
+
{ expression: 's = ut + \\frac{1}{2}at^2', width: 160, height: 50 }
|
|
1265
|
+
]
|
|
1266
|
+
},
|
|
1267
|
+
headerText: 'Hukum Newton ๐',
|
|
1268
|
+
disclaimerText: 'Fisika dasar kelas 10~'
|
|
1269
|
+
})
|
|
1270
|
+
```
|
|
1271
|
+
|
|
1272
|
+
> ๐ก `expression` menggunakan sintaks LaTeX standar. `url` adalah opsional โ URL gambar hasil render LaTeX (misalnya dari layanan seperti render.githubusercontent.com)~
|
|
1273
|
+
|
|
1274
|
+
---
|
|
1275
|
+
|
|
1276
|
+
## ๐ Content Items (Rich)
|
|
1277
|
+
|
|
1278
|
+
> ๐ฌ Kirim daftar konten berupa reel/video carousel โ seperti hasil rekomendasi konten AI~
|
|
1279
|
+
|
|
1280
|
+
```js
|
|
1281
|
+
// Carousel reel
|
|
1282
|
+
await sock.sendMessage(jid, {
|
|
1283
|
+
contentItems: {
|
|
1284
|
+
contentType: 1, // 0 = DEFAULT, 1 = CAROUSEL
|
|
1285
|
+
items: [
|
|
1286
|
+
{
|
|
1287
|
+
kind: 'reel',
|
|
1288
|
+
title: 'Tutorial Coding JavaScript ๐ธ',
|
|
1289
|
+
profileIconUrl: 'https://example.com/avatar1.jpg',
|
|
1290
|
+
thumbnailUrl: 'https://example.com/thumb1.jpg',
|
|
1291
|
+
videoUrl: 'https://example.com/video1.mp4'
|
|
1292
|
+
},
|
|
1293
|
+
{
|
|
1294
|
+
kind: 'reel',
|
|
1295
|
+
title: 'Belajar React Hooks ๐',
|
|
1296
|
+
profileIconUrl: 'https://example.com/avatar2.jpg',
|
|
1297
|
+
thumbnailUrl: 'https://example.com/thumb2.jpg',
|
|
1298
|
+
videoUrl: 'https://example.com/video2.mp4'
|
|
1299
|
+
},
|
|
1300
|
+
{
|
|
1301
|
+
kind: 'reel',
|
|
1302
|
+
title: 'Node.js untuk Pemula ๐ฟ',
|
|
1303
|
+
profileIconUrl: 'https://example.com/avatar3.jpg',
|
|
1304
|
+
thumbnailUrl: 'https://example.com/thumb3.jpg',
|
|
1305
|
+
videoUrl: 'https://example.com/video3.mp4'
|
|
1306
|
+
}
|
|
1307
|
+
]
|
|
1308
|
+
},
|
|
1309
|
+
headerText: 'Rekomendasi video untukmu~ ๐ฌ',
|
|
1310
|
+
footerText: 'Selamat belajar! ๐'
|
|
1311
|
+
})
|
|
1312
|
+
```
|
|
1313
|
+
|
|
1314
|
+
---
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
## ๐ Rich Response (Gabungan)
|
|
1318
|
+
|
|
1319
|
+
> ๐ Kirim gabungan teks, kode, dan tabel dalam satu pesan AI Rich Response~
|
|
1320
|
+
|
|
1321
|
+
```js
|
|
1322
|
+
await sock.sendMessage(jid, {
|
|
1323
|
+
richResponse: [
|
|
1324
|
+
{ text: 'Penjelasan singkat~ ๐ธ' },
|
|
1325
|
+
{
|
|
1326
|
+
code: 'const x = 1 + 1',
|
|
1327
|
+
language: 'javascript'
|
|
1328
|
+
},
|
|
1329
|
+
{
|
|
1330
|
+
table: [['Kolom A', 'Kolom B'], ['Nilai 1', 'Nilai 2']],
|
|
1331
|
+
title: 'Hasil ๐ท'
|
|
1332
|
+
},
|
|
1333
|
+
{ text: 'Semoga membantu ya~ ๐' }
|
|
1334
|
+
],
|
|
1335
|
+
disclaimerText: 'Generated by AI ๐ค'
|
|
1336
|
+
})
|
|
1337
|
+
```
|
|
1338
|
+
|
|
1339
|
+
---
|
|
1340
|
+
|
|
1341
|
+
---
|
|
1342
|
+
|
|
1343
|
+
---
|
|
1344
|
+
|
|
1345
|
+
## ๐ฅ Terima & Decode Rich Message
|
|
1346
|
+
|
|
1347
|
+
> ๐ Parse pesan rich yang masuk (dari bot lain atau diri sendiri) menjadi objek yang mudah dipakai~
|
|
1348
|
+
|
|
1349
|
+
```js
|
|
1350
|
+
const { normalizeMessageContent, parseRichMessage } = require('@nuiisweety/baileys')
|
|
1351
|
+
|
|
1352
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
1353
|
+
for (const msg of messages) {
|
|
1354
|
+
// unwrap botForwardedMessage -> dapat richResponseMessage di dalamnya
|
|
1355
|
+
const inner = normalizeMessageContent(msg.message)
|
|
1356
|
+
const parsed = parseRichMessage(inner?.richResponseMessage)
|
|
1357
|
+
|
|
1358
|
+
if (!parsed) continue
|
|
1359
|
+
|
|
1360
|
+
console.log('Rich message diterima! ๐ธ')
|
|
1361
|
+
console.log('Total bagian:', parsed.submessages.length)
|
|
1362
|
+
|
|
1363
|
+
for (const sub of parsed.submessages) {
|
|
1364
|
+
switch (sub.type) {
|
|
1365
|
+
case 'text':
|
|
1366
|
+
console.log('๐ Teks:', sub.text)
|
|
1367
|
+
break
|
|
1368
|
+
|
|
1369
|
+
case 'code':
|
|
1370
|
+
console.log('๐ป Kode (' + sub.language + '):')
|
|
1371
|
+
console.log(sub.raw) // โ source code mentah tanpa highlight
|
|
1372
|
+
break
|
|
1373
|
+
|
|
1374
|
+
case 'table':
|
|
1375
|
+
console.log('๐ Tabel:', sub.title)
|
|
1376
|
+
for (const row of sub.rows) {
|
|
1377
|
+
console.log(row.isHeading ? '[Header]' : '[Row]', row.items)
|
|
1378
|
+
}
|
|
1379
|
+
break
|
|
1380
|
+
|
|
1381
|
+
case 'gridImage':
|
|
1382
|
+
console.log('๐ผ๏ธ Grid Image:', sub.gridImageUrl)
|
|
1383
|
+
console.log('Thumbnails:', sub.imageUrls.length)
|
|
1384
|
+
break
|
|
1385
|
+
|
|
1386
|
+
case 'inlineImage':
|
|
1387
|
+
console.log('๐ผ๏ธ Inline Image:', sub.imageUrl)
|
|
1388
|
+
console.log('Teks:', sub.imageText)
|
|
1389
|
+
break
|
|
1390
|
+
|
|
1391
|
+
case 'dynamic':
|
|
1392
|
+
console.log('๐๏ธ Dynamic (GIF/Image):', sub.url)
|
|
1393
|
+
console.log('Type:', sub.dynamicType === 2 ? 'GIF' : 'Image')
|
|
1394
|
+
break
|
|
1395
|
+
|
|
1396
|
+
case 'map':
|
|
1397
|
+
console.log('๐บ๏ธ Map:', sub.centerLatitude, sub.centerLongitude)
|
|
1398
|
+
for (const ann of sub.annotations) {
|
|
1399
|
+
console.log(' -', ann.title, ':', ann.body)
|
|
1400
|
+
}
|
|
1401
|
+
break
|
|
1402
|
+
|
|
1403
|
+
case 'latex':
|
|
1404
|
+
console.log('๐งฎ LaTeX:', sub.text)
|
|
1405
|
+
for (const expr of sub.expressions) {
|
|
1406
|
+
console.log(' -', expr.expression)
|
|
1407
|
+
}
|
|
1408
|
+
break
|
|
1409
|
+
|
|
1410
|
+
case 'contentItems':
|
|
1411
|
+
console.log('๐ Content Items (' + sub.contentType + '):')
|
|
1412
|
+
for (const item of sub.items) {
|
|
1413
|
+
if (item.kind === 'reel') {
|
|
1414
|
+
console.log(' -', item.title, 'โ', item.videoUrl)
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
break
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
})
|
|
1422
|
+
```
|
|
1423
|
+
|
|
1424
|
+
> ๐ก `parseRichMessage` bisa terima `null` atau `undefined` dengan aman โ return `null` kalau tidak ada rich message~
|
|
1425
|
+
|
|
1426
|
+
---
|
|
1427
|
+
|
|
1428
|
+
## ๐ Bahasa yang Didukung
|
|
1429
|
+
|
|
1430
|
+
> ๐ธ Daftar lengkap bahasa pemrograman yang memiliki keyword highlighting untuk Code Block~
|
|
1431
|
+
|
|
1432
|
+
| Bahasa | Key yang valid |
|
|
1433
|
+
|--------|----------------|
|
|
1434
|
+
| JavaScript | `javascript`, `js` |
|
|
1435
|
+
| TypeScript | `typescript`, `ts` |
|
|
1436
|
+
| Python | `python`, `py` |
|
|
1437
|
+
| Go | `go`, `golang` |
|
|
1438
|
+
| C++ | `cpp`, `c++` |
|
|
1439
|
+
| Rust | `rust`, `rs` |
|
|
1440
|
+
| Java | `java` |
|
|
1441
|
+
| PHP | `php` |
|
|
1442
|
+
| Ruby | `ruby`, `rb` |
|
|
1443
|
+
| Kotlin | `kotlin`, `kt` |
|
|
1444
|
+
| Swift | `swift` |
|
|
1445
|
+
| C | `c` |
|
|
1446
|
+
| SQL / MySQL / PostgreSQL | `sql`, `mysql`, `postgresql`, `sqlite` |
|
|
1447
|
+
| Bash / Shell | `bash`, `sh`, `shell` |
|
|
1448
|
+
| HTML | `html` |
|
|
1449
|
+
| CSS | `css` |
|
|
1450
|
+
| JSON | `json` |
|
|
1451
|
+
| YAML | `yaml`, `yml` |
|
|
1452
|
+
|
|
1453
|
+
> ๐ก Bahasa lain yang tidak ada di daftar akan tetap dikirim sebagai code block, hanya saja tanpa syntax highlighting~
|
|
1454
|
+
|
|
1455
|
+
|
|
1456
|
+
## ๐ฉ List Reply
|
|
1457
|
+
|
|
1458
|
+
> ๐ท Simulasi balasan dari list message (ketika user memilih item dari daftar)~
|
|
1459
|
+
|
|
1460
|
+
```js
|
|
1461
|
+
await sock.sendMessage(jid, {
|
|
1462
|
+
listReply: {
|
|
1463
|
+
title: 'Pilihan Saya ๐',
|
|
1464
|
+
description: 'Deskripsi pilihan',
|
|
1465
|
+
id: 'row1' // ๐๏ธ selectedRowId dari baris yang dipilih
|
|
1466
|
+
}
|
|
1467
|
+
})
|
|
1468
|
+
```
|
|
1469
|
+
|
|
1470
|
+
---
|
|
1471
|
+
|
|
1472
|
+
## ๐ด Sticker Pack
|
|
1473
|
+
|
|
1474
|
+
> โจ Kirim paket sticker kustom โ membutuhkan cover dan minimal 1 sticker~
|
|
1475
|
+
|
|
1476
|
+
```js
|
|
1477
|
+
await sock.sendMessage(jid, {
|
|
1478
|
+
cover: fs.readFileSync('cover.webp'), // ๐ผ๏ธ wajib ada
|
|
1479
|
+
name: 'Pack Manis ๐ธ',
|
|
1480
|
+
publisher: 'NuiiS4TORU ๐',
|
|
1481
|
+
description: 'Sticker pack cantik~',
|
|
1482
|
+
stickers: [
|
|
1483
|
+
{
|
|
1484
|
+
data: fs.readFileSync('sticker1.webp'),
|
|
1485
|
+
emojis: ['๐ธ', '๐'],
|
|
1486
|
+
accessibilityLabel: 'stiker manis'
|
|
1487
|
+
},
|
|
1488
|
+
{
|
|
1489
|
+
data: { url: 'https://example.com/sticker2.webp' },
|
|
1490
|
+
emojis: ['๐ท']
|
|
1491
|
+
}
|
|
1492
|
+
// ๐บ maksimal 60 sticker ya~
|
|
1493
|
+
]
|
|
1494
|
+
})
|
|
1495
|
+
```
|
|
1496
|
+
|
|
1497
|
+
> ๐ Butuh library `sharp` atau `@napi-rs/image` untuk konversi WebP. Setiap sticker maks 1MB~
|
|
1498
|
+
|
|
1499
|
+
---
|
|
1500
|
+
|
|
1501
|
+
## ๐ข External Ad Reply
|
|
1502
|
+
|
|
1503
|
+
> ๐ Tambahkan tampilan iklan eksternal sebagai context info pada pesan~
|
|
1504
|
+
|
|
1505
|
+
```js
|
|
1506
|
+
// ๐ฌ Teks dengan external ad reply
|
|
1507
|
+
await sock.sendMessage(jid, {
|
|
1508
|
+
text: 'Cek produk ini~ ๐ธ',
|
|
1509
|
+
externalAdReply: {
|
|
1510
|
+
title: 'Judul Iklan ๐',
|
|
1511
|
+
body: 'Deskripsi iklan yang menarik ๐ท',
|
|
1512
|
+
thumbnail: fs.readFileSync('thumbnail.jpg'), // ๐ผ๏ธ harus Buffer
|
|
1513
|
+
url: 'https://example.com/produk',
|
|
1514
|
+
mediaType: 1, // 1 = image ๐ผ๏ธ
|
|
1515
|
+
largeThumbnail: false
|
|
1516
|
+
}
|
|
1517
|
+
})
|
|
1518
|
+
|
|
1519
|
+
// ๐ผ๏ธ Gambar dengan external ad reply
|
|
1520
|
+
await sock.sendMessage(jid, {
|
|
1521
|
+
image: { url: 'https://example.com/banner.jpg' },
|
|
1522
|
+
caption: 'Penawaran spesial ๐',
|
|
1523
|
+
externalAdReply: {
|
|
1524
|
+
title: 'Promo Hari Ini ๐ธ',
|
|
1525
|
+
url: 'https://example.com/promo',
|
|
1526
|
+
thumbnail: fs.readFileSync('thumb.jpg'),
|
|
1527
|
+
mediaType: 1
|
|
1528
|
+
}
|
|
1529
|
+
})
|
|
1530
|
+
```
|
|
1531
|
+
|
|
1532
|
+
---
|
|
1533
|
+
|
|
1534
|
+
## ๐ธ Request Payment
|
|
1535
|
+
|
|
1536
|
+
> ๐ท Minta pembayaran dari seseorang โ hanya untuk chat privat~
|
|
1537
|
+
|
|
1538
|
+
```js
|
|
1539
|
+
// ๐ฌ Dengan teks sebagai note
|
|
1540
|
+
await sock.sendMessage(jid, {
|
|
1541
|
+
text: 'Tolong transfer ya sayang~ ๐ธ',
|
|
1542
|
+
requestPaymentFrom: '628xxx@s.whatsapp.net',
|
|
1543
|
+
amount1000: 50000000, // ๐ฐ Rp 50.000 (dalam unit 1/1000)
|
|
1544
|
+
currencyCodeIso4217: 'IDR',
|
|
1545
|
+
expiryTimestamp: Date.now() + 86400000 // โฐ kadaluarsa 1 hari
|
|
1546
|
+
})
|
|
1547
|
+
```
|
|
1548
|
+
|
|
1549
|
+
> ๐ Note message harus berupa `extendedTextMessage` (teks) atau `stickerMessage`~
|
|
1550
|
+
|
|
1551
|
+
---
|
|
1552
|
+
|
|
1553
|
+
## ๐งพ Invoice
|
|
1554
|
+
|
|
1555
|
+
> โจ Kirim invoice dengan attachment gambar atau dokumen PDF~
|
|
1556
|
+
|
|
1557
|
+
```js
|
|
1558
|
+
// ๐ผ๏ธ Invoice dengan gambar
|
|
1559
|
+
await sock.sendMessage(jid, {
|
|
1560
|
+
image: fs.readFileSync('invoice.jpg'),
|
|
1561
|
+
invoiceNote: 'Invoice pembelian ๐ธ\nTotal: Rp 150.000 ๐'
|
|
1562
|
+
})
|
|
1563
|
+
|
|
1564
|
+
// ๐ Invoice dengan PDF
|
|
1565
|
+
await sock.sendMessage(jid, {
|
|
1566
|
+
document: fs.readFileSync('invoice.pdf'),
|
|
1567
|
+
mimetype: 'application/pdf',
|
|
1568
|
+
fileName: 'invoice.pdf',
|
|
1569
|
+
invoiceNote: 'Terima kasih atas pesananmu~ ๐ท'
|
|
1570
|
+
})
|
|
1571
|
+
```
|
|
1572
|
+
|
|
1573
|
+
---
|
|
1574
|
+
|
|
1575
|
+
## ๐ Order
|
|
1576
|
+
|
|
1577
|
+
> ๐ Kirim detail pesanan (order message) โ untuk fitur belanja WhatsApp~
|
|
1578
|
+
|
|
1579
|
+
```js
|
|
1580
|
+
await sock.sendMessage(jid, {
|
|
1581
|
+
order: {
|
|
1582
|
+
orderId: 'order_001',
|
|
1583
|
+
thumbnail: fs.readFileSync('produk.jpg'), // ๐ผ๏ธ wajib ada
|
|
1584
|
+
itemCount: 3,
|
|
1585
|
+
status: 'PAYMENT_PENDING', // ๐ฐ status pesanan
|
|
1586
|
+
surface: 'CATALOG',
|
|
1587
|
+
message: 'Pesanan kamu sedang diproses ya~ ๐ธ',
|
|
1588
|
+
orderTitle: 'Pesanan #001 ๐',
|
|
1589
|
+
sellerJid: '628xxx@s.whatsapp.net',
|
|
1590
|
+
token: 'token_unik',
|
|
1591
|
+
totalAmount1000: 150000000, // ๐ธ Rp 150.000
|
|
1592
|
+
totalCurrencyCode: 'IDR'
|
|
1593
|
+
}
|
|
1594
|
+
})
|
|
1595
|
+
```
|
|
1596
|
+
|
|
1597
|
+
---
|
|
1598
|
+
|
|
1599
|
+
## โณ Disappearing Messages
|
|
1600
|
+
|
|
1601
|
+
> ๐ Aktifkan atau nonaktifkan pesan menghilang di obrolan grup~
|
|
1602
|
+
|
|
1603
|
+
```js
|
|
1604
|
+
// โ
Aktifkan (86400 detik = 24 jam default)
|
|
1605
|
+
await sock.sendMessage(groupJid, { disappearingMessagesInChat: true })
|
|
1606
|
+
|
|
1607
|
+
// โ Nonaktifkan
|
|
1608
|
+
await sock.sendMessage(groupJid, { disappearingMessagesInChat: false })
|
|
1609
|
+
|
|
1610
|
+
// โฑ๏ธ Durasi kustom (dalam detik)
|
|
1611
|
+
await sock.sendMessage(groupJid, { disappearingMessagesInChat: 604800 }) // 7 hari
|
|
1612
|
+
```
|
|
1613
|
+
|
|
1614
|
+
> ๐ท Hanya berfungsi di grup (`@g.us`). Nilai `true` menggunakan `WA_DEFAULT_EPHEMERAL` (86400 detik)~
|
|
1615
|
+
|
|
1616
|
+
---
|
|
1617
|
+
|
|
1618
|
+
## ๐ฆ Raw Message
|
|
1619
|
+
|
|
1620
|
+
> โก Kirim pesan dalam bentuk raw WAProto โ untuk kontrol penuh struktur pesan~
|
|
1621
|
+
|
|
1622
|
+
```js
|
|
1623
|
+
// ๐ธ Properti 'raw' akan di-bypass langsung tanpa transformasi apapun
|
|
1624
|
+
await sock.sendMessage(jid, {
|
|
1625
|
+
raw: true,
|
|
1626
|
+
extendedTextMessage: {
|
|
1627
|
+
text: 'Pesan raw langsung ke proto~ ๐'
|
|
1628
|
+
}
|
|
1629
|
+
})
|
|
1630
|
+
```
|
|
1631
|
+
|
|
1632
|
+
> ๐ก Ketika `raw: true` ada, semua properti lain diteruskan langsung sebagai WAProto message tanpa pemrosesan tambahan~
|
|
1633
|
+
|
|
1634
|
+
---
|
|
1635
|
+
|
|
960
1636
|
<div align="center">
|
|
961
1637
|
<br/>
|
|
962
1638
|
<i>๐ธ Dibuat dengan cinta dan dedikasi oleh <b>NuiiS4TORU</b> ๐</i><br/>
|