Update Baileys to 7RC
This commit is contained in:
parent
69cb77b8f4
commit
e952973f7f
9 changed files with 984 additions and 900 deletions
2
.nvmrc
2
.nvmrc
|
|
@ -1 +1 @@
|
||||||
v22.18.0
|
v24
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
{
|
{
|
||||||
"name": "@link-stack/bridge-whatsapp",
|
"name": "@link-stack/bridge-whatsapp",
|
||||||
"version": "3.3.5",
|
"version": "3.3.5",
|
||||||
|
"type": "module",
|
||||||
"main": "build/main/index.js",
|
"main": "build/main/index.js",
|
||||||
"author": "Darren Clarke <darren@redaranj.com>",
|
"author": "Darren Clarke <darren@redaranj.com>",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@adiwajshing/keyed-db": "0.2.4",
|
|
||||||
"@hapi/hapi": "^21.4.3",
|
"@hapi/hapi": "^21.4.3",
|
||||||
"@hapipal/schmervice": "^3.0.0",
|
"@hapipal/schmervice": "^3.0.0",
|
||||||
"@hapipal/toys": "^4.0.0",
|
"@hapipal/toys": "^4.0.0",
|
||||||
"@link-stack/bridge-common": "workspace:*",
|
"@link-stack/bridge-common": "workspace:*",
|
||||||
"@link-stack/logger": "workspace:*",
|
"@link-stack/logger": "workspace:*",
|
||||||
"@whiskeysockets/baileys": "6.7.21",
|
"@whiskeysockets/baileys": "7.0.0-rc.9",
|
||||||
"hapi-pino": "^13.0.0",
|
"hapi-pino": "^13.0.0",
|
||||||
"link-preview-js": "^3.1.0"
|
"link-preview-js": "^3.1.0"
|
||||||
},
|
},
|
||||||
|
|
@ -19,15 +19,12 @@
|
||||||
"@link-stack/eslint-config": "workspace:*",
|
"@link-stack/eslint-config": "workspace:*",
|
||||||
"@link-stack/jest-config": "workspace:*",
|
"@link-stack/jest-config": "workspace:*",
|
||||||
"@link-stack/typescript-config": "workspace:*",
|
"@link-stack/typescript-config": "workspace:*",
|
||||||
"@types/long": "^5",
|
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
"dotenv-cli": "^10.0.0",
|
|
||||||
"tsx": "^4.20.6",
|
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -p tsconfig.json",
|
"build": "tsc -p tsconfig.json",
|
||||||
"dev": "dotenv -- tsx src/index.ts",
|
"dev": "node --env-file=.env --experimental-transform-types src/index.ts",
|
||||||
"start": "node build/main/index.js"
|
"start": "node build/main/index.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
import * as Hapi from "@hapi/hapi";
|
import * as Hapi from "@hapi/hapi";
|
||||||
import hapiPino from "hapi-pino";
|
import hapiPino from "hapi-pino";
|
||||||
import Schmervice from "@hapipal/schmervice";
|
import Schmervice from "@hapipal/schmervice";
|
||||||
import WhatsappService from "./service.js";
|
import WhatsappService from "./service.ts";
|
||||||
import {
|
import {
|
||||||
RegisterBotRoute,
|
RegisterBotRoute,
|
||||||
UnverifyBotRoute,
|
UnverifyBotRoute,
|
||||||
GetBotRoute,
|
GetBotRoute,
|
||||||
SendMessageRoute,
|
SendMessageRoute,
|
||||||
ReceiveMessageRoute,
|
ReceiveMessageRoute,
|
||||||
} from "./routes.js";
|
} from "./routes.ts";
|
||||||
import { createLogger } from "@link-stack/logger";
|
import { createLogger } from "@link-stack/logger";
|
||||||
|
|
||||||
const logger = createLogger('bridge-whatsapp-index');
|
const logger = createLogger("bridge-whatsapp-index");
|
||||||
|
|
||||||
const server = Hapi.server({ port: 5000 });
|
const server = Hapi.server({ port: 5000 });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import * as Hapi from "@hapi/hapi";
|
import * as Hapi from "@hapi/hapi";
|
||||||
import Toys from "@hapipal/toys";
|
import Toys from "@hapipal/toys";
|
||||||
import WhatsappService from "./service";
|
import WhatsappService from "./service.ts";
|
||||||
|
|
||||||
const withDefaults = Toys.withRouteDefaults({
|
const withDefaults = Toys.withRouteDefaults({
|
||||||
options: {
|
options: {
|
||||||
|
|
@ -27,15 +27,9 @@ export const SendMessageRoute = withDefaults({
|
||||||
description: "Send a message",
|
description: "Send a message",
|
||||||
async handler(request: Hapi.Request, _h: Hapi.ResponseToolkit) {
|
async handler(request: Hapi.Request, _h: Hapi.ResponseToolkit) {
|
||||||
const { id } = request.params;
|
const { id } = request.params;
|
||||||
const { phoneNumber, message, attachments } =
|
const { phoneNumber, message, attachments } = request.payload as MessageRequest;
|
||||||
request.payload as MessageRequest;
|
|
||||||
const whatsappService = getService(request);
|
const whatsappService = getService(request);
|
||||||
await whatsappService.send(
|
await whatsappService.send(id, phoneNumber, message as string, attachments);
|
||||||
id,
|
|
||||||
phoneNumber,
|
|
||||||
message as string,
|
|
||||||
attachments,
|
|
||||||
);
|
|
||||||
request.logger.info(
|
request.logger.info(
|
||||||
{
|
{
|
||||||
id,
|
id,
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,13 @@ import makeWASocket, {
|
||||||
DisconnectReason,
|
DisconnectReason,
|
||||||
proto,
|
proto,
|
||||||
downloadContentFromMessage,
|
downloadContentFromMessage,
|
||||||
MediaType,
|
|
||||||
fetchLatestBaileysVersion,
|
fetchLatestBaileysVersion,
|
||||||
isJidBroadcast,
|
isJidBroadcast,
|
||||||
isJidStatusBroadcast,
|
isJidStatusBroadcast,
|
||||||
useMultiFileAuthState,
|
useMultiFileAuthState,
|
||||||
} from "@whiskeysockets/baileys";
|
} from "@whiskeysockets/baileys";
|
||||||
|
|
||||||
|
type MediaType = "audio" | "document" | "image" | "video" | "sticker";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { createLogger } from "@link-stack/logger";
|
import { createLogger } from "@link-stack/logger";
|
||||||
import {
|
import {
|
||||||
|
|
@ -175,11 +176,12 @@ export default class WhatsappService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async queueMessage(botID: string, webMessageInfo: proto.IWebMessageInfo) {
|
private async queueMessage(botID: string, webMessageInfo: proto.IWebMessageInfo) {
|
||||||
const {
|
const { key, message, messageTimestamp } = webMessageInfo;
|
||||||
key: { id, fromMe, remoteJid },
|
if (!key) {
|
||||||
message,
|
logger.warn("Message missing key, skipping");
|
||||||
messageTimestamp,
|
return;
|
||||||
} = webMessageInfo;
|
}
|
||||||
|
const { id, fromMe, remoteJid } = key;
|
||||||
logger.info("Message type debug");
|
logger.info("Message type debug");
|
||||||
for (const key in message) {
|
for (const key in message) {
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type WhatsappService from "./service.js";
|
import type WhatsappService from "./service.ts";
|
||||||
|
|
||||||
declare module "@hapipal/schmervice" {
|
declare module "@hapipal/schmervice" {
|
||||||
interface SchmerviceDecorator {
|
interface SchmerviceDecorator {
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,17 @@
|
||||||
{
|
{
|
||||||
"extends": "@link-stack/typescript-config/tsconfig.node.json",
|
"extends": "@link-stack/typescript-config/tsconfig.node.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "commonjs",
|
"module": "NodeNext",
|
||||||
"target": "es2018",
|
"target": "es2022",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "NodeNext",
|
||||||
"outDir": "build/main",
|
"outDir": "build/main",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"lib": ["es2020", "DOM"],
|
"lib": ["es2022", "DOM"],
|
||||||
"composite": true
|
"composite": true,
|
||||||
|
"rewriteRelativeImportExtensions": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts", "src/**/.*.ts"],
|
"include": ["src/**/*.ts", "src/**/.*.ts"],
|
||||||
"exclude": ["node_modules/**"]
|
"exclude": ["node_modules/**"]
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
"react": "19.2.0",
|
"react": "19.2.0",
|
||||||
"react-dom": "19.2.0",
|
"react-dom": "19.2.0",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"turbo": "^2.5.8",
|
"turbo": "^2.6.0",
|
||||||
"typescript": "latest"
|
"typescript": "latest"
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
|
|
|
||||||
1826
pnpm-lock.yaml
generated
1826
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue