Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sending and receiving photos? #3

Closed
deduzzo opened this issue Mar 30, 2019 · 6 comments
Closed

sending and receiving photos? #3

deduzzo opened this issue Mar 30, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@deduzzo
Copy link

deduzzo commented Mar 30, 2019

It's possibile to send and receive photos? You can give an example?
Thanks for the great work!

@JRakhimov
Copy link

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?

@pedroslopez pedroslopez added the enhancement New feature or request label May 30, 2019
@pedroslopez pedroslopez mentioned this issue Jul 21, 2019
@pedroslopez pedroslopez added the blocked Waiting on another issue to be resolved label Jul 21, 2019
@pedroslopez pedroslopez removed the blocked Waiting on another issue to be resolved label Sep 3, 2019
@dannielio
Copy link

@pedroslopez
Copy link
Owner

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 :)

@aliyss
Copy link
Collaborator

aliyss commented Feb 3, 2020

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.

@pedroslopez
Copy link
Owner

@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.

@aliyss
Copy link
Collaborator

aliyss commented Feb 3, 2020

Alright. In that case I'll leave my hands out of it. 😇

mpirescarvalho referenced this issue in mpirescarvalho/whatsapp-web.js Feb 3, 2021
add await when needed and polish work with files
mpirescarvalho referenced this issue in mpirescarvalho/whatsapp-web.js Feb 11, 2021
add await when needed and polish work with files
koodinikula pushed a commit to koodinikula/whatsapp-web.js that referenced this issue Oct 29, 2022
…/patch

Update WhatsApp Web Version (2.2238.7)
@devsakae devsakae mentioned this issue Nov 9, 2023
7 tasks
Belfio pushed a commit to Belfio/whatsapp-web.js that referenced this issue Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants