Giter Club home page Giter Club logo

Comments (6)

JRakhimov avatar JRakhimov commented on May 11, 2024

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.

dannielio avatar dannielio commented on May 11, 2024

@pedroslopez Could something like this help?

https://gist.github.com/phpRajat/a6422922efae32914f4dbd1082f3f412

from whatsapp-web.js.

pedroslopez avatar pedroslopez commented on May 11, 2024

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.

aliyss avatar aliyss commented on May 11, 2024
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.

pedroslopez avatar pedroslopez commented on May 11, 2024

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

aliyss avatar aliyss commented on May 11, 2024

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

from whatsapp-web.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.