webfast 0.1.49 → 0.1.51

Sign up to get free protection for your applications and to get access to all the features.
@@ -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`);
@@ -29,6 +29,7 @@ module.exports = {
29
29
  try {
30
30
 
31
31
  let scriptStart = `start`;
32
+
32
33
  // It's new
33
34
  if (program.modules.telegram.script.int[command] == undefined && program.modules.telegram.functions.que.line[chatID] == undefined) {
34
35
  // Send message we don't know
@@ -42,6 +43,13 @@ module.exports = {
42
43
  let current;
43
44
 
44
45
  let theUUID = program.uuid.v4();
46
+
47
+ if (program.modules.telegram.functions.que.line[chatID] != undefined && middleValue.origin != undefined) {
48
+ if (middleValue.origin.startsWith(`/`)) {
49
+ delete program.modules.telegram.functions.que.line[chatID];
50
+ }
51
+ }
52
+
45
53
  if (program.modules.telegram.functions.que.line[chatID] != undefined) {
46
54
  // It's original que
47
55
  // Process response
@@ -57,7 +65,8 @@ module.exports = {
57
65
  // Check if text then we need to match if not we probably need to run only function and go to next one
58
66
  let matched = false;
59
67
  let anwserData;
60
- if (middleValue.text != undefined) {
68
+ if (middleValue.text != undefined || middleValue.data != undefined) {
69
+
61
70
  console.log(`Match Text`);
62
71
  // Loop through match
63
72
  anwserData = middleValue.text;
@@ -91,7 +100,13 @@ module.exports = {
91
100
  case command:
92
101
  console.log(`It's the dynamic thing`);
93
102
  matched = matchCheck;
94
- let variable = data.message[command]
103
+ let variable;
104
+ if (data.message != undefined) {
105
+ variable = data.message[command]
106
+ } else if (data.callback_query != undefined) {
107
+ variable = data.callback_query
108
+ }
109
+
95
110
  anwserData = {
96
111
  type : command,
97
112
  data : variable
@@ -112,7 +127,7 @@ module.exports = {
112
127
  // Send command when wrong // or buttons like reset button
113
128
  // check what to do
114
129
  // check if stop
115
- if (middleValue.text == `reset` || middleValue.text `stop`) {
130
+ if (String(middleValue.text) == `reset` || String(middleValue.text) == `stop`) {
116
131
  delete program.modules.telegram.functions.que.line[chatID];
117
132
  }
118
133
  return false;
@@ -159,6 +174,13 @@ module.exports = {
159
174
  // Get item
160
175
  const theScript = script[scriptStart];
161
176
 
177
+ if (scriptStart == `finish`) {
178
+ // Delete from list
179
+ setTimeout(function(){
180
+ delete program.modules.telegram.functions.que.line[chatID];
181
+ },150);
182
+ }
183
+
162
184
  // Create replacelist
163
185
  let replace = {
164
186
  "{{URL}}" : process.env.url,
@@ -77,6 +77,14 @@ module.exports = async function(program,folder) {
77
77
  try {
78
78
  // Or check if single word
79
79
  let starts;
80
+ if (middleValue.text == undefined && key == `callback_query`) {
81
+ if (middleValue.data.startsWith(`/`)) {
82
+ middleValue.text = middleValue.data.slice(1);
83
+ middleValue.origin = middleValue.data;
84
+ } else {
85
+ middleValue.text = middleValue.data;
86
+ }
87
+ }
80
88
  if (middleValue.text != undefined) {
81
89
  if (middleValue.text.startsWith('/')) {
82
90
  starts = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webfast",
3
- "version": "0.1.49",
3
+ "version": "0.1.51",
4
4
  "description": "WebFast! Bot Application, including TON mini-apps for makign it easy and fast to build ini-apps",
5
5
  "main": "index.js",
6
6
  "repository": {
package/example.js DELETED
@@ -1,68 +0,0 @@
1
- const path = require(`path`);
2
- const contentPath = path.join(__dirname,`example`,`content`)
3
- let setArray = {
4
- wget : '/usr/local/bin/wget',
5
- process : {
6
- ts : Date.now(),
7
- socket : {
8
- api : {
9
- list : function(program,ws,json,data,path) {
10
- // Example to create process for websocket path action and process data
11
- console.log(`Example of list process`);
12
-
13
- function generateRandomText(length) {
14
- const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
15
- let result = '';
16
-
17
- for (let i = 0; i < length; i++) {
18
- result += characters.charAt(Math.floor(Math.random() * characters.length));
19
- }
20
-
21
- return result;
22
- }
23
-
24
-
25
- // Loop for example through
26
- let exampleData = {
27
- list : [],
28
- ell : data.ell,
29
- action : data.action
30
- }
31
-
32
- const pushData = {};
33
- for (let i in data.other.items) {
34
- const item = data.other.items[i];
35
- // We have itme
36
- const id = item.id;
37
- const key = item.name;
38
-
39
- pushData[key] = {
40
- id : id,
41
- text : generateRandomText(10)
42
- }
43
- }
44
-
45
- pushData.uuid = program.uuid.v4();
46
- exampleData.list.push(pushData);
47
-
48
- // Send websocket message create standard
49
- const sendObject = {
50
- func : data.function,
51
- data : exampleData,
52
- js : `console.log("RUN FROM BACKEND")`
53
- }
54
-
55
- // Sedn back to front-end
56
- //ws.send();
57
-
58
- return sendObject;
59
- }
60
- }
61
- }
62
- },
63
- contentPath : contentPath
64
- };
65
-
66
-
67
- let program = require(path.join(__dirname,`index.js`))(setArray);
68
- console.log(`Required`);