This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { default: makeWASocket, useMultiFileAuthState } = require('@whiskeysockets/baileys') | |
| async function startBot() { | |
| const { state, saveCreds } = await useMultiFileAuthState('auth') | |
| const sock = makeWASocket({ auth: state }) | |
| sock.ev.on('creds.update', saveCreds) | |
| if (!sock.authState.creds.registered) { | |
| const code = await sock.requestPairingCode('263716594370') | |
| console.log('YOUR CODE: ' + code) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { default: makeWASocket, useMultiFileAuthState } = require('@whiskeysockets/baileys') | |
| const readline = require('readline') | |
| const rl = readline.createInterface({ input: process.stdin, output: process.stdout }) | |
| const question = (text) => new Promise((resolve) => rl.question(text, resolve)) | |
| async function startBot() { | |
| const { state, saveCreds } = await useMultiFileAuthState('auth') | |
| const sock = makeWASocket({ auth: state }) | |
| sock.ev.on('creds.update', saveCreds) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sock.ev.on('connection.update', (update) => { | |
| const { connection, lastDisconnect, qr } = update; | |
| if(qr) { | |
| // This line manually prints the QR to the terminal | |
| console.log(qr); | |
| } | |
| // ... rest of your connection logic | |
| }); | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { default: makeWASocket, useMultiFileAuthState } = require('@whiskeysockets/baileys') | |
| async function startBot() { | |
| const { state, saveCreds } = await useMultiFileAuthState('auth') | |
| const sock = makeWASocket({ auth: state, printQRInTerminal: true }) | |
| sock.ev.on('creds.update', saveCreds) | |
| sock.ev.on('messages.upsert', async ({ messages }) => { | |
| const msg = messages[0] | |
| if (!msg.key.fromMe && msg.message) { | |
| await sock.sendMessage(msg.key.remoteJid, { text: 'Hello! I received your message. I will reply soon.' }) |