Comparing version 0.1.7 to 0.1.10
{ | ||
"name": "waweb-phi", | ||
"version": "0.1.7", | ||
"version": "0.1.10", | ||
"description": "control whatsapp web with nodejs", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -62,5 +62,5 @@ /** | ||
}); | ||
window.Store.ChatClass.default.prototype.sendMessage = function (e) { | ||
return window.Store.SendTextMsgToChat(this, ...arguments); | ||
} | ||
// window.Store.ChatClass.default.prototype.sendMessage = function (e) { | ||
// return window.Store.SendTextMsgToChat(this, ...arguments); | ||
// } | ||
return window.Store; | ||
@@ -100,8 +100,8 @@ } | ||
return Object.assign(window.WAPI._serializeRawObj(obj), { | ||
kind : obj.kind, | ||
isGroup : obj.isGroup, | ||
contact : obj['contact'] ? window.WAPI._serializeContactObj(obj['contact']) : null, | ||
groupMetadata: obj["groupMetadata"] ? window.WAPI._serializeRawObj(obj["groupMetadata"]): null, | ||
presence : obj["presence"] ? window.WAPI._serializeRawObj(obj["presence"]) : null, | ||
msgs : null | ||
kind: obj.kind, | ||
isGroup: obj.isGroup, | ||
contact: obj['contact'] ? window.WAPI._serializeContactObj(obj['contact']) : null, | ||
groupMetadata: obj["groupMetadata"] ? window.WAPI._serializeRawObj(obj["groupMetadata"]) : null, | ||
presence: obj["presence"] ? window.WAPI._serializeRawObj(obj["presence"]) : null, | ||
msgs: null | ||
}); | ||
@@ -116,13 +116,13 @@ }; | ||
return Object.assign(window.WAPI._serializeRawObj(obj), { | ||
formattedName : obj.formattedName, | ||
formattedName: obj.formattedName, | ||
isHighLevelVerified: obj.isHighLevelVerified, | ||
isMe : obj.isMe, | ||
isMyContact : obj.isMyContact, | ||
isPSA : obj.isPSA, | ||
isUser : obj.isUser, | ||
isVerified : obj.isVerified, | ||
isWAContact : obj.isWAContact, | ||
profilePicThumbObj : obj.profilePicThumb ? WAPI._serializeProfilePicThumb(obj.profilePicThumb): {}, | ||
statusMute : obj.statusMute, | ||
msgs : null | ||
isMe: obj.isMe, | ||
isMyContact: obj.isMyContact, | ||
isPSA: obj.isPSA, | ||
isUser: obj.isUser, | ||
isVerified: obj.isVerified, | ||
isWAContact: obj.isWAContact, | ||
profilePicThumbObj: obj.profilePicThumb ? WAPI._serializeProfilePicThumb(obj.profilePicThumb) : {}, | ||
statusMute: obj.statusMute, | ||
msgs: null | ||
}); | ||
@@ -137,17 +137,17 @@ }; | ||
return Object.assign(window.WAPI._serializeRawObj(obj), { | ||
id : obj.id._serialized, | ||
sender : obj["senderObj"] ? WAPI._serializeContactObj(obj["senderObj"]): null, | ||
timestamp : obj["t"], | ||
content : obj["body"], | ||
isGroupMsg : obj.isGroupMsg, | ||
isLink : obj.isLink, | ||
isMMS : obj.isMMS, | ||
isMedia : obj.isMedia, | ||
id: obj.id._serialized, | ||
sender: obj["senderObj"] ? WAPI._serializeContactObj(obj["senderObj"]) : null, | ||
timestamp: obj["t"], | ||
content: obj["body"], | ||
isGroupMsg: obj.isGroupMsg, | ||
isLink: obj.isLink, | ||
isMMS: obj.isMMS, | ||
isMedia: obj.isMedia, | ||
isNotification: obj.isNotification, | ||
isPSA : obj.isPSA, | ||
type : obj.type, | ||
chat : WAPI._serializeChatObj(obj['chat']), | ||
chatId : obj.id.remote, | ||
quotedMsgObj : WAPI._serializeMessageObj(obj['_quotedMsgObj']), | ||
mediaData : window.WAPI._serializeRawObj(obj['mediaData']) | ||
isPSA: obj.isPSA, | ||
type: obj.type, | ||
chat: WAPI._serializeChatObj(obj['chat']), | ||
chatId: obj.id.remote, | ||
quotedMsgObj: WAPI._serializeMessageObj(obj['_quotedMsgObj']), | ||
mediaData: window.WAPI._serializeRawObj(obj['mediaData']) | ||
}); | ||
@@ -162,5 +162,5 @@ }; | ||
return Object.assign({}, { | ||
id : obj.jid, | ||
status : obj.status, | ||
isBusiness : (obj.biz === true), | ||
id: obj.jid, | ||
status: obj.status, | ||
isBusiness: (obj.biz === true), | ||
canReceiveMessage: (obj.status === 200) | ||
@@ -176,8 +176,8 @@ }); | ||
return Object.assign({}, { | ||
eurl : obj.eurl, | ||
id : obj.id, | ||
img : obj.img, | ||
eurl: obj.eurl, | ||
id: obj.id, | ||
img: obj.img, | ||
imgFull: obj.imgFull, | ||
raw : obj.raw, | ||
tag : obj.tag | ||
raw: obj.raw, | ||
tag: obj.tag | ||
}); | ||
@@ -306,3 +306,3 @@ } | ||
var chatDatabase = window.WAPI.getChatByName('DATABASEPICBOT'); | ||
var msgWithImg = chatDatabase.msgs.find((msg) => msg.caption == picId); | ||
var msgWithImg = chatDatabase.msgs.find((msg) => msg.caption == picId); | ||
@@ -318,6 +318,6 @@ if (msgWithImg === undefined) { | ||
msgWithImg.id.id = window.WAPI.getNewId(); | ||
msgWithImg.id.id = window.WAPI.getNewId(); | ||
msgWithImg.id.remote = chatId; | ||
msgWithImg.t = Math.ceil(new Date().getTime() / 1000); | ||
msgWithImg.to = chatId; | ||
msgWithImg.t = Math.ceil(new Date().getTime() / 1000); | ||
msgWithImg.to = chatId; | ||
@@ -345,6 +345,6 @@ if (caption !== undefined && caption !== '') { | ||
canonicalUrl: url, | ||
description : description, | ||
matchedText : url, | ||
title : title, | ||
thumbnail : thumb | ||
description: description, | ||
matchedText: url, | ||
title: title, | ||
thumbnail: thumb | ||
}; | ||
@@ -357,3 +357,3 @@ chatSend.sendMessage(url, { linkPreview: linkPreview, mentionedJidList: [], quotedMsg: null, quotedMsgAdminGroupJid: null }); | ||
window.WAPI.getNewId = function () { | ||
var text = ""; | ||
var text = ""; | ||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
@@ -399,3 +399,3 @@ | ||
// get chat and its messages | ||
let chat = WAPI.getChat(id); | ||
let chat = WAPI.getChat(id); | ||
let messages = chat.msgs._models; | ||
@@ -423,4 +423,4 @@ | ||
let message = WAPI.processMessageObj(messageObj, | ||
includeMe, | ||
includeNotifications); | ||
includeMe, | ||
includeNotifications); | ||
@@ -437,3 +437,3 @@ // save processed message on result list | ||
} | ||
; | ||
; | ||
@@ -571,3 +571,3 @@ | ||
const output = (await WAPI._getGroupParticipants(id)) | ||
.map((participant) => participant.id); | ||
.map((participant) => participant.id); | ||
@@ -580,4 +580,4 @@ if (done !== undefined) done(output); | ||
const output = (await WAPI._getGroupParticipants(id)) | ||
.filter((participant) => participant.isAdmin) | ||
.map((admin) => admin.id); | ||
.filter((participant) => participant.isAdmin) | ||
.map((admin) => admin.id); | ||
@@ -631,4 +631,4 @@ if (done !== undefined) done(output); | ||
window.WAPI.getAllMessagesInChat = function (id, includeMe, includeNotifications, done) { | ||
const chat = WAPI.getChat(id); | ||
let output = []; | ||
const chat = WAPI.getChat(id); | ||
let output = []; | ||
const messages = chat.msgs._models; | ||
@@ -651,4 +651,4 @@ | ||
window.WAPI.getAllMessageIdsInChat = function (id, includeMe, includeNotifications, done) { | ||
const chat = WAPI.getChat(id); | ||
let output = []; | ||
const chat = WAPI.getChat(id); | ||
let output = []; | ||
const messages = chat.msgs._models; | ||
@@ -658,4 +658,4 @@ | ||
if ((i === "remove") | ||
|| (!includeMe && messages[i].isMe) | ||
|| (!includeNotifications && messages[i].isNotification)) { | ||
|| (!includeMe && messages[i].isMe) | ||
|| (!includeNotifications && messages[i].isNotification)) { | ||
continue; | ||
@@ -735,3 +735,3 @@ } | ||
window.WAPI.sendMessageToID = function (id, message, done) { | ||
if (window.Store.Chat.length == 0) | ||
if (window.Store.Chat.length == 0) | ||
return false; | ||
@@ -742,3 +742,5 @@ firstChat = Store.Chat.models[0]; | ||
if (done !== undefined) { | ||
firstChat.sendMessage(message).then(function () { | ||
window.Store.SendTextMsgToChat(firstChat, message).then(function () { | ||
firstChat.id = originalID; | ||
@@ -749,4 +751,7 @@ done(true); | ||
} else { | ||
firstChat.sendMessage(message); | ||
window.Store.SendTextMsgToChat(firstChat, message); | ||
firstChat.id = originalID; | ||
return true; | ||
@@ -760,3 +765,3 @@ } | ||
if (done !== undefined) { | ||
chat.sendMessage(message).then(function () { | ||
window.Store.SendTextMsgToChat(chat, message).then(function () { | ||
function sleep(ms) { | ||
@@ -790,3 +795,3 @@ return new Promise(resolve => setTimeout(resolve, ms)); | ||
} else { | ||
chat.sendMessage(message); | ||
window.Store.SendTextMsgToChat(chat, message) | ||
return true; | ||
@@ -853,4 +858,4 @@ } | ||
window.WAPI.getUnreadMessages = function (includeMe, includeNotifications, use_unread_count, done) { | ||
const chats = window.Store.Chat.models; | ||
let output = []; | ||
const chats = window.Store.Chat.models; | ||
let output = []; | ||
@@ -863,3 +868,3 @@ for (let chat in chats) { | ||
let messageGroupObj = chats[chat]; | ||
let messageGroup = WAPI._serializeChatObj(messageGroupObj); | ||
let messageGroup = WAPI._serializeChatObj(messageGroupObj); | ||
@@ -1044,3 +1049,3 @@ messageGroup.messages = []; | ||
window.WAPI.deleteConversation = function (chatId, done) { | ||
let userId = new window.Store.UserConstructor(chatId, {intentionallyUsePrivateConstructor: true}); | ||
let userId = new window.Store.UserConstructor(chatId, { intentionallyUsePrivateConstructor: true }); | ||
let conversation = WAPI.getChat(userId); | ||
@@ -1068,8 +1073,8 @@ | ||
window.WAPI.deleteMessage = function (chatId, messageArray, revoke=false, done) { | ||
let userId = new window.Store.UserConstructor(chatId, {intentionallyUsePrivateConstructor: true}); | ||
window.WAPI.deleteMessage = function (chatId, messageArray, revoke = false, done) { | ||
let userId = new window.Store.UserConstructor(chatId, { intentionallyUsePrivateConstructor: true }); | ||
let conversation = WAPI.getChat(userId); | ||
if(!conversation) { | ||
if(done !== undefined) { | ||
if (!conversation) { | ||
if (done !== undefined) { | ||
done(false); | ||
@@ -1085,5 +1090,5 @@ } | ||
if (revoke) { | ||
conversation.sendRevokeMsgs(messageArray, conversation); | ||
conversation.sendRevokeMsgs(messageArray, conversation); | ||
} else { | ||
conversation.sendDeleteMsgs(messageArray, conversation); | ||
conversation.sendDeleteMsgs(messageArray, conversation); | ||
} | ||
@@ -1100,5 +1105,5 @@ | ||
window.WAPI.checkNumberStatus = function (id) { | ||
return window.Store.WapQuery.queryExist(id).then((result) => { | ||
return window.WAPI._serializeNumberStatusObj(result); | ||
return window.Store.WapQuery.queryExist(id).then((result) => { | ||
return window.WAPI._serializeNumberStatusObj(result); | ||
}); | ||
@@ -1111,4 +1116,4 @@ | ||
*/ | ||
window.WAPI._newMessagesQueue = []; | ||
window.WAPI._newMessagesBuffer = (sessionStorage.getItem('saved_msgs') != null) ? JSON.parse(sessionStorage.getItem('saved_msgs')) : []; | ||
window.WAPI._newMessagesQueue = []; | ||
window.WAPI._newMessagesBuffer = (sessionStorage.getItem('saved_msgs') != null) ? JSON.parse(sessionStorage.getItem('saved_msgs')) : []; | ||
window.WAPI._newMessagesDebouncer = null; | ||
@@ -1135,3 +1140,3 @@ window.WAPI._newMessagesCallbacks = []; | ||
window.WAPI._newMessagesDebouncer = null; | ||
window.WAPI._newMessagesQueue = []; | ||
window.WAPI._newMessagesQueue = []; | ||
@@ -1205,21 +1210,21 @@ let removeCallbacks = []; | ||
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); | ||
//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); | ||
}); | ||
}); | ||
}); | ||
} | ||
window.WAPI.base64ImageToFile = function (b64Data, filename) { | ||
var arr = b64Data.split(','); | ||
var mime = arr[0].match(/:(.*?);/)[1]; | ||
var bstr = atob(arr[1]); | ||
var n = bstr.length; | ||
var arr = b64Data.split(','); | ||
var mime = arr[0].match(/:(.*?);/)[1]; | ||
var bstr = atob(arr[1]); | ||
var n = bstr.length; | ||
var u8arr = new Uint8Array(n); | ||
@@ -1231,3 +1236,3 @@ | ||
return new File([u8arr], filename, {type: mime}); | ||
return new File([u8arr], filename, { type: mime }); | ||
}; | ||
@@ -1264,5 +1269,5 @@ | ||
newMsgId.fromMe = true; | ||
newMsgId.id = WAPI.getNewId().toUpperCase(); | ||
newMsgId.remote = chatId; | ||
newMsgId.fromMe = true; | ||
newMsgId.id = WAPI.getNewId().toUpperCase(); | ||
newMsgId.remote = chatId; | ||
newMsgId._serialized = `${newMsgId.fromMe}_${newMsgId.remote}_${newMsgId.id}` | ||
@@ -1280,13 +1285,13 @@ | ||
window.WAPI.sendVCard = function (chatId, vcard) { | ||
var chat = Store.Chat.get(chatId); | ||
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 newId = window.WAPI.getNewMessageId(chatId); | ||
var extend = { | ||
ack : 0, | ||
id : newId, | ||
local : !0, | ||
self : "out", | ||
t : parseInt(new Date().getTime() / 1000), | ||
to : chatId, | ||
ack: 0, | ||
id: newId, | ||
local: !0, | ||
self: "out", | ||
t: parseInt(new Date().getTime() / 1000), | ||
to: chatId, | ||
isNewMsg: !0, | ||
@@ -1297,3 +1302,3 @@ }; | ||
Object.assign(extend, { | ||
type : "multi_vcard", | ||
type: "multi_vcard", | ||
vcardList: vcard | ||
@@ -1305,5 +1310,5 @@ }); | ||
Object.assign(extend, { | ||
type : "vcard", | ||
type: "vcard", | ||
subtype: vcard.displayName, | ||
body : vcard.vcard | ||
body: vcard.vcard | ||
}); | ||
@@ -1310,0 +1315,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76498