Advertisement
Guest User

bot vk js

a guest
Nov 16th, 2024
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. const { VK, Keyboard } = require('vk-io')
  2. const vk = new VK({ token: "скрыл" })
  3. const { HearManager } = require('@vk-io/hear')
  4. const { QuestionManager } = require('vk-io-question')
  5. const hearManager = new HearManager('<MessageContext>')
  6. const questionManager = new QuestionManager()
  7. vk.updates.use(questionManager.middleware)
  8. vk.updates.on('message_new', hearManager.middleware)
  9. const users = require('./users.json')
  10. const fs = require('fs')
  11.  
  12. const startKeyboard = Keyboard.keyboard([
  13. [
  14. Keyboard.textButton({
  15. label: `Сколько стоит поиграть?💸`,
  16. color: Keyboard.POSITIVE_COLOR
  17. }),
  18. Keyboard.textButton({
  19. label: `Какие компьютеры и девайсы?🔧`,
  20. color: Keyboard.POSITIVE_COLOR
  21. }),
  22. ],
  23. [
  24. Keyboard.textButton({
  25. label: `Где мы находимся?📍`,
  26. color: Keyboard.SECONDARY_COLOR
  27. }),
  28. Keyboard.textButton({
  29. label: `Еда и напитки🌭`,
  30. color: Keyboard.SECONDARY_COLOR
  31. })
  32. ],
  33. [
  34. Keyboard.textButton({
  35. label: `Акции🎁`,
  36. color: Keyboard.SECONDARY_COLOR
  37. }),
  38. ],
  39. [
  40. Keyboard.textButton({
  41. label: `Какие есть игры?🎮`,
  42. color: Keyboard.SECONDARY_COLOR
  43. }),
  44. Keyboard.textButton({
  45. label: `Будут ли турниры?🏆`,
  46. color: Keyboard.SECONDARY_COLOR
  47. }),
  48. ],
  49. [
  50. Keyboard.textButton({
  51. label: `Правила посещения📋`,
  52. color: Keyboard.PRIMARY_COLOR
  53. }),
  54. ],
  55. [
  56. Keyboard.textButton({
  57. label: `Позвать админа📞`,
  58. color: Keyboard.SECONDARY_COLOR
  59. }),
  60. Keyboard.textButton({
  61. label: `Оставить отзыв✍`,
  62. color: Keyboard.NEGATIVE_COLOR
  63. }),
  64. ]
  65. ])
  66.  
  67. hearManager.hear(/^a|б|в|г|д|е|о|с|м|1|2|3|н/i, async(next, context) => {
  68. const user = users.filter(x => x.id === next.senderId)[0]
  69. if(next.senderId < 0) return;
  70. if(user) return context()
  71.  
  72. const [user_info] = await vk.api.users.get({user_id: next.senderId, fields: "sex"})
  73. users.push({
  74. id: next.senderId,
  75. firstName: user_info.first_name,
  76. lastName: user_info.last_name,
  77. gender: user_info.sex,
  78. });
  79. return context();
  80. })
  81.  
  82. hearManager.hear(/^Начать/i, async(context) => {
  83. context.send({message: `Здравствуйте, это компьютерный клуб CodeX.\nВыберите интересующую кнопку или сразу позовите админа😊`, keyboard: startKeyboard })
  84. })
  85.  
  86. hearManager.hear(/^Сколько стоит поиграть?💸/i, async (context) => {
  87. context.send({ message: `Наш прайс`, keyboard: startKeyboard })
  88. })
  89.  
  90. setInterval(async() => {
  91. fs.writeFileSync("./users.json", JSON.stringify(users, null, "\t"))
  92. }, 1000);
  93.  
  94. vk.updates.start();
  95. console.log(`>_Все процессы успешно запущены!`)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement