How to use @vk-io/scenes - 2 common examples

To help you get started, we’ve selected a few @vk-io/scenes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github negezor / vk-io / docs / examples / scene-bot.js View on Github external
const { VK } = require('vk-io');

const { SessionManager } = require('@vk-io/session');
const { SceneManager, StepScene } = require('@vk-io/scenes');

const vk = new VK({
	token: process.env.TOKEN
});

const sessionManager = new SessionManager();
const sceneManager = new SceneManager();

sceneManager.addScene(new StepScene('signup', [
	(context) => {
		if (context.scene.step.firstTime || !context.text) {
			return context.send('What\'s your name?');
		}

		context.scene.state.firstName = context.text;

		return context.scene.step.next();
	},
	(context) => {
		if (context.scene.step.firstTime || !context.text) {
			return context.send('How old are you?');
		}
github negezor / vk-io / docs / examples / scene-bot.js View on Github external
const { VK } = require('vk-io');

const { SessionManager } = require('@vk-io/session');
const { SceneManager, StepScene } = require('@vk-io/scenes');

const vk = new VK({
	token: process.env.TOKEN
});

const sessionManager = new SessionManager();
const sceneManager = new SceneManager();

sceneManager.addScene(new StepScene('signup', [
	(context) => {
		if (context.scene.step.firstTime || !context.text) {
			return context.send('What\'s your name?');
		}

		context.scene.state.firstName = context.text;

		return context.scene.step.next();
	},
	(context) => {
		if (context.scene.step.firstTime || !context.text) {
			return context.send('How old are you?');
		}

		context.scene.state.age = Number(context.text);

@vk-io/scenes

Scenes for the library vk-io

MIT
Latest version published 1 year ago

Package Health Score

59 / 100
Full package analysis