diff --git a/lib/api/auth.js b/lib/api/auth.js index 37a92d1..a09036e 100644 --- a/lib/api/auth.js +++ b/lib/api/auth.js @@ -114,6 +114,17 @@ Auth.prototype.checkPhone = function (phone_number, callback) { return utility.callService(api.service.auth.checkPhone, this.client, this.client._channel, callback, arguments); }; +// *** +// auth.**logOut([callback])** + +// Return a Promise for logout the user. + +// [Click here for more details](https://core.telegram.org/method/auth.logOut) + +// The code: +Auth.prototype.logOut = function (callback) { + return utility.callService(api.service.auth.logOut, this.client, this.client._channel, callback, arguments); +}; // Export the class. module.exports = exports = Auth; diff --git a/lib/api/contacts.js b/lib/api/contacts.js index 60fa2fb..ebc6637 100644 --- a/lib/api/contacts.js +++ b/lib/api/contacts.js @@ -7,6 +7,7 @@ // Dependencies: var api = require('../api'); var utility = require('../utility'); +var tl = require('telegram-tl-node'); // *** @@ -41,5 +42,58 @@ Contacts.prototype.getContacts = function (hash, callback) { return utility.callService(api.service.contacts.getContacts, this.client, this.client._channel, callback, arguments); }; +// *** +// contacts.**importContacts(contacts, replace, [callback])** + +// Return a Promise. Imports contacts: saves a full list on the server, adds already registered contacts to the contact list, returns added contacts and their info. + +// [Click here for more details](https://core.telegram.org/method/contacts.importContacts) + +// The code: +Contacts.prototype.importContacts = function (contacts, replace, callback) { + + contacts = new tl.TypeVector({ + type: 'InputContact', + list: contacts.map(function (item) { + + return new api.type.InputPhoneContact({props: item}); + }) + }); + + replace = !!replace === false + ? new api.type.BoolFalse() + : new api.type.BoolTrue(); + + return utility.callService(api.service.contacts.importContacts, this.client, this.client._channel, callback, arguments); +}; + +// *** +// contacts.**getStatuses([callback])** + +// Return a Promise. Returns the list of contact statuses. + +// [Click here for more details](https://core.telegram.org/method/contacts.getStatuses) + +// The code: +Contacts.prototype.getStatuses = function (callback) { + + return utility.callService(api.service.contacts.getStatuses, this.client, this.client._channel, callback, arguments); +}; + +// *** +// contacts.**deleteContact(user_id, [callback])** + +// Return a Promise. Deletes a contact from the list. + +// [Click here for more details](https://core.telegram.org/method/contacts.deleteContact) + +// The code: +Contacts.prototype.deleteContact = function (user_id, callback) { + + user_id = new tl.type.InputUserContact({props: {user_id: user_id}}); + + return utility.callService(api.service.contacts.importContacts, this.client, this.client._channel, callback, arguments); +}; + // Export the class module.exports = exports = Contacts; diff --git a/lib/api/messages.js b/lib/api/messages.js index 89c73a2..27bd4db 100644 --- a/lib/api/messages.js +++ b/lib/api/messages.js @@ -122,5 +122,15 @@ Messages.prototype.sendMessage = function (peer, message, random_id, callback) { return utility.callService(api.service.messages.sendMessage, this.client, this.client._channel, callback, arguments); }; +// *** +// messages.**receivedMessages(max_id, [callback])** + +// Return a Promise to Confirms receipt of messages by a client, cancels PUSH-notification sending. + +// [Click here for more details](https://core.telegram.org/method/messages.receivedMessages) +Messages.prototype.receivedMessages = function (max_id, callback) { + return utility.callService(api.service.messages.receivedMessages, this.client, this.client._channel, callback, arguments); +}; + // Export the class. module.exports = exports = Messages; diff --git a/package.json b/package.json index 42a1c06..9368365 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,8 @@ "get-flow": "latest", "get-log": "latest", "requirish": "latest", - "telegram-tl-node": "latest", - "telegram-mt-node": "latest", + "telegram-tl-node": "https://github.com/amurchick/telegram-tl-node", + "telegram-mt-node": "https://github.com/amurchick/telegram-mt-node", "colors": "1.1.2", "es6-promise": "2.3.0" },