telegram-botbuilder 1.0.13 → 1.0.15

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.
@@ -133,12 +133,17 @@ var BotBuilder = /** @class */ (function () {
133
133
  }); });
134
134
  this._bot.onText(/\/start/, function (msg) { return __awaiter(_this, void 0, void 0, function () {
135
135
  return __generator(this, function (_a) {
136
- //if (await this._runmw(msg.chat.id, msg)) return;
137
- if (!this._userdialogs[msg.chat.id])
138
- this._userdialogs[msg.chat.id] = { dialog: this._schema.start, lastid: -1, waiter: { statewait: false, descriptor: '' } };
139
- this._bot.deleteMessage(msg.chat.id, msg.message_id).catch(function () { return undefined; });
140
- this.ChangeDialog(msg.chat.id, this._schema.start);
141
- return [2 /*return*/];
136
+ switch (_a.label) {
137
+ case 0: return [4 /*yield*/, this._runmw(msg.chat.id, msg)];
138
+ case 1:
139
+ if (_a.sent())
140
+ return [2 /*return*/];
141
+ if (!this._userdialogs[msg.chat.id])
142
+ this._userdialogs[msg.chat.id] = { dialog: this._schema.start, lastid: -1, waiter: { statewait: false, descriptor: '' } };
143
+ this._bot.deleteMessage(msg.chat.id, msg.message_id).catch(function () { return undefined; });
144
+ this.ChangeDialog(msg.chat.id, this._schema.start);
145
+ return [2 /*return*/];
146
+ }
142
147
  });
143
148
  }); });
144
149
  var _loop_1 = function (cmd) {
@@ -146,29 +151,32 @@ var BotBuilder = /** @class */ (function () {
146
151
  var chat, _i, _a, act;
147
152
  return __generator(this, function (_b) {
148
153
  switch (_b.label) {
149
- case 0:
154
+ case 0: return [4 /*yield*/, this._runmw(msg.chat.id, msg)];
155
+ case 1:
156
+ if (_b.sent())
157
+ return [2 /*return*/];
150
158
  chat = msg.chat.id;
151
- if (!Array.isArray(cmd === null || cmd === void 0 ? void 0 : cmd.action)) return [3 /*break*/, 5];
159
+ if (!Array.isArray(cmd === null || cmd === void 0 ? void 0 : cmd.action)) return [3 /*break*/, 6];
152
160
  _i = 0, _a = cmd === null || cmd === void 0 ? void 0 : cmd.action;
153
- _b.label = 1;
154
- case 1:
155
- if (!(_i < _a.length)) return [3 /*break*/, 4];
161
+ _b.label = 2;
162
+ case 2:
163
+ if (!(_i < _a.length)) return [3 /*break*/, 5];
156
164
  act = _a[_i];
157
165
  return [4 /*yield*/, act(chat, this, match[1])];
158
- case 2:
159
- _b.sent();
160
- _b.label = 3;
161
166
  case 3:
167
+ _b.sent();
168
+ _b.label = 4;
169
+ case 4:
162
170
  _i++;
163
- return [3 /*break*/, 1];
164
- case 4: return [3 /*break*/, 7];
165
- case 5:
166
- if (!(cmd === null || cmd === void 0 ? void 0 : cmd.action)) return [3 /*break*/, 7];
167
- return [4 /*yield*/, (cmd === null || cmd === void 0 ? void 0 : cmd.action)(chat, this, match[1])];
171
+ return [3 /*break*/, 2];
172
+ case 5: return [3 /*break*/, 8];
168
173
  case 6:
174
+ if (!(cmd === null || cmd === void 0 ? void 0 : cmd.action)) return [3 /*break*/, 8];
175
+ return [4 /*yield*/, (cmd === null || cmd === void 0 ? void 0 : cmd.action)(chat, this, match[1])];
176
+ case 7:
169
177
  _b.sent();
170
- _b.label = 7;
171
- case 7: return [2 /*return*/];
178
+ _b.label = 8;
179
+ case 8: return [2 /*return*/];
172
180
  }
173
181
  });
174
182
  }); });
@@ -198,7 +206,7 @@ var BotBuilder = /** @class */ (function () {
198
206
  mwb = this._mwbreak[desc];
199
207
  if (typeof mwb === 'boolean')
200
208
  return [2 /*return*/, mwb];
201
- if (!(typeof mwb === 'object')) return [3 /*break*/, 2];
209
+ if (!(mwb === null)) return [3 /*break*/, 2];
202
210
  return [4 /*yield*/, this._mwba(desc)];
203
211
  case 1: return [2 /*return*/, _c.sent()];
204
212
  case 2:
@@ -223,7 +231,7 @@ var BotBuilder = /** @class */ (function () {
223
231
  return [3 /*break*/, 3];
224
232
  case 7:
225
233
  this._mwbreak[desc] = res;
226
- this.ActionSystem.emit("mwb_".concat(desc));
234
+ this.ActionSystem.emit("mwb_".concat(desc), res);
227
235
  return [2 /*return*/, res];
228
236
  }
229
237
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telegram-botbuilder",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "main": "lib/index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -38,7 +38,7 @@ export class BotBuilder {
38
38
  let desc = `${chat}_${(msg as TelegramBot.Message).message_id || (msg as TelegramBot.CallbackQuery).id}`;
39
39
  let mwb = this._mwbreak[desc];
40
40
  if (typeof mwb === 'boolean') return mwb;
41
- if (typeof mwb === 'object') return await this._mwba(desc);
41
+ if (mwb === null) return await this._mwba(desc);
42
42
  this._mwbreak[desc] = null;
43
43
 
44
44
  let res = false;
@@ -46,7 +46,7 @@ export class BotBuilder {
46
46
  res = res || await mw(chat, msg);
47
47
  }
48
48
  this._mwbreak[desc] = res;
49
- this.ActionSystem.emit(`mwb_${desc}`);
49
+ this.ActionSystem.emit(`mwb_${desc}`, res);
50
50
  return res;
51
51
  }
52
52
 
@@ -101,7 +101,7 @@ export class BotBuilder {
101
101
  });
102
102
 
103
103
  this._bot.onText(/\/start/, async (msg) => {
104
- //if (await this._runmw(msg.chat.id, msg)) return;
104
+ if (await this._runmw(msg.chat.id, msg)) return;
105
105
 
106
106
  if (!this._userdialogs[msg.chat.id]) this._userdialogs[msg.chat.id] = {dialog: this._schema.start, lastid: -1, waiter: { statewait: false, descriptor: '' }}
107
107
  this._bot.deleteMessage(msg.chat.id, msg.message_id).catch(() => undefined);
@@ -110,7 +110,7 @@ export class BotBuilder {
110
110
 
111
111
  for (let cmd of this._schema.commands) {
112
112
  this._bot.onText(new RegExp(`\\/${cmd.text}(?:\\s+(.*))?$`), async (msg, match) => {
113
- //if (await this._runmw(msg.chat.id, msg)) return;
113
+ if (await this._runmw(msg.chat.id, msg)) return;
114
114
 
115
115
  let chat = msg.chat.id;
116
116
  if (Array.isArray(cmd?.action)) {