mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Update README.md (#1228)
This commit is contained in:
20
README.md
20
README.md
@@ -44,7 +44,7 @@ To run the example script, download or clone the repo and then type the followin
|
|||||||
|
|
||||||
Use the stable version:
|
Use the stable version:
|
||||||
```
|
```
|
||||||
yarn add @whiskeysockets/baileys
|
yarn add baileys
|
||||||
```
|
```
|
||||||
|
|
||||||
Use the edge version (no guarantee of stability, but latest fixes + features)
|
Use the edge version (no guarantee of stability, but latest fixes + features)
|
||||||
@@ -52,9 +52,9 @@ Use the edge version (no guarantee of stability, but latest fixes + features)
|
|||||||
yarn add github:WhiskeySockets/Baileys
|
yarn add github:WhiskeySockets/Baileys
|
||||||
```
|
```
|
||||||
|
|
||||||
Then import your code using:
|
Then import the default function in your code:
|
||||||
```ts
|
```ts
|
||||||
import makeWASocket from '@whiskeysockets/baileys'
|
import makeWASocket from 'baileys'
|
||||||
```
|
```
|
||||||
|
|
||||||
# Links
|
# Links
|
||||||
@@ -183,7 +183,7 @@ WhatsApp provides a multi-device API that allows Baileys to be authenticated as
|
|||||||
> You can customize browser name if you connect with **QR-CODE**, with `Browser` constant, we have some browsers config, **see [here](https://baileys.whiskeysockets.io/types/BrowsersMap.html)**
|
> You can customize browser name if you connect with **QR-CODE**, with `Browser` constant, we have some browsers config, **see [here](https://baileys.whiskeysockets.io/types/BrowsersMap.html)**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import makeWASocket from '@whiskeysockets/baileys'
|
import makeWASocket from 'baileys'
|
||||||
|
|
||||||
const sock = makeWASocket({
|
const sock = makeWASocket({
|
||||||
// can provide additional config here
|
// can provide additional config here
|
||||||
@@ -203,13 +203,13 @@ If the connection is successful, you will see a QR code printed on your terminal
|
|||||||
The phone number can't have `+` or `()` or `-`, only numbers, you must provide country code
|
The phone number can't have `+` or `()` or `-`, only numbers, you must provide country code
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import makeWASocket from '@whiskeysockets/baileys'
|
import makeWASocket from 'baileys'
|
||||||
|
|
||||||
const sock = makeWASocket({
|
const sock = makeWASocket({
|
||||||
// can provide additional config here
|
// can provide additional config here
|
||||||
printQRInTerminal: false //need to be false
|
printQRInTerminal: false //need to be false
|
||||||
})
|
})
|
||||||
|
// NOTE: WAIT TILL QR EVENT BEFORE REQUESTING THE PAIRING CODE
|
||||||
if (!sock.authState.creds.registered) {
|
if (!sock.authState.creds.registered) {
|
||||||
const number = 'XXXXXXXXXXX'
|
const number = 'XXXXXXXXXXX'
|
||||||
const code = await sock.requestPairingCode(number)
|
const code = await sock.requestPairingCode(number)
|
||||||
@@ -276,7 +276,7 @@ You obviously don't want to keep scanning the QR code every time you want to con
|
|||||||
|
|
||||||
So, you can load the credentials to log back in:
|
So, you can load the credentials to log back in:
|
||||||
```ts
|
```ts
|
||||||
import makeWASocket, { useMultiFileAuthState } from '@whiskeysockets/baileys'
|
import makeWASocket, { useMultiFileAuthState } from 'baileys'
|
||||||
|
|
||||||
const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
|
const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ sock.ev.on('messages.upsert', ({ messages }) => {
|
|||||||
> This example includes basic auth storage too
|
> This example includes basic auth storage too
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@whiskeysockets/baileys'
|
import makeWASocket, { DisconnectReason, useMultiFileAuthState } from 'baileys'
|
||||||
import { Boom } from '@hapi/boom'
|
import { Boom } from '@hapi/boom'
|
||||||
|
|
||||||
async function connectToWhatsApp () {
|
async function connectToWhatsApp () {
|
||||||
@@ -398,7 +398,7 @@ sock.ev.on('messages.update', event => {
|
|||||||
It can be used as follows:
|
It can be used as follows:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import makeWASocket, { makeInMemoryStore } from '@whiskeysockets/baileys'
|
import makeWASocket, { makeInMemoryStore } from 'baileys'
|
||||||
// the store maintains the data of the WA connection in memory
|
// the store maintains the data of the WA connection in memory
|
||||||
// can be written out to a file & read from it
|
// can be written out to a file & read from it
|
||||||
const store = makeInMemoryStore({ })
|
const store = makeInMemoryStore({ })
|
||||||
@@ -714,7 +714,7 @@ await sock.sendMessage(jid, {
|
|||||||
If you want to save the media you received
|
If you want to save the media you received
|
||||||
```ts
|
```ts
|
||||||
import { createWriteStream } from 'fs'
|
import { createWriteStream } from 'fs'
|
||||||
import { downloadMediaMessage, getContentType } from '@whiskeysockets/baileys'
|
import { downloadMediaMessage, getContentType } from 'baileys'
|
||||||
|
|
||||||
sock.ev.on('messages.upsert', async ({ [m] }) => {
|
sock.ev.on('messages.upsert', async ({ [m] }) => {
|
||||||
if (!m.message) return // if there is no text or media message
|
if (!m.message) return // if there is no text or media message
|
||||||
|
|||||||
Reference in New Issue
Block a user