Skip to content

Commit

Permalink
Merge branch 'master' into master3
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelo386 authored Oct 24, 2023
2 parents 19b2028 + 4cdb5d3 commit 50c5014
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/config/create-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export const defaultOptions: CreateConfig = {
waitForLogin: true,
logger: defaultLogger,
tokenStore: 'file',
whatsappVersion: '2.2331.x',
whatsappVersion: '2.2346.x',
deviceName: false,
linkPreviewApiServers: null,
disableGoogleAnalytics: true,
Expand Down
68 changes: 68 additions & 0 deletions src/lib/wapi/wapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,33 @@ if (typeof window.WAPI === 'undefined') {
return window.Debug.VERSION;
};

/**
* @param NumberChatsDelete Number of chats that will be deleted
*/
//Add Marcelo 21/10/2023
window.WAPI.deleteOldChats = async function (NumberChatsDelete) {
const options = {
onlyWithUnreadMessage: false,
onlyUsers: true,
};

try {
const chats = await window.WAPI.chat.list(options);
chats.reverse();
const numChatsToDelete = Math.min(NumberChatsDelete, chats.length);

for (let i = 0; i < numChatsToDelete; i++) {
await window.WAPI.chat
.delete(chats[i].id._serialized)
.then((_) => true)
.catch((_) => false);
}
} catch (e) {
console.error('Erro:', e);
return e;
}
};

/**
* @param id The id of the conversation
* @param archive boolean true => archive, false => unarchive
Expand Down Expand Up @@ -422,6 +449,47 @@ if (typeof window.WAPI === 'undefined') {
}
};

* @param content Status Message Text
* @param options {backgroundColor: '#0275d8', font: 2}
*/
window.WAPI.sendTextStatus = async function (content, options) {
try {
const result = await WPP.status.sendTextStatus(content, options);
return result;
} catch (err) {
console.log(err);
return err;
}
};

/**
* @param base64 data:image/jpeg;base64,<a long base64 file...>
* @param options {backgroundColor: '#0275d8', font: 2}
*/
window.WAPI.sendImageStatus = async function (base64, options) {
try {
const result = await WPP.status.sendImageStatus(base64, options);
return result;
} catch (err) {
console.log(err);
return err;
}
};

/**
* @param base64 data:video/mp4;base64,<a long base64 file...>
* @param options {backgroundColor: '#0275d8', font: 2}
*/
window.WAPI.sendVideoStatus = async function (base64, options) {
try {
const result = await WPP.status.sendVideoStatus(base64, options);
return result;
} catch (err) {
console.log(err);
return err;
}
};

window.WAPI.takeOver = async function () {
await WPP.whatsapp.Socket.takeover();
return true;
Expand Down

0 comments on commit 50c5014

Please sign in to comment.