webfast 0.1.44 → 0.1.48
Sign up to get free protection for your applications and to get access to all the features.
- package/modules/bots/applications/telegram/middleware/message/location.js +1 -1
- package/modules/bots/applications/telegram/middleware/message/photo.js +1 -1
- package/modules/bots/applications/telegram/middleware/message/start.js +20 -4
- package/modules/bots/applications/telegram/que.js +12 -4
- package/modules/bots/applications/telegram/scripts/test/script.json +1 -1
- package/modules/bots/applications/telegram.js +22 -16
- package/package.json +1 -1
@@ -6,7 +6,7 @@ module.exports = async function(req,res,body,params,command,middleValue) {
|
|
6
6
|
locSendMessage = `Thank you for sending your location\n ${middleValue.location.longitude}\n${middleValue.location.latitude}`;
|
7
7
|
}
|
8
8
|
|
9
|
-
const scripting = await program.modules.telegram.script.function.check(program,command,middleValue.
|
9
|
+
const scripting = await program.modules.telegram.script.function.check(program,command,middleValue.from.id,middleValue,body);
|
10
10
|
console.log(scripting);
|
11
11
|
|
12
12
|
return {
|
@@ -45,7 +45,7 @@ module.exports = async function(program,req,res,body,params,command,middleValue)
|
|
45
45
|
|
46
46
|
locSendMessage = `Image succesfull received`;
|
47
47
|
|
48
|
-
const scripting = await program.modules.telegram.script.function.check(program,command,middleValue.
|
48
|
+
const scripting = await program.modules.telegram.script.function.check(program,command,middleValue.from.id,middleValue,body);
|
49
49
|
console.log(scripting);
|
50
50
|
|
51
51
|
// Send back
|
@@ -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.from.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`);
|
@@ -206,7 +214,7 @@ module.exports = {
|
|
206
214
|
}
|
207
215
|
buttons = JSON.parse(buttons);
|
208
216
|
}
|
209
|
-
await program.modules.telegram.functions.send(program,toSend,middleValue.
|
217
|
+
await program.modules.telegram.functions.send(program,toSend,middleValue.from.id,buttons);
|
210
218
|
|
211
219
|
// set que uuid
|
212
220
|
program.modules.telegram.functions.que.line[chatID] = current;
|
@@ -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(' ');
|
@@ -124,7 +125,7 @@ module.exports = async function(program,folder) {
|
|
124
125
|
case `message`:
|
125
126
|
console.log(`We have response, check for response message`);
|
126
127
|
const message = respFunc[action];
|
127
|
-
await program.modules.telegram.functions.send(program,message,middleValue.
|
128
|
+
await program.modules.telegram.functions.send(program,message,middleValue.from.id);
|
128
129
|
break;
|
129
130
|
default:
|
130
131
|
console.error(`Missing Response Action Telegram: ${action}`);
|
@@ -139,25 +140,30 @@ 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.from.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);
|
159
165
|
//console.error(`Error For Telegram Function`);
|
160
|
-
await program.modules.telegram.functions.send(program,`Unknown Command: ${command}`,middleValue.
|
166
|
+
await program.modules.telegram.functions.send(program,`Unknown Command: ${command}`,middleValue.from.id);
|
161
167
|
}
|
162
168
|
}
|
163
169
|
|
@@ -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];
|
@@ -183,7 +189,7 @@ module.exports = async function(program,folder) {
|
|
183
189
|
case `message`:
|
184
190
|
console.log(`We have response, check for response message`);
|
185
191
|
const message = respFunc[action];
|
186
|
-
await program.modules.telegram.functions.send(program,message,middleValue.
|
192
|
+
await program.modules.telegram.functions.send(program,message,middleValue.from.id);
|
187
193
|
break;
|
188
194
|
default:
|
189
195
|
console.error(`Missing Response Action Telegram: ${action}`);
|
@@ -192,9 +198,9 @@ module.exports = async function(program,folder) {
|
|
192
198
|
//console.error(err);
|
193
199
|
//console.error(`Error For Telegram Function`);
|
194
200
|
console.log(`Checking for script`);
|
195
|
-
const scripting = await program.modules.telegram.script.function.check(program,command,middleValue.
|
201
|
+
const scripting = await program.modules.telegram.script.function.check(program,command,middleValue.from.id,middleValue,received);
|
196
202
|
/*
|
197
|
-
await program.modules.telegram.functions.send(program,`${command}`,middleValue.
|
203
|
+
await program.modules.telegram.functions.send(program,`${command}`,middleValue.from.id,[
|
198
204
|
[
|
199
205
|
{ text: 'EventGO!', web_app : { url : 'https://cloud.eventgo.today/events/list'}},
|
200
206
|
{ text: 'Create Event', callback_data: 'create_event' },
|
@@ -231,7 +237,7 @@ module.exports = async function(program,folder) {
|
|
231
237
|
case `message`:
|
232
238
|
console.log(`We have response, check for response message`);
|
233
239
|
const message = respFunc[action];
|
234
|
-
await program.modules.telegram.functions.send(program,message,middleValue.
|
240
|
+
await program.modules.telegram.functions.send(program,message,middleValue.from.id);
|
235
241
|
break;
|
236
242
|
default:
|
237
243
|
console.error(`Missing Response Action Telegram: ${action}`);
|