From 6566ba30a0f89ddcc220a8b7fd5a71b2b9861639 Mon Sep 17 00:00:00 2001 From: Preeti Rawat Date: Sat, 25 Jul 2020 14:04:29 +0400 Subject: [PATCH 1/4] testing1 create companu_name --- whatsapp-web.js/package.json | 2 +- .../src/userInteraction/messages.js | 66 ++++++++++++++++++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/whatsapp-web.js/package.json b/whatsapp-web.js/package.json index 3a32f85..b5f9c49 100644 --- a/whatsapp-web.js/package.json +++ b/whatsapp-web.js/package.json @@ -5,7 +5,7 @@ "main": "test.js", "scripts": { "test-web": "node website_test.js http://localhost:8004", - "test" : "mocha", + "test": "mocha", "start": "node index.js" }, "author": "", diff --git a/whatsapp-web.js/src/userInteraction/messages.js b/whatsapp-web.js/src/userInteraction/messages.js index e62c716..7692fdf 100644 --- a/whatsapp-web.js/src/userInteraction/messages.js +++ b/whatsapp-web.js/src/userInteraction/messages.js @@ -24,6 +24,69 @@ const commands = [ } }), + + new Command({ + //User command + command: 'wg help', + + //function to be executed + callback : (input) => { + + 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~` + ]; + + return help_signal; + } + }), + + new Command({ + //User command + + + 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 *` + ]; + + return create_company; + } + }), + ]; @@ -45,7 +108,8 @@ module.exports= onMessage = (message, client) => { if(command != null){ let input = {}; - if(command.requireInput){ + if(command.requireInput) + { input = command.getInput(); } From dc8c28305fc212b4689eef4dbe9bce6046d4fec3 Mon Sep 17 00:00:00 2001 From: Preeti Rawat Date: Sat, 25 Jul 2020 22:26:25 +0400 Subject: [PATCH 2/4] just comments firstname,lastname,logourl,companyname, help are sending comments --- whatsapp-web.js/src/businessLogic/logic.js | 93 +++++++++++- whatsapp-web.js/src/models/commands.js | 2 +- .../src/userInteraction/messages.js | 132 +++++++++++++----- 3 files changed, 188 insertions(+), 39 deletions(-) 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); From 9e358e1c24180f2c899344a566c3d5f15c82c189 Mon Sep 17 00:00:00 2001 From: Preeti Rawat Date: Sun, 26 Jul 2020 17:29:59 +0400 Subject: [PATCH 3/4] condition added condition-1 --- whatsapp-web.js/src/businessLogic/logic.js | 137 ++++++++++++----- .../src/userInteraction/messages.js | 144 +++++++++++++----- 2 files changed, 201 insertions(+), 80 deletions(-) diff --git a/whatsapp-web.js/src/businessLogic/logic.js b/whatsapp-web.js/src/businessLogic/logic.js index 0bdd958..5e665e5 100644 --- a/whatsapp-web.js/src/businessLogic/logic.js +++ b/whatsapp-web.js/src/businessLogic/logic.js @@ -51,61 +51,122 @@ 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` + `wg website firstname **`, + `wg website lastname **`, + `wg website companyname **`, + `wg website logo **`, + `wg website banner **`, + `wg website description **`, + `wg website email **`, + `For adding information use *wg website *`, + ]; - + Website.companyName = input; + if(Website.companyName == null) + { + create_company = [`you have not input your company name. Please try again.`]; + } return create_company; } -module.exports.fn = (input) => -{ - let fName = [ - `first name has been added` - ]; - - return fName; +module.exports.fn = (fdata) => +{ + + + + let info = [`your first name is:` + fdata + ]; + + + + if(Website.companyName == null) + { + info = [`you have not input your company name. Please try again.`] + } + else + { + Website.firstname = fdata; + console.log('this is data ' +Website.firstname); + + } + + return info; } -module.exports.ln = (input) => + +module.exports.ln = (ldata) => { + - - let lName = [ - `last name has been added` + let info = + [`your last name is: ` + ldata ]; - - return lName; + if(Website.companyName == null) + { + info = [`company name has not been used`]; + } + else if(Website.firstname == null) + { + info = [`you have not insert first name.`]; + } + else + { + Website.lastname = ldata; + console.log('lname added'); + } + + return info; } -module.exports.cn = (input) => +module.exports.cn = (cdata) => { + + let info = [`your company name is: ` + cdata + ]; + + if(Website.firstname == null) + { + info = [`you have not insert first name.`]; + } + else if(Website.lastname == null) + { + info = [`you have not insert last name.`]; + } + else(Website.companyName != cdata) + { + Website.companyName = cdata; + info = [`your company name has been changed to` +cdata]; + console.log('this is data ' +Website.companyName); + } - let cName = [ - `company name has been added` - ]; - - return cName; - + return info; } -module.exports.logo = (input) => -{ +module.exports.logourl = (ldata) => +{ - - let lo = [ - `logo has been added` - ]; - - return lo; - -} + let info = [`the data that you added are as follow:`, + `company Name: ` + ldata + ]; + if(Website.companyName == null) + { + info = [`you have not input your company name. Please try again.`] + } + else if(Website.firstname == null) + { + info = [`you have not insert first name.`]; + } + else if(Website.lastname == null) + { + info = [`you have not insert last name.`]; + } + else + { + Website.logoUrl = ldata + } + return info; +} \ No newline at end of file diff --git a/whatsapp-web.js/src/userInteraction/messages.js b/whatsapp-web.js/src/userInteraction/messages.js index 3cb0ccd..abd9914 100644 --- a/whatsapp-web.js/src/userInteraction/messages.js +++ b/whatsapp-web.js/src/userInteraction/messages.js @@ -60,90 +60,150 @@ const commands = [ } }), - - - new Command({ + new Command({ //User command - command: 'wg website firstname ', + + command: 'wg website firstname ', //function to be executed callback : (input) => - { + { logic.onWG(); + + //cdata = input['company']; + fdata = input['firstName']; + + + info = logic.fn(fdata); + return info; - inputting = input['f_name']; - fname = logic.fn(); - return fname; + } + }), + + // new Command({ + // //User command + // command: 'wg website firstname ', + + // //function to be executed + // callback : (input) => + // { + + // logic.onWG(); + + // inputting = input['f_name']; + // fname = logic.fn(input); + // return fname; + + // } + // }), + new Command({ + //User command + + command: 'wg website lastname ', + + //function to be executed + callback : (input) => + { + + logic.onWG(); + + //cdata = input['company']; + ldata = input['lastname']; + + + info = logic.ln(ldata); + return info; } }), new Command({ //User command - command: 'wg website lastname ', - + command: 'wg website companyname ', + //function to be executed callback : (input) => - { + { logic.onWG(); - - - - inputting = input['l_name']; - - lname = logic.ln(); - return lname; - + + //cdata = input['company']; + cdata = input['cname']; + + + info = logic.cn(cdata); + return info; } }), new Command({ //User command - command: 'wg website companyname ', - + command: 'wg website logo ', + //function to be executed callback : (input) => - { + { logic.onWG(); - - - - inputting = input['c_name']; - - cname = logic.cn(); - return cname; - + + //cdata = input['company']; + logoU = input['url']; + + + info = logic.logourl(logoU); + return info; } }), - new Command({ - //User command - command: 'wg website logourl ', + // new Command({ + // //User command + // command: 'wg website logo ', - //function to be executed - callback : (input) => - { + // //function to be executed + // callback : (input) => + // { - logic.onWG(); + // logic.onWG(); - inputting = input['logo_name']; + // inputting = input['logo_name']; - logoURL = logic.logo(); - return logoURL; + // logoURL = logic.logo(input); + // return logoURL; - } - }), + // } + // }), + + // new Command({ + // //User command + + // command: 'wg website ', + + // //function to be executed + // callback : (input) => + // { + + // logic.onWG(); + + // //cdata = input['company']; + // fdata = input['firstName']; + // ldata = input['lastname']; + // cdata = input['Cname']; + + + // info = logic.comdetails(fdata, ldata, cdata); + // return info; + + // } + // }), ]; From e4cffc728257c286ade21a602bb64fa913afe3b9 Mon Sep 17 00:00:00 2001 From: Preeti Rawat Date: Wed, 29 Jul 2020 22:29:04 +0400 Subject: [PATCH 4/4] website(II) website (II) with documentation --- whatsapp-web.js/src/businessLogic/logic.js | 172 ++++++++++++++++-- .../src/userInteraction/messages.js | 122 +++++++------ 2 files changed, 228 insertions(+), 66 deletions(-) diff --git a/whatsapp-web.js/src/businessLogic/logic.js b/whatsapp-web.js/src/businessLogic/logic.js index 5e665e5..4259ab9 100644 --- a/whatsapp-web.js/src/businessLogic/logic.js +++ b/whatsapp-web.js/src/businessLogic/logic.js @@ -21,6 +21,12 @@ module.exports.onCreate = (id, companyName) => { +/** + * A help function + * @param {void} nothing + * @return {help_signal} details on how to use the website + */ + module.exports.help = () => { let help_signal = [ @@ -45,7 +51,11 @@ module.exports.help = () => return help_signal; } - +/** + * wg create + * @param {string} input of the company name + * @return {void} gives information on how to add details to website + */ module.exports.comp = (input) => { let create_company = [ @@ -70,13 +80,17 @@ module.exports.comp = (input) => } - -module.exports.fn = (fdata) => +/** + * wg website firstname + * @param {string} input of the firstname for website + * @return {void} informs you that first name has been added + */ +module.exports.firstName = (fdata) => { - let info = [`your first name is:` + fdata + let info = [`your first name is:` + fdata ]; @@ -95,13 +109,17 @@ module.exports.fn = (fdata) => return info; } - -module.exports.ln = (ldata) => +/** + * wg website lastname + * @param {string} input of the last name for website + * @return {void} informs you that last name has been added + */ +module.exports.lastName = (ldata) => { let info = - [`your last name is: ` + ldata + [`your last name is: ` + ldata ]; if(Website.companyName == null) @@ -121,11 +139,16 @@ module.exports.ln = (ldata) => return info; } -module.exports.cn = (cdata) => +/** + * wg website companyname + * @param {string} input of the companyname for website. In case you want to change the company name, you can do so here. + * @return {void} informs you that company name has been updated + */ +module.exports.CompanyName_website = (cdata) => { - let info = [`your company name is: ` + cdata + let info = [`your company name is: ` + cdata ]; if(Website.firstname == null) @@ -139,18 +162,23 @@ module.exports.cn = (cdata) => else(Website.companyName != cdata) { Website.companyName = cdata; - info = [`your company name has been changed to` +cdata]; + info = [`your company name has been changed to ` +cdata]; console.log('this is data ' +Website.companyName); } return info; } +/** + * wg website logo + * @param {string} input of the logo URL for website + * @return {void} informs you that logo URL has been added + */ + module.exports.logourl = (ldata) => { - let info = [`the data that you added are as follow:`, - `company Name: ` + ldata + let info = [`your logo is: ` + ldata ]; if(Website.companyName == null) { @@ -169,4 +197,124 @@ module.exports.logourl = (ldata) => Website.logoUrl = ldata } return info; +} + + +/** + * wg website banner + * @param {string} input of the banner URL for website + * @return {void} informs you that banner URL has been added + */ +module.exports.bannerurl = (bannerdata) => +{ + + let info = [`your banner is: ` + bannerdata + ]; + if(Website.companyName == null) + { + info = [`you have not input your company name. Please try again.`] + } + else if(Website.firstname == null) + { + info = [`you have not insert first name.`]; + } + else if(Website.lastname == null) + { + info = [`you have not insert last name.`]; + } + else if(Website.logoUrl == null) + { + info = [`you have not insert logo url`]; + } + else + { + Website.bannerUrl = bannerdata + } + return info; +} + + +/** + * wg website description + * @param {string} input of the company description for website + * @return {void} informs you that description has been added + */ +module.exports.company_description = (descriptiondata) => +{ + + let info = [`your company description is: ` + descriptiondata + ]; + if(Website.companyName == null) + { + info = [`you have not input your company name. Please try again.`] + } + else if(Website.firstname == null) + { + info = [`you have not insert first name.`]; + } + else if(Website.lastname == null) + { + info = [`you have not insert last name.`]; + } + else if(Website.logoUrl == null) + { + info = [`you have not insert logo url`]; + } + else if(Website.bannerUrl == null) + { + info = [`you have not insert banner url`]; + } + else + { + Website.desc = descriptiondata + } + return info; +} + + + + + +/** + * wg website email + * @param {string} input of the email for website + * @return {void} informs you that email has been added + * + */ + + +module.exports.email = (email_data) => +{ + + let info = [`your email is: `+ email_data + ]; + if(Website.companyName == null) + { + info = [`you have not input your company name. Please try again.`] + } + else if(Website.firstname == null) + { + info = [`you have not insert first name.`]; + } + else if(Website.lastname == null) + { + info = [`you have not insert last name.`]; + } + else if(Website.logoUrl == null) + { + info = [`you have not insert logo url`]; + } + else if(Website.bannerUrl == null) + { + info = [`you have not insert banner url`]; + } + else if(Website.desc == null) + { + info = [`you have not insert the description`]; + } + else + { + Website.email = email_data + } + return info; } \ No newline at end of file diff --git a/whatsapp-web.js/src/userInteraction/messages.js b/whatsapp-web.js/src/userInteraction/messages.js index abd9914..a6cfb5b 100644 --- a/whatsapp-web.js/src/userInteraction/messages.js +++ b/whatsapp-web.js/src/userInteraction/messages.js @@ -5,6 +5,8 @@ const logic = require("../businessLogic/logic"); /////////// //add the commands here /////////// + + const commands = [ new Command({ //User command @@ -25,8 +27,10 @@ const commands = [ }), + //gives user information on how to create website new Command({ //User command + command: 'wg help', //function to be executed @@ -41,6 +45,7 @@ const commands = [ } }), + //helps user to create a website. The first step. new Command({ //User command @@ -60,6 +65,7 @@ const commands = [ } }), + //Inputs user's first name for website new Command({ //User command @@ -75,28 +81,14 @@ const commands = [ fdata = input['firstName']; - info = logic.fn(fdata); + info = logic.firstName(fdata); return info; } }), - // new Command({ - // //User command - // command: 'wg website firstname ', - // //function to be executed - // callback : (input) => - // { - - // logic.onWG(); - - // inputting = input['f_name']; - // fname = logic.fn(input); - // return fname; - - // } - // }), + //inputs user last name in website new Command({ //User command @@ -112,12 +104,14 @@ const commands = [ ldata = input['lastname']; - info = logic.ln(ldata); + info = logic.lastName(ldata); return info; } }), + + //inputs user companyname;in case they want to update the name new Command({ //User command @@ -133,12 +127,13 @@ const commands = [ cdata = input['cname']; - info = logic.cn(cdata); + info = logic.CompanyName_website(cdata); return info; } }), + //inputs the logo of the company to website using url of logo new Command({ //User command @@ -160,50 +155,69 @@ const commands = [ } }), - // new Command({ - // //User command - // command: 'wg website logo ', + //inputs the banner for the company to website using url of banner + new Command({ + //User command - // //function to be executed - // callback : (input) => - // { - - // logic.onWG(); - - - - // inputting = input['logo_name']; - - // logoURL = logic.logo(input); - // return logoURL; - - - // } - // }), + command: 'wg website banner ', - // new Command({ - // //User command - - // command: 'wg website ', - - // //function to be executed - // callback : (input) => - // { + //function to be executed + callback : (input) => + { - // logic.onWG(); + logic.onWG(); - // //cdata = input['company']; - // fdata = input['firstName']; - // ldata = input['lastname']; - // cdata = input['Cname']; + bannerU = input['bannerURL']; - // info = logic.comdetails(fdata, ldata, cdata); - // return info; + info = logic.bannerurl(bannerU); + return info; - // } - // }), + } + }), + + //inputs the description of the company to be seen in the website + new Command({ + //User command + + command: 'wg website description ', + + //function to be executed + callback : (input) => + { + + logic.onWG(); + + websiteDescription = input['descript']; + + + info = logic.company_description(websiteDescription); + return info; + + } + }), + + //inputs the email of the company for contacting. + new Command({ + //User command + + command: 'wg website email ', + + //function to be executed + callback : (input) => + { + + logic.onWG(); + + mail = input['Email']; + + + info = logic.email(mail); + return info; + + } + }), ];