webfast 0.1.48 → 0.1.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ module.exports = async function(req,res,body,params,command,middleValue,received
|
|
4
4
|
|
5
5
|
// Do the script thing
|
6
6
|
if (middleValue.text.startsWith(`/`)) {
|
7
|
+
middleValue.origin = middleValue.text;
|
7
8
|
middleValue.text = `start`;
|
8
9
|
const scripting = await program.modules.telegram.script.function.check(program,command,middleValue.from.id,middleValue,received);
|
9
10
|
console.log(`Scripting`);
|
@@ -42,6 +42,13 @@ module.exports = {
|
|
42
42
|
let current;
|
43
43
|
|
44
44
|
let theUUID = program.uuid.v4();
|
45
|
+
|
46
|
+
if (program.modules.telegram.functions.que.line[chatID] != undefined && middleValue.origin != undefined) {
|
47
|
+
if (middleValue.origin.startsWith(`/`)) {
|
48
|
+
delete program.modules.telegram.functions.que.line[chatID];
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
45
52
|
if (program.modules.telegram.functions.que.line[chatID] != undefined) {
|
46
53
|
// It's original que
|
47
54
|
// Process response
|
@@ -91,7 +98,13 @@ module.exports = {
|
|
91
98
|
case command:
|
92
99
|
console.log(`It's the dynamic thing`);
|
93
100
|
matched = matchCheck;
|
94
|
-
let variable
|
101
|
+
let variable;
|
102
|
+
if (data.message != undefined) {
|
103
|
+
variable = data.message[command]
|
104
|
+
} else if (data.callback_query != undefined) {
|
105
|
+
variable = data.callback_query
|
106
|
+
}
|
107
|
+
|
95
108
|
anwserData = {
|
96
109
|
type : command,
|
97
110
|
data : variable
|
@@ -112,7 +125,9 @@ module.exports = {
|
|
112
125
|
// Send command when wrong // or buttons like reset button
|
113
126
|
// check what to do
|
114
127
|
// check if stop
|
115
|
-
|
128
|
+
if (String(middleValue.text) == `reset` || String(middleValue.text) == `stop`) {
|
129
|
+
delete program.modules.telegram.functions.que.line[chatID];
|
130
|
+
}
|
116
131
|
return false;
|
117
132
|
} else {
|
118
133
|
console.log(`Matched`);
|
@@ -157,6 +172,13 @@ module.exports = {
|
|
157
172
|
// Get item
|
158
173
|
const theScript = script[scriptStart];
|
159
174
|
|
175
|
+
if (scriptStart == `finish`) {
|
176
|
+
// Delete from list
|
177
|
+
setTimeout(function(){
|
178
|
+
delete program.modules.telegram.functions.que.line[chatID];
|
179
|
+
},150);
|
180
|
+
}
|
181
|
+
|
160
182
|
// Create replacelist
|
161
183
|
let replace = {
|
162
184
|
"{{URL}}" : process.env.url,
|
@@ -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
|
|
@@ -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);
|