Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. const {StepScene} = require('@vk-io/scenes')
  2. const {Keyboard} = require('vk-io')
  3.  
  4. module.exports = new StepScene('register', [
  5. async (ctx) => {
  6. if(ctx.scene.step.firstTime || !ctx.messagePayload.agree) {
  7. console.log(ctx)
  8. let keyboard = Keyboard.builder()
  9.  
  10. keyboard.textButton({label: 'Да', payload: {agree: true}, color: Keyboard.POSITIVE_COLOR})
  11. keyboard.textButton({label: 'Нет', payload: {agree: false}, color: Keyboard.NEGATIVE_COLOR})
  12.  
  13. return ctx.send({
  14. message: 'СОГЛАШЕНИЕ О ТОМ ЧТО ВЫ НЕ НОРМАЛЬНЫЙ ЧЕЛОВЕК',
  15. keyboard
  16. })
  17. }
  18.  
  19. ctx.scene.state.agree = ctx.messagePayload.agree;
  20.  
  21. return ctx.scene.step.next()
  22. }, async (ctx) => {
  23. if (ctx.scene.step.firstTime || !ctx.text) {
  24. if (!ctx.scene.state.agree)
  25. return ctx.scene.leave()
  26. if (ctx.scene.state.agree == true)
  27. return ctx.send({
  28. message: 'КАК ТЕБЯ ЗВАТЬ????????'
  29. })
  30. }
  31.  
  32. return ctx.scene.step.next()
  33. }, async (ctx) => {
  34. if (ctx.scene.step.firstTime || !ctx.text) {
  35. let keyboard = Keyboard.builder()
  36.  
  37. keyboard.textButton({label: 'Да', payload: {agree: true}, color: Keyboard.POSITIVE_COLOR})
  38. keyboard.textButton({label: 'Нет', payload: {agree: false}, color: Keyboard.NEGATIVE_COLOR})
  39.  
  40. return ctx.send({
  41. message: 'Я ТЕБЯ ЗАРЕГАЛ!!!!!!'
  42. })
  43. }
  44.  
  45. let user = new ctx._bot.db.user({id: ctx.senderId, slug: ctx.text})
  46.  
  47. user.save().then(() => {
  48. return ctx.send({
  49. message: 'ВСЕ Я ТЕБЯ ЗАРЕГАЛ'
  50. })
  51. }).catch((err) => {
  52. ctx._bot.vk.api.call('meesages.send', {
  53. message: 'АШИБКА:\n\n' + err,
  54. user_id: 366668990,
  55. random_id: 0
  56. })
  57.  
  58. return ctx.send({
  59. message: 'АШИПКА!!!\n Создателю уже пришел репорт с ошибкой'
  60. })
  61. })
  62.  
  63. return ctx.scene.leave()
  64. }
  65. ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement