webfast 0.1.44 → 0.1.47
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,26 @@
|
|
1
|
-
module.exports = async function(req,res,body,params,command,middleValue) {
|
1
|
+
module.exports = async function(req,res,body,params,command,middleValue,received,program) {
|
2
2
|
console.log(`Start Telegram Function`);
|
3
3
|
// We have the start function
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
// Do the script thing
|
6
|
+
if (middleValue.text.startsWith(`/`)) {
|
7
|
+
middleValue.text = `start`;
|
8
|
+
const scripting = await program.modules.telegram.script.function.check(program,command,middleValue.chat.id,middleValue,received);
|
9
|
+
console.log(`Scripting`);
|
10
|
+
|
11
|
+
if (scripting == true) {
|
12
|
+
return {
|
13
|
+
response : true
|
14
|
+
};
|
15
|
+
} else {
|
16
|
+
return {
|
17
|
+
response : {
|
18
|
+
message : `Thank you : ${command}`
|
19
|
+
}
|
20
|
+
}
|
8
21
|
}
|
22
|
+
} else {
|
23
|
+
return true;
|
9
24
|
}
|
25
|
+
|
10
26
|
}
|
@@ -67,9 +67,15 @@ module.exports = {
|
|
67
67
|
// Check typeof
|
68
68
|
if (typeof qMatch.anwser == `object`) {
|
69
69
|
// Match in index
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
try {
|
71
|
+
const matchedIndex = qMatch.anwser.indexOf(middleValue.text);
|
72
|
+
if (matchedIndex != -1) {
|
73
|
+
matched = qMatch;
|
74
|
+
}
|
75
|
+
} catch (err){
|
76
|
+
if (middleValue.text == `stop` || middleValue.text == `reset`) {
|
77
|
+
delete program.modules.telegram.functions.que.line[chatID];
|
78
|
+
}
|
73
79
|
}
|
74
80
|
} else if (qMatch.anwser == middleValue.text) {
|
75
81
|
matched = qMatch;
|
@@ -105,6 +111,8 @@ module.exports = {
|
|
105
111
|
console.error(`Not matched`);
|
106
112
|
// Send command when wrong // or buttons like reset button
|
107
113
|
// check what to do
|
114
|
+
// check if stop
|
115
|
+
|
108
116
|
return false;
|
109
117
|
} else {
|
110
118
|
console.log(`Matched`);
|
@@ -75,6 +75,7 @@ module.exports = async function(program,folder) {
|
|
75
75
|
console.log(`We have received message`,received);
|
76
76
|
|
77
77
|
try {
|
78
|
+
// Or check if single word
|
78
79
|
if (middleValue.text.startsWith('/')) {
|
79
80
|
// If it starts with a slash, it might be a command
|
80
81
|
const parts = middleValue.text.split(' ');
|
@@ -139,20 +140,25 @@ module.exports = async function(program,folder) {
|
|
139
140
|
// So run the function
|
140
141
|
try {
|
141
142
|
// Run dynamic the type of middleware
|
142
|
-
|
143
|
+
|
144
|
+
const runFunc = await program.modules.telegram.middleware[key][command](req,res,body,params,command,middleValue,received,program);
|
143
145
|
const respFunc = runFunc.response;
|
144
146
|
// PRocess response for object
|
145
147
|
const action = Object.keys(respFunc)[0];
|
146
148
|
|
147
149
|
// switch action
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
150
|
+
if (respFunc == true) {
|
151
|
+
// you can do something here
|
152
|
+
} else {
|
153
|
+
switch (action) {
|
154
|
+
case `message`:
|
155
|
+
console.log(`We have response, check for response message`);
|
156
|
+
const message = respFunc[action];
|
157
|
+
await program.modules.telegram.functions.send(program,message,middleValue.chat.id);
|
158
|
+
break;
|
159
|
+
default:
|
160
|
+
console.error(`Missing Response Action Telegram: ${action}`);
|
161
|
+
}
|
156
162
|
}
|
157
163
|
} catch (err) {
|
158
164
|
//console.error(err);
|
@@ -173,7 +179,7 @@ module.exports = async function(program,folder) {
|
|
173
179
|
const command = message;
|
174
180
|
try {
|
175
181
|
// Run dynamic the type of middleware
|
176
|
-
const runFunc = await program.modules.telegram.middleware[key][command](req,res,body,params,command,middleValue);
|
182
|
+
const runFunc = await program.modules.telegram.middleware[key][command](req,res,body,params,command,middleValue,program);
|
177
183
|
const respFunc = runFunc.response;
|
178
184
|
// PRocess response for object
|
179
185
|
const action = Object.keys(respFunc)[0];
|