webfast 0.1.47 → 0.1.49
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 +1 -1
- package/modules/bots/applications/telegram/que.js +4 -2
- package/modules/bots/applications/telegram/scripts/test/script.json +6 -1
- package/modules/bots/applications/telegram.js +29 -10
- 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
|
@@ -5,7 +5,7 @@ module.exports = async function(req,res,body,params,command,middleValue,received
|
|
5
5
|
// Do the script thing
|
6
6
|
if (middleValue.text.startsWith(`/`)) {
|
7
7
|
middleValue.text = `start`;
|
8
|
-
const scripting = await program.modules.telegram.script.function.check(program,command,middleValue.
|
8
|
+
const scripting = await program.modules.telegram.script.function.check(program,command,middleValue.from.id,middleValue,received);
|
9
9
|
console.log(`Scripting`);
|
10
10
|
|
11
11
|
if (scripting == true) {
|
@@ -112,7 +112,9 @@ module.exports = {
|
|
112
112
|
// Send command when wrong // or buttons like reset button
|
113
113
|
// check what to do
|
114
114
|
// check if stop
|
115
|
-
|
115
|
+
if (middleValue.text == `reset` || middleValue.text `stop`) {
|
116
|
+
delete program.modules.telegram.functions.que.line[chatID];
|
117
|
+
}
|
116
118
|
return false;
|
117
119
|
} else {
|
118
120
|
console.log(`Matched`);
|
@@ -214,7 +216,7 @@ module.exports = {
|
|
214
216
|
}
|
215
217
|
buttons = JSON.parse(buttons);
|
216
218
|
}
|
217
|
-
await program.modules.telegram.functions.send(program,toSend,middleValue.
|
219
|
+
await program.modules.telegram.functions.send(program,toSend,middleValue.from.id,buttons);
|
218
220
|
|
219
221
|
// set que uuid
|
220
222
|
program.modules.telegram.functions.que.line[chatID] = current;
|
@@ -3,7 +3,12 @@
|
|
3
3
|
"start" : {
|
4
4
|
"object" : {
|
5
5
|
"text" : "Test First Title : {{TEST}}",
|
6
|
-
"image" : "{{URL}}app/content/images/block.png"
|
6
|
+
"image" : "{{URL}}app/content/images/block.png",
|
7
|
+
"buttons" : [
|
8
|
+
[
|
9
|
+
{ "text": "Test Callback", "callback_data": "other" }
|
10
|
+
]
|
11
|
+
]
|
7
12
|
},
|
8
13
|
"match" : {
|
9
14
|
"data" : [{
|
@@ -48,7 +48,7 @@ module.exports = async function(program,folder) {
|
|
48
48
|
middleValue.chat.ts = Date.now();
|
49
49
|
middleValue.chat.uuid = program.uuid.v4();
|
50
50
|
let user = await program.modules.data.findOrCreate(`eventgo`,`telegram`,{
|
51
|
-
id : middleValue.
|
51
|
+
id : middleValue.from.id
|
52
52
|
},middleValue.chat);
|
53
53
|
let typeOFF = typeof user;
|
54
54
|
if (middleValue.chat.uuid == user.uuid || user.profileImage == undefined) {
|
@@ -76,7 +76,13 @@ module.exports = async function(program,folder) {
|
|
76
76
|
|
77
77
|
try {
|
78
78
|
// Or check if single word
|
79
|
-
|
79
|
+
let starts;
|
80
|
+
if (middleValue.text != undefined) {
|
81
|
+
if (middleValue.text.startsWith('/')) {
|
82
|
+
starts = true;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
if (starts== true) {
|
80
86
|
// If it starts with a slash, it might be a command
|
81
87
|
const parts = middleValue.text.split(' ');
|
82
88
|
|
@@ -125,7 +131,7 @@ module.exports = async function(program,folder) {
|
|
125
131
|
case `message`:
|
126
132
|
console.log(`We have response, check for response message`);
|
127
133
|
const message = respFunc[action];
|
128
|
-
await program.modules.telegram.functions.send(program,message,middleValue.
|
134
|
+
await program.modules.telegram.functions.send(program,message,middleValue.from.id);
|
129
135
|
break;
|
130
136
|
default:
|
131
137
|
console.error(`Missing Response Action Telegram: ${action}`);
|
@@ -154,7 +160,7 @@ module.exports = async function(program,folder) {
|
|
154
160
|
case `message`:
|
155
161
|
console.log(`We have response, check for response message`);
|
156
162
|
const message = respFunc[action];
|
157
|
-
await program.modules.telegram.functions.send(program,message,middleValue.
|
163
|
+
await program.modules.telegram.functions.send(program,message,middleValue.from.id);
|
158
164
|
break;
|
159
165
|
default:
|
160
166
|
console.error(`Missing Response Action Telegram: ${action}`);
|
@@ -163,7 +169,7 @@ module.exports = async function(program,folder) {
|
|
163
169
|
} catch (err) {
|
164
170
|
//console.error(err);
|
165
171
|
//console.error(`Error For Telegram Function`);
|
166
|
-
await program.modules.telegram.functions.send(program,`Unknown Command: ${command}`,middleValue.
|
172
|
+
await program.modules.telegram.functions.send(program,`Unknown Command: ${command}`,middleValue.from.id);
|
167
173
|
}
|
168
174
|
}
|
169
175
|
|
@@ -176,7 +182,20 @@ module.exports = async function(program,folder) {
|
|
176
182
|
|
177
183
|
// TODO Catch events for middleware now just respond
|
178
184
|
const message = `${middleValue.text}`;
|
179
|
-
|
185
|
+
let command = message;
|
186
|
+
if (middleValue.text == undefined) {
|
187
|
+
// Check if callback or something
|
188
|
+
if (middleValue.message != undefined) {
|
189
|
+
if (middleValue.message.reply_markup != undefined) {
|
190
|
+
// Grab markup
|
191
|
+
const markupData = middleValue.message.reply_markup.inline_keyboard[0][0][`callback_data`];
|
192
|
+
// Hoppa
|
193
|
+
middleValue.text = markupData;
|
194
|
+
command = markupData;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
180
199
|
try {
|
181
200
|
// Run dynamic the type of middleware
|
182
201
|
const runFunc = await program.modules.telegram.middleware[key][command](req,res,body,params,command,middleValue,program);
|
@@ -189,7 +208,7 @@ module.exports = async function(program,folder) {
|
|
189
208
|
case `message`:
|
190
209
|
console.log(`We have response, check for response message`);
|
191
210
|
const message = respFunc[action];
|
192
|
-
await program.modules.telegram.functions.send(program,message,middleValue.
|
211
|
+
await program.modules.telegram.functions.send(program,message,middleValue.from.id);
|
193
212
|
break;
|
194
213
|
default:
|
195
214
|
console.error(`Missing Response Action Telegram: ${action}`);
|
@@ -198,9 +217,9 @@ module.exports = async function(program,folder) {
|
|
198
217
|
//console.error(err);
|
199
218
|
//console.error(`Error For Telegram Function`);
|
200
219
|
console.log(`Checking for script`);
|
201
|
-
const scripting = await program.modules.telegram.script.function.check(program,command,middleValue.
|
220
|
+
const scripting = await program.modules.telegram.script.function.check(program,command,middleValue.from.id,middleValue,received);
|
202
221
|
/*
|
203
|
-
await program.modules.telegram.functions.send(program,`${command}`,middleValue.
|
222
|
+
await program.modules.telegram.functions.send(program,`${command}`,middleValue.from.id,[
|
204
223
|
[
|
205
224
|
{ text: 'EventGO!', web_app : { url : 'https://cloud.eventgo.today/events/list'}},
|
206
225
|
{ text: 'Create Event', callback_data: 'create_event' },
|
@@ -237,7 +256,7 @@ module.exports = async function(program,folder) {
|
|
237
256
|
case `message`:
|
238
257
|
console.log(`We have response, check for response message`);
|
239
258
|
const message = respFunc[action];
|
240
|
-
await program.modules.telegram.functions.send(program,message,middleValue.
|
259
|
+
await program.modules.telegram.functions.send(program,message,middleValue.from.id);
|
241
260
|
break;
|
242
261
|
default:
|
243
262
|
console.error(`Missing Response Action Telegram: ${action}`);
|