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AAO,eAAe,EACtC,CAOA,uBAAM,CAAkB,GACpB,OAAO,KAAK,OAAO,kBAAkB,EACzC,CAOA,cAAM,CAAS,EAAQ,GACnB,KAAK,OAAO,SAAS,EAAQ,EACjC,CAMA,gBAAM,CAAW,GACb,KAAK,OAAO,WAAW,EAC3B,CAMA,aAAM,CAAQ,GACV,OAAO,KAAK,OAAO,QAAQ,EAC/B,CAMA,eAAM,CAAU,GACZ,OAAO,KAAK,OAAO,UAAU,EACjC,CAMA,iBAAM,CAAY,GACd,OAAO,KAAK,OAAO,YAAY,EACnC,CAMA,mBAAM,CAAc,GAChB,OAAO,KAAK,OAAO,cAAc,EACrC,CAMA,cAAM,GACF,OAAO,KAAK,OAAO,UACvB,CAKA,gBAAM,GACF,OAAO,KAAK,OAAO,YACvB,CAKA,MAAA,GACO,KAAK,SACJ,KAAK,OAAO,SAEZ,QAAQ,KAAK,+BAErB,CAIA,OAAA,GACI,OAAO,KAAK,QAChB,CAIA,KAAA,GACI,KAAK,OAAO,OAChB,EAGJ,OAAO,QAAU","file":"/npm/wabot@1.4.9/src/WABOT.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/wabot@1.4.9/src/WABOT.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const EventEmitter = require('events');\nconst Merge = require('merge-anything');\nconst fs = require('fs');\nconst path = require('path');\nvar scrape = require('html-metadata');\nconst _WABOT = require('../lib/browser');\nconst ConvertBase64 = require('../lib/convertBase64');\nconst Stickers = require('../lib/stickers');\nconst Vcards = require('../lib/vcards');\nconst TYPES = require('../types/validTypes');\nconst types = new TYPES();\nconst convert64 = new ConvertBase64();\nconst vcard = new Vcards();\nconst puppeteerDefault = require('../types/puppeteer.config.json');\nconst intentsDefault = require('../types/intents.json');\n\nTHUMB_DEFAULT_URL = 'https://icon-library.com/images/url-icon-png/url-icon-png-20.jpg'\n\nconst Params = require('./params');\nconst getRandomItem = (array) => {\n    return array[Math.floor(Math.random()*array.length)]\n}\n\nconst randomUUI = (a,b) => {for(b=a='';a++<36;b+=a*51&52?(a^15?8^Math.random()*(a^20?16:4):4).toString(16):'');return b}\n\nconst escapeRegExp = (string) => {\n    return string.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nconst replaceAll = (str, term, replacement) => {\n  return str.replace(new RegExp(escapeRegExp(term), 'g'), replacement);\n}\n/**\n *WABOT class for interact whit whatsapp web\n *\n * @class WABOT\n * @extends {EventEmitter}\n * @param {object} opts - Wabot options\n * @param {object} opts.puppeteerConfig - Puppeteer launch options\n * @param {string} opts.puppeteerConfig.WAUrl - Whatsapp Web Url\n * @param {string} opts.puppeteerConfig.sessionPath - Path to save the session info for restore this in the future\n * @param {boolean} opts.puppeteerConfig.viewBrowser - Show browser (headless)\n * @param {boolean} opts.puppeteerConfig.opendevtools - Show devtools (console)\n * @param {string} opts.puppeteerConfig.userAgent - User Agent for web browser \n * @param {number} opts.puppeteerConfig.width - Width for web browser \n * @param {number} opts.puppeteerConfig.heigth - Height for web browser\n * @param {boolean} opts.puppeteerConfig.dowloadChromeVersion - Download chromium browser or use local google chome\n * @param {number} opts.puppeteerConfig.chromeVersion - Version of chromium to download\n * @param {string} opts.puppeteerConfig.localChromePath - Google chrome executable path\n * @param {string} opts.puppeteerConfig.getInitScreenshot - Allows you to take a screenshot when you start WhatsApp in order to detect problems when running in headless mode\n * @param {string} opts.puppeteerConfig.localChromePath - File name to save the screenshot\n * @param {string} opts.puppeteerConfig.args - Args to open the web browser\n * @param {object} opts.intentConfig - Execution and internal options\n * @param {boolean} opts.intentConfig.showContent - Display chats in browser\n * @param {string} opts.intentConfig.debug - Debug mode for view console logs\n * @param {string[]} opts.intentConfig.removeBgApis - Api keys for https://www.remove.bg\n * @param {object} opts.intentConfig.plugins - Options for plugins config \n * @param {string} opts.intentConfig.plugins.folder - Folder containing the plugins\n * @param {string[]} opts.intentConfig.plugins.plugins - Array containing the plugin names to use\n * @param {object} opts.intentConfig.plugins.setup - Configuration of each plugin\n * @param {object} opts.intentConfig.executions - Options for control chats\n * @param {boolean} opts.intentConfig.executions.reponseUsers - Control response to users \n * @param {boolean} opts.intentConfig.executions.simulateTyping - Simulate typing in chat \n * @param {number} opts.intentConfig.executions.timeSimulate - Time in ms for simulate typing \n * @param {boolean} opts.intentConfig.executions.contorlExecutions - Control chats to enqueue messages \n * @param {number} opts.intentConfig.executions.maxExecutions - Max messages to process in the same time\n * @param {number} opts.intentConfig.executions.timeInterval - Time in seconds to queue messages\n * @param {number} opts.intentConfig.executions.timePending - Time in minutes to search for pending messages\n * @param {boolean} opts.intentConfig.executions.sendSeen - Send seen ticket \n * @param {boolean} opts.intentConfig.executions.sendSeenFull - Send seen ticket to all pending messages on login\n * @param {number} opts.intentConfig.executions.intervalSendSeen - Time in minutes for search pending messages to send seen\n * @param {object} opts.intentConfig.bann - Bann options \n * @param {boolean} opts.intentConfig.bann.active - Control bann users\n * @param {number} opts.intentConfig.bann.timeInterval - Time in seconds to validate spam messages\n * @param {number} opts.intentConfig.bann.maxBann - Maximum number of messages allowed in the indicated amount of time\n * @param {number} opts.intentConfig.bann.timeBann - Time in minutes for temporary ban\n * @param {number} opts.intentConfig.bann.timeInactive - Time in minutes to release banned users who are inactive for the specified time\n * @param {string[]} opts.intentConfig.bann.whiteList - List of users who will not be banned\n * @param {object} opts.intentConfig.messages - Message settings\n * @param {string} opts.intentConfig.messages.userBanned - Message to display when a user is banned\n * @param {string} opts.intentConfig.messages.groupBanned - Message to display when a group is banned\n * @param {string} opts.intentConfig.messages.privileges - Message to display when you do not have privileges to use the bot\n * @param {string[]} opts.intentConfig.blocked - List of users who cannot use the bot\n * @param {string[]} opts.intentConfig.whiteList - List of users who can use the bot\n * @param {object[]} opts.intentConfig.commands - List of commands to evaluate in user messages\n * @param {string} opts.intentConfig.commands.name - Name of the command\n * @param {string[]} opts.intentConfig.commands.contains - Contains word on message\n * @param {string[]} opts.intentConfig.commands.exact - Message is the same as what is contained here\n * @param {object[]} opts.intentConfig.commands.params - Parameters to require\n * @param {string} opts.intentConfig.commands.params.name - Name of the param\n * @param {boolean} opts.intentConfig.commands.params.isNumber - Is a number param\n * @param {string[]} opts.intentConfig.commands.params.request - Questions to request the parameter\n * @param {string[]} opts.intentConfig.commands.params.values - Allowed values. If any is allowed, \"any\" must be indicated\n * @param {string[]} opts.intentConfig.commands.params.badResponse - Messages to send in case of illegal values\n * @param {object} opts.session - Object containing session information. Can be used to restore the session.\n * @param {string} opts.session.WABrowserId\n * @param {string} opts.session.WASecretBundle\n * @param {string} opts.session.WAToken1\n * @param {string} opts.session.WAToken2\n * \n * @fires WABOT#ready\n * @fires WABOT#onStateChanged\n * @fires WABOT#onMessageFromBloqued\n * @fires WABOT#onMessageFromNoPrivileges\n * @fires WABOT#waitNewAcknowledgements\n * @fires WABOT#onBattery\n * @fires WABOT#onPlugged\n * @fires WABOT#onRemovedFromGroup\n * @fires WABOT#onParticipantsChanged\n * @fires WABOT#onMessageMediaUploadedEvent\n * @fires WABOT#vcard\n * @fires WABOT#message\n * @fires WABOT#command\n */\nclass WABOT extends EventEmitter {\n    constructor(opts = {}){\n        super();\n        // Messages callbacks history\n        this.callbacks = [];\n        this.isLogged = false;\n        if(opts !== undefined && typeof opts === 'object'){\n            this.puppeterConfig = opts.puppeteerConfig || {}; \n            this.intentConfig = opts.intentsConfig || {};\n        }else {\n            this.puppeterConfig = puppeteerDefault;\n            this.intentConfig = intentsDefault;\n        }\n\n        this.puppeteerConfig = this.mergeOpts(puppeteerDefault, this.puppeterConfig);\n        this.intentConfig = this.mergeOpts(intentsDefault, this.intentConfig);\n\n        this.sticker = new Stickers(this.intentConfig.removeBgApis);\n\n        // Add plugins\n        if (this.intentConfig.plugins.plugins.length > 0) {\n            this.addPlugins(this.intentConfig.plugins);\n        }\n\n        this._wabot = new _WABOT({\n            puppeteerConfig: this.puppeteerConfig,\n            intentConfig: this.intentConfig,\n            session: opts.session\n        });\n\n        this._wabot.on('message', (arg) => {\n            try {\n                this.getNewMessages(arg);\n            } catch (err) {\n                console.error('Error on new message', err);\n            }\n        });\n\n        this._wabot.on('onStateChanged', (arg) => {\n            /**\n            * Emitted when the connection state changes\n            * @event WABOT#onStateChanged\n            * @param {object} arg - State info\n            */\n            this.emit('onStateChanged', arg);\n        });\n\n        this._wabot.on('onMessageFromBloqued', (arg) => {\n            /**\n             * Emitted when a message is received from a bloqued user\n             * @event WABOT#onMessageFromBloqued\n             * @param {object} arg - Message info\n             */\n            this.emit('onMessageFromBloqued', arg);\n        });\n\n        this._wabot.on('onMessageFromNoPrivileges', (arg) => {\n            /**\n             * Emitted when a message is received from a non-privileged user\n             * @event WABOT#onMessageFromNoPrivileges\n             * @param {object} arg - Message info\n             */\n            this.emit('onMessageFromNoPrivileges', arg);\n        });\n    \n        this._wabot.on('waitNewAcknowledgements', (arg) => {\n            /**\n             * Emitted when a the acknowledgement state of a message changes.\n             * @event WABOT#waitNewAcknowledgements\n             * @param {object} arg \n             */\n            this.emit('waitNewAcknowledgements', arg);\n        });\n    \n        this._wabot.on('onBattery', (arg) => {\n            /**\n             * Emitted when the battery percentage for the attached device changes\n             * @event WABOT#onBattery\n             * @param {number} arg - The current battery percentage\n             */\n            this.emit('onBattery', arg);\n        });\n    \n        this._wabot.on('onPlugged', (arg) => {\n            /**\n             * Emitted when add a participant of the group \n             * @event WABOT#onPlugged\n             * @param {boolean} arg - True or False\n             */\n            this.emit('onPlugged', arg);\n        });\n    \n        this._wabot.on('onAddedToGroup', (arg) => {\n            /**\n             * Emitted when add a participant of the group \n             * @event WABOT#onAddedToGroup\n             * @param {object} arg \n             */\n            this.emit('onAddedToGroup', arg);\n        });\n    \n        this._wabot.on('onRemovedFromGroup', (arg) => {\n            /**\n             * Emitted when remove a participant of the group \n             * @event WABOT#onRemovedFromGroup\n             * @param {object} arg \n             */\n            this.emit('onRemovedFromGroup', arg);\n        });\n    \n        this._wabot.on('onParticipantsChanged', (arg) => {\n            /**\n             * Emitted when a participant of the group change \n             * @event WABOT#onParticipantsChanged\n             * @param {object} arg \n             * @param {string} arg.by \n             * @param {string} arg.action - Promote or Demote\n             * @param {string} arg.who - Id of the user  \n             */\n            this.emit('onParticipantsChanged', arg);\n        });\n        \n        this._wabot.on('onMessageMediaUploadedEvent', (arg) => {\n            /**\n             * Emitted when media has been uploaded for a message sent by the client.\n             * @event WABOT#onMessageMediaUploadedEvent\n             * @param {object} message - The message with media that was uploaded\n             */\n            this.emit('onMessageMediaUploadedEvent', arg);\n        });\n\n        this._wabot.on('ready', (session) => {\n            this.isLogged = true;\n            /**\n             * Emitted when WABOT is ready to work\n             * @event WABOT#ready\n             * @param {object} session Object containing session information. Can be used to restore the session.\n             * @param {string} session.WABrowserId\n             * @param {string} session.WASecretBundle\n             * @param {string} session.WAToken1\n             * @param {string} session.WAToken2\n             */\n            this.emit('ready', session);\n        })\n\n        process.on('SIGINT', async () => {\n            console.log('Unexpected closure, we will close the browser for greater security!');\n            await this._wabot.destroy();\n        });\n\n        process.on('SIGQUIT', async () => {\n            console.log('Unexpected closure, we will close the browser for greater security!');\n            this._wabot.destroy();\n        });\n    }\n\n    mergeOpts (defaultOpts, customOpts) {\n        return Merge.merge(defaultOpts, customOpts);\n    }\n\n    emitMessage (type, arg){\n        switch (type) {\n            case 'message': \n                /**\n                * Emitted when an uncontrolled message is received\n                * @event WABOT#message\n                * @param {object} arg - Message Info\n                */\n                this.emit('message', arg); \n                break;\n            case 'vcard': \n                /**\n                * Emitted when a vcard pis received\n                * @event WABOT#vcard\n                * @param {object} arg - Message Info\n                */\n                this.emit('message', arg); \n                break;\n            default: \n                /**\n                * Emitted when a command is detected\n                * @event WABOT#command\n                * @param {object} arg - Message Info\n                */\n                this.emit(type, arg); \n                break;\n        }\n        \n    }\n\n    async getNewMessages(arg) {\n        let _this = this;\n        if (this.intentConfig.commands.length === 0) {\n            switch (arg.data.type) {\n                case \"vcard\":\n                    vcard.extractVcard(arg.data.content)\n                    .then(res => {\n                        arg.data.vcard = res; \n                        _this.emitMessage('vcard', arg);\n                    });\n                    break;\n                case \"document\": case \"sticker\": case \"video\": case \"gif\":\n                    _this.emitMessage('message', arg);\n                    break;\n                default:\n                    _this.emitMessage('message', arg);\n                    break;\n            }\n        } else {\n            switch (arg.data.type) {\n                case \"vcard\":\n                    vcard.extractVcard(arg.data.content)\n                    .then(res => {\n                        arg.data.vcard = res; \n                        _this.emitMessage('vcard', arg);\n                    });\n                    break;\n                case \"sticker\": case \"video\": case \"gif\":\n                    _this.emitMessage('message', arg);\n                    break;\n                case \"document\": \n                    if (!await _this.validCallbackResponse({\n                        idChat: arg.data.from, \n                        message: arg\n                    })){\n                        _this.emitMessage('message', arg);\n                    }\n                    break;\n                default:\n                    \n                    let exactMatch, PartialMatch, _match, _find;\n                    let response = arg;\n                    _find = false;\n                    let _message; \n                    if (arg.data.type === 'chat'){\n                        _message = arg.data.body;\n                    }else {\n                        _message = arg.data.caption;\n                    }\n\n                    if (_message === undefined) _message = '';\n\n                    exactMatch = this.intentConfig.commands.find(obj => obj.exact.find(ex => ex.toLowerCase() == _message.toLowerCase()));\n                    if (exactMatch !== undefined) {\n                        response.params = Params.getParams(exactMatch, '');\n                        _match = exactMatch;\n                        _find = true;\n                    }else{\n                        let exactMatch = this.intentConfig.commands.find(obj => obj.exact.find(ex => _message.toLowerCase().trim().indexOf(ex.toLowerCase().trim()) === 0));\n                        if (exactMatch != undefined && exactMatch.params) {\n                            let initCommand = exactMatch.exact.find(ex => _message.toLowerCase().trim().indexOf(ex.toLowerCase().trim()) === 0);\n                            let _arguments = _message.toLowerCase().replace(initCommand.toLowerCase(), \"\").trim();\n                            response.params = Params.getParams(exactMatch, _arguments);\n                            if (typeof exactMatch.params !== 'undefined' && exactMatch.params.length > 0){\n                                _match = exactMatch;\n                                _find = true;\n                            }\n                        }else{\n                            PartialMatch = this.intentConfig.commands.find(obj => obj.contains !== undefined && obj.contains.find(ex => _message.toLowerCase().search(ex.toLowerCase()) > -1));\n                            if (PartialMatch != undefined) {\n                                if (PartialMatch.isFile) PartialMatch['values'] = \"any\";\n                                _match = PartialMatch;\n                                _find = true;\n                            }\n                        }\n                    }\n\n                    if (!_find) {\n                        if (!await _this.validCallbackResponse({\n                            idChat: arg.data.from, \n                            message: arg\n                        })) {\n                            _this.emitMessage('message', arg);\n                        }\n                    } else {\n                        _this.releaseCallback(arg.data.from);\n                        // Request first param else emit intent\n                        if (_match.params && Array.isArray(_match.params) && _match.params.length > 0){                            \n                            let index = Params.getNextPendingValue(_match, response.params);\n                            if (index === 'no_data') {\n                                _this.emitMessage(_match.name, response);\n                            } else {\n                                if (typeof _match.params[index] === 'object'){\n                                    _this.executeCallback({\n                                        idChat: arg.data.from, \n                                        message: arg.data, \n                                        intent: _match,\n                                        idParam: index,\n                                        values: response.params\n                                    });\n                                } else {\n                                    _this.emitMessage(_match.name, response);\n                                }\n                            }\n                        } else {\n                            _this.emitMessage(_match.name, response);\n                        }\n                    }\n                    break;\n            }\n        }\n    }\n\n    validCallback(args){\n        if (typeof this.callbacks[args.idChat] !== 'undefined'){\n            if (this.callbacks[args.idChat].isFinished) {\n                this.releaseCallback(args.idChat);\n                return false;\n            } else {\n                return true;\n            }\n        } else {\n            return false;\n        }\n    }\n\n    async validCallbackResponse(args){\n        if (this.validCallback({idChat: args.idChat})){\n            let caption = \"\";\n            if (args.message.data.type === 'chat'){\n                caption = args.message.data.body;\n            } else {\n                caption = args.message.data.caption;\n            }\n            caption = caption.trim().toLowerCase();\n            const _possibleValues = this.callbacks[args.idChat].possibleValues;\n            let currentParam = this.callbacks[args.idChat].currentParam;\n            const requireFile = this.callbacks[args.idChat].requireFile;\n            let response;\n            if (requireFile) {\n                if (args.message.data.type === 'document') {\n                    const file = await this.downloadFile(args.message.data.id);\n                    const pathFile = path.join(this.intentConfig.downloadPath, `${randomUUI()}${path.extname(args.message.data.filename)}`);\n                    fs.writeFileSync(pathFile, file.split(';base64,').pop(), {encoding: 'base64'});\n                    response = pathFile;\n                }\n            } else if (typeof _possibleValues === 'object'){\n                response = Object.keys(_possibleValues).find(key => _possibleValues[key].find(obj => obj.toLowerCase() == caption));\n            } else {\n                if ( _possibleValues === 'any' ) {\n                    if (this.callbacks[args.idChat].intent.params[currentParam].isNumber){\n                        try {\n                            response = isNaN(parseInt(caption)) ? '' : parseInt(caption);\n                        } catch (e) {\n                            response = '';\n                        }\n                    } else {\n                        response = caption;\n                    }\n                }\n            }\n            if (response !== undefined && response !== '') {\n                let param = this.callbacks[args.idChat].intent.params[currentParam].name;\n                let value;\n                if (requireFile) value = response;\n                else if (typeof _possibleValues === 'object'){\n                    if (this.callbacks[args.idChat].customValues.length > 0) {\n                        value = this.callbacks[args.idChat].customValues[response].value;\n                    } else {\n                        if (typeof this.callbacks[args.idChat].intent.params[currentParam].values[response] === 'object') {\n                            value = this.callbacks[args.idChat].intent.params[currentParam].values[response].value;\n                        } else {\n                            value = this.callbacks[args.idChat].intent.params[currentParam].values[response];\n                        }\n                    }\n                } else {\n                    value = response;\n                }\n                this.callbacks[args.idChat].values[param] = value;\n                currentParam = Params.getNextPendingValue(this.callbacks[args.idChat].intent, this.callbacks[args.idChat].values);\n                if (currentParam === 'no_data') {\n                    this.callbacks[args.idChat].isFinished = true;\n                    let _message = args.message;\n                    _message.params = this.callbacks[args.idChat].values;\n                    this.emitMessage(this.callbacks[args.idChat].intent.name, _message);\n                } else {\n                    this.callbacks[args.idChat].currentParam = currentParam;\n                    this.executeCallback({\n                        idChat: args.idChat, \n                        message: args.message, \n                        intent: this.callbacks[args.idChat].intent,\n                        idParam: currentParam,\n                        values: this.callbacks[args.idChat].values\n                    });\n                }\n            } else {\n                let text = getRandomItem(this.callbacks[args.idChat].intent.params[currentParam].badResponse);\n                this.sendMessage({\n                    \"idChat\": args.idChat,\n                    \"message\": text\n                });\n            }\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    releaseCallback(idChat){\n        if (typeof this.callbacks[idChat] !== 'undefined'){\n            delete this.callbacks[idChat];\n        }\n    }\n\n    executeCallback(args){\n        let index = args.idParam;\n        let _values = {};\n        let _possibleValues = {};\n        let _customValues = [];\n        let cont = 0;\n        if (this.validCallback({idChat: args.idChat})){\n            _values = this.callbacks[args.idChat].values;\n        } else {\n            _values = args.values;\n        }\n\n        let isFile = false;\n        if (args.intent.params[index].isFile) {\n            isFile = args.intent.params[index].isFile;\n        } else if (Array.isArray(args.intent.params[index].values)){\n            // If custom values ​​are configured\n            let valuesToDisplay = [];\n            if (args.intent.params[index].customValues && args.intent.params[index].customValues.length > 0) {\n                args.intent.params[index].customValues.forEach(customValue => {\n                    if (_values[customValue.param] !== undefined \n                        && _values[customValue.param] === customValue.paramValue\n                    ) {\n                        _customValues.push(customValue);\n                        valuesToDisplay.push(customValue);\n                    }\n                })\n            }\n            if (valuesToDisplay.length === 0) {\n                valuesToDisplay = args.intent.params[index].values;\n            }\n            valuesToDisplay.forEach((value) => {\n                if (typeof value === 'object'){\n                    _possibleValues[cont] = [(cont+1).toString(), value.display, value.value];\n                } else {\n                    _possibleValues[cont] = [(cont+1).toString(), value];\n                }\n                ++cont;\n            });\n        } else {\n            if (args.intent.params[index].values === 'any'){\n                _possibleValues = \"any\";\n            }\n        }\n\n        this.callbacks[args.idChat] = {\n            message: args.message,\n            intent: args.intent, \n            currentParam: index,\n            isFinished: false,\n            requireFile: isFile,\n            possibleValues: _possibleValues,\n            values: _values,\n            customValues: _customValues\n        }\n\n        let text = getRandomItem(args.intent.params[index].request) + String.fromCharCode(10);\n        for (var i=0; i<cont; i++){\n            let options = [];\n            options.push(_possibleValues[(i).toString()][0]);\n            options.push(_possibleValues[(i).toString()][1]);\n            //text += _possibleValues[(i).toString()].join('.- ') + String.fromCharCode(10);\n            text += options.join('.- ') + String.fromCharCode(10);\n        }\n        \n        this.sendMessage({\n            \"idChat\": args.idChat,\n            \"message\": text\n        });\n    }\n\n    addPlugins (plugins) {\n        if (Array.isArray(plugins.plugins)) {\n            // Read plugins folder\n            const pathPlugins = path.join(__dirname, plugins.folder || '../plugins/');\n            fs.readdir(pathPlugins, (err, files) => {\n                if (err) { \n                    console.error('Error reading plugins directory'); \n                } else {\n                    let pluginsFiles = [];\n                    files.forEach(file => {\n                        if (file.indexOf('.js') !== -1){\n                            const {id, setup, plugin, init} = require(path.join(pathPlugins, file));\n                            const metadata = {\n                                id: id,\n                                setup: setup,\n                                init: init,\n                                plugin: plugin\n                            };\n                            pluginsFiles.push(metadata);\n                        }\n                    });\n\n                    plugins.plugins.forEach(plugin => {\n                        const pluginFile = pluginsFiles.find(el => el.id === plugin);\n                        if (pluginFile !== undefined) {\n                            Object.assign(this, {\n                                [pluginFile.id]: pluginFile.plugin\n                            });\n                            if (typeof pluginFile.init !== 'undefined') {\n                                pluginFile.init();\n                            }\n                            if (typeof plugins.setup[plugin] !== 'undefined') {\n                                pluginFile.setup(plugins.setup[plugin]);\n                            }\n                        }\n                    })\n                }\n            });\n        }\n    }\n\n    /**\n     * Send list of commands\n     * @param {object} args - The message info\n     * @param {string} args.idChat - Id Chat\n     * @param {string} args.prefix - Prefix message\n     * @param {string} args.postfix - Postfix message\n     */\n     sendCommands(args) {\n        if (this.intentConfig.commands && this.intentConfig.commands.length > 0) {\n            let helpText = `${args.prefix || ''} \\n `;\n            this.intentConfig.commands.forEach(command => {\n                if (command.description && command.description !== '') {\n                    if (command.exact && command.exact.length > 0) {\n                        helpText += `- *${command.exact[0]}* - ${command.description} \\n `;\n                    } else {\n                        helpText += `- ${command.description} \\n `;\n                    }\n                }\n            });\n\n            helpText += `${args.postfix || ''}`;\n\n            if (helpText !== '') {\n                this.sendMessage({\n                    \"idChat\": args.idChat, \n                    \"message\": helpText\n                });\n            }\n        }\n    }\n\n    addCommand (command) {\n        this.intentConfig.commands.push(command);\n    }\n\n    deleteCommand (commandName) {\n        this.intentConfig.commands = this.intentConfig.commands.filter(el => el.name !== commandName);\n    }\n    /**\n     * Send text as image \n     * @param {object} args - The message info\n     * @param {string} args.idChat - Id Chat\n     * @param {string} args.idMessage - Id of message to reply\n     * @param {string} args.message - Message to send\n     */\n    sendMessage(args){\n        let data = types.valid('text', args);\n        if (data.isValid){\n            this._wabot.sendMessage(data.data);\n        }else {\n            console.error(data.messageInvalid);\n        }\n    }\n\n    /**\n     * Download file from message received from others users\n     * @param {string} idMessage - Message id containing the file to download\n     * \n     * @returns {Promise<string>} file in base64 or error message\n     */\n    async downloadFile(idMessage){\n        return new Promise(async (resolve, reject) => {\n            this._wabot.downloadFile(idMessage)\n            .then((file) => {\n                resolve(file);\n            })\n            .catch((err) => {\n                reject(err);\n            });\n        });\n    }\n\n    /**\n     * Send text as image \n     * @param {object} args - The message info\n     * @param {string} args.idChat - Id Chat\n     * @param {string} args.idMessage - Id of message to reply\n     * @param {string} args.caption - Caption to display in the message \n     * @param {string} args.message - Message to convert into image\n     */\n    sendText2Image(args){\n        let data = types.valid('text2image', args);\n        if (data.isValid){\n            this._wabot.sendMessage(data.data);\n        }else {\n            console.error(data.messageInvalid);\n        }\n    }\n\n    /**\n     * Send a image file \n     * @param {object} args - The message info\n     * @param {string} args.idChat - Id Chat\n     * @param {string} args.idMessage - Id of message to reply\n     * @param {string} args.caption - Caption to display in the message \n     * @param {string} args.file - Url, base64 or path to the file\n     */\n    sendImage(args){\n        if (typeof args.file !== 'undefined' && args.file !== ''){\n            convert64.convert(args.file)\n            .then(res => {\n                args.file = res;\n                let data = types.valid('image', args);\n                if (data.isValid){\n                    this._wabot.sendMessage(data.data);\n                }else {\n                    console.error(data.messageInvalid);\n                }\n            })\n            .catch(err => {\n                console.error(`Error converting to base64.`, err);\n            })\n        }\n    }\n\n    /**\n     * Send a file \n     * @param {object} args - The message info\n     * @param {string} args.idChat - Id Chat\n     * @param {string} args.idMessage - Id of message to reply\n     * @param {string} args.caption - Caption to display in the message \n     * @param {string} args.file - Url, base64 or path to the file\n     */\n    sendFile(args){\n        if (typeof args.file !== 'undefined' && args.file !== ''){\n            convert64.convert(args.file)\n            .then(res => {\n                args.file = res;\n                let data = types.valid('document', args);\n                if (data.isValid){\n                    this._wabot.sendMessage(data.data);\n                }else {\n                    console.error(data.messageInvalid);\n                }\n            })\n            .catch(err => {\n                console.error(`Error converting to base64.`, err);\n            })\n        }\n    }\n\n    /**\n     * Send a video file \n     * @param {object} args - The message info\n     * @param {string} args.idChat - Id Chat\n     * @param {string} args.idMessage - Id of message to reply\n     * @param {string} args.caption - Caption to display in the message \n     * @param {string} args.file - Url, base64 or path to the file\n     */\n    sendVideo(args){\n        if (typeof args.file !== 'undefined' && args.file !== ''){\n            convert64.convert(args.file)\n            .then(res => {\n                args.file = res;\n                let data = types.valid('video', args);\n                if (data.isValid){\n                    this._wabot.sendMessage(data.data);\n                }else {\n                    console.error(data.messageInvalid);\n                }\n            })\n            .catch(err => {\n                console.error(`Error converting to base64.`, err);\n            })\n        }\n    }\n\n    /**\n     * Send a gif file \n     * @param {object} args - The message info\n     * @param {string} args.idChat - Id Chat\n     * @param {string} args.idMessage - Id of message to reply\n     * @param {string} args.caption - Caption to display in the message \n     * @param {string} args.file - Url, base64 or path to the file\n     */\n    sendGif(args){\n        if (typeof args.file !== 'undefined' && args.file !== ''){\n            convert64.convert(args.file)\n            .then(res => {\n                args.file = res;\n                let data = types.valid('gif', args);\n                if (data.isValid){\n                    this._wabot.sendMessage(data.data);\n                }else {\n                    console.error(data.messageInvalid);\n                }\n            })\n            .catch(err => {\n                console.error(`Error converting to base64.`, err);\n            })\n        }\n    }\n\n    /**\n     * Send a music file \n     * @param {object} args - The message info\n     * @param {string} args.idChat - Id Chat\n     * @param {string} args.idMessage - Id of message to reply\n     * @param {string} args.caption - Caption to display in the message \n     * @param {string} args.file - Url, base64 or path to the file\n     */\n    sendMusic(args){\n        if (typeof args.file !== 'undefined' && args.file !== ''){\n            convert64.convert(args.file)\n            .then(res => {\n                args.file = res;\n                args.fileType = 'music';\n                let data = types.valid('music', args);\n                if (data.isValid){\n                    this._wabot.sendMessage(data.data);\n                }else {\n                    console.error(data.messageInvalid);\n                }\n            })\n            .catch(err => {\n                console.error(`Error converting to base64.`, err);\n            })\n        }\n    }\n\n    /**\n     * Send a link\n     * @param {object} args - The message info\n     * @param {string} args.idChat - Id Chat\n     * @param {string} args.idMessage - Id of message to reply\n     * @param {string} args.caption - Caption to display in the message \n     * @param {string} args.link - Url to send\n     */\n    sendLink(args){\n        let data = types.valid('link', args);\n        if (data.isValid){\n            if (args.thumb && args.thumb !== '') {\n                this._wabot.sendMessage(data.data);\n            } else {\n                const _this = this;\n                scrape(args.link, function(error, metadata){\n                    if(!error){\n                        if(typeof metadata.openGraph != 'undefined' && metadata.openGraph != undefined){\n                            const title = metadata.openGraph.title || \"News\";\n                            const description = metadata.openGraph.description || \"\";\n                            const urlNews = metadata.openGraph.url || args.link;\n                            let urlImage;\n                            if(typeof metadata.openGraph.image.url != \"undefined\" && metadata.openGraph.image.url != undefined && metadata.openGraph.image.url != \"\"){\n                                urlImage = metadata.openGraph.image.url;\n                            }else{\n                                urlImage = THUMB_DEFAULT_URL;\n                            }\n\n                            const info = data.data;\n                            info.description = description;\n                            info.title = title;\n                            info.link = urlNews;\n                            \n                            convert64.convert(urlImage)\n                            .then(res => {\n                                info.thumb = res;\n                                _this._wabot.sendMessage(info);\n                            })\n                            .catch(err => {\n                                info.thumb = '';\n                                _this._wabot.sendMessage(info);\n                            })\n                        }\n                    } else {\n                        console.error(data.messageInvalid);\n                    }\n                });\n            }\n        }else {\n            console.error(data.messageInvalid);\n        }\n    }\n\n    /**\n     * Send a sticker\n     * @param {object} args - The message info\n     * @param {string} args.idChat - Id Chat\n     * @param {string} args.idMessage - Id of message to reply\n     * @param {string} args.file - Url, base64 or Path of the image (with or without background)\n     */\n    sendSticker(args){\n        if (typeof args.file !== 'undefined' && args.file !== ''){\n            this.sticker.makeSticker(args.file)\n            .then(res => {\n                args.file = res.file;\n                let data = types.valid('sticker', args);\n                if (data.isValid){\n                    this._wabot.sendMessage(data.data);\n                }else {\n                    console.error(data.messageInvalid);\n                }\n            })\n            .catch(err => {\n                console.error(`Error creating sticker.`, err);\n            })\n        }\n    }\n\n    /**\n     * Send a location \n     * @param {object} args - The message info\n     * @param {string} args.idChat - Id Chat\n     * @param {string} args.idMessage - Id of message to reply\n     * @param {string} args.lat - Latitude of the location\n     * @param {string} args.lng - Location of the location\n     * @param {string} args.title - Title to display\n     */\n    sendLocation(args){\n        let data = types.valid('location', args);\n        if (data.isValid){\n            this._wabot.sendMessage(data.data);\n        }else {\n            console.error(data.messageInvalid);\n        }\n    }\n\n    /**\n     * Send a contact as vcard\n     * @param {object} args - The message info\n     * @param {string} args.idChat - Id Chat\n     * @param {string} args.idMessage - Id of message to reply\n     * @param {string} args.contactName - Contact Name to display \n     * @param {object} args.vcard - Contact info\n     * @param {string} args.vcard.firstName - First Name \n     * @param {string} args.vcard.middleName - Middle Name \n     * @param {string} args.vcard.lastName - Last Name \n     * @param {string} args.vcard.organization - Organization\n     * @param {string} args.vcard.birthday - Dirthday date\n     * @param {string} args.vcard.title - Title to display\n     * @param {string} args.vcard.url - Url\n     * @param {string} args.vcard.note - Note\n     * @param {string} args.vcard.nickname - Nickname\n     * @param {string} args.vcard.namePrefix - Name Prefix \n     * @param {string} args.vcard.nameSuffix - Name Suffix\n     * @param {string} args.vcard.gender - Gender\n     * @param {string} args.vcard.role - Role\n     * @param {string} args.vcard.homePhone - Home Phone\n     * @param {string} args.vcard.workPhone - Work Phone\n     * @param {string} args.vcard.cellPhone - Cell Phone\n     * @param {string} args.vcard.pagerPhone - Pager Phone\n     * @param {string} args.vcard.homeFax - Home Fax\n     * @param {string} args.vcard.workFax - Work Fax\n     * @param {string} args.vcard.email - Email\n     * @param {string} args.vcard.workEmail - Work Email\n     * @param {string} args.vcard.socialUrlsFacebook - Social Urls Facebook\n     * @param {string} args.vcard.socialUrlsLinkedin - Social Urls Linkedin\n     * @param {string} args.vcard.socialUrlsTwitter - Social Urls Twitter\n     * @param {string} args.vcard.socialUrlsFlickr - Social Urls Flickr\n     * @param {string} args.vcard.socialUrlsCustom - Social Urls Custom\n     * @param {string} args.vcard.homeAddressLabel - Home Address Label\n     * @param {string} args.vcard.homeAddressStreet - Home Address Street\n     * @param {string} args.vcard.homeAddressCity - Home Address City\n     * @param {string} args.vcard.homeAddressStateProvince - Home Address State Province\n     * @param {string} args.vcard.homeAddressPostalCode - Home Address Postal Code\n     * @param {string} args.vcard.homeAddressCountryRegion - Home Address Country Region\n     * @param {string} args.vcard.workAddressLabel - Work Address Label\n     * @param {string} args.vcard.workAddressStreet - Work Address Street\n     * @param {string} args.vcard.workAddressCity - Work Address City\n     * @param {string} args.vcard.workAddressStateProvince - Work Address State Province\n     * @param {string} args.vcard.workAddressPostalCode - Work Address Postal Code\n     * @param {string} args.vcard.workAddressCountryRegion - Work Address Country Region\n     * @param {string} args.vcard.photo - Photo (url or path)\n     */\n    sendVcard(args){\n        let data = types.valid('vcard', args);\n        if (data.isValid){\n            let _vcard = vcard.createVcard(data.data.vcard);\n            data.data.vcard = _vcard;\n            this._wabot.sendMessage(data.data);\n        }else {\n            console.error(data.messageInvalid);\n        }\n    }\n\n    /**\n     * Returns an object with all of your host device details\n     * @returns {Promise<object>}\n     */\n    async getMe() {\n        return this._wabot.getMe();\n    }\n\n    /**\n     * Returns the version of WhatsApp Web currently being run\n     * @returns {Promise<string>}\n     */\n    async getWAVersion() {\n        return this._wabot.getWAVersion();\n    }\n\n    /**\n     * Get current battery percentage and charging status for the attached device\n     * @returns {number} battery - The current battery percentage\n     */\n    async getBatteryLevel() {\n        return this._wabot.getBatteryLevel();\n    }\n\n    /**\n     * Get all chats\n     * @returns {Promise<Object[]>}\n     */\n    async getAllChats() {\n        return this._wabot.getAllChats();\n    }\n    \n    /**\n     * Get all chats with pending messages\n     * @returns {Promise<Object[]>}\n     */\n    async getAllChatsWithNewMsg() {\n        return this._wabot.getAllChatsWithNewMsg();\n    }\n\n    /**\n     * Get chat instance by ID\n     * @param {string} chatId \n     * @returns {Promise<Chat>}\n     */\n    async getChatById(chatId) {\n        return this._wabot.getChatById(chatId);\n    }\n\n    /**\n     * Get message by Id\n     * @param {string} messageId - Message Id\n     * \n     * @returns {Promise<Object[]>}\n     */\n    async getMessageById(messageId) {\n        return this._wabot.getMessageById(messageId);\n    }\n\n    /**\n     * Get all unread messages\n     * @returns {Promise<Object[]>}\n     */\n    async getAllUnreadMessages() {\n        return this._wabot.getAllUnreadMessages();\n    }\n\n    /**\n     * Fetches all group metadata objects from store\n     *\n     * @returns {Array|*} List of group metadata\n     */\n    async getAllGroupMetadata() {\n        return this._wabot.getAllGroupMetadata();\n    }\n\n    /**\n     * Fetches group metadata object from store by ID\n     *\n     * @param {string} groupId - ID of group\n     * @returns {T|*} Group metadata object\n     */\n    async getGroupMetadata(groupId) {\n        return this._wabot.getGroupMetadata(groupId);\n    }\n\n    /**\n     * Create a new group\n     * @param {string} name group title\n     * @param {Array<Contact|string>} contactsId an array of Contacts or contact IDs to add to the group\n     * @returns {Object} createRes\n     * @returns {string} createRes.gid - ID for the group that was just created\n     * @returns {Object.<string,string>} createRes.missingParticipants - participants that were not added to the group. Keys represent the ID for participant that was not added and its value is a status code that represents the reason why participant could not be added. This is usually 403 if the user's privacy settings don't allow you to add them to groups.\n     */\n    async createGroup(name, contactsId) {\n        return this._wabot.createGroup(name, contactsId);\n    }\n\n    /**\n     * Gets the list of all users\n     * @param {string} contactId\n     * @returns {Promise<Contact[]>}\n     */\n    async getAllContacts() {\n        return this._wabot.getAllContacts();\n    }\n\n    /**\n     * Get the user's registered contact list\n     * @param {string} contactId\n     * @returns {Promise<Contact[]>}\n     */\n    async getMyContacts() {\n        return this._wabot.getMyContacts();\n    }\n\n    /**\n     * Get contact instance by ID\n     * @param {string} contactId\n     * @returns {Promise<Contact>}\n     */\n    async getContactById(contactId) {\n        return this._wabot.getContactById(contactId);\n    }\n\n    /**\n     * Returns an object with information about the invite code's group\n     * @param {string} inviteCode \n     * @returns {Promise<object>} Invite information\n     */\n    async getInviteInfo(inviteCode) {\n        return this._wabot.getInviteInfo(inviteCode);\n    }\n\n    /**\n     * Get the invite code's group\n     * @param {string} chatId\n     * @returns {Promise<string>} Invite Code\n     */\n    async getGroupInviteLink(chatId) {\n        return this._wabot.getGroupInviteLink(chatId);\n    }\n\n    /**\n     * Accepts an invitation to join a group\n     * @param {string} inviteCode Invitation code\n     */\n    async joinGroupViaLink(inviteCode) {\n        return this._wabot.joinGroupViaLink(inviteCode);\n    }\n\n    /**\n     * Sets the current user's status message\n     * @param {string} status New status message\n     */\n    async setStatusMessage(newStatus){\n        return this._wabot.logout(newStatus);\n    }\n\n    /**\n     * Gets the current status message\n     * @returns {string} status message\n     */\n    async getStatus(){\n        return this._wabot.getStatus();\n    }\n\n    /**\n     * Enables and returns the archive state of the Chat\n     * @returns {boolean}\n     */\n    async archiveChat(idChat, archive){\n        return this._wabot.archiveChat(idChat, archive);\n    }\n\n    /**\n     * Marks the client as online or offline\n     * @param {boolean} - true for online false for offline\n     */\n    async setPresence(presence){\n        return this._wabot.setPresence(presence);\n    }\n\n    /**\n     * Sets the current user's display name. \n     * This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.\n     * @param {string} displayName New display name\n     */\n    async setDisplayName(newName){\n        return this._wabot.setDisplayName(newName);\n    }\n\n    /**\n     * Check if a given ID is registered in whatsapp\n     * @param {string} id the whatsapp user's ID\n     * @returns {Promise<Boolean>}\n     */\n    async validNumberExists(id){\n        return this._wabot.validNumberExists(id);\n    }\n\n    /**\n     * Mutes the Chat until a specified date\n     * @param {string} chatId ID of the chat that will be muted\n     * @param {Date} unmuteDate Date when the chat will be unmuted\n     */\n    async muteChat(chatId, unmuteDate) {\n        this._wabot.muteChat(chatId, unmuteDate);\n    }\n\n    /**\n     * Unmutes the Chat\n     * @param {string} chatId ID of the chat that will be unmuted\n     */\n    async unmuteChat(chatId) {\n        this._wabot.unmuteChat(chatId);\n    }\n\n    /**\n     * Pins the Chat\n     * @returns {Promise<boolean>} New pin state. Could be false if the max number of pinned chats was reached.\n     */\n    async pinChat(chatId) {\n        return this._wabot.pinChat(chatId);\n    }\n\n    /**\n     * Unpins the Chat\n     * @returns {Promise<boolean>} New pin state\n     */\n    async unpinChat(chatId) {\n        return this._wabot.unpinChat(chatId);\n    }\n\n    /**\n     * Enables and returns the archive state of the Chat\n     * @returns {boolean}\n     */\n    async archiveChat(chatId) {\n        return this._wabot.archiveChat(chatId);\n    }\n\n    /**\n     * Changes and returns the archive state of the Chat\n     * @returns {boolean}\n     */\n    async unarchiveChat(chatId) {\n        return this._wabot.unarchiveChat(chatId);\n    }\n\n    /**\n     * Gets the current connection state for the client\n     * @returns WAState\n     */\n    async getState(){\n        return this._wabot.getState();\n    }\n\n    /**\n     * Force reset of connection state for the client\n     */\n    async resetState(){\n        return this._wabot.resetState();\n    }\n\n    /**\n     * Logs out the client, closing the current session\n     */\n    logout(){\n        if(this.isLogged){\n            this._wabot.logout();\n        }else{\n            console.info(\"You must first be logged in.\");\n        }\n    }\n    /**\n     * To know if the process is ready\n     */\n    isReady() {\n        return this.isLogged;\n    }\n    /**\n     * Start session on whatsapp web \n     */\n    start(){\n        this._wabot.start();\n    }\n}\n\nmodule.exports = WABOT;"]}