diff --git a/lib/telegram.link.js b/lib/telegram.link.js index a9e3b38..fb71138 100644 --- a/lib/telegram.link.js +++ b/lib/telegram.link.js @@ -307,6 +307,42 @@ Client.prototype.startHttpPollLoop = function (callback, maxWait, waitAfter, max Client.prototype.stopHttpPollLoop = function () { this._httpPollLoop = false; }; + + +// *** +// client.**registerOnUpdates(callback)** + +// Register the function and call back on any update events. + +// The code: +Client.prototype.registerOnUpdates = function (callback) { + var emitter = this._channel.getParser(); + emitter.on('api.type.UpdatesTooLong', callback); + emitter.on('api.type.UpdateShortMessage', callback); + emitter.on('api.type.UpdateShortChatMessage', callback); + emitter.on('api.type.UpdateShort', callback); + emitter.on('api.type.UpdatesCombined', callback); + emitter.on('api.type.Updates', callback); +}; + +// *** +// client.**unregisterOnUpdates(callback)** + +// Un-register from the update events. + +// The code: +Client.prototype.unregisterOnUpdates = function (callback) { + var emitter = this._channel.getParser(); + emitter.removeListener('api.type.UpdatesTooLong', callback); + emitter.removeListener('api.type.UpdateShortMessage', callback); + emitter.removeListener('api.type.UpdateShortChatMessage', callback); + emitter.removeListener('api.type.UpdateShort', callback); + emitter.removeListener('api.type.UpdatesCombined', callback); + emitter.removeListener('api.type.Updates', callback); +}; + + +// *** // client.**isReady()** // Checks if the client is ready to communicate with Telegram and immediately emits the error-event if required. diff --git a/package.json b/package.json index 0e200d4..1f53976 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "telegram.link", - "version": "0.6.1", + "version": "0.6.2", "description": "Telegram API library", "keywords": [ "telegram",