diff --git a/doc/updates.html b/doc/api/account.html similarity index 78% rename from doc/updates.html rename to doc/api/account.html index 81fbdc1..b06a1da 100644 --- a/doc/updates.html +++ b/doc/api/account.html @@ -2,10 +2,10 @@ - updates.js + account.js - +
@@ -15,7 +15,7 @@
  • -

    updates.js

    +

    account.js

  • @@ -47,8 +47,8 @@

    updates.js

    -
    var api = require('./api');
    -var utility = require('./utility');
    +
    var api = require('../api');
    +var utility = require('../utility');
    @@ -72,7 +72,7 @@

    updates.js

    -

    This module wraps API methods required to manage the session updates

    +

    This module wraps API methods required to manage notifications and settings

    @@ -85,7 +85,7 @@

    updates.js

    -

    See Api Methods

    +

    See Api Methods

    @@ -98,12 +98,12 @@

    updates.js

    -

    Access only via Client object and updates instance property

    +

    Access only via Client object and account instance property

    -function Updates(client) {
    +function Account(client) {
         this.client = client;
     }
    @@ -156,7 +156,7 @@

    updates.js


    -

    updates.getState([callback])

    +

    account.updateStatus(offline, [callback])

    @@ -169,7 +169,7 @@

    updates.js

    -

    Returns a Promise for get the current state of updates.

    +

    Return a Promise to update the online user status..

    @@ -182,7 +182,7 @@

    updates.js

    -

    Click here for more details

    +

    Click here for more details

    @@ -199,8 +199,12 @@

    updates.js

    -
    Updates.prototype.getState = function (callback) {
    -    return utility.callService(api.service.updates.getState, this.client, this.client._channel, callback, arguments);
    +            
    Account.prototype.updateStatus = function (offline, callback) {
    +
    +    offline = offline === false ? new api.type.BoolFalse() :
    +        ( offline === true ? new api.type.BoolTrue() : offline);
    +
    +    return utility.callService(api.service.account.updateStatus, this.client, this.client._channel, callback, arguments);
     };
    @@ -216,7 +220,7 @@

    updates.js

    -
    module.exports = exports = Updates;
    +
    module.exports = exports = Account;
    diff --git a/doc/auth.html b/doc/api/auth.html similarity index 95% rename from doc/auth.html rename to doc/api/auth.html index 9c907ad..0f9bbd1 100644 --- a/doc/auth.html +++ b/doc/api/auth.html @@ -5,7 +5,7 @@ auth.js - +
    @@ -47,8 +47,8 @@

    auth.js

    -
    var api = require('./api');
    -var utility = require('./utility');
    +
    var api = require('../api');
    +var utility = require('../utility');
    @@ -170,7 +170,7 @@

    auth.js

    -

    Sends a text message with the confirmation code required for registration to the given phone number.

    +

    Send a text message with the confirmation code required for registration to the given phone number.

    @@ -247,8 +247,8 @@

    auth.js

    -

    Makes a voice call to the passed phone number. A robot will repeat the confirmation code from a previously sent SMS message. -Returns a Promise.

    +

    Return a Promise to make a voice call to the passed phone number. +A robot will repeat the confirmation code from a previously sent SMS message.

    @@ -305,8 +305,7 @@

    auth.js

    -

    Signs in a user with a validated phone number. -Returns a Promise.

    +

    Return a Promise to sign in a user with a validated phone number.

    @@ -363,8 +362,7 @@

    auth.js

    -

    Registers a validated phone number in the system. -Returns a Promise.

    +

    Return a Promise to register a validated phone number in the system.

    @@ -421,7 +419,7 @@

    auth.js

    -

    Returns a Promise for get the information on whether the passed phone number was registered.

    +

    Return a Promise to get the information on whether the passed phone number was registered.

    @@ -464,7 +462,7 @@

    auth.js

    -

    Exports the class.

    +

    Export the class.

    diff --git a/doc/contacts.html b/doc/api/contacts.html similarity index 95% rename from doc/contacts.html rename to doc/api/contacts.html index 2d6b09f..d7be614 100644 --- a/doc/contacts.html +++ b/doc/api/contacts.html @@ -5,7 +5,7 @@ contacts.js - +
    @@ -47,8 +47,8 @@

    contacts.js

    -
    var api = require('./api');
    -var utility = require('./utility');
    +
    var api = require('../api');
    +var utility = require('../utility');
    @@ -169,7 +169,7 @@

    contacts.js

    -

    Returns a Promise for get the current user’s contact list.

    +

    Return a Promise to get the current user’s contact list.

    @@ -212,7 +212,7 @@

    contacts.js

    -

    Exports the class

    +

    Export the class

    diff --git a/doc/messages.html b/doc/api/messages.html similarity index 83% rename from doc/messages.html rename to doc/api/messages.html index 6e1bd52..2215dbb 100644 --- a/doc/messages.html +++ b/doc/api/messages.html @@ -5,7 +5,7 @@ messages.js - +
    @@ -47,8 +47,8 @@

    messages.js

    -
    var api = require('./api');
    -var utility = require('./utility');
    +
    var api = require('../api');
    +var utility = require('../utility');
    @@ -169,7 +169,7 @@

    messages.js

    -

    Returns a Promise for get the current user dialog list.

    +

    Return a Promise to get the current user dialog list.

    @@ -226,7 +226,7 @@

    messages.js

    -

    Returns a Promise for get the message history for a chat.

    +

    Return a Promise to get the message history for a chat.

    @@ -312,7 +312,7 @@

    messages.js


    -

    messages.sendMessage(peer, message, random_id, [callback])

    +

    messages.readHistory(peer, max_id, offset, read_contents, [callback])

    @@ -325,7 +325,7 @@

    messages.js

    -

    Returns a Promise for get the message history for a chat.

    +

    Return a Promise to mark the message history as read..

    @@ -338,7 +338,7 @@

    messages.js

    -

    Click here for more details

    +

    Click here for more details

    @@ -351,10 +351,18 @@

    messages.js

    -

    Usage example (user_id must be a real contact id, of course):

    +

    The code:

    +
    Messages.prototype.readHistory = function (peer, max_id, offset, read_contents, callback) {
    +
    +    read_contents = read_contents === false ? new api.type.BoolFalse() :
    +        ( read_contents === true ? new api.type.BoolTrue() : read_contents);
    +
    +    return utility.callService(api.service.messages.readHistory, this.client, this.client._channel, callback, arguments);
    +};
    + @@ -364,6 +372,59 @@

    messages.js

    +
    +

    messages.sendMessage(peer, message, random_id, [callback])

    + + + + + + +
  • +
    + +
    + +
    +

    Return a Promise to send a message to the peer.

    + +
    + +
  • + + +
  • +
    + +
    + +
    +

    Click here for more details

    + +
    + +
  • + + +
  • +
    + +
    + +
    +

    Usage example (user_id must be a real contact id, of course):

    + +
    + +
  • + + +
  • +
    + +
    + +
     var api = require('telegram.link')();
     
      var client = api.createClient( ...
    @@ -387,11 +448,11 @@ 

    messages.js

  • -
  • +
  • - +

    The code:

    @@ -404,13 +465,13 @@

    messages.js

  • -
  • +
  • - +
    -

    Exports the class.

    +

    Export the class.

    diff --git a/doc/api/updates.html b/doc/api/updates.html new file mode 100644 index 0000000..43d306e --- /dev/null +++ b/doc/api/updates.html @@ -0,0 +1,283 @@ + + + + + updates.js + + + + + +
    +
    + +
      + +
    • +
      +

      updates.js

      +
      +
    • + + + +
    • +
      + +
      + +
      +
      telegram.link
      +Copyright 2014 Enrico Stara 'enrico.stara@gmail.com'
      +Released under the MIT License
      +http://telegram.link
      +
      +
      + +
    • + + +
    • +
      + +
      + +
      +

      Dependencies:

      + +
      + +
      var api = require('../api');
      +var utility = require('../utility');
      + +
    • + + +
    • +
      + +
      + +
      +
      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      This module wraps API methods required to manage the session updates

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      See Api Methods

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      Access only via Client object and updates instance property

      + +
      + +
      +function Updates(client) {
      +    this.client = client;
      +}
      + +
    • + + +
    • +
      + +
      + +
      +
      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      Event: 'method name'

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      Each of the following methods emits an event with the same name when done, an error event otherwise.

      + +
      + +
    • + + +
    • +
      + +
      + +
      +
      +

      updates.getState([callback])

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      Return a Promise to get the current state of updates.

      + +
      + +
    • + + +
    • + + +
    • + + +
    • +
      + +
      + +
      +

      The code:

      + +
      + +
      Updates.prototype.getState = function (callback) {
      +    return utility.callService(api.service.updates.getState, this.client, this.client._channel, callback, arguments);
      +};
      + +
    • + + +
    • +
      + +
      + +
      +
      +

      updates.getDifference(pts, date, qts, [callback])

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      Return a Promise to get the difference between the current state of updates and transmitted.

      + +
      + +
    • + + +
    • + + +
    • + + +
    • +
      + +
      + +
      +

      The code:

      + +
      + +
      Updates.prototype.getDifference = function (pts, date, qts, callback) {
      +    return utility.callService(api.service.updates.getDifference, this.client, this.client._channel, callback, arguments);
      +};
      + +
    • + + +
    • +
      + +
      + +
      +

      Export the class

      + +
      + +
      module.exports = exports = Updates;
      + +
    • + +
    +
    + + diff --git a/doc/telegram.link.html b/doc/telegram.link.html index 774fce4..b9bf6ba 100644 --- a/doc/telegram.link.html +++ b/doc/telegram.link.html @@ -425,12 +425,11 @@

    telegram.link.js

    -

    creates the authorization modules bound with the client to call all the API methods -user authorization

    +

    User authorization

    -
        this.auth = new (require('./auth'))(this);
    +
        this.auth = new (require('./api/auth'))(this);
  • @@ -441,11 +440,11 @@

    telegram.link.js

    -

    user contacts

    +

    User contacts

    -
        this.contacts = new (require('./contacts'))(this);
    +
        this.contacts = new (require('./api/contacts'))(this);
    @@ -456,11 +455,11 @@

    telegram.link.js

    -

    session updates

    +

    Session updates

    -
        this.updates = new (require('./updates'))(this);
    +
        this.updates = new (require('./api/updates'))(this);
    @@ -471,12 +470,11 @@

    telegram.link.js

    -

    chat messages

    +

    Chat messages

    -
        this.messages = new (require('./messages'))(this);
    -}
    +
        this.messages = new (require('./api/messages'))(this);
    @@ -487,11 +485,12 @@

    telegram.link.js

    -

    Extend the events.EventEmitter class

    +

    Notifications and settings

    -
    require('util').inherits(Client, require('events').EventEmitter);
    +
        this.account = new (require('./api/account'))(this);
    +}
    @@ -502,11 +501,12 @@

    telegram.link.js

    -
    -

    createEncryptedChannel()

    +

    Extend the events.EventEmitter class

    +
    require('util').inherits(Client, require('events').EventEmitter);
    + @@ -516,7 +516,8 @@

    telegram.link.js

    -

    Creates the encrypted channel used to call all the Telegram API methods (private).

    +
    +

    createEncryptedChannel()

    @@ -529,6 +530,19 @@

    telegram.link.js

    +

    Creates the encrypted channel used to call all the Telegram API methods (private).

    + + + + + + +
  • +
    + +
    + +

    The code:

    @@ -547,11 +561,11 @@

    telegram.link.js

  • -
  • +
  • - +

    client.createAuthKey([callback])

    @@ -561,11 +575,11 @@

    telegram.link.js

  • -
  • +
  • - +

    Exchanges the authorization key with Telegram, see https://core.telegram.org/mtproto/auth_key

    @@ -574,11 +588,11 @@

    telegram.link.js

  • -
  • +
  • - +

    This method is asynchronous and the client must be already connected before calling this function. When the authKey is created, the authKeyCreate event will be emitted.

    @@ -588,11 +602,11 @@

    telegram.link.js

  • -
  • +
  • - +

    The last parameter callback will be added as a listener for the authKeyCreate event, the callback could receive the following arguments:

    @@ -606,11 +620,11 @@

    telegram.link.js

  • -
  • +
  • - +

    The code:

    @@ -637,11 +651,11 @@

    telegram.link.js

  • -
  • +
  • - +

    client.getDataCenterList([callback])

    @@ -651,11 +665,11 @@

    telegram.link.js

  • -
  • +
  • - +

    Gets the data center list, the current data center and the nearest one.

    @@ -664,11 +678,11 @@

    telegram.link.js

  • -
  • +
  • - +

    The code:

    @@ -726,11 +740,273 @@

    telegram.link.js

  • -
  • +
  • - + +
    +
    +

    client.httpPoll(callback, [maxWait], [waitAfter], [maxDelay])

    + +
    + +
  • + + +
  • +
    + +
    + +
    +

    HTTP long poll service.

    + +
    + +
  • + + +
  • +
    + +
    + +
    +

    The code:

    + +
    + +
    Client.prototype.httpPoll = function (callback, maxWait, waitAfter, maxDelay) {
    +    if (callback) {
    +        this.once('httpPoll', callback);
    +    }
    +    if (this.isReady(true) && this._connection instanceof mt.net.HttpConnection) {
    +        var self = this;
    +        maxWait = maxWait || 30000;
    +        console.log('call http long poll each %sms', maxWait);
    +        try {
    +            mt.service.http_wait({
    +                props: {
    +                    max_delay: maxDelay || 0,
    +                    wait_after: waitAfter || 0,
    +                    max_wait: maxWait
    +                },
    +                channel: self._channel,
    +                callback: function (ex, result) {
    +                    if (ex) {
    +                        self.emit('error', ex);
    +                    } else {
    +                        self.emit('httpPoll', result);
    +                        if(self._httpPollLoop) {
    +                            self.httpPoll(callback, maxWait, waitAfter, maxDelay);
    +                        }
    +                    }
    +                }
    +            });
    +        } catch (err) {
    +            this.emit('error', err);
    +        }
    +    }
    +};
    + +
  • + + +
  • +
    + +
    + +
    +
    +

    client.startHttpPollLoop(callback, [maxWait], [waitAfter], [maxDelay])

    + +
    + +
  • + + +
  • +
    + +
    + +
    +

    Start the HTTP long poll service loop.

    + +
    + +
  • + + +
  • +
    + +
    + +
    +

    The code:

    + +
    + +
    Client.prototype.startHttpPollLoop = function (callback, maxWait, waitAfter, maxDelay) {
    +    this._httpPollLoop = true;
    +    this.httpPoll(callback, maxWait, waitAfter, maxDelay);
    +};
    + +
  • + + +
  • +
    + +
    + +
    +
    +

    client.stopHttpPollLoop()

    + +
    + +
  • + + +
  • +
    + +
    + +
    +

    Stop the HTTP long poll service loop.

    + +
    + +
  • + + +
  • +
    + +
    + +
    +

    The code:

    + +
    + +
    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()

    @@ -740,11 +1016,11 @@

    telegram.link.js

  • -
  • +
  • - +

    Checks if the client is ready to communicate with Telegram and immediately emits the error-event if required.

    @@ -753,11 +1029,11 @@

    telegram.link.js

  • -
  • +
  • - +

    The code:

    @@ -776,11 +1052,11 @@

    telegram.link.js

  • -
  • +
  • - +

    client.end([callback])

    @@ -790,11 +1066,11 @@

    telegram.link.js

  • -
  • +
  • - +

    Closes the communication with the DataCenter,

    @@ -803,11 +1079,11 @@

    telegram.link.js

  • -
  • +
  • - +

    The last parameter callback will be added as a listener for the end event.

    @@ -816,11 +1092,11 @@

    telegram.link.js

  • -
  • +
  • - +

    The code:

    @@ -836,11 +1112,11 @@

    telegram.link.js

  • -
  • +
  • - +

    connect()

    @@ -850,11 +1126,11 @@

    telegram.link.js

  • -
  • +
  • - +

    Establishes the connection with the data center (private).

    @@ -863,11 +1139,11 @@

    telegram.link.js

  • -
  • +
  • - +

    The code:

    @@ -880,11 +1156,11 @@

    telegram.link.js

  • -
  • +
  • - +

    Event: ‘connect’ @@ -895,11 +1171,11 @@

    telegram.link.js

  • -
  • +
  • - +

    Event: ‘authKeyCreate’ Emitted when the authKey is successfully created. See client.createAuthKey().

    @@ -909,11 +1185,11 @@

    telegram.link.js

  • -
  • +
  • - +

    Event: ‘dataCenter’ Emitted when the data-center map is available. See client.getDataCenters().

    @@ -923,11 +1199,11 @@

    telegram.link.js

  • -
  • +
  • - +

    Event: ‘end’ Emitted when the data center close the connection. See client.end().

    @@ -937,11 +1213,11 @@

    telegram.link.js

  • -
  • +
  • - +

    Event: ‘error’ Emitted when an error occurs.

    @@ -951,11 +1227,11 @@

    telegram.link.js

  • -
  • +
  • - +

    @@ -964,11 +1240,11 @@

    telegram.link.js

  • -
  • +
  • - +

    Export the internals.

    @@ -983,11 +1259,11 @@

    telegram.link.js

  • -
  • +
  • - +

    Export all the API types. (no methods)

    diff --git a/doc/utility.html b/doc/utility.html index 885444c..5e9ba6f 100644 --- a/doc/utility.html +++ b/doc/utility.html @@ -88,7 +88,8 @@

    utility.js

    return new Promise(function (fulfill, reject) { emitter.once('error', reject); emitter.once(eventName, function (result) { - if ('mtproto.type.Rpc_error' == result.typeName) { + emitter.removeListener('error', reject); + if (typeof result !== 'boolean' && result.instanceOf('mtproto.type.Rpc_error')) { reject(new Error(result.error_message)); } else { fulfill(result); diff --git a/gulpfile.js b/gulpfile.js index 15cf6c0..8d13cca 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,7 +6,7 @@ var del = require('del'); gulp.task('doc', function () { del(['./doc'], function () { - gulp.src('./lib/*.js') + gulp.src('./lib/**/*.js') .pipe(docco(/*{'layout': 'linear'}*/)) .pipe(gulp.dest('./doc')); }); diff --git a/lib/api/account.js b/lib/api/account.js index f8134fc..7ce9906 100644 --- a/lib/api/account.js +++ b/lib/api/account.js @@ -32,7 +32,7 @@ function Account(client) { // *** // account.**updateStatus(offline, [callback])** -// Returns a Promise for update the online user status.. +// Return a Promise to update the online user status.. // [Click here for more details](https://core.telegram.org/method/account.updateStatus) diff --git a/lib/api/auth.js b/lib/api/auth.js index c48c057..d0fd4fd 100644 --- a/lib/api/auth.js +++ b/lib/api/auth.js @@ -33,7 +33,7 @@ function Auth(client) { // *** // auth.**sendCode(phone_number, sms_type, lang_code, [callback])** -// Sends a text message with the confirmation code required for registration to the given phone number. +// Send a text message with the confirmation code required for registration to the given phone number. // [Click here for more details](https://core.telegram.org/method/auth.sendCode) @@ -66,8 +66,8 @@ Auth.prototype.sendCode = function (phone_number, sms_type, lang_code, callback) // *** // auth.**sendCall(phone_number, phone_code_hash, [callback])** -// Makes a voice call to the passed phone number. A robot will repeat the confirmation code from a previously sent SMS message. -// Returns a Promise. +// Return a Promise to make a voice call to the passed phone number. +// A robot will repeat the confirmation code from a previously sent SMS message. // [Click here for more details](https://core.telegram.org/method/auth.sendCall) @@ -80,8 +80,7 @@ Auth.prototype.sendCall = function (phone_number, phone_code_hash, callback) { // *** // auth.**signIn(phone_number, phone_code_hash, phone_code, [callback])** -// Signs in a user with a validated phone number. -// Returns a Promise. +// Return a Promise to sign in a user with a validated phone number. // [Click here for more details](https://core.telegram.org/method/auth.signIn) @@ -94,8 +93,7 @@ Auth.prototype.signIn = function (phone_number, phone_code_hash, phone_code, cal // *** // auth.**signUp(phone_number, phone_code_hash, phone_code, first_name, last_name, [callback])** -// Registers a validated phone number in the system. -// Returns a Promise. +// Return a Promise to register a validated phone number in the system. // [Click here for more details](https://core.telegram.org/method/auth.signUp) @@ -107,7 +105,7 @@ Auth.prototype.signUp = function (phone_number, phone_code_hash, phone_code, fir // *** // auth.**checkPhone(phone_number, [callback])** -// Returns a Promise for get the information on whether the passed phone number was registered. +// Return a Promise to get the information on whether the passed phone number was registered. // [Click here for more details](https://core.telegram.org/method/auth.checkPhone) @@ -117,5 +115,5 @@ Auth.prototype.checkPhone = function (phone_number, callback) { }; -// Exports the class. +// Export the class. module.exports = exports = Auth; \ No newline at end of file diff --git a/lib/api/contacts.js b/lib/api/contacts.js index d9ca544..0c52b4f 100644 --- a/lib/api/contacts.js +++ b/lib/api/contacts.js @@ -32,7 +32,7 @@ function Contacts(client) { // *** // contacts.**getContacts(hash, [callback])** -// Returns a Promise for get the current user's contact list. +// Return a Promise to get the current user's contact list. // [Click here for more details](https://core.telegram.org/method/contacts.getContacts) @@ -41,5 +41,5 @@ Contacts.prototype.getContacts = function (hash, callback) { return utility.callService(api.service.contacts.getContacts, this.client, this.client._channel, callback, arguments); }; -// Exports the class +// Export the class module.exports = exports = Contacts; \ No newline at end of file diff --git a/lib/api/messages.js b/lib/api/messages.js index 51d0e3e..0e2c332 100644 --- a/lib/api/messages.js +++ b/lib/api/messages.js @@ -32,7 +32,7 @@ function Messages(client) { // *** // messages.**getDialogs(offset, max_id, limit, [callback])** -// Returns a Promise for get the current user dialog list. +// Return a Promise to get the current user dialog list. // [Click here for more details](https://core.telegram.org/method/messages.getDialogs) @@ -44,7 +44,7 @@ Messages.prototype.getDialogs = function (offset, max_id, limit, callback) { // *** // messages.**getHistory(peer, offset, max_id, limit, [callback])** -// Returns a Promise for get the message history for a chat. +// Return a Promise to get the message history for a chat. // [Click here for more details](https://core.telegram.org/method/messages.getHistory) @@ -74,22 +74,26 @@ Messages.prototype.getHistory = function (peer, offset, max_id, limit, callback) }; // *** -// messages.**readHistory(peer, offset, max_id, limit, [callback])** +// messages.**readHistory(peer, max_id, offset, read_contents, [callback])** -// Returns a Promise to mark message history as read.. +// Return a Promise to mark the message history as read.. // [Click here for more details](https://core.telegram.org/method/messages.readHistory) // The code: -Messages.prototype.readHistory = function (peer, offset, max_id, limit, callback) { +Messages.prototype.readHistory = function (peer, max_id, offset, read_contents, callback) { + + read_contents = read_contents === false ? new api.type.BoolFalse() : + ( read_contents === true ? new api.type.BoolTrue() : read_contents); + return utility.callService(api.service.messages.readHistory, this.client, this.client._channel, callback, arguments); }; // *** // messages.**sendMessage(peer, message, random_id, [callback])** -// Returns a Promise for get the message history for a chat. +// Return a Promise to send a message to the peer. // [Click here for more details](https://core.telegram.org/method/messages.sendMessage) @@ -118,5 +122,5 @@ Messages.prototype.sendMessage = function (peer, message, random_id, callback) { return utility.callService(api.service.messages.sendMessage, this.client, this.client._channel, callback, arguments); }; -// Exports the class. +// Export the class. module.exports = exports = Messages; \ No newline at end of file diff --git a/lib/api/updates.js b/lib/api/updates.js index 86e74c0..96079a0 100644 --- a/lib/api/updates.js +++ b/lib/api/updates.js @@ -32,7 +32,7 @@ function Updates(client) { // *** // updates.**getState([callback])** -// Returns a Promise for get the current state of updates. +// Return a Promise to get the current state of updates. // [Click here for more details](https://core.telegram.org/method/updates.getState) @@ -45,7 +45,7 @@ Updates.prototype.getState = function (callback) { // *** // updates.**getDifference(pts, date, qts, [callback])** -// Returns a Promise for get the difference between the current state of updates and transmitted. +// Return a Promise to get the difference between the current state of updates and transmitted. // [Click here for more details](https://core.telegram.org/method/updates.getDifference) @@ -54,5 +54,5 @@ Updates.prototype.getDifference = function (pts, date, qts, callback) { return utility.callService(api.service.updates.getDifference, this.client, this.client._channel, callback, arguments); }; -// Exports the class +// Export the class module.exports = exports = Updates; \ No newline at end of file