UNPKG

vvlad1973-telegram-framework

Version:
51 lines (39 loc) 935 B
'use strict' import { BaseTelegramBot } from "./base_telegram_bot/base_telegram_bot.js"; export class TelegramBotEx extends BaseTelegramBot { #stack = []; needNext = false; constructor(...args) { super(...args); Object.defineProperties(this, { stack: { get: () => this.#stack }, }); } processUpdate(contents) { let self = this, needNext = true; function next() { needNext = true; } this.#stack.forEach(item => { if (needNext) { needNext = false; item.f(contents, item.options, next, self); } }) if (needNext) super.processUpdate(contents); } use(f, options) { this.#stack.push({f: f, options: options}); } unuse(f) { this.#stack.find(function (item, index, stack) { if (item.f === f) { stack.splice(index, 1); } }); } }