Comparing version 5.0.0-rc.4 to 5.0.0
@@ -58,2 +58,3 @@ 'use strict'; | ||
useMutableRename: false, | ||
useDefaultVerbosityLevel: false, | ||
tdlibParameters: { | ||
@@ -195,3 +196,3 @@ use_message_database: true, | ||
try { | ||
this.setLogVerbosityLevel(this._options.verbosityLevel); | ||
if (!this._options.useDefaultVerbosityLevel) this.setLogVerbosityLevel(this._options.verbosityLevel); | ||
@@ -198,0 +199,0 @@ this._client = await this._tdlib.create(); |
@@ -111,5 +111,9 @@ 'use strict'; | ||
setLogFatalErrorCallback(fn) { | ||
this._tdlib.td_set_log_fatal_error_callback(_ffiNapi2.default.Callback('void', ['string'], fn)); | ||
if (fn == null) { | ||
this._tdlib.td_set_log_fatal_error_callback(null); | ||
} else { | ||
this._tdlib.td_set_log_fatal_error_callback(_ffiNapi2.default.Callback('void', ['string'], fn)); | ||
} | ||
} | ||
} | ||
exports.TDLib = TDLib; |
@@ -53,3 +53,3 @@ import { | ||
setLogVerbosityLevel: (verbosity: number) => undefined | ||
setLogFatalErrorCallback: (fn: (errorMessage: string) => void) => undefined | ||
setLogFatalErrorCallback: (fn: null | ((errorMessage: string) => void)) => undefined | ||
execute: Execute | ||
@@ -77,3 +77,3 @@ } | ||
setLogVerbosityLevel(verbosity: number): undefined | ||
setLogFatalErrorCallback(fn: (errorMessage: string) => void): undefined | ||
setLogFatalErrorCallback(fn: null | ((errorMessage: string) => void)): undefined | ||
} | ||
@@ -117,16 +117,3 @@ | ||
export type ConfigType = { | ||
apiId?: number, | ||
apiHash?: string, | ||
binaryPath?: string, | ||
databaseDirectory?: string, | ||
filesDirectory?: string, | ||
databaseEncryptionKey?: string, | ||
verbosityLevel?: number, | ||
skipOldUpdates?: boolean, | ||
useTestDc?: boolean, | ||
useMutableRename?: boolean, | ||
tdlibParameters?: TDLibParameters, | ||
tdlibInstance?: TDLib | ||
} | ||
export type ConfigType = Partial<StrictConfigType> | ||
@@ -144,4 +131,5 @@ export type StrictConfigType = { | ||
useMutableRename: boolean, | ||
useDefaultVerbosityLevel: boolean, | ||
tdlibParameters: TDLibParameters, | ||
tdlibInstance?: TDLib | ||
tdlibInstance?: ITDLibJSON | ||
} |
{ | ||
"name": "tdl", | ||
"version": "5.0.0-rc.4", | ||
"version": "5.0.0", | ||
"description": "TDLib (Telegram Database library) bindings for Node.js", | ||
@@ -44,3 +44,3 @@ "main": "index.js", | ||
"ref-napi": "^1.4.0", | ||
"tdl-shared": "^0.2.0" | ||
"tdl-shared": "^0.4.0" | ||
}, | ||
@@ -47,0 +47,0 @@ "devDependencies": { |
@@ -139,4 +139,8 @@ ## tdl | ||
See [docs](https://core.telegram.org/tdlib/docs/classtd_1_1_log.html#a038b57d66436f9f367f5c77360e8254b). | ||
```js | ||
client.setLogFilePath('log.txt') | ||
``` | ||
See [docs](https://core.telegram.org/tdlib/docs/td__log_8h.html#a4b098540dd3957b60a67600cba3ebd7f). | ||
##### `client.setLogMaxFileSize(maxFileSize: (number | string)) => undefined` | ||
@@ -146,4 +150,8 @@ | ||
See [docs](https://core.telegram.org/tdlib/docs/classtd_1_1_log.html#a749ea8521373bbe9f5c30f58bc591016). | ||
```js | ||
client.setLogMaxFileSize(50000) | ||
``` | ||
See [docs](https://core.telegram.org/tdlib/docs/td__log_8h.html#adcbe44e62e16d65eb4c7503aabe264b3). | ||
##### `client.setLogVerbosityLevel(verbosityLevel: number) => undefined` | ||
@@ -154,15 +162,19 @@ | ||
See [docs](https://core.telegram.org/tdlib/docs/classtd_1_1_log.html#a0f683bd572154f7b4c8b4f973ea3395f). | ||
```js | ||
client.setLogVerbosityLevel(2) | ||
``` | ||
##### `client.setLogFatalErrorCallback(fn: Function) => undefined` | ||
See [docs](https://core.telegram.org/tdlib/docs/td__log_8h.html#a8cd6fada30eb227c667fc9a10464ae50). | ||
##### `client.setLogFatalErrorCallback(fn: (null | Function)) => undefined` | ||
Sets the callback that will be called when a fatal error happens. None of the TDLib methods can be called from the callback. The TDLib will crash as soon as callback returns. By default the callback is not set. | ||
```js | ||
client.setLogFatalErrorCallback(errorMessage => | ||
console.error('Fatal error:', errorMessage) | ||
client.setLogFatalErrorCallback( | ||
errorMessage => console.error('Fatal error:', errorMessage) | ||
) | ||
``` | ||
See [docs](https://core.telegram.org/tdlib/docs/classtd_1_1_log.html#ab2c5a70ac5ca1f952d979f9fa4b2ba82). | ||
See [docs](https://core.telegram.org/tdlib/docs/td__log_8h.html#addebe91c4525817a6d2b448634c19d71). | ||
@@ -302,3 +314,3 @@ ##### `client.invokeFuture(query: Object) => Future` | ||
You can also you use prebuilt binaries: | ||
You can also use prebuilt binaries: | ||
@@ -305,0 +317,0 @@ - [tdlib.native](https://github.com/ForNeVeR/tdlib.native/releases) |
@@ -14,3 +14,4 @@ ## TDLib API | ||
```js | ||
const tdlib = new TDLib('/Users/user/testproject/libtdjson') | ||
const tdlib = new TDLib() | ||
const tdlib = new TDLib('libtdjson') | ||
``` | ||
@@ -28,12 +29,37 @@ | ||
[Docs](https://core.telegram.org/tdlib/docs/classtd_1_1_client.html#a1a6f9cbe607ce76ff869493833c1224d) | ||
```js | ||
await tdlib.send(client, { | ||
'@type': 'sendMessage', | ||
chat_id: 123456789, | ||
input_message_content: { | ||
'@type': 'inputMessageText', | ||
text: { | ||
'@type': 'formattedText', | ||
text: '👻' | ||
} | ||
} | ||
}) | ||
``` | ||
[Docs](https://core.telegram.org/tdlib/docs/td__json__client_8h.html#a1fea1f986bf950d19eee3032c24cce83) | ||
##### `receive: (client: TDLibClient, timeout: number) => Promise<Object | null>` | ||
[Docs](https://core.telegram.org/tdlib/docs/classtd_1_1_client.html#a128bb17ada87f4a1522f56428706cfd6) | ||
```js | ||
const response = await tdlib.receive(client, 10) | ||
``` | ||
[Docs](https://core.telegram.org/tdlib/docs/td__json__client_8h.html#a9e0cb36bfa2bc2249905aebd7d07a4ac) | ||
##### `execute: (client: TDLibClient, query: Object) => Object | null` | ||
[Docs](https://core.telegram.org/tdlib/docs/classtd_1_1_client.html#a6500da45fe520151a774fbd69f30ec30) | ||
```js | ||
const res = await tdlib.execute(client, { | ||
'@type': 'getTextEntities', | ||
text: '@telegram /test_command https://telegram.org telegram.me' | ||
}) | ||
``` | ||
[Docs](https://core.telegram.org/tdlib/docs/td__json__client_8h.html#a6d6c76380793072d4a9ce3c71ba0f1cf) | ||
##### `destroy: (client: TDLibClient) => void` | ||
@@ -49,2 +75,6 @@ | ||
```js | ||
client.setLogFilePath('log.txt') | ||
``` | ||
[Docs](https://core.telegram.org/tdlib/docs/td__log_8h.html#a4b098540dd3957b60a67600cba3ebd7f) | ||
@@ -54,2 +84,7 @@ | ||
```js | ||
tdlib.setLogMaxFileSize(50000) | ||
tdlib.setLogMaxFileSize('9007199254748991') | ||
``` | ||
[Docs](https://core.telegram.org/tdlib/docs/td__log_8h.html#adcbe44e62e16d65eb4c7503aabe264b3) | ||
@@ -59,6 +94,18 @@ | ||
```js | ||
tdlib.setLogVerbosityLevel(2) | ||
``` | ||
[Docs](https://core.telegram.org/tdlib/docs/td__log_8h.html#a8cd6fada30eb227c667fc9a10464ae50) | ||
##### `setLogFatalErrorCallback: (fn: (errorMessage: string) => void) => void` | ||
##### `setLogFatalErrorCallback: (fn: null | (errorMessage: string) => void) => void` | ||
```js | ||
tdlib.setLogFatalErrorCallback( | ||
errorMessage => console.error('Fatal error:', errorMessage) | ||
) | ||
tdlib.setLogFatalErrorCallback(null) | ||
``` | ||
[Docs](https://core.telegram.org/tdlib/docs/td__log_8h.html#addebe91c4525817a6d2b448634c19d71) |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1303185
0
316
36261
+ Addedtdl-shared@0.4.0(transitive)
- Removedtdl-shared@0.2.0(transitive)
Updatedtdl-shared@^0.4.0