mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-20 04:29:15 +00:00
feat: disable / enable WA Web features (#543)
* Added Features and Enabling/Disabling of Features within WhatsappWeb * remove feature commands from example Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com> Co-authored-by: Pedro Lopez <pedroslopez@me.com>
This commit is contained in:
@@ -192,7 +192,7 @@ client.on('message', async msg => {
|
|||||||
const chat = await msg.getChat();
|
const chat = await msg.getChat();
|
||||||
// stops typing or recording in the chat
|
// stops typing or recording in the chat
|
||||||
chat.clearState();
|
chat.clearState();
|
||||||
} else if (msg.body === 'jumpto') {
|
} else if (msg.body === '!jumpto') {
|
||||||
if (msg.hasQuotedMsg) {
|
if (msg.hasQuotedMsg) {
|
||||||
const quotedMsg = await msg.getQuotedMessage();
|
const quotedMsg = await msg.getQuotedMessage();
|
||||||
client.interface.openChatWindowAt(quotedMsg.id._serialized);
|
client.interface.openChatWindowAt(quotedMsg.id._serialized);
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|||||||
window.Store.Sticker = window.mR.findModule('Sticker')[0].default.Sticker;
|
window.Store.Sticker = window.mR.findModule('Sticker')[0].default.Sticker;
|
||||||
window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
|
window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
|
||||||
window.Store.Label = window.mR.findModule('LabelCollection')[0].default;
|
window.Store.Label = window.mR.findModule('LabelCollection')[0].default;
|
||||||
|
window.Store.Features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0].default;
|
||||||
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
|
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
|
||||||
window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
|
window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.LoadUtils = () => {
|
exports.LoadUtils = () => {
|
||||||
|
|||||||
@@ -74,6 +74,48 @@ class InterfaceController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all Features
|
||||||
|
*/
|
||||||
|
async getFeatures() {
|
||||||
|
return await this.pupPage.evaluate(() => {
|
||||||
|
return window.Store.Features.F;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Feature is enabled
|
||||||
|
* @param {string} feature status to check
|
||||||
|
*/
|
||||||
|
async checkFeatureStatus(feature) {
|
||||||
|
return await this.pupPage.evaluate((feature) => {
|
||||||
|
return window.Store.Features.supportsFeature(feature);
|
||||||
|
}, feature);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable Features
|
||||||
|
* @param {string[]} features to be enabled
|
||||||
|
*/
|
||||||
|
async enableFeatures(features) {
|
||||||
|
await this.pupPage.evaluate((features) => {
|
||||||
|
for (const feature in features) {
|
||||||
|
window.Store.Features.setFeature(features[feature], true);
|
||||||
|
}
|
||||||
|
}, features);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable Features
|
||||||
|
* @param {string[]} features to be disabled
|
||||||
|
*/
|
||||||
|
async disableFeatures(features) {
|
||||||
|
await this.pupPage.evaluate((features) => {
|
||||||
|
for (const feature in features) {
|
||||||
|
window.Store.Features.setFeature(features[feature], false);
|
||||||
|
}
|
||||||
|
}, features);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = InterfaceController;
|
module.exports = InterfaceController;
|
||||||
|
|||||||
Reference in New Issue
Block a user