mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Merge branch 'master' into master
This commit is contained in:
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
|||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 18.x
|
||||||
|
|
||||||
- name: Install packages
|
- name: Install packages
|
||||||
run: yarn
|
run: yarn
|
||||||
|
|||||||
46
.github/workflows/manual-release.yml
vendored
Normal file
46
.github/workflows/manual-release.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
name: Manual Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
increment:
|
||||||
|
type: string
|
||||||
|
description: "Must be: patch, minor, major, pre* or <version>"
|
||||||
|
required: true
|
||||||
|
default: "patch"
|
||||||
|
jobs:
|
||||||
|
manual-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.PERSONAL_TOKEN }}
|
||||||
|
|
||||||
|
- name: Setup GIT
|
||||||
|
run: |
|
||||||
|
git config --global user.name "github-actions[bot]"
|
||||||
|
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v3.6.0
|
||||||
|
with:
|
||||||
|
node-version: 18.x
|
||||||
|
|
||||||
|
- name: Get yarn cache directory path
|
||||||
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||||
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-yarn-
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: yarn
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: "npx release-it --increment ${{ github.event.inputs.increment }}"
|
||||||
144
.github/workflows/publish-release.yml
vendored
144
.github/workflows/publish-release.yml
vendored
@@ -1,83 +1,81 @@
|
|||||||
name: Publish Release
|
name: Publish Release
|
||||||
|
|
||||||
on: "workflow_dispatch"
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
|
||||||
|
permissions: write-all
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
publish-release:
|
||||||
# Test:
|
|
||||||
# runs-on: ubuntu-latest
|
|
||||||
# steps:
|
|
||||||
# - name: Checkout Commit
|
|
||||||
# uses: actions/checkout@v2
|
|
||||||
#
|
|
||||||
# - name: Setup Node.js environment
|
|
||||||
# uses: actions/setup-node@v2.1.1
|
|
||||||
#
|
|
||||||
# - name: Install Dependencies
|
|
||||||
# run: npm install
|
|
||||||
#
|
|
||||||
# - name: Run Tests
|
|
||||||
# run: npm run test
|
|
||||||
Build:
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Commit
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Parsing Package Info
|
- name: Fetching tags
|
||||||
id: packageInfo
|
run: git fetch --tags -f || true
|
||||||
run: |
|
|
||||||
echo "::set-output name=package-name::$(jq -r .name package.json)"
|
|
||||||
echo "::set-output name=package-version::$(jq -r .version package.json)"
|
|
||||||
echo "::set-output name=commit-msg::$(git log -1 --pretty=%B)"
|
|
||||||
|
|
||||||
- name: Setup Node.js environment
|
|
||||||
uses: actions/setup-node@v2.1.1
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Setup Node
|
||||||
run: yarn
|
uses: actions/setup-node@v3.6.0
|
||||||
|
with:
|
||||||
|
node-version: 18.x
|
||||||
|
registry-url: "https://registry.npmjs.org"
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
- name: Build
|
- name: Get yarn cache directory path
|
||||||
run: yarn run build:tsc
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
||||||
- name: Create Release
|
|
||||||
id: releaseCreate
|
- uses: actions/cache@v3
|
||||||
uses: actions/create-release@v1
|
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||||
env:
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-yarn-
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: yarn
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
|
- name: Publish in NPM
|
||||||
|
run: npm publish --access public
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
|
- name: Generate Changelog
|
||||||
|
id: generate_changelog
|
||||||
|
run: |
|
||||||
|
changelog=$(npm run changelog:last --silent)
|
||||||
|
echo "changelog<<EOF" >> $GITHUB_OUTPUT
|
||||||
|
echo "${changelog}" >> $GITHUB_OUTPUT
|
||||||
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Make Package
|
||||||
|
run: npm pack
|
||||||
|
|
||||||
|
- name: Rename Pack
|
||||||
|
run: mv *.tgz baileys.tgz
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
uses: meeDamian/github-release@2.0
|
||||||
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
# The name of the tag. This should come from the webhook payload, `github.GITHUB_REF` when a user pushes a new tag
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
tag_name: v${{ steps.packageInfo.outputs.package-version }}
|
tag: ${{ github.ref }}
|
||||||
# The name of the release. For example, `Release v1.0.1`
|
commitish: ${{ github.sha }}
|
||||||
release_name: v${{ steps.packageInfo.outputs.package-version }}
|
name: ${{ github.ref_name }}
|
||||||
# Text describing the contents of the tag.
|
body: ${{ steps.generate_changelog.outputs.changelog }}
|
||||||
body: ${{steps.packageInfo.outputs.commit-msg}}
|
draft: false
|
||||||
# `true` to create a draft (unpublished) release, `false` to create a published one. Default: `false`
|
prerelease: false
|
||||||
draft: false
|
files: >
|
||||||
# `true` to identify the release as a prerelease. `false` to identify the release as a full release. Default: `false`
|
baileys.tgz
|
||||||
prerelease: false
|
gzip: folders
|
||||||
|
allow_override: true
|
||||||
- name: Make Package
|
|
||||||
run: npm pack
|
|
||||||
|
|
||||||
- name: Rename Pack
|
|
||||||
run: mv *.tgz npmPackage.tgz
|
|
||||||
|
|
||||||
- name: Git Release
|
|
||||||
uses: actions/upload-release-asset@v1.0.2
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
# The URL for uploading assets to the release
|
|
||||||
upload_url: ${{steps.releaseCreate.outputs.upload_url}}
|
|
||||||
# The path to the asset you want to upload
|
|
||||||
asset_path: npmPackage.tgz
|
|
||||||
asset_name: npmPackage.tgz
|
|
||||||
# The content-type of the asset you want to upload. See the supported Media Types here: https://www.iana.org/assignments/media-types/media-types.xhtml for more information
|
|
||||||
asset_content_type: application/x-compressed-tar
|
|
||||||
|
|
||||||
- name: NPM Publish
|
|
||||||
uses: JS-DevTools/npm-publish@v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.NPM_TOKEN }}
|
|
||||||
|
|||||||
20
.gitignore
vendored
20
.gitignore
vendored
@@ -1,17 +1,19 @@
|
|||||||
node_modules
|
.DS_Store
|
||||||
|
.env
|
||||||
|
.yarn/
|
||||||
|
*.tgz
|
||||||
|
*/.DS_Store
|
||||||
auth_info*.json
|
auth_info*.json
|
||||||
baileys_auth_info*
|
baileys_auth_info*
|
||||||
baileys_store*.json
|
baileys_store*.json
|
||||||
output.csv
|
|
||||||
*/.DS_Store
|
|
||||||
.DS_Store
|
|
||||||
.env
|
|
||||||
browser-messages.json
|
browser-messages.json
|
||||||
decoded-ws.json
|
|
||||||
lib
|
|
||||||
docs
|
|
||||||
browser-token.json
|
browser-token.json
|
||||||
Proxy
|
decoded-ws.json
|
||||||
|
docs
|
||||||
|
lib
|
||||||
messages*.json
|
messages*.json
|
||||||
|
node_modules
|
||||||
|
output.csv
|
||||||
|
Proxy
|
||||||
test.ts
|
test.ts
|
||||||
TestData
|
TestData
|
||||||
14
.release-it.yml
Normal file
14
.release-it.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
git:
|
||||||
|
commitMessage: "chore(release): v${version}"
|
||||||
|
tagAnnotation: "chore(release): v${version}"
|
||||||
|
tagName: "v${version}"
|
||||||
|
|
||||||
|
hooks:
|
||||||
|
after:bump:
|
||||||
|
- "npm run changelog:update"
|
||||||
|
|
||||||
|
# automatic publish from github workflow
|
||||||
|
npm:
|
||||||
|
publish: false
|
||||||
|
private: true
|
||||||
|
registry: "OMITTED"
|
||||||
4
CHANGELOG.md
Normal file
4
CHANGELOG.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# 6.0.0 (2023-05-10)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
66
README.md
66
README.md
@@ -25,7 +25,7 @@ To run the example script, download or clone the repo and then type the followin
|
|||||||
|
|
||||||
Use the stable version:
|
Use the stable version:
|
||||||
```
|
```
|
||||||
temporarily unavailable
|
yarn add @whiskeysockets/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)
|
||||||
@@ -35,7 +35,7 @@ yarn add github:WhiskeySockets/Baileys
|
|||||||
|
|
||||||
Then import your code using:
|
Then import your code using:
|
||||||
``` ts
|
``` ts
|
||||||
import makeWASocket from '@adiwajshing/baileys'
|
import makeWASocket from '@whiskeysockets/baileys'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Unit Tests
|
## Unit Tests
|
||||||
@@ -45,7 +45,7 @@ TODO
|
|||||||
## Connecting
|
## Connecting
|
||||||
|
|
||||||
``` ts
|
``` ts
|
||||||
import makeWASocket, { DisconnectReason } from '@adiwajshing/baileys'
|
import makeWASocket, { DisconnectReason } from '@whiskeysockets/baileys'
|
||||||
import { Boom } from '@hapi/boom'
|
import { Boom } from '@hapi/boom'
|
||||||
|
|
||||||
async function connectToWhatsApp () {
|
async function connectToWhatsApp () {
|
||||||
@@ -175,7 +175,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, { BufferJSON, useMultiFileAuthState } from '@adiwajshing/baileys'
|
import makeWASocket, { BufferJSON, useMultiFileAuthState } from '@whiskeysockets/baileys'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
|
|
||||||
// utility function to help save the auth state in a single folder
|
// utility function to help save the auth state in a single folder
|
||||||
@@ -288,7 +288,7 @@ Baileys does not come with a defacto storage for chats, contacts, or messages. H
|
|||||||
It can be used as follows:
|
It can be used as follows:
|
||||||
|
|
||||||
``` ts
|
``` ts
|
||||||
import makeWASocket, { makeInMemoryStore } from '@adiwajshing/baileys'
|
import makeWASocket, { makeInMemoryStore } from '@whiskeysockets/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({ })
|
||||||
@@ -327,7 +327,7 @@ The store also provides some simple functions such as `loadMessages` that utiliz
|
|||||||
### Non-Media Messages
|
### Non-Media Messages
|
||||||
|
|
||||||
``` ts
|
``` ts
|
||||||
import { MessageType, MessageOptions, Mimetype } from '@adiwajshing/baileys'
|
import { MessageType, MessageOptions, Mimetype } from '@whiskeysockets/baileys'
|
||||||
|
|
||||||
const id = 'abcd@s.whatsapp.net' // the WhatsApp ID
|
const id = 'abcd@s.whatsapp.net' // the WhatsApp ID
|
||||||
// send a simple text!
|
// send a simple text!
|
||||||
@@ -445,7 +445,7 @@ Sending media (video, stickers, images) is easier & more efficient than ever.
|
|||||||
- When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
|
- When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
|
||||||
|
|
||||||
``` ts
|
``` ts
|
||||||
import { MessageType, MessageOptions, Mimetype } from '@adiwajshing/baileys'
|
import { MessageType, MessageOptions, Mimetype } from '@whiskeysockets/baileys'
|
||||||
// Sending gifs
|
// Sending gifs
|
||||||
await sock.sendMessage(
|
await sock.sendMessage(
|
||||||
id,
|
id,
|
||||||
@@ -527,7 +527,7 @@ const sendMsg = await sock.sendMessage(id, templateMessage)
|
|||||||
Do not enter this field if you want to automatically generate a thumb
|
Do not enter this field if you want to automatically generate a thumb
|
||||||
*/
|
*/
|
||||||
mimetype: Mimetype.pdf, /* (for media messages) specify the type of media (optional for all media types except documents),
|
mimetype: Mimetype.pdf, /* (for media messages) specify the type of media (optional for all media types except documents),
|
||||||
import {Mimetype} from '@adiwajshing/baileys'
|
import {Mimetype} from '@whiskeysockets/baileys'
|
||||||
*/
|
*/
|
||||||
fileName: 'somefile.pdf', // (for media messages) file name for the media
|
fileName: 'somefile.pdf', // (for media messages) file name for the media
|
||||||
/* will send audio messages as voice notes, if set to true */
|
/* will send audio messages as voice notes, if set to true */
|
||||||
@@ -586,7 +586,7 @@ The presence expires after about 10 seconds.
|
|||||||
If you want to save the media you received
|
If you want to save the media you received
|
||||||
``` ts
|
``` ts
|
||||||
import { writeFile } from 'fs/promises'
|
import { writeFile } from 'fs/promises'
|
||||||
import { downloadMediaMessage } from '@adiwajshing/baileys'
|
import { downloadMediaMessage } from '@whiskeysockets/baileys'
|
||||||
|
|
||||||
sock.ev.on('messages.upsert', async ({ messages }) => {
|
sock.ev.on('messages.upsert', async ({ messages }) => {
|
||||||
const m = messages[0]
|
const m = messages[0]
|
||||||
@@ -741,6 +741,11 @@ await sock.sendMessage(
|
|||||||
const jid = '111234567890-1594482450@g.us' // can be your own too
|
const jid = '111234567890-1594482450@g.us' // can be your own too
|
||||||
await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
|
await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
|
||||||
```
|
```
|
||||||
|
- To remove your display picture or a group's
|
||||||
|
``` ts
|
||||||
|
const jid = '111234567890-1594482450@g.us' // can be your own too
|
||||||
|
await sock.removeProfilePicture(jid)
|
||||||
|
```
|
||||||
- To get someone's presence (if they're typing or online)
|
- To get someone's presence (if they're typing or online)
|
||||||
``` ts
|
``` ts
|
||||||
// the presence update is fetched and called here
|
// the presence update is fetched and called here
|
||||||
@@ -832,7 +837,48 @@ Of course, replace ``` xyz ``` with an actual ID.
|
|||||||
console.log("joined to: " + response)
|
console.log("joined to: " + response)
|
||||||
```
|
```
|
||||||
Of course, replace ``` xxx ``` with invitation code.
|
Of course, replace ``` xxx ``` with invitation code.
|
||||||
|
|
||||||
|
## Privacy
|
||||||
|
- To get the privacy settings
|
||||||
|
``` ts
|
||||||
|
const privacySettings = await sock.fetchPrivacySettings(true)
|
||||||
|
console.log("privacy settings: " + privacySettings)
|
||||||
|
```
|
||||||
|
- To update the LastSeen privacy
|
||||||
|
``` ts
|
||||||
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
||||||
|
await sock.updateLastSeenPrivacy(value)
|
||||||
|
```
|
||||||
|
- To update the Online privacy
|
||||||
|
``` ts
|
||||||
|
const value = 'all' // 'match_last_seen'
|
||||||
|
await sock.updateOnlinePrivacy(value)
|
||||||
|
```
|
||||||
|
- To update the Profile Picture privacy
|
||||||
|
``` ts
|
||||||
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
||||||
|
await sock.updateProfilePicturePrivacy(value)
|
||||||
|
```
|
||||||
|
- To update the Status privacy
|
||||||
|
``` ts
|
||||||
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
||||||
|
await sock.updateStatusPrivacy(value)
|
||||||
|
```
|
||||||
|
- To update the Read Receipts privacy
|
||||||
|
``` ts
|
||||||
|
const value = 'all' // 'none'
|
||||||
|
await sock.updateReadReceiptsPrivacy(value)
|
||||||
|
```
|
||||||
|
- To update the Groups Add privacy
|
||||||
|
``` ts
|
||||||
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
||||||
|
await sock.updateGroupsAddPrivacy(value)
|
||||||
|
```
|
||||||
|
- To update the Default Disappearing Mode
|
||||||
|
``` ts
|
||||||
|
const duration = 86400 // 604800 | 7776000 | 0
|
||||||
|
await sock.updateDefaultDisappearingMode(duration)
|
||||||
|
```
|
||||||
## Broadcast Lists & Stories
|
## Broadcast Lists & Stories
|
||||||
|
|
||||||
**Note:** messages currently cannot be sent to broadcast lists from the MD version.
|
**Note:** messages currently cannot be sent to broadcast lists from the MD version.
|
||||||
|
|||||||
90
package.json
90
package.json
@@ -1,36 +1,44 @@
|
|||||||
{
|
{
|
||||||
"name": "@adiwajshing/baileys",
|
"name": "@whiskeysockets/baileys",
|
||||||
"version": "5.0.0",
|
"version": "6.0.0",
|
||||||
"description": "WhatsApp API",
|
"description": "WhatsApp API",
|
||||||
"homepage": "https://github.com/adiwajshing/Baileys",
|
|
||||||
"main": "lib/index.js",
|
|
||||||
"types": "lib/index.d.ts",
|
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"whatsapp",
|
"whatsapp",
|
||||||
"js-whatsapp",
|
"js-whatsapp",
|
||||||
"whatsapp-api",
|
"whatsapp-api",
|
||||||
"whatsapp-web",
|
"whatsapp-web",
|
||||||
"whatsapp",
|
|
||||||
"whatsapp-chat",
|
"whatsapp-chat",
|
||||||
"whatsapp-group",
|
"whatsapp-group",
|
||||||
"automation",
|
"automation",
|
||||||
"multi-device"
|
"multi-device"
|
||||||
],
|
],
|
||||||
|
"homepage": "https://github.com/WhiskeySockets/Baileys",
|
||||||
|
"repository": {
|
||||||
|
"url": "git@github.com:WhiskeySockets/Baileys.git"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"author": "Adhiraj Singh",
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"types": "lib/index.d.ts",
|
||||||
|
"files": [
|
||||||
|
"lib/*",
|
||||||
|
"WAProto/*",
|
||||||
|
"WASignalGroup/*.js"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest",
|
|
||||||
"prepare": "tsc",
|
|
||||||
"build:all": "tsc && typedoc",
|
"build:all": "tsc && typedoc",
|
||||||
"build:docs": "typedoc",
|
"build:docs": "typedoc",
|
||||||
"build:tsc": "tsc",
|
"build:tsc": "tsc",
|
||||||
|
"changelog:last": "conventional-changelog -p angular -r 2",
|
||||||
|
"changelog:preview": "conventional-changelog -p angular -u",
|
||||||
|
"changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
||||||
"example": "node --inspect -r ts-node/register Example/example.ts",
|
"example": "node --inspect -r ts-node/register Example/example.ts",
|
||||||
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
||||||
"lint": "eslint . --ext .js,.ts,.jsx,.tsx",
|
"lint": "eslint . --ext .js,.ts,.jsx,.tsx",
|
||||||
"lint:fix": "eslint . --fix --ext .js,.ts,.jsx,.tsx"
|
"lint:fix": "eslint . --fix --ext .js,.ts,.jsx,.tsx",
|
||||||
},
|
"prepare": "tsc",
|
||||||
"author": "Adhiraj Singh",
|
"release": "release-it",
|
||||||
"license": "MIT",
|
"test": "jest"
|
||||||
"repository": {
|
|
||||||
"url": "git@github.com:adiwajshing/baileys.git"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hapi/boom": "^9.1.3",
|
"@hapi/boom": "^9.1.3",
|
||||||
@@ -45,6 +53,27 @@
|
|||||||
"uuid": "^9.0.0",
|
"uuid": "^9.0.0",
|
||||||
"ws": "^8.0.0"
|
"ws": "^8.0.0"
|
||||||
},
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@adiwajshing/eslint-config": "https://github.com/adiwajshing/eslint-config.git",
|
||||||
|
"@adiwajshing/keyed-db": "^0.2.4",
|
||||||
|
"@types/got": "^9.6.11",
|
||||||
|
"@types/jest": "^27.5.1",
|
||||||
|
"@types/node": "^16.0.0",
|
||||||
|
"@types/sharp": "^0.29.4",
|
||||||
|
"@types/ws": "^8.0.0",
|
||||||
|
"conventional-changelog-cli": "^2.2.2",
|
||||||
|
"eslint": "^8.0.0",
|
||||||
|
"jest": "^27.0.6",
|
||||||
|
"jimp": "^0.16.1",
|
||||||
|
"link-preview-js": "^3.0.0",
|
||||||
|
"qrcode-terminal": "^0.12.0",
|
||||||
|
"release-it": "^15.10.3",
|
||||||
|
"sharp": "^0.30.5",
|
||||||
|
"ts-jest": "^27.0.3",
|
||||||
|
"ts-node": "^10.8.1",
|
||||||
|
"typedoc": "^0.22.0",
|
||||||
|
"typescript": "^4.0.0"
|
||||||
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@adiwajshing/keyed-db": "^0.2.4",
|
"@adiwajshing/keyed-db": "^0.2.4",
|
||||||
"jimp": "^0.16.1",
|
"jimp": "^0.16.1",
|
||||||
@@ -59,40 +88,15 @@
|
|||||||
"jimp": {
|
"jimp": {
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
|
"link-preview-js": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"qrcode-terminal": {
|
"qrcode-terminal": {
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"sharp": {
|
"sharp": {
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
|
||||||
"link-preview-js": {
|
|
||||||
"optional": true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"packageManager": "yarn@1.22.19"
|
||||||
"lib/*",
|
|
||||||
"WAProto/*",
|
|
||||||
"WASignalGroup/*.js"
|
|
||||||
],
|
|
||||||
"devDependencies": {
|
|
||||||
"@adiwajshing/eslint-config": "https://github.com/adiwajshing/eslint-config.git",
|
|
||||||
"@adiwajshing/keyed-db": "^0.2.4",
|
|
||||||
"@types/got": "^9.6.11",
|
|
||||||
"@types/jest": "^27.5.1",
|
|
||||||
"@types/node": "^16.0.0",
|
|
||||||
"@types/sharp": "^0.29.4",
|
|
||||||
"@types/uuid": "^9.0.0",
|
|
||||||
"@types/ws": "^8.0.0",
|
|
||||||
"eslint": "^8.0.0",
|
|
||||||
"jest": "^27.0.6",
|
|
||||||
"jimp": "^0.16.1",
|
|
||||||
"link-preview-js": "^3.0.0",
|
|
||||||
"pino-pretty": "^9.4.0",
|
|
||||||
"qrcode-terminal": "^0.12.0",
|
|
||||||
"sharp": "^0.30.5",
|
|
||||||
"ts-jest": "^27.0.3",
|
|
||||||
"ts-node": "^10.8.1",
|
|
||||||
"typedoc": "^0.22.0",
|
|
||||||
"typescript": "^4.0.0"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Boom } from '@hapi/boom'
|
import { Boom } from '@hapi/boom'
|
||||||
import { proto } from '../../WAProto'
|
import { proto } from '../../WAProto'
|
||||||
import { PROCESSABLE_HISTORY_TYPES } from '../Defaults'
|
import { PROCESSABLE_HISTORY_TYPES } from '../Defaults'
|
||||||
import { ALL_WA_PATCH_NAMES, ChatModification, ChatMutation, LTHashState, MessageUpsertType, PresenceData, SocketConfig, WABusinessHoursConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPatchName, WAPresence } from '../Types'
|
import { ALL_WA_PATCH_NAMES, ChatModification, ChatMutation, LTHashState, MessageUpsertType, PresenceData, SocketConfig, WABusinessHoursConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPatchName, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types'
|
||||||
import { chatModificationToAppPatch, ChatMutationMap, decodePatches, decodeSyncdSnapshot, encodeSyncdPatch, extractSyncdPatches, generateProfilePicture, getHistoryMsg, newLTHashState, processSyncAction } from '../Utils'
|
import { chatModificationToAppPatch, ChatMutationMap, decodePatches, decodeSyncdSnapshot, encodeSyncdPatch, extractSyncdPatches, generateProfilePicture, getHistoryMsg, newLTHashState, processSyncAction } from '../Utils'
|
||||||
import { makeMutex } from '../Utils/make-mutex'
|
import { makeMutex } from '../Utils/make-mutex'
|
||||||
import processMessage from '../Utils/process-message'
|
import processMessage from '../Utils/process-message'
|
||||||
@@ -61,6 +61,69 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
|||||||
return privacySettings
|
return privacySettings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** helper function to run a privacy IQ query */
|
||||||
|
const privacyQuery = async(name: string, value: string) => {
|
||||||
|
await query({
|
||||||
|
tag: 'iq',
|
||||||
|
attrs: {
|
||||||
|
xmlns: 'privacy',
|
||||||
|
to: S_WHATSAPP_NET,
|
||||||
|
type: 'set'
|
||||||
|
},
|
||||||
|
content: [{
|
||||||
|
tag: 'privacy',
|
||||||
|
attrs: {},
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
tag: 'category',
|
||||||
|
attrs: { name, value }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateLastSeenPrivacy = async(value: WAPrivacyValue) => {
|
||||||
|
await privacyQuery('last', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateOnlinePrivacy = async(value: WAPrivacyOnlineValue) => {
|
||||||
|
await privacyQuery('online', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateProfilePicturePrivacy = async(value: WAPrivacyValue) => {
|
||||||
|
await privacyQuery('profile', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateStatusPrivacy = async(value: WAPrivacyValue) => {
|
||||||
|
await privacyQuery('status', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateReadReceiptsPrivacy = async(value: WAReadReceiptsValue) => {
|
||||||
|
await privacyQuery('readreceipts', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateGroupsAddPrivacy = async(value: WAPrivacyValue) => {
|
||||||
|
await privacyQuery('groupadd', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateDefaultDisappearingMode = async(duration: number) => {
|
||||||
|
await query({
|
||||||
|
tag: 'iq',
|
||||||
|
attrs: {
|
||||||
|
xmlns: 'disappearing_mode',
|
||||||
|
to: S_WHATSAPP_NET,
|
||||||
|
type: 'set'
|
||||||
|
},
|
||||||
|
content: [{
|
||||||
|
tag: 'disappearing_mode',
|
||||||
|
attrs: {
|
||||||
|
duration : duration.toString()
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** helper function to run a generic IQ query */
|
/** helper function to run a generic IQ query */
|
||||||
const interactiveQuery = async(userNodes: BinaryNode[], queryNode: BinaryNode) => {
|
const interactiveQuery = async(userNodes: BinaryNode[], queryNode: BinaryNode) => {
|
||||||
const result = await query({
|
const result = await query({
|
||||||
@@ -161,6 +224,18 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** remove the profile picture for yourself or a group */
|
||||||
|
const removeProfilePicture = async(jid: string) => {
|
||||||
|
await query({
|
||||||
|
tag: 'iq',
|
||||||
|
attrs: {
|
||||||
|
to: jidNormalizedUser(jid),
|
||||||
|
type: 'set',
|
||||||
|
xmlns: 'w:profile:picture'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** update the profile status for yourself */
|
/** update the profile status for yourself */
|
||||||
const updateProfileStatus = async(status: string) => {
|
const updateProfileStatus = async(status: string) => {
|
||||||
await query({
|
await query({
|
||||||
@@ -857,9 +932,17 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
|||||||
fetchBlocklist,
|
fetchBlocklist,
|
||||||
fetchStatus,
|
fetchStatus,
|
||||||
updateProfilePicture,
|
updateProfilePicture,
|
||||||
|
removeProfilePicture,
|
||||||
updateProfileStatus,
|
updateProfileStatus,
|
||||||
updateProfileName,
|
updateProfileName,
|
||||||
updateBlockStatus,
|
updateBlockStatus,
|
||||||
|
updateLastSeenPrivacy,
|
||||||
|
updateOnlinePrivacy,
|
||||||
|
updateProfilePicturePrivacy,
|
||||||
|
updateStatusPrivacy,
|
||||||
|
updateReadReceiptsPrivacy,
|
||||||
|
updateGroupsAddPrivacy,
|
||||||
|
updateDefaultDisappearingMode,
|
||||||
getBusinessProfile,
|
getBusinessProfile,
|
||||||
resyncAppState,
|
resyncAppState,
|
||||||
chatModify
|
chatModify
|
||||||
|
|||||||
@@ -3,6 +3,13 @@ import type { AccountSettings } from './Auth'
|
|||||||
import type { BufferedEventData } from './Events'
|
import type { BufferedEventData } from './Events'
|
||||||
import type { MinimalMessage } from './Message'
|
import type { MinimalMessage } from './Message'
|
||||||
|
|
||||||
|
/** privacy settings in WhatsApp Web */
|
||||||
|
export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none'
|
||||||
|
|
||||||
|
export type WAPrivacyOnlineValue = 'all' | 'match_last_seen'
|
||||||
|
|
||||||
|
export type WAReadReceiptsValue = 'all' | 'none'
|
||||||
|
|
||||||
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
|
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
|
||||||
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused'
|
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused'
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ type Mentionable = {
|
|||||||
type ViewOnce = {
|
type ViewOnce = {
|
||||||
viewOnce?: boolean
|
viewOnce?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
type Buttonable = {
|
type Buttonable = {
|
||||||
/** add buttons to the message */
|
/** add buttons to the message */
|
||||||
buttons?: proto.Message.ButtonsMessage.IButton[]
|
buttons?: proto.Message.ButtonsMessage.IButton[]
|
||||||
@@ -65,6 +66,9 @@ type Templatable = {
|
|||||||
|
|
||||||
footer?: string
|
footer?: string
|
||||||
}
|
}
|
||||||
|
type Editable = {
|
||||||
|
edit?: WAMessageKey
|
||||||
|
}
|
||||||
type Listable = {
|
type Listable = {
|
||||||
/** Sections of the List */
|
/** Sections of the List */
|
||||||
sections?: proto.Message.ListMessage.ISection[]
|
sections?: proto.Message.ListMessage.ISection[]
|
||||||
@@ -117,7 +121,7 @@ export type AnyMediaMessageContent = (
|
|||||||
fileName?: string
|
fileName?: string
|
||||||
caption?: string
|
caption?: string
|
||||||
} & Buttonable & Templatable))
|
} & Buttonable & Templatable))
|
||||||
& { mimetype?: string }
|
& { mimetype?: string } & Editable
|
||||||
|
|
||||||
export type ButtonReplyInfo = {
|
export type ButtonReplyInfo = {
|
||||||
displayText: string
|
displayText: string
|
||||||
@@ -134,11 +138,11 @@ export type AnyRegularMessageContent = (
|
|||||||
text: string
|
text: string
|
||||||
linkPreview?: WAUrlInfo | null
|
linkPreview?: WAUrlInfo | null
|
||||||
}
|
}
|
||||||
& Mentionable & Buttonable & Templatable & Listable)
|
& Mentionable & Buttonable & Templatable & Listable & Editable)
|
||||||
| AnyMediaMessageContent
|
| AnyMediaMessageContent
|
||||||
| ({
|
| ({
|
||||||
poll: PollMessageOptions
|
poll: PollMessageOptions
|
||||||
} & Mentionable & Buttonable & Templatable)
|
} & Mentionable & Buttonable & Templatable & Editable)
|
||||||
| {
|
| {
|
||||||
contacts: {
|
contacts: {
|
||||||
displayName?: string
|
displayName?: string
|
||||||
|
|||||||
@@ -488,6 +488,16 @@ export const generateWAMessageContent = async(
|
|||||||
m[messageType].contextInfo.mentionedJid = message.mentions
|
m[messageType].contextInfo.mentionedJid = message.mentions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if('edit' in message) {
|
||||||
|
m = {
|
||||||
|
protocolMessage: {
|
||||||
|
key: message.edit,
|
||||||
|
editedMessage: m,
|
||||||
|
type: WAProto.Message.ProtocolMessage.Type.MESSAGE_EDIT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return WAProto.Message.fromObject(m)
|
return WAProto.Message.fromObject(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -886,4 +896,4 @@ export const assertMediaContent = (content: proto.IMessage | null | undefined) =
|
|||||||
}
|
}
|
||||||
|
|
||||||
return mediaContent
|
return mediaContent
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user