diff --git a/src/config/create-config.ts b/src/config/create-config.ts index 463897761..ae39b38ed 100644 --- a/src/config/create-config.ts +++ b/src/config/create-config.ts @@ -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, diff --git a/src/lib/wapi/wapi.js b/src/lib/wapi/wapi.js index 6f0cd80ad..44b2a9eda 100644 --- a/src/lib/wapi/wapi.js +++ b/src/lib/wapi/wapi.js @@ -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 @@ -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, + * @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, + * @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;