just comments

firstname,lastname,logourl,companyname, help are sending comments
This commit is contained in:
Preeti Rawat
2020-07-25 22:26:25 +04:00
parent 6566ba30a0
commit dc8c28305f
3 changed files with 188 additions and 39 deletions

View File

@@ -17,4 +17,95 @@ module.exports.onCreate = (id, companyName) => {
//add the website with the company name
user.addWebsite(new Website(companyName));
}
}
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 <company name>* and write the name of your company`,
`if you already have a website us *wg website <company name>* 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 <firstName>* *wg website <lastName>* 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 <id>`,
`To get all information of the product you selected, type *wg product info*`,
`To change the product name, type *wg product name <product-name>*`,
`To change the product cost, type *wg product cost <product-cost>* `,
`To change the product description, type *wg product desc <product-desc>*`,
`To change the image of the product, type *wg product image <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<id>* where id is the product id`,
`If you want to delete your whole website, type *wg delete website <company name>`,
`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 <First Name>`,
`wg website lastname <Last Name>`,
`wg website companyname <Company name>`,
`wg website logourl <Logo URL>`,
`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;
}

View File

@@ -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;

View File

@@ -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 <company name>* and write the name of your company`,
`if you already have a website us *wg website <company name>* 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 <firstName>* *wg website <lastName>* 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 <id>`,
`To get all information of the product you selected, type *wg product info*`,
`To change the product name, type *wg product name <product-name>*`,
`To change the product cost, type *wg product cost <product-cost>* `,
`To change the product description, type *wg product desc <product-desc>*`,
`To change the image of the product, type *wg product image <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<id>* where id is the product id`,
`If you want to delete your whole website, type *wg delete website <company name>`,
`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 <company_name>',
//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 <firstname>*`
];
data = input['company_name'];
cn = logic.comp(data);
return cn;
}
}),
return create_company;
new Command({
//User command
command: 'wg website firstname <f_name>',
//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 <l_name>',
//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 <c_name>',
//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 <logo_name>',
//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);