Comments (6)
Hi, I am looking for this feature too and my research result is that WBOT module has this function in api (sendImage method) but for this we need inject/include modules: UserConstructor, MediaCollection. My question, @pedroslopez how can we include other models like Message module?
from whatsapp-web.js.
@pedroslopez Could something like this help?
https://gist.github.com/phpRajat/a6422922efae32914f4dbd1082f3f412
from whatsapp-web.js.
Receiving photos is now possible as of v0.3 (https://github.com/pedroslopez/whatsapp-web.js/releases/tag/v0.3.0)
I'll leave this issue open until sending is also implemented :)
from whatsapp-web.js.
window.WAPI.sendImage = function (imgBase64, chatid, filename, caption, done) {
//var idUser = new window.Store.UserConstructor(chatid);
var idUser = new window.Store.UserConstructor(chatid, { intentionallyUsePrivateConstructor: true });
// create new chat
return Store.Chat.find(idUser).then((chat) => {
var mediaBlob = window.WAPI.base64ImageToFile(imgBase64, filename);
var mc = new Store.MediaCollection();
mc.processFiles([mediaBlob], chat, 1).then(() => {
var media = mc.models[0];
media.sendToChat(chat, { caption: caption });
if (done !== undefined) done(true);
});
});
}
Stole it from here: https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/master/webwhatsapi/js/wapi.js
Edit: Will look into it asap.
from whatsapp-web.js.
@aliyss I was actually working in this yesterday using a similar solution, and I got it working for any attachment type (except videos for whatever reason), however the ‘.sendToChat’ part doesn’t allow us to get the sent message ID.
I basically left off reimplementing the sendToChat function myself combining it with our custom sendMessage function that assigns the ID manually. This seemed to work fine but I need to do some additional testing and clean things up.
from whatsapp-web.js.
Alright. In that case I'll leave my hands out of it. 😇
from whatsapp-web.js.
Related Issues (20)
- Support for Electron? HOT 1
- npm WARN deprecated [email protected]: < 21.5.0 is no longer supported
- Downgrading npm to version 6.14.18 worked for me: npm install -g [email protected] not working
- client.sendMessage MP4 - Error: Evaluation failed: u
- WhatsApp is out of date HOT 1
- npm WARN deprecated [email protected]: < 21.5.0 is no longer supported
- how to get a invite to group via link, get a group join qrcode display HOT 1
- Group Messages - "Waiting for this message. This may take a while." HOT 4
- getNumberId HOT 1
- Events Call
- unable to reproduce ptt downloaded file (message voice) HOT 1
- Cannot create logic when message from admin HOT 1
- Is there any method in Message object that delete the message media from the phone HOT 1
- TypeError: Cannot read properties of null (reading '1') HOT 9
- Uncaught SyntaxError /node_modules/whatsapp-web.js/src/Client.js:1354 HOT 1
- Link preview not working on all websites HOT 1
- Client problem i cant see qr code or any client operations
- the first message does not arrive HOT 2
- Bug: fetchMessage Function Does Not Update Message ACK Status Properly
- Whatsapp suspend my account HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from whatsapp-web.js.