I
I
ItsDoome12021-06-12 20:32:13
Node.js
ItsDoome1, 2021-06-12 20:32:13

How to display nickname in node js (VK bot)?

I am writing a bot in VK using the node-vk-bot-api library. I'm making a checker.
I need to somehow put the message at the end (so far it’s not clear, I don’t know how to explain)

const VkBot = require('node-vk-bot-api');
const Session = require('C:/Users/igago/Desktop/newBotVk/node_modules/node-vk-bot-api/lib/session');
const Stage = require('C:/Users/igago/Desktop/newBotVk/node_modules/node-vk-bot-api/lib/stage');
const Scene = require('C:/Users/igago/Desktop/newBotVk/node_modules/node-vk-bot-api/lib/scene');

const bot = new VkBot('');
const session = new Session();
const scene = new Scene('check',
  (ctx) => {
    ctx.scene.next();
    ctx.reply('Введите ник');
  },
  (ctx) => {
  	ctx.session.name = ctx.message.text

    ctx.scene.next();
    ctx.reply('Подождите...');
  },
  (ctx) => {

    ctx.scene.leave();
    ctx.reply(`Проверка завершена.\nНик: ${ctx.session.name}`);
  });
const stage = new Stage(scene);

bot.use(session.middleware());
bot.use(stage.middleware());

bot.command('/check', (ctx) => {
  ctx.scene.enter('check');
});

bot.startPolling();

In general, at the end it is not displayed in a nickname. Help if you know how and if it's not difficult.60c4ef2ae2317797819982.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question