Describe the bug
A clear and concise description of what the bug is.
client.sendFile stopped working with update, was working with version "sulla-hotfix": "1.6.05".
No error is thrown.
Steps to Reproduce
create() code
fs.readFile(`${folder}${file}`, (err, data) => {
try {
client.sendFile(
'[email protected]',
`data:application/pdf;base64,${data.toString('base64')}`,
filename,
`Caption`
);
} catch (error) {
console.log(error);
};
});
DEBUG INFO
This is the info printed to the console when you start your app. It should look like this
Debug Info {
WA_VERSION: '0.4.612',
PAGE_UA:
'WhatsApp/0.4.607 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36',
SULLA_HOTFIX_VERSION: '1.7.5',
BROWSER_VERSION: 'HeadlessChrome/79.0.3945.0' }
Host (please complete the following information):
Hi @LucasDibz
Thanks for following the template. You have not shared your create() code. Can you do that, please?
Here's an example:
https://github.com/smashah/sulla/issues/96#issue-560091558
I have tried with PDFs on the latest version and it is working fine. sendFile code has not changed for a very long time.
Just FYI, i would suggest against using headless chrome
Using all default create();
That's the whole code:
const startBot = (client) => {
fs.readFile(`${folder}${file}`, (err, data) => {
try {
client.sendFile(
tel,
`data:application/pdf;base64,${data.toString('base64')}`,
filename,
`Caption`
);
client.sendText(tel, 'test'); //this works
} catch (error) {
console.error(error);
};
});
};
sulla.create().then(client => startBot(client));
Thanks for your time.
@LucasDibz did you have find a solution?
@haroldorodsilva not yet, trying with diff create setting...still no success... maybe something about puppeteer?
@LucasDibz what puppeteer v are you running?
@smashah sullas default,
"_requested": {
"type": "version",
"registry": true,
"raw": "[email protected]",
"name": "puppeteer",
"escapedName": "puppeteer",
"rawSpec": "2.0.0",
"saveSpec": null,
"fetchSpec": "2.0.0"
},
@LucasDibz can you run the demo, send it a pdf then see if it replies with the pdf?
I am testing with the clone of the project and works fine. I used this code below:
client.onMessage(async message => {
try {
const isConnected = await client.isConnected();
console.log('TCL: start -> isConnected', isConnected);
if (message.body.toUpperCase() === 'image'.toUpperCase()) {
const image = await utils.getFileInBase64('image.png');
console.log('send image to', message.from, image === '');
await client.sendImage(
message.from,
// `data:image/png;base64,${image}`,
String(image),
'image.png',
`Try to send image`
);
}
//
} catch (error) {
console.log('TCL: start -> error', error);
}
});
I'll try using with npm and with the dist of the clone now.
Now I had created a new project and make a clone of sulla inside this project. I used the script build to generate the foldes dist and used this folder.
const { create } = require("./sulla/dist");
const utils = require("./utils");
const startBot = client => {
client.onMessage(async message => {
try {
const isConnected = await client.isConnected();
console.log(" start -> isConnected", isConnected);
if (message.body.toUpperCase() === "image".toUpperCase()) {
const image = await utils.getFileInBase64("image.png");
console.log("send image to", message.from, image === "");
await client.sendImage(
message.from,
// `data:image/png;base64,${image}`,
image,
"image.png",
`Try to send image`
);
}
//
} catch (error) {
console.log("TCL: start -> error", error);
}
});
};
create().then(client => startBot(client));
With this way the it is not works.
with package don't work too:
const { create } = require("sulla-hotfix");
@smashah Can you try using download the library from npm and using files .js ?
because cloning the project and running ts-node on demo is working.
the same problem occurs here. any ideas on how to solve?
I've moved totally to using ts-node for everything. I'd suggest migrating to that if it works until this issue gets sorted.
@haroldorodsilva I'm a noob with ts-node. do you know how do i import the modules and be able to execute the code that you posted? I would be very grateful if you could help me.
@cucabr same as demo/index.ts
around here, even using the ts-node with project clone (actual), it's not ok. nothing happens. the image is not sent and no errors appear either. sad. I discovered this repository today.
The test that I think must be made is create a project with typescript and install the package with npm and try.
@cucabr n茫o sou t茫o bom com typescript, procurei na Net apenas para testar. Tem que instalar o typescript e o ts-node e depois s贸 rodar: ts-node demo/Index.js...
around here, even using the ts-node with project clone (actual), it's not ok. nothing happens. the image is not sent and no errors appear either. sad. I discovered this repository today.
I'll post here later the code latter
around here, even using the ts-node with project clone (actual), it's not ok. nothing happens. the image is not sent and no errors appear either. sad. I discovered this repository today.
I'll post here later the code latter
around here, even using the ts-node with project clone (actual), it's not ok. nothing happens. the image is not sent and no errors appear either. sad. I discovered this repository today.
You're right, I updated and did not send the image. @smashah
I deleted the folder and cloned version 1.7.6 again and also did not send the image. I downloaded 1.7.5 in the releases and made the same change and it didn't work anymore.
Now I don't understand what happened. I will attach my files here from 1.7.6
@LucasDibz @haroldorodsilva @cucabr try v1.7.7 it should be fixed now.
Let me know how it goes. Thanks.
@smashah In version 1.7.7 it worked perfectly both in the demo of the clone, via npm and using the compiled dist.
Thanks
@smashah Perfect!
thanks!
Error: Evaluation failed: ReferenceError: chatId is not defined. ChatId not define.
@gildastema latest version? I'll fix that today. Thanks for pointing it out.
@smashah the pull request #116 I have tested here with the alterations and works fine
@haroldorodsilva next v will include the fix in the above pull request
@haroldorodsilva @gildastema
Fix is live in v1.7.12
thanks
Most helpful comment
@smashah In version 1.7.7 it worked perfectly both in the demo of the clone, via npm and using the compiled dist.
Thanks