Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auth.logOut() method #24

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/api/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
54 changes: 54 additions & 0 deletions lib/api/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// Dependencies:
var api = require('../api');
var utility = require('../utility');
var tl = require('telegram-tl-node');


// ***
Expand Down Expand Up @@ -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;
10 changes: 10 additions & 0 deletions lib/api/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down