|
|
@@ -66,7 +66,7 @@ function callbacks(client, callback, type = "create") { |
|
|
|
// console.log(`state => ${state}`); |
|
|
|
}); |
|
|
|
client.on("authenticated", (session) => { |
|
|
|
// console.log("authenticated"); |
|
|
|
console.log("authenticated"); |
|
|
|
try { |
|
|
|
sessionData = session; |
|
|
|
// fs.writeFileSync(SESSION_FILE_PATH, JSON.stringify(session)); |
|
|
@@ -132,7 +132,7 @@ var createNewClient = async function (callback) { |
|
|
|
}); |
|
|
|
|
|
|
|
callbacks(client, callback); |
|
|
|
|
|
|
|
console.log("initialize"); |
|
|
|
client.initialize(); |
|
|
|
//var clientInfo = await getClientInfo(); |
|
|
|
//return clientInfo; |
|
|
@@ -173,6 +173,18 @@ var getChatbyPhoneNumber = async function (phone_number) { |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
var getAllChats = async function () { |
|
|
|
try { |
|
|
|
if (!client.info) { |
|
|
|
throw { message: "Client Is Not Ready !" }; |
|
|
|
} |
|
|
|
let chatList = await client.getChats(); |
|
|
|
return { STATUS: 1, DATA: chatList }; |
|
|
|
} catch (e) { |
|
|
|
return { STATUS: 0, DATA: e.message }; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
var getClientInfo = function () { |
|
|
|
try { |
|
|
|
var a; |
|
|
@@ -245,4 +257,5 @@ module.exports = { |
|
|
|
getClientState: getClientState, |
|
|
|
getChatbyPhoneNumber: getChatbyPhoneNumber, |
|
|
|
asyncLoadClient: asyncLoadClient, |
|
|
|
getAllChats: getAllChats, |
|
|
|
}; |