Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. 'use strict'
  2.  
  3. class MyUpdateFetcher {
  4. fetch () {
  5.  
  6. console.log('fetch')
  7. }
  8. }
  9.  
  10. const Telegram = require('telegram-node-bot')
  11. const TelegramBaseController = Telegram.TelegramBaseController
  12. const TextCommand = Telegram.TextCommand
  13. const RegexpCommand = Telegram.RegexpCommand
  14. const tg = new Telegram.Telegram('SECRET', {
  15. updateFetcher: new MyUpdateFetcher()
  16. })
  17.  
  18.  
  19.  
  20. class MainController extends TelegramBaseController {
  21.  
  22. testHandler($) {
  23. process.stdout.write('LOGGING!!!')
  24. console.log('LOGGING')
  25. console.log($)
  26.  
  27. $.sendMessage('test ok')
  28. }
  29.  
  30. noHandler($) {
  31. $.sendMessage('No!')
  32. }
  33.  
  34. get routes() {
  35. return {
  36. 'testCommand': 'testHandler',
  37. 'noCommand' : 'noHandler',
  38. }
  39. }
  40. }
  41.  
  42. tg.router
  43. .when(
  44. new TextCommand('test', 'testCommand'),
  45. new MainController()
  46. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement