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