From 8c0a3a9f9c838e0f1f23ff5a1efa73c45d592372 Mon Sep 17 00:00:00 2001 From: Mohammed Ashab Uddin Date: Thu, 20 Aug 2020 20:14:47 +0400 Subject: [PATCH] messages has been updated --- whatsapp-web.js/src/businessLogic/logic.js | 60 ++++++++++++------- whatsapp-web.js/src/models/user.js | 8 ++- .../src/userInteraction/messages.js | 12 +++- 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/whatsapp-web.js/src/businessLogic/logic.js b/whatsapp-web.js/src/businessLogic/logic.js index 5a6ba85..4ed61b7 100644 --- a/whatsapp-web.js/src/businessLogic/logic.js +++ b/whatsapp-web.js/src/businessLogic/logic.js @@ -8,7 +8,7 @@ const {stripIndents} = require('common-tags'); /** * user to be sent the message to - * @type {User} + * @type { User } */ let user = null; @@ -176,7 +176,7 @@ module.exports.onSelectProduct = () => { if(!user.getSelectedWebsite().selectProduct(input['id'])) { return [ - `There was no product with the given id. Use the following command to get the list of all id's`, + `There was no product with the given id. Use the following command to get the list of all products`, `wg product all` ]; } @@ -322,27 +322,43 @@ module.exports.onSetProductImage = () => { 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~` + `NOTE : text between '<>' are replaceable.`, + `NOTE : Sentences needs to be between qoutes. For Example "I am a bot" ` + `*wg create Create a website with the given company_name*`, + `*wg website select * Selects a website if exists`, + `*wg website firstname * Sets the firstname`, + `*wg website lastname * Sets the firstname`, + `*wg website logo (with an image attached)* Sets the logo`, + `*wg website banner (with an image attached)* Sets the banner`, + `*wg website desc * Sets the description`, + `*wg website email * Sets the email`, + `*wg website finished* Completes and creates the website`, + `*wg product new * Creates a new product with an id`, + `*wg product select * Selects a product with a given id`, + `*wg product all* Shows all the products`, + `*wg product info* Shows the information of the selected product`, + `*wg product name * Sets the name of the product`, + `*wg product desc * Sets the description of the product`, + `*wg product cost * Sets the cost of the product`, + `*wg product image (with an image attached)* Sets the image of the product`, ]; return help_signal; } +module.exports.onSelectWebsite = () => { + + if(user.isWebsite(input['company_name'])) + { + user.selectWebsite(input['company_name']); + return [`Website with the company name *${user.getSelectedWebsite().companyName}* is selected`] + } + + return [`No website with the company name *${input['company_name']}* has been selected`]; + + +} + /** * wg create * @param {string} input of the company name @@ -353,14 +369,12 @@ module.exports.onCreateWebsite = () => user.addWebsite(new Website(input['company_name'])); return [ + `A website with the company name *${user.getSelectedWebsite().companyName}* is created`, stripIndents` - 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 logo ** - wg website banner ** + wg website logo *with an image attached* + wg website banner *with an image attached* wg website description ** wg website email ** For adding information use *wg website *` diff --git a/whatsapp-web.js/src/models/user.js b/whatsapp-web.js/src/models/user.js index 8e5c2dc..662f59c 100644 --- a/whatsapp-web.js/src/models/user.js +++ b/whatsapp-web.js/src/models/user.js @@ -29,6 +29,10 @@ class User{ return this.websites.getData(companyName); } + isWebsite(companyName){ + return this.websites.isData(companyName); + } + selectWebsite(companyName) { return this.websites.selectData(companyName); @@ -43,4 +47,6 @@ class User{ } -module.exports.User = User; \ No newline at end of file +module.exports = { + User: User +} \ 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 5e123cc..6d7c436 100644 --- a/whatsapp-web.js/src/userInteraction/messages.js +++ b/whatsapp-web.js/src/userInteraction/messages.js @@ -64,6 +64,12 @@ const commands = [ callback : logic.onCreateWebsite }), //Inputs user's first name for website + new Command({ + //User command + command: 'wg website select ', + callback : logic.onSelectWebsite + }), + new Command({ //User command @@ -99,10 +105,12 @@ const commands = [ new Command({ //User command - command: 'wg website banner ', + command: 'wg website banner', //function to be executed - callback : logic.onSetBanner + callback : logic.onSetBanner, + + requireMedia: true, }), //inputs the description of the company to be seen in the website