node-telegram-bot-api
Advanced tools
Comparing version 0.23.0 to 0.23.1
@@ -67,31 +67,3 @@ 'use strict'; | ||
_this.options = options; | ||
_this.token = token; | ||
_this.textRegexpCallbacks = []; | ||
_this.onReplyToMessages = []; | ||
if (options.polling) { | ||
_this.initPolling(); | ||
} | ||
if (options.webHook) { | ||
_this._WebHook = new TelegramBotWebHook(token, options.webHook, _this.processUpdate); | ||
} | ||
return _this; | ||
} | ||
_createClass(TelegramBot, [{ | ||
key: 'initPolling', | ||
value: function initPolling() { | ||
if (this._polling) { | ||
this._polling.abort = true; | ||
this._polling.lastRequest.cancel('Polling restart'); | ||
} | ||
this._polling = new TelegramBotPolling(this.token, this.options.polling, this.processUpdate); | ||
} | ||
}, { | ||
key: 'processUpdate', | ||
value: function processUpdate(update) { | ||
var _this2 = this; | ||
_this.processUpdate = function (update) { | ||
debug('Process Update %j', update); | ||
@@ -105,7 +77,7 @@ var message = update.message; | ||
debug('Process Update message %j', message); | ||
this.emit('message', message); | ||
_this.emit('message', message); | ||
var processMessageType = function processMessageType(messageType) { | ||
if (message[messageType]) { | ||
debug('Emtting %s: %j', messageType, message); | ||
_this2.emit(messageType, message); | ||
_this.emit(messageType, message); | ||
} | ||
@@ -116,3 +88,3 @@ }; | ||
debug('Text message'); | ||
this.textRegexpCallbacks.forEach(function (reg) { | ||
_this.textRegexpCallbacks.forEach(function (reg) { | ||
debug('Matching %s whith', message.text, reg.regexp); | ||
@@ -128,3 +100,3 @@ var result = reg.regexp.exec(message.text); | ||
// Only callbacks waiting for this message | ||
this.onReplyToMessages.forEach(function (reply) { | ||
_this.onReplyToMessages.forEach(function (reply) { | ||
// Message from the same chat | ||
@@ -142,16 +114,41 @@ if (reply.chatId === message.chat.id) { | ||
debug('Process Update inline_query %j', inlineQuery); | ||
this.emit('inline_query', inlineQuery); | ||
_this.emit('inline_query', inlineQuery); | ||
} else if (chosenInlineResult) { | ||
debug('Process Update chosen_inline_result %j', chosenInlineResult); | ||
this.emit('chosen_inline_result', chosenInlineResult); | ||
_this.emit('chosen_inline_result', chosenInlineResult); | ||
} else if (callbackQuery) { | ||
debug('Process Update callback_query %j', callbackQuery); | ||
this.emit('callback_query', callbackQuery); | ||
_this.emit('callback_query', callbackQuery); | ||
} | ||
}; | ||
_this.options = options; | ||
_this.token = token; | ||
_this.textRegexpCallbacks = []; | ||
_this.onReplyToMessages = []; | ||
if (options.polling) { | ||
_this.initPolling(); | ||
} | ||
// used so that other funcs are not non-optimizable | ||
if (options.webHook) { | ||
_this._WebHook = new TelegramBotWebHook(token, options.webHook, _this.processUpdate); | ||
} | ||
return _this; | ||
} | ||
_createClass(TelegramBot, [{ | ||
key: 'initPolling', | ||
value: function initPolling() { | ||
if (this._polling) { | ||
this._polling.abort = true; | ||
this._polling.lastRequest.cancel('Polling restart'); | ||
} | ||
this._polling = new TelegramBotPolling(this.token, this.options.polling, this.processUpdate); | ||
} | ||
}, { | ||
key: '_safeParse', | ||
// used so that other funcs are not non-optimizable | ||
value: function _safeParse(json) { | ||
@@ -170,3 +167,3 @@ try { | ||
value: function _request(_path) { | ||
var _this3 = this; | ||
var _this2 = this; | ||
@@ -195,3 +192,3 @@ var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var data = _this3._safeParse(resp.body); | ||
var data = _this2._safeParse(resp.body); | ||
if (data.ok) { | ||
@@ -790,3 +787,3 @@ return data.result; | ||
value: function getFileLink(fileId) { | ||
var _this4 = this; | ||
var _this3 = this; | ||
@@ -797,3 +794,3 @@ return this.getFile(fileId).then(function (resp) { | ||
host: 'api.telegram.org', | ||
pathname: '/file/bot' + _this4.token + '/' + resp.file_path | ||
pathname: '/file/bot' + _this3.token + '/' + resp.file_path | ||
}); | ||
@@ -800,0 +797,0 @@ }); |
{ | ||
"name": "node-telegram-bot-api", | ||
"version": "0.23.0", | ||
"version": "0.23.1", | ||
"description": "Telegram Bot API", | ||
@@ -38,3 +38,3 @@ "main": "./lib/telegram.js", | ||
"babel-cli": "^6.6.5", | ||
"babel-eslint": "^5.0.0", | ||
"babel-eslint": "^6.0.4", | ||
"babel-plugin-transform-class-properties": "^6.6.0", | ||
@@ -51,3 +51,3 @@ "babel-plugin-transform-es2015-destructuring": "^6.6.5", | ||
"coveralls": "^2.11.8", | ||
"eslint": "^2.4.0", | ||
"eslint": "^2.11.1", | ||
"eslint-config-airbnb": "^6.1.0", | ||
@@ -54,0 +54,0 @@ "eslint-plugin-mocha": "^2.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
0
72980
929