mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.03k stars 795 forks source link

SendVCard example #970

Open mikelustosa opened 3 years ago

mikelustosa commented 3 years ago

Hello, how use this function? Any example please. Thanks.

in neededonbejcts add this { id: "AddAndSendMsgToChat", conditions: (module) => (module.addAndSendMsgToChat) ? module.addAndSendMsgToChat : null },

and change function to

window.WAPI.sendVCard = async function (chatId, vcard) { var chat = Store.Chat.get(chatId); var tempMsg = Object.create(Store.Msg.models.filter(msg => msg.__x_isSentByMe)[0]); var newId = window.WAPI.getNewMessageId(chatId);

var extend = { ack : 0, id : newId, local : !0, self : "out", t : parseInt(new Date().getTime() / 1000), to : chatId, isNewMsg: !0, };

if (Array.isArray(vcard)) { Object.assign(extend, { type : "multi_vcard", vcardList: vcard });

delete extend.body;

} else { Object.assign(extend, { type : "vcard", subtype: vcard.displayName, body : vcard.vcard });

delete extend.vcardList;

}

Object.assign(tempMsg, extend);

await Promise.all(Store.AddAndSendMsgToChat(chat, tempMsg)) };