webfast 0.1.18 → 0.1.21

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.
package/index.js CHANGED
@@ -1,244 +1,246 @@
1
- const { readdirSync } = require("fs");
2
-
3
- console.log(`WebFast!! Program`);
4
- let program = {
5
- ts : Date.now(),
6
- modules : {},
7
- tmp : {}
8
- }
9
-
10
- // Setup The Requirements
11
- async function set(program) {
12
- program.path = await require(`path`);
13
- program.fs = await require(`fs`);
14
- program.uuid = require(`uuid`);
15
- program.fetch = require(`fetch`);
16
- return program;
17
- }
18
-
19
- // Program Fetch
20
- program.modules.dependOn = async function(reqFunc,program,name,callback) {
21
- console.log(`Depend On Check`);
22
-
23
- // Loop Through dependOn if its not true then check
24
- for (let dependIndex in reqFunc.dependOn) {
25
- const dependOn = reqFunc.dependOn[dependIndex];
26
- // So we dependOn
27
- // Check index
28
- // If .
29
- let split = dependOn.split(`.`);
30
- // Now we should loop through array
31
- let objectData = program;
32
- let fullObjectPath = `program`;
33
- let dependOnItem = ``;
34
- for (let spl in split) {
35
- // Grab object
36
- let toCheck = split[spl];
37
- if (objectData[toCheck] == undefined) {
38
- if (program.modules[name] != undefined) {
39
- return;
40
- } else {
41
- program.modules[name] = {
42
- ts : Date.now()
1
+ module.exports = function () {
2
+ const { readdirSync } = require("fs");
3
+
4
+ console.log(`WebFast!! Program`);
5
+ let program = {
6
+ ts : Date.now(),
7
+ modules : {},
8
+ tmp : {}
9
+ }
10
+
11
+ // Setup The Requirements
12
+ async function set(program) {
13
+ program.path = await require(`path`);
14
+ program.fs = await require(`fs`);
15
+ program.uuid = require(`uuid`);
16
+ program.fetch = require(`fetch`);
17
+ return program;
18
+ }
19
+
20
+ // Program Fetch
21
+ program.modules.dependOn = async function(reqFunc,program,name,callback) {
22
+ console.log(`Depend On Check`);
23
+
24
+ // Loop Through dependOn if its not true then check
25
+ for (let dependIndex in reqFunc.dependOn) {
26
+ const dependOn = reqFunc.dependOn[dependIndex];
27
+ // So we dependOn
28
+ // Check index
29
+ // If .
30
+ let split = dependOn.split(`.`);
31
+ // Now we should loop through array
32
+ let objectData = program;
33
+ let fullObjectPath = `program`;
34
+ let dependOnItem = ``;
35
+ for (let spl in split) {
36
+ // Grab object
37
+ let toCheck = split[spl];
38
+ if (objectData[toCheck] == undefined) {
39
+ if (program.modules[name] != undefined) {
40
+ return;
41
+ } else {
42
+ program.modules[name] = {
43
+ ts : Date.now()
44
+ }
45
+ await setTimeout(async function(){
46
+ await program.modules.dependOn(reqFunc,program,name,callback);
47
+ },200);
43
48
  }
44
- await setTimeout(async function(){
45
- await program.modules.dependOn(reqFunc,program,name,callback);
46
- },200);
47
- }
48
- } else {
49
- // New object thing and og next
50
- if (split.length-1 != spl) {
51
- fullObjectPath = fullObjectPath + `.${toCheck}`
52
49
  } else {
53
- // Depend on
54
- dependOnItem = toCheck;
50
+ // New object thing and og next
51
+ if (split.length-1 != spl) {
52
+ fullObjectPath = fullObjectPath + `.${toCheck}`
53
+ } else {
54
+ // Depend on
55
+ dependOnItem = toCheck;
56
+ }
57
+ objectData = objectData[toCheck];
55
58
  }
56
- objectData = objectData[toCheck];
57
59
  }
58
- }
59
60
 
60
- let progData = await eval(fullObjectPath);
61
- const IndexCheck = Object.keys(progData).indexOf(dependOnItem);
62
- if (IndexCheck == -1) {
63
- // We need to wait and try again untill we can return
64
- console.log(`DependOn Fail: ${dependOn}`);
65
- await setTimeout(async function(){
66
- await program.modules.dependOn(reqFunc,program);
67
- },200);
68
- } else if (program.modules[reqFunc.name] == undefined) {
69
- console.log(`DependOn Succes: ${dependOn}`);
70
-
71
- // Loop Through to find where data to set
72
- const splitLoop = String(`${fullObjectPath}.${dependOnItem}`).split(`.`);
73
- let object;
74
- for (let s in splitLoop) {
75
- let key = splitLoop[s];
61
+ let progData = await eval(fullObjectPath);
62
+ const IndexCheck = Object.keys(progData).indexOf(dependOnItem);
63
+ if (IndexCheck == -1) {
64
+ // We need to wait and try again untill we can return
65
+ console.log(`DependOn Fail: ${dependOn}`);
66
+ await setTimeout(async function(){
67
+ await program.modules.dependOn(reqFunc,program);
68
+ },200);
69
+ } else if (program.modules[reqFunc.name] == undefined) {
70
+ console.log(`DependOn Succes: ${dependOn}`);
71
+
72
+ // Loop Through to find where data to set
73
+ const splitLoop = String(`${fullObjectPath}.${dependOnItem}`).split(`.`);
74
+ let object;
75
+ for (let s in splitLoop) {
76
+ let key = splitLoop[s];
77
+ try {
78
+ if (object == undefined) {
79
+ object = eval(key);
80
+ } else {
81
+ object = object[key];
82
+ }
83
+ if (s == splitLoop-1) {
84
+ // It's end
85
+ object = {
86
+ depend : dependOn,
87
+ state : true,
88
+ ts : Date.now()
89
+ }
90
+ }
91
+ } catch (err) {
92
+ console.error(err);
93
+ console.error(`errror boject eval set`);
94
+ return setTimeout(async function(){
95
+ await program.modules.dependOn(reqFunc,program,name,callback);
96
+ },200);
97
+ }
98
+ }
99
+ /*
100
+ progData[dependOnItem] = {
101
+ depend : dependOn,
102
+ state : true,
103
+ ts : Date.now()
104
+ } */
105
+
106
+ // Now include this thing then
76
107
  try {
77
- if (object == undefined) {
78
- object = eval(key);
108
+ program.modules[reqFunc.name] = await reqFunc.run(program,reqFunc.name);
109
+ if (callback != undefined) {
110
+ return callback(program,name)
79
111
  } else {
80
- object = object[key];
112
+ return program;
81
113
  }
82
- if (s == splitLoop-1) {
83
- // It's end
84
- object = {
85
- depend : dependOn,
86
- state : true,
87
- ts : Date.now()
88
- }
89
- }
90
- } catch (err) {
114
+ } catch(err) {
115
+ // When erro
116
+ console.error(`Error Program add depend on require`);
91
117
  console.error(err);
92
- console.error(`errror boject eval set`);
93
- return setTimeout(async function(){
94
- await program.modules.dependOn(reqFunc,program,name,callback);
95
- },200);
96
118
  }
97
119
  }
98
- /*
99
- progData[dependOnItem] = {
100
- depend : dependOn,
101
- state : true,
102
- ts : Date.now()
103
- } */
104
-
105
- // Now include this thing then
106
- try {
107
- program.modules[reqFunc.name] = await reqFunc.run(program,reqFunc.name);
108
- if (callback != undefined) {
109
- return callback(program,name)
120
+ }
121
+ }
122
+
123
+ program.modules.fetch = async function(folder,program) {
124
+ // TO Fetch folder modules
125
+ program = await set(program);
126
+ try {
127
+ // Loop through folder and run module if js
128
+ const readPath = program.path.join(__dirname,folder);
129
+ const readDir = program.fs.readdirSync(readPath);
130
+ // Check if folder or not
131
+ await readDir.forEach(async (item) => {
132
+ const itemPath = program.path.join(readPath, item);
133
+ // Get the filename with extension
134
+ const fileNameWithExtension = program.path.basename(itemPath);
135
+
136
+ // Get the filename without extension
137
+ const fileNameWithoutExtension = program.path.parse(fileNameWithExtension).name;
138
+
139
+ console.log('Filename without extension:', fileNameWithoutExtension);
140
+
141
+ const isDirectory = program.fs.statSync(itemPath).isDirectory();
142
+
143
+ if (!isDirectory) {
144
+ // So it's file
145
+ // Run the file to know what to do but change program with the return
146
+ //program = (require(itemPath)(program));
147
+ //console.log(`Set`,itemPath);
110
148
  } else {
111
- return program;
149
+ // It's directory so read the init file
150
+ const initPath = program.path.join(itemPath,`init.js`);
151
+
152
+ // Require first
153
+ const reqFunc = require(initPath);
154
+ const theType = typeof reqFunc;
155
+ switch (theType) {
156
+ case `object`:
157
+ // It's a object so check for dependend things etc.
158
+ console.log(`Depending object`);
159
+ return await program.modules.dependOn(reqFunc,program,fileNameWithoutExtension,function(program,name){
160
+ console.log(`Setup `,name)
161
+ });
162
+ break;
163
+ case `function`:
164
+ program = await (require(initPath)(program,fileNameWithExtension));
165
+ break;
166
+ default:
167
+ console.error(`Error Missing typeOf item`);
168
+ }
112
169
  }
113
- } catch(err) {
114
- // When erro
115
- console.error(`Error Program add depend on require`);
116
- console.error(err);
117
- }
170
+ });
171
+
172
+ } catch(err) {
173
+ console.error(`Error Program Modules Fetch`);
174
+ console.error(err);
118
175
  }
119
176
  }
120
- }
121
-
122
- program.modules.fetch = async function(folder,program) {
123
- // TO Fetch folder modules
124
- program = await set(program);
125
- try {
126
- // Loop through folder and run module if js
127
- const readPath = program.path.join(__dirname,folder);
128
- const readDir = program.fs.readdirSync(readPath);
129
- // Check if folder or not
130
- await readDir.forEach(async (item) => {
131
- const itemPath = program.path.join(readPath, item);
132
- // Get the filename with extension
133
- const fileNameWithExtension = program.path.basename(itemPath);
134
-
135
- // Get the filename without extension
136
- const fileNameWithoutExtension = program.path.parse(fileNameWithExtension).name;
137
-
138
- console.log('Filename without extension:', fileNameWithoutExtension);
139
-
140
- const isDirectory = program.fs.statSync(itemPath).isDirectory();
141
-
142
- if (!isDirectory) {
143
- // So it's file
144
- // Run the file to know what to do but change program with the return
145
- //program = (require(itemPath)(program));
146
- //console.log(`Set`,itemPath);
177
+
178
+ // Create tmp file path
179
+ program.modules.walkDirectory = async function (directoryPath, callback, forward, parentFileData) {
180
+ let allFiles = [];
181
+ try {
182
+ // Read the contents of the current directory
183
+ const files = await program.fs.readdirSync(directoryPath);
184
+
185
+ // Iterate through the files in the directory
186
+ for (const file of files) {
187
+ // Construct the full path of the current file or directory
188
+ const fullPath = program.path.join(directoryPath, file);
189
+
190
+ // Check if the current item is a directory
191
+ const pathSync = await program.fs.statSync(fullPath);
192
+ const isDirectoryPath = await pathSync.isDirectory();
193
+ const fileExtension = program.path.extname(fullPath);
194
+
195
+ // Get the filename without the extension
196
+ const fileName = program.path.basename(fullPath, fileExtension);
197
+
198
+ // Create a new fileData object for each file or directory
199
+ const currentFileData = {
200
+ extension: fileExtension,
201
+ name: fileName,
202
+ path: fullPath,
203
+ sub: [],
204
+ };
205
+
206
+ if (isDirectoryPath) {
207
+ // If it's a directory, recursively walk through it
208
+ let pushData = await program.modules.walkDirectory(fullPath, callback, fileName, currentFileData);
209
+ if (pushData.length !== 0) {
210
+ // Concatenate arrays instead of pushing an array
211
+ allFiles.push(currentFileData);
212
+ allFiles = allFiles.concat(pushData);
147
213
  } else {
148
- // It's directory so read the init file
149
- const initPath = program.path.join(itemPath,`init.js`);
150
-
151
- // Require first
152
- const reqFunc = require(initPath);
153
- const theType = typeof reqFunc;
154
- switch (theType) {
155
- case `object`:
156
- // It's a object so check for dependend things etc.
157
- console.log(`Depending object`);
158
- return await program.modules.dependOn(reqFunc,program,fileNameWithoutExtension,function(program,name){
159
- console.log(`Setup `,name)
160
- });
161
- break;
162
- case `function`:
163
- program = await (require(initPath)(program,fileNameWithExtension));
164
- break;
165
- default:
166
- console.error(`Error Missing typeOf item`);
167
- }
214
+ allFiles.push(currentFileData);
215
+ }
216
+ } else {
217
+ // If it's a file, print the path
218
+ console.log('File Extension:', fileExtension);
219
+ console.log('File Name:', fileName);
220
+
221
+ if (forward !== undefined) {
222
+ // Push it to sub
223
+ parentFileData.sub.push(currentFileData);
224
+ } else {
225
+ allFiles.push(currentFileData);
226
+ }
168
227
  }
169
- });
170
-
171
- } catch(err) {
172
- console.error(`Error Program Modules Fetch`);
173
- console.error(err);
174
- }
175
- }
176
-
177
- // Create tmp file path
178
- program.modules.walkDirectory = async function (directoryPath, callback, forward, parentFileData) {
179
- let allFiles = [];
180
- try {
181
- // Read the contents of the current directory
182
- const files = await program.fs.readdirSync(directoryPath);
183
-
184
- // Iterate through the files in the directory
185
- for (const file of files) {
186
- // Construct the full path of the current file or directory
187
- const fullPath = program.path.join(directoryPath, file);
188
-
189
- // Check if the current item is a directory
190
- const pathSync = await program.fs.statSync(fullPath);
191
- const isDirectoryPath = await pathSync.isDirectory();
192
- const fileExtension = program.path.extname(fullPath);
193
-
194
- // Get the filename without the extension
195
- const fileName = program.path.basename(fullPath, fileExtension);
196
-
197
- // Create a new fileData object for each file or directory
198
- const currentFileData = {
199
- extension: fileExtension,
200
- name: fileName,
201
- path: fullPath,
202
- sub: [],
203
- };
204
-
205
- if (isDirectoryPath) {
206
- // If it's a directory, recursively walk through it
207
- let pushData = await program.modules.walkDirectory(fullPath, callback, fileName, currentFileData);
208
- if (pushData.length !== 0) {
209
- // Concatenate arrays instead of pushing an array
210
- allFiles.push(currentFileData);
211
- allFiles = allFiles.concat(pushData);
212
- } else {
213
- allFiles.push(currentFileData);
214
- }
215
- } else {
216
- // If it's a file, print the path
217
- console.log('File Extension:', fileExtension);
218
- console.log('File Name:', fileName);
219
-
220
- if (forward !== undefined) {
221
- // Push it to sub
222
- parentFileData.sub.push(currentFileData);
223
- } else {
224
- allFiles.push(currentFileData);
225
- }
226
228
  }
227
- }
228
-
229
- if (callback && forward === undefined) {
230
- await callback(allFiles);
231
- }
232
-
233
- return allFiles;
234
- } catch (error) {
235
- console.error('Error:', error.message);
236
- }
237
- };
238
-
229
+
230
+ if (callback && forward === undefined) {
231
+ await callback(allFiles);
232
+ }
233
+
234
+ return allFiles;
235
+ } catch (error) {
236
+ console.error('Error:', error.message);
237
+ }
238
+ };
239
+
239
240
 
240
-
241
-
241
+
242
+
242
243
 
243
- // Run program fetch
244
- program.modules.fetch(`modules`,program);
244
+ // Run program fetch
245
+ program.modules.fetch(`modules`,program);
246
+ }
@@ -7,14 +7,13 @@ module.exports = {
7
7
  this.line[id] = data;
8
8
  return this.line[id];
9
9
  },
10
- get : function(id) {
10
+ get : function(id,program) {
11
11
  console.log(`Que Get Telegram`);
12
12
  // Check if in que line
13
- let indexPart = Object.keys(this.line).indexOf(id);
14
- if (indexPart == -1) {
13
+ if (program.modules.telegram.functions.que.line[id] == undefined) {
15
14
  return false;
16
15
  } else {
17
- let lineData = this.line[indexPart];
16
+ let lineData = program.modules.telegram.functions.que.line[id];
18
17
  return lineData;
19
18
  }
20
19
  },
@@ -31,22 +30,87 @@ module.exports = {
31
30
 
32
31
  let scriptStart = `start`;
33
32
  // It's new
34
- if (program.modules.telegram.script.int[command] == undefined) {
33
+ if (program.modules.telegram.script.int[command] == undefined && program.modules.telegram.functions.que.line[chatID] == undefined) {
35
34
  // Send message we don't know
36
35
 
37
36
  return false;
38
37
  }
39
38
 
40
39
  // Create the que line command
41
- const script = program.modules.telegram.script.int[command];
40
+ let script = program.modules.telegram.script.int[command];
42
41
 
43
42
  let current;
44
43
 
44
+ let theUUID = program.uuid.v4();
45
45
  if (program.modules.telegram.functions.que.line[chatID] != undefined) {
46
46
  // It's original que
47
47
  // Process response
48
48
  console.log(`It's a process`)
49
49
  current = program.modules.telegram.functions.que.line[chatID];
50
+ theUUID = current.uuid;
51
+
52
+ // Check what to do next first of all save anwser
53
+ const question = current.script[current.process];
54
+ // Grab function to process
55
+ const anwser = middleValue;
56
+
57
+ // Check if text then we need to match if not we probably need to run only function and go to next one
58
+ let matched = false;
59
+ let anwserData;
60
+ if (middleValue.text != undefined) {
61
+ console.log(`Match Text`);
62
+ // Loop through match
63
+ anwserData = middleValue.text;
64
+ for (let q in question.match.data) {
65
+ const qMatch = question.match.data[q];
66
+
67
+ // Check typeof
68
+ if (typeof qMatch.anwser == `object`) {
69
+ // Match in index
70
+ const matchedIndex = qMatch.anwser.indexOf(middleValue.text);
71
+ if (matchedIndex != -1) {
72
+ matched = qMatch;
73
+ }
74
+ } else if (qMatch.anwser == middleValue.text) {
75
+ matched = qMatch;
76
+ }
77
+ }
78
+ } else {
79
+ console.error(`Need to set anwser data`);
80
+ }
81
+
82
+ // End of match process fo matched checking
83
+ if (matched == false && current.q == true) {
84
+ // We have different data
85
+ console.error(`Not matched`);
86
+ // Send command when wrong // or buttons like reset button
87
+ // check what to do
88
+ return false;
89
+ } else {
90
+ console.log(`Matched`);
91
+ current.anwsers[current.process] = {
92
+ anwser : anwserData,
93
+ message : anwser,
94
+ ts : Date.now()
95
+ };
96
+
97
+ // Set next steps and get next steps data
98
+ try {
99
+ const nextData = current.script[matched.next];
100
+ if (nextData == undefined) {
101
+ throw new Error(`Problems getting nextData for`,current);
102
+ }
103
+ console.log(`Next Data`);
104
+ scriptStart = matched.next;
105
+ current.process = matched.next;
106
+ script = current.script;
107
+ } catch (err) {
108
+ console.error(err);
109
+ console.error(`Error getting data for next: ${matched.next}`);
110
+ }
111
+ }
112
+
113
+ console.log(`We have question anwser`);
50
114
  } else {
51
115
  // Create que line
52
116
  let setData = {
@@ -54,7 +118,9 @@ module.exports = {
54
118
  action : command,
55
119
  process : scriptStart,
56
120
  script : script,
57
- anwsers : {}
121
+ anwsers : {},
122
+ uuid : theUUID,
123
+ q : true
58
124
  }
59
125
  program.modules.telegram.functions.que.line[chatID] = setData;
60
126
  current = setData;
@@ -69,6 +135,22 @@ module.exports = {
69
135
  "{{TEST}}" : "TEST REPLACED"
70
136
  }
71
137
 
138
+ // Check if anwsers
139
+ if (Object.keys(current.anwsers).length > 0) {
140
+ // Check the anwsers
141
+ for (let anwserTXT in current.anwsers) {
142
+ const typedOf = typeof current.anwsers[anwserTXT].anwser;
143
+
144
+ if (typedOf == `string`) {
145
+ replace[`{{${String(anwserTXT).toUpperCase()}}}`] = current.anwsers[anwserTXT].anwser;
146
+ }
147
+ }
148
+ console.log(`Check loop through anwsers`);
149
+ }
150
+
151
+ // Add items to replace
152
+ console.log(`Add Items to replace`);
153
+
72
154
  // Check if text
73
155
  let toSend = {}
74
156
  if (theScript.object.text != undefined) {
@@ -92,13 +174,29 @@ module.exports = {
92
174
  }
93
175
 
94
176
  // Check if text
95
- await program.modules.telegram.functions.send(program,toSend,middleValue.chat.id);
177
+ let buttons;
178
+ // check for buttons
179
+ if (theScript.object.buttons != undefined) {
180
+ buttons = JSON.stringify(theScript.object.buttons);
181
+ // Loop through replace
182
+ for (let repKey in replace) {
183
+ const newRegx = new RegExp(repKey, 'g');
184
+ buttons = buttons.replace(newRegx,replace[repKey]);
185
+ }
186
+ buttons = JSON.parse(buttons);
187
+ }
188
+ await program.modules.telegram.functions.send(program,toSend,middleValue.chat.id,buttons);
96
189
 
190
+ // set que uuid
97
191
  program.modules.telegram.functions.que.line[chatID] = current;
192
+
98
193
  console.log(`We have script data`);
194
+
195
+ return current;
99
196
  } catch (err) {
100
197
  console.error(err);
101
198
  console.error(`Error with que something`);
199
+ return false;
102
200
  }
103
201
 
104
202
  // Do all the things that we need to do in the run
@@ -4,8 +4,8 @@ module.exports = {
4
4
  console.log(`Check if there is script`);
5
5
  try {
6
6
  const scriptData = program.modules.telegram.script.int[command];
7
- if (scriptData.length == 0) {
8
- await program.modules.telegram.functions.send(program,`${command}`,chatID,[
7
+ if (scriptData == undefined && program.modules.telegram.functions.que.get(chatID,program) == false) {
8
+ await program.modules.telegram.functions.send(program,`Sorry we don't understand: ${command}`,chatID,[
9
9
  [
10
10
  { text: 'EventGO!', web_app : { url : 'https://cloud.eventgo.today/events/list'}},
11
11
  { text: 'Create Event', callback_data: 'create_event' },
@@ -17,8 +17,16 @@ module.exports = {
17
17
 
18
18
  // Check if queData is empty otherwise we will run the script from "start", if que data is not empty we run it further
19
19
  // unt o process script
20
-
20
+ // now it's just wait
21
21
  console.log(`Went through que get`);
22
+ // Send message
23
+ if (queData == false) {
24
+ await program.modules.telegram.functions.send(program,`Sorry we don't know what to do with: ${command}`,chatID);
25
+ } else if (queData.process != `start`) {
26
+ // Process the que event
27
+ console.log(`Process the que event`);
28
+
29
+ }
22
30
  }
23
31
  console.log(`Setted`);
24
32
 
@@ -27,5 +35,8 @@ module.exports = {
27
35
  console.error(err);
28
36
  console.error(`Error Scripting`);
29
37
  }
38
+ },
39
+ response : async function() {
40
+ console.log(`Function Response`);
30
41
  }
31
42
  }
@@ -2,36 +2,56 @@
2
2
  "input" : "test input",
3
3
  "start" : {
4
4
  "object" : {
5
- "text" : "Testing Title : {{TEST}}",
5
+ "text" : "Test First Title : {{TEST}}",
6
6
  "image" : "{{URL}}app/content/images/block.png"
7
7
  },
8
8
  "match" : {
9
9
  "data" : [{
10
- "response" : "anwser text",
11
- "function" : "program.modules.bots.scripts.function",
12
- "reply_markup" : {
13
- "inline_keyboard": [[
14
- {
15
- "text": "A",
16
- "callback_data": "A1"
17
- },
18
- {
19
- "text": "B",
20
- "callback_data": "C1"
21
- }]
22
- ]
23
- },
10
+ "anwser" : ["anwser text","anwser"],
11
+ "function" : "program.modules.bots.scripts.function.response",
24
12
  "next" : "nextFunc"
25
13
  },{
26
- "response" : "other",
27
- "function" : "program.modules.bots.scripts.function",
14
+ "anwser" : "other",
15
+ "function" : "program.modules.bots.scripts.function.response",
28
16
  "next" : "nextFunc"
17
+ },{
18
+ "anwser" : "hi",
19
+ "function" : "program.modules.bots.scripts.function.response",
20
+ "next" : "nextFunc"
21
+ }]
22
+ },
23
+ "fail" : {
24
+ "response" : "start",
25
+ "function" : "program.modules.bots.scripts.function.response",
26
+ "next" : "failResponse"
27
+ }
28
+ },
29
+ "nextFunc" : {
30
+ "object" : {
31
+ "text" : "Testing Title : {{START}}",
32
+ "buttons" : [
33
+ [
34
+ { "text": "EventGO!", "web_app" : { "url" : "{{URL}}events/list"}},
35
+ { "text": "Create Event", "callback_data": "create_event" }
36
+ ]
37
+ ]
38
+ },
39
+ "match" : {
40
+ "data" : [{
41
+ "anwser" : ["create_event"],
42
+ "function" : "program.modules.bots.scripts.function.response",
43
+ "next" : "finish"
29
44
  }]
30
45
  },
31
46
  "fail" : {
32
47
  "response" : "start",
33
- "function" : "program.modules.bots.scripts.function",
48
+ "function" : "program.modules.bots.scripts.function.response",
34
49
  "next" : "failResponse"
35
50
  }
51
+ },
52
+ "failResponse" : {
53
+ "object" : {
54
+ "text" : "Sorry Something Wnt wrong : {{START}}"
55
+ }
36
56
  }
37
57
  }
@@ -44,6 +44,8 @@ module.exports = async function(program,message,id,buttons) {
44
44
  delete body.reply_to_message_id;
45
45
  telegramURL = `${telegramURL}/sendPhoto`;
46
46
  }
47
+ } else {
48
+ telegramURL = `${telegramURL}/sendMessage`;
47
49
  }
48
50
 
49
51
  // If options is there add as
@@ -52,6 +54,13 @@ module.exports = async function(program,message,id,buttons) {
52
54
  }
53
55
 
54
56
  const madeRequest = await program.modules.request.post(program,telegramURL,body)
57
+
58
+ // Save to send so we can have the id and do things
59
+ madeRequest.result.uuid = program.uuid.v4();
60
+ let saveSend = await program.modules.data.findOrCreate(`eventgo`,`send`,{
61
+ message_id : madeRequest.result.message_id
62
+ },madeRequest.result);
63
+
55
64
  console.log(`Send Message`);
56
65
  return madeRequest;
57
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webfast",
3
- "version": "0.1.18",
3
+ "version": "0.1.21",
4
4
  "description": "WebFast! Bot Application, including TON mini-apps",
5
5
  "main": "index.js",
6
6
  "repository": {
File without changes
File without changes
File without changes
File without changes