2015-06-28 22:42:48 +00:00
'use strict' ;
2016-03-27 20:29:00 +00:00
Object . defineProperty ( exports , "__esModule" , {
2015-06-28 22:42:48 +00:00
value : true
} ) ;
2016-03-27 20:29:00 +00:00
var _createClass = function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ;
2015-06-28 22:42:48 +00:00
2016-03-27 20:29:00 +00:00
var _Base2 = require ( './Base' ) ;
2015-06-28 22:42:48 +00:00
2016-03-27 20:29:00 +00:00
var _Base3 = _interopRequireDefault ( _Base2 ) ;
2015-06-28 22:42:48 +00:00
2016-03-27 20:29:00 +00:00
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
2015-06-28 22:42:48 +00:00
2016-03-27 20:29:00 +00:00
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
2015-06-28 22:42:48 +00:00
2016-03-27 20:29:00 +00:00
function _possibleConstructorReturn ( self , call ) { if ( ! self ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return call && ( typeof call === "object" || typeof call === "function" ) ? call : self ; }
2015-06-28 22:42:48 +00:00
2016-03-27 20:29:00 +00:00
function _inherits ( subClass , superClass ) { if ( typeof superClass !== "function" && superClass !== null ) { throw new TypeError ( "Super expression must either be null or a function, not " + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . _ _proto _ _ = superClass ; }
2015-06-28 22:42:48 +00:00
/ * *
* Message class , used to send message to a chat
* /
2016-03-27 20:29:00 +00:00
var Message = function ( _Base ) {
_inherits ( Message , _Base ) ;
2015-06-28 22:42:48 +00:00
/ * *
* Create a new message
* @ param { object } properties Message properties , as defined by Telegram API
* /
function Message ( ) {
2016-03-27 20:29:00 +00:00
var properties = arguments . length <= 0 || arguments [ 0 ] === undefined ? { } : arguments [ 0 ] ;
2015-06-28 22:42:48 +00:00
_classCallCheck ( this , Message ) ;
2016-03-27 20:29:00 +00:00
var _this = _possibleConstructorReturn ( this , Object . getPrototypeOf ( Message ) . call ( this , 'sendMessage' ) ) ;
2015-06-28 22:42:48 +00:00
2016-03-27 20:29:00 +00:00
_this . properties = properties ;
_this . _keyboard = new _Base3 . default ( ) ;
return _this ;
2015-06-28 22:42:48 +00:00
}
2016-03-27 20:29:00 +00:00
/ * *
* Set chat _id of the message
* @ param { number } chat
* @ return { object } returns the message object
* /
2015-06-28 22:42:48 +00:00
_createClass ( Message , [ {
key : 'to' ,
value : function to ( chat ) {
this . properties . chat _id = chat ;
return this ;
}
/ * *
* Set text of the message
* @ param { string } text Message ' s content
* @ return { object } returns the message object
* /
2016-03-27 20:29:00 +00:00
} , {
key : 'text' ,
2015-06-28 22:42:48 +00:00
value : function text ( _text ) {
this . properties . text = _text ;
return this ;
}
2016-03-27 20:29:00 +00:00
/ * *
* Set text of the message in HTML format
* @ param { string } text Message ' s content in HTML format
* @ return { object } returns the message object
* /
} , {
key : 'html' ,
value : function html ( text ) {
this . properties . parse _mode = 'HTML' ;
if ( text ) {
this . properties . text = text ;
}
return this ;
}
/ * *
* Set text of the message in Markdown format
* @ param { string } text Message ' s content in Markdown format
* @ return { object } returns the message object
* /
2015-06-28 22:42:48 +00:00
} , {
2016-03-27 20:29:00 +00:00
key : 'markdown' ,
value : function markdown ( text ) {
this . properties . parse _mode = 'Markdown' ;
if ( text ) {
this . properties . text = text ;
}
return this ;
}
2015-06-28 22:42:48 +00:00
/ * *
* Set reply _to _message _id of the message
* @ param { number } id message _id of the message to reply to
* @ return { object } returns the message object
* /
2016-03-27 20:29:00 +00:00
} , {
key : 'reply' ,
2015-06-28 22:42:48 +00:00
value : function reply ( id ) {
this . properties . reply _to _message _id = id ;
return this ;
}
2015-07-03 15:07:40 +00:00
/ * *
* Set disable _web _page _preview of the message
* @ param { boolean } enable
* @ return { object } returns the message object
* /
2016-03-27 20:29:00 +00:00
} , {
key : 'preview' ,
2015-07-03 15:07:40 +00:00
value : function preview ( ) {
2016-03-27 20:29:00 +00:00
var enable = arguments . length <= 0 || arguments [ 0 ] === undefined ? true : arguments [ 0 ] ;
2015-07-03 15:07:40 +00:00
this . properties . disable _web _page _preview = ! enable ;
return this ;
}
2015-06-28 22:42:48 +00:00
/ * *
* Sets keyboard of the message
* The value of reply _markup is set to the sanitized keyboard properties
* i . e . reply _markup = JSON . stringify ( kb . getProperties ( ) )
* @ param { object } kb A Keyboard instance
* @ return { object } returns the message object
* /
2016-03-27 20:29:00 +00:00
} , {
key : 'keyboard' ,
2015-06-28 22:42:48 +00:00
value : function keyboard ( kb ) {
this . _keyboard = kb ;
return this ;
}
2015-06-30 22:04:44 +00:00
// This class inherits Base's send method
2015-06-28 22:42:48 +00:00
} ] ) ;
return Message ;
2016-03-27 20:29:00 +00:00
} ( _Base3 . default ) ;
2015-06-28 22:42:48 +00:00
2016-03-27 20:29:00 +00:00
exports . default = Message ;
2015-06-28 22:42:48 +00:00
module . exports = exports [ 'default' ] ;