tdlib-native
Advanced tools
Comparing version 3.0.0 to 3.1.0
"use strict"; | ||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | ||
const client = require("./client.js"); | ||
const types = require("./generated/types.js"); | ||
@@ -19,4 +20,4 @@ async function wait(waiter, ...parameters) { | ||
*/ | ||
static create(client) { | ||
return new Authenticator(client); | ||
static create(client2) { | ||
return new Authenticator(client2); | ||
} | ||
@@ -30,4 +31,4 @@ _client; | ||
*/ | ||
constructor(client) { | ||
this._client = client; | ||
constructor(client2) { | ||
this._client = client2; | ||
} | ||
@@ -52,3 +53,3 @@ /** | ||
case types.AuthorizationState$Type.LoggingOut: { | ||
throw new Error("Closing"); | ||
throw new client.TDError("Closing"); | ||
} | ||
@@ -55,0 +56,0 @@ case types.AuthorizationState$Type.WaitCode: { |
@@ -260,3 +260,2 @@ "use strict"; | ||
}); | ||
await this.api.testCallEmpty({}); | ||
} | ||
@@ -263,0 +262,0 @@ /** |
import { $AsyncApi } from './generated/types'; | ||
/** | ||
* To update this types run scripts/scrape-tdlib-options.js | ||
* on https://core.telegram.org/tdlib/options | ||
* | ||
* and copy `readable` and `writable` here | ||
* | ||
*/ | ||
type integer = bigint; | ||
@@ -6,4 +13,2 @@ type TDLibOptionsWritable = { | ||
readonly always_parse_markdown?: boolean; | ||
/** If true, new chats from non-contacts will be automatically archived and muted. The option can be set only if the option “can_archive_and_mute_new_chats_from_unknown_users” is true. getOption needs to be called explicitly to fetch the latest value of the option, changed from another device */ | ||
readonly archive_and_mute_new_chats_from_unknown_users?: boolean; | ||
/** If true, animated emoji will be disabled and shown as plain emoji */ | ||
@@ -13,2 +18,4 @@ readonly disable_animated_emoji?: boolean; | ||
readonly disable_contact_registered_notifications?: boolean; | ||
/** Since TDLib 1.8.24. If true, then network statistics will be completely disabled */ | ||
readonly disable_network_statistics?: boolean; | ||
/** If true, persistent network statistics will be disabled, which significantly reduces disk usage */ | ||
@@ -26,2 +33,4 @@ readonly disable_persistent_network_statistics?: boolean; | ||
readonly ignore_default_disable_notification?: boolean; | ||
/** Since TDLib 1.8.24. If true, document file names will be ignored and numerical names will be used instead */ | ||
readonly ignore_file_names?: boolean; | ||
/** If true, prevents file thumbnails sent by the server along with messages from being saved on the disk */ | ||
@@ -35,2 +44,4 @@ readonly ignore_inline_thumbnails?: boolean; | ||
readonly is_location_visible?: boolean; | ||
/** Since TDLib 1.8.36. If true, added paid reactions are anonymous by default. If false, they are non-anonymous. */ | ||
readonly is_paid_reaction_anonymous?: boolean; | ||
/** Path to a database for storing language pack strings, so that this database can be shared between different accounts. By default, language pack strings are stored only in memory. Changes of value of this option will be applied only after TDLib restart, so it should be set before call to setTdlibParameters. */ | ||
@@ -52,2 +63,4 @@ readonly language_pack_database_path?: string; | ||
readonly prefer_ipv6?: boolean; | ||
/** Since TDLib 1.8.24. If true, then all pinned messages will be treated as mentions even posted without notification of chat members */ | ||
readonly process_pinned_messages_as_mentions?: boolean; | ||
/** If true, Perfect Forward Secrecy will be enabled for interaction with the Telegram servers for cloud chats */ | ||
@@ -61,7 +74,13 @@ readonly use_pfs?: boolean; | ||
readonly utc_time_offset?: integer; | ||
}; | ||
type TDLibOptionsReadable = TDLibOptionsWritable & { | ||
/** Since TDLib 1.8.24. The maximum number of active stories posted by the current user */ | ||
readonly active_story_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of added shareable chat folders for the current user */ | ||
readonly added_shareable_chat_folder_count_max?: integer; | ||
/** Username of a bot which can be used in inline mode for animations search */ | ||
readonly animation_search_bot_username?: string; | ||
}; | ||
type TDLibOptionsReadable = TDLibOptionsWritable & { | ||
/** An authentication token to be used on subsequent authorizations and received when logging out */ | ||
/** Since TDLib 1.8.24. User identifier of the Telegram Anti-Spam bot */ | ||
readonly anti_spam_bot_user_id?: integer; | ||
/** An authentication token to be used on subsequent authorizations */ | ||
readonly authentication_token?: string; | ||
@@ -72,2 +91,12 @@ /** Point in time (Unix timestamp) when authorization was received */ | ||
readonly basic_group_size_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum allowed length of the current user's bio */ | ||
readonly bio_length_max?: integer; | ||
/** Since TDLib 1.8.34. The maximum number of media previews that can be added for a bot */ | ||
readonly bot_media_preview_count_max?: integer; | ||
/** Since TDLib 1.8.28. The maximum number of created short chat links by a Telegram Business account */ | ||
readonly business_chat_link_count_max?: integer; | ||
/** Since TDLib 1.8.28. The maximum allowed length of the start page message of a Telegram Business account */ | ||
readonly business_start_page_message_length_max?: integer; | ||
/** Since TDLib 1.8.28. The maximum allowed length of the start page title of a Telegram Business account */ | ||
readonly business_start_page_title_length_max?: integer; | ||
/** Maximum time to wait for call connection creation to be passed to libtgvoip */ | ||
@@ -79,6 +108,30 @@ readonly call_connect_timeout_ms?: integer; | ||
readonly can_archive_and_mute_new_chats_from_unknown_users?: boolean; | ||
/** Since TDLib 1.8.34. If true, Telegram Stars can be gifted to other users */ | ||
readonly can_gift_stars?: boolean; | ||
/** If true, the option “ignore_sensitive_content_restrictions” can be changed */ | ||
readonly can_ignore_sensitive_content_restrictions?: boolean; | ||
/** Since TDLib 1.8.34. If true, the current weather must be preloaded before adding the media area to the story. Otherwise, weather must be loaded only after the user has chosen weather media area. */ | ||
readonly can_preload_weather?: boolean; | ||
/** Since TDLib 1.8.28. If true, then the current user can change privacy settings for new chats */ | ||
readonly can_set_new_chat_privacy_settings?: boolean; | ||
/** Since TDLib 1.8.24. If true, then the current user can use text entities in story captions */ | ||
readonly can_use_text_entities_in_story_caption?: boolean; | ||
/** Since TDLib 1.8.28. If true, then revenue from sponsored messages in chats can be withdrawn */ | ||
readonly can_withdraw_chat_revenue?: boolean; | ||
/** Identifier of the bot which is shown as the sender of messages sent on behalf of channels when viewed from an outdated client */ | ||
readonly channel_bot_user_id?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of manually chosen reactions for a chat */ | ||
readonly chat_available_reaction_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum boost level available to a chat */ | ||
readonly chat_boost_level_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of always included or excluded chats in a chat folder for the current user */ | ||
readonly chat_folder_chosen_chat_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of chat folders that the current user can have */ | ||
readonly chat_folder_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of shareable chat folders with owned invite links */ | ||
readonly chat_folder_invite_link_count_max?: integer; | ||
/** Since TDLib 1.8.24. The minimum interval between calls to getChatFolderNewChats in shareable chat folders */ | ||
readonly chat_folder_new_chats_update_period?: integer; | ||
/** Since TDLib 1.8.24. If known, the hash of the source code commit that was used to build TDLib. Can be received synchronously. */ | ||
readonly commit_hash?: string; | ||
/** Identifier of the enabled proxy */ | ||
@@ -88,2 +141,4 @@ readonly enabled_proxy_id?: integer; | ||
readonly expect_blocking?: boolean; | ||
/** Since TDLib 1.8.30. The maximum allowed length of a fact-check */ | ||
readonly fact_check_length_max?: integer; | ||
/** Maximum number of favorite stickers */ | ||
@@ -93,18 +148,84 @@ readonly favorite_stickers_limit?: integer; | ||
readonly forwarded_message_count_max?: integer; | ||
/** Since TDLib 1.8.24. If true, then a suggestion to gift Telegram Premium needs to be shown in the attachment menu if appropriate */ | ||
readonly gift_premium_from_attachment_menu?: boolean; | ||
/** Since TDLib 1.8.24. If true, then a suggestion to gift Telegram Premium needs to be shown in the input field if appropriate */ | ||
readonly gift_premium_from_input_field?: boolean; | ||
/** Since TDLib 1.8.37. The maximum length of a message added to a sent gift */ | ||
readonly gift_text_length_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of additional chats that can be added to a giveaway */ | ||
readonly giveaway_additional_chat_count_max?: integer; | ||
/** Since TDLib 1.8.24. The number of boosts that received by the channel for each giveaway prize */ | ||
readonly giveaway_boost_count_per_premium?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of countries that can be added to a giveaway */ | ||
readonly giveaway_country_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of additional chats that can be added to a giveaway */ | ||
readonly giveaway_duration_max?: integer; | ||
/** Identifier of the bot which is shown as the sender of anonymous messages in groups when viewed from an outdated client */ | ||
readonly group_anonymous_bot_user_id?: integer; | ||
/** Since TDLib 1.8.24. If true, then the current user subscribed to Telegram Premium */ | ||
readonly is_premium?: boolean; | ||
/** Since TDLib 1.8.24. If true, then the current user can subscribe to Telegram Premium. Otherwise, all premium-related features must be hidden */ | ||
readonly is_premium_available?: boolean; | ||
/** Maximum length of a message caption */ | ||
readonly message_caption_length_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum length of quote from the replied message */ | ||
readonly message_reply_quote_length_max?: integer; | ||
/** Maximum length of a message text */ | ||
readonly message_text_length_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of stories that can be posted per month by the current user */ | ||
readonly monthly_sent_story_count_max?: integer; | ||
/** Identifier of the current user */ | ||
readonly my_id?: integer; | ||
/** Maximum number of pinned cloud chats in the Archive chat list. The same amount of secret chats can be pinned locally */ | ||
/** Since TDLib 1.8.24. The maximum number of saved notification sounds */ | ||
readonly notification_sound_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum duration of an audio that can be used as a notification sound */ | ||
readonly notification_sound_duration_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum size of the audio file that can be used as a notification sound */ | ||
readonly notification_sound_size_max?: integer; | ||
/** Since TDLib 1.8.32. The maximum price of a paid post in Telegram Stars */ | ||
readonly paid_media_message_star_count_max?: integer; | ||
/** Since TDLib 1.8.35. The maximum number of Telegram Stars that can be added as paid reaction to a message in one request */ | ||
readonly paid_reaction_star_count_max?: integer; | ||
/** Maximum number of pinned cloud chats in the Archive chat list for the current user. The same amount of secret chats can be pinned locally */ | ||
readonly pinned_archived_chat_count_max?: integer; | ||
/** Maximum number of pinned cloud chats in the Main chat list. The same amount of secret chats can be pinned locally */ | ||
/** Maximum number of pinned cloud chats in the Main chat list for the current user. The same amount of secret chats can be pinned locally */ | ||
readonly pinned_chat_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of pinned forum topics */ | ||
readonly pinned_forum_topic_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of pinned topics in Saved Messages for the current user */ | ||
readonly pinned_saved_messages_topic_count_max?: integer; | ||
/** Since TDLib 1.8.29. The maximum number of pinned stories on a chat page */ | ||
readonly pinned_story_count_max?: integer; | ||
/** Username of a bot which can be used in inline mode for photos search */ | ||
readonly photo_search_bot_username?: string; | ||
/** Since TDLib 1.8.28. Approximate number of times file download speed will increase if the user subscribes to Telegram Premium */ | ||
readonly premium_download_speedup?: integer; | ||
/** Since TDLib 1.8.24. The number of boosts that is obtained by gifting Telegram Premium to another user */ | ||
readonly premium_gift_boost_count?: integer; | ||
/** Since TDLib 1.8.28. Approximate number of times file upload speed will increase if the user subscribes to Telegram Premium */ | ||
readonly premium_upload_speedup?: integer; | ||
/** Since TDLib 1.8.28. The maximum number of quick reply shortcuts that can be created by a Telegram Business account */ | ||
readonly quick_reply_shortcut_count_max?: integer; | ||
/** Since TDLib 1.8.28. The maximum number of messages that can be added to a quick reply shortcut by a Telegram Business account */ | ||
readonly quick_reply_shortcut_message_count_max?: integer; | ||
/** Identifier of the @replies bot */ | ||
readonly replies_bot_chat_id?: integer; | ||
/** Since TDLib 1.8.31. The minimum number of Telegram Stars that can be withdrawn */ | ||
readonly star_withdrawal_count_min?: integer; | ||
/** Since TDLib 1.8.24. The maximum length of story caption for the current user */ | ||
readonly story_caption_length_max?: integer; | ||
/** Since TDLib 1.8.31. The maximum number of link areas that can be added to a story by Telegram Premium users */ | ||
readonly story_link_area_count_max?: integer; | ||
/** Since TDLib 1.8.24. The number of seconds that must pass between before Stealth Mode can be enabled again */ | ||
readonly story_stealth_mode_cooldown_period?: integer; | ||
/** Since TDLib 1.8.24. The number of seconds in the future the Stealth Mode will last */ | ||
readonly story_stealth_mode_future_period?: integer; | ||
/** Since TDLib 1.8.24. The number of seconds in the past during which all views of stories from the current user will be hidden if Stealth Mode is enabled */ | ||
readonly story_stealth_mode_past_period?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of suggested reaction areas that can be added to a story */ | ||
readonly story_suggested_reaction_area_count_max?: integer; | ||
/** Since TDLib 1.8.24. The number of seconds after story expiration date for which story viewers still can be received */ | ||
readonly story_viewers_expiration_delay?: integer; | ||
/** Since TDLib 1.8.35. The maximum number of Telegram Stars that can be asked for monthly subscription to a chat */ | ||
readonly subscription_star_count_max?: integer; | ||
/** Identifier of the language pack, suggested for the user by the server */ | ||
@@ -126,8 +247,16 @@ readonly suggested_language_pack_id?: string; | ||
readonly test_mode?: boolean; | ||
/** Since TDLib 1.8.35. The number of US dollars that can be received by withdrawing 1000 Telegram Stars */ | ||
readonly thousand_star_to_usd_rate?: integer; | ||
/** An estimation of the current Unix timestamp. The option will not be updated automatically unless the difference between the previous estimation and the locally available monotonic clocks changes significantly */ | ||
readonly unix_time?: integer; | ||
/** Since TDLib 1.8.35. The number of US dollars needed to buy 1000 Telegram Stars */ | ||
readonly usd_to_thousand_star_rate?: integer; | ||
/** Username of a bot which can be used in inline mode for venues search */ | ||
readonly venue_search_bot_username?: string; | ||
/** TDLib version. This options is guaranteed to come before all other updates since TDLib 1.4.0 */ | ||
/** TDLib version. This options is guaranteed to come before all other updates. Can be received synchronously. */ | ||
readonly version?: string; | ||
/** Since TDLib 1.8.32. A space-separated list of URL protocols that are allowed to be open by the call to web_app_open_link from Web Apps. */ | ||
readonly web_app_allowed_protocols?: string; | ||
/** Since TDLib 1.8.24. The maximum number of stories that can be posted per week by the current user */ | ||
readonly weekly_sent_story_count_max?: integer; | ||
}; | ||
@@ -165,4 +294,7 @@ type AnyKeyof<T extends {}> = keyof T | (string & {}); | ||
/** | ||
* **Waits for `setTdlibParameters` to be called to respond.** | ||
* Exception: "version", "commit_hash" | ||
* | ||
* | ||
* @see {@link https://t.me/tdlibchat/155412} | ||
* @see {@link https://core.telegram.org/tdlib/options} | ||
* @template {Keys} T | ||
@@ -175,4 +307,6 @@ * @param {T} key | ||
/** | ||
* **Waits for `setTdlibParameters` to be called to respond.** | ||
* | ||
* | ||
* @see {@link https://t.me/tdlibchat/155412} | ||
* @see {@link https://core.telegram.org/tdlib/options} | ||
* @template {Keys} T | ||
@@ -186,4 +320,6 @@ * @param {T} key | ||
/** | ||
* **Waits for `setTdlibParameters` to be called to respond.** | ||
* | ||
* | ||
* @see {@link https://t.me/tdlibchat/155412} | ||
* @see {@link https://core.telegram.org/tdlib/options} | ||
* @param {Keys} key | ||
@@ -195,4 +331,6 @@ * @memberof TDLibOptions | ||
/** | ||
* **Waits for `setTdlibParameters` to be called to respond.** | ||
* | ||
* | ||
* @see {@link https://t.me/tdlibchat/155412} | ||
* @see {@link https://core.telegram.org/tdlib/options} | ||
* @param {OptionsWritable} values | ||
@@ -199,0 +337,0 @@ * @memberof TDLibOptions |
"use strict"; | ||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | ||
const types = require("./generated/types.js"); | ||
const warn = require("./warn.js"); | ||
class TDLibOptions { | ||
@@ -27,4 +28,7 @@ /** | ||
/** | ||
* **Waits for `setTdlibParameters` to be called to respond.** | ||
* Exception: "version", "commit_hash" | ||
* | ||
* | ||
* @see {@link https://t.me/tdlibchat/155412} | ||
* @see {@link https://core.telegram.org/tdlib/options} | ||
* @template {Keys} T | ||
@@ -36,3 +40,9 @@ * @param {T} key | ||
async get(key) { | ||
const value = await this._api.getOption({ name: key }).catch(() => ({ [types.typename]: types.OptionValue$Type.Empty })); | ||
const warner = setTimeout(() => { | ||
warn.warnOnce( | ||
"W001", | ||
"tdlibOptions.get() takes to long to respond. This method waits for tdlibParameters to be passed. Use api.setTdlibParameters()" | ||
); | ||
}, 1e3); | ||
const value = await this._api.getOption({ name: key }).catch(() => ({ [types.typename]: types.OptionValue$Type.Empty })).finally(() => clearTimeout(warner)); | ||
switch (value._) { | ||
@@ -51,4 +61,6 @@ case types.OptionValue$Type.Integer: { | ||
/** | ||
* **Waits for `setTdlibParameters` to be called to respond.** | ||
* | ||
* | ||
* @see {@link https://t.me/tdlibchat/155412} | ||
* @see {@link https://core.telegram.org/tdlib/options} | ||
* @template {Keys} T | ||
@@ -80,7 +92,15 @@ * @param {T} key | ||
} | ||
await this._api.setOption({ name: key, value: option }); | ||
const warner = setTimeout(() => { | ||
warn.warnOnce( | ||
"W002", | ||
"tdlibOptions.set() takes to long to respond. This method waits for tdlibParameters to be passed. Use api.setTdlibParameters()" | ||
); | ||
}, 1e3); | ||
await this._api.setOption({ name: key, value: option }).finally(() => clearTimeout(warner)); | ||
} | ||
/** | ||
* **Waits for `setTdlibParameters` to be called to respond.** | ||
* | ||
* | ||
* @see {@link https://t.me/tdlibchat/155412} | ||
* @see {@link https://core.telegram.org/tdlib/options} | ||
* @param {Keys} key | ||
@@ -94,4 +114,6 @@ * @memberof TDLibOptions | ||
/** | ||
* **Waits for `setTdlibParameters` to be called to respond.** | ||
* | ||
* | ||
* @see {@link https://t.me/tdlibchat/155412} | ||
* @see {@link https://core.telegram.org/tdlib/options} | ||
* @param {OptionsWritable} values | ||
@@ -98,0 +120,0 @@ * @memberof TDLibOptions |
{ | ||
"name": "tdlib-native", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "🚀 Telegram TDLib native nodejs wrapper", | ||
@@ -5,0 +5,0 @@ "packageManager": "npm@10.9.0", |
@@ -86,6 +86,11 @@ # TDLib Native | ||
// Start polling responses from TDLib | ||
await client.start(); | ||
await authenticator.authenticate(); | ||
// And authenticate bot | ||
// THIS SHOULD BE USED via Promise.all | ||
// OR ELSE .authenticate() skips an update and hangs | ||
await Promise.all([ | ||
client.start(), | ||
authenticator.authenticate() | ||
]); | ||
// client authorized as bot | ||
// Call any tdlib method | ||
@@ -120,2 +125,37 @@ await client.api.getOption({ name: "version" }); | ||
### Projects built with `tdlib-native` | ||
<table><tbody><tr><td align="center" valign="top" width="11%"> | ||
<a href="https://t.me/guardcore_bot"> | ||
<img | ||
src="https://github.com/AlexXanderGrib/node-tdlib/blob/6b8b34a2134f6ad0510a0e2f2b8c45f5e7c61880/docs/icons/guardcore-bot.jpg?raw=1" | ||
width="75" | ||
height="75" | ||
alt="GuardCore Bot's Avatar" | ||
/><br /> | ||
GuardCore Bot | ||
</a> | ||
</td><td align="center" valign="top" width="11%"> | ||
<a href="https://t.me/tvoya_statya_bot"> | ||
<img | ||
src="https://github.com/AlexXanderGrib/node-tdlib/blob/6b8b34a2134f6ad0510a0e2f2b8c45f5e7c61880/docs/icons/tvoya-statya-bot.jpg?raw=1" | ||
width="75" | ||
height="75" | ||
alt="Твоя Статья УК РФ's Avatar" | ||
/><br /> | ||
Твоя Статья УК РФ | ||
</a> | ||
</td><td align="center" valign="top" width="11%"> | ||
<a href="https://github.com/AlexXanderGrib/node-tdlib/issues/new"> | ||
<img | ||
src="https://github.com/AlexXanderGrib/node-tdlib/blob/6b8b34a2134f6ad0510a0e2f2b8c45f5e7c61880/docs/icons/add.png?raw=1" | ||
width="75" | ||
height="75" | ||
alt="" | ||
/><br /> | ||
Add your project | ||
</a> | ||
</td></tr></tbody></table> | ||
## Credits | ||
@@ -122,0 +162,0 @@ |
@@ -8,3 +8,3 @@ import { describe, test, expect, beforeAll, assert, afterAll } from "vitest"; | ||
describe("Client Serialization (async)", () => { | ||
describe("Client Serialization (async)", { concurrent: true }, () => { | ||
let client: Client; | ||
@@ -11,0 +11,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { Client } from "./client"; | ||
import { Client, TDError } from "./client"; | ||
import { | ||
@@ -141,3 +141,3 @@ setTdlibParameters$DirectInput, | ||
case AuthorizationState$Type.LoggingOut: { | ||
throw new Error("Closing"); | ||
throw new TDError("Closing"); | ||
} | ||
@@ -144,0 +144,0 @@ |
@@ -357,4 +357,2 @@ import type { TDLib, TDLibClient } from "./shared/client"; | ||
}); | ||
await this.api.testCallEmpty({}); | ||
} | ||
@@ -361,0 +359,0 @@ |
@@ -7,3 +7,12 @@ import { | ||
} from "./generated/types"; | ||
import { warnOnce } from "./warn"; | ||
/** | ||
* To update this types run scripts/scrape-tdlib-options.js | ||
* on https://core.telegram.org/tdlib/options | ||
* | ||
* and copy `readable` and `writable` here | ||
* | ||
*/ | ||
type integer = bigint; | ||
@@ -13,4 +22,2 @@ type TDLibOptionsWritable = { | ||
readonly always_parse_markdown?: boolean; | ||
/** If true, new chats from non-contacts will be automatically archived and muted. The option can be set only if the option “can_archive_and_mute_new_chats_from_unknown_users” is true. getOption needs to be called explicitly to fetch the latest value of the option, changed from another device */ | ||
readonly archive_and_mute_new_chats_from_unknown_users?: boolean; | ||
/** If true, animated emoji will be disabled and shown as plain emoji */ | ||
@@ -20,2 +27,4 @@ readonly disable_animated_emoji?: boolean; | ||
readonly disable_contact_registered_notifications?: boolean; | ||
/** Since TDLib 1.8.24. If true, then network statistics will be completely disabled */ | ||
readonly disable_network_statistics?: boolean; | ||
/** If true, persistent network statistics will be disabled, which significantly reduces disk usage */ | ||
@@ -33,2 +42,4 @@ readonly disable_persistent_network_statistics?: boolean; | ||
readonly ignore_default_disable_notification?: boolean; | ||
/** Since TDLib 1.8.24. If true, document file names will be ignored and numerical names will be used instead */ | ||
readonly ignore_file_names?: boolean; | ||
/** If true, prevents file thumbnails sent by the server along with messages from being saved on the disk */ | ||
@@ -42,2 +53,4 @@ readonly ignore_inline_thumbnails?: boolean; | ||
readonly is_location_visible?: boolean; | ||
/** Since TDLib 1.8.36. If true, added paid reactions are anonymous by default. If false, they are non-anonymous. */ | ||
readonly is_paid_reaction_anonymous?: boolean; | ||
/** Path to a database for storing language pack strings, so that this database can be shared between different accounts. By default, language pack strings are stored only in memory. Changes of value of this option will be applied only after TDLib restart, so it should be set before call to setTdlibParameters. */ | ||
@@ -59,2 +72,4 @@ readonly language_pack_database_path?: string; | ||
readonly prefer_ipv6?: boolean; | ||
/** Since TDLib 1.8.24. If true, then all pinned messages will be treated as mentions even posted without notification of chat members */ | ||
readonly process_pinned_messages_as_mentions?: boolean; | ||
/** If true, Perfect Forward Secrecy will be enabled for interaction with the Telegram servers for cloud chats */ | ||
@@ -68,8 +83,14 @@ readonly use_pfs?: boolean; | ||
readonly utc_time_offset?: integer; | ||
} | ||
type TDLibOptionsReadable = TDLibOptionsWritable & { | ||
/** Since TDLib 1.8.24. The maximum number of active stories posted by the current user */ | ||
readonly active_story_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of added shareable chat folders for the current user */ | ||
readonly added_shareable_chat_folder_count_max?: integer; | ||
/** Username of a bot which can be used in inline mode for animations search */ | ||
readonly animation_search_bot_username?: string; | ||
}; | ||
type TDLibOptionsReadable = TDLibOptionsWritable & { | ||
/** An authentication token to be used on subsequent authorizations and received when logging out */ | ||
/** Since TDLib 1.8.24. User identifier of the Telegram Anti-Spam bot */ | ||
readonly anti_spam_bot_user_id?: integer; | ||
/** An authentication token to be used on subsequent authorizations */ | ||
readonly authentication_token?: string; | ||
@@ -80,2 +101,12 @@ /** Point in time (Unix timestamp) when authorization was received */ | ||
readonly basic_group_size_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum allowed length of the current user's bio */ | ||
readonly bio_length_max?: integer; | ||
/** Since TDLib 1.8.34. The maximum number of media previews that can be added for a bot */ | ||
readonly bot_media_preview_count_max?: integer; | ||
/** Since TDLib 1.8.28. The maximum number of created short chat links by a Telegram Business account */ | ||
readonly business_chat_link_count_max?: integer; | ||
/** Since TDLib 1.8.28. The maximum allowed length of the start page message of a Telegram Business account */ | ||
readonly business_start_page_message_length_max?: integer; | ||
/** Since TDLib 1.8.28. The maximum allowed length of the start page title of a Telegram Business account */ | ||
readonly business_start_page_title_length_max?: integer; | ||
/** Maximum time to wait for call connection creation to be passed to libtgvoip */ | ||
@@ -87,6 +118,30 @@ readonly call_connect_timeout_ms?: integer; | ||
readonly can_archive_and_mute_new_chats_from_unknown_users?: boolean; | ||
/** Since TDLib 1.8.34. If true, Telegram Stars can be gifted to other users */ | ||
readonly can_gift_stars?: boolean; | ||
/** If true, the option “ignore_sensitive_content_restrictions” can be changed */ | ||
readonly can_ignore_sensitive_content_restrictions?: boolean; | ||
/** Since TDLib 1.8.34. If true, the current weather must be preloaded before adding the media area to the story. Otherwise, weather must be loaded only after the user has chosen weather media area. */ | ||
readonly can_preload_weather?: boolean; | ||
/** Since TDLib 1.8.28. If true, then the current user can change privacy settings for new chats */ | ||
readonly can_set_new_chat_privacy_settings?: boolean; | ||
/** Since TDLib 1.8.24. If true, then the current user can use text entities in story captions */ | ||
readonly can_use_text_entities_in_story_caption?: boolean; | ||
/** Since TDLib 1.8.28. If true, then revenue from sponsored messages in chats can be withdrawn */ | ||
readonly can_withdraw_chat_revenue?: boolean; | ||
/** Identifier of the bot which is shown as the sender of messages sent on behalf of channels when viewed from an outdated client */ | ||
readonly channel_bot_user_id?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of manually chosen reactions for a chat */ | ||
readonly chat_available_reaction_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum boost level available to a chat */ | ||
readonly chat_boost_level_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of always included or excluded chats in a chat folder for the current user */ | ||
readonly chat_folder_chosen_chat_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of chat folders that the current user can have */ | ||
readonly chat_folder_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of shareable chat folders with owned invite links */ | ||
readonly chat_folder_invite_link_count_max?: integer; | ||
/** Since TDLib 1.8.24. The minimum interval between calls to getChatFolderNewChats in shareable chat folders */ | ||
readonly chat_folder_new_chats_update_period?: integer; | ||
/** Since TDLib 1.8.24. If known, the hash of the source code commit that was used to build TDLib. Can be received synchronously. */ | ||
readonly commit_hash?: string; | ||
/** Identifier of the enabled proxy */ | ||
@@ -96,2 +151,4 @@ readonly enabled_proxy_id?: integer; | ||
readonly expect_blocking?: boolean; | ||
/** Since TDLib 1.8.30. The maximum allowed length of a fact-check */ | ||
readonly fact_check_length_max?: integer; | ||
/** Maximum number of favorite stickers */ | ||
@@ -101,18 +158,84 @@ readonly favorite_stickers_limit?: integer; | ||
readonly forwarded_message_count_max?: integer; | ||
/** Since TDLib 1.8.24. If true, then a suggestion to gift Telegram Premium needs to be shown in the attachment menu if appropriate */ | ||
readonly gift_premium_from_attachment_menu?: boolean; | ||
/** Since TDLib 1.8.24. If true, then a suggestion to gift Telegram Premium needs to be shown in the input field if appropriate */ | ||
readonly gift_premium_from_input_field?: boolean; | ||
/** Since TDLib 1.8.37. The maximum length of a message added to a sent gift */ | ||
readonly gift_text_length_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of additional chats that can be added to a giveaway */ | ||
readonly giveaway_additional_chat_count_max?: integer; | ||
/** Since TDLib 1.8.24. The number of boosts that received by the channel for each giveaway prize */ | ||
readonly giveaway_boost_count_per_premium?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of countries that can be added to a giveaway */ | ||
readonly giveaway_country_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of additional chats that can be added to a giveaway */ | ||
readonly giveaway_duration_max?: integer; | ||
/** Identifier of the bot which is shown as the sender of anonymous messages in groups when viewed from an outdated client */ | ||
readonly group_anonymous_bot_user_id?: integer; | ||
/** Since TDLib 1.8.24. If true, then the current user subscribed to Telegram Premium */ | ||
readonly is_premium?: boolean; | ||
/** Since TDLib 1.8.24. If true, then the current user can subscribe to Telegram Premium. Otherwise, all premium-related features must be hidden */ | ||
readonly is_premium_available?: boolean; | ||
/** Maximum length of a message caption */ | ||
readonly message_caption_length_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum length of quote from the replied message */ | ||
readonly message_reply_quote_length_max?: integer; | ||
/** Maximum length of a message text */ | ||
readonly message_text_length_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of stories that can be posted per month by the current user */ | ||
readonly monthly_sent_story_count_max?: integer; | ||
/** Identifier of the current user */ | ||
readonly my_id?: integer; | ||
/** Maximum number of pinned cloud chats in the Archive chat list. The same amount of secret chats can be pinned locally */ | ||
/** Since TDLib 1.8.24. The maximum number of saved notification sounds */ | ||
readonly notification_sound_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum duration of an audio that can be used as a notification sound */ | ||
readonly notification_sound_duration_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum size of the audio file that can be used as a notification sound */ | ||
readonly notification_sound_size_max?: integer; | ||
/** Since TDLib 1.8.32. The maximum price of a paid post in Telegram Stars */ | ||
readonly paid_media_message_star_count_max?: integer; | ||
/** Since TDLib 1.8.35. The maximum number of Telegram Stars that can be added as paid reaction to a message in one request */ | ||
readonly paid_reaction_star_count_max?: integer; | ||
/** Maximum number of pinned cloud chats in the Archive chat list for the current user. The same amount of secret chats can be pinned locally */ | ||
readonly pinned_archived_chat_count_max?: integer; | ||
/** Maximum number of pinned cloud chats in the Main chat list. The same amount of secret chats can be pinned locally */ | ||
/** Maximum number of pinned cloud chats in the Main chat list for the current user. The same amount of secret chats can be pinned locally */ | ||
readonly pinned_chat_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of pinned forum topics */ | ||
readonly pinned_forum_topic_count_max?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of pinned topics in Saved Messages for the current user */ | ||
readonly pinned_saved_messages_topic_count_max?: integer; | ||
/** Since TDLib 1.8.29. The maximum number of pinned stories on a chat page */ | ||
readonly pinned_story_count_max?: integer; | ||
/** Username of a bot which can be used in inline mode for photos search */ | ||
readonly photo_search_bot_username?: string; | ||
/** Since TDLib 1.8.28. Approximate number of times file download speed will increase if the user subscribes to Telegram Premium */ | ||
readonly premium_download_speedup?: integer; | ||
/** Since TDLib 1.8.24. The number of boosts that is obtained by gifting Telegram Premium to another user */ | ||
readonly premium_gift_boost_count?: integer; | ||
/** Since TDLib 1.8.28. Approximate number of times file upload speed will increase if the user subscribes to Telegram Premium */ | ||
readonly premium_upload_speedup?: integer; | ||
/** Since TDLib 1.8.28. The maximum number of quick reply shortcuts that can be created by a Telegram Business account */ | ||
readonly quick_reply_shortcut_count_max?: integer; | ||
/** Since TDLib 1.8.28. The maximum number of messages that can be added to a quick reply shortcut by a Telegram Business account */ | ||
readonly quick_reply_shortcut_message_count_max?: integer; | ||
/** Identifier of the @replies bot */ | ||
readonly replies_bot_chat_id?: integer; | ||
/** Since TDLib 1.8.31. The minimum number of Telegram Stars that can be withdrawn */ | ||
readonly star_withdrawal_count_min?: integer; | ||
/** Since TDLib 1.8.24. The maximum length of story caption for the current user */ | ||
readonly story_caption_length_max?: integer; | ||
/** Since TDLib 1.8.31. The maximum number of link areas that can be added to a story by Telegram Premium users */ | ||
readonly story_link_area_count_max?: integer; | ||
/** Since TDLib 1.8.24. The number of seconds that must pass between before Stealth Mode can be enabled again */ | ||
readonly story_stealth_mode_cooldown_period?: integer; | ||
/** Since TDLib 1.8.24. The number of seconds in the future the Stealth Mode will last */ | ||
readonly story_stealth_mode_future_period?: integer; | ||
/** Since TDLib 1.8.24. The number of seconds in the past during which all views of stories from the current user will be hidden if Stealth Mode is enabled */ | ||
readonly story_stealth_mode_past_period?: integer; | ||
/** Since TDLib 1.8.24. The maximum number of suggested reaction areas that can be added to a story */ | ||
readonly story_suggested_reaction_area_count_max?: integer; | ||
/** Since TDLib 1.8.24. The number of seconds after story expiration date for which story viewers still can be received */ | ||
readonly story_viewers_expiration_delay?: integer; | ||
/** Since TDLib 1.8.35. The maximum number of Telegram Stars that can be asked for monthly subscription to a chat */ | ||
readonly subscription_star_count_max?: integer; | ||
/** Identifier of the language pack, suggested for the user by the server */ | ||
@@ -134,12 +257,21 @@ readonly suggested_language_pack_id?: string; | ||
readonly test_mode?: boolean; | ||
/** Since TDLib 1.8.35. The number of US dollars that can be received by withdrawing 1000 Telegram Stars */ | ||
readonly thousand_star_to_usd_rate?: integer; | ||
/** An estimation of the current Unix timestamp. The option will not be updated automatically unless the difference between the previous estimation and the locally available monotonic clocks changes significantly */ | ||
readonly unix_time?: integer; | ||
/** Since TDLib 1.8.35. The number of US dollars needed to buy 1000 Telegram Stars */ | ||
readonly usd_to_thousand_star_rate?: integer; | ||
/** Username of a bot which can be used in inline mode for venues search */ | ||
readonly venue_search_bot_username?: string; | ||
/** TDLib version. This options is guaranteed to come before all other updates since TDLib 1.4.0 */ | ||
/** TDLib version. This options is guaranteed to come before all other updates. Can be received synchronously. */ | ||
readonly version?: string; | ||
}; | ||
/** Since TDLib 1.8.32. A space-separated list of URL protocols that are allowed to be open by the call to web_app_open_link from Web Apps. */ | ||
readonly web_app_allowed_protocols?: string; | ||
/** Since TDLib 1.8.24. The maximum number of stories that can be posted per week by the current user */ | ||
readonly weekly_sent_story_count_max?: integer; | ||
} | ||
type AnyKeyof<T extends {}> = keyof T | (string & {}); | ||
type Extendable<T extends {}> = T & Readonly<Record<string, string | boolean | bigint | number | undefined>>; | ||
type Extendable<T extends {}> = T & | ||
Readonly<Record<string, string | boolean | bigint | number | undefined>>; | ||
@@ -184,4 +316,7 @@ type Keys = AnyKeyof<TDLibOptionsReadable>; | ||
/** | ||
* **Waits for `setTdlibParameters` to be called to respond.** | ||
* Exception: "version", "commit_hash" | ||
* | ||
* | ||
* @see {@link https://t.me/tdlibchat/155412} | ||
* @see {@link https://core.telegram.org/tdlib/options} | ||
* @template {Keys} T | ||
@@ -193,5 +328,13 @@ * @param {T} key | ||
async get<T extends Keys>(key: T): Promise<OptionsReadable[T]> { | ||
const warner = setTimeout(() => { | ||
warnOnce( | ||
"W001", | ||
"tdlibOptions.get() takes to long to respond. This method waits for tdlibParameters to be passed. Use api.setTdlibParameters()" | ||
); | ||
}, 1000); | ||
const value = await this._api | ||
.getOption({ name: key }) | ||
.catch((): OptionValue => ({ [typename]: OptionValue$Type.Empty })); | ||
.catch((): OptionValue => ({ [typename]: OptionValue$Type.Empty })) | ||
.finally(() => clearTimeout(warner)); | ||
@@ -214,4 +357,6 @@ switch (value._) { | ||
/** | ||
* **Waits for `setTdlibParameters` to be called to respond.** | ||
* | ||
* | ||
* @see {@link https://t.me/tdlibchat/155412} | ||
* @see {@link https://core.telegram.org/tdlib/options} | ||
* @template {Keys} T | ||
@@ -250,8 +395,19 @@ * @param {T} key | ||
await this._api.setOption({ name: key, value: option }); | ||
const warner = setTimeout(() => { | ||
warnOnce( | ||
"W002", | ||
"tdlibOptions.set() takes to long to respond. This method waits for tdlibParameters to be passed. Use api.setTdlibParameters()" | ||
); | ||
}, 1000); | ||
await this._api | ||
.setOption({ name: key, value: option }) | ||
.finally(() => clearTimeout(warner)); | ||
} | ||
/** | ||
* **Waits for `setTdlibParameters` to be called to respond.** | ||
* | ||
* | ||
* @see {@link https://t.me/tdlibchat/155412} | ||
* @see {@link https://core.telegram.org/tdlib/options} | ||
* @param {Keys} key | ||
@@ -266,4 +422,6 @@ * @memberof TDLibOptions | ||
/** | ||
* **Waits for `setTdlibParameters` to be called to respond.** | ||
* | ||
* | ||
* @see {@link https://t.me/tdlibchat/155412} | ||
* @see {@link https://core.telegram.org/tdlib/options} | ||
* @param {OptionsWritable} values | ||
@@ -270,0 +428,0 @@ * @memberof TDLibOptions |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
8622739
87
251322
0
167