Telegram
Main Telegram class An instance of Telegram can be used to instantiate new clients that will perform the API calls
Constructor Summary
Public Constructor | ||
public |
constructor(MTProto: MTProto, TL: TL) |
Member Summary
Public Members | ||
public |
schema: * |
Method Summary
Public Methods | ||
public |
addPublicKey(key: Object) |
|
public |
buffer2String(buffer: String, length: Number): String Utility method: converts a buffer into a string in hexadecimal format |
|
public |
createAuthKey(authKeyId: String, authKeyBody: String): AuthKey Create a new <span><a href="https://github.com/enricostara/telegram-mt-node/blob/master/lib/auth/auth-key.js">AuthKey</a></span> instance from a key id and a key payload. |
|
public |
Create a new client to interact with the API |
|
public |
createRandomPassword(size: Number): * Creates a random string of chars. |
|
public |
decryptKey(keyBuffer: Buffer, keyPassword: String): AuthKey Decrypt an AuthKey buffer. |
|
public |
string2Buffer(string: String, length: Number): Buffer Utility method: converts a string to a Buffer object |
|
public |
Imports a schema structure into the library. |
Public Constructors
public constructor(MTProto: MTProto, TL: TL) source
Params:
Name | Type | Attribute | Description |
MTProto | MTProto | An object with the MTProto implementation |
|
TL | TL | An object with the Telegram's TypeLanguage implementation |
Public Methods
public addPublicKey(key: Object) source
Params:
Name | Type | Attribute | Description |
key | Object | The key config to add on MtProto layer |
Example:
Telegram.addPublicKey({
fingerprint: '0x123123...',
modulus: '...',
exponent: '010001'
})
public buffer2String(buffer: String, length: Number): String source
Utility method: converts a buffer into a string in hexadecimal format
public createAuthKey(authKeyId: String, authKeyBody: String): AuthKey source
Create a new <span><a href="https://github.com/enricostara/telegram-mt-node/blob/master/lib/auth/auth-key.js">AuthKey</a></span> instance from a key id and a key payload. These two parameters are returned from a Telegram server during the key exchange.
public createRandomPassword(size: Number): * source
Creates a random string of chars. You can use it to generate an AuthKey encryption password
Params:
Name | Type | Attribute | Description |
size | Number |
|
Return:
* |
public decryptKey(keyBuffer: Buffer, keyPassword: String): AuthKey source
Decrypt an AuthKey buffer. This buffer is usually generated from an authKey
Example:
var keyBuffer = authKey.encrypt('password');
var key = tg.decryptKey(keyBuffer, 'password');
public string2Buffer(string: String, length: Number): Buffer source
Utility method: converts a string to a Buffer object
public useSchema(schema: Object, typePrefix: String, servicePrefix: String) source
Imports a schema structure into the library. The default Telegram API schema can be downloaded here: https://core.telegram.org/schema
The prefixes are added in front of all types and methods declared on schema, so after loading the schema you will access them like this:
Example:
// let's assume that your schema has a "foo.TypeFoo" type and a
// "foo.callFoo" method
Telegram.useSchema(schema, 'types', 'methods');
let types = Telegram.schema.type;
let methods = Telegram.schema.service;
let TypeFoo = types.foo.TypeFoo;
let callFoo = methods.foo.callFoo;