Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { VK, Keyboard } = require('vk-io')
- const vk = new VK({ token: "скрыл" })
- const { HearManager } = require('@vk-io/hear')
- const { QuestionManager } = require('vk-io-question')
- const hearManager = new HearManager('<MessageContext>')
- const questionManager = new QuestionManager()
- vk.updates.use(questionManager.middleware)
- vk.updates.on('message_new', hearManager.middleware)
- const users = require('./users.json')
- const fs = require('fs')
- const startKeyboard = Keyboard.keyboard([
- [
- Keyboard.textButton({
- label: `Сколько стоит поиграть?💸`,
- color: Keyboard.POSITIVE_COLOR
- }),
- Keyboard.textButton({
- label: `Какие компьютеры и девайсы?🔧`,
- color: Keyboard.POSITIVE_COLOR
- }),
- ],
- [
- Keyboard.textButton({
- label: `Где мы находимся?📍`,
- color: Keyboard.SECONDARY_COLOR
- }),
- Keyboard.textButton({
- label: `Еда и напитки🌭`,
- color: Keyboard.SECONDARY_COLOR
- })
- ],
- [
- Keyboard.textButton({
- label: `Акции🎁`,
- color: Keyboard.SECONDARY_COLOR
- }),
- ],
- [
- Keyboard.textButton({
- label: `Какие есть игры?🎮`,
- color: Keyboard.SECONDARY_COLOR
- }),
- Keyboard.textButton({
- label: `Будут ли турниры?🏆`,
- color: Keyboard.SECONDARY_COLOR
- }),
- ],
- [
- Keyboard.textButton({
- label: `Правила посещения📋`,
- color: Keyboard.PRIMARY_COLOR
- }),
- ],
- [
- Keyboard.textButton({
- label: `Позвать админа📞`,
- color: Keyboard.SECONDARY_COLOR
- }),
- Keyboard.textButton({
- label: `Оставить отзыв✍`,
- color: Keyboard.NEGATIVE_COLOR
- }),
- ]
- ])
- hearManager.hear(/^a|б|в|г|д|е|о|с|м|1|2|3|н/i, async(next, context) => {
- const user = users.filter(x => x.id === next.senderId)[0]
- if(next.senderId < 0) return;
- if(user) return context()
- const [user_info] = await vk.api.users.get({user_id: next.senderId, fields: "sex"})
- users.push({
- id: next.senderId,
- firstName: user_info.first_name,
- lastName: user_info.last_name,
- gender: user_info.sex,
- });
- return context();
- })
- hearManager.hear(/^Начать/i, async(context) => {
- context.send({message: `Здравствуйте, это компьютерный клуб CodeX.\nВыберите интересующую кнопку или сразу позовите админа😊`, keyboard: startKeyboard })
- })
- hearManager.hear(/^Сколько стоит поиграть?💸/i, async (context) => {
- context.send({ message: `Наш прайс`, keyboard: startKeyboard })
- })
- setInterval(async() => {
- fs.writeFileSync("./users.json", JSON.stringify(users, null, "\t"))
- }, 1000);
- vk.updates.start();
- console.log(`>_Все процессы успешно запущены!`)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement