commit
This commit is contained in:
parent
be4fd23bcf
commit
0bd53741af
728 changed files with 86573 additions and 0 deletions
31
node_modules/telegraf/lib/scenes/wizard/context.js
generated
vendored
Normal file
31
node_modules/telegraf/lib/scenes/wizard/context.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class WizardContextWizard {
|
||||
constructor(ctx, steps) {
|
||||
var _a;
|
||||
this.ctx = ctx;
|
||||
this.steps = steps;
|
||||
this.state = ctx.scene.state;
|
||||
this.cursor = (_a = ctx.scene.session.cursor) !== null && _a !== void 0 ? _a : 0;
|
||||
}
|
||||
get step() {
|
||||
return this.steps[this.cursor];
|
||||
}
|
||||
get cursor() {
|
||||
return this.ctx.scene.session.cursor;
|
||||
}
|
||||
set cursor(cursor) {
|
||||
this.ctx.scene.session.cursor = cursor;
|
||||
}
|
||||
selectStep(index) {
|
||||
this.cursor = index;
|
||||
return this;
|
||||
}
|
||||
next() {
|
||||
return this.selectStep(this.cursor + 1);
|
||||
}
|
||||
back() {
|
||||
return this.selectStep(this.cursor - 1);
|
||||
}
|
||||
}
|
||||
exports.default = WizardContextWizard;
|
45
node_modules/telegraf/lib/scenes/wizard/index.js
generated
vendored
Normal file
45
node_modules/telegraf/lib/scenes/wizard/index.js
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.WizardScene = void 0;
|
||||
const base_1 = __importDefault(require("../base"));
|
||||
const context_1 = __importDefault(require("./context"));
|
||||
const composer_1 = __importDefault(require("../../composer"));
|
||||
class WizardScene extends base_1.default {
|
||||
constructor(id, options, ...steps) {
|
||||
let opts;
|
||||
let s;
|
||||
if (typeof options === 'function' || 'middleware' in options) {
|
||||
opts = undefined;
|
||||
s = [options, ...steps];
|
||||
}
|
||||
else {
|
||||
opts = options;
|
||||
s = steps;
|
||||
}
|
||||
super(id, opts);
|
||||
this.steps = s;
|
||||
}
|
||||
middleware() {
|
||||
return composer_1.default.compose([
|
||||
(ctx, next) => {
|
||||
ctx.wizard = new context_1.default(ctx, this.steps);
|
||||
return next();
|
||||
},
|
||||
super.middleware(),
|
||||
(ctx, next) => {
|
||||
if (ctx.wizard.step === undefined) {
|
||||
ctx.wizard.selectStep(0);
|
||||
return ctx.scene.leave();
|
||||
}
|
||||
return composer_1.default.unwrap(ctx.wizard.step)(ctx, next);
|
||||
},
|
||||
]);
|
||||
}
|
||||
enterMiddleware() {
|
||||
return composer_1.default.compose([this.enterHandler, this.middleware()]);
|
||||
}
|
||||
}
|
||||
exports.WizardScene = WizardScene;
|
Loading…
Add table
Add a link
Reference in a new issue