Guest User

Untitled

a guest
Oct 4th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. 'use strict'
  2.  
  3. const BaseCommand = require('./BaseCommand')
  4.  
  5. class ParamCommand extends BaseCommand {
  6.  
  7. /**
  8. *
  9. * @param {string} textPattern
  10. * @param {string} [handler]
  11. * @param {Array} ...arguments the arguments passed to parameter
  12. */
  13. constructor(textPattern, handler, ...parameters) {
  14. super()
  15.  
  16. this._regexp = new RegExp()
  17. this._handler = handler
  18. this._param = parameters
  19. }
  20.  
  21. /**
  22. * @param {Scope} scope
  23. * @returns {boolean}
  24. */
  25. test(scope) {
  26. return scope.message.text &&
  27. scope.message.text.indexOf(this._textPattern) > -1
  28. }
  29.  
  30. /**
  31. * @returns {string}
  32. */
  33. get handlerName() {
  34. return this._handler
  35. }
  36.  
  37. }
  38.  
  39. module.exports = ParamCommand
Advertisement
Add Comment
Please, Sign In to add comment