Update tdweb documentation.
GitOrigin-RevId: bc02a159b4b2b74e0217459d7c4b6213b30851ab
This commit is contained in:
parent
b0329188e1
commit
fa8604edf3
@ -35,7 +35,7 @@ Take a look at our [examples](https://github.com/tdlib/td/blob/master/example/RE
|
|||||||
|
|
||||||
See our [Getting Started](https://core.telegram.org/tdlib/getting-started) tutorial for a description of basic TDLib concepts.
|
See our [Getting Started](https://core.telegram.org/tdlib/getting-started) tutorial for a description of basic TDLib concepts.
|
||||||
|
|
||||||
See [build instructions generator](https://tdlib.github.io/td/build.html) for detailed instructions on how to build TDLib.
|
See a [TDLib build instructions generator](https://tdlib.github.io/td/build.html) for detailed instructions on how to build TDLib.
|
||||||
|
|
||||||
See description of our [JSON](#using-json), [C++](#using-cxx), [Java](#using-java) and [.NET](#using-dotnet) interfaces.
|
See description of our [JSON](#using-json), [C++](#using-cxx), [Java](#using-java) and [.NET](#using-dotnet) interfaces.
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ for a list of all available `TDLib` [methods](https://core.telegram.org/tdlib/do
|
|||||||
<a name="building"></a>
|
<a name="building"></a>
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
The simplest way to build `TDLib` is to use our [build instructions generator](https://tdlib.github.io/td/build.html).
|
The simplest way to build `TDLib` is to use our [TDLib build instructions generator](https://tdlib.github.io/td/build.html).
|
||||||
You need only to choose your programming language and target operating system to receive complete build instructions.
|
You need only to choose your programming language and target operating system to receive complete build instructions.
|
||||||
|
|
||||||
In general, you need to install all `TDLib` [dependencies](#dependencies) as described in [Installing dependencies](#installing-dependencies).
|
In general, you need to install all `TDLib` [dependencies](#dependencies) as described in [Installing dependencies](#installing-dependencies).
|
||||||
|
@ -6,7 +6,7 @@ automatically generated [HTML documentation](https://core.telegram.org/tdlib/doc
|
|||||||
[methods](https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_function.html) and [classes](https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_object.html).
|
[methods](https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_function.html) and [classes](https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_object.html).
|
||||||
Also take a look at our [Getting Started](https://core.telegram.org/tdlib/getting-started) tutorial for a description of basic TDLib concepts.
|
Also take a look at our [Getting Started](https://core.telegram.org/tdlib/getting-started) tutorial for a description of basic TDLib concepts.
|
||||||
|
|
||||||
TDLib can be easily used from almost any programming language on any platform. See [build instructions generator](https://tdlib.github.io/td/build.html) for detailed instructions on how to build TDLib.
|
TDLib can be easily used from almost any programming language on any platform. See a [TDLib build instructions generator](https://tdlib.github.io/td/build.html) for detailed instructions on how to build TDLib.
|
||||||
Choose your preferred programming language to see examples of usage and a detailed description:
|
Choose your preferred programming language to see examples of usage and a detailed description:
|
||||||
|
|
||||||
- [Python](#python)
|
- [Python](#python)
|
||||||
|
@ -6,39 +6,43 @@ import log from './logger.js';
|
|||||||
const sleep = ms => new Promise(res => setTimeout(res, ms));
|
const sleep = ms => new Promise(res => setTimeout(res, ms));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TDLib in browser
|
* TDLib in a browser
|
||||||
*
|
*
|
||||||
* TDLib can be used from javascript through the [JSON](https://github.com/tdlib/td#using-json) interface.
|
* TDLib can be compiled to WebAssembly or asm.js using Emscripten compiler and used in a browser from JavaScript.
|
||||||
* This is a convenient wrapper around it.
|
* This is a convenient wrapper for TDLib in a browser which controls TDLib instance creation, handles interaction
|
||||||
* Internally it uses TDLib built with emscripten as asm.js or WebAssembly. All work happens in a WebWorker.
|
* with the TDLib and manages a filesystem for persistent TDLib data.
|
||||||
* TdClient itself just sends queries to WebWorker, receive updates and results from WebWorker.
|
* TDLib instance is created in a Web Worker, because TDLib needs synchronous access to filesystem and the IndexedDB.
|
||||||
*
|
* TdClient just sends queries to the Web Worker and receive updates and results from it.
|
||||||
* <br><br>
|
* <br>
|
||||||
* Differences from TDLib API<br>
|
* <br>
|
||||||
* 1. updateFatalError error:string = Update; <br>
|
* Differences from TDLib API:<br>
|
||||||
* 3. file <..as in td_api..> idb_key:string = File; <br>
|
* 1. Added the update <code>updateFatalError error:string = Update;</code> which is sent whenever a TDLib fatal error is encountered.<br>
|
||||||
* 2. setJsLogVerbosityLevel new_verbosity_level:string = Ok;
|
* 2. Added the field <code>idb_key</code> to <code>file</code> object, which contains IndexedDB key in which the file content is stored.<br>
|
||||||
* 3. inputFileBlob blob:<javascript blob> = InputFile;<br>
|
* This field is non-empty only for fully downloaded files. IndexedDB database name is chosen during TdClient creation.<br>
|
||||||
* 4. readFilePart path:string offset:int64 size:int64 = FilePart;<br>
|
* 3. Added the method <code>setJsLogVerbosityLevel new_verbosity_level:string = Ok;</code>, which allows to change the verbosity level of tdweb logging.<br>
|
||||||
* filePart data:blob = FilePart;<br>
|
* 4. Added the possibility to use blobs as input files via constructor <code>inputFileBlob blob:<JavaScript blob> = InputFile;</code>.<br>
|
||||||
|
* 5. Added the method <code>readFilePart path:string offset:int64 size:int64 = FilePart;</code> and class <code>filePart data:<JavaScript blob> = FilePart;</code><br>
|
||||||
|
* which can be used on a partially downloaded file to support media streaming.<br>
|
||||||
|
* 6. Methods <code>getStorageStatistics</code>, <code>getStorageStatisticsFast</code>, <code>optimizeStorage</code>, <code>addProxy</code> are not supported.<br>
|
||||||
* <br>
|
* <br>
|
||||||
*/
|
*/
|
||||||
class TdClient {
|
class TdClient {
|
||||||
/**
|
/**
|
||||||
* @callback updateCallback
|
* @callback TdClient~updateCallback
|
||||||
* @param {Object} update
|
* @param {Object} The update.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create TdClient
|
* Create TdClient.
|
||||||
* @param {Object} options - Options
|
* @param {Object} options - The options for TDLib instance creation.
|
||||||
* @param {updateCallback} options.onUpdate - Callback for all updates. Could also be set explicitly right after TdClient construction.
|
* @param {TdClient~updateCallback} options.onUpdate - The callback for all incoming updates.
|
||||||
* @param {number} [options.jsLogVerbosityLevel='info'] - Verbosity level for javascript part of the code (error, warning, info, log, debug)
|
* @param {string} [options.prefix=tdlib] - The name of the IndexedDB database which will be used for persistent data storage. Currently only one instance of TdClient per a database is allowed. All but one created instances will be automatically closed. Usually, the newest non-background instance is kept alive.
|
||||||
* @param {number} [options.logVerbosityLevel=2] - Verbosity level for tdlib
|
* @param {boolean} [options.isBackground=false] - Pass true, if the instance is opened from the background.
|
||||||
* @param {string} [options.prefix=tdlib] Currently only one instance of TdClient per a prefix is allowed. All but one created instances will be automatically closed. Usually, the newest instance is kept alive.
|
* @param {string} [options.mode=wasm] - The type of the TDLib build to use. 'asmjs' for asm.js and 'wasm' for WebAssembly.
|
||||||
* @param {boolean} [options.isBackground=false] - When choosing which instance to keep alive, we prefer instance with isBackground=false
|
* @param {string} [options.jsLogVerbosityLevel='info'] - The initial verbosity level of the JavaScript part of the code (one of 'error', 'warning', 'info', 'log', 'debug').
|
||||||
* @param {string} [options.mode=wasm] - Type of tdlib build to use. 'asmjs' for asm.js and 'wasm' for WebAssembly.
|
* @param {number} [options.logVerbosityLevel=2] - The initial verbosity level for TDLib internal logging (0-1023).
|
||||||
* @param {boolean} [options.readOnly=false] - Open tdlib in read-only mode. Changes to tdlib database won't be persisted. For debug only.
|
* @param {boolean} [options.noDb=false] - Pass true to use TDLib without database and secret chats. It will significantly improve load time, but some functionality will be unavailable.
|
||||||
|
* @param {boolean} [options.readOnly=false] - Pass true to open TDLib database in read-only mode. For debug only.
|
||||||
*/
|
*/
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
log.setVerbosity(options.jsLogVerbosityLevel);
|
log.setVerbosity(options.jsLogVerbosityLevel);
|
||||||
@ -96,15 +100,22 @@ class TdClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send query to tdlib.
|
* Send a query to TDLib.
|
||||||
*
|
*
|
||||||
* If query contains an '@extra' field, the same field will be added into the result.
|
* If the query contains an '@extra' field, the same field will be added into the result.
|
||||||
* '@extra' may contain any js object, it won't be sent to web worker.
|
|
||||||
*
|
*
|
||||||
* @param {Object} query - Query for tdlib.
|
* @param {Object} query - The query for TDLib. See the [td_api.tl]{@link https://github.com/tdlib/td/blob/master/td/generate/scheme/td_api.tl} scheme or
|
||||||
* @returns {Promise} Promise represents the result of the query.
|
* the automatically generated [HTML documentation]{@link https://core.telegram.org/tdlib/docs/td__api_8h.html}
|
||||||
|
* for a list of all available TDLib [methods]{@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_function.html} and
|
||||||
|
* [classes]{@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_object.html}.
|
||||||
|
* @returns {Promise} Promise object represents the result of the query.
|
||||||
*/
|
*/
|
||||||
send(query) {
|
send(query) {
|
||||||
|
let unsupportedMethods = ['getStorageStatistics', 'getStorageStatisticsFast', 'optimizeStorage', 'addProxy'];
|
||||||
|
if (unsupportedMethods.includes(query['@type'])) {
|
||||||
|
return; // TODO what we need to return?
|
||||||
|
}
|
||||||
|
|
||||||
this.query_id++;
|
this.query_id++;
|
||||||
if (query['@extra']) {
|
if (query['@extra']) {
|
||||||
query['@extra'] = {
|
query['@extra'] = {
|
||||||
|
@ -33,7 +33,7 @@ class Logger {
|
|||||||
}
|
}
|
||||||
if (typeof level === 'string') {
|
if (typeof level === 'string') {
|
||||||
level =
|
level =
|
||||||
{ ERROR: 1, WARNINIG: 2, INFO: 3, LOG: 4, DEBUG: 4 }[
|
{ ERROR: 1, WARNING: 2, INFO: 3, LOG: 4, DEBUG: 4 }[
|
||||||
level.toUpperCase()
|
level.toUpperCase()
|
||||||
] || 2;
|
] || 2;
|
||||||
}
|
}
|
||||||
|
@ -820,7 +820,7 @@ pageBlockAnimation animation:animation caption:pageBlockCaption need_autoplay:Bo
|
|||||||
//@description An audio file @audio Audio file; may be null @caption Audio file caption
|
//@description An audio file @audio Audio file; may be null @caption Audio file caption
|
||||||
pageBlockAudio audio:audio caption:pageBlockCaption = PageBlock;
|
pageBlockAudio audio:audio caption:pageBlockCaption = PageBlock;
|
||||||
|
|
||||||
//@description A photo @photo Photo file; may be null @caption Photo caption @url URL associated with the photo
|
//@description A photo @photo Photo file; may be null @caption Photo caption @url URL that needs to be opened when the photo is clicked
|
||||||
pageBlockPhoto photo:photo caption:pageBlockCaption url:string = PageBlock;
|
pageBlockPhoto photo:photo caption:pageBlockCaption url:string = PageBlock;
|
||||||
|
|
||||||
//@description A video @video Video file; may be null @caption Video caption @need_autoplay True, if the video should be played automatically @is_looped True, if the video should be looped
|
//@description A video @video Video file; may be null @caption Video caption @need_autoplay True, if the video should be played automatically @is_looped True, if the video should be looped
|
||||||
@ -3221,8 +3221,8 @@ setPinnedChats chat_ids:vector<int53> = Ok;
|
|||||||
//@description Downloads a file from the cloud. Download progress and completion of the download will be notified through updateFile updates
|
//@description Downloads a file from the cloud. Download progress and completion of the download will be notified through updateFile updates
|
||||||
//@file_id Identifier of the file to download
|
//@file_id Identifier of the file to download
|
||||||
//@priority Priority of the download (1-32). The higher the priority, the earlier the file will be downloaded. If the priorities of two files are equal, then the last one for which downloadFile was called will be downloaded first
|
//@priority Priority of the download (1-32). The higher the priority, the earlier the file will be downloaded. If the priorities of two files are equal, then the last one for which downloadFile was called will be downloaded first
|
||||||
//@offset File will be downloaded starting from that offset in bytes first. Supposed to be used for streaming
|
//@offset The starting position from which the file should be downloaded
|
||||||
//@limit Download will be automatically cancelled when at least limit bytes are downloaded starting from the specified offset; use 0 to download without limit
|
//@limit Number of bytes which should be downloaded starting from the "offset" position before the download will be automatically cancelled; use 0 to download without a limit
|
||||||
//@synchronous If false, this request returns file state just after the download has been started. If true, this request returns file state only after
|
//@synchronous If false, this request returns file state just after the download has been started. If true, this request returns file state only after
|
||||||
//-the download has succeeded, has failed, has been cancelled or a new downloadFile request with different offset/limit parameters was sent
|
//-the download has succeeded, has failed, has been cancelled or a new downloadFile request with different offset/limit parameters was sent
|
||||||
downloadFile file_id:int32 priority:int32 offset:int32 limit:int32 synchronous:Bool = File;
|
downloadFile file_id:int32 priority:int32 offset:int32 limit:int32 synchronous:Bool = File;
|
||||||
|
Reference in New Issue
Block a user