X
X
xxmarfixxx2020-10-03 21:03:16
API
xxmarfixxx, 2020-10-03 21:03:16

How to make a dialogue in a chat bot for VK?

Greetings. I am writing a chat bot for VKontakte using Node.JS, using the VK-IO library.
There is an array table. It contains data on lessons at the Moscow Electronic School (MES).
Teachers add their lessons to the array via the "add" command. The command syntax is:
add [Lesson ID] [Lesson Name] [Subject] [Codeword].
The command code is:

cmd.hear(/^(?:добавить)\s?([0-9]+)?\s([^]+)?\s([^]+)?\s([^]+)?/i, async (message, args, bot) => {
if(message.user.adm < 3) return;
tabl.push(
{
  id: `${message.args[1]}`,
  name: `${message.args[2]}`,
  predmet: `${message.args[3]}`,
  kod1: `${message.args[4]}`,
  uid: tablcount
  });
tablcount = tablcount + 1
saveConfig();
await message.send(`Вы успешно добавили урок в Библиотеку уроков бота.\n Посмотреть его можно по команде: "мэш [кодовое слово]".`);
});

With the command "add 691326 Filesystem Computer Science File", the array takes on the value:
[
  {
    "id": "691326",
    "name": "Файловая_система",
    "predmet": "Информатика",
    "kod1": "Файл",
    "uid": 0
  }
]

The "uid" parameter is the ordinal ID of the lesson in the array.
The problem is that each parameter can only be one word. And I need to have several code words, or even phrases.
Recently I saw somewhere on the Internet a thing called "chain".
The point is that the Bot sends a message and waits for a response; writes response #1, sends the next message, and waits for a response again. Such a chain can continue indefinitely, but I need it to repeat 5 times. Can you suggest how to do it?

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