telegram-botbuilder 1.1.4 → 1.1.6

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.
@@ -6,7 +6,7 @@ export interface ActionCallback {
6
6
  chatid: number;
7
7
  }
8
8
  export declare class BotBuilder {
9
- private _bot;
9
+ _bot: TelegramBot;
10
10
  private _schema;
11
11
  ActionSystem: EventEmitter;
12
12
  private _userdialogs;
@@ -399,13 +399,30 @@ function CallbackAction(descriptor) {
399
399
  function WaitForData(descriptor) {
400
400
  var _this = this;
401
401
  return function (chat, _bot) { return __awaiter(_this, void 0, void 0, function () {
402
- var desc_1;
402
+ var _tmpds_1, desc_1;
403
403
  return __generator(this, function (_a) {
404
404
  if (typeof descriptor == 'string') {
405
- _bot.AttachDataWait(chat, descriptor);
405
+ _tmpds_1 = crypto.randomUUID();
406
+ _bot.AttachDataWait(chat, _tmpds_1);
406
407
  return [2 /*return*/, new Promise(function (r) {
407
- _bot.ActionSystem.once(descriptor, r);
408
- _bot.ActionSystem.once("cancel_".concat(descriptor), r);
408
+ _bot.ActionSystem.once(_tmpds_1, function () {
409
+ var _a;
410
+ var args = [];
411
+ for (var _i = 0; _i < arguments.length; _i++) {
412
+ args[_i] = arguments[_i];
413
+ }
414
+ (_a = _bot.ActionSystem).emit.apply(_a, __spreadArray([descriptor], args, false));
415
+ return r(undefined);
416
+ });
417
+ _bot.ActionSystem.once("cancel_".concat(_tmpds_1), function () {
418
+ var _a;
419
+ var args = [];
420
+ for (var _i = 0; _i < arguments.length; _i++) {
421
+ args[_i] = arguments[_i];
422
+ }
423
+ (_a = _bot.ActionSystem).emit.apply(_a, __spreadArray(["cancel_".concat(descriptor)], args, false));
424
+ return r(undefined);
425
+ });
409
426
  })];
410
427
  }
411
428
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telegram-botbuilder",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "main": "lib/index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -18,7 +18,7 @@ export interface ActionCallback {
18
18
  }
19
19
 
20
20
  export class BotBuilder {
21
- private _bot: TelegramBot;
21
+ public _bot: TelegramBot;
22
22
  private _schema: BotSchema;
23
23
  public ActionSystem: EventEmitter;
24
24
  private _userdialogs: UserDialog;
@@ -196,10 +196,11 @@ export function CallbackAction(descriptor: string | CallbackActionFunc, ...args:
196
196
  export function WaitForData(descriptor: string | CallbackActionFunc): Action {
197
197
  return async (chat: number, _bot: BotBuilder) => {
198
198
  if (typeof descriptor == 'string') {
199
- _bot.AttachDataWait(chat, descriptor);
199
+ let _tmpds = crypto.randomUUID();
200
+ _bot.AttachDataWait(chat, _tmpds);
200
201
  return new Promise(r => {
201
- _bot.ActionSystem.once(descriptor, r);
202
- _bot.ActionSystem.once(`cancel_${descriptor}`, r);
202
+ _bot.ActionSystem.once(_tmpds, (...args: any[]) => {_bot.ActionSystem.emit(descriptor, ...args); return r(undefined)});
203
+ _bot.ActionSystem.once(`cancel_${_tmpds}`, (...args: any[]) => {_bot.ActionSystem.emit(`cancel_${descriptor}`, ...args); return r(undefined)});
203
204
  });
204
205
  } else {
205
206
  let desc = crypto.randomUUID();