diff --git a/whatsapp-web.js/src/businessLogic/logic.js b/whatsapp-web.js/src/businessLogic/logic.js index 483cb10..0bdd958 100644 --- a/whatsapp-web.js/src/businessLogic/logic.js +++ b/whatsapp-web.js/src/businessLogic/logic.js @@ -17,4 +17,95 @@ module.exports.onCreate = (id, companyName) => { //add the website with the company name user.addWebsite(new Website(companyName)); -} \ No newline at end of file +} + + + +module.exports.help = () => +{ + let help_signal = [ + `Here are the following commands that can help you create your website`, + `if you want to create a website use *wg create * and write the name of your company`, + `if you already have a website us *wg website * to get access to the website`, + `when creating your website you will be asked to give details of your company. To add these details you will have to write *wg website * *wg website * etc`, + `If you want to check all the products that have already been created for your websit type *wg product all*`, + `If you want to create a new product type *wg product new*`, + `If you want to select a particular product for manipulating its data, give your product id as such: *wg product `, + `To get all information of the product you selected, type *wg product info*`, + `To change the product name, type *wg product name *`, + `To change the product cost, type *wg product cost * `, + `To change the product description, type *wg product desc *`, + `To change the image of the product, type *wg product image *`, + `When you are done making your website and want to see it ,type *wg website finished*`, + `If you want to delete a product, type *wg delete product* where id is the product id`, + `If you want to delete your whole website, type *wg delete website `, + `That is all! Hope you make a great website~` + ]; + + return help_signal; +} + + +module.exports.comp = (input) => +{ + let create_company = [ + `welcome to building your own website!`, + `We would like you add the following details:`, + `wg website firstname `, + `wg website lastname `, + `wg website companyname `, + `wg website logourl `, + `Banner URL`, + `Description`, + `Email` + ]; + + return create_company; + +} + +module.exports.fn = (input) => +{ + let fName = [ + `first name has been added` + ]; + + return fName; + +} + +module.exports.ln = (input) => +{ + + + let lName = [ + `last name has been added` + ]; + + return lName; + +} + +module.exports.cn = (input) => +{ + + + let cName = [ + `company name has been added` + ]; + + return cName; + +} + +module.exports.logo = (input) => +{ + + + let lo = [ + `logo has been added` + ]; + + return lo; + +} diff --git a/whatsapp-web.js/src/models/commands.js b/whatsapp-web.js/src/models/commands.js index ab084c2..674a54b 100644 --- a/whatsapp-web.js/src/models/commands.js +++ b/whatsapp-web.js/src/models/commands.js @@ -45,7 +45,7 @@ class Command{ //else return false if(splitMsg[i] == splitCommand[i]){ continue; - }else if(splitCommand[i].match(/[<>]/g).length > 1){ + }else if(splitCommand[i].match(/[<>]/g) != null){ continue; }else{ return false; diff --git a/whatsapp-web.js/src/userInteraction/messages.js b/whatsapp-web.js/src/userInteraction/messages.js index 7692fdf..3cb0ccd 100644 --- a/whatsapp-web.js/src/userInteraction/messages.js +++ b/whatsapp-web.js/src/userInteraction/messages.js @@ -6,7 +6,7 @@ const logic = require("../businessLogic/logic"); //add the commands here /////////// const commands = [ - new Command({ + new Command({ //User command command: 'wg', @@ -34,26 +34,10 @@ const commands = [ logic.onWG(); //mesage to be sent to the user - let help_signal = [ - `Here are the following commands that can help you create your website`, - `if you want to create a website use *wg create * and write the name of your company`, - `if you already have a website us *wg website * to get access to the website`, - `when creating your website you will be asked to give details of your company. To add these details you will have to write *wg website * *wg website * etc`, - `If you want to check all the products that have already been created for your websit type *wg product all*`, - `If you want to create a new product type *wg product new*`, - `If you want to select a particular product for manipulating its data, give your product id as such: *wg product `, - `To get all information of the product you selected, type *wg product info*`, - `To change the product name, type *wg product name *`, - `To change the product cost, type *wg product cost * `, - `To change the product description, type *wg product desc *`, - `To change the image of the product, type *wg product image *`, - `When you are done making your website and want to see it ,type *wg website finished*`, - `If you want to delete a product, type *wg delete product* where id is the product id`, - `If you want to delete your whole website, type *wg delete website `, - `That is all! Hope you make a great website~` - ]; + get_help = logic.help(); - return help_signal; + + return get_help; } }), @@ -61,29 +45,103 @@ const commands = [ //User command - command: 'wg create', + command: 'wg create ', //function to be executed callback : (input) => { - name_of_company = input.substring(9), logic.onWG(); - //mesage to be sent to the user - let create_company = [ - `welcome to building your own website!`, - `We would like you add the following details:`, - `First Name`, - `Last Name`, - `Company name`, - `Logo URL`, - `Banner URL`, - `Description`, - `Email`, - `For adding information use *wg website *` - ]; + + data = input['company_name']; + cn = logic.comp(data); + return cn; + + } + }), + - return create_company; + + new Command({ + //User command + command: 'wg website firstname ', + + //function to be executed + callback : (input) => + { + + logic.onWG(); + + inputting = input['f_name']; + fname = logic.fn(); + return fname; + + } + }), + + new Command({ + //User command + command: 'wg website lastname ', + + + //function to be executed + callback : (input) => + { + + logic.onWG(); + + + + inputting = input['l_name']; + + lname = logic.ln(); + return lname; + + + } + }), + + new Command({ + //User command + command: 'wg website companyname ', + + + //function to be executed + callback : (input) => + { + + logic.onWG(); + + + + inputting = input['c_name']; + + cname = logic.cn(); + return cname; + + + } + }), + + new Command({ + //User command + command: 'wg website logourl ', + + + //function to be executed + callback : (input) => + { + + logic.onWG(); + + + + inputting = input['logo_name']; + + logoURL = logic.logo(); + return logoURL; + + } }), @@ -110,7 +168,7 @@ module.exports= onMessage = (message, client) => { let input = {}; if(command.requireInput) { - input = command.getInput(); + input = command.getInput(message.body); } let messageToBeSent = command.callback(input);