whatsapp-web.js 不发送视频(什么也没有发生)

问题描述 投票:0回答:1

我正在努力解决 Whatsapp Web JS 的 sendMessage 方法。这是我的测试代码:

import pkg from 'whatsapp-web.js';
const { Client, LocalAuth, MessageMedia } = pkg;
import qrcode, { error } from 'qrcode-terminal';


const client = new Client({ 
    puppeteer: {
        executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
    },
    authStrategy: new LocalAuth({ dataPath: "sessions", }), 
    webVersionCache: { 
        type: 'remote', 
        remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html', 
    }
});


client.on('qr', qr => {
    qrcode.generate(qr, {small: true});
});

client.on('ready', async () => {
    console.log('Pret'); 
    const media = await MessageMedia.fromUrl('https://runex-fitness.com/wp-content/uploads/2024/05/Elegant-Beige-Launching-Soon-Instagram-Reel-2-1.mp4');
    await client.sendMessage("[email protected]", media);
});

client.on('message_ack', (message, ack) => {
    console.log(`Message ack received: ${ack}`);
    // ack sera true si le message a été envoyé avec succès
});

client.initialize();

当 Url MessageMedia.fromUrl 用于图像时,它可以工作,对于 gif,它可以工作(但将 gif 作为图像发送),但对于视频,则不会发生任何情况。

我使用 2020 款 MacBook Pro m1。

我尝试了找到的所有解决方案(主要是将executablePath添加到puppeteer,但它没有改变任何东西,问题继续发生。

无法发送 5mb 的视频,即使文件托管在本地。

我希望能够发送视频。

node.js google-chrome bots puppeteer whatsapp
1个回答
0
投票

请使用问题#3002中提到的固定版本(https://github.com/pedroslopez/whatsapp-web.js/issues/3002)作为您的remotePath,如下所示:

remotePath: 'https://raw.githubusercontent.com/guigo613/alternative-wa-version/main/html/2.2412.54v2.html' 

由于某种原因,其他版本无法再加载处理视频的 JS。

© www.soinside.com 2019 - 2024. All rights reserved.