Guest User

Untitled

a guest
Nov 20th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. const bot = new Telegraf(TOKEN)
  2.  
  3. let db
  4.  
  5. MongoClient.connect(MONGO_URL)
  6. .then(_db => {
  7. db = _db
  8. })
  9. .then(() => {
  10. let session = new MongoSession(db)
  11.  
  12. session.setup().then(() => {
  13. bot.use(session.middleware)
  14.  
  15. bot.start(ctx => {
  16. ctx.session.orderState = { tags: {} }
  17. console.log(ctx.session)
  18. })
  19.  
  20. bot.on('callback_query', ctx => {
  21. switch(ctx.update.callback_query.data) {
  22. case '1000rub':
  23. ctx.session.orderState.provisionalSum = ctx.update.callback_query.data
  24. console.log(ctx.session)
  25. break
  26.  
  27. case 'nezni':
  28. ctx.session.orderState.hue = ctx.update.callback_query.data
  29. console.log(ctx.session)
  30. break
  31.  
  32. case 'leto':
  33. ctx.session.orderState.tags[ctx.update.callback_query.data] = ctx.update.callback_query.data
  34. console.log(ctx.session)
  35. break
  36. }
  37. })
  38.  
  39. bot.startPolling()
  40. })
  41. })
Add Comment
Please, Sign In to add comment