Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions webwhatsapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,9 @@ def send_message_to_id(self, recipient, message):
:type message: str
"""
return self.wapi_functions.sendMessageToID(recipient, message)

def send_mention(self, chat_id, message, mentionId=[]):
return self.wapi_functions.sendMention(chat_id, message, mentionId)

def convert_to_base64(self, path, is_thumbnail=False):
"""
Expand Down
29 changes: 22 additions & 7 deletions webwhatsapi/js/wapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,22 @@ window.WAPI.sendMessageWithThumb = function (thumb, url, title, description, tex
return true;
};

window.WAPI.sendMention = function (chat_id, message, mentionedJidList, done){
var chat = WAPI.getChat(chat_id);
var listUser = [];
if (chat === undefined){
if (done !== undefined) done(false);
return false;
}
for (let idx in mentionedJidList){
let idUser = new window.Store.UserConstructor(mentionedJidList[idx], { intentionallyUsePrivateConstructor: true });
listUser.push(idUser);
}
chat.sendMessage(message, {mentionedJidList: listUser});
if (done !== undefined) done(true);
return true;
};

window.WAPI.getNewId = function () {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
Expand Down Expand Up @@ -582,8 +598,8 @@ window.WAPI.getGroupAdmins = async function (id, done) {
window.WAPI.getMe = function (done) {
const rawMe = window.Store.Contact.get(window.Store.Conn.me);

if (done !== undefined) done(rawMe.all);
return rawMe.all;
if (done !== undefined) done(rawMe);
return rawMe;
};

window.WAPI.isLoggedIn = function (done) {
Expand Down Expand Up @@ -674,12 +690,11 @@ window.WAPI.ReplyMessage = function (idMessage, message, done) {
if (done !== undefined) done(false);
return false;
}
messageObject = messageObject.value();


const chat = WAPI.getChat(messageObject.chat.id)
if (chat !== undefined) {
if (done !== undefined) {
chat.sendMessage(message, null, messageObject).then(function () {
chat.sendMessage(message, {quotedMsg: messageObject}, messageObject).then(function () {
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
Expand Down Expand Up @@ -708,7 +723,7 @@ window.WAPI.ReplyMessage = function (idMessage, message, done) {
});
return true;
} else {
chat.sendMessage(message, null, messageObject);
chat.sendMessage(message, {quotedMsg: messageObject}, messageObject);
return true;
}
} else {
Expand Down Expand Up @@ -1218,7 +1233,7 @@ var idUser = new window.Store.UserConstructor(chatid, { intentionallyUsePrivateC
// create new chat
return Store.Chat.find(idUser).then((chat) => {
var mediaBlob = window.WAPI.base64ImageToFile(imgBase64, filename);
var mc = new Store.MediaCollection();
var mc = new Store.MediaCollection(chat);
mc.processFiles([mediaBlob], chat, 1).then(() => {
var media = mc.models[0];
media.sendToChat(chat, { caption: caption });
Expand Down