Compare commits

..
12 Commits
Author SHA1 Message Date
devlikepro 176c2bbd4c [core] 2025.1.5
Release / WEBJS - chrome - amd64 - chrome (push) Waiting to run
Release / WEBJS - chromium - amd64 - latest (push) Waiting to run
Release / WEBJS - chromium - linux/arm64 - arm (push) Waiting to run
Release / GOWS - none - amd64 - gows (push) Waiting to run
Release / GOWS - none - linux/arm64 - gows-arm (push) Waiting to run
Release / NOWEB - none - amd64 - noweb (push) Waiting to run
Release / NOWEB - none - linux/arm64 - noweb-arm (push) Waiting to run
2025-01-21 11:57:40 +07:00
devlikepro 7771954455 [core] build proto on package install 2025-01-21 11:57:28 +07:00
devlikepro a66743bb20 [core] rm old scripts 2025-01-21 11:57:27 +07:00
devlikepro 851c7b75f9 [core] GOWS Channels 2025-01-21 11:57:26 +07:00
devlikepro ed0b406027 [core] GOWS Send Status 2025-01-21 11:57:26 +07:00
devlikepro 71985972a2 [core] GOWS check exists 2025-01-21 11:57:26 +07:00
devlikepro 2dbeef9290 [core] font 0 by default in status 2025-01-21 11:57:25 +07:00
devlikepro a79453270d [core] WEBJS handle status 2025-01-21 11:57:25 +07:00
devlikepro ae71808c61 [core] ws heartbeat do not return after closing one client 2025-01-21 11:57:25 +07:00
devlikepro 5c195ba37b [core] ws 60 seconds heartbeat 2025-01-21 11:57:24 +07:00
devlikepro 607ee17a86 [core] perf tests 2025-01-21 11:57:23 +07:00
devlikepro a15aacc5b3 [core] perf tests 2025-01-21 11:57:23 +07:00
23 changed files with 510 additions and 155 deletions

No files matched your search

