@aldy11/rekber-bot
v3.1.0
Published
Modified Baileys with LID conversion, Rekber (Escrow), Menu System, Modern Buttons & Interactive Messages — ESM first, synced with WhiskeySocket Baileys v7
Maintainers
Readme
@baileys-mod/rekber
Modified Baileys dengan LID ↔ JID conversion dan Rekber (Escrow) bot support. ESM-first.
Kompatibilitas
| Baileys Version | Status |
|----------------|--------|
| @whiskeysockets/baileys v6.x | ✅ Didukung (fallback mode) |
| @whiskeysockets/baileys v7.x (rc) | ✅ Didukung (native LID mapping) |
Catatan v7: Baileys v7 menggunakan LID sebagai identifier utama. Modul ini otomatis mendeteksi v7 dan menggunakan native
LIDMappingStoreuntuk resolusi yang lebih akurat.
Fitur
- 🔄 LID Converter - Konversi LID ke JID dan sebaliknya dari berbagai sumber (cache, native mapping, socket, store, manual)
- 💰 Rekber Manager - Sistem transaksi escrow lengkap dengan state machine
- 🔌 Enhanced Socket - Wrapper baileys dengan auto LID conversion
- 📋 Menu Manager - Sistem menu dinamis untuk bot WhatsApp
- 📦 Dual Module - Support ESM dan CommonJS
- 🔍 Auto-detect - Otomatis deteksi Baileys v6/v7 dan gunakan fitur terbaik
Install
npm install @baileys-mod/rekber @whiskeysockets/baileysQuick Start
import makeWASocket, { useMultiFileAuthState } from '@whiskeysockets/baileys';
import { enhanceSocket } from '@baileys-mod/rekber';
const { state, saveCreds } = await useMultiFileAuthState('./auth');
const sock = makeWASocket({ auth: state });
const { lid, rekber, isV7 } = enhanceSocket(sock, {
lidConverter: { cachePath: './data/lid-cache.json' },
rekber: { storagePath: './data/rekber.json', defaultFeePercent: 3 },
autoExtractLids: true,
});
sock.ev.on('creds.update', saveCreds);
console.log('Baileys v7:', isV7);
// v7: native LID mapping otomatis aktif
// v6: fallback ke cache + store contacts
// === LID Conversion ===
lid.addMapping('123@lid', '[email protected]');
console.log(lid.autoConvert('123@lid')); // [email protected]
// v7: resolve via native LIDMappingStore
const result = await lid.resolveLidViaSocket('123@lid');
console.log(result.source); // 'native' (v7) atau 'store'/'socket' (v6)
// === Rekber Transaction ===
sock.ev.on('messages.upsert', async ({ messages }) => {
for (const msg of messages) {
const text = msg.message?.conversation || '';
// v7: remoteJid bisa berupa LID, gunakan autoConvert
const from = lid.autoConvert(msg.key.remoteJid || '');
const sender = lid.autoConvert(msg.key.participant || msg.key.remoteJid || '');
if (text.startsWith('!rekber ')) {
const [, sellerNum, ...itemParts] = text.split(' ');
const tx = rekber.createTransaction({
buyerJid: sender,
sellerJid: `${sellerNum}@s.whatsapp.net`,
adminJid: lid.autoConvert(sock.user?.id || ''),
groupJid: from,
items: [{ name: itemParts.join(' '), quantity: 1, price: 100000 }],
});
await sock.sendMessage(from, { text: rekber.formatTransaction(tx) });
}
}
});API
LidConverter
| Method | Deskripsi |
|--------|-----------|
| lidToJid(lid) | Konversi LID ke JID |
| jidToLid(jid) | Konversi JID ke LID |
| autoConvert(jid, target) | Auto-detect dan konversi |
| addMapping(lid, jid) | Tambah mapping manual |
| batchConvert(jids, target) | Konversi batch |
| resolveLidViaSocket(lid) | Resolve LID → JID via socket (native v7 + fallback) |
| resolveJidToLidViaSocket(jid) | Baru: Resolve JID → LID via native v7 mapping |
| extractParticipantLids(meta) | Extract dari group metadata |
| bindSocket(socket) | Bind ke baileys socket (auto-detect v7) |
| bindNativeLidMapping(mapping) | Bind native LIDMappingStore manual |
| hasNativeMapping | Cek apakah native mapping tersedia (v7) |
RekberManager
| Method | Deskripsi |
|--------|-----------|
| createTransaction(params) | Buat transaksi baru |
| confirmTransaction(id, sellerJid) | Seller konfirmasi |
| confirmPayment(id, adminJid) | Admin konfirmasi bayar |
| markProcessing(id, sellerJid) | Tandai sedang dikirim |
| confirmDelivery(id, buyerJid) | Buyer konfirmasi terima |
| completeTransaction(id, adminJid) | Selesaikan & cairkan |
| cancelTransaction(id, byJid) | Batalkan transaksi |
| disputeTransaction(id, byJid, reason) | Ajukan sengketa |
| refundTransaction(id, adminJid) | Refund ke buyer |
| formatTransaction(tx) | Format ke text chat |
| getStats(adminJid?) | Statistik rekber |
EnhancedSocket
| Property | Deskripsi |
|----------|-----------|
| lid | Instance LidConverter |
| rekber | Instance RekberManager |
| sock | Socket baileys asli |
| isV7 | true jika Baileys v7 terdeteksi |
| destroy() | Cleanup semua resources |
Baileys v7 Perubahan Penting
Jika upgrade dari v6 ke v7, perhatikan hal berikut:
- LID sebagai identifier utama —
msg.key.remoteJidbisa berupa LID (xxx@lid), gunakanlid.autoConvert() - Field baru di message key —
remoteJidAlt,participantAltmengandung format alternatif (PN jika remoteJid adalah LID, atau sebaliknya) - Event
lid-mapping.update— Baileys v7 emit mapping{ pn, lid }secara otomatis, modul ini auto-capture onWhatsApp()tidak return LID — GunakanresolveLidViaSocket()atauresolveJidToLidViaSocket()yang memanfaatkan native mapping- Contact format baru — Field
phoneNumberdanusernameditambahkan
License
MIT
