telegram-botbuilder 1.0.8 → 1.0.9

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.
@@ -132,11 +132,17 @@ var BotBuilder = /** @class */ (function () {
132
132
  }); });
133
133
  this._bot.onText(/\/start/, function (msg) { return __awaiter(_this, void 0, void 0, function () {
134
134
  return __generator(this, function (_a) {
135
- if (!this._userdialogs[msg.chat.id])
136
- this._userdialogs[msg.chat.id] = { dialog: this._schema.start, lastid: -1, waiter: { statewait: false, descriptor: '' } };
137
- this._bot.deleteMessage(msg.chat.id, msg.message_id).catch(function () { return undefined; });
138
- this.ChangeDialog(msg.chat.id, this._schema.start);
139
- return [2 /*return*/];
135
+ switch (_a.label) {
136
+ case 0: return [4 /*yield*/, this._runmw(msg.chat.id, msg)];
137
+ case 1:
138
+ if (_a.sent())
139
+ return [2 /*return*/];
140
+ if (!this._userdialogs[msg.chat.id])
141
+ this._userdialogs[msg.chat.id] = { dialog: this._schema.start, lastid: -1, waiter: { statewait: false, descriptor: '' } };
142
+ this._bot.deleteMessage(msg.chat.id, msg.message_id).catch(function () { return undefined; });
143
+ this.ChangeDialog(msg.chat.id, this._schema.start);
144
+ return [2 /*return*/];
145
+ }
140
146
  });
141
147
  }); });
142
148
  var _loop_1 = function (cmd) {
@@ -144,29 +150,32 @@ var BotBuilder = /** @class */ (function () {
144
150
  var chat, _i, _a, act;
145
151
  return __generator(this, function (_b) {
146
152
  switch (_b.label) {
147
- case 0:
153
+ case 0: return [4 /*yield*/, this._runmw(msg.chat.id, msg)];
154
+ case 1:
155
+ if (_b.sent())
156
+ return [2 /*return*/];
148
157
  chat = msg.chat.id;
149
- if (!Array.isArray(cmd === null || cmd === void 0 ? void 0 : cmd.action)) return [3 /*break*/, 5];
158
+ if (!Array.isArray(cmd === null || cmd === void 0 ? void 0 : cmd.action)) return [3 /*break*/, 6];
150
159
  _i = 0, _a = cmd === null || cmd === void 0 ? void 0 : cmd.action;
151
- _b.label = 1;
152
- case 1:
153
- if (!(_i < _a.length)) return [3 /*break*/, 4];
160
+ _b.label = 2;
161
+ case 2:
162
+ if (!(_i < _a.length)) return [3 /*break*/, 5];
154
163
  act = _a[_i];
155
164
  return [4 /*yield*/, act(chat, this, match[1])];
156
- case 2:
157
- _b.sent();
158
- _b.label = 3;
159
165
  case 3:
166
+ _b.sent();
167
+ _b.label = 4;
168
+ case 4:
160
169
  _i++;
161
- return [3 /*break*/, 1];
162
- case 4: return [3 /*break*/, 7];
163
- case 5:
164
- if (!(cmd === null || cmd === void 0 ? void 0 : cmd.action)) return [3 /*break*/, 7];
165
- return [4 /*yield*/, (cmd === null || cmd === void 0 ? void 0 : cmd.action)(chat, this, match[1])];
170
+ return [3 /*break*/, 2];
171
+ case 5: return [3 /*break*/, 8];
166
172
  case 6:
173
+ if (!(cmd === null || cmd === void 0 ? void 0 : cmd.action)) return [3 /*break*/, 8];
174
+ return [4 /*yield*/, (cmd === null || cmd === void 0 ? void 0 : cmd.action)(chat, this, match[1])];
175
+ case 7:
167
176
  _b.sent();
168
- _b.label = 7;
169
- case 7: return [2 /*return*/];
177
+ _b.label = 8;
178
+ case 8: return [2 /*return*/];
170
179
  }
171
180
  });
172
181
  }); });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telegram-botbuilder",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "main": "lib/index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -84,6 +84,8 @@ export class BotBuilder {
84
84
  });
85
85
 
86
86
  this._bot.onText(/\/start/, async (msg) => {
87
+ if (await this._runmw(msg.chat.id, msg)) return;
88
+
87
89
  if (!this._userdialogs[msg.chat.id]) this._userdialogs[msg.chat.id] = {dialog: this._schema.start, lastid: -1, waiter: { statewait: false, descriptor: '' }}
88
90
  this._bot.deleteMessage(msg.chat.id, msg.message_id).catch(() => undefined);
89
91
  this.ChangeDialog(msg.chat.id, this._schema.start);
@@ -91,6 +93,8 @@ export class BotBuilder {
91
93
 
92
94
  for (let cmd of this._schema.commands) {
93
95
  this._bot.onText(new RegExp('\\/${cmd.text}(?:\\s+(.*))?$'), async (msg, match) => {
96
+ if (await this._runmw(msg.chat.id, msg)) return;
97
+
94
98
  let chat = msg.chat.id;
95
99
  if (Array.isArray(cmd?.action)) {
96
100
  for (let act of (cmd?.action as Action[])) {