mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
adjusts in v1.7.3
This commit is contained in:
parent
5e0e4051dc
commit
d6e19b9273
@ -1,3 +1,10 @@
|
||||
# 1.7.3 (develop)
|
||||
|
||||
### Fixed
|
||||
* Fix audio encoding
|
||||
* Recovering messages lost
|
||||
* Adjusts in proxy
|
||||
|
||||
# 1.7.2 (2024-04-12 17:31)
|
||||
|
||||
### Feature
|
||||
|
@ -1,6 +1,6 @@
|
||||
FROM node:20.7.0-alpine AS builder
|
||||
|
||||
LABEL version="1.7.2" description="Api to control whatsapp features through http requests."
|
||||
LABEL version="1.7.3" description="Api to control whatsapp features through http requests."
|
||||
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
|
||||
LABEL contact="contato@agenciadgcode.com"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "evolution-api",
|
||||
"version": "1.7.2",
|
||||
"version": "1.7.3",
|
||||
"description": "Rest api for communication with WhatsApp",
|
||||
"main": "./dist/src/main.js",
|
||||
"scripts": {
|
||||
|
@ -39,9 +39,10 @@ import makeWASocket, {
|
||||
import { Label } from '@whiskeysockets/baileys/lib/Types/Label';
|
||||
import { LabelAssociation } from '@whiskeysockets/baileys/lib/Types/LabelAssociation';
|
||||
import axios from 'axios';
|
||||
import { exec } from 'child_process';
|
||||
import { arrayUnique, isBase64, isURL } from 'class-validator';
|
||||
import EventEmitter2 from 'eventemitter2';
|
||||
import ffmpeg from 'fluent-ffmpeg';
|
||||
// import ffmpeg from 'fluent-ffmpeg';
|
||||
import fs, { existsSync, readFileSync } from 'fs';
|
||||
import { parsePhoneNumber } from 'libphonenumber-js';
|
||||
import Long from 'long';
|
||||
@ -485,11 +486,11 @@ export class BaileysStartupService extends WAStartupService {
|
||||
let options;
|
||||
|
||||
if (this.localProxy.enabled) {
|
||||
this.logger.info('Proxy enabled: ' + this.localProxy.proxy.host);
|
||||
this.logger.info('Proxy enabled: ' + this.localProxy.proxy?.host);
|
||||
|
||||
if (this.localProxy?.proxy?.host?.includes('proxyscrape')) {
|
||||
try {
|
||||
const response = await axios.get(this.localProxy.proxy.host);
|
||||
const response = await axios.get(this.localProxy.proxy?.host);
|
||||
const text = response.data;
|
||||
const proxyUrls = text.split('\r\n');
|
||||
const rand = Math.floor(Math.random() * Math.floor(proxyUrls.length));
|
||||
@ -655,11 +656,11 @@ export class BaileysStartupService extends WAStartupService {
|
||||
let options;
|
||||
|
||||
if (this.localProxy.enabled) {
|
||||
this.logger.info('Proxy enabled: ' + this.localProxy.proxy.host);
|
||||
this.logger.info('Proxy enabled: ' + this.localProxy.proxy?.host);
|
||||
|
||||
if (this.localProxy?.proxy?.host?.includes('proxyscrape')) {
|
||||
try {
|
||||
const response = await axios.get(this.localProxy.proxy.host);
|
||||
const response = await axios.get(this.localProxy.proxy?.host);
|
||||
const text = response.data;
|
||||
const proxyUrls = text.split('\r\n');
|
||||
const rand = Math.floor(Math.random() * Math.floor(proxyUrls.length));
|
||||
@ -1043,6 +1044,12 @@ export class BaileysStartupService extends WAStartupService {
|
||||
}
|
||||
}
|
||||
|
||||
if (received.messageStubParameters && received.messageStubParameters[0] === 'Message absent from node') {
|
||||
this.logger.info('Recovering message lost');
|
||||
await this.client.sendMessageAck(JSON.parse(received.messageStubParameters[1], BufferJSON.reviver));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
(type !== 'notify' && type !== 'append') ||
|
||||
received.message?.protocolMessage ||
|
||||
@ -2093,7 +2100,7 @@ export class BaileysStartupService extends WAStartupService {
|
||||
content: {
|
||||
audio: Buffer.from(audio, 'base64'),
|
||||
ptt: true,
|
||||
mimetype: 'audio/mp4',
|
||||
mimetype: 'audio/ogg; codecs=opus',
|
||||
},
|
||||
option: {
|
||||
statusJidList: status.statusJidList,
|
||||
@ -2297,6 +2304,82 @@ export class BaileysStartupService extends WAStartupService {
|
||||
return await this.sendMessageWithTyping(data.number, { ...generate.message }, data?.options, isChatwoot);
|
||||
}
|
||||
|
||||
// public async processAudio(audio: string, number: string) {
|
||||
// this.logger.verbose('Processing audio');
|
||||
// let tempAudioPath: string;
|
||||
// let outputAudio: string;
|
||||
|
||||
// number = number.replace(/\D/g, '');
|
||||
// const hash = `${number}-${new Date().getTime()}`;
|
||||
// this.logger.verbose('Hash to audio name: ' + hash);
|
||||
|
||||
// if (isURL(audio)) {
|
||||
// this.logger.verbose('Audio is url');
|
||||
|
||||
// outputAudio = `${join(this.storePath, 'temp', `${hash}.ogg`)}`;
|
||||
// tempAudioPath = `${join(this.storePath, 'temp', `temp-${hash}.mp3`)}`;
|
||||
|
||||
// this.logger.verbose('Output audio path: ' + outputAudio);
|
||||
// this.logger.verbose('Temp audio path: ' + tempAudioPath);
|
||||
|
||||
// const timestamp = new Date().getTime();
|
||||
// const url = `${audio}?timestamp=${timestamp}`;
|
||||
|
||||
// this.logger.verbose('Including timestamp in url: ' + url);
|
||||
|
||||
// let config: any = {
|
||||
// responseType: 'arraybuffer',
|
||||
// };
|
||||
|
||||
// if (this.localProxy.enabled) {
|
||||
// config = {
|
||||
// ...config,
|
||||
// httpsAgent: makeProxyAgent(this.localProxy.proxy),
|
||||
// };
|
||||
// }
|
||||
|
||||
// const response = await axios.get(url, config);
|
||||
// this.logger.verbose('Getting audio from url');
|
||||
|
||||
// fs.writeFileSync(tempAudioPath, response.data);
|
||||
// } else {
|
||||
// this.logger.verbose('Audio is base64');
|
||||
|
||||
// outputAudio = `${join(this.storePath, 'temp', `${hash}.ogg`)}`;
|
||||
// tempAudioPath = `${join(this.storePath, 'temp', `temp-${hash}.mp3`)}`;
|
||||
|
||||
// this.logger.verbose('Output audio path: ' + outputAudio);
|
||||
// this.logger.verbose('Temp audio path: ' + tempAudioPath);
|
||||
|
||||
// const audioBuffer = Buffer.from(audio, 'base64');
|
||||
// fs.writeFileSync(tempAudioPath, audioBuffer);
|
||||
// this.logger.verbose('Temp audio created');
|
||||
// }
|
||||
|
||||
// this.logger.verbose('Converting audio to mp4');
|
||||
// return new Promise((resolve, reject) => {
|
||||
// // This fix was suggested by @PurpShell
|
||||
// ffmpeg.setFfmpegPath(ffmpegPath.path);
|
||||
|
||||
// ffmpeg()
|
||||
// .input(tempAudioPath)
|
||||
// .outputFormat('ogg')
|
||||
// .noVideo()
|
||||
// .audioCodec('libopus')
|
||||
// .save(outputAudio)
|
||||
// .on('error', function (error) {
|
||||
// console.log('error', error);
|
||||
// fs.unlinkSync(tempAudioPath);
|
||||
// if (error) reject(error);
|
||||
// })
|
||||
// .on('end', async function () {
|
||||
// fs.unlinkSync(tempAudioPath);
|
||||
// resolve(outputAudio);
|
||||
// })
|
||||
// .run();
|
||||
// });
|
||||
// }
|
||||
|
||||
public async processAudio(audio: string, number: string) {
|
||||
this.logger.verbose('Processing audio');
|
||||
let tempAudioPath: string;
|
||||
@ -2309,7 +2392,7 @@ export class BaileysStartupService extends WAStartupService {
|
||||
if (isURL(audio)) {
|
||||
this.logger.verbose('Audio is url');
|
||||
|
||||
outputAudio = `${join(this.storePath, 'temp', `${hash}.ogg`)}`;
|
||||
outputAudio = `${join(this.storePath, 'temp', `${hash}.mp4`)}`;
|
||||
tempAudioPath = `${join(this.storePath, 'temp', `temp-${hash}.mp3`)}`;
|
||||
|
||||
this.logger.verbose('Output audio path: ' + outputAudio);
|
||||
@ -2320,25 +2403,14 @@ export class BaileysStartupService extends WAStartupService {
|
||||
|
||||
this.logger.verbose('Including timestamp in url: ' + url);
|
||||
|
||||
let config: any = {
|
||||
responseType: 'arraybuffer',
|
||||
};
|
||||
|
||||
if (this.localProxy.enabled) {
|
||||
config = {
|
||||
...config,
|
||||
httpsAgent: makeProxyAgent(this.localProxy.proxy),
|
||||
};
|
||||
}
|
||||
|
||||
const response = await axios.get(url, config);
|
||||
const response = await axios.get(url, { responseType: 'arraybuffer' });
|
||||
this.logger.verbose('Getting audio from url');
|
||||
|
||||
fs.writeFileSync(tempAudioPath, response.data);
|
||||
} else {
|
||||
this.logger.verbose('Audio is base64');
|
||||
|
||||
outputAudio = `${join(this.storePath, 'temp', `${hash}.ogg`)}`;
|
||||
outputAudio = `${join(this.storePath, 'temp', `${hash}.mp4`)}`;
|
||||
tempAudioPath = `${join(this.storePath, 'temp', `temp-${hash}.mp3`)}`;
|
||||
|
||||
this.logger.verbose('Output audio path: ' + outputAudio);
|
||||
@ -2351,25 +2423,15 @@ export class BaileysStartupService extends WAStartupService {
|
||||
|
||||
this.logger.verbose('Converting audio to mp4');
|
||||
return new Promise((resolve, reject) => {
|
||||
// This fix was suggested by @PurpShell
|
||||
ffmpeg.setFfmpegPath(ffmpegPath.path);
|
||||
exec(`${ffmpegPath.path} -i ${tempAudioPath} -vn -ab 128k -ar 44100 -f ipod ${outputAudio} -y`, (error) => {
|
||||
fs.unlinkSync(tempAudioPath);
|
||||
this.logger.verbose('Temp audio deleted');
|
||||
|
||||
ffmpeg()
|
||||
.input(tempAudioPath)
|
||||
.outputFormat('ogg')
|
||||
.noVideo()
|
||||
.audioCodec('libopus')
|
||||
.save(outputAudio)
|
||||
.on('error', function (error) {
|
||||
console.log('error', error);
|
||||
fs.unlinkSync(tempAudioPath);
|
||||
if (error) reject(error);
|
||||
})
|
||||
.on('end', async function () {
|
||||
fs.unlinkSync(tempAudioPath);
|
||||
resolve(outputAudio);
|
||||
})
|
||||
.run();
|
||||
if (error) reject(error);
|
||||
|
||||
this.logger.verbose('Audio converted to mp4');
|
||||
resolve(outputAudio);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ info:
|
||||
</font>
|
||||
|
||||
[](https://god.gw.postman.com/run-collection/26869335-5546d063-156b-4529-915f-909dd628c090?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D26869335-5546d063-156b-4529-915f-909dd628c090%26entityType%3Dcollection%26workspaceId%3D339a4ee7-378b-45c9-b5b8-fd2c0a9c2442)
|
||||
version: 1.7.2
|
||||
version: 1.7.3
|
||||
contact:
|
||||
name: DavidsonGomes
|
||||
email: contato@agenciadgcode.com
|
||||
|
Loading…
Reference in New Issue
Block a user