+1
View File
@@ -1,5 +1,6 @@
Dockerfile
src/core/engines/gows/grpc
src/core/engines/gows/proto
.*sessions
sessions
files
+1
View File
@@ -1 +1,2 @@
src/core/engines/gows/grpc/*
src/core/engines/gows/proto/*
+1
View File
@@ -1,4 +1,5 @@
src/core/engines/gows/grpc
src/core/engines/gows/proto
.env
*.heapsnapshot
.yarn
+3
View File
@@ -3,6 +3,7 @@ exclude: |
^src/dashboard/.*|
^src/core/engines/webjs/.*html|
^src/core/engines/gows/grpc/.*|
^src/core/engines/gows/proto/.*|
^src/plus/engines/webjs/.*html|
^.yarn/.*
)$
@@ -74,4 +75,6 @@ repos:
.pre-commit-config.yaml|
^src/core/engines/webjs/session.webjs.core.ts|
^src/core/engines/webjs/_lodash.js|
^tests/perf/.*|
^scripts/.*|
)$
+21 -31
View File
@@ -1,9 +1,3 @@
# GOWS
ARG GOWS_GITHUB_REPO=devlikeapro/gows
ARG GOWS_SHA=39ba4dcceeeb6e6fab172ee71ad1c09deea4db16
ARG WAHA_DASHBOARD_GITHUB_REPO=devlikeapro/dashboard
ARG WAHA_DASHBOARD_SHA=a1c839d8da94d1cade182addffdfc42fc0cf7ed3
#
# Build
#
@@ -11,12 +5,8 @@ ARG NODE_VERSION=22.8-bullseye
FROM node:${NODE_VERSION} AS build
ENV PUPPETEER_SKIP_DOWNLOAD=True
# install protoc
RUN apt-get update && \
apt-get install protobuf-compiler -y
# npm packages
WORKDIR /src
WORKDIR /git
COPY package.json .
COPY yarn.lock .
ENV YARN_CHECKSUM_BEHAVIOR=update
@@ -25,19 +15,10 @@ RUN yarn set version 3.6.3
RUN yarn install
# App
WORKDIR /src
ADD . /src
WORKDIR /git
ADD . /git
RUN yarn install
# Build node grpc client for GOWS engine
WORKDIR /gows/proto
ARG GOWS_GITHUB_REPO
ARG GOWS_SHA
RUN wget https://raw.githubusercontent.com/${GOWS_GITHUB_REPO}/${GOWS_SHA}/proto/gows.proto
WORKDIR /src
RUN make proto-gows
RUN yarn gows:proto
RUN yarn build && find ./dist -name "*.d.ts" -delete
#
@@ -45,10 +26,13 @@ RUN yarn build && find ./dist -name "*.d.ts" -delete
#
FROM node:${NODE_VERSION} AS dashboard
# Download WAHA Dashboard
ARG WAHA_DASHBOARD_GITHUB_REPO
ARG WAHA_DASHBOARD_SHA
# jq to parse json
RUN apt-get update && apt-get install -y jq && rm -rf /var/lib/apt/lists/*
COPY waha.config.json /tmp/waha.config.json
RUN \
WAHA_DASHBOARD_GITHUB_REPO=$(jq -r '.waha.dashboard.repo' /tmp/waha.config.json) && \
WAHA_DASHBOARD_SHA=$(jq -r '.waha.dashboard.ref' /tmp/waha.config.json) && \
wget https://github.com/${WAHA_DASHBOARD_GITHUB_REPO}/archive/${WAHA_DASHBOARD_SHA}.zip \
&& unzip ${WAHA_DASHBOARD_SHA}.zip -d /tmp/dashboard \
&& mkdir -p /dashboard \
@@ -60,6 +44,10 @@ RUN \
# GOWS
#
FROM golang:1.23-bullseye AS gows
# jq to parse json
RUN apt-get update && apt-get install -y jq && rm -rf /var/lib/apt/lists/*
# install protoc
RUN apt-get update && \
apt-get install protobuf-compiler -y
@@ -69,9 +57,11 @@ RUN apt-get update \
&& apt-get install -y libvips-dev \
&& rm -rf /var/lib/apt/lists/*
ARG GOWS_GITHUB_REPO
ARG GOWS_SHA
RUN git clone https://github.com/${GOWS_GITHUB_REPO} gows && \
COPY waha.config.json /tmp/waha.config.json
RUN \
GOWS_GITHUB_REPO=$(jq -r '.waha.gows.repo' /tmp/waha.config.json) && \
GOWS_SHA=$(jq -r '.waha.gows.ref' /tmp/waha.config.json) && \
git clone https://github.com/${GOWS_GITHUB_REPO} gows && \
cd gows && \
git checkout ${GOWS_SHA}
@@ -163,8 +153,8 @@ ENV WHATSAPP_DEFAULT_ENGINE=$WHATSAPP_DEFAULT_ENGINE
# Attach sources, install packages
WORKDIR /app
COPY package.json ./
COPY --from=build /src/node_modules ./node_modules
COPY --from=build /src/dist ./dist
COPY --from=build /git/node_modules ./node_modules
COPY --from=build /git/dist ./dist
COPY --from=dashboard /dashboard ./dist/dashboard
COPY --from=gows /go/gows/bin/gows /app/gows
ENV WAHA_GOWS_PATH /app/gows
+1 -9
View File
@@ -47,15 +47,7 @@ start-proxy:
docker run --rm -d --name squid-container -e TZ=UTC -p 3128:3128 ubuntu/squid:5.2-22.04_beta
proto-gows:
rm -rf src/core/engines/gows/grpc
mkdir -p src/core/engines/gows/grpc
protoc \
--plugin=protoc-gen-ts=node_modules/.bin/protoc-gen-ts \
--plugin=protoc-gen-grpc=node_modules/.bin/grpc_tools_node_protoc_plugin \
--js_out=import_style=commonjs,binary:src/core/engines/gows/grpc \
--grpc_out=grpc_js:src/core/engines/gows/grpc \
--ts_out=grpc_js:src/core/engines/gows/grpc \
-I ../gows/proto ../gows/proto/gows.proto
node scripts/gows-proto.js build --dir ../gows/proto
gows:
cd ../gows && \
+20 -58
View File
@@ -9,19 +9,13 @@
[![Docker Pulls](https://img.shields.io/docker/pulls/devlikeapro/whatsapp-http-api)](https://hub.docker.com/r/devlikeapro/waha)
- Documentation: [https://waha.devlike.pro/](https://waha.devlike.pro/)
- Dashboard Example: [https://waha.devlike.pro/dashboard](https://waha.devlike.pro/dashboard)
- Swagger Example: [https://waha.devlike.pro/swagger](https://waha.devlike.pro/swagger)
# Tables of Contents
<!-- toc -->
- [Features](#features)
* [Messages](#messages)
* [Sessions](#sessions)
* [Security](#security)
* [Updates](#updates)
* [Groups](#groups)
* [Contacts](#contacts)
- [Quick start](#quick-start)
* [Requirements](#requirements)
* [Send your first message](#send-your-first-message)
@@ -32,52 +26,11 @@
+ [5. Get the screenshot](#5-get-the-screenshot)
+ [6. Send a text message](#6-send-a-text-message)
* [What is next?](#what-is-next)
- [Development](#development)
* [Start the project](#start-the-project)
<!-- tocstop -->
# Features
## Messages
- Send messages
- Receive messages
- Message replies
- Send location
- Receive location
- React to messages
- Send media (images/documents/files)
- Send voice messages
- Receive media (images/audio/video/documents)
- Receive messages - webhook retries
## Sessions
- Multi Device
- Get the screenshot
- Session saving (don't have to scan QR on every restart)
- Single WhatsApp account running inside one container
- Multiple WhatsApp account running inside one container
## Security
- Swagger panel authentication
- API authentication
## Updates
- Bug fixes and updates come as soon as they are implemented.
## Groups
- Create a group
- Get invite for group
- Modify group info (subject, description)
- Add group participants
- Kick group participants
- Promote/demote group participants
## Contacts
- Mute/unmute chats
- Block/unblock contacts
- Get contact info
- Get profile pictures
- Get presence (online\offline\typing) status
# Quick start
## Requirements
@@ -87,13 +40,6 @@ instruction <a href="https://docs.docker.com/get-docker/" target="_blank" rel="n
When you are ready - come back and follows the below steps to send the first text message to WhatsApp via HTTP API!
{{< details "Why Docker?" >}}
Docker makes it easy to ship all-in-one solution with the runtime and dependencies. You don't have to worry about
language-specific libraries or chrome installation.
Also Docker makes installation and update processes so simple, just one command!
{{< /details >}}
## Send your first message
Let's go over steps that allow you to send your first text message via WhatsApp HTTP API!
@@ -114,7 +60,7 @@ docker pull devlikeapro/waha-plus
docker logout
```
Read more about how to get `PASSWORD` for [Plus Version →]({{< relref "plus-version" >}})
Read more about how to get `PASSWORD` for [**➕ WAHA Plus**](https://waha.devlike.pro/docs/how-to/waha-plus/)
### 2. Run WhatsApp HTTP API
@@ -195,3 +141,19 @@ curl -d "{\"chatId\": \"${PHONE}@c.us\", \"text\": \"Hello from WhatsApp HTTP AP
## What is next?
[Go and read the full documentation!](https://waha.devlike.pro/docs/overview/introduction/)
# Development
## Start the project
1. Clone the repository
2. Make sure you're using node>=22
3. Run the following commands:
```bash
# Install dependencies
yarn install
# Fetch and compile proto files
yarn gows:proto
# Run
yarn start
# open http://localhost:3000
```
+6 -2
View File
@@ -20,7 +20,10 @@
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
"test:e2e": "jest --config ./test/jest-e2e.json",
"gows:proto:fetch": "node scripts/gows-proto.js fetch",
"gows:proto:build": "node scripts/gows-proto.js build",
"gows:proto": "yarn gows:proto:fetch && yarn gows:proto:build"
},
"dependencies": {
"@adiwajshing/baileys": "github:devlikeapro/Baileys#fork-master-channels-678",
@@ -120,7 +123,8 @@
"ts-loader": "^6.2.1",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.0",
"typescript": "^4.8.4"
"typescript": "^4.8.4",
"yargs": "^17.7.2"
},
"jest": {
"moduleFileExtensions": [
+144
View File
@@ -0,0 +1,144 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const axios = require('axios');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { execSync } = require('child_process');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const yargs = require('yargs');
// Defaults
const CONFIG_FILE = 'waha.config.json';
// Load defaults from package.json
gows = (() => {
try {
const config = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
return config.waha.gows || {};
} catch (error) {
return {};
}
})();
const DEFAULT_REPO = gows.repo;
if (!DEFAULT_REPO) {
throw new Error(`Missing default repo in ${CONFIG_FILE}`);
}
const DEFAULT_REF = gows.ref;
if (!DEFAULT_REF) {
throw new Error('Missing default ref in ${CONFIG_FILE}');
}
const DEFAULT_DIR = './src/core/engines/gows/proto';
const PROTO_FILES = ['gows.proto'];
const PROTO_OUTPUT = './src/core/engines/gows/grpc';
// Helper function to clean directory
function cleanDirectory(directory, suffix) {
if (!fs.existsSync(directory)) {
fs.mkdirSync(directory, { recursive: true });
return;
}
const files = fs.readdirSync(directory);
for (const file of files) {
const filePath = path.join(directory, file);
if (file.endsWith(suffix)) {
fs.unlinkSync(filePath);
}
}
}
// Helper function to download files
async function downloadFiles(repo, ref, directory) {
for (const file of PROTO_FILES) {
const url = `https://raw.githubusercontent.com/${repo}/${ref}/proto/${file}`;
const filePath = path.join(directory, file);
try {
const response = await axios.get(url, { responseType: 'arraybuffer' });
fs.writeFileSync(filePath, response.data);
console.log(`Downloaded: ${file}`);
} catch (error) {
console.error(`Failed to download ${file}: ${error.message}`);
}
}
}
// Handler for fetch command
async function handleFetch(repo, ref, dir) {
console.log(`Fetching .proto files from ${repo}@${ref} to ${dir}...`);
cleanDirectory(dir, '.proto');
await downloadFiles(repo, ref, dir);
}
// Handler for build command
function handleBuild(dir) {
console.log('Building gRPC files...');
cleanDirectory(PROTO_OUTPUT);
const command = `grpc_tools_node_protoc \
--plugin=protoc-gen-ts=node_modules/.bin/protoc-gen-ts \
--plugin=protoc-gen-grpc=node_modules/.bin/grpc_tools_node_protoc_plugin \
--js_out=import_style=commonjs,binary:${PROTO_OUTPUT} \
--grpc_out=grpc_js:${PROTO_OUTPUT} \
--ts_out=grpc_js:${PROTO_OUTPUT} \
-I ${dir} ${dir}/gows.proto`;
try {
execSync(command, { stdio: 'inherit' });
console.log('gRPC files built successfully.');
} catch (error) {
console.error(`Failed to build gRPC files: ${error.message}`);
}
}
//
// Commands
//
// fetch
yargs.command(
'fetch',
'Fetch .proto files from GitHub',
(yargs) => {
yargs
.option('repo', {
describe: 'GitHub repository (owner/repo)',
type: 'string',
default: DEFAULT_REPO,
})
.option('ref', {
describe: 'Git reference (branch or commit SHA)',
type: 'string',
default: DEFAULT_REF,
})
.option('dir', {
describe: 'Directory to output .proto files',
type: 'string',
default: DEFAULT_DIR,
});
},
async (argv) => {
await handleFetch(argv.repo, argv.ref, argv.dir);
},
);
// build
yargs.command(
'build',
'Build gRPC files from .proto files',
(yargs) => {
yargs.option('dir', {
describe: 'Directory containing .proto files',
type: 'string',
default: DEFAULT_DIR,
});
},
(argv) => {
handleBuild(argv.dir);
},
);
// Parse arguments
yargs.parse();
-22
View File
@@ -1,22 +0,0 @@
#!/bin/bash
set -e
echo "Starting WAHA..."
docker run -d \
--restart=always \
--name waha \
-p 3000:3000/tcp \
-v ./.sessions:/app/.sessions \
-v ./.media:/app/.media \
--env WHATSAPP_API_KEY=321 \
--env WAHA_DASHBOARD_USERNAME=waha \
--env WAHA_DASHBOARD_PASSWORD=waha \
--env WAHA_LOG_FORMAT=JSON \
--env WAHA_LOG_LEVEL=info \
--env WHATSAPP_DEFAULT_ENGINE=WEBJS \
--env WAHA_PRINT_QR=False \
--env WHATSAPP_FILES_LIFETIME=0 \
--env WHATSAPP_FILES_FOLDER=/app/.media \
devlikeapro/waha-plus:latest
echo "WAHA started."
-21
View File
@@ -1,21 +0,0 @@
set -e
echo "Updating WAHA..."
echo "Logging in to Docker..."
docker login -u devlikeapro # -p {KEY} - you can hard code key here https://portal.devlike.pro/
echo "Pulling the latest image..."
docker pull devlikeapro/waha-plus
echo "Logging out of Docker..."
docker logout
# Just pull if you're using WAHA Core
# docker pull devlikeapro/waha
echo "Stopping the current container..."
docker stop waha || true
echo "Removing the current container..."
docker rm waha || true
echo "Running WAHA..."
sh ./waha-run.sh
+1 -1
View File
@@ -32,7 +32,7 @@ export class WebsocketGatewayCore
OnGatewayDisconnect,
BeforeApplicationShutdown
{
HEARTBEAT_INTERVAL = 10_000;
HEARTBEAT_INTERVAL = 60_000;
@WebSocketServer()
server: Server;
+3
View File
@@ -0,0 +1,3 @@
export enum Jid {
BROADCAST = 'status@broadcast',
}
+175 -6
View File
@@ -1,8 +1,17 @@
import { isJidGroup, jidNormalizedUser } from '@adiwajshing/baileys';
import {
getUrlFromDirectPath,
isJidGroup,
isJidStatusBroadcast,
jidNormalizedUser,
} from '@adiwajshing/baileys';
import * as grpc from '@grpc/grpc-js';
import { connectivityState } from '@grpc/grpc-js';
import { UnprocessableEntityException } from '@nestjs/common';
import { WhatsappSession } from '@waha/core/abc/session.abc';
import {
getChannelInviteLink,
WhatsappSession,
} from '@waha/core/abc/session.abc';
import { Jid } from '@waha/core/engines/const';
import { EventsFromObservable } from '@waha/core/engines/gows/EventsFromObservable';
import { GowsEventStreamObservable } from '@waha/core/engines/gows/GowsEventStreamObservable';
import { messages } from '@waha/core/engines/gows/grpc/gows';
@@ -12,9 +21,18 @@ import {
toCusFormat,
toJID,
} from '@waha/core/engines/noweb/session.noweb.core';
import { AvailableInPlusVersion } from '@waha/core/exceptions';
import {
AvailableInPlusVersion,
NotImplementedByEngineError,
} from '@waha/core/exceptions';
import { IMediaEngineProcessor } from '@waha/core/media/IMediaEngineProcessor';
import { QR } from '@waha/core/QR';
import {
Channel,
ChannelRole,
CreateChannelRequest,
ListChannelsQuery,
} from '@waha/structures/channels.dto';
import {
ChatRequest,
CheckNumberStatusQuery,
@@ -27,6 +45,7 @@ import {
MessageTextRequest,
MessageVoiceRequest,
SendSeenRequest,
WANumberExistResult,
} from '@waha/structures/chatting.dto';
import {
ACK_UNKNOWN,
@@ -41,6 +60,7 @@ import {
} from '@waha/structures/presence.dto';
import { WAMessage, WAMessageReaction } from '@waha/structures/responses.dto';
import { MeInfo, ProxyConfig } from '@waha/structures/sessions.dto';
import { StatusRequest, TextStatus } from '@waha/structures/status.dto';
import { EnginePayload, WAMessageAckBody } from '@waha/structures/webhooks.dto';
import { sleep, waitUntil } from '@waha/utils/promiseTimeout';
import { onlyEvent } from '@waha/utils/reactive/ops/onlyEvent';
@@ -402,11 +422,38 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
return this.messageResponse(jid, data);
}
protected checkStatusRequest(request: StatusRequest) {
if (request.contacts && request.contacts?.length > 0) {
const msg =
"GOWS doesn't accept 'contacts'. Remove the field to send status to all contacts.";
throw new UnprocessableEntityException(msg);
}
}
public async sendTextStatus(status: TextStatus) {
this.checkStatusRequest(status);
const message = new messages.MessageRequest({
jid: Jid.BROADCAST,
text: status.text,
session: this.session,
backgroundColor: new messages.OptionalString({
value: status.backgroundColor,
}),
font: new messages.OptionalUInt32({
value: status.font,
}),
});
const response = await promisify(this.client.SendMessage)(message);
const data = response.toObject();
return this.messageResponse(Jid.BROADCAST, data);
}
protected messageResponse(jid, data) {
const id = buildMessageId({
ID: data.id,
IsFromMe: true,
IsGroup: isJidGroup(jid),
IsGroup: isJidGroup(jid) || isJidStatusBroadcast(jid),
Chat: jid,
Sender: this.me.id,
});
@@ -416,8 +463,20 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
};
}
checkNumberStatus(request: CheckNumberStatusQuery) {
throw new Error('Method not implemented.');
async checkNumberStatus(
request: CheckNumberStatusQuery,
): Promise<WANumberExistResult> {
const req = new messages.CheckPhonesRequest({
session: this.session,
phones: [request.phone],
});
const response = await promisify(this.client.CheckPhones)(req);
const data = response.toObject();
const info = data.infos[0];
return {
numberExists: info.registered,
chatId: toCusFormat(info.jid),
};
}
sendLocation(request: MessageLocationRequest) {
@@ -606,6 +665,116 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
};
}
/**
* Channels methods
*/
protected toChannel(newsletter: messages.Newsletter): Channel {
const role: ChannelRole =
(newsletter.role?.toUpperCase() as ChannelRole) || ChannelRole.GUEST;
let picture = newsletter.picture;
if (picture.startsWith('/')) {
picture = getUrlFromDirectPath(picture);
}
let preview = newsletter.preview;
if (preview.startsWith('/')) {
preview = getUrlFromDirectPath(preview);
}
return {
id: newsletter.id,
name: newsletter.name,
description: newsletter.description,
invite: getChannelInviteLink(newsletter.invite),
picture: picture,
preview: preview,
verified: newsletter.verified,
role: role,
};
}
public async channelsList(query: ListChannelsQuery): Promise<Channel[]> {
const request = new messages.NewsletterListRequest({
session: this.session,
});
const response = await promisify(this.client.GetSubscribedNewsletters)(
request,
);
const data = response.toObject();
const newsletters = data.newsletters;
let channels: Channel[] = newsletters.map(this.toChannel.bind(this));
if (query.role) {
// @ts-ignore
channels = channels.filter((channel) => channel.role === query.role);
}
return channels;
}
public async channelsCreateChannel(
request: CreateChannelRequest,
): Promise<Channel> {
const req = new messages.CreateNewsletterRequest({
session: this.session,
name: request.name,
description: request.description,
});
const response = await promisify(this.client.CreateNewsletter)(req);
const newsletter = response.toObject() as messages.Newsletter;
return this.toChannel(newsletter);
}
public async channelsGetChannel(id: string): Promise<Channel> {
return await this.channelsGetChannelByInviteCode(id);
}
public async channelsGetChannelByInviteCode(
inviteCode: string,
): Promise<Channel> {
const request = new messages.NewsletterInfoRequest({
session: this.session,
id: inviteCode,
});
const response = await promisify(this.client.GetNewsletterInfo)(request);
const newsletter = response.toObject() as messages.Newsletter;
return this.toChannel(newsletter);
}
public channelsFollowChannel(id: string): Promise<any> {
return this.channelsToggleFollow(id, true);
}
public channelsUnfollowChannel(id: string): Promise<any> {
return this.channelsToggleFollow(id, false);
}
protected async channelsToggleFollow(id: string, follow: boolean) {
const request = new messages.NewsletterToggleFollowRequest({
session: this.session,
jid: id,
follow: follow,
});
const response = await promisify(this.client.NewsletterToggleFollow)(
request,
);
return response.toObject();
}
public channelsMuteChannel(id: string): Promise<void> {
return this.channelsToggleMute(id, true);
}
public channelsUnmuteChannel(id: string): Promise<void> {
return this.channelsToggleMute(id, false);
}
protected async channelsToggleMute(id: string, mute: boolean): Promise<any> {
const request = new messages.NewsletterToggleMuteRequest({
session: this.session,
jid: id,
mute: mute,
});
const response = await promisify(this.client.NewsletterToggleMute)(request);
return response.toObject();
}
//
// END - Methods for API
//
+1 -1
View File
@@ -1054,7 +1054,7 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
* Status methods
*/
protected checkStatusRequest(request: StatusRequest) {
if (request.contacts?.length > 0) {
if (request.contacts && request.contacts?.length > 0) {
const msg =
"WEBJS doesn't accept 'contacts'. Remove the field to send status to all contacts.";
throw new UnprocessableEntityException(msg);
+1 -1
View File
@@ -22,7 +22,7 @@ export class WebsocketHeartbeatJob {
this.logger.debug(
`Terminating client connection due to heartbeat timeout, ${client.id}`,
);
return client.terminate();
client.terminate();
}
client.isAlive = false;
+1 -1
View File
@@ -24,7 +24,7 @@ export interface StatusRequest {
export class TextStatus {
text: string = 'Have a look! https://github.com/';
backgroundColor: string = '#38b42f';
font: number = 1;
font: number = 0;
@ContactsProperty
contacts?: string[];
+1 -1
View File
@@ -33,7 +33,7 @@ export function getEngineName(): string {
}
export const VERSION: WAHAEnvironment = {
version: '2025.1.4',
version: '2025.1.5',
engine: getEngineName(),
tier: getWAHAVersion(),
browser: getBrowserExecutablePath(),
+59
View File
@@ -0,0 +1,59 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const axios = require('axios');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const yargs = require('yargs/yargs');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { hideBin } = require('yargs/helpers');
// Parse CLI arguments
const argv = yargs(hideBin(process.argv))
.option('number', {
alias: 'n',
type: 'number',
description: 'Number of messages to send',
default: 10,
})
.option('chat-id', {
alias: 'to',
type: 'number',
description: 'Chat ID to send messages to',
demandOption: true,
})
.option('session', {
type: 'string',
description: 'Session ID to use',
demandOption: true,
})
.option('api-key', {
alias: 'k',
type: 'string',
description: 'API key for authentication',
demandOption: true,
})
.help().argv;
const sendTextMessage = async (session, numMessages, chatId, apiKey) => {
const url = 'http://localhost:3000/api/sendText/';
for (let i = 1; i <= numMessages; i++) {
console.log(`Sending message ${i}`);
const response = await axios.post(
url,
{
chatId: chatId.toString(),
session: session,
text: `Message - ${i}`,
},
{
headers: {
Accept: 'application/json',
'X-Api-Key': apiKey,
'Content-Type': 'application/json',
},
},
);
console.log(`Message ${i} sent successfully:`, response.data);
}
};
// Run the script
sendTextMessage(argv.session, argv.number, argv['chat-id'], argv['api-key']);
+56
View File
@@ -0,0 +1,56 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const axios = require('axios');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const yargs = require('yargs/yargs');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { hideBin } = require('yargs/helpers');
// Parse CLI arguments
const argv = yargs(hideBin(process.argv))
.option('sessions', {
alias: 'n',
type: 'number',
description: 'Number of sessions to create',
default: 10,
})
.option('api-key', {
alias: 'k',
type: 'string',
description: 'API key for authentication',
demandOption: true,
})
.help().argv;
const createSessions = async (numSessions, apiKey) => {
const url = 'http://localhost:3000/api/sessions/';
for (let i = 1; i <= numSessions; i++) {
try {
console.log(`Creating session ${i}`);
const response = await axios.post(
url,
{
name: '',
config: {
metadata: {},
webhooks: [],
},
start: true,
},
{
headers: {
Accept: 'application/json',
'X-Api-Key': apiKey,
'Content-Type': 'application/json',
},
},
);
console.log(`Session ${i} created successfully:`, response.data);
} catch (error) {
console.error(`Error creating session ${i}:`, error.message);
}
}
};
// Run the script
createSessions(argv.sessions, argv['api-key']);
+1 -1
View File
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
"exclude": ["node_modules", "test", "dist", "**/*spec.ts", "scripts/*.js"]
}
+12
View File
@@ -0,0 +1,12 @@
{
"waha": {
"gows": {
"repo": "devlikeapro/gows",
"ref": "32baf0cc2e8c35388b0b6d4a1a446cca0f3525a8"
},
"dashboard": {
"repo": "devlikeapro/dashboard",
"ref": "a1c839d8da94d1cade182addffdfc42fc0cf7ed3"
}
}
}
+1
View File
@@ -12646,6 +12646,7 @@ __metadata:
ulid: ^2.3.0
whatsapp-web.js: "github:devlikeapro/whatsapp-web.js#fork-main-channels"
write-file-atomic: ^6.0.0
yargs: ^17.7.2
dependenciesMeta:
bufferutil:
optional: true