slight changes
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
const { User } = require("../models/user");
|
const { User } = require("./user");
|
||||||
const { Website } = require("../models/website");
|
const { Website } = require("./website");
|
||||||
|
|
||||||
module.exports.data = new StructuredData();
|
module.exports.data = new StructuredData();
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,26 @@
|
|||||||
|
|
||||||
const { Command } = require("./commands");
|
const { Command } = require("../models/commands");
|
||||||
const { onWG } = require("../businessLogic/logic");
|
const logic = require("../businessLogic/logic");
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
//add the commands here
|
//add the commands here
|
||||||
///////////
|
///////////
|
||||||
const commands = [
|
const commands = [
|
||||||
|
|
||||||
new Command({
|
new Command({
|
||||||
|
//User command
|
||||||
command: 'wg',
|
command: 'wg',
|
||||||
message : [
|
|
||||||
`stop it and get some help by using the following command *wg help*`,
|
//function to be executed
|
||||||
`Hope everything works well`
|
|
||||||
] ,
|
|
||||||
callback : () => {
|
callback : () => {
|
||||||
onWG();
|
|
||||||
|
logic.onWG();
|
||||||
|
//mesage to be sent to the user
|
||||||
|
let message = [
|
||||||
|
`stop it and get some help by using the following command *wg help*`,
|
||||||
|
`Hope everything works well`
|
||||||
|
];
|
||||||
|
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -22,7 +28,7 @@ const commands = [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports= onMessage = (message, client) => {
|
const onMessage = (message, client) => {
|
||||||
|
|
||||||
let command = null;
|
let command = null;
|
||||||
|
|
||||||
@@ -30,7 +36,7 @@ module.exports= onMessage = (message, client) => {
|
|||||||
if(message.body.startsWith("wg"))
|
if(message.body.startsWith("wg"))
|
||||||
{
|
{
|
||||||
for (let c of commands){
|
for (let c of commands){
|
||||||
if(c.getCommand() == message.body)
|
if(c.command == message.body)
|
||||||
{
|
{
|
||||||
command = c;
|
command = c;
|
||||||
break;
|
break;
|
||||||
@@ -38,8 +44,8 @@ module.exports= onMessage = (message, client) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(command != null){
|
if(command != null){
|
||||||
command.getCallback()();
|
let messageToBeSent = command.callback();
|
||||||
for (let msg of command.getMessage())
|
for (let msg of messageToBeSent)
|
||||||
{
|
{
|
||||||
client.sendMessage(message.from, msg, new Object());
|
client.sendMessage(message.from, msg, new Object());
|
||||||
}
|
}
|
||||||
@@ -48,5 +54,6 @@ module.exports= onMessage = (message, client) => {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.onMessage = onMessage;
|
||||||
|
|
||||||
//export default onMessage;
|
//export default onMessage;
|
||||||
Reference in New Issue
Block a user