diff --git a/.travis.yml b/.travis.yml index eada9ea..74c7dfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: ruby rvm: -- 2.3.8 -- 2.6.0 +- 2.4.9 +- 2.6.5 addons: apt: sources: diff --git a/ChangeLog.md b/ChangeLog.md index f600977..23a6040 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,8 @@ +### 2.1.0 / 2019-10-18 + +* Support tdlib 1.5 +* Fix TD::Client#dispose race condition and client crash + ### 2.0.0 / 2019-02-08 * Generated types and client functions diff --git a/README.md b/README.md index 5e1ba88..26e7251 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Ruby bindings and client for TDLib (Telegram database library). ## Requirements -* Ruby 2.3+ +* Ruby 2.4+ * Compiled [tdlib](https://github.com/tdlib/td) We have precompiled versions for CentOS 6 & 7 in our repositories: @@ -29,6 +29,7 @@ http://rpms.southbridge.ru/rhel6/stable/SRPMS/ |:-------------:|:-:| :-----------: | | 1.x | → | 1.0 - 1.2 | | 2.0 | → | 1.3 | +| 2.1 | → | 1.5 | ## Install @@ -83,7 +84,7 @@ begin when :wait_phone_number puts 'Please, enter your phone number:' phone = STDIN.gets.strip - client.set_authentication_phone_number(phone).wait + client.set_authentication_phone_number(phone, nil).wait when :wait_code puts 'Please, enter code from SMS:' code = STDIN.gets.strip @@ -154,6 +155,12 @@ TD::Client.new(database_directory: 'will override value from config', files_directory: 'will override value from config') ``` +If the tdlib schema changes, then `./bin/parse` can be run to +synchronize the Ruby types with the new schema. Please look through +`lib/tdlib/client_methods.rb` carefully, especially the set_password +method! + + ## License [MIT](https://github.com/centosadmin/tdlib-ruby/blob/master/LICENSE.txt) diff --git a/bin/parser b/bin/parser index e705f37..4d048e7 100755 --- a/bin/parser +++ b/bin/parser @@ -1,9 +1,10 @@ #!/usr/bin/env ruby - +require 'open-uri' require 'active_support/all' AUTOLOAD_BASE_DIR = 'tdlib/types' -TD_API_TL_LOCATION = File.join(File.expand_path("../../", __FILE__), %w(td td generate scheme td_api.tl)) +TD_API_TL_LOCATION = "https://raw.githubusercontent.com/tdlib/td/v1.5.0/td/generate/scheme/td_api.tl" + def parse_tl_type(type) if (vector = type.scan(/[vV]ector<(.*)>/)).length > 0 @@ -207,9 +208,12 @@ def attrs_to_yard_comment(attrs, key = 'attr') end.join("\n") end -puts "Creating types directory" +puts "Removing lib/tdlib/types" +# `find lib/tdlib/types | grep -v base.rb | xargs rm -rf` +`rm -rf lib/tdlib/types` -FileUtils.mkdir_p "types" +puts "MKDIR 'lib/tdlib/types'" +FileUtils.mkdir_p "lib/tdlib/types" puts "Writing Base class" @@ -245,12 +249,13 @@ module TD::Types end RUBY +puts "Writing 'lib/tdlib/types/base.rb'" File.write 'lib/tdlib/types/base.rb', klass -puts "Parsing td_api.tl" +puts "Parsing #{TD_API_TL_LOCATION}" # Reading the TL file and splitting it into classes and functions -@classes, @functions = File.read(TD_API_TL_LOCATION).split("\n\n---functions---\n\n") +@classes, @functions = open(TD_API_TL_LOCATION).read.split("\n\n---functions---\n\n") # First entry in td_api.tl is typecasting, it's worthless for us. # Last entry before functions is a testing class, once again worthless @@ -267,6 +272,7 @@ puts "Converting classes into Ruby types" @lookup_table = build_lookup_table(@classes) @lookup_regex = Regexp.union(@lookup_table.keys.select { |k| k.match?(/[a-z]+[A-Z][a-z]+/) }.map { |k| /\W#{k}\W/ }) + @classes.each do |class_info| class_name = normalize_class_name(class_info[:class], class_info[:super_class]) attributes = class_info[:arguments] @@ -292,7 +298,8 @@ puts "Converting classes into Ruby types" file_name = "#{super_class_name.underscore}/#{class_name.sub(super_class_name, '').underscore}" class_name = "#{super_class_name}::#{class_name.sub(super_class_name, '')} < #{super_class_name}" - FileUtils.mkdir_p "types/#{super_class_name.underscore}" + puts "MKDIR 'lib/tdlib/types/#{super_class_name.underscore}'" + FileUtils.mkdir_p "lib/tdlib/types/#{super_class_name.underscore}" end if attributes.blank? @@ -317,6 +324,7 @@ module TD::Types#{description}#{attributes_doc} end RUBY + puts "Writing 'lib/tdlib/types/#{file_name}.rb'" File.write "lib/tdlib/types/#{file_name}.rb", klass end @@ -384,6 +392,7 @@ module TD::Types end RUBY +puts "Writing 'lib/tdlib/types.rb'" File.write 'lib/tdlib/types.rb', klass puts "Converting functions" @@ -407,10 +416,21 @@ puts "Converting functions" else params_doc = "\n" + attrs_to_yard_comment(params, 'param') - # TODO: Fix mixup of =nil params (only in set_password) - method_params = params.map do |attr, info| - "#{attr}#{ " = nil" if info[:optional] }" - end.join(", ") + if method_name == 'set_password' + method_params = params.map do |attr, info| + #set default value to false + if attr == 'set_recovery_email_address' + "#{attr}: false" + else + # use named arguments + "#{attr}#{ ": nil" if info[:optional] }" + end + end.join(", ") + else + method_params = params.map do |attr, info| + "#{attr}#{ " = nil" if info[:optional] }" + end.join(", ") + end method_params = "(#{wrap_params(method_params, 118 - (method_name.length + 5), method_name.length + 7)})" @@ -442,6 +462,7 @@ module TD::ClientMethods #{@functions.join(" \n")}end RUBY +puts "Writing 'lib/tdlib/client_methods.rb'" File.write 'lib/tdlib/client_methods.rb', klass puts "Done. Please look through client_methods.rb carefully, especially the set_password method!" diff --git a/lib/tdlib/client.rb b/lib/tdlib/client.rb index 54356a9..8f17cf7 100644 --- a/lib/tdlib/client.rb +++ b/lib/tdlib/client.rb @@ -49,7 +49,7 @@ def connect end end - @update_manager.run + @update_manager.run(callback: method(:handle_update)) ready end @@ -149,10 +149,7 @@ def on_ready(&action) # Stops update manager and destroys TDLib client def dispose return if dead? - @update_manager.stop - @alive = false - @ready = false - TD::Api.client_destroy(@td_client) + close.then { get_authorization_state } end def alive? @@ -169,6 +166,14 @@ def ready? private + def handle_update(update) + return unless update.is_a?(TD::Types::AuthorizationState::Closed) + @alive = false + @ready = false + TD::Api.client_destroy(@td_client) + throw(:client_closed) + end + def send_to_td_client(query) return unless alive? TD::Api.client_send(@td_client, query) diff --git a/lib/tdlib/client_methods.rb b/lib/tdlib/client_methods.rb index b74e613..7e6bb15 100644 --- a/lib/tdlib/client_methods.rb +++ b/lib/tdlib/client_methods.rb @@ -28,10 +28,10 @@ def accept_terms_of_service(terms_of_service_id) # @param chat_id [Integer] Chat identifier. # @param user_id [Integer] Identifier of the user. # @param forward_limit [Integer] The number of earlier messages from the chat to be forwarded to the new member; up - # to 300. + # to 100. # Ignored for supergroups and channels. # @return [TD::Types::Ok] - def add_chat_member(chat_id, user_id, forward_limit: 300) + def add_chat_member(chat_id, user_id, forward_limit) broadcast('@type' => 'addChatMember', 'chat_id' => chat_id, 'user_id' => user_id, @@ -53,6 +53,17 @@ def add_chat_members(chat_id, user_ids) 'user_ids' => user_ids) end + # Adds a custom server language pack to the list of installed language packs in current localization target. + # Can be called before authorization. + # + # @param language_pack_id [String] Identifier of a language pack to be added; may be different from a name that is + # used in an "https://t.me/setlanguage/" link. + # @return [TD::Types::Ok] + def add_custom_server_language_pack(language_pack_id) + broadcast('@type' => 'addCustomServerLanguagePack', + 'language_pack_id' => language_pack_id) + end + # Adds a new sticker to the list of favorite stickers. # The new sticker is added to the top of the list. # If the sticker was already in the list, it is removed from the list first. @@ -67,6 +78,7 @@ def add_favorite_sticker(sticker) # Adds a local message to a chat. # The message is persistent across application restarts only if the message database is used. + # Returns the added message. # # @param chat_id [Integer] Target chat. # @param sender_user_id [Integer] Identifier of the user who will be shown as the sender of the message; may be 0 for @@ -74,9 +86,8 @@ def add_favorite_sticker(sticker) # @param reply_to_message_id [Integer] Identifier of the message to reply to or 0. # @param disable_notification [Boolean] Pass true to disable notification for the message. # @param input_message_content [TD::Types::InputMessageContent] The content of the message to be added. - # @return [TD::Types::Message] the added message. - def add_local_message(chat_id, input_message_content, - sender_user_id: 0, reply_to_message_id: 0, disable_notification: false) + # @return [TD::Types::Message] + def add_local_message(chat_id, sender_user_id, reply_to_message_id, disable_notification, input_message_content) broadcast('@type' => 'addLocalMessage', 'chat_id' => chat_id, 'sender_user_id' => sender_user_id, @@ -85,6 +96,20 @@ def add_local_message(chat_id, input_message_content, 'input_message_content' => input_message_content) end + # Adds a message to TDLib internal log. + # This is an offline method. + # Can be called before authorization. + # Can be called synchronously. + # + # @param verbosity_level [Integer] Minimum verbosity level needed for the message to be logged, 0-1023. + # @param text [String] Text of a message to log. + # @return [TD::Types::Ok] + def add_log_message(verbosity_level, text) + broadcast('@type' => 'addLogMessage', + 'verbosity_level' => verbosity_level, + 'text' => text) + end + # Adds the specified data to data usage statistics. # Can be called before authorization. # @@ -104,7 +129,7 @@ def add_network_statistics(entry) # @param enable [Boolean] True, if the proxy should be enabled. # @param type [TD::Types::ProxyType] Proxy type. # @return [TD::Types::Proxy] - def add_proxy(server, port, type, enable = false) + def add_proxy(server, port, enable, type) broadcast('@type' => 'addProxy', 'server' => server, 'port' => port, @@ -121,7 +146,7 @@ def add_proxy(server, port, type, enable = false) # video files; pass false to add the sticker to the list of recently sent stickers. # @param sticker [TD::Types::InputFile] Sticker file to add. # @return [TD::Types::Stickers] - def add_recent_sticker(sticker, is_attached: false) + def add_recent_sticker(is_attached, sticker) broadcast('@type' => 'addRecentSticker', 'is_attached' => is_attached, 'sticker' => sticker) @@ -144,7 +169,8 @@ def add_recently_found_chat(chat_id) # Only non-secret video animations with MIME type "video/mp4" can be added to the list. # # @param animation [TD::Types::InputFile] The animation file to be added. - # Only animations known to the server (i.e. successfully sent via a message) can be added to the list. + # Only animations known to the server (i.e. + # successfully sent via a message) can be added to the list. # @return [TD::Types::Ok] def add_saved_animation(animation) broadcast('@type' => 'addSavedAnimation', @@ -152,11 +178,12 @@ def add_saved_animation(animation) end # Adds a new sticker to a set; for bots only. + # Returns the sticker set. # # @param user_id [Integer] Sticker set owner. # @param name [String] Sticker set name. # @param sticker [TD::Types::InputSticker] Sticker to add to the set. - # @return [TD::Types::StickerSet] the sticker set. + # @return [TD::Types::StickerSet] def add_sticker_to_set(user_id, name, sticker) broadcast('@type' => 'addStickerToSet', 'user_id' => user_id, @@ -218,9 +245,9 @@ def answer_inline_query(inline_query_id, is_personal, results, cache_time, next_ # Sets the result of a pre-checkout query; for bots only. # # @param pre_checkout_query_id [Integer] Identifier of the pre-checkout query. - # @param error_message [String, nil] An error message, empty on success. + # @param error_message [String] An error message, empty on success. # @return [TD::Types::Ok] - def answer_pre_checkout_query(pre_checkout_query_id, error_message: nil) + def answer_pre_checkout_query(pre_checkout_query_id, error_message) broadcast('@type' => 'answerPreCheckoutQuery', 'pre_checkout_query_id' => pre_checkout_query_id, 'error_message' => error_message) @@ -230,9 +257,9 @@ def answer_pre_checkout_query(pre_checkout_query_id, error_message: nil) # # @param shipping_query_id [Integer] Identifier of the shipping query. # @param shipping_options [Array] Available shipping options. - # @param error_message [String, nil] An error message, empty on success. + # @param error_message [String] An error message, empty on success. # @return [TD::Types::Ok] - def answer_shipping_query(shipping_query_id, shipping_options, error_message: nil) + def answer_shipping_query(shipping_query_id, shipping_options, error_message) broadcast('@type' => 'answerShippingQuery', 'shipping_query_id' => shipping_query_id, 'shipping_options' => shipping_options, @@ -255,14 +282,14 @@ def block_user(user_id) # @param only_if_pending [Boolean] Pass true to stop downloading only if it hasn't been started, i.e. # request hasn't been sent to server. # @return [TD::Types::Ok] - def cancel_download_file(file_id, only_if_pending: false) + def cancel_download_file(file_id, only_if_pending) broadcast('@type' => 'cancelDownloadFile', 'file_id' => file_id, 'only_if_pending' => only_if_pending) end # Stops the uploading of a file. - # Supported only for files uploaded by using {#upload_file}. + # Supported only for files uploaded by using uploadFile. # For other files the behavior is undefined. # # @param file_id [Integer] Identifier of the file to stop uploading. @@ -272,9 +299,9 @@ def cancel_upload_file(file_id) 'file_id' => file_id) end - # Used to let the server know whether a chat is spam or not. - # Can be used only if {TD::Types::ChatReportSpamState#can_report_spam} is true. - # After this request, {TD::Types::ChatReportSpamState#can_report_spam} becomes false forever. + # Reports to the server whether a chat is a spam chat or not. + # Can be used only if ChatReportSpamState.can_report_spam is true. + # After this request, ChatReportSpamState.can_report_spam becomes false forever. # # @param chat_id [Integer] Chat identifier. # @param is_spam_chat [Boolean] If true, the chat will be reported as spam; otherwise it will be marked as not spam. @@ -298,17 +325,16 @@ def change_imported_contacts(contacts) end # Changes the phone number of the user and sends an authentication code to the user's new phone number. + # On success, returns information about the sent code. # # @param phone_number [String] The new phone number of the user in international format. - # @param allow_flash_call [Boolean] Pass true if the code can be sent via flash call to the specified phone number. - # @param is_current_phone_number [Boolean] Pass true if the phone number is used on the current device. - # Ignored if allow_flash_call is false. - # @return [TD::Types::AuthenticationCodeInfo] On success, returns information about the sent code. - def change_phone_number(phone_number, allow_flash_call: false, is_current_phone_number: false) - broadcast('@type' => 'changePhoneNumber', - 'phone_number' => phone_number, - 'allow_flash_call' => allow_flash_call, - 'is_current_phone_number' => is_current_phone_number) + # @param settings [TD::Types::PhoneNumberAuthenticationSettings] Settings for the authentication of the user's phone + # number. + # @return [TD::Types::AuthenticationCodeInfo] + def change_phone_number(phone_number, settings) + broadcast('@type' => 'changePhoneNumber', + 'phone_number' => phone_number, + 'settings' => settings) end # Installs/uninstalls or activates/archives a sticker set. @@ -326,8 +352,8 @@ def change_sticker_set(set_id, is_installed, is_archived) end # Checks the authentication token of a bot; to log in as a bot. - # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitPhoneNumber}. - # Can be used instead of {#set_authentication_phone_number} and {#check_authentication_code} to log in. + # Works only when the current authorization state is authorizationStateWaitPhoneNumber. + # Can be used instead of setAuthenticationPhoneNumber and checkAuthenticationCode to log in. # # @param token [String] The bot token. # @return [TD::Types::Ok] @@ -337,22 +363,17 @@ def check_authentication_bot_token(token) end # Checks the authentication code. - # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitCode}. + # Works only when the current authorization state is authorizationStateWaitCode. # # @param code [String] The verification code received via SMS, Telegram message, phone call, or flash call. - # @param first_name [String, nil] If the user is not yet registered, the first name of the user; 1-255 characters. - # @param last_name [String, nil] If the user is not yet registered; the last name of the user; optional; 0-255 - # characters. # @return [TD::Types::Ok] - def check_authentication_code(code, first_name = nil, last_name = nil) - broadcast('@type' => 'checkAuthenticationCode', - 'code' => code, - 'first_name' => first_name, - 'last_name' => last_name) + def check_authentication_code(code) + broadcast('@type' => 'checkAuthenticationCode', + 'code' => code) end # Checks the authentication password for correctness. - # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitPassword}. + # Works only when the current authorization state is authorizationStateWaitPassword. # # @param password [String] The password to check. # @return [TD::Types::Ok] @@ -393,7 +414,7 @@ def check_chat_username(chat_id, username) end # Checks the database encryption key for correctness. - # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitEncryptionKey}. + # Works only when the current authorization state is authorizationStateWaitEncryptionKey. # # @param encryption_key [String] Encryption key to check or set up. # @return [TD::Types::Ok] @@ -429,6 +450,15 @@ def check_phone_number_verification_code(code) 'code' => code) end + # Checks the 2-step verification recovery email address verification code. + # + # @param code [String] Verification code. + # @return [TD::Types::PasswordState] + def check_recovery_email_address_code(code) + broadcast('@type' => 'checkRecoveryEmailAddressCode', + 'code' => code) + end + # Removes potentially dangerous characters from the name of a file. # The encoding of the file name is supposed to be UTF-8. # Returns an empty string on failure. @@ -452,7 +482,7 @@ def clear_all_draft_messages(exclude_secret_chats) 'exclude_secret_chats' => exclude_secret_chats) end - # Clears all imported contacts, contacts list remains unchanged. + # Clears all imported contacts, contact list remains unchanged. # # @return [TD::Types::Ok] def clear_imported_contacts @@ -464,7 +494,7 @@ def clear_imported_contacts # @param is_attached [Boolean] Pass true to clear the list of stickers recently attached to photo or video files; # pass false to clear the list of recently sent stickers. # @return [TD::Types::Ok] - def clear_recent_stickers(is_attached = false) + def clear_recent_stickers(is_attached) broadcast('@type' => 'clearRecentStickers', 'is_attached' => is_attached) end @@ -478,15 +508,14 @@ def clear_recently_found_chats # Closes the TDLib instance. # All databases will be flushed to disk and properly closed. - # After the close completes, {TD::Types::Update::AuthorizationState} with {TD::Types::AuthorizationState::Closed} - # will be sent. + # After the close completes, updateAuthorizationState with authorizationStateClosed will be sent. # # @return [TD::Types::Ok] def close broadcast('@type' => 'close') end - # This method should be called if the chat is closed by the user. + # Informs TDLib that the chat is closed by the user. # Many useful activities depend on the chat being opened or closed. # # @param chat_id [Integer] Chat identifier. @@ -496,7 +525,7 @@ def close_chat(chat_id) 'chat_id' => chat_id) end - # Closes a secret chat, effectively transfering its state to {TD::Types::SecretChatState::Closed}. + # Closes a secret chat, effectively transfering its state to secretChatStateClosed. # # @param secret_chat_id [Integer] Secret chat identifier. # @return [TD::Types::Ok] @@ -511,7 +540,7 @@ def close_secret_chat(secret_chat_id) # @param force [Boolean] If true, the chat will be created without network request. # In this case all information about the chat except its type, title and photo can be incorrect. # @return [TD::Types::Chat] - def create_basic_group_chat(basic_group_id, force = false) + def create_basic_group_chat(basic_group_id, force) broadcast('@type' => 'createBasicGroupChat', 'basic_group_id' => basic_group_id, 'force' => force) @@ -528,11 +557,12 @@ def create_call(user_id, protocol) 'protocol' => protocol) end - # Creates a new basic group and sends a corresponding {TD::Types::MessageContent::BasicGroupChatCreate}. + # Creates a new basic group and sends a corresponding messageBasicGroupChatCreate. + # Returns the newly created chat. # # @param user_ids [Array] Identifiers of users to be added to the basic group. - # @param title [String] Title of the new basic group; 1-255 characters. - # @return [TD::Types::Chat] the newly created chat. + # @param title [String] Title of the new basic group; 1-128 characters. + # @return [TD::Types::Chat] def create_new_basic_group_chat(user_ids, title) broadcast('@type' => 'createNewBasicGroupChat', 'user_ids' => user_ids, @@ -540,15 +570,17 @@ def create_new_basic_group_chat(user_ids, title) end # Creates a new secret chat. + # Returns the newly created chat. # # @param user_id [Integer] Identifier of the target user. - # @return [TD::Types::Chat] the newly created chat. + # @return [TD::Types::Chat] def create_new_secret_chat(user_id) broadcast('@type' => 'createNewSecretChat', 'user_id' => user_id) end # Creates a new sticker set; for bots only. + # Returns the newly created sticker set. # # @param user_id [Integer] Sticker set owner. # @param title [String] Sticker set title; 1-64 characters. @@ -557,8 +589,8 @@ def create_new_secret_chat(user_id) # Must end with *"_by_"* (** is case insensitive); 1-64 characters. # @param is_masks [Boolean] True, if stickers are masks. # @param stickers [Array] List of stickers to be added to the set. - # @return [TD::Types::StickerSet] the newly created sticker set. - def create_new_sticker_set(user_id, title, name, stickers, is_masks: false) + # @return [TD::Types::StickerSet] + def create_new_sticker_set(user_id, title, name, is_masks, stickers) broadcast('@type' => 'createNewStickerSet', 'user_id' => user_id, 'title' => title, @@ -567,13 +599,14 @@ def create_new_sticker_set(user_id, title, name, stickers, is_masks: false) 'stickers' => stickers) end - # Creates a new supergroup or channel and sends a corresponding {TD::Types::MessageContent::SupergroupChatCreate}. + # Creates a new supergroup or channel and sends a corresponding messageSupergroupChatCreate. + # Returns the newly created chat. # - # @param title [String] Title of the new chat; 1-255 characters. + # @param title [String] Title of the new chat; 1-128 characters. # @param is_channel [Boolean] True, if a channel chat should be created. # @param description [String] Chat description; 0-255 characters. - # @return [TD::Types::Chat] the newly created chat. - def create_new_supergroup_chat(title, description, is_channel: false) + # @return [TD::Types::Chat] + def create_new_supergroup_chat(title, is_channel, description) broadcast('@type' => 'createNewSupergroupChat', 'title' => title, 'is_channel' => is_channel, @@ -586,7 +619,7 @@ def create_new_supergroup_chat(title, description, is_channel: false) # @param force [Boolean] If true, the chat will be created without network request. # In this case all information about the chat except its type, title and photo can be incorrect. # @return [TD::Types::Chat] - def create_private_chat(user_id, force = false) + def create_private_chat(user_id, force) broadcast('@type' => 'createPrivateChat', 'user_id' => user_id, 'force' => force) @@ -607,7 +640,7 @@ def create_secret_chat(secret_chat_id) # @param force [Boolean] If true, the chat will be created without network request. # In this case all information about the chat except its type, title and photo can be incorrect. # @return [TD::Types::Chat] - def create_supergroup_chat(supergroup_id, force = false) + def create_supergroup_chat(supergroup_id, force) broadcast('@type' => 'createSupergroupChat', 'supergroup_id' => supergroup_id, 'force' => force) @@ -627,8 +660,7 @@ def create_temporary_password(password, valid_for) # Deletes the account of the current user, deleting all information associated with the user from the server. # The phone number of the account can be used to create a new account. - # Can be called before authorization when the current authorization state is - # {TD::Types::AuthorizationState::WaitPassword}. + # Can be called before authorization when the current authorization state is authorizationStateWaitPassword. # # @param reason [String, nil] The reason why the account was deleted; optional. # @return [TD::Types::Ok] @@ -637,16 +669,19 @@ def delete_account(reason = nil) 'reason' => reason) end - # Deletes all messages in the chat only for the user. - # Cannot be used in channels and public supergroups. + # Deletes all messages in the chat. + # Use Chat.can_be_deleted_only_for_self and Chat.can_be_deleted_for_all_users fields to find whether and how the + # method can be applied to the chat. # # @param chat_id [Integer] Chat identifier. - # @param remove_from_chat_list [Boolean] Pass true if the chat should be removed from the chats list. + # @param remove_from_chat_list [Boolean] Pass true if the chat should be removed from the chat list. + # @param revoke [Boolean] Pass true to try to delete chat history for all users. # @return [TD::Types::Ok] - def delete_chat_history(chat_id, remove_from_chat_list = false) + def delete_chat_history(chat_id, remove_from_chat_list, revoke) broadcast('@type' => 'deleteChatHistory', 'chat_id' => chat_id, - 'remove_from_chat_list' => remove_from_chat_list) + 'remove_from_chat_list' => remove_from_chat_list, + 'revoke' => revoke) end # Deletes all messages sent by the specified user to a chat. @@ -684,7 +719,9 @@ def delete_file(file_id) end # Deletes all information about a language pack in the current localization target. - # The language pack that is currently in use can't be deleted. + # The language pack which is currently in use (including base language pack) or is being synchronized can't be + # deleted. + # Can be called before authorization. # # @param language_pack_id [String] Identifier of the language pack to delete. # @return [TD::Types::Ok] @@ -697,11 +734,10 @@ def delete_language_pack(language_pack_id) # # @param chat_id [Integer] Chat identifier. # @param message_ids [Array] Identifiers of the messages to be deleted. - # @param revoke [Boolean] Pass true to try to delete outgoing messages for all chat members (may fail if messages are - # too old). + # @param revoke [Boolean] Pass true to try to delete messages for all chat members. # Always true for supergroups, channels and secret chats. # @return [TD::Types::Ok] - def delete_messages(chat_id, message_ids, revoke = false) + def delete_messages(chat_id, message_ids, revoke) broadcast('@type' => 'deleteMessages', 'chat_id' => chat_id, 'message_ids' => message_ids, @@ -718,7 +754,7 @@ def delete_passport_element(type) end # Deletes a profile photo. - # If something changes, {TD::Types::Update::User} will be sent. + # If something changes, updateUser will be sent. # # @param profile_photo_id [Integer] Identifier of the profile photo to delete. # @return [TD::Types::Ok] @@ -756,8 +792,7 @@ def delete_supergroup(supergroup_id) # Closes the TDLib instance, destroying all local data without a proper logout. # The current user session will remain in the list of all active sessions. # All local data will be destroyed. - # After the destruction completes {TD::Types::Update::AuthorizationState} with {TD::Types::AuthorizationState::Closed} - # will be sent. + # After the destruction completes updateAuthorizationState with authorizationStateClosed will be sent. # # @return [TD::Types::Ok] def destroy @@ -779,7 +814,7 @@ def disable_proxy # @param duration [Integer] The call duration, in seconds. # @param connection_id [Integer] Identifier of the connection used during the call. # @return [TD::Types::Ok] - def discard_call(call_id, duration, connection_id, is_disconnected: false) + def discard_call(call_id, is_disconnected, duration, connection_id) broadcast('@type' => 'discardCall', 'call_id' => call_id, 'is_disconnected' => is_disconnected, @@ -803,26 +838,34 @@ def disconnect_website(website_id) 'website_id' => website_id) end - # Asynchronously downloads a file from the cloud. - # {TD::Types::Update::File} will be used to notify about the download progress and successful completion of the - # download. - # Returns file state just after the download has been started. + # Downloads a file from the cloud. + # Download progress and completion of the download will be notified through updateFile updates. # # @param file_id [Integer] Identifier of the file to download. # @param priority [Integer] 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 {#download_file} was called will be - # downloaded first. + # If the priorities of two files are equal, then the last one for which downloadFile was called will be downloaded + # first. + # @param offset [Integer] The starting position from which the file should be downloaded. + # @param limit [Integer] 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. + # @param synchronous [Boolean] 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. # @return [TD::Types::File] - def download_file(file_id, priority = 1) - broadcast('@type' => 'downloadFile', - 'file_id' => file_id, - 'priority' => priority) + def download_file(file_id, priority, offset, limit, synchronous) + broadcast('@type' => 'downloadFile', + 'file_id' => file_id, + 'priority' => priority, + 'offset' => offset, + 'limit' => limit, + 'synchronous' => synchronous) end - # Edits information about a custom language pack in the current localization target. + # Edits information about a custom local language pack in the current localization target. + # Can be called before authorization. # - # @param info [TD::Types::LanguagePackInfo] New information about the custom language pack. + # @param info [TD::Types::LanguagePackInfo] New information about the custom local language pack. # @return [TD::Types::Ok] def edit_custom_language_pack_info(info) broadcast('@type' => 'editCustomLanguagePackInfo', @@ -847,8 +890,8 @@ def edit_inline_message_caption(inline_message_id, reply_markup, caption) # # @param inline_message_id [String] Inline message identifier. # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup. - # @param location [TD::Types::Location, nil] New location content of the message. - # Pass nil to stop sharing the live location. + # @param location [TD::Types::Location, nil] New location content of the message; may be null. + # Pass null to stop sharing the live location. # @return [TD::Types::Ok] def edit_inline_message_live_location(inline_message_id, reply_markup, location = nil) broadcast('@type' => 'editInlineMessageLiveLocation', @@ -861,12 +904,12 @@ def edit_inline_message_live_location(inline_message_id, reply_markup, location # sent via a bot; for bots only. # # @param inline_message_id [String] Inline message identifier. - # @param reply_markup [TD::Types::ReplyMarkup, nil] The new message reply markup; for bots only. - # @param input_message_content [TD::Types::InputMessageContent::Animation, TD::Types::InputMessageContent::Audio, - # TD::Types::InputMessageContent::Document, TD::Types::InputMessageContent::Photo, - # TD::Types::InputMessageContent::Video] New content of the message. + # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup; for bots only. + # @param input_message_content [TD::Types::InputMessageContent] New content of the message. + # Must be one of the following types: InputMessageAnimation, InputMessageAudio, InputMessageDocument, + # InputMessagePhoto or InputMessageVideo. # @return [TD::Types::Ok] - def edit_inline_message_media(inline_message_id, input_message_content, reply_markup: nil) + def edit_inline_message_media(inline_message_id, reply_markup, input_message_content) broadcast('@type' => 'editInlineMessageMedia', 'inline_message_id' => inline_message_id, 'reply_markup' => reply_markup, @@ -888,9 +931,10 @@ def edit_inline_message_reply_markup(inline_message_id, reply_markup) # # @param inline_message_id [String] Inline message identifier. # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup. - # @param input_message_content [TD::Types::InputMessageContent::Text] New text content of the message. + # @param input_message_content [TD::Types::InputMessageContent] New text content of the message. + # Should be of type InputMessageText. # @return [TD::Types::Ok] - def edit_inline_message_text(inline_message_id, input_message_content, reply_markup) + def edit_inline_message_text(inline_message_id, reply_markup, input_message_content) broadcast('@type' => 'editInlineMessageText', 'inline_message_id' => inline_message_id, 'reply_markup' => reply_markup, @@ -898,14 +942,15 @@ def edit_inline_message_text(inline_message_id, input_message_content, reply_mar end # Edits the message content caption. + # Returns the edited message after the edit is completed on the server side. # # @param chat_id [Integer] The chat the message belongs to. # @param message_id [Integer] Identifier of the message. - # @param reply_markup [TD::Types::ReplyMarkup, nil] The new message reply markup; for bots only. + # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup; for bots only. # @param caption [TD::Types::FormattedText] New message content caption; 0-GetOption("message_caption_length_max") # characters. - # @return [TD::Types::Message] the edited message after the edit is completed on the server side. - def edit_message_caption(chat_id, message_id, caption, reply_markup: nil) + # @return [TD::Types::Message] + def edit_message_caption(chat_id, message_id, reply_markup, caption) broadcast('@type' => 'editMessageCaption', 'chat_id' => chat_id, 'message_id' => message_id, @@ -915,14 +960,15 @@ def edit_message_caption(chat_id, message_id, caption, reply_markup: nil) # Edits the message content of a live location. # Messages can be edited for a limited period of time specified in the live location. + # Returns the edited message after the edit is completed on the server side. # # @param chat_id [Integer] The chat the message belongs to. # @param message_id [Integer] Identifier of the message. - # @param reply_markup [TD::Types::ReplyMarkup, nil] The new message reply markup; for bots only. - # @param location [TD::Types::Location, nil] New location content of the message. - # Pass nil to stop sharing the live location. - # @return [TD::Types::Message] the edited message after the edit is completed on the server side. - def edit_message_live_location(chat_id, message_id, location = nil, reply_markup: nil) + # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup; for bots only. + # @param location [TD::Types::Location, nil] New location content of the message; may be null. + # Pass null to stop sharing the live location. + # @return [TD::Types::Message] + def edit_message_live_location(chat_id, message_id, reply_markup, location = nil) broadcast('@type' => 'editMessageLiveLocation', 'chat_id' => chat_id, 'message_id' => message_id, @@ -934,15 +980,16 @@ def edit_message_live_location(chat_id, message_id, location = nil, reply_markup # The media in the message can't be replaced if the message was set to self-destruct. # Media can't be replaced by self-destructing media. # Media in an album can be edited only to contain a photo or a video. + # Returns the edited message after the edit is completed on the server side. # # @param chat_id [Integer] The chat the message belongs to. # @param message_id [Integer] Identifier of the message. - # @param reply_markup [TD::Types::ReplyMarkup, nil] The new message reply markup; for bots only. - # @param input_message_content [TD::Types::InputMessageContent::Animation, TD::Types::InputMessageContent::Audio, - # TD::Types::InputMessageContent::Document, TD::Types::InputMessageContent::Photo, - # TD::Types::InputMessageContent::Video] New content of the message. - # @return [TD::Types::Message] the edited message after the edit is completed on the server side. - def edit_message_media(chat_id, message_id, input_message_content, reply_markup: nil) + # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup; for bots only. + # @param input_message_content [TD::Types::InputMessageContent] New content of the message. + # Must be one of the following types: InputMessageAnimation, InputMessageAudio, InputMessageDocument, + # InputMessagePhoto or InputMessageVideo. + # @return [TD::Types::Message] + def edit_message_media(chat_id, message_id, reply_markup, input_message_content) broadcast('@type' => 'editMessageMedia', 'chat_id' => chat_id, 'message_id' => message_id, @@ -951,11 +998,12 @@ def edit_message_media(chat_id, message_id, input_message_content, reply_markup: end # Edits the message reply markup; for bots only. + # Returns the edited message after the edit is completed on the server side. # # @param chat_id [Integer] The chat the message belongs to. # @param message_id [Integer] Identifier of the message. # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup. - # @return [TD::Types::Message] the edited message after the edit is completed on the server side. + # @return [TD::Types::Message] def edit_message_reply_markup(chat_id, message_id, reply_markup) broadcast('@type' => 'editMessageReplyMarkup', 'chat_id' => chat_id, @@ -964,13 +1012,15 @@ def edit_message_reply_markup(chat_id, message_id, reply_markup) end # Edits the text of a message (or a text of a game message). + # Returns the edited message after the edit is completed on the server side. # # @param chat_id [Integer] The chat the message belongs to. # @param message_id [Integer] Identifier of the message. - # @param reply_markup [TD::Types::ReplyMarkup, nil] The new message reply markup; for bots only. - # @param input_message_content [TD::Types::InputMessageContent::Text] New text content of the message. - # @return [TD::Types::Message] the edited message after the edit is completed on the server side. - def edit_message_text(chat_id, message_id, input_message_content, reply_markup: nil) + # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup; for bots only. + # @param input_message_content [TD::Types::InputMessageContent] New text content of the message. + # Should be of type InputMessageText. + # @return [TD::Types::Message] + def edit_message_text(chat_id, message_id, reply_markup, input_message_content) broadcast('@type' => 'editMessageText', 'chat_id' => chat_id, 'message_id' => message_id, @@ -987,7 +1037,7 @@ def edit_message_text(chat_id, message_id, input_message_content, reply_markup: # @param enable [Boolean] True, if the proxy should be enabled. # @param type [TD::Types::ProxyType] Proxy type. # @return [TD::Types::Proxy] - def edit_proxy(proxy_id, server, port, type, enable = false) + def edit_proxy(proxy_id, server, port, enable, type) broadcast('@type' => 'editProxy', 'proxy_id' => proxy_id, 'server' => server, @@ -1010,42 +1060,48 @@ def enable_proxy(proxy_id) # Finishes the file generation. # # @param generation_id [Integer] The identifier of the generation process. - # @param error [TD::Types::Error, nil] If set, means that file generation has failed and should be terminated. + # @param error [TD::Types::Error] If set, means that file generation has failed and should be terminated. # @return [TD::Types::Ok] - def finish_file_generation(generation_id, error: nil) + def finish_file_generation(generation_id, error) broadcast('@type' => 'finishFileGeneration', 'generation_id' => generation_id, 'error' => error) end # Forwards previously sent messages. + # Returns the forwarded messages in the same order as the message identifiers passed in message_ids. + # If a message can't be forwarded, null will be returned instead of the message. # # @param chat_id [Integer] Identifier of the chat to which to forward messages. # @param from_chat_id [Integer] Identifier of the chat from which to forward messages. # @param message_ids [Array] Identifiers of the messages to forward. # @param disable_notification [Boolean] Pass true to disable notification for the message, doesn't work if messages # are forwarded to a secret chat. - # @param from_background [Boolean] Pass true if the message is sent from the background. + # @param from_background [Boolean] Pass true if the messages are sent from the background. # @param as_album [Boolean] True, if the messages should be grouped into an album after forwarding. # For this to work, no more than 10 messages may be forwarded, and all of them must be photo or video messages. - # @return [TD::Types::Messages, nil] the forwarded messages in the same order as the message identifiers passed in - # message_ids. - # If a message can't be forwarded, nil will be returned instead of the message. - def forward_messages(chat_id, from_chat_id, message_ids, - disable_notification: false, from_background: false, as_album: false) + # @param send_copy [Boolean] True, if content of the messages needs to be copied without links to the original + # messages. + # Always true if the messages are forwarded to a secret chat. + # @param remove_caption [Boolean] True, if media captions of message copies needs to be removed. + # Ignored if send_copy is false. + # @return [TD::Types::Messages] + def forward_messages(chat_id, from_chat_id, message_ids, disable_notification, from_background, as_album, send_copy, + remove_caption) broadcast('@type' => 'forwardMessages', 'chat_id' => chat_id, 'from_chat_id' => from_chat_id, 'message_ids' => message_ids, 'disable_notification' => disable_notification, 'from_background' => from_background, - 'as_album' => as_album) + 'as_album' => as_album, + 'send_copy' => send_copy, + 'remove_caption' => remove_caption) end # Generates a new invite link for a chat; the previously generated link is revoked. # Available for basic groups, supergroups, and channels. - # In basic groups this can be called only by the group's creator; in supergroups and channels this requires - # appropriate administrator rights. + # Requires administrator privileges and can_invite_users right. # # @param chat_id [Integer] Chat identifier. # @return [TD::Types::ChatInviteLink] @@ -1085,13 +1141,21 @@ def get_all_passport_elements(password) 'password' => password) end + # Returns application config, provided by the server. + # Can be called before authorization. + # + # @return [TD::Types::JsonValue] + def get_application_config + broadcast('@type' => 'getApplicationConfig') + end + # Returns a list of archived sticker sets. # # @param is_masks [Boolean] Pass true to return mask stickers sets; pass false to return ordinary sticker sets. # @param offset_sticker_set_id [Integer] Identifier of the sticker set from which to return the result. # @param limit [Integer] Maximum number of sticker sets to return. # @return [TD::Types::StickerSets] - def get_archived_sticker_sets(offset_sticker_set_id, limit = 100, is_masks: false) + def get_archived_sticker_sets(is_masks, offset_sticker_set_id, limit) broadcast('@type' => 'getArchivedStickerSets', 'is_masks' => is_masks, 'offset_sticker_set_id' => offset_sticker_set_id, @@ -1110,13 +1174,40 @@ def get_attached_sticker_sets(file_id) # Returns the current authorization state; this is an offline request. # For informational purposes only. - # Use {TD::Types::Update::AuthorizationState} instead to maintain the current authorization state. + # Use updateAuthorizationState instead to maintain the current authorization state. # # @return [TD::Types::AuthorizationState] def get_authorization_state broadcast('@type' => 'getAuthorizationState') end + # Returns auto-download settings presets for the currently logged in user. + # + # @return [TD::Types::AutoDownloadSettingsPresets] + def get_auto_download_settings_presets + broadcast('@type' => 'getAutoDownloadSettingsPresets') + end + + # Constructs a persistent HTTP URL for a background. + # + # @param name [String] Background name. + # @param type [TD::Types::BackgroundType] Background type. + # @return [TD::Types::HttpUrl] + def get_background_url(name, type) + broadcast('@type' => 'getBackgroundUrl', + 'name' => name, + 'type' => type) + end + + # Returns backgrounds installed by the user. + # + # @param for_dark_theme [Boolean] True, if the backgrounds needs to be ordered for dark theme. + # @return [TD::Types::Backgrounds] + def get_backgrounds(for_dark_theme) + broadcast('@type' => 'getBackgrounds', + 'for_dark_theme' => for_dark_theme) + end + # Returns information about a basic group by its identifier. # This is an offline request if the current user is not a bot. # @@ -1141,7 +1232,7 @@ def get_basic_group_full_info(basic_group_id) # @param offset [Integer] Number of users to skip in the result; must be non-negative. # @param limit [Integer] Maximum number of users to return; up to 100. # @return [TD::Types::Users] - def get_blocked_users(offset, limit = 100) + def get_blocked_users(offset, limit) broadcast('@type' => 'getBlockedUsers', 'offset' => offset, 'limit' => limit) @@ -1182,7 +1273,8 @@ def get_chat_administrators(chat_id) # Returns a list of service actions taken by chat members and administrators in the last 48 hours. # Available only in supergroups and channels. # Requires administrator rights. - # Returns results in reverse chronological order (i.e., in order of decreasing event_id). + # Returns results in reverse chronological order (i. + # e., in order of decreasing event_id). # # @param chat_id [Integer] Chat identifier. # @param query [String] Search query by which to filter events. @@ -1212,17 +1304,17 @@ def get_chat_event_log(chat_id, query, from_event_id, limit, filters, user_ids) # @param chat_id [Integer] Chat identifier. # @param from_message_id [Integer] Identifier of the message starting from which history must be fetched; use 0 to # get results from the last message. - # @param offset [Integer] Specify 0 to get results from exactly the from_message_id or a negative offset to get the - # specified message and some newer messages. + # @param offset [Integer] Specify 0 to get results from exactly the from_message_id or a negative offset up to 99 to + # get additionally some newer messages. # @param limit [Integer] The maximum number of messages to be returned; must be positive and can't be greater than # 100. - # If the offset is negative, the limit must be greater than -offset. + # If the offset is negative, the limit must be greater or equal to -offset. # Fewer messages may be returned than specified by the limit, even if the end of the message history has not been # reached. # @param only_local [Boolean] If true, returns only messages that are available locally without sending network # requests. # @return [TD::Types::Messages] - def get_chat_history(chat_id, from_message_id, offset = 0, limit = 100, only_local: false) + def get_chat_history(chat_id, from_message_id, offset, limit, only_local) broadcast('@type' => 'getChatHistory', 'chat_id' => chat_id, 'from_message_id' => from_message_id, @@ -1256,18 +1348,30 @@ def get_chat_message_by_date(chat_id, date) # Returns approximate number of messages of the specified type in the chat. # # @param chat_id [Integer] Identifier of the chat in which to count messages. - # @param filter [TD::Types::SearchMessagesFilter, nil] Filter for message content; + # @param filter [TD::Types::SearchMessagesFilter] Filter for message content; # {TD::Types::SearchMessagesFilter::Empty} is unsupported in this function. # @param return_local [Boolean] If true, returns count that is available locally without sending network requests, # returning -1 if the number of messages is unknown. # @return [TD::Types::Count] - def get_chat_message_count(chat_id, filter = nil, return_local: false) + def get_chat_message_count(chat_id, filter, return_local) broadcast('@type' => 'getChatMessageCount', 'chat_id' => chat_id, 'filter' => filter, 'return_local' => return_local) end + # Returns list of chats with non-default notification settings. + # + # @param scope [TD::Types::NotificationSettingsScope] If specified, only chats from the specified scope will be + # returned. + # @param compare_sound [Boolean] If true, also chats with non-default sound will be returned. + # @return [TD::Types::Chats] + def get_chat_notification_settings_exceptions(scope, compare_sound) + broadcast('@type' => 'getChatNotificationSettingsExceptions', + 'scope' => scope, + 'compare_sound' => compare_sound) + end + # Returns information about a pinned chat message. # # @param chat_id [Integer] Identifier of the chat the message belongs to. @@ -1286,9 +1390,24 @@ def get_chat_report_spam_state(chat_id) 'chat_id' => chat_id) end + # Returns an HTTP URL with the chat statistics. + # Currently this method can be used only for channels. + # + # @param chat_id [Integer] Chat identifier. + # @param parameters [String] Parameters from "tg://statsrefresh?params=******" link. + # @param is_dark [Boolean] Pass true if a URL with the dark theme must be returned. + # @return [TD::Types::HttpUrl] + def get_chat_statistics_url(chat_id, parameters, is_dark) + broadcast('@type' => 'getChatStatisticsUrl', + 'chat_id' => chat_id, + 'parameters' => parameters, + 'is_dark' => is_dark) + end + # Returns an ordered list of chats. # Chats are sorted by the pair (order, chat_id) in decreasing order. - # (For example, to get a list of chats from the beginning, the offset_order should be equal to 2^63 - 1). + # (For example, to get a list of chats from the beginning, the offset_order should be equal to a biggest signed + # 64-bit number 9223372036854775807 == 2^63 - 1). # For optimal performance the number of returned chats is chosen by the library. # # @param offset_order [Integer] Chat order to return chats from. @@ -1296,7 +1415,7 @@ def get_chat_report_spam_state(chat_id) # @param limit [Integer] The maximum number of chats to be returned. # It is possible that fewer chats than the limit are returned even if the end of the list is not reached. # @return [TD::Types::Chats] - def get_chats(offset_chat_id = 0, limit = 100, offset_order: 9223372036854775807) + def get_chats(offset_order, offset_chat_id, limit) broadcast('@type' => 'getChats', 'offset_order' => offset_order, 'offset_chat_id' => offset_chat_id, @@ -1317,21 +1436,40 @@ def get_contacts broadcast('@type' => 'getContacts') end - # Uses current user IP to found his country. + # Uses current user IP to found their country. + # Returns two-letter ISO 3166-1 alpha-2 country code. # Can be called before authorization. # - # @return [TD::Types::Text] two-letter ISO 3166-1 alpha-2 country code. + # @return [TD::Types::Text] def get_country_code broadcast('@type' => 'getCountryCode') end - # Returns a list of public chats created by the user. + # Returns a list of public chats with username created by the user. # # @return [TD::Types::Chats] def get_created_public_chats broadcast('@type' => 'getCreatedPublicChats') end + # Returns all updates needed to restore current TDLib state, i.e. + # all actual UpdateAuthorizationState/UpdateUser/UpdateNewChat and others. + # This is especially usefull if TDLib is run in a separate process. + # This is an offline method. + # Can be called before authorization. + # + # @return [TD::Types::Updates] + def get_current_state + broadcast('@type' => 'getCurrentState') + end + + # Returns database statistics. + # + # @return [TD::Types::DatabaseStatistics] + def get_database_statistics + broadcast('@type' => 'getDatabaseStatistics') + end + # Returns information about a tg:// deep link. # Use "tg://need_update_for_some_feature" or "tg:some_unsupported_feature" for testing. # Returns a 404 error for unknown links. @@ -1344,6 +1482,17 @@ def get_deep_link_info(link) 'link' => link) end + # Returns an HTTP URL which can be used to automatically log in to the translation platform and suggest new emoji + # replacements. + # The URL will be valid for 30 seconds after generation. + # + # @param language_code [String] Language code for which the emoji replacements will be suggested. + # @return [TD::Types::HttpUrl] + def get_emoji_suggestions_url(language_code) + broadcast('@type' => 'getEmojiSuggestionsUrl', + 'language_code' => language_code) + end + # Returns favorite stickers. # # @return [TD::Types::Stickers] @@ -1360,6 +1509,17 @@ def get_file(file_id) 'file_id' => file_id) end + # Returns file downloaded prefix size from a given offset. + # + # @param file_id [Integer] Identifier of the file. + # @param offset [Integer] Offset from which downloaded prefix size should be calculated. + # @return [TD::Types::Count] + def get_file_downloaded_prefix_size(file_id, offset) + broadcast('@type' => 'getFileDownloadedPrefixSize', + 'file_id' => file_id, + 'offset' => offset) + end + # Returns the extension of a file, guessed by its MIME type. # Returns an empty string on failure. # This is an offline method. @@ -1400,14 +1560,14 @@ def get_game_high_scores(chat_id, message_id, user_id) 'user_id' => user_id) end - # Returns a list of common chats with a given user. + # Returns a list of common group chats with a given user. # Chats are sorted by their type and creation date. # # @param user_id [Integer] User identifier. # @param offset_chat_id [Integer] Chat identifier starting from which to return chats; use 0 for the first request. # @param limit [Integer] Maximum number of chats to be returned; up to 100. # @return [TD::Types::Chats] - def get_groups_in_common(user_id, offset_chat_id = 0, limit = 100) + def get_groups_in_common(user_id, offset_chat_id, limit) broadcast('@type' => 'getGroupsInCommon', 'user_id' => user_id, 'offset_chat_id' => offset_chat_id, @@ -1437,11 +1597,11 @@ def get_inline_game_high_scores(inline_message_id, user_id) # # @param bot_user_id [Integer] The identifier of the target bot. # @param chat_id [Integer] Identifier of the chat, where the query was sent. - # @param user_location [TD::Types::Location, nil] Location of the user, only if needed. + # @param user_location [TD::Types::Location] Location of the user, only if needed. # @param query [String] Text of the query. # @param offset [String] Offset of the first entry to return. # @return [TD::Types::InlineQueryResults] - def get_inline_query_results(bot_user_id, chat_id, query, offset = '0', user_location: nil) + def get_inline_query_results(bot_user_id, chat_id, user_location, query, offset) broadcast('@type' => 'getInlineQueryResults', 'bot_user_id' => bot_user_id, 'chat_id' => chat_id, @@ -1454,7 +1614,7 @@ def get_inline_query_results(bot_user_id, chat_id, query, offset = '0', user_loc # # @param is_masks [Boolean] Pass true to return mask sticker sets; pass false to return ordinary sticker sets. # @return [TD::Types::StickerSets] - def get_installed_sticker_sets(is_masks = false) + def get_installed_sticker_sets(is_masks) broadcast('@type' => 'getInstalledStickerSets', 'is_masks' => is_masks) end @@ -1467,6 +1627,41 @@ def get_invite_text broadcast('@type' => 'getInviteText') end + # Converts a JsonValue object to corresponding JSON-serialized string. + # This is an offline method. + # Can be called before authorization. + # Can be called synchronously. + # + # @param json_value [TD::Types::JsonValue] The {TD::Types::JsonValue} object. + # @return [TD::Types::Text] + def get_json_string(json_value) + broadcast('@type' => 'getJsonString', + 'json_value' => json_value) + end + + # Converts a JSON-serialized string to corresponding JsonValue object. + # This is an offline method. + # Can be called before authorization. + # Can be called synchronously. + # + # @param json [String] The JSON-serialized string. + # @return [TD::Types::JsonValue] + def get_json_value(json) + broadcast('@type' => 'getJsonValue', + 'json' => json) + end + + # Returns information about a language pack. + # Returned language pack identifier may be different from a provided one. + # Can be called before authorization. + # + # @param language_pack_id [String] Language pack identifier. + # @return [TD::Types::LanguagePackInfo] + def get_language_pack_info(language_pack_id) + broadcast('@type' => 'getLanguagePackInfo', + 'language_pack_id' => language_pack_id) + end + # Returns a string stored in the local database from the specified localization target and language pack by its key. # Returns a 404 error if the string is not found. # This is an offline method. @@ -1487,6 +1682,7 @@ def get_language_pack_string(language_pack_database_path, localization_target, l end # Returns strings from a language pack in the current localization target by their keys. + # Can be called before authorization. # # @param language_pack_id [String] Language pack identifier of the strings to be returned. # @param keys [Array] Language pack keys of the strings to be returned; leave empty to request all available @@ -1500,14 +1696,58 @@ def get_language_pack_strings(language_pack_id, keys) # Returns information about the current localization target. # This is an offline request if only_local is true. + # Can be called before authorization. # # @param only_local [Boolean] If true, returns only locally available information without sending network requests. # @return [TD::Types::LocalizationTargetInfo] - def get_localization_target_info(only_local = false) + def get_localization_target_info(only_local) broadcast('@type' => 'getLocalizationTargetInfo', 'only_local' => only_local) end + # Returns information about currently used log stream for internal logging of TDLib. + # This is an offline method. + # Can be called before authorization. + # Can be called synchronously. + # + # @return [TD::Types::LogStream] + def get_log_stream + broadcast('@type' => 'getLogStream') + end + + # Returns current verbosity level for a specified TDLib internal log tag. + # This is an offline method. + # Can be called before authorization. + # Can be called synchronously. + # + # @param tag [String] Logging tag to change verbosity level. + # @return [TD::Types::LogVerbosityLevel] + def get_log_tag_verbosity_level(tag) + broadcast('@type' => 'getLogTagVerbosityLevel', + 'tag' => tag) + end + + # Returns list of available TDLib internal log tags, for example, ["actor", "binlog", "connections", "notifications", + # "proxy"]. + # This is an offline method. + # Can be called before authorization. + # Can be called synchronously. + # + # @return [TD::Types::LogTags] + def get_log_tags + broadcast('@type' => 'getLogTags') + end + + # Returns current verbosity level of the internal logging of TDLib. + # This is an offline method. + # Can be called before authorization. + # Can be called synchronously. + # + # @return [TD::Types::LogVerbosityLevel] + def get_log_verbosity_level + broadcast('@type' => 'getLogVerbosityLevel') + end + # Returns information about a file with a map thumbnail in PNG format. # Only map thumbnail files with size less than 1MB can be downloaded. # @@ -1519,7 +1759,7 @@ def get_localization_target_info(only_local = false) # @param chat_id [Integer] Identifier of a chat, in which the thumbnail will be shown. # Use 0 if unknown. # @return [TD::Types::File] - def get_map_thumbnail_file(location, zoom = 13, width = 1024, height = 1024, scale = 1, chat_id: 0) + def get_map_thumbnail_file(location, zoom, width, height, scale, chat_id) broadcast('@type' => 'getMapThumbnailFile', 'location' => location, 'zoom' => zoom, @@ -1547,8 +1787,43 @@ def get_message(chat_id, message_id) 'message_id' => message_id) end + # Returns a private HTTPS link to a message in a chat. + # Available only for already sent messages in supergroups and channels. + # The link will work only for members of the chat. + # + # @param chat_id [Integer] Identifier of the chat to which the message belongs. + # @param message_id [Integer] Identifier of the message. + # @return [TD::Types::HttpUrl] + def get_message_link(chat_id, message_id) + broadcast('@type' => 'getMessageLink', + 'chat_id' => chat_id, + 'message_id' => message_id) + end + + # Returns information about a public or private message link. + # + # @param url [String] The message link in the format "https://t.me/c/...", or "tg://privatepost?...", or + # "https://t.me/username/...", or "tg://resolve?...". + # @return [TD::Types::MessageLinkInfo] + def get_message_link_info(url) + broadcast('@type' => 'getMessageLinkInfo', + 'url' => url) + end + + # Returns information about a message, if it is available locally without sending network request. + # This is an offline request. + # + # @param chat_id [Integer] Identifier of the chat the message belongs to. + # @param message_id [Integer] Identifier of the message to get. + # @return [TD::Types::Message] + def get_message_locally(chat_id, message_id) + broadcast('@type' => 'getMessageLocally', + 'chat_id' => chat_id, + 'message_id' => message_id) + end + # Returns information about messages. - # If a message is not found, returns nil on the corresponding position of the result. + # If a message is not found, returns null on the corresponding position of the result. # # @param chat_id [Integer] Identifier of the chat the messages belong to. # @param message_ids [Array] Identifiers of the messages to get. @@ -1564,16 +1839,16 @@ def get_messages(chat_id, message_ids) # # @param only_current [Boolean] If true, returns only data for the current library launch. # @return [TD::Types::NetworkStatistics] - def get_network_statistics(only_current = false) + def get_network_statistics(only_current) broadcast('@type' => 'getNetworkStatistics', 'only_current' => only_current) end # Returns the value of an option by its name. - # Can be called before authorization. + # (Check the list of available options on https://core.telegram.org/tdlib/options.) Can be called before + # authorization. # # @param name [String] The name of the option. - # @see https://core.telegram.org/tdlib/options List of available options # @return [TD::Types::OptionValue] def get_option(name) broadcast('@type' => 'getOption', @@ -1586,15 +1861,26 @@ def get_option(name) # @param scope [String] Telegram Passport element types requested by the service. # @param public_key [String] Service's public_key. # @param nonce [String] Authorization form nonce provided by the service. - # @param password [String] Password of the current user. # @return [TD::Types::PassportAuthorizationForm] - def get_passport_authorization_form(bot_user_id, scope, public_key, nonce, password) + def get_passport_authorization_form(bot_user_id, scope, public_key, nonce) broadcast('@type' => 'getPassportAuthorizationForm', 'bot_user_id' => bot_user_id, 'scope' => scope, 'public_key' => public_key, - 'nonce' => nonce, - 'password' => password) + 'nonce' => nonce) + end + + # Returns already available Telegram Passport elements suitable for completing a Telegram Passport authorization + # form. + # Result can be received only once for each authorization form. + # + # @param autorization_form_id [Integer] Authorization form identifier. + # @param password [String] Password of the current user. + # @return [TD::Types::PassportElementsWithErrors] + def get_passport_authorization_form_available_elements(autorization_form_id, password) + broadcast('@type' => 'getPassportAuthorizationFormAvailableElements', + 'autorization_form_id' => autorization_form_id, + 'password' => password) end # Returns one of the available Telegram Passport elements. @@ -1616,7 +1902,7 @@ def get_password_state end # Returns an invoice payment form. - # This method should be called when the user presses {TD::Types::InlineKeyboardButton::Buy}. + # This method should be called when the user presses inlineKeyboardButtonBuy. # # @param chat_id [Integer] Chat identifier of the Invoice message. # @param message_id [Integer] Message identifier. @@ -1669,19 +1955,32 @@ def get_proxy_link(proxy_id) end # Returns a public HTTPS link to a message. - # Available only for messages in public supergroups and channels. + # Available only for messages in supergroups and channels with username. # # @param chat_id [Integer] Identifier of the chat to which the message belongs. # @param message_id [Integer] Identifier of the message. # @param for_album [Boolean] Pass true if a link for a whole media album should be returned. # @return [TD::Types::PublicMessageLink] - def get_public_message_link(chat_id, message_id, for_album: false) + def get_public_message_link(chat_id, message_id, for_album) broadcast('@type' => 'getPublicMessageLink', 'chat_id' => chat_id, 'message_id' => message_id, 'for_album' => for_album) end + # Returns a globally unique push notification subscription identifier for identification of an account, which has + # received a push notification. + # This is an offline method. + # Can be called before authorization. + # Can be called synchronously. + # + # @param payload [String] JSON-encoded push notification payload. + # @return [TD::Types::PushReceiverId] + def get_push_receiver_id(payload) + broadcast('@type' => 'getPushReceiverId', + 'payload' => payload) + end + # Returns up to 20 recently used inline bots in the order of their last usage. # # @return [TD::Types::Users] @@ -1694,7 +1993,7 @@ def get_recent_inline_bots # @param is_attached [Boolean] Pass true to return stickers and masks that were recently attached to photos or video # files; pass false to return recently sent stickers. # @return [TD::Types::Stickers] - def get_recent_stickers(is_attached = false) + def get_recent_stickers(is_attached) broadcast('@type' => 'getRecentStickers', 'is_attached' => is_attached) end @@ -1708,7 +2007,7 @@ def get_recently_visited_t_me_urls(referrer) 'referrer' => referrer) end - # Returns a recovery email address that was previously set up. + # Returns a 2-step verification recovery email address that was previously set up. # This method can be used to verify a password provided by the user. # # @param password [String] The password for the current user. @@ -1722,9 +2021,9 @@ def get_recovery_email_address(password) # Can be used to register a URL as a file for further uploading, or sending as a message. # # @param remote_file_id [String] Remote identifier of the file to get. - # @param file_type [TD::Types::FileType, nil] File type, if known. + # @param file_type [TD::Types::FileType] File type, if known. # @return [TD::Types::File] - def get_remote_file(remote_file_id, file_type = nil) + def get_remote_file(remote_file_id, file_type) broadcast('@type' => 'getRemoteFile', 'remote_file_id' => remote_file_id, 'file_type' => file_type) @@ -1776,9 +2075,11 @@ def get_secret_chat(secret_chat_id) end # Returns emoji corresponding to a sticker. + # The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the + # corresponding Sticker object. # # @param sticker [TD::Types::InputFile] Sticker file identifier. - # @return [TD::Types::StickerEmojis] + # @return [TD::Types::Emojis] def get_sticker_emojis(sticker) broadcast('@type' => 'getStickerEmojis', 'sticker' => sticker) @@ -1800,13 +2101,14 @@ def get_sticker_set(set_id) # If empty, returns all known installed stickers. # @param limit [Integer] Maximum number of stickers to be returned. # @return [TD::Types::Stickers] - def get_stickers(emoji, limit = 100) + def get_stickers(emoji, limit) broadcast('@type' => 'getStickers', 'emoji' => emoji, 'limit' => limit) end # Returns storage usage statistics. + # Can be called before authorization. # # @param chat_limit [Integer] Maximum number of chats with the largest storage usage for which separate statistics # should be returned. @@ -1819,6 +2121,7 @@ def get_storage_statistics(chat_limit) end # Quickly returns approximate storage usage statistics. + # Can be called before authorization. # # @return [TD::Types::StorageStatisticsFast] def get_storage_statistics_fast @@ -1850,7 +2153,7 @@ def get_supergroup_full_info(supergroup_id) # # @param supergroup_id [Integer] Identifier of the supergroup or channel. # @param filter [TD::Types::SupergroupMembersFilter] The type of users to return. - # By default, {TD::Types::SupergroupMembersFilter::Recent}. + # By default, supergroupMembersRecent. # @param offset [Integer] Number of users to skip. # @param limit [Integer] The maximum number of users be returned; up to 200. # @return [TD::Types::ChatMembers] @@ -1894,7 +2197,7 @@ def get_text_entities(text) # @param category [TD::Types::TopChatCategory] Category of chats to be returned. # @param limit [Integer] Maximum number of chats to be returned; up to 30. # @return [TD::Types::Chats] - def get_top_chats(category, limit = 30) + def get_top_chats(category, limit) broadcast('@type' => 'getTopChats', 'category' => category, 'limit' => limit) @@ -1942,27 +2245,20 @@ def get_user_privacy_setting_rules(setting) # @param offset [Integer] The number of photos to skip; must be non-negative. # @param limit [Integer] Maximum number of photos to be returned; up to 100. # @return [TD::Types::UserProfilePhotos] - def get_user_profile_photos(user_id, offset = 0, limit = 100) + def get_user_profile_photos(user_id, offset, limit) broadcast('@type' => 'getUserProfilePhotos', 'user_id' => user_id, 'offset' => offset, 'limit' => limit) end - # Returns background wallpapers. - # - # @return [TD::Types::Wallpapers] - def get_wallpapers - broadcast('@type' => 'getWallpapers') - end - # Returns an instant view version of a web page if available. # Returns a 404 error if the web page has no instant view page. # # @param url [String] The web page URL. # @param force_full [Boolean] If true, the full instant view for the web page will be returned. # @return [TD::Types::WebPageInstantView] - def get_web_page_instant_view(url, force_full = false) + def get_web_page_instant_view(url, force_full) broadcast('@type' => 'getWebPageInstantView', 'url' => url, 'force_full' => force_full) @@ -2023,15 +2319,14 @@ def leave_chat(chat_id) # Closes the TDLib instance after a proper logout. # Requires an available network connection. # All local data will be destroyed. - # After the logout completes, {TD::Types::Update::AuthorizationState} with {TD::Types::AuthorizationState::Closed} - # will be sent. + # After the logout completes, updateAuthorizationState with authorizationStateClosed will be sent. # # @return [TD::Types::Ok] def log_out broadcast('@type' => 'logOut') end - # This method should be called if the chat is opened by the user. + # Informs TDLib that the chat is opened by the user. # Many useful activities depend on the chat being opened or closed (e.g., in supergroups and channels all updates are # received only for opened chats). # @@ -2042,9 +2337,9 @@ def open_chat(chat_id) 'chat_id' => chat_id) end - # This method should be called if the message content has been opened (e.g., the user has opened a photo, video, - # document, location or venue, or has listened to an audio file or voice note message). - # An {TD::Types::Update::MessageContentOpened} will be generated if something has changed. + # Informs TDLib that the message content has been opened (e.g., the user has opened a photo, video, document, + # location or venue, or has listened to an audio file or voice note message). + # An updateMessageContentOpened update will be generated if something has changed. # # @param chat_id [Integer] Chat identifier of the message. # @param message_id [Integer] Identifier of the message with the opened content. @@ -2055,7 +2350,8 @@ def open_message_content(chat_id, message_id) 'message_id' => message_id) end - # Optimizes storage usage, i.e. deletes some files and returns new storage usage statistics. + # Optimizes storage usage, i.e. + # deletes some files and returns new storage usage statistics. # Secret thumbnails can't be deleted. # # @param size [Integer] Limit on the total size of files after deletion. @@ -2068,17 +2364,16 @@ def open_message_content(chat_id, message_id) # @param immunity_delay [Integer] The amount of time after the creation of a file during which it can't be deleted, # in seconds. # Pass -1 to use the default value. - # @param file_types [Array, nil] If not empty, only files with the given type(s) are considered. + # @param file_types [Array] If not empty, only files with the given type(s) are considered. # By default, all types except thumbnails, profile photos, stickers and wallpapers are deleted. - # @param chat_ids [Array, nil] If not empty, only files from the given chats are considered. + # @param chat_ids [Array] If not empty, only files from the given chats are considered. # Use 0 as chat identifier to delete files not belonging to any chat (e.g., profile photos). - # @param exclude_chat_ids [Array, nil] If not empty, files from the given chats are excluded. + # @param exclude_chat_ids [Array] If not empty, files from the given chats are excluded. # Use 0 as chat identifier to exclude all files not belonging to any chat (e.g., profile photos). - # @param chat_limit [Integer, nil] Same as in {#get_storage_statistics}. + # @param chat_limit [Integer] Same as in getStorageStatistics. # Affects only returned statistics. # @return [TD::Types::StorageStatistics] - def optimize_storage(size: -1, ttl: -1, count: -1, immunity_delay: -1, - file_types: nil, chat_ids: nil, exclude_chat_ids: nil, chat_limit: nil) + def optimize_storage(size, ttl, count, immunity_delay, file_types, chat_ids, exclude_chat_ids, chat_limit) broadcast('@type' => 'optimizeStorage', 'size' => size, 'ttl' => ttl, @@ -2104,15 +2399,15 @@ def parse_text_entities(text, parse_mode) 'parse_mode' => parse_mode) end - # Pins a message in a supergroup or channel; requires appropriate administrator rights in the supergroup or channel. + # Pins a message in a chat; requires can_pin_messages rights. # - # @param supergroup_id [Integer] Identifier of the supergroup or channel. + # @param chat_id [Integer] Identifier of the chat. # @param message_id [Integer] Identifier of the new pinned message. # @param disable_notification [Boolean] True, if there should be no notification about the pinned message. # @return [TD::Types::Ok] - def pin_supergroup_message(supergroup_id, message_id, disable_notification: false) - broadcast('@type' => 'pinSupergroupMessage', - 'supergroup_id' => supergroup_id, + def pin_chat_message(chat_id, message_id, disable_notification) + broadcast('@type' => 'pinChatMessage', + 'chat_id' => chat_id, 'message_id' => message_id, 'disable_notification' => disable_notification) end @@ -2128,16 +2423,17 @@ def ping_proxy(proxy_id) 'proxy_id' => proxy_id) end - # Handles a DC_UPDATE push service notification. + # Handles a push notification. + # Returns error with code 406 if the push notification is not supported and connection to the server is required to + # fetch new data. # Can be called before authorization. # - # @param dc [String] Value of the "dc" parameter of the notification. - # @param addr [String] Value of the "addr" parameter of the notification. + # @param payload [String] JSON-encoded push notification payload with all fields sent by the server, and + # "google.sent_time" and "google.notification.sound" fields added. # @return [TD::Types::Ok] - def process_dc_update(dc, addr) - broadcast('@type' => 'processDcUpdate', - 'dc' => dc, - 'addr' => addr) + def process_push_notification(payload) + broadcast('@type' => 'processPushNotification', + 'payload' => payload) end # Marks all mentions in a chat as read. @@ -2149,8 +2445,26 @@ def read_all_chat_mentions(chat_id) 'chat_id' => chat_id) end + # Reads a part of a file from the TDLib file cache and returns read bytes. + # This method is intended to be used only if the client has no direct access to TDLib's file system, because it is + # usually slower than a direct read from the file. + # + # @param file_id [Integer] Identifier of the file. + # The file must be located in the TDLib file cache. + # @param offset [Integer] The offset from which to read the file. + # @param count [Integer] Number of bytes to read. + # An error will be returned if there are not enough bytes available in the file from the specified position. + # Pass 0 to read all available data from the specified position. + # @return [TD::Types::FilePart] + def read_file_part(file_id, offset, count) + broadcast('@type' => 'readFilePart', + 'file_id' => file_id, + 'offset' => offset, + 'count' => count) + end + # Recovers the password with a password recovery code sent to an email address that was previously set up. - # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitPassword}. + # Works only when the current authorization state is authorizationStateWaitPassword. # # @param recovery_code [String] Recovery code to check. # @return [TD::Types::Ok] @@ -2169,18 +2483,39 @@ def recover_password(recovery_code) end # Registers the currently used device for receiving push notifications. + # Returns a globally unique identifier of the push notification subscription. # # @param device_token [TD::Types::DeviceToken] Device token. - # @param other_user_ids [Array] List of at most 100 user identifiers of other users currently using the - # client. - # @return [TD::Types::Ok] - def register_device(device_token, other_user_ids = []) + # @param other_user_ids [Array] List of user identifiers of other users currently using the client. + # @return [TD::Types::PushReceiverId] + def register_device(device_token, other_user_ids) broadcast('@type' => 'registerDevice', 'device_token' => device_token, 'other_user_ids' => other_user_ids) end - # Removes users from the contacts list. + # Finishes user registration. + # Works only when the current authorization state is authorizationStateWaitRegistration. + # + # @param first_name [String] The first name of the user; 1-64 characters. + # @param last_name [String] The last name of the user; 0-64 characters. + # @return [TD::Types::Ok] + def register_user(first_name, last_name) + broadcast('@type' => 'registerUser', + 'first_name' => first_name, + 'last_name' => last_name) + end + + # Removes background from the list of installed backgrounds. + # + # @param background_id [Integer] The background indentifier. + # @return [TD::Types::Ok] + def remove_background(background_id) + broadcast('@type' => 'removeBackground', + 'background_id' => background_id) + end + + # Removes users from the contact list. # # @param user_ids [Array] Identifiers of users to be deleted. # @return [TD::Types::Ok] @@ -2198,6 +2533,30 @@ def remove_favorite_sticker(sticker) 'sticker' => sticker) end + # Removes an active notification from notification list. + # Needs to be called only if the notification is removed by the current user. + # + # @param notification_group_id [Integer] Identifier of notification group to which the notification belongs. + # @param notification_id [Integer] Identifier of removed notification. + # @return [TD::Types::Ok] + def remove_notification(notification_group_id, notification_id) + broadcast('@type' => 'removeNotification', + 'notification_group_id' => notification_group_id, + 'notification_id' => notification_id) + end + + # Removes a group of active notifications. + # Needs to be called only if the notification group is removed by the current user. + # + # @param notification_group_id [Integer] Notification group identifier. + # @param max_notification_id [Integer] Maximum identifier of removed notifications. + # @return [TD::Types::Ok] + def remove_notification_group(notification_group_id, max_notification_id) + broadcast('@type' => 'removeNotificationGroup', + 'notification_group_id' => notification_group_id, + 'max_notification_id' => max_notification_id) + end + # Removes a proxy server. # Can be called before authorization. # @@ -2223,7 +2582,7 @@ def remove_recent_hashtag(hashtag) # or video files; pass false to remove the sticker from the list of recently sent stickers. # @param sticker [TD::Types::InputFile] Sticker file to delete. # @return [TD::Types::Ok] - def remove_recent_sticker(sticker, is_attached: false) + def remove_recent_sticker(is_attached, sticker) broadcast('@type' => 'removeRecentSticker', 'is_attached' => is_attached, 'sticker' => sticker) @@ -2275,7 +2634,7 @@ def remove_top_chat(category, chat_id) # ordinary sticker sets. # @param sticker_set_ids [Array] Identifiers of installed sticker sets in the new correct order. # @return [TD::Types::Ok] - def reorder_installed_sticker_sets(sticker_set_ids, is_masks: false) + def reorder_installed_sticker_sets(is_masks, sticker_set_ids) broadcast('@type' => 'reorderInstalledStickerSets', 'is_masks' => is_masks, 'sticker_set_ids' => sticker_set_ids) @@ -2289,7 +2648,7 @@ def reorder_installed_sticker_sets(sticker_set_ids, is_masks: false) # @param reason [TD::Types::ChatReportReason] The reason for reporting the chat. # @param message_ids [Array] Identifiers of reported messages, if any. # @return [TD::Types::Ok] - def report_chat(chat_id, reason, message_ids = []) + def report_chat(chat_id, reason, message_ids) broadcast('@type' => 'reportChat', 'chat_id' => chat_id, 'reason' => reason, @@ -2303,7 +2662,7 @@ def report_chat(chat_id, reason, message_ids = []) # @param message_ids [Array] Identifiers of messages sent in the supergroup by the user. # This list must be non-empty. # @return [TD::Types::Ok] - def report_supergroup_spam(supergroup_id, user_id, message_ids = []) + def report_supergroup_spam(supergroup_id, user_id, message_ids) broadcast('@type' => 'reportSupergroupSpam', 'supergroup_id' => supergroup_id, 'user_id' => user_id, @@ -2311,7 +2670,7 @@ def report_supergroup_spam(supergroup_id, user_id, message_ids = []) end # Requests to send a password recovery code to an email address that was previously set up. - # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitPassword}. + # Works only when the current authorization state is authorizationStateWaitPassword. # # @return [TD::Types::Ok] def request_authentication_password_recovery @@ -2326,8 +2685,8 @@ def request_password_recovery end # Re-sends an authentication code to the user. - # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitCode} and the - # {TD::Types::AuthenticationCodeInfo#next_type} of the result is not nil. + # Works only when the current authorization state is authorizationStateWaitCode and the next_code_type of the result + # is not null. # # @return [TD::Types::Ok] def resend_authentication_code @@ -2335,7 +2694,7 @@ def resend_authentication_code end # Re-sends the authentication code sent to confirm a new phone number for the user. - # Works only if the previously received {TD::Types::AuthenticationCodeInfo#next_type} was not nil. + # Works only if the previously received authenticationCodeInfo next_code_type was not null. # # @return [TD::Types::AuthenticationCodeInfo] def resend_change_phone_number_code @@ -2349,6 +2708,23 @@ def resend_email_address_verification_code broadcast('@type' => 'resendEmailAddressVerificationCode') end + # Resends messages which failed to send. + # Can be called only for messages for which messageSendingStateFailed.can_retry is true and after specified in + # messageSendingStateFailed.retry_after time passed. + # If a message is re-sent, the corresponding failed to send message is deleted. + # Returns the sent messages in the same order as the message identifiers passed in message_ids. + # If a message can't be re-sent, null will be returned instead of the message. + # + # @param chat_id [Integer] Identifier of the chat to send messages. + # @param message_ids [Array] Identifiers of the messages to resend. + # Message identifiers must be in a strictly increasing order. + # @return [TD::Types::Messages] + def resend_messages(chat_id, message_ids) + broadcast('@type' => 'resendMessages', + 'chat_id' => chat_id, + 'message_ids' => message_ids) + end + # Resends phone number confirmation code. # # @return [TD::Types::AuthenticationCodeInfo] @@ -2363,6 +2739,13 @@ def resend_phone_number_verification_code broadcast('@type' => 'resendPhoneNumberVerificationCode') end + # Resends the 2-step verification recovery email address verification code. + # + # @return [TD::Types::PasswordState] + def resend_recovery_email_address_code + broadcast('@type' => 'resendRecoveryEmailAddressCode') + end + # Resets all notification settings to their default values. # By default, all chats are unmuted, the sound is set to "default" and message previews are shown. # @@ -2371,6 +2754,13 @@ def reset_all_notification_settings broadcast('@type' => 'resetAllNotificationSettings') end + # Resets list of installed backgrounds to its default value. + # + # @return [TD::Types::Ok] + def reset_backgrounds + broadcast('@type' => 'resetBackgrounds') + end + # Resets all network data usage statistics to zero. # Can be called before authorization. # @@ -2379,8 +2769,32 @@ def reset_network_statistics broadcast('@type' => 'resetNetworkStatistics') end + # Saves application log event on the server. + # Can be called before authorization. + # + # @param type [String] Event type. + # @param chat_id [Integer] Optional chat identifier, associated with the event. + # @param data [TD::Types::JsonValue] The log event data. + # @return [TD::Types::Ok] + def save_application_log_event(type, chat_id, data) + broadcast('@type' => 'saveApplicationLogEvent', + 'type' => type, + 'chat_id' => chat_id, + 'data' => data) + end + + # Searches for a background by its name. + # + # @param name [String] The name of the background. + # @return [TD::Types::Background] + def search_background(name) + broadcast('@type' => 'searchBackground', + 'name' => name) + end + # Searches for call messages. - # Returns the results in reverse chronological order (i.e., in order of decreasing message_id). + # Returns the results in reverse chronological order (i. + # e., in order of decreasing message_id). # For optimal performance the number of returned messages is chosen by the library. # # @param from_message_id [Integer] Identifier of the message from which to search; use 0 to get results from the last @@ -2390,7 +2804,7 @@ def reset_network_statistics # reached. # @param only_missed [Boolean] If true, returns only messages with missed calls. # @return [TD::Types::Messages] - def search_call_messages(from_message_id, limit = 100, only_missed: false) + def search_call_messages(from_message_id, limit, only_missed) broadcast('@type' => 'searchCallMessages', 'from_message_id' => from_message_id, 'limit' => limit, @@ -2401,12 +2815,12 @@ def search_call_messages(from_message_id, limit = 100, only_missed: false) # Requires administrator rights in channels. # # @param chat_id [Integer] Chat identifier. - # @param query [String, nil] Query to search for. + # @param query [String] Query to search for. # @param limit [Integer] The maximum number of users to be returned. # @param filter [TD::Types::ChatMembersFilter] The type of users to return. - # By default, {TD::Types::ChatMembersFilter::Members}. + # By default, chatMembersFilterMembers. # @return [TD::Types::ChatMembers] - def search_chat_members(chat_id, limit = 100, query: nil, filter: ChatMembersFilter::Members.new) + def search_chat_members(chat_id, query, limit, filter) broadcast('@type' => 'searchChatMembers', 'chat_id' => chat_id, 'query' => query, @@ -2415,13 +2829,14 @@ def search_chat_members(chat_id, limit = 100, query: nil, filter: ChatMembersFil end # Searches for messages with given words in the chat. - # Returns the results in reverse chronological order, i.e. in order of decreasing message_id. + # Returns the results in reverse chronological order, i.e. + # in order of decreasing message_id. # Cannot be used in secret chats with a non-empty query (searchSecretMessages should be used instead), or without an # enabled message database. # For optimal performance the number of returned messages is chosen by the library. # # @param chat_id [Integer] Identifier of the chat in which to search messages. - # @param query [String, nil] Query to search for. + # @param query [String] Query to search for. # @param sender_user_id [Integer] If not 0, only messages sent by the specified user will be returned. # Not supported in secret chats. # @param from_message_id [Integer] Identifier of the message starting from which history must be fetched; use 0 to @@ -2435,8 +2850,7 @@ def search_chat_members(chat_id, limit = 100, query: nil, filter: ChatMembersFil # reached. # @param filter [TD::Types::SearchMessagesFilter] Filter for message content in the search results. # @return [TD::Types::Messages] - def search_chat_messages(chat_id, offset = 0, limit = 100, - query: nil, sender_user_id: 0, from_message_id: 0, filter: SearchMessagesFilter::Empty.new) + def search_chat_messages(chat_id, query, sender_user_id, from_message_id, offset, limit, filter) broadcast('@type' => 'searchChatMessages', 'chat_id' => chat_id, 'query' => query, @@ -2453,7 +2867,7 @@ def search_chat_messages(chat_id, offset = 0, limit = 100, # @param chat_id [Integer] Chat identifier. # @param limit [Integer] Maximum number of messages to be returned. # @return [TD::Types::Messages] - def search_chat_recent_location_messages(chat_id, limit = 100) + def search_chat_recent_location_messages(chat_id, limit) broadcast('@type' => 'searchChatRecentLocationMessages', 'chat_id' => chat_id, 'limit' => limit) @@ -2462,11 +2876,11 @@ def search_chat_recent_location_messages(chat_id, limit = 100) # Searches for the specified query in the title and username of already known chats, this is an offline request. # Returns chats in the order seen in the chat list. # - # @param query [String, nil] Query to search for. + # @param query [String] Query to search for. # If the query is empty, returns up to 20 recently found chats. # @param limit [Integer] Maximum number of chats to be returned. # @return [TD::Types::Chats] - def search_chats(query = nil, limit = 100) + def search_chats(query, limit) broadcast('@type' => 'searchChats', 'query' => query, 'limit' => limit) @@ -2478,7 +2892,7 @@ def search_chats(query = nil, limit = 100) # @param query [String] Query to search for. # @param limit [Integer] Maximum number of chats to be returned. # @return [TD::Types::Chats] - def search_chats_on_server(query, limit = 100) + def search_chats_on_server(query, limit) broadcast('@type' => 'searchChatsOnServer', 'query' => query, 'limit' => limit) @@ -2486,21 +2900,33 @@ def search_chats_on_server(query, limit = 100) # Searches for the specified query in the first names, last names and usernames of the known user contacts. # - # @param query [String, nil] Query to search for; can be empty to return all contacts. + # @param query [String, nil] Query to search for; may be empty to return all contacts. # @param limit [Integer] Maximum number of users to be returned. # @return [TD::Types::Users] - def search_contacts(query = nil, limit = 100) + def search_contacts(query = nil, limit) broadcast('@type' => 'searchContacts', 'query' => query, 'limit' => limit) end + # Searches for emojis by keywords. + # Supported only if the file database is enabled. + # + # @param text [String] Text to search for. + # @param exact_match [Boolean] True, if only emojis, which exactly match text needs to be returned. + # @return [TD::Types::Emojis] + def search_emojis(text, exact_match) + broadcast('@type' => 'searchEmojis', + 'text' => text, + 'exact_match' => exact_match) + end + # Searches for recently used hashtags by their prefix. # - # @param prefix [String, nil] Hashtag prefix to search for. + # @param prefix [String] Hashtag prefix to search for. # @param limit [Integer] Maximum number of hashtags to be returned. # @return [TD::Types::Hashtags] - def search_hashtags(prefix = nil, limit = 100) + def search_hashtags(prefix, limit) broadcast('@type' => 'searchHashtags', 'prefix' => prefix, 'limit' => limit) @@ -2509,10 +2935,10 @@ def search_hashtags(prefix = nil, limit = 100) # Searches for installed sticker sets by looking for specified query in their title and name. # # @param is_masks [Boolean] Pass true to return mask sticker sets; pass false to return ordinary sticker sets. - # @param query [String, nil] Query to search for. + # @param query [String] Query to search for. # @param limit [Integer] Maximum number of sticker sets to return. # @return [TD::Types::StickerSets] - def search_installed_sticker_sets(query = nil, limit = 100, is_masks: false) + def search_installed_sticker_sets(is_masks, query, limit) broadcast('@type' => 'searchInstalledStickerSets', 'is_masks' => is_masks, 'query' => query, @@ -2532,7 +2958,7 @@ def search_installed_sticker_sets(query = nil, limit = 100, is_masks: false) # Fewer messages may be returned than specified by the limit, even if the end of the message history has not been # reached. # @return [TD::Types::Messages] - def search_messages(query, limit = 100, offset_date: 0, offset_chat_id: 0, offset_message_id: 0) + def search_messages(query, offset_date, offset_chat_id, offset_message_id, limit) broadcast('@type' => 'searchMessages', 'query' => query, 'offset_date' => offset_date, @@ -2572,7 +2998,7 @@ def search_public_chats(query) # @param chat_id [Integer] Identifier of the chat in which to search. # Specify 0 to search in all secret chats. # @param query [String] Query to search for. - # If empty, {#search_chat_messages} should be used instead. + # If empty, searchChatMessages should be used instead. # @param from_search_id [Integer] The identifier from the result of a previous request, use 0 to get results from the # last message. # @param limit [Integer] Maximum number of messages to be returned; up to 100. @@ -2580,7 +3006,7 @@ def search_public_chats(query) # reached. # @param filter [TD::Types::SearchMessagesFilter] A filter for the content of messages in the search results. # @return [TD::Types::FoundMessages] - def search_secret_messages(chat_id, query, limit = 100, from_search_id: 0, filter: SearchMessagesFilter::Empty.new) + def search_secret_messages(chat_id, query, from_search_id, limit, filter) broadcast('@type' => 'searchSecretMessages', 'chat_id' => chat_id, 'query' => query, @@ -2611,9 +3037,9 @@ def search_sticker_sets(query) # Searches for stickers from public sticker sets that correspond to a given emoji. # # @param emoji [String] String representation of emoji; must be non-empty. - # @param limit [Integer] Maximum number of stickers to be returned. + # @param limit [Integer, nil] Maximum number of stickers to be returned. # @return [TD::Types::Stickers] - def search_stickers(emoji, limit = 100) + def search_stickers(emoji, limit = nil) broadcast('@type' => 'searchStickers', 'emoji' => emoji, 'limit' => limit) @@ -2622,13 +3048,14 @@ def search_stickers(emoji, limit = 100) # Invites a bot to a chat (if it is not yet a member) and sends it the /start command. # Bots can't be invited to a private chat other than the chat with the bot. # Bots can't be invited to channels (although they can be added as admins) and secret chats. + # Returns the sent message. # # @param bot_user_id [Integer] Identifier of the bot. # @param chat_id [Integer] Identifier of the target chat. - # @param parameter [String, nil] A hidden parameter sent to the bot for deep linking purposes - # @see https://api.telegram.org/bots#deep-linking - # @return [TD::Types::Message] the sent message. - def send_bot_start_message(bot_user_id, chat_id, parameter = nil) + # @param parameter [String] A hidden parameter sent to the bot for deep linking purposes + # (https://core.telegram.org/bots#deep-linking). + # @return [TD::Types::Message] + def send_bot_start_message(bot_user_id, chat_id, parameter) broadcast('@type' => 'sendBotStartMessage', 'bot_user_id' => bot_user_id, 'chat_id' => chat_id, @@ -2650,13 +3077,16 @@ def send_call_debug_information(call_id, debug_information) # # @param call_id [Integer] Call identifier. # @param rating [Integer] Call rating; 1-5. - # @param comment [String, nil] An optional user comment if the rating is less than 5. + # @param comment [String] An optional user comment if the rating is less than 5. + # @param problems [Array] List of the exact types of problems with the call, specified by the + # user. # @return [TD::Types::Ok] - def send_call_rating(call_id, rating, comment = nil) - broadcast('@type' => 'sendCallRating', - 'call_id' => call_id, - 'rating' => rating, - 'comment' => comment) + def send_call_rating(call_id, rating, comment, problems) + broadcast('@type' => 'sendCallRating', + 'call_id' => call_id, + 'rating' => rating, + 'comment' => comment, + 'problems' => problems) end # Sends a notification about user activity in a chat. @@ -2723,30 +3153,35 @@ def send_email_address_verification_code(email_address) # @param from_background [Boolean] Pass true if the message is sent from background. # @param query_id [Integer] Identifier of the inline query. # @param result_id [String] Identifier of the inline result. + # @param hide_via_bot [Boolean] If true, there will be no mention of a bot, via which the message is sent. + # Can be used only for bots GetOption("animation_search_bot_username"), GetOption("photo_search_bot_username") and + # GetOption("venue_search_bot_username"). # @return [TD::Types::Message] - def send_inline_query_result_message(chat_id, query_id, result_id, - reply_to_message_id: 0, disable_notification: false, from_background: false) + def send_inline_query_result_message(chat_id, reply_to_message_id, disable_notification, from_background, query_id, + result_id, hide_via_bot) broadcast('@type' => 'sendInlineQueryResultMessage', 'chat_id' => chat_id, 'reply_to_message_id' => reply_to_message_id, 'disable_notification' => disable_notification, 'from_background' => from_background, 'query_id' => query_id, - 'result_id' => result_id) + 'result_id' => result_id, + 'hide_via_bot' => hide_via_bot) end # Sends a message. + # Returns the sent message. # # @param chat_id [Integer] Target chat. # @param reply_to_message_id [Integer] Identifier of the message to reply to or 0. # @param disable_notification [Boolean] Pass true to disable notification for the message. # Not supported in secret chats. # @param from_background [Boolean] Pass true if the message is sent from the background. - # @param reply_markup [TD::Types::ReplyMarkup, nil] Markup for replying to the message; for bots only. + # @param reply_markup [TD::Types::ReplyMarkup] Markup for replying to the message; for bots only. # @param input_message_content [TD::Types::InputMessageContent] The content of the message to be sent. - # @return [TD::Types::Message] the sent message. - def send_message(chat_id, input_message_content, - reply_to_message_id: 0, disable_notification: false, from_background: false, reply_markup: nil) + # @return [TD::Types::Message] + def send_message(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, + input_message_content) broadcast('@type' => 'sendMessage', 'chat_id' => chat_id, 'reply_to_message_id' => reply_to_message_id, @@ -2758,6 +3193,7 @@ def send_message(chat_id, input_message_content, # Sends messages grouped together into an album. # Currently only photo and video messages can be grouped into an album. + # Returns sent messages. # # @param chat_id [Integer] Target chat. # @param reply_to_message_id [Integer] Identifier of a message to reply to or 0. @@ -2765,9 +3201,8 @@ def send_message(chat_id, input_message_content, # Not supported in secret chats. # @param from_background [Boolean] Pass true if the messages are sent from the background. # @param input_message_contents [Array] Contents of messages to be sent. - # @return [TD::Types::Messages] the sent messages. - def send_message_album(chat_id, input_message_contents, - reply_to_message_id: 0, disable_notification: false, from_background: false) + # @return [TD::Types::Messages] + def send_message_album(chat_id, reply_to_message_id, disable_notification, from_background, input_message_contents) broadcast('@type' => 'sendMessageAlbum', 'chat_id' => chat_id, 'reply_to_message_id' => reply_to_message_id, @@ -2777,6 +3212,8 @@ def send_message_album(chat_id, input_message_contents, end # Sends a Telegram Passport authorization form, effectively sharing data with the service. + # This method must be called after getPassportAuthorizationFormAvailableElements if some previously available + # elements need to be used. # # @param autorization_form_id [Integer] Authorization form identifier. # @param types [Array] Types of Telegram Passport elements chosen by user to complete @@ -2792,11 +3229,11 @@ def send_passport_authorization_form(autorization_form_id, types) # # @param chat_id [Integer] Chat identifier of the Invoice message. # @param message_id [Integer] Message identifier. - # @param order_info_id [String] Identifier returned by {#validate_order_info}, or an empty string. - # @param shipping_option_id [String, nil] Identifier of a chosen shipping option, if applicable. + # @param order_info_id [String] Identifier returned by ValidateOrderInfo, or an empty string. + # @param shipping_option_id [String] Identifier of a chosen shipping option, if applicable. # @param credentials [TD::Types::InputCredentials] The credentials chosen by user for payment. # @return [TD::Types::PaymentResult] - def send_payment_form(chat_id, message_id, credentials, order_info_id: "", shipping_option_id: nil) + def send_payment_form(chat_id, message_id, order_info_id, shipping_option_id, credentials) broadcast('@type' => 'sendPaymentForm', 'chat_id' => chat_id, 'message_id' => message_id, @@ -2811,32 +3248,26 @@ def send_payment_form(chat_id, message_id, credentials, order_info_id: "", shipp # # @param hash [String] Value of the "hash" parameter from the link. # @param phone_number [String] Value of the "phone" parameter from the link. - # @param allow_flash_call [Boolean] Pass true if the authentication code may be sent via flash call to the specified - # phone number. - # @param is_current_phone_number [Boolean] Pass true if the phone number is used on the current device. - # Ignored if allow_flash_call is false. + # @param settings [TD::Types::PhoneNumberAuthenticationSettings] Settings for the authentication of the user's phone + # number. # @return [TD::Types::AuthenticationCodeInfo] - def send_phone_number_confirmation_code(hash, phone_number, allow_flash_call: false, is_current_phone_number: false) - broadcast('@type' => 'sendPhoneNumberConfirmationCode', - 'hash' => hash, - 'phone_number' => phone_number, - 'allow_flash_call' => allow_flash_call, - 'is_current_phone_number' => is_current_phone_number) + def send_phone_number_confirmation_code(hash, phone_number, settings) + broadcast('@type' => 'sendPhoneNumberConfirmationCode', + 'hash' => hash, + 'phone_number' => phone_number, + 'settings' => settings) end # Sends a code to verify a phone number to be added to a user's Telegram Passport. # # @param phone_number [String] The phone number of the user, in international format. - # @param allow_flash_call [Boolean] Pass true if the authentication code may be sent via flash call to the specified - # phone number. - # @param is_current_phone_number [Boolean] Pass true if the phone number is used on the current device. - # Ignored if allow_flash_call is false. + # @param settings [TD::Types::PhoneNumberAuthenticationSettings] Settings for the authentication of the user's phone + # number. # @return [TD::Types::AuthenticationCodeInfo] - def send_phone_number_verification_code(phone_number, allow_flash_call: false, is_current_phone_number: false) - broadcast('@type' => 'sendPhoneNumberVerificationCode', - 'phone_number' => phone_number, - 'allow_flash_call' => allow_flash_call, - 'is_current_phone_number' => is_current_phone_number) + def send_phone_number_verification_code(phone_number, settings) + broadcast('@type' => 'sendPhoneNumberVerificationCode', + 'phone_number' => phone_number, + 'settings' => settings) end # Changes the period of inactivity after which the account of the current user will automatically be deleted. @@ -2860,19 +3291,43 @@ def set_alarm(seconds) end # Sets the phone number of the user and sends an authentication code to the user. - # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitPhoneNumber}. + # Works only when the current authorization state is authorizationStateWaitPhoneNumber, or if there is no pending + # authentication query and the current authorization state is authorizationStateWaitCode or + # authorizationStateWaitPassword. # # @param phone_number [String] The phone number of the user, in international format. - # @param allow_flash_call [Boolean] Pass true if the authentication code may be sent via flash call to the specified - # phone number. - # @param is_current_phone_number [Boolean] Pass true if the phone number is used on the current device. - # Ignored if allow_flash_call is false. + # @param settings [TD::Types::PhoneNumberAuthenticationSettings] Settings for the authentication of the user's phone + # number. + # @return [TD::Types::Ok] + def set_authentication_phone_number(phone_number, settings) + broadcast('@type' => 'setAuthenticationPhoneNumber', + 'phone_number' => phone_number, + 'settings' => settings) + end + + # Sets auto-download settings. + # + # @param settings [TD::Types::AutoDownloadSettings] New user auto-download settings. + # @param type [TD::Types::NetworkType] Type of the network for which the new settings are applied. # @return [TD::Types::Ok] - def set_authentication_phone_number(phone_number, allow_flash_call: false, is_current_phone_number: false) - broadcast('@type' => 'setAuthenticationPhoneNumber', - 'phone_number' => phone_number, - 'allow_flash_call' => allow_flash_call, - 'is_current_phone_number' => is_current_phone_number) + def set_auto_download_settings(settings, type) + broadcast('@type' => 'setAutoDownloadSettings', + 'settings' => settings, + 'type' => type) + end + + # Changes the background selected by the user; adds background to the list of installed backgrounds. + # + # @param background [TD::Types::InputBackground] The input background to use, null for solid backgrounds. + # @param type [TD::Types::BackgroundType] Background type; null for default background. + # The method will return error 404 if type is null. + # @param for_dark_theme [Boolean] True, if the background is chosen for dark theme. + # @return [TD::Types::Background] + def set_background(background, type, for_dark_theme) + broadcast('@type' => 'setBackground', + 'background' => background, + 'type' => type, + 'for_dark_theme' => for_dark_theme) end # Changes the bio of the current user. @@ -2907,10 +3362,23 @@ def set_chat_client_data(chat_id, client_data) 'client_data' => client_data) end + # Changes information about a chat. + # Available for basic groups, supergroups, and channels. + # Requires can_change_info rights. + # + # @param chat_id [Integer] Identifier of the chat. + # @param description [String] New chat description; 0-255 characters. + # @return [TD::Types::Ok] + def set_chat_description(chat_id, description) + broadcast('@type' => 'setChatDescription', + 'chat_id' => chat_id, + 'description' => description) + end + # Changes the draft message in a chat. # # @param chat_id [Integer] Chat identifier. - # @param draft_message [TD::Types::DraftMessage, nil] New draft message. + # @param draft_message [TD::Types::DraftMessage, nil] New draft message; may be null. # @return [TD::Types::Ok] def set_chat_draft_message(chat_id, draft_message = nil) broadcast('@type' => 'setChatDraftMessage', @@ -2919,7 +3387,7 @@ def set_chat_draft_message(chat_id, draft_message = nil) end # Changes the status of a chat member, needs appropriate privileges. - # This function is currently not suitable for adding new members to the chat; instead, use {#add_chat_member}. + # This function is currently not suitable for adding new members to the chat; instead, use addChatMember. # The chat member status will not be changed until it has been synchronized with the server. # # @param chat_id [Integer] Chat identifier. @@ -2944,17 +3412,30 @@ def set_chat_notification_settings(chat_id, notification_settings) 'notification_settings' => notification_settings) end + # Changes the chat members permissions. + # Supported only for basic groups and supergroups. + # Requires can_restrict_members administrator right. + # + # @param chat_id [Integer] Chat identifier. + # @param permissions [TD::Types::ChatPermissions] New non-administrator members permissions in the chat. + # @return [TD::Types::Ok] + def set_chat_permissions(chat_id, permissions) + broadcast('@type' => 'setChatPermissions', + 'chat_id' => chat_id, + 'permissions' => permissions) + end + # Changes the photo of a chat. # Supported only for basic groups, supergroups and channels. - # Requires administrator rights in basic groups and the appropriate administrator rights in supergroups and channels. + # Requires can_change_info rights. # The photo will not be changed before request to the server has been completed. # # @param chat_id [Integer] Chat identifier. # @param photo [TD::Types::InputFile] New chat photo. - # You can use a zero {TD::Types::InputFile::Id} to delete the chat photo. + # You can use a zero InputFileId to delete the chat photo. # Files that are accessible only by HTTP URL are not acceptable. # @return [TD::Types::Ok] - def set_chat_photo(chat_id, photo = InputFile::Id.new(id: 0)) + def set_chat_photo(chat_id, photo) broadcast('@type' => 'setChatPhoto', 'chat_id' => chat_id, 'photo' => photo) @@ -2962,11 +3443,11 @@ def set_chat_photo(chat_id, photo = InputFile::Id.new(id: 0)) # Changes the chat title. # Supported only for basic groups, supergroups and channels. - # Requires administrator rights in basic groups and the appropriate administrator rights in supergroups and channels. + # Requires can_change_info rights. # The title will not be changed until the request to the server has been completed. # # @param chat_id [Integer] Chat identifier. - # @param title [String] New title of the chat; 1-255 characters. + # @param title [String] New title of the chat; 1-128 characters. # @return [TD::Types::Ok] def set_chat_title(chat_id, title) broadcast('@type' => 'setChatTitle', @@ -2974,11 +3455,12 @@ def set_chat_title(chat_id, title) 'title' => title) end - # Adds or changes a custom language pack to the current localization target. + # Adds or changes a custom local language pack to the current localization target. # # @param info [TD::Types::LanguagePackInfo] Information about the language pack. # Language pack ID must start with 'X', consist only of English letters, digits and hyphens, and must not exceed 64 # characters. + # Can be called before authorization. # @param strings [Array] Strings of the new language pack. # @return [TD::Types::Ok] def set_custom_language_pack(info, strings) @@ -2987,10 +3469,11 @@ def set_custom_language_pack(info, strings) 'strings' => strings) end - # Adds, edits or deletes a string in a custom language pack. + # Adds, edits or deletes a string in a custom local language pack. + # Can be called before authorization. # - # @param language_pack_id [String] Identifier of a previously added custom language pack in the current localization - # target. + # @param language_pack_id [String] Identifier of a previously added custom local language pack in the current + # localization target. # @param new_string [TD::Types::LanguagePackString] New language pack string. # @return [TD::Types::Ok] def set_custom_language_pack_string(language_pack_id, new_string) @@ -3009,13 +3492,13 @@ def set_database_encryption_key(new_encryption_key) 'new_encryption_key' => new_encryption_key) end - # The next part of a file was generated. + # Informs TDLib on a file generation prograss. # # @param generation_id [Integer] The identifier of the generation process. # @param expected_size [Integer] Expected size of the generated file, in bytes; 0 if unknown. # @param local_prefix_size [Integer] The number of bytes already generated. # @return [TD::Types::Ok] - def set_file_generation_progress(generation_id, local_prefix_size, expected_size: 0) + def set_file_generation_progress(generation_id, expected_size, local_prefix_size) broadcast('@type' => 'setFileGenerationProgress', 'generation_id' => generation_id, 'expected_size' => expected_size, @@ -3024,7 +3507,7 @@ def set_file_generation_progress(generation_id, local_prefix_size, expected_size # Updates the game score of the specified user in the game; for bots only. # - # @param chat_id [Integer] The chat to which the message with the game. + # @param chat_id [Integer] The chat to which the message with the game belongs. # @param message_id [Integer] Identifier of the message. # @param edit_message [Boolean] True, if the message should be edited. # @param user_id [Integer] User identifier. @@ -3032,7 +3515,7 @@ def set_file_generation_progress(generation_id, local_prefix_size, expected_size # @param force [Boolean] Pass true to update the score even if it decreases. # If the score is 0, the user will be deleted from the high score table. # @return [TD::Types::Message] - def set_game_score(chat_id, message_id, user_id, score, edit_message: false, force: false) + def set_game_score(chat_id, message_id, edit_message, user_id, score, force) broadcast('@type' => 'setGameScore', 'chat_id' => chat_id, 'message_id' => message_id, @@ -3051,7 +3534,7 @@ def set_game_score(chat_id, message_id, user_id, score, edit_message: false, for # @param force [Boolean] Pass true to update the score even if it decreases. # If the score is 0, the user will be deleted from the high score table. # @return [TD::Types::Ok] - def set_inline_game_score(inline_message_id, user_id, score, edit_message: false, force: false) + def set_inline_game_score(inline_message_id, edit_message, user_id, score, force) broadcast('@type' => 'setInlineGameScore', 'inline_message_id' => inline_message_id, 'edit_message' => edit_message, @@ -3060,11 +3543,52 @@ def set_inline_game_score(inline_message_id, user_id, score, edit_message: false 'force' => force) end + # Sets new log stream for internal logging of TDLib. + # This is an offline method. + # Can be called before authorization. + # Can be called synchronously. + # + # @param log_stream [TD::Types::LogStream] New log stream. + # @return [TD::Types::Ok] + def set_log_stream(log_stream) + broadcast('@type' => 'setLogStream', + 'log_stream' => log_stream) + end + + # Sets the verbosity level for a specified TDLib internal log tag. + # This is an offline method. + # Can be called before authorization. + # Can be called synchronously. + # + # @param tag [String] Logging tag to change verbosity level. + # @param new_verbosity_level [Integer] New verbosity level; 1-1024. + # @return [TD::Types::Ok] + def set_log_tag_verbosity_level(tag, new_verbosity_level) + broadcast('@type' => 'setLogTagVerbosityLevel', + 'tag' => tag, + 'new_verbosity_level' => new_verbosity_level) + end + + # Sets the verbosity level of the internal logging of TDLib. + # This is an offline method. + # Can be called before authorization. + # Can be called synchronously. + # + # @param new_verbosity_level [Integer] New value of the verbosity level for logging. + # Value 0 corresponds to fatal errors, value 1 corresponds to errors, value 2 corresponds to warnings and debug + # warnings, value 3 corresponds to informational, value 4 corresponds to debug, value 5 corresponds to verbose debug, + # value greater than 5 and up to 1023 can be used to enable even more logging. + # @return [TD::Types::Ok] + def set_log_verbosity_level(new_verbosity_level) + broadcast('@type' => 'setLogVerbosityLevel', + 'new_verbosity_level' => new_verbosity_level) + end + # Changes the first and last name of the current user. - # If something changes, {TD::Types::Update::User} will be sent. + # If something changes, updateUser will be sent. # - # @param first_name [String] The new value of the first name for the user; 1-255 characters. - # @param last_name [String] The new value of the optional last name for the user; 0-255 characters. + # @param first_name [String] The new value of the first name for the user; 1-64 characters. + # @param last_name [String] The new value of the optional last name for the user; 0-64 characters. # @return [TD::Types::Ok] def set_name(first_name, last_name) broadcast('@type' => 'setName', @@ -3080,20 +3604,19 @@ def set_name(first_name, last_name) # network data usage statistics. # # @param type [TD::Types::NetworkType] The new network type. - # By default, {TD::Types::NetworkType::Other}. + # By default, networkTypeOther. # @return [TD::Types::Ok] - def set_network_type(type = NetworkType::Other) + def set_network_type(type) broadcast('@type' => 'setNetworkType', 'type' => type) end # Sets the value of an option. - # Only writable options can be set. + # (Check the list of available options on https://core.telegram.org/tdlib/options.) Only writable options can be set. # Can be called before authorization. # # @param name [String] The name of the option. # @param value [TD::Types::OptionValue] The new value of the option. - # @see https://core.telegram.org/tdlib/options List of available options # @return [TD::Types::Ok] def set_option(name, value) broadcast('@type' => 'setOption', @@ -3127,16 +3650,14 @@ def set_passport_element_errors(user_id, errors) end # Changes the password for the user. - # If a new recovery email address is specified, then the error EMAIL_UNCONFIRMED is returned and the password change - # will not be applied until the new recovery email address has been confirmed. - # The application should periodically call {#get_password_state} to check whether the new email address has been - # confirmed. + # If a new recovery email address is specified, then the change will not be applied until the new recovery email + # address is confirmed. # # @param old_password [String] Previous password of the user. # @param new_password [String, nil] New password of the user; may be empty to remove the password. - # @param new_hint [String, nil] New password hint. + # @param new_hint [String, nil] New password hint; may be empty. # @param set_recovery_email_address [Boolean] Pass true if the recovery email address should be changed. - # @param new_recovery_email_address [String, nil] New recovery email address. + # @param new_recovery_email_address [String, nil] New recovery email address; may be empty. # @return [TD::Types::PasswordState] def set_password(old_password, new_password: nil, new_hint: nil, set_recovery_email_address: false, new_recovery_email_address: nil) @@ -3157,8 +3678,22 @@ def set_pinned_chats(chat_ids) 'chat_ids' => chat_ids) end + # Changes user answer to a poll. + # + # @param chat_id [Integer] Identifier of the chat to which the poll belongs. + # @param message_id [Integer] Identifier of the message containing the poll. + # @param option_ids [Array] 0-based identifiers of options, chosen by the user. + # Currently user can't choose more than 1 option. + # @return [TD::Types::Ok] + def set_poll_answer(chat_id, message_id, option_ids) + broadcast('@type' => 'setPollAnswer', + 'chat_id' => chat_id, + 'message_id' => message_id, + 'option_ids' => option_ids) + end + # Uploads a new profile photo for the current user. - # If something changes, {TD::Types::Update::User} will be sent. + # If something changes, updateUser will be sent. # # @param photo [TD::Types::InputFile] Profile photo to set. # {TD::Types::InputFile::Id} and {TD::Types::InputFile::Remote} may still be unsupported. @@ -3168,18 +3703,16 @@ def set_profile_photo(photo) 'photo' => photo) end - # Changes the recovery email address of the user. - # If a new recovery email address is specified, then the error EMAIL_UNCONFIRMED is returned and the email address - # will not be changed until the new email has been confirmed. - # The application should periodically call {#get_password_state} to check whether the email address has been - # confirmed. + # Changes the 2-step verification recovery email address of the user. + # If a new recovery email address is specified, then the change will not be applied until the new recovery email + # address is confirmed. # If new_recovery_email_address is the same as the email address that is currently set up, this call succeeds # immediately and aborts all other requests waiting for an email confirmation. # # @param password [String] Password of the current user. # @param new_recovery_email_address [String] New recovery email address. # @return [TD::Types::PasswordState] - def set_recovery_email_address(new_recovery_email_address, password) + def set_recovery_email_address(password, new_recovery_email_address) broadcast('@type' => 'setRecoveryEmailAddress', 'password' => password, 'new_recovery_email_address' => new_recovery_email_address) @@ -3209,24 +3742,13 @@ def set_sticker_position_in_set(sticker, position) 'position' => position) end - # Changes information about a supergroup or channel; requires appropriate administrator rights. - # - # @param supergroup_id [Integer] Identifier of the supergroup or channel. - # @param description [String] New supergroup or channel description; 0-255 characters. - # @return [TD::Types::Ok] - def set_supergroup_description(supergroup_id, description) - broadcast('@type' => 'setSupergroupDescription', - 'supergroup_id' => supergroup_id, - 'description' => description) - end - - # Changes the sticker set of a supergroup; requires appropriate rights in the supergroup. + # Changes the sticker set of a supergroup; requires can_change_info rights. # # @param supergroup_id [Integer] Identifier of the supergroup. # @param sticker_set_id [Integer] New value of the supergroup sticker set identifier. # Use 0 to remove the supergroup sticker set. # @return [TD::Types::Ok] - def set_supergroup_sticker_set(supergroup_id, sticker_set_id = 0) + def set_supergroup_sticker_set(supergroup_id, sticker_set_id) broadcast('@type' => 'setSupergroupStickerSet', 'supergroup_id' => supergroup_id, 'sticker_set_id' => sticker_set_id) @@ -3238,14 +3760,14 @@ def set_supergroup_sticker_set(supergroup_id, sticker_set_id = 0) # @param username [String] New value of the username. # Use an empty string to remove the username. # @return [TD::Types::Ok] - def set_supergroup_username(supergroup_id, username = "") + def set_supergroup_username(supergroup_id, username) broadcast('@type' => 'setSupergroupUsername', 'supergroup_id' => supergroup_id, 'username' => username) end # Sets the parameters for TDLib initialization. - # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitTdlibParameters}. + # Works only when the current authorization state is authorizationStateWaitTdlibParameters. # # @param parameters [TD::Types::TdlibParameters] Parameters. # @return [TD::Types::Ok] @@ -3266,16 +3788,41 @@ def set_user_privacy_setting_rules(setting, rules) end # Changes the username of the current user. - # If something changes, {TD::Types::Update::User} will be sent. + # If something changes, updateUser will be sent. # # @param username [String] The new value of the username. # Use an empty string to remove the username. # @return [TD::Types::Ok] - def set_username(username = "") + def set_username(username) broadcast('@type' => 'setUsername', 'username' => username) end + # Stops a poll. + # A poll in a message can be stopped when the message has can_be_edited flag set. + # + # @param chat_id [Integer] Identifier of the chat to which the poll belongs. + # @param message_id [Integer] Identifier of the message containing the poll. + # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup; for bots only. + # @return [TD::Types::Ok] + def stop_poll(chat_id, message_id, reply_markup) + broadcast('@type' => 'stopPoll', + 'chat_id' => chat_id, + 'message_id' => message_id, + 'reply_markup' => reply_markup) + end + + # Fetches the latest versions of all strings from a language pack in the current localization target from the server. + # This method doesn't need to be called explicitly for the current used/base language packs. + # Can be called before authorization. + # + # @param language_pack_id [String] Language pack identifier. + # @return [TD::Types::Ok] + def synchronize_language_pack(language_pack_id) + broadcast('@type' => 'synchronizeLanguagePack', + 'language_pack_id' => language_pack_id) + end + # Terminates all other sessions of the current user. # # @return [TD::Types::Ok] @@ -3292,17 +3839,6 @@ def terminate_session(session_id) 'session_id' => session_id) end - # Toggles the "All members are admins" setting in basic groups; requires creator privileges in the group. - # - # @param basic_group_id [Integer] Identifier of the basic group. - # @param everyone_is_administrator [Boolean] New value of everyone_is_administrator. - # @return [TD::Types::Ok] - def toggle_basic_group_administrators(basic_group_id, everyone_is_administrator) - broadcast('@type' => 'toggleBasicGroupAdministrators', - 'basic_group_id' => basic_group_id, - 'everyone_is_administrator' => everyone_is_administrator) - end - # Changes the value of the default disable_notification parameter, used when a message is sent to a chat. # # @param chat_id [Integer] Chat identifier. @@ -3337,20 +3873,7 @@ def toggle_chat_is_pinned(chat_id, is_pinned) 'is_pinned' => is_pinned) end - # Toggles whether all members of a supergroup can add new members; requires appropriate administrator rights in the - # supergroup. - # - # @param supergroup_id [Integer] Identifier of the supergroup. - # @param anyone_can_invite [Boolean] New value of anyone_can_invite. - # @return [TD::Types::Ok] - def toggle_supergroup_invites(supergroup_id, anyone_can_invite) - broadcast('@type' => 'toggleSupergroupInvites', - 'supergroup_id' => supergroup_id, - 'anyone_can_invite' => anyone_can_invite) - end - - # Toggles whether the message history of a supergroup is available to new members; requires appropriate administrator - # rights in the supergroup. + # Toggles whether the message history of a supergroup is available to new members; requires can_change_info rights. # # @param supergroup_id [Integer] The identifier of the supergroup. # @param is_all_history_available [Boolean] The new value of is_all_history_available. @@ -3361,7 +3884,7 @@ def toggle_supergroup_is_all_history_available(supergroup_id, is_all_history_ava 'is_all_history_available' => is_all_history_available) end - # Toggles sender signatures messages sent in a channel; requires appropriate administrator rights in the channel. + # Toggles sender signatures messages sent in a channel; requires can_change_info rights. # # @param supergroup_id [Integer] Identifier of the channel. # @param sign_messages [Boolean] New value of sign_messages. @@ -3381,18 +3904,17 @@ def unblock_user(user_id) 'user_id' => user_id) end - # Removes the pinned message from a supergroup or channel; requires appropriate administrator rights in the - # supergroup or channel. + # Removes the pinned message from a chat; requires can_pin_messages rights in the group or channel. # - # @param supergroup_id [Integer] Identifier of the supergroup or channel. + # @param chat_id [Integer] Identifier of the chat. # @return [TD::Types::Ok] - def unpin_supergroup_message(supergroup_id) - broadcast('@type' => 'unpinSupergroupMessage', - 'supergroup_id' => supergroup_id) + def unpin_chat_message(chat_id) + broadcast('@type' => 'unpinChatMessage', + 'chat_id' => chat_id) end - # Creates a new supergroup from an existing basic group and sends a corresponding - # {TD::Types::MessageContent::UpgradeTo} and {TD::Types::MessageContent::ChatUpgradeFrom}. + # Creates a new supergroup from an existing basic group and sends a corresponding messageChatUpgradeTo and + # messageChatUpgradeFrom; requires creator privileges. # Deactivates the original basic group. # # @param chat_id [Integer] Identifier of the chat to upgrade. @@ -3403,29 +3925,29 @@ def upgrade_basic_group_chat_to_supergroup_chat(chat_id) end # Asynchronously uploads a file to the cloud without sending it in a message. - # {TD::Types::Update::File} will be used to notify about upload progress and successful completion of the upload. + # updateFile will be used to notify about upload progress and successful completion of the upload. # The file will not have a persistent remote identifier until it will be sent in a message. # # @param file [TD::Types::InputFile] File to upload. # @param file_type [TD::Types::FileType] File type. # @param priority [Integer] Priority of the upload (1-32). # The higher the priority, the earlier the file will be uploaded. - # If the priorities of two files are equal, then the first one for which {#upload_file} was called will be uploaded + # If the priorities of two files are equal, then the first one for which uploadFile was called will be uploaded # first. # @return [TD::Types::File] - def upload_file(file, file_type, priority = 1) + def upload_file(file, file_type, priority) broadcast('@type' => 'uploadFile', 'file' => file, 'file_type' => file_type, 'priority' => priority) end - # Uploads a PNG image with a sticker; for bots only + # Uploads a PNG image with a sticker; for bots only; returns the uploaded file. # # @param user_id [Integer] Sticker file owner. # @param png_sticker [TD::Types::InputFile] PNG image with the sticker; must be up to 512 kB in size and fit in # 512x512 square. - # @return [TD::Types::File] the uploaded file. + # @return [TD::Types::File] def upload_sticker_file(user_id, png_sticker) broadcast('@type' => 'uploadStickerFile', 'user_id' => user_id, @@ -3440,7 +3962,7 @@ def upload_sticker_file(user_id, png_sticker) # @param order_info [TD::Types::OrderInfo] The order information, provided by the user. # @param allow_save [Boolean] True, if the order information can be saved. # @return [TD::Types::ValidatedOrderInfo] - def validate_order_info(chat_id, message_id, order_info, allow_save: false) + def validate_order_info(chat_id, message_id, order_info, allow_save) broadcast('@type' => 'validateOrderInfo', 'chat_id' => chat_id, 'message_id' => message_id, @@ -3448,7 +3970,7 @@ def validate_order_info(chat_id, message_id, order_info, allow_save: false) 'allow_save' => allow_save) end - # This method should be called if messages are being viewed by the user. + # Informs TDLib that messages are being viewed by the user. # Many useful activities depend on whether the messages are currently being viewed or not (e.g., marking messages as # read, incrementing a view counter, updating a view counter, removing deleted messages in supergroups and channels). # @@ -3456,7 +3978,7 @@ def validate_order_info(chat_id, message_id, order_info, allow_save: false) # @param message_ids [Array] The identifiers of the messages being viewed. # @param force_read [Boolean] True, if messages in closed chats should be marked as read. # @return [TD::Types::Ok] - def view_messages(chat_id, message_ids, force_read: false) + def view_messages(chat_id, message_ids, force_read) broadcast('@type' => 'viewMessages', 'chat_id' => chat_id, 'message_ids' => message_ids, @@ -3471,4 +3993,19 @@ def view_trending_sticker_sets(sticker_set_ids) broadcast('@type' => 'viewTrendingStickerSets', 'sticker_set_ids' => sticker_set_ids) end + + # Writes a part of a generated file. + # This method is intended to be used only if the client has no direct access to TDLib's file system, because it is + # usually slower than a direct write to the destination file. + # + # @param generation_id [Integer] The identifier of the generation process. + # @param offset [Integer] The offset from which to write the data to the file. + # @param data [String] The data to write. + # @return [TD::Types::Ok] + def write_generated_file_part(generation_id, offset, data) + broadcast('@type' => 'writeGeneratedFilePart', + 'generation_id' => generation_id, + 'offset' => offset, + 'data' => data) + end end diff --git a/lib/tdlib/types.rb b/lib/tdlib/types.rb index 9910455..8543681 100644 --- a/lib/tdlib/types.rb +++ b/lib/tdlib/types.rb @@ -24,6 +24,7 @@ module TD::Types 'authorizationStateWaitEncryptionKey' => 'AuthorizationState::WaitEncryptionKey', 'authorizationStateWaitPhoneNumber' => 'AuthorizationState::WaitPhoneNumber', 'authorizationStateWaitCode' => 'AuthorizationState::WaitCode', + 'authorizationStateWaitRegistration' => 'AuthorizationState::WaitRegistration', 'authorizationStateWaitPassword' => 'AuthorizationState::WaitPassword', 'authorizationStateReady' => 'AuthorizationState::Ready', 'authorizationStateLoggingOut' => 'AuthorizationState::LoggingOut', @@ -41,12 +42,14 @@ module TD::Types 'inputFileLocal' => 'InputFile::Local', 'inputFileGenerated' => 'InputFile::Generated', 'photoSize' => 'PhotoSize', + 'minithumbnail' => 'Minithumbnail', 'MaskPoint' => 'MaskPoint', 'maskPointForehead' => 'MaskPoint::Forehead', 'maskPointEyes' => 'MaskPoint::Eyes', 'maskPointMouth' => 'MaskPoint::Mouth', 'maskPointChin' => 'MaskPoint::Chin', 'maskPosition' => 'MaskPosition', + 'pollOption' => 'PollOption', 'animation' => 'Animation', 'audio' => 'Audio', 'document' => 'Document', @@ -59,6 +62,7 @@ module TD::Types 'location' => 'Location', 'venue' => 'Venue', 'game' => 'Game', + 'poll' => 'Poll', 'profilePhoto' => 'ProfilePhoto', 'chatPhoto' => 'ChatPhoto', 'LinkState' => 'LinkState', @@ -74,8 +78,10 @@ module TD::Types 'botInfo' => 'BotInfo', 'user' => 'User', 'userFullInfo' => 'UserFullInfo', + 'userProfilePhoto' => 'UserProfilePhoto', 'userProfilePhotos' => 'UserProfilePhotos', 'users' => 'Users', + 'chatPermissions' => 'ChatPermissions', 'ChatMemberStatus' => 'ChatMemberStatus', 'chatMemberStatusCreator' => 'ChatMemberStatus::Creator', 'chatMemberStatusAdministrator' => 'ChatMemberStatus::Administrator', @@ -86,6 +92,7 @@ module TD::Types 'chatMember' => 'ChatMember', 'chatMembers' => 'ChatMembers', 'ChatMembersFilter' => 'ChatMembersFilter', + 'chatMembersFilterContacts' => 'ChatMembersFilter::Contacts', 'chatMembersFilterAdministrators' => 'ChatMembersFilter::Administrators', 'chatMembersFilterMembers' => 'ChatMembersFilter::Members', 'chatMembersFilterRestricted' => 'ChatMembersFilter::Restricted', @@ -93,6 +100,7 @@ module TD::Types 'chatMembersFilterBots' => 'ChatMembersFilter::Bots', 'SupergroupMembersFilter' => 'SupergroupMembersFilter', 'supergroupMembersFilterRecent' => 'SupergroupMembersFilter::Recent', + 'supergroupMembersFilterContacts' => 'SupergroupMembersFilter::Contacts', 'supergroupMembersFilterAdministrators' => 'SupergroupMembersFilter::Administrators', 'supergroupMembersFilterSearch' => 'SupergroupMembersFilter::Search', 'supergroupMembersFilterRestricted' => 'SupergroupMembersFilter::Restricted', @@ -107,9 +115,11 @@ module TD::Types 'secretChatStateReady' => 'SecretChatState::Ready', 'secretChatStateClosed' => 'SecretChatState::Closed', 'secretChat' => 'SecretChat', - 'MessageForwardInfo' => 'MessageForwardInfo', - 'messageForwardedFromUser' => 'MessageForwardInfo::MessageForwardedFromUser', - 'messageForwardedPost' => 'MessageForwardInfo::MessageForwardedPost', + 'MessageForwardOrigin' => 'MessageForwardOrigin', + 'messageForwardOriginUser' => 'MessageForwardOrigin::User', + 'messageForwardOriginHiddenUser' => 'MessageForwardOrigin::HiddenUser', + 'messageForwardOriginChannel' => 'MessageForwardOrigin::Channel', + 'messageForwardInfo' => 'MessageForwardInfo', 'MessageSendingState' => 'MessageSendingState', 'messageSendingStatePending' => 'MessageSendingState::Pending', 'messageSendingStateFailed' => 'MessageSendingState::Failed', @@ -119,6 +129,7 @@ module TD::Types 'NotificationSettingsScope' => 'NotificationSettingsScope', 'notificationSettingsScopePrivateChats' => 'NotificationSettingsScope::PrivateChats', 'notificationSettingsScopeGroupChats' => 'NotificationSettingsScope::GroupChats', + 'notificationSettingsScopeChannelChats' => 'NotificationSettingsScope::ChannelChats', 'chatNotificationSettings' => 'ChatNotificationSettings', 'scopeNotificationSettings' => 'ScopeNotificationSettings', 'draftMessage' => 'DraftMessage', @@ -138,6 +149,7 @@ module TD::Types 'keyboardButton' => 'KeyboardButton', 'InlineKeyboardButtonType' => 'InlineKeyboardButtonType', 'inlineKeyboardButtonTypeUrl' => 'InlineKeyboardButtonType::Url', + 'inlineKeyboardButtonTypeLoginUrl' => 'InlineKeyboardButtonType::LoginUrl', 'inlineKeyboardButtonTypeCallback' => 'InlineKeyboardButtonType::Callback', 'inlineKeyboardButtonTypeCallbackGame' => 'InlineKeyboardButtonType::CallbackGame', 'inlineKeyboardButtonTypeSwitchInline' => 'InlineKeyboardButtonType::SwitchInline', @@ -157,13 +169,32 @@ module TD::Types 'richTextFixed' => 'RichText::Fixed', 'richTextUrl' => 'RichText::Url', 'richTextEmailAddress' => 'RichText::EmailAddress', + 'richTextSubscript' => 'RichText::Subscript', + 'richTextSuperscript' => 'RichText::Superscript', + 'richTextMarked' => 'RichText::Marked', + 'richTextPhoneNumber' => 'RichText::PhoneNumber', + 'richTextIcon' => 'RichText::Icon', + 'richTextAnchor' => 'RichText::Anchor', 'richTexts' => 'RichText::s', + 'pageBlockCaption' => 'PageBlockCaption', + 'pageBlockListItem' => 'PageBlockListItem', + 'PageBlockHorizontalAlignment' => 'PageBlockHorizontalAlignment', + 'pageBlockHorizontalAlignmentLeft' => 'PageBlockHorizontalAlignment::Left', + 'pageBlockHorizontalAlignmentCenter' => 'PageBlockHorizontalAlignment::Center', + 'pageBlockHorizontalAlignmentRight' => 'PageBlockHorizontalAlignment::Right', + 'PageBlockVerticalAlignment' => 'PageBlockVerticalAlignment', + 'pageBlockVerticalAlignmentTop' => 'PageBlockVerticalAlignment::Top', + 'pageBlockVerticalAlignmentMiddle' => 'PageBlockVerticalAlignment::Middle', + 'pageBlockVerticalAlignmentBottom' => 'PageBlockVerticalAlignment::Bottom', + 'pageBlockTableCell' => 'PageBlockTableCell', + 'pageBlockRelatedArticle' => 'PageBlockRelatedArticle', 'PageBlock' => 'PageBlock', 'pageBlockTitle' => 'PageBlock::Title', 'pageBlockSubtitle' => 'PageBlock::Subtitle', 'pageBlockAuthorDate' => 'PageBlock::AuthorDate', 'pageBlockHeader' => 'PageBlock::Header', 'pageBlockSubheader' => 'PageBlock::Subheader', + 'pageBlockKicker' => 'PageBlock::Kicker', 'pageBlockParagraph' => 'PageBlock::Paragraph', 'pageBlockPreformatted' => 'PageBlock::Preformatted', 'pageBlockFooter' => 'PageBlock::Footer', @@ -182,6 +213,10 @@ module TD::Types 'pageBlockCollage' => 'PageBlock::Collage', 'pageBlockSlideshow' => 'PageBlock::Slideshow', 'pageBlockChatLink' => 'PageBlock::ChatLink', + 'pageBlockTable' => 'PageBlock::Table', + 'pageBlockDetails' => 'PageBlock::Details', + 'pageBlockRelatedArticles' => 'PageBlock::RelatedArticles', + 'pageBlockMap' => 'PageBlock::Map', 'webPageInstantView' => 'WebPageInstantView', 'webPage' => 'WebPage', 'address' => 'Address', @@ -264,6 +299,7 @@ module TD::Types 'passportSuitableElement' => 'PassportSuitableElement', 'passportRequiredElement' => 'PassportRequiredElement', 'passportAuthorizationForm' => 'PassportAuthorizationForm', + 'passportElementsWithErrors' => 'PassportElementsWithErrors', 'encryptedCredentials' => 'EncryptedCredentials', 'encryptedPassportElement' => 'EncryptedPassportElement', 'InputPassportElementErrorSource' => 'InputPassportElementErrorSource', @@ -293,6 +329,7 @@ module TD::Types 'messageVenue' => 'MessageContent::Venue', 'messageContact' => 'MessageContent::Contact', 'messageGame' => 'MessageContent::Game', + 'messagePoll' => 'MessageContent::Poll', 'messageInvoice' => 'MessageContent::Invoice', 'messageCall' => 'MessageContent::Call', 'messageBasicGroupChatCreate' => 'MessageContent::BasicGroupChatCreate', @@ -348,6 +385,7 @@ module TD::Types 'inputMessageContact' => 'InputMessageContent::Contact', 'inputMessageGame' => 'InputMessageContent::Game', 'inputMessageInvoice' => 'InputMessageContent::Invoice', + 'inputMessagePoll' => 'InputMessageContent::Poll', 'inputMessageForwarded' => 'InputMessageContent::Forwarded', 'SearchMessagesFilter' => 'SearchMessagesFilter', 'searchMessagesFilterEmpty' => 'SearchMessagesFilter::Empty', @@ -388,7 +426,7 @@ module TD::Types 'userStatusLastWeek' => 'UserStatus::LastWeek', 'userStatusLastMonth' => 'UserStatus::LastMonth', 'stickers' => 'Stickers', - 'stickerEmojis' => 'StickerEmojis', + 'emojis' => 'Emojis', 'stickerSet' => 'StickerSet', 'stickerSetInfo' => 'StickerSetInfo', 'stickerSets' => 'StickerSets', @@ -408,9 +446,19 @@ module TD::Types 'callStateHangingUp' => 'CallState::HangingUp', 'callStateDiscarded' => 'CallState::Discarded', 'callStateError' => 'CallState::Error', + 'CallProblem' => 'CallProblem', + 'callProblemEcho' => 'CallProblem::Echo', + 'callProblemNoise' => 'CallProblem::Noise', + 'callProblemInterruptions' => 'CallProblem::Interruptions', + 'callProblemDistortedSpeech' => 'CallProblem::DistortedSpeech', + 'callProblemSilentLocal' => 'CallProblem::SilentLocal', + 'callProblemSilentRemote' => 'CallProblem::SilentRemote', + 'callProblemDropped' => 'CallProblem::Dropped', 'call' => 'Call', + 'phoneNumberAuthenticationSettings' => 'PhoneNumberAuthenticationSettings', 'animations' => 'Animations', 'importedContacts' => 'ImportedContacts', + 'httpUrl' => 'HttpUrl', 'InputInlineQueryResult' => 'InputInlineQueryResult', 'inputInlineQueryResultAnimatedGif' => 'InputInlineQueryResult::AnimatedGif', 'inputInlineQueryResultAnimatedMpeg4' => 'InputInlineQueryResult::AnimatedMpeg4', @@ -449,6 +497,7 @@ module TD::Types 'ChatEventAction' => 'ChatEventAction', 'chatEventMessageEdited' => 'ChatEventAction::MessageEdited', 'chatEventMessageDeleted' => 'ChatEventAction::MessageDeleted', + 'chatEventPollStopped' => 'ChatEventAction::PollStopped', 'chatEventMessagePinned' => 'ChatEventAction::MessagePinned', 'chatEventMessageUnpinned' => 'ChatEventAction::MessageUnpinned', 'chatEventMemberJoined' => 'ChatEventAction::MemberJoined', @@ -457,6 +506,7 @@ module TD::Types 'chatEventMemberPromoted' => 'ChatEventAction::MemberPromoted', 'chatEventMemberRestricted' => 'ChatEventAction::MemberRestricted', 'chatEventTitleChanged' => 'ChatEventAction::TitleChanged', + 'chatEventPermissionsChanged' => 'ChatEventAction::PermissionsChanged', 'chatEventDescriptionChanged' => 'ChatEventAction::DescriptionChanged', 'chatEventUsernameChanged' => 'ChatEventAction::UsernameChanged', 'chatEventPhotoChanged' => 'ChatEventAction::PhotoChanged', @@ -476,7 +526,7 @@ module TD::Types 'languagePackInfo' => 'LanguagePackInfo', 'localizationTargetInfo' => 'LocalizationTargetInfo', 'DeviceToken' => 'DeviceToken', - 'deviceTokenGoogleCloudMessaging' => 'DeviceToken::GoogleCloudMessaging', + 'deviceTokenFirebaseCloudMessaging' => 'DeviceToken::FirebaseCloudMessaging', 'deviceTokenApplePush' => 'DeviceToken::ApplePush', 'deviceTokenApplePushVoIP' => 'DeviceToken::ApplePushVoIP', 'deviceTokenWindowsPush' => 'DeviceToken::WindowsPush', @@ -487,8 +537,16 @@ module TD::Types 'deviceTokenUbuntuPush' => 'DeviceToken::UbuntuPush', 'deviceTokenBlackBerryPush' => 'DeviceToken::BlackBerryPush', 'deviceTokenTizenPush' => 'DeviceToken::TizenPush', - 'wallpaper' => 'Wallpaper', - 'wallpapers' => 'Wallpapers', + 'pushReceiverId' => 'PushReceiverId', + 'BackgroundType' => 'BackgroundType', + 'backgroundTypeWallpaper' => 'BackgroundType::Wallpaper', + 'backgroundTypePattern' => 'BackgroundType::Pattern', + 'backgroundTypeSolid' => 'BackgroundType::Solid', + 'background' => 'Background', + 'backgrounds' => 'Backgrounds', + 'InputBackground' => 'InputBackground', + 'inputBackgroundLocal' => 'InputBackground::Local', + 'inputBackgroundRemote' => 'InputBackground::Remote', 'hashtags' => 'Hashtags', 'CheckChatUsernameResult' => 'CheckChatUsernameResult', 'checkChatUsernameResultOk' => 'CheckChatUsernameResult::Ok', @@ -496,11 +554,58 @@ module TD::Types 'checkChatUsernameResultUsernameOccupied' => 'CheckChatUsernameResult::UsernameOccupied', 'checkChatUsernameResultPublicChatsTooMuch' => 'CheckChatUsernameResult::PublicChatsTooMuch', 'checkChatUsernameResultPublicGroupsUnavailable' => 'CheckChatUsernameResult::PublicGroupsUnavailable', + 'PushMessageContent' => 'PushMessageContent', + 'pushMessageContentHidden' => 'PushMessageContent::Hidden', + 'pushMessageContentAnimation' => 'PushMessageContent::Animation', + 'pushMessageContentAudio' => 'PushMessageContent::Audio', + 'pushMessageContentContact' => 'PushMessageContent::Contact', + 'pushMessageContentContactRegistered' => 'PushMessageContent::ContactRegistered', + 'pushMessageContentDocument' => 'PushMessageContent::Document', + 'pushMessageContentGame' => 'PushMessageContent::Game', + 'pushMessageContentGameScore' => 'PushMessageContent::GameScore', + 'pushMessageContentInvoice' => 'PushMessageContent::Invoice', + 'pushMessageContentLocation' => 'PushMessageContent::Location', + 'pushMessageContentPhoto' => 'PushMessageContent::Photo', + 'pushMessageContentPoll' => 'PushMessageContent::Poll', + 'pushMessageContentScreenshotTaken' => 'PushMessageContent::ScreenshotTaken', + 'pushMessageContentSticker' => 'PushMessageContent::Sticker', + 'pushMessageContentText' => 'PushMessageContent::Text', + 'pushMessageContentVideo' => 'PushMessageContent::Video', + 'pushMessageContentVideoNote' => 'PushMessageContent::VideoNote', + 'pushMessageContentVoiceNote' => 'PushMessageContent::VoiceNote', + 'pushMessageContentBasicGroupChatCreate' => 'PushMessageContent::BasicGroupChatCreate', + 'pushMessageContentChatAddMembers' => 'PushMessageContent::ChatAddMembers', + 'pushMessageContentChatChangePhoto' => 'PushMessageContent::ChatChangePhoto', + 'pushMessageContentChatChangeTitle' => 'PushMessageContent::ChatChangeTitle', + 'pushMessageContentChatDeleteMember' => 'PushMessageContent::ChatDeleteMember', + 'pushMessageContentChatJoinByLink' => 'PushMessageContent::ChatJoinByLink', + 'pushMessageContentMessageForwards' => 'PushMessageContent::MessageForwards', + 'pushMessageContentMediaAlbum' => 'PushMessageContent::MediaAlbum', + 'NotificationType' => 'NotificationType', + 'notificationTypeNewMessage' => 'NotificationType::NewMessage', + 'notificationTypeNewSecretChat' => 'NotificationType::NewSecretChat', + 'notificationTypeNewCall' => 'NotificationType::NewCall', + 'notificationTypeNewPushMessage' => 'NotificationType::NewPushMessage', + 'NotificationGroupType' => 'NotificationGroupType', + 'notificationGroupTypeMessages' => 'NotificationGroupType::Messages', + 'notificationGroupTypeMentions' => 'NotificationGroupType::Mentions', + 'notificationGroupTypeSecretChat' => 'NotificationGroupType::SecretChat', + 'notificationGroupTypeCalls' => 'NotificationGroupType::Calls', + 'notification' => 'Notification', + 'notificationGroup' => 'NotificationGroup', 'OptionValue' => 'OptionValue', 'optionValueBoolean' => 'OptionValue::Boolean', 'optionValueEmpty' => 'OptionValue::Empty', 'optionValueInteger' => 'OptionValue::Integer', 'optionValueString' => 'OptionValue::String', + 'jsonObjectMember' => 'JsonObjectMember', + 'JsonValue' => 'JsonValue', + 'jsonValueNull' => 'JsonValue::Null', + 'jsonValueBoolean' => 'JsonValue::Boolean', + 'jsonValueNumber' => 'JsonValue::Number', + 'jsonValueString' => 'JsonValue::String', + 'jsonValueArray' => 'JsonValue::Array', + 'jsonValueObject' => 'JsonValue::Object', 'UserPrivacySettingRule' => 'UserPrivacySettingRule', 'userPrivacySettingRuleAllowAll' => 'UserPrivacySettingRule::AllowAll', 'userPrivacySettingRuleAllowContacts' => 'UserPrivacySettingRule::AllowContacts', @@ -511,8 +616,11 @@ module TD::Types 'userPrivacySettingRules' => 'UserPrivacySettingRules', 'UserPrivacySetting' => 'UserPrivacySetting', 'userPrivacySettingShowStatus' => 'UserPrivacySetting::ShowStatus', + 'userPrivacySettingShowProfilePhoto' => 'UserPrivacySetting::ShowProfilePhoto', + 'userPrivacySettingShowLinkInForwardedMessages' => 'UserPrivacySetting::ShowLinkInForwardedMessages', 'userPrivacySettingAllowChatInvites' => 'UserPrivacySetting::AllowChatInvites', 'userPrivacySettingAllowCalls' => 'UserPrivacySetting::AllowCalls', + 'userPrivacySettingAllowPeerToPeerCalls' => 'UserPrivacySetting::AllowPeerToPeerCalls', 'accountTtl' => 'AccountTtl', 'session' => 'Session', 'sessions' => 'Sessions', @@ -523,9 +631,12 @@ module TD::Types 'chatReportReasonSpam' => 'ChatReportReason::Spam', 'chatReportReasonViolence' => 'ChatReportReason::Violence', 'chatReportReasonPornography' => 'ChatReportReason::Pornography', + 'chatReportReasonChildAbuse' => 'ChatReportReason::ChildAbuse', 'chatReportReasonCopyright' => 'ChatReportReason::Copyright', 'chatReportReasonCustom' => 'ChatReportReason::Custom', 'publicMessageLink' => 'PublicMessageLink', + 'messageLinkInfo' => 'MessageLinkInfo', + 'filePart' => 'FilePart', 'FileType' => 'FileType', 'fileTypeNone' => 'FileType::None', 'fileTypeAnimation' => 'FileType::Animation', @@ -547,6 +658,7 @@ module TD::Types 'storageStatisticsByChat' => 'StorageStatisticsByChat', 'storageStatistics' => 'StorageStatistics', 'storageStatisticsFast' => 'StorageStatisticsFast', + 'databaseStatistics' => 'DatabaseStatistics', 'NetworkType' => 'NetworkType', 'networkTypeNone' => 'NetworkType::None', 'networkTypeMobile' => 'NetworkType::Mobile', @@ -557,6 +669,8 @@ module TD::Types 'networkStatisticsEntryFile' => 'NetworkStatisticsEntry::File', 'networkStatisticsEntryCall' => 'NetworkStatisticsEntry::Call', 'networkStatistics' => 'NetworkStatistics', + 'autoDownloadSettings' => 'AutoDownloadSettings', + 'autoDownloadSettingsPresets' => 'AutoDownloadSettingsPresets', 'ConnectionState' => 'ConnectionState', 'connectionStateWaitingForNetwork' => 'ConnectionState::WaitingForNetwork', 'connectionStateConnectingToProxy' => 'ConnectionState::ConnectingToProxy', @@ -605,6 +719,7 @@ module TD::Types 'updateNewChat' => 'Update::NewChat', 'updateChatTitle' => 'Update::ChatTitle', 'updateChatPhoto' => 'Update::ChatPhoto', + 'updateChatPermissions' => 'Update::ChatPermissions', 'updateChatLastMessage' => 'Update::ChatLastMessage', 'updateChatOrder' => 'Update::ChatOrder', 'updateChatIsPinned' => 'Update::ChatIsPinned', @@ -616,8 +731,14 @@ module TD::Types 'updateChatUnreadMentionCount' => 'Update::ChatUnreadMentionCount', 'updateChatNotificationSettings' => 'Update::ChatNotificationSettings', 'updateScopeNotificationSettings' => 'Update::ScopeNotificationSettings', + 'updateChatPinnedMessage' => 'Update::ChatPinnedMessage', 'updateChatReplyMarkup' => 'Update::ChatReplyMarkup', 'updateChatDraftMessage' => 'Update::ChatDraftMessage', + 'updateChatOnlineMemberCount' => 'Update::ChatOnlineMemberCount', + 'updateNotification' => 'Update::Notification', + 'updateNotificationGroup' => 'Update::NotificationGroup', + 'updateActiveNotifications' => 'Update::ActiveNotifications', + 'updateHavePendingNotifications' => 'Update::HavePendingNotifications', 'updateDeleteMessages' => 'Update::DeleteMessages', 'updateUserChatAction' => 'Update::UserChatAction', 'updateUserStatus' => 'Update::UserStatus', @@ -642,6 +763,7 @@ module TD::Types 'updateRecentStickers' => 'Update::RecentStickers', 'updateFavoriteStickers' => 'Update::FavoriteStickers', 'updateSavedAnimations' => 'Update::SavedAnimations', + 'updateSelectedBackground' => 'Update::SelectedBackground', 'updateLanguagePackStrings' => 'Update::LanguagePackStrings', 'updateConnectionState' => 'Update::ConnectionState', 'updateTermsOfService' => 'Update::TermsOfService', @@ -652,7 +774,15 @@ module TD::Types 'updateNewShippingQuery' => 'Update::NewShippingQuery', 'updateNewPreCheckoutQuery' => 'Update::NewPreCheckoutQuery', 'updateNewCustomEvent' => 'Update::NewCustomEvent', - 'updateNewCustomQuery' => 'Update::NewCustomQuery' + 'updateNewCustomQuery' => 'Update::NewCustomQuery', + 'updatePoll' => 'Update::Poll', + 'updates' => 'Updates', + 'LogStream' => 'LogStream', + 'logStreamDefault' => 'LogStream::Default', + 'logStreamFile' => 'LogStream::File', + 'logStreamEmpty' => 'LogStream::Empty', + 'logVerbosityLevel' => 'LogVerbosityLevel', + 'logTags' => 'LogTags' }.freeze module_function @@ -699,6 +829,11 @@ def camelize(str) authentication_code_info authentication_code_type authorization_state + auto_download_settings + auto_download_settings_presets + background + background_type + backgrounds base basic_group basic_group_full_info @@ -708,6 +843,7 @@ def camelize(str) call_connection call_discard_reason call_id + call_problem call_protocol call_state callback_query_answer @@ -725,6 +861,7 @@ def camelize(str) chat_members chat_members_filter chat_notification_settings + chat_permissions chat_photo chat_report_reason chat_report_spam_state @@ -737,6 +874,7 @@ def camelize(str) contact count custom_request_result + database_statistics date dated_file deep_link_info @@ -744,10 +882,12 @@ def camelize(str) document draft_message email_address_authentication_code_info + emojis encrypted_credentials encrypted_passport_element error file + file_part file_type formatted_text found_messages @@ -755,12 +895,14 @@ def camelize(str) game_high_score game_high_scores hashtags + http_url identity_document imported_contacts inline_keyboard_button inline_keyboard_button_type inline_query_result inline_query_results + input_background input_credentials input_file input_identity_document @@ -773,6 +915,8 @@ def camelize(str) input_sticker input_thumbnail invoice + json_object_member + json_value keyboard_button keyboard_button_type labeled_price_part @@ -784,27 +928,44 @@ def camelize(str) local_file localization_target_info location + log_stream + log_tags + log_verbosity_level mask_point mask_position message message_content message_forward_info + message_forward_origin + message_link_info message_sending_state messages + minithumbnail network_statistics network_statistics_entry network_type + notification + notification_group + notification_group_type notification_settings_scope + notification_type ok option_value order_info page_block + page_block_caption + page_block_horizontal_alignment + page_block_list_item + page_block_related_article + page_block_table_cell + page_block_vertical_alignment passport_authorization_form passport_element passport_element_error passport_element_error_source passport_element_type passport_elements + passport_elements_with_errors passport_required_element passport_suitable_element password_state @@ -814,13 +975,18 @@ def camelize(str) payments_provider_stripe personal_details personal_document + phone_number_authentication_settings photo photo_size + poll + poll_option profile_photo proxies proxy proxy_type public_message_link + push_message_content + push_receiver_id recovery_email_address remote_file reply_markup @@ -835,7 +1001,6 @@ def camelize(str) sessions shipping_option sticker - sticker_emojis sticker_set sticker_set_info sticker_sets @@ -860,11 +1025,13 @@ def camelize(str) text_parse_mode top_chat_category update + updates user user_full_info user_privacy_setting user_privacy_setting_rule user_privacy_setting_rules + user_profile_photo user_profile_photos user_status user_type @@ -874,8 +1041,6 @@ def camelize(str) video video_note voice_note - wallpaper - wallpapers web_page web_page_instant_view ].each do |type| diff --git a/lib/tdlib/types/animation.rb b/lib/tdlib/types/animation.rb index 2f5e087..8408aea 100644 --- a/lib/tdlib/types/animation.rb +++ b/lib/tdlib/types/animation.rb @@ -7,6 +7,7 @@ module TD::Types # @attr height [Integer] Height of the animation. # @attr file_name [String] Original name of the file; as defined by the sender. # @attr mime_type [String] MIME type of the file, usually "image/gif" or "video/mp4". + # @attr minithumbnail [TD::Types::Minithumbnail, nil] Animation minithumbnail; may be null. # @attr thumbnail [TD::Types::PhotoSize, nil] Animation thumbnail; may be null. # @attr animation [TD::Types::File] File containing the animation. class Animation < Base @@ -15,6 +16,7 @@ class Animation < Base attribute :height, TD::Types::Integer attribute :file_name, TD::Types::String attribute :mime_type, TD::Types::String + attribute :minithumbnail, TD::Types::Minithumbnail.optional.default(nil) attribute :thumbnail, TD::Types::PhotoSize.optional.default(nil) attribute :animation, TD::Types::File end diff --git a/lib/tdlib/types/audio.rb b/lib/tdlib/types/audio.rb index 42b7de3..9713060 100644 --- a/lib/tdlib/types/audio.rb +++ b/lib/tdlib/types/audio.rb @@ -7,6 +7,7 @@ module TD::Types # @attr performer [String] Performer of the audio; as defined by the sender. # @attr file_name [String] Original name of the file; as defined by the sender. # @attr mime_type [String] The MIME type of the file; as defined by the sender. + # @attr album_cover_minithumbnail [TD::Types::Minithumbnail, nil] The minithumbnail of the album cover; may be null. # @attr album_cover_thumbnail [TD::Types::PhotoSize, nil] The thumbnail of the album cover; as defined by the sender. # The full size thumbnail should be extracted from the downloaded file; may be null. # @attr audio [TD::Types::File] File containing the audio. @@ -16,6 +17,7 @@ class Audio < Base attribute :performer, TD::Types::String attribute :file_name, TD::Types::String attribute :mime_type, TD::Types::String + attribute :album_cover_minithumbnail, TD::Types::Minithumbnail.optional.default(nil) attribute :album_cover_thumbnail, TD::Types::PhotoSize.optional.default(nil) attribute :audio, TD::Types::File end diff --git a/lib/tdlib/types/authorization_state.rb b/lib/tdlib/types/authorization_state.rb index 09b0704..0ef2bcd 100644 --- a/lib/tdlib/types/authorization_state.rb +++ b/lib/tdlib/types/authorization_state.rb @@ -6,6 +6,7 @@ class AuthorizationState < Base wait_encryption_key wait_phone_number wait_code + wait_registration wait_password ready logging_out diff --git a/lib/tdlib/types/authorization_state/wait_code.rb b/lib/tdlib/types/authorization_state/wait_code.rb index 70e5e98..a42734b 100644 --- a/lib/tdlib/types/authorization_state/wait_code.rb +++ b/lib/tdlib/types/authorization_state/wait_code.rb @@ -1,13 +1,8 @@ module TD::Types - # TDLib needs the user's authentication code to finalize authorization. + # TDLib needs the user's authentication code to authorize. # - # @attr is_registered [Boolean] True, if the user is already registered. - # @attr terms_of_service [TD::Types::TermsOfService, nil] Telegram terms of service, which should be accepted before - # user can continue registration; may be null. # @attr code_info [TD::Types::AuthenticationCodeInfo] Information about the authorization code that was sent. class AuthorizationState::WaitCode < AuthorizationState - attribute :is_registered, TD::Types::Bool - attribute :terms_of_service, TD::Types::TermsOfService.optional.default(nil) attribute :code_info, TD::Types::AuthenticationCodeInfo end end diff --git a/lib/tdlib/types/authorization_state/wait_password.rb b/lib/tdlib/types/authorization_state/wait_password.rb index 5831eb8..546be65 100644 --- a/lib/tdlib/types/authorization_state/wait_password.rb +++ b/lib/tdlib/types/authorization_state/wait_password.rb @@ -1,8 +1,8 @@ module TD::Types # The user has been authorized, but needs to enter a password to start using the application. # - # @attr password_hint [String, nil] Hint for the password; can be empty. - # @attr has_recovery_email_address [Boolean] True if a recovery email address has been set up. + # @attr password_hint [String, nil] Hint for the password; may be empty. + # @attr has_recovery_email_address [Boolean] True, if a recovery email address has been set up. # @attr recovery_email_address_pattern [String, nil] Pattern of the email address to which the recovery email was # sent; empty until a recovery email has been sent. class AuthorizationState::WaitPassword < AuthorizationState diff --git a/lib/tdlib/types/authorization_state/wait_registration.rb b/lib/tdlib/types/authorization_state/wait_registration.rb new file mode 100644 index 0000000..f543d02 --- /dev/null +++ b/lib/tdlib/types/authorization_state/wait_registration.rb @@ -0,0 +1,9 @@ +module TD::Types + # The user is unregistered and need to accept terms of service and enter their first name and last name to finish + # registration. + # + # @attr terms_of_service [TD::Types::TermsOfService] Telegram terms of service. + class AuthorizationState::WaitRegistration < AuthorizationState + attribute :terms_of_service, TD::Types::TermsOfService + end +end diff --git a/lib/tdlib/types/auto_download_settings.rb b/lib/tdlib/types/auto_download_settings.rb new file mode 100644 index 0000000..b7f2131 --- /dev/null +++ b/lib/tdlib/types/auto_download_settings.rb @@ -0,0 +1,21 @@ +module TD::Types + # Contains auto-download settings. + # + # @attr is_auto_download_enabled [Boolean] True, if the auto-download is enabled. + # @attr max_photo_file_size [Integer] Maximum size of a photo file to be auto-downloaded. + # @attr max_video_file_size [Integer] Maximum size of a video file to be auto-downloaded. + # @attr max_other_file_size [Integer] Maximum size of other file types to be auto-downloaded. + # @attr preload_large_videos [Boolean] True, if the beginning of videos needs to be preloaded for instant playback. + # @attr preload_next_audio [Boolean] True, if the next audio track needs to be preloaded while the user is listening + # to an audio file. + # @attr use_less_data_for_calls [Boolean] True, if "use less data for calls" option needs to be enabled. + class AutoDownloadSettings < Base + attribute :is_auto_download_enabled, TD::Types::Bool + attribute :max_photo_file_size, TD::Types::Integer + attribute :max_video_file_size, TD::Types::Integer + attribute :max_other_file_size, TD::Types::Integer + attribute :preload_large_videos, TD::Types::Bool + attribute :preload_next_audio, TD::Types::Bool + attribute :use_less_data_for_calls, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/auto_download_settings_presets.rb b/lib/tdlib/types/auto_download_settings_presets.rb new file mode 100644 index 0000000..99e9ea0 --- /dev/null +++ b/lib/tdlib/types/auto_download_settings_presets.rb @@ -0,0 +1,15 @@ +module TD::Types + # Contains auto-download settings presets for the user. + # + # @attr low [TD::Types::AutoDownloadSettings] Preset with lowest settings; supposed to be used by default when + # roaming. + # @attr medium [TD::Types::AutoDownloadSettings] Preset with medium settings; supposed to be used by default when + # using mobile data. + # @attr high [TD::Types::AutoDownloadSettings] Preset with highest settings; supposed to be used by default when + # connected on Wi-Fi. + class AutoDownloadSettingsPresets < Base + attribute :low, TD::Types::AutoDownloadSettings + attribute :medium, TD::Types::AutoDownloadSettings + attribute :high, TD::Types::AutoDownloadSettings + end +end diff --git a/lib/tdlib/types/background.rb b/lib/tdlib/types/background.rb new file mode 100644 index 0000000..ae84b7c --- /dev/null +++ b/lib/tdlib/types/background.rb @@ -0,0 +1,19 @@ +module TD::Types + # Describes a chat background. + # + # @attr id [Integer] Unique background identifier. + # @attr is_default [Boolean] True, if this is one of default backgrounds. + # @attr is_dark [Boolean] True, if the background is dark and is recommended to be used with dark theme. + # @attr name [String] Unique background name. + # @attr document [TD::Types::Document, nil] Document with the background; may be null. + # Null only for solid backgrounds. + # @attr type [TD::Types::BackgroundType] Type of the background. + class Background < Base + attribute :id, TD::Types::Integer + attribute :is_default, TD::Types::Bool + attribute :is_dark, TD::Types::Bool + attribute :name, TD::Types::String + attribute :document, TD::Types::Document.optional.default(nil) + attribute :type, TD::Types::BackgroundType + end +end diff --git a/lib/tdlib/types/background_type.rb b/lib/tdlib/types/background_type.rb new file mode 100644 index 0000000..af76086 --- /dev/null +++ b/lib/tdlib/types/background_type.rb @@ -0,0 +1,12 @@ +module TD::Types + # Describes a type of a background. + class BackgroundType < Base + %w[ + wallpaper + pattern + solid + ].each do |type| + autoload TD::Types.camelize(type), "tdlib/types/background_type/#{type}" + end + end +end diff --git a/lib/tdlib/types/background_type/pattern.rb b/lib/tdlib/types/background_type/pattern.rb new file mode 100644 index 0000000..18fb32a --- /dev/null +++ b/lib/tdlib/types/background_type/pattern.rb @@ -0,0 +1,12 @@ +module TD::Types + # A PNG pattern to be combined with the color chosen by the user. + # + # @attr is_moving [Boolean] True, if the background needs to be slightly moved when device is rotated. + # @attr color [Integer] Main color of the background in RGB24 format. + # @attr intensity [Integer] Intensity of the pattern when it is shown above the main background color, 0-100. + class BackgroundType::Pattern < BackgroundType + attribute :is_moving, TD::Types::Bool + attribute :color, TD::Types::Integer + attribute :intensity, TD::Types::Integer + end +end diff --git a/lib/tdlib/types/background_type/solid.rb b/lib/tdlib/types/background_type/solid.rb new file mode 100644 index 0000000..fa64a83 --- /dev/null +++ b/lib/tdlib/types/background_type/solid.rb @@ -0,0 +1,8 @@ +module TD::Types + # A solid background. + # + # @attr color [Integer] A color of the background in RGB24 format. + class BackgroundType::Solid < BackgroundType + attribute :color, TD::Types::Integer + end +end diff --git a/lib/tdlib/types/background_type/wallpaper.rb b/lib/tdlib/types/background_type/wallpaper.rb new file mode 100644 index 0000000..a841cfb --- /dev/null +++ b/lib/tdlib/types/background_type/wallpaper.rb @@ -0,0 +1,11 @@ +module TD::Types + # A wallpaper in JPEG format. + # + # @attr is_blurred [Boolean] True, if the wallpaper must be downscaled to fit in 450x450 square and then box-blurred + # with radius 12. + # @attr is_moving [Boolean] True, if the background needs to be slightly moved when device is rotated. + class BackgroundType::Wallpaper < BackgroundType + attribute :is_blurred, TD::Types::Bool + attribute :is_moving, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/backgrounds.rb b/lib/tdlib/types/backgrounds.rb new file mode 100644 index 0000000..d20b3cd --- /dev/null +++ b/lib/tdlib/types/backgrounds.rb @@ -0,0 +1,8 @@ +module TD::Types + # Contains a list of backgrounds. + # + # @attr backgrounds [Array] A list of backgrounds. + class Backgrounds < Base + attribute :backgrounds, TD::Types::Array.of(TD::Types::Background) + end +end diff --git a/lib/tdlib/types/basic_group.rb b/lib/tdlib/types/basic_group.rb index ac0bb21..03102ba 100644 --- a/lib/tdlib/types/basic_group.rb +++ b/lib/tdlib/types/basic_group.rb @@ -4,14 +4,12 @@ module TD::Types # @attr id [Integer] Group identifier. # @attr member_count [Integer] Number of members in the group. # @attr status [TD::Types::ChatMemberStatus] Status of the current user in the group. - # @attr everyone_is_administrator [Boolean] True, if all members have been granted administrator rights in the group. # @attr is_active [Boolean] True, if the group is active. # @attr upgraded_to_supergroup_id [Integer] Identifier of the supergroup to which this group was upgraded; 0 if none. class BasicGroup < Base attribute :id, TD::Types::Integer attribute :member_count, TD::Types::Integer attribute :status, TD::Types::ChatMemberStatus - attribute :everyone_is_administrator, TD::Types::Bool attribute :is_active, TD::Types::Bool attribute :upgraded_to_supergroup_id, TD::Types::Integer end diff --git a/lib/tdlib/types/basic_group_full_info.rb b/lib/tdlib/types/basic_group_full_info.rb index c74c71d..b2c7c8a 100644 --- a/lib/tdlib/types/basic_group_full_info.rb +++ b/lib/tdlib/types/basic_group_full_info.rb @@ -1,11 +1,13 @@ module TD::Types # Contains full information about a basic group. # + # @attr description [String] Group description. # @attr creator_user_id [Integer] User identifier of the creator of the group; 0 if unknown. # @attr members [Array] Group members. # @attr invite_link [String] Invite link for this group; available only for the group creator and only after it has # been generated at least once. class BasicGroupFullInfo < Base + attribute :description, TD::Types::String attribute :creator_user_id, TD::Types::Integer attribute :members, TD::Types::Array.of(TD::Types::ChatMember) attribute :invite_link, TD::Types::String diff --git a/lib/tdlib/types/call_problem.rb b/lib/tdlib/types/call_problem.rb new file mode 100644 index 0000000..4dc002f --- /dev/null +++ b/lib/tdlib/types/call_problem.rb @@ -0,0 +1,16 @@ +module TD::Types + # Describes the exact type of a problem with a call. + class CallProblem < Base + %w[ + echo + noise + interruptions + distorted_speech + silent_local + silent_remote + dropped + ].each do |type| + autoload TD::Types.camelize(type), "tdlib/types/call_problem/#{type}" + end + end +end diff --git a/lib/tdlib/types/call_problem/distorted_speech.rb b/lib/tdlib/types/call_problem/distorted_speech.rb new file mode 100644 index 0000000..fdc69a2 --- /dev/null +++ b/lib/tdlib/types/call_problem/distorted_speech.rb @@ -0,0 +1,5 @@ +module TD::Types + # The speech was distorted. + class CallProblem::DistortedSpeech < CallProblem + end +end diff --git a/lib/tdlib/types/call_problem/dropped.rb b/lib/tdlib/types/call_problem/dropped.rb new file mode 100644 index 0000000..69d4ff7 --- /dev/null +++ b/lib/tdlib/types/call_problem/dropped.rb @@ -0,0 +1,5 @@ +module TD::Types + # The call ended unexpectedly. + class CallProblem::Dropped < CallProblem + end +end diff --git a/lib/tdlib/types/call_problem/echo.rb b/lib/tdlib/types/call_problem/echo.rb new file mode 100644 index 0000000..2b16714 --- /dev/null +++ b/lib/tdlib/types/call_problem/echo.rb @@ -0,0 +1,5 @@ +module TD::Types + # The user heard their own voice. + class CallProblem::Echo < CallProblem + end +end diff --git a/lib/tdlib/types/call_problem/interruptions.rb b/lib/tdlib/types/call_problem/interruptions.rb new file mode 100644 index 0000000..392849e --- /dev/null +++ b/lib/tdlib/types/call_problem/interruptions.rb @@ -0,0 +1,5 @@ +module TD::Types + # The other side kept disappearing. + class CallProblem::Interruptions < CallProblem + end +end diff --git a/lib/tdlib/types/call_problem/noise.rb b/lib/tdlib/types/call_problem/noise.rb new file mode 100644 index 0000000..613d7f4 --- /dev/null +++ b/lib/tdlib/types/call_problem/noise.rb @@ -0,0 +1,5 @@ +module TD::Types + # The user heard background noise. + class CallProblem::Noise < CallProblem + end +end diff --git a/lib/tdlib/types/call_problem/silent_local.rb b/lib/tdlib/types/call_problem/silent_local.rb new file mode 100644 index 0000000..eb7967e --- /dev/null +++ b/lib/tdlib/types/call_problem/silent_local.rb @@ -0,0 +1,5 @@ +module TD::Types + # The user couldn't hear the other side. + class CallProblem::SilentLocal < CallProblem + end +end diff --git a/lib/tdlib/types/call_problem/silent_remote.rb b/lib/tdlib/types/call_problem/silent_remote.rb new file mode 100644 index 0000000..ac39b92 --- /dev/null +++ b/lib/tdlib/types/call_problem/silent_remote.rb @@ -0,0 +1,5 @@ +module TD::Types + # The other side couldn't hear the user. + class CallProblem::SilentRemote < CallProblem + end +end diff --git a/lib/tdlib/types/call_state/ready.rb b/lib/tdlib/types/call_state/ready.rb index db4fc7c..0da3c93 100644 --- a/lib/tdlib/types/call_state/ready.rb +++ b/lib/tdlib/types/call_state/ready.rb @@ -6,11 +6,13 @@ module TD::Types # @attr config [String] A JSON-encoded call config. # @attr encryption_key [String] Call encryption key. # @attr emojis [Array] Encryption key emojis fingerprint. + # @attr allow_p2p [Boolean] True, if peer-to-peer connection is allowed by users privacy settings. class CallState::Ready < CallState attribute :protocol, TD::Types::CallProtocol attribute :connections, TD::Types::Array.of(TD::Types::CallConnection) attribute :config, TD::Types::String attribute :encryption_key, TD::Types::String attribute :emojis, TD::Types::Array.of(TD::Types::String) + attribute :allow_p2p, TD::Types::Bool end end diff --git a/lib/tdlib/types/chat.rb b/lib/tdlib/types/chat.rb index bf3e9c2..cb85ccb 100644 --- a/lib/tdlib/types/chat.rb +++ b/lib/tdlib/types/chat.rb @@ -6,6 +6,8 @@ module TD::Types # @attr type [TD::Types::ChatType] Type of the chat. # @attr title [String] Chat title. # @attr photo [TD::Types::ChatPhoto, nil] Chat photo; may be null. + # @attr permissions [TD::Types::ChatPermissions] Actions that non-administrator chat members are allowed to take in + # the chat. # @attr last_message [TD::Types::Message, nil] Last message in the chat; may be null. # @attr order [Integer] Descending parameter by which chats are sorted in the main chat list. # If the order number of two chats is the same, they must be sorted in descending order by ID. @@ -13,6 +15,9 @@ module TD::Types # @attr is_pinned [Boolean] True, if the chat is pinned. # @attr is_marked_as_unread [Boolean] True, if the chat is marked as unread. # @attr is_sponsored [Boolean] True, if the chat is sponsored by the user's MTProxy server. + # @attr can_be_deleted_only_for_self [Boolean] True, if the chat messages can be deleted only for the current user + # while other users will continue to see the messages. + # @attr can_be_deleted_for_all_users [Boolean] True, if the chat messages can be deleted for all users. # @attr can_be_reported [Boolean] True, if the chat can be reported to Telegram moderators through reportChat. # @attr default_disable_notification [Boolean] Default value of the disable_notification parameter, used when a # message is sent to the chat. @@ -21,6 +26,7 @@ module TD::Types # @attr last_read_outbox_message_id [Integer] Identifier of the last read outgoing message. # @attr unread_mention_count [Integer] Number of unread messages with a mention/reply in the chat. # @attr notification_settings [TD::Types::ChatNotificationSettings] Notification settings for this chat. + # @attr pinned_message_id [Integer] Identifier of the pinned message in the chat; 0 if none. # @attr reply_markup_message_id [Integer] Identifier of the message from which reply markup needs to be used; 0 if # there is no default custom reply markup in the chat. # @attr draft_message [TD::Types::DraftMessage, nil] A draft of a message in the chat; may be null. @@ -32,11 +38,14 @@ class Chat < Base attribute :type, TD::Types::ChatType attribute :title, TD::Types::String attribute :photo, TD::Types::ChatPhoto.optional.default(nil) + attribute :permissions, TD::Types::ChatPermissions attribute :last_message, TD::Types::Message.optional.default(nil) attribute :order, TD::Types::Integer attribute :is_pinned, TD::Types::Bool attribute :is_marked_as_unread, TD::Types::Bool attribute :is_sponsored, TD::Types::Bool + attribute :can_be_deleted_only_for_self, TD::Types::Bool + attribute :can_be_deleted_for_all_users, TD::Types::Bool attribute :can_be_reported, TD::Types::Bool attribute :default_disable_notification, TD::Types::Bool attribute :unread_count, TD::Types::Integer @@ -44,6 +53,7 @@ class Chat < Base attribute :last_read_outbox_message_id, TD::Types::Integer attribute :unread_mention_count, TD::Types::Integer attribute :notification_settings, TD::Types::ChatNotificationSettings + attribute :pinned_message_id, TD::Types::Integer attribute :reply_markup_message_id, TD::Types::Integer attribute :draft_message, TD::Types::DraftMessage.optional.default(nil) attribute :client_data, TD::Types::String diff --git a/lib/tdlib/types/chat_event_action.rb b/lib/tdlib/types/chat_event_action.rb index 1d88261..7022e29 100644 --- a/lib/tdlib/types/chat_event_action.rb +++ b/lib/tdlib/types/chat_event_action.rb @@ -4,6 +4,7 @@ class ChatEventAction < Base %w[ message_edited message_deleted + poll_stopped message_pinned message_unpinned member_joined @@ -12,6 +13,7 @@ class ChatEventAction < Base member_promoted member_restricted title_changed + permissions_changed description_changed username_changed photo_changed diff --git a/lib/tdlib/types/chat_event_action/invites_toggled.rb b/lib/tdlib/types/chat_event_action/invites_toggled.rb index d3ae462..fc5779f 100644 --- a/lib/tdlib/types/chat_event_action/invites_toggled.rb +++ b/lib/tdlib/types/chat_event_action/invites_toggled.rb @@ -1,8 +1,8 @@ module TD::Types - # The anyone_can_invite setting of a supergroup chat was toggled. + # The can_invite_users permission of a supergroup chat was toggled. # - # @attr anyone_can_invite [Boolean] New value of anyone_can_invite. + # @attr can_invite_users [Boolean] New value of can_invite_users permission. class ChatEventAction::InvitesToggled < ChatEventAction - attribute :anyone_can_invite, TD::Types::Bool + attribute :can_invite_users, TD::Types::Bool end end diff --git a/lib/tdlib/types/chat_event_action/permissions_changed.rb b/lib/tdlib/types/chat_event_action/permissions_changed.rb new file mode 100644 index 0000000..2d99181 --- /dev/null +++ b/lib/tdlib/types/chat_event_action/permissions_changed.rb @@ -0,0 +1,10 @@ +module TD::Types + # The chat permissions was changed. + # + # @attr old_permissions [TD::Types::ChatPermissions] Previous chat permissions. + # @attr new_permissions [TD::Types::ChatPermissions] New chat permissions. + class ChatEventAction::PermissionsChanged < ChatEventAction + attribute :old_permissions, TD::Types::ChatPermissions + attribute :new_permissions, TD::Types::ChatPermissions + end +end diff --git a/lib/tdlib/types/chat_event_action/photo_changed.rb b/lib/tdlib/types/chat_event_action/photo_changed.rb index 4c49237..890735c 100644 --- a/lib/tdlib/types/chat_event_action/photo_changed.rb +++ b/lib/tdlib/types/chat_event_action/photo_changed.rb @@ -1,10 +1,10 @@ module TD::Types # The chat photo was changed. # - # @attr old_photo [TD::Types::ChatPhoto, nil] Previous chat photo value; may be null. - # @attr new_photo [TD::Types::ChatPhoto, nil] New chat photo value; may be null. + # @attr old_photo [TD::Types::Photo, nil] Previous chat photo value; may be null. + # @attr new_photo [TD::Types::Photo, nil] New chat photo value; may be null. class ChatEventAction::PhotoChanged < ChatEventAction - attribute :old_photo, TD::Types::ChatPhoto.optional.default(nil) - attribute :new_photo, TD::Types::ChatPhoto.optional.default(nil) + attribute :old_photo, TD::Types::Photo.optional.default(nil) + attribute :new_photo, TD::Types::Photo.optional.default(nil) end end diff --git a/lib/tdlib/types/chat_event_action/poll_stopped.rb b/lib/tdlib/types/chat_event_action/poll_stopped.rb new file mode 100644 index 0000000..371995c --- /dev/null +++ b/lib/tdlib/types/chat_event_action/poll_stopped.rb @@ -0,0 +1,8 @@ +module TD::Types + # A poll in a message was stopped. + # + # @attr message [TD::Types::Message] The message with the poll. + class ChatEventAction::PollStopped < ChatEventAction + attribute :message, TD::Types::Message + end +end diff --git a/lib/tdlib/types/chat_invite_link_info.rb b/lib/tdlib/types/chat_invite_link_info.rb index 570719a..8933757 100644 --- a/lib/tdlib/types/chat_invite_link_info.rb +++ b/lib/tdlib/types/chat_invite_link_info.rb @@ -7,7 +7,7 @@ module TD::Types # @attr photo [TD::Types::ChatPhoto, nil] Chat photo; may be null. # @attr member_count [Integer] Number of members. # @attr member_user_ids [Array] User identifiers of some chat members that may be known to the current user. - # @attr is_public [Boolean] True, if the chat is a public supergroup or channel with a username. + # @attr is_public [Boolean] True, if the chat is a public supergroup or a channel with a username. class ChatInviteLinkInfo < Base attribute :chat_id, TD::Types::Integer attribute :type, TD::Types::ChatType diff --git a/lib/tdlib/types/chat_member_status/administrator.rb b/lib/tdlib/types/chat_member_status/administrator.rb index 2cd8495..3dc3ed1 100644 --- a/lib/tdlib/types/chat_member_status/administrator.rb +++ b/lib/tdlib/types/chat_member_status/administrator.rb @@ -12,9 +12,9 @@ module TD::Types # @attr can_delete_messages [Boolean] True, if the administrator can delete messages of other users. # @attr can_invite_users [Boolean] True, if the administrator can invite new users to the chat. # @attr can_restrict_members [Boolean] True, if the administrator can restrict, ban, or unban chat members. - # @attr can_pin_messages [Boolean] True, if the administrator can pin messages; applicable to supergroups only. - # @attr can_promote_members [Boolean] True, if the administrator can add new administrators with a subset of his own - # privileges or demote administrators that were directly or indirectly promoted by him. + # @attr can_pin_messages [Boolean] True, if the administrator can pin messages; applicable to groups only. + # @attr can_promote_members [Boolean] True, if the administrator can add new administrators with a subset of their + # own privileges or demote administrators that were directly or indirectly promoted by him. class ChatMemberStatus::Administrator < ChatMemberStatus attribute :can_be_edited, TD::Types::Bool attribute :can_change_info, TD::Types::Bool diff --git a/lib/tdlib/types/chat_member_status/restricted.rb b/lib/tdlib/types/chat_member_status/restricted.rb index de149cd..c8c4a92 100644 --- a/lib/tdlib/types/chat_member_status/restricted.rb +++ b/lib/tdlib/types/chat_member_status/restricted.rb @@ -7,21 +7,10 @@ module TD::Types # user; 0 if never. # If the user is restricted for more than 366 days or for less than 30 seconds from the current time, the user is # considered to be restricted forever. - # @attr can_send_messages [Boolean] True, if the user can send text messages, contacts, locations, and venues. - # @attr can_send_media_messages [Boolean] True, if the user can send audio files, documents, photos, videos, video - # notes, and voice notes. - # Implies can_send_messages permissions. - # @attr can_send_other_messages [Boolean] True, if the user can send animations, games, and stickers and use inline - # bots. - # Implies can_send_media_messages permissions. - # @attr can_add_web_page_previews [Boolean] True, if the user may add a web page preview to his messages. - # Implies can_send_messages permissions. + # @attr permissions [TD::Types::ChatPermissions] User permissions in the chat. class ChatMemberStatus::Restricted < ChatMemberStatus attribute :is_member, TD::Types::Bool attribute :restricted_until_date, TD::Types::Integer - attribute :can_send_messages, TD::Types::Bool - attribute :can_send_media_messages, TD::Types::Bool - attribute :can_send_other_messages, TD::Types::Bool - attribute :can_add_web_page_previews, TD::Types::Bool + attribute :permissions, TD::Types::ChatPermissions end end diff --git a/lib/tdlib/types/chat_members_filter.rb b/lib/tdlib/types/chat_members_filter.rb index 09c18e8..5366924 100644 --- a/lib/tdlib/types/chat_members_filter.rb +++ b/lib/tdlib/types/chat_members_filter.rb @@ -2,6 +2,7 @@ module TD::Types # Specifies the kind of chat members to return in searchChatMembers. class ChatMembersFilter < Base %w[ + contacts administrators members restricted diff --git a/lib/tdlib/types/chat_members_filter/contacts.rb b/lib/tdlib/types/chat_members_filter/contacts.rb new file mode 100644 index 0000000..d1aaf43 --- /dev/null +++ b/lib/tdlib/types/chat_members_filter/contacts.rb @@ -0,0 +1,5 @@ +module TD::Types + # Returns contacts of the user. + class ChatMembersFilter::Contacts < ChatMembersFilter + end +end diff --git a/lib/tdlib/types/chat_notification_settings.rb b/lib/tdlib/types/chat_notification_settings.rb index a711516..10b9a09 100644 --- a/lib/tdlib/types/chat_notification_settings.rb +++ b/lib/tdlib/types/chat_notification_settings.rb @@ -11,6 +11,14 @@ module TD::Types # @attr use_default_show_preview [Boolean] If true, show_preview is ignored and the value for the relevant type of # chat is used instead. # @attr show_preview [Boolean] True, if message content should be displayed in notifications. + # @attr use_default_disable_pinned_message_notifications [Boolean] If true, disable_pinned_message_notifications is + # ignored and the value for the relevant type of chat is used instead. + # @attr disable_pinned_message_notifications [Boolean] If true, notifications for incoming pinned messages will be + # created as for an ordinary unread message. + # @attr use_default_disable_mention_notifications [Boolean] If true, disable_mention_notifications is ignored and the + # value for the relevant type of chat is used instead. + # @attr disable_mention_notifications [Boolean] If true, notifications for messages with mentions will be created as + # for an ordinary unread message. class ChatNotificationSettings < Base attribute :use_default_mute_for, TD::Types::Bool attribute :mute_for, TD::Types::Integer @@ -18,5 +26,9 @@ class ChatNotificationSettings < Base attribute :sound, TD::Types::String attribute :use_default_show_preview, TD::Types::Bool attribute :show_preview, TD::Types::Bool + attribute :use_default_disable_pinned_message_notifications, TD::Types::Bool + attribute :disable_pinned_message_notifications, TD::Types::Bool + attribute :use_default_disable_mention_notifications, TD::Types::Bool + attribute :disable_mention_notifications, TD::Types::Bool end end diff --git a/lib/tdlib/types/chat_permissions.rb b/lib/tdlib/types/chat_permissions.rb new file mode 100644 index 0000000..41a0d06 --- /dev/null +++ b/lib/tdlib/types/chat_permissions.rb @@ -0,0 +1,28 @@ +module TD::Types + # Describes actions that a user is allowed to take in a chat. + # + # @attr can_send_messages [Boolean] True, if the user can send text messages, contacts, locations, and venues. + # @attr can_send_media_messages [Boolean] True, if the user can send audio files, documents, photos, videos, video + # notes, and voice notes. + # Implies can_send_messages permissions. + # @attr can_send_polls [Boolean] True, if the user can send polls. + # Implies can_send_messages permissions. + # @attr can_send_other_messages [Boolean] True, if the user can send animations, games, and stickers and use inline + # bots. + # Implies can_send_messages permissions. + # @attr can_add_web_page_previews [Boolean] True, if the user may add a web page preview to their messages. + # Implies can_send_messages permissions. + # @attr can_change_info [Boolean] True, if the user can change the chat title, photo, and other settings. + # @attr can_invite_users [Boolean] True, if the user can invite new users to the chat. + # @attr can_pin_messages [Boolean] True, if the user can pin messages. + class ChatPermissions < Base + attribute :can_send_messages, TD::Types::Bool + attribute :can_send_media_messages, TD::Types::Bool + attribute :can_send_polls, TD::Types::Bool + attribute :can_send_other_messages, TD::Types::Bool + attribute :can_add_web_page_previews, TD::Types::Bool + attribute :can_change_info, TD::Types::Bool + attribute :can_invite_users, TD::Types::Bool + attribute :can_pin_messages, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/chat_photo.rb b/lib/tdlib/types/chat_photo.rb index 973220e..21d8382 100644 --- a/lib/tdlib/types/chat_photo.rb +++ b/lib/tdlib/types/chat_photo.rb @@ -2,7 +2,9 @@ module TD::Types # Describes the photo of a chat. # # @attr small [TD::Types::File] A small (160x160) chat photo. + # The file can be downloaded only before the photo is changed. # @attr big [TD::Types::File] A big (640x640) chat photo. + # The file can be downloaded only before the photo is changed. class ChatPhoto < Base attribute :small, TD::Types::File attribute :big, TD::Types::File diff --git a/lib/tdlib/types/chat_report_reason.rb b/lib/tdlib/types/chat_report_reason.rb index fd853ae..b5c2018 100644 --- a/lib/tdlib/types/chat_report_reason.rb +++ b/lib/tdlib/types/chat_report_reason.rb @@ -5,6 +5,7 @@ class ChatReportReason < Base spam violence pornography + child_abuse copyright custom ].each do |type| diff --git a/lib/tdlib/types/chat_report_reason/child_abuse.rb b/lib/tdlib/types/chat_report_reason/child_abuse.rb new file mode 100644 index 0000000..ca20566 --- /dev/null +++ b/lib/tdlib/types/chat_report_reason/child_abuse.rb @@ -0,0 +1,5 @@ +module TD::Types + # The chat has child abuse related content. + class ChatReportReason::ChildAbuse < ChatReportReason + end +end diff --git a/lib/tdlib/types/check_chat_username_result/public_chats_too_much.rb b/lib/tdlib/types/check_chat_username_result/public_chats_too_much.rb index 4b22044..0c4825f 100644 --- a/lib/tdlib/types/check_chat_username_result/public_chats_too_much.rb +++ b/lib/tdlib/types/check_chat_username_result/public_chats_too_much.rb @@ -1,5 +1,5 @@ module TD::Types - # The user has too much public chats, one of them should be made private first. + # The user has too much chats with username, one of them should be made private first. class CheckChatUsernameResult::PublicChatsTooMuch < CheckChatUsernameResult end end diff --git a/lib/tdlib/types/connection_state/waiting_for_network.rb b/lib/tdlib/types/connection_state/waiting_for_network.rb index a744e87..ef4a1f4 100644 --- a/lib/tdlib/types/connection_state/waiting_for_network.rb +++ b/lib/tdlib/types/connection_state/waiting_for_network.rb @@ -1,6 +1,6 @@ module TD::Types # Currently waiting for the network to become available. - # Use SetNetworkType to change the available network type. + # Use setNetworkType to change the available network type. class ConnectionState::WaitingForNetwork < ConnectionState end end diff --git a/lib/tdlib/types/database_statistics.rb b/lib/tdlib/types/database_statistics.rb new file mode 100644 index 0000000..db028ab --- /dev/null +++ b/lib/tdlib/types/database_statistics.rb @@ -0,0 +1,8 @@ +module TD::Types + # Contains database statistics. + # + # @attr statistics [String] Database statistics in an unspecified human-readable format. + class DatabaseStatistics < Base + attribute :statistics, TD::Types::String + end +end diff --git a/lib/tdlib/types/device_token.rb b/lib/tdlib/types/device_token.rb index 4606416..771190e 100644 --- a/lib/tdlib/types/device_token.rb +++ b/lib/tdlib/types/device_token.rb @@ -1,10 +1,10 @@ module TD::Types - # Represents a data needed to subscribe for push notifications. + # Represents a data needed to subscribe for push notifications through registerDevice method. # To use specific push notification service, you must specify the correct application platform and upload valid # server authentication data at https://my.telegram.org. class DeviceToken < Base %w[ - google_cloud_messaging + firebase_cloud_messaging apple_push apple_push_vo_ip windows_push diff --git a/lib/tdlib/types/device_token/apple_push_vo_ip.rb b/lib/tdlib/types/device_token/apple_push_vo_ip.rb index bdab9b3..6f26d8f 100644 --- a/lib/tdlib/types/device_token/apple_push_vo_ip.rb +++ b/lib/tdlib/types/device_token/apple_push_vo_ip.rb @@ -3,8 +3,10 @@ module TD::Types # # @attr device_token [String, nil] Device token; may be empty to de-register a device. # @attr is_app_sandbox [Boolean] True, if App Sandbox is enabled. + # @attr encrypt [Boolean] True, if push notifications should be additionally encrypted. class DeviceToken::ApplePushVoIP < DeviceToken attribute :device_token, TD::Types::String.optional.default(nil) attribute :is_app_sandbox, TD::Types::Bool + attribute :encrypt, TD::Types::Bool end end diff --git a/lib/tdlib/types/device_token/firebase_cloud_messaging.rb b/lib/tdlib/types/device_token/firebase_cloud_messaging.rb new file mode 100644 index 0000000..f7f32ba --- /dev/null +++ b/lib/tdlib/types/device_token/firebase_cloud_messaging.rb @@ -0,0 +1,10 @@ +module TD::Types + # A token for Firebase Cloud Messaging. + # + # @attr token [String, nil] Device registration token; may be empty to de-register a device. + # @attr encrypt [Boolean] True, if push notifications should be additionally encrypted. + class DeviceToken::FirebaseCloudMessaging < DeviceToken + attribute :token, TD::Types::String.optional.default(nil) + attribute :encrypt, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/device_token/google_cloud_messaging.rb b/lib/tdlib/types/device_token/google_cloud_messaging.rb deleted file mode 100644 index 6090d31..0000000 --- a/lib/tdlib/types/device_token/google_cloud_messaging.rb +++ /dev/null @@ -1,8 +0,0 @@ -module TD::Types - # A token for Google Cloud Messaging. - # - # @attr token [String, nil] Device registration token; may be empty to de-register a device. - class DeviceToken::GoogleCloudMessaging < DeviceToken - attribute :token, TD::Types::String.optional.default(nil) - end -end diff --git a/lib/tdlib/types/document.rb b/lib/tdlib/types/document.rb index 2e511ca..f917447 100644 --- a/lib/tdlib/types/document.rb +++ b/lib/tdlib/types/document.rb @@ -3,11 +3,14 @@ module TD::Types # # @attr file_name [String] Original name of the file; as defined by the sender. # @attr mime_type [String] MIME type of the file; as defined by the sender. - # @attr thumbnail [TD::Types::PhotoSize, nil] Document thumbnail; as defined by the sender; may be null. + # @attr minithumbnail [TD::Types::Minithumbnail, nil] Document minithumbnail; may be null. + # @attr thumbnail [TD::Types::PhotoSize, nil] Document thumbnail in JPEG or PNG format (PNG will be used only for + # background patterns); as defined by the sender; may be null. # @attr document [TD::Types::File] File containing the document. class Document < Base attribute :file_name, TD::Types::String attribute :mime_type, TD::Types::String + attribute :minithumbnail, TD::Types::Minithumbnail.optional.default(nil) attribute :thumbnail, TD::Types::PhotoSize.optional.default(nil) attribute :document, TD::Types::File end diff --git a/lib/tdlib/types/emojis.rb b/lib/tdlib/types/emojis.rb new file mode 100644 index 0000000..2a97600 --- /dev/null +++ b/lib/tdlib/types/emojis.rb @@ -0,0 +1,8 @@ +module TD::Types + # Represents a list of emoji. + # + # @attr emojis [Array] List of emojis. + class Emojis < Base + attribute :emojis, TD::Types::Array.of(TD::Types::String) + end +end diff --git a/lib/tdlib/types/file_part.rb b/lib/tdlib/types/file_part.rb new file mode 100644 index 0000000..80223d0 --- /dev/null +++ b/lib/tdlib/types/file_part.rb @@ -0,0 +1,8 @@ +module TD::Types + # Contains a part of a file. + # + # @attr data [String] File bytes. + class FilePart < Base + attribute :data, TD::Types::String + end +end diff --git a/lib/tdlib/types/file_type/wallpaper.rb b/lib/tdlib/types/file_type/wallpaper.rb index 68fb231..81ab8ce 100644 --- a/lib/tdlib/types/file_type/wallpaper.rb +++ b/lib/tdlib/types/file_type/wallpaper.rb @@ -1,5 +1,5 @@ module TD::Types - # The file is a wallpaper. + # The file is a wallpaper or a background pattern. class FileType::Wallpaper < FileType end end diff --git a/lib/tdlib/types/http_url.rb b/lib/tdlib/types/http_url.rb new file mode 100644 index 0000000..b37f096 --- /dev/null +++ b/lib/tdlib/types/http_url.rb @@ -0,0 +1,8 @@ +module TD::Types + # Contains an HTTP URL. + # + # @attr url [String] The URL. + class HttpUrl < Base + attribute :url, TD::Types::String + end +end diff --git a/lib/tdlib/types/inline_keyboard_button_type.rb b/lib/tdlib/types/inline_keyboard_button_type.rb index d420b16..932f895 100644 --- a/lib/tdlib/types/inline_keyboard_button_type.rb +++ b/lib/tdlib/types/inline_keyboard_button_type.rb @@ -3,6 +3,7 @@ module TD::Types class InlineKeyboardButtonType < Base %w[ url + login_url callback callback_game switch_inline diff --git a/lib/tdlib/types/inline_keyboard_button_type/login_url.rb b/lib/tdlib/types/inline_keyboard_button_type/login_url.rb new file mode 100644 index 0000000..292c971 --- /dev/null +++ b/lib/tdlib/types/inline_keyboard_button_type/login_url.rb @@ -0,0 +1,12 @@ +module TD::Types + # A button that opens a specified URL and automatically logs in in current user if they allowed to do that. + # + # @attr url [String] HTTP URL to open. + # @attr id [Integer] Unique button identifier. + # @attr forward_text [String] If non-empty, new text of the button in forwarded messages. + class InlineKeyboardButtonType::LoginUrl < InlineKeyboardButtonType + attribute :url, TD::Types::String + attribute :id, TD::Types::Integer + attribute :forward_text, TD::Types::String + end +end diff --git a/lib/tdlib/types/input_background.rb b/lib/tdlib/types/input_background.rb new file mode 100644 index 0000000..958ba6b --- /dev/null +++ b/lib/tdlib/types/input_background.rb @@ -0,0 +1,11 @@ +module TD::Types + # Contains information about background to set. + class InputBackground < Base + %w[ + local + remote + ].each do |type| + autoload TD::Types.camelize(type), "tdlib/types/input_background/#{type}" + end + end +end diff --git a/lib/tdlib/types/input_background/local.rb b/lib/tdlib/types/input_background/local.rb new file mode 100644 index 0000000..a3cdd17 --- /dev/null +++ b/lib/tdlib/types/input_background/local.rb @@ -0,0 +1,10 @@ +module TD::Types + # A background from a local file. + # + # @attr background [TD::Types::InputFile] Background file to use. + # Only {TD::Types::InputFile::Local} and {TD::Types::InputFile::Generated} are supported. + # The file nust be in JPEG format for wallpapers and in PNG format for patterns. + class InputBackground::Local < InputBackground + attribute :background, TD::Types::InputFile + end +end diff --git a/lib/tdlib/types/input_background/remote.rb b/lib/tdlib/types/input_background/remote.rb new file mode 100644 index 0000000..e4a497b --- /dev/null +++ b/lib/tdlib/types/input_background/remote.rb @@ -0,0 +1,8 @@ +module TD::Types + # A background from the server. + # + # @attr background_id [Integer] The background identifier. + class InputBackground::Remote < InputBackground + attribute :background_id, TD::Types::Integer + end +end diff --git a/lib/tdlib/types/input_file/generated.rb b/lib/tdlib/types/input_file/generated.rb index e8ccfdc..3c8c01f 100644 --- a/lib/tdlib/types/input_file/generated.rb +++ b/lib/tdlib/types/input_file/generated.rb @@ -5,6 +5,7 @@ module TD::Types # no such file. # @attr conversion [String] String specifying the conversion applied to the original file; should be persistent # across application restarts. + # Conversions beginning with '#' are reserved for internal TDLib usage. # @attr expected_size [Integer] Expected size of the generated file; 0 if unknown. class InputFile::Generated < InputFile attribute :original_path, TD::Types::String.optional.default(nil) diff --git a/lib/tdlib/types/input_inline_query_result/animated_gif.rb b/lib/tdlib/types/input_inline_query_result/animated_gif.rb index 81e4ea1..86d71ff 100644 --- a/lib/tdlib/types/input_inline_query_result/animated_gif.rb +++ b/lib/tdlib/types/input_inline_query_result/animated_gif.rb @@ -8,10 +8,11 @@ module TD::Types # @attr gif_duration [Integer] Duration of the GIF, in seconds. # @attr gif_width [Integer] Width of the GIF. # @attr gif_height [Integer] Height of the GIF. - # @attr reply_markup [TD::Types::ReplyMarkup::InlineKeyboard, nil] The message reply markup. - # @attr input_message_content [TD::Types::InputMessageContent::Text, TD::Types::InputMessageContent::Animation, - # TD::Types::InputMessageContent::Location, TD::Types::InputMessageContent::Venue, - # TD::Types::InputMessageContent::Contact] The content of the message to be sent. + # @attr reply_markup [TD::Types::ReplyMarkup] The message reply markup. + # Must be of type {TD::Types::ReplyMarkup::InlineKeyboard} or null. + # @attr input_message_content [TD::Types::InputMessageContent] The content of the message to be sent. + # Must be one of the following types: InputMessageText, InputMessageAnimation, InputMessageLocation, + # InputMessageVenue or InputMessageContact. class InputInlineQueryResult::AnimatedGif < InputInlineQueryResult attribute :id, TD::Types::String attribute :title, TD::Types::String diff --git a/lib/tdlib/types/input_inline_query_result/animated_mpeg4.rb b/lib/tdlib/types/input_inline_query_result/animated_mpeg4.rb index f168ae0..b9a360e 100644 --- a/lib/tdlib/types/input_inline_query_result/animated_mpeg4.rb +++ b/lib/tdlib/types/input_inline_query_result/animated_mpeg4.rb @@ -9,10 +9,11 @@ module TD::Types # @attr mpeg4_duration [Integer] Duration of the video, in seconds. # @attr mpeg4_width [Integer] Width of the video. # @attr mpeg4_height [Integer] Height of the video. - # @attr reply_markup [TD::Types::ReplyMarkup::InlineKeyboard, nil] The message reply markup. - # @attr input_message_content [TD::Types::InputMessageContent::Text, TD::Types::InputMessageContent::Animation, - # TD::Types::InputMessageContent::Location, TD::Types::InputMessageContent::Venue, - # TD::Types::InputMessageContent::Contact] The content of the message to be sent. + # @attr reply_markup [TD::Types::ReplyMarkup] The message reply markup. + # Must be of type {TD::Types::ReplyMarkup::InlineKeyboard} or null. + # @attr input_message_content [TD::Types::InputMessageContent] The content of the message to be sent. + # Must be one of the following types: InputMessageText, InputMessageAnimation, InputMessageLocation, + # InputMessageVenue or InputMessageContact. class InputInlineQueryResult::AnimatedMpeg4 < InputInlineQueryResult attribute :id, TD::Types::String attribute :title, TD::Types::String diff --git a/lib/tdlib/types/input_inline_query_result/article.rb b/lib/tdlib/types/input_inline_query_result/article.rb index 7bc4fb8..ce2e1c2 100644 --- a/lib/tdlib/types/input_inline_query_result/article.rb +++ b/lib/tdlib/types/input_inline_query_result/article.rb @@ -9,10 +9,11 @@ module TD::Types # @attr thumbnail_url [String] URL of the result thumbnail, if it exists. # @attr thumbnail_width [Integer] Thumbnail width, if known. # @attr thumbnail_height [Integer] Thumbnail height, if known. - # @attr reply_markup [TD::Types::ReplyMarkup::InlineKeyboard, nil] The message reply markup. - # @attr input_message_content [TD::Types::InputMessageContent::Text, TD::Types::InputMessageContent::Location, - # TD::Types::InputMessageContent::Venue, TD::Types::InputMessageContent::Contact] The content of the message to be - # sent. + # @attr reply_markup [TD::Types::ReplyMarkup] The message reply markup. + # Must be of type {TD::Types::ReplyMarkup::InlineKeyboard} or null. + # @attr input_message_content [TD::Types::InputMessageContent] The content of the message to be sent. + # Must be one of the following types: InputMessageText, InputMessageLocation, InputMessageVenue or + # InputMessageContact. class InputInlineQueryResult::Article < InputInlineQueryResult attribute :id, TD::Types::String attribute :url, TD::Types::String diff --git a/lib/tdlib/types/input_inline_query_result/audio.rb b/lib/tdlib/types/input_inline_query_result/audio.rb index 7493790..90f41bf 100644 --- a/lib/tdlib/types/input_inline_query_result/audio.rb +++ b/lib/tdlib/types/input_inline_query_result/audio.rb @@ -6,10 +6,11 @@ module TD::Types # @attr performer [String] Performer of the audio file. # @attr audio_url [String] The URL of the audio file. # @attr audio_duration [Integer] Audio file duration, in seconds. - # @attr reply_markup [TD::Types::ReplyMarkup::InlineKeyboard, nil] The message reply markup. - # @attr input_message_content [TD::Types::InputMessageContent::Text, TD::Types::InputMessageContent::Audio, - # TD::Types::InputMessageContent::Location, TD::Types::InputMessageContent::Venue, - # TD::Types::InputMessageContent::Contact] The content of the message to be sent. + # @attr reply_markup [TD::Types::ReplyMarkup] The message reply markup. + # Must be of type {TD::Types::ReplyMarkup::InlineKeyboard} or null. + # @attr input_message_content [TD::Types::InputMessageContent] The content of the message to be sent. + # Must be one of the following types: InputMessageText, InputMessageAudio, InputMessageLocation, InputMessageVenue + # or InputMessageContact. class InputInlineQueryResult::Audio < InputInlineQueryResult attribute :id, TD::Types::String attribute :title, TD::Types::String diff --git a/lib/tdlib/types/input_inline_query_result/contact.rb b/lib/tdlib/types/input_inline_query_result/contact.rb index b3fcba6..f9079f0 100644 --- a/lib/tdlib/types/input_inline_query_result/contact.rb +++ b/lib/tdlib/types/input_inline_query_result/contact.rb @@ -6,10 +6,11 @@ module TD::Types # @attr thumbnail_url [String] URL of the result thumbnail, if it exists. # @attr thumbnail_width [Integer] Thumbnail width, if known. # @attr thumbnail_height [Integer] Thumbnail height, if known. - # @attr reply_markup [TD::Types::ReplyMarkup::InlineKeyboard, nil] The message reply markup. - # @attr input_message_content [TD::Types::InputMessageContent::Text, TD::Types::InputMessageContent::Location, - # TD::Types::InputMessageContent::Venue, TD::Types::InputMessageContent::Contact] The content of the message to be - # sent. + # @attr reply_markup [TD::Types::ReplyMarkup] The message reply markup. + # Must be of type {TD::Types::ReplyMarkup::InlineKeyboard} or null. + # @attr input_message_content [TD::Types::InputMessageContent] The content of the message to be sent. + # Must be one of the following types: InputMessageText, InputMessageLocation, InputMessageVenue or + # InputMessageContact. class InputInlineQueryResult::Contact < InputInlineQueryResult attribute :id, TD::Types::String attribute :contact, TD::Types::Contact diff --git a/lib/tdlib/types/input_inline_query_result/document.rb b/lib/tdlib/types/input_inline_query_result/document.rb index 194250a..21762a3 100644 --- a/lib/tdlib/types/input_inline_query_result/document.rb +++ b/lib/tdlib/types/input_inline_query_result/document.rb @@ -10,10 +10,11 @@ module TD::Types # @attr thumbnail_url [String] The URL of the file thumbnail, if it exists. # @attr thumbnail_width [Integer] Width of the thumbnail. # @attr thumbnail_height [Integer] Height of the thumbnail. - # @attr reply_markup [TD::Types::ReplyMarkup::InlineKeyboard, nil] The message reply markup. - # @attr input_message_content [TD::Types::InputMessageContent::Text, TD::Types::InputMessageContent::Document, - # TD::Types::InputMessageContent::Location, TD::Types::InputMessageContent::Venue, - # TD::Types::InputMessageContent::Contact] The content of the message to be sent. + # @attr reply_markup [TD::Types::ReplyMarkup] The message reply markup. + # Must be of type {TD::Types::ReplyMarkup::InlineKeyboard} or null. + # @attr input_message_content [TD::Types::InputMessageContent] The content of the message to be sent. + # Must be one of the following types: InputMessageText, InputMessageDocument, InputMessageLocation, + # InputMessageVenue or InputMessageContact. class InputInlineQueryResult::Document < InputInlineQueryResult attribute :id, TD::Types::String attribute :title, TD::Types::String diff --git a/lib/tdlib/types/input_inline_query_result/game.rb b/lib/tdlib/types/input_inline_query_result/game.rb index cf9d7ca..83def4d 100644 --- a/lib/tdlib/types/input_inline_query_result/game.rb +++ b/lib/tdlib/types/input_inline_query_result/game.rb @@ -3,7 +3,8 @@ module TD::Types # # @attr id [String] Unique identifier of the query result. # @attr game_short_name [String] Short name of the game. - # @attr reply_markup [TD::Types::ReplyMarkup::InlineKeyboard, nil] Message reply markup. + # @attr reply_markup [TD::Types::ReplyMarkup] Message reply markup. + # Must be of type {TD::Types::ReplyMarkup::InlineKeyboard} or null. class InputInlineQueryResult::Game < InputInlineQueryResult attribute :id, TD::Types::String attribute :game_short_name, TD::Types::String diff --git a/lib/tdlib/types/input_inline_query_result/location.rb b/lib/tdlib/types/input_inline_query_result/location.rb index 282546f..dbaaec0 100644 --- a/lib/tdlib/types/input_inline_query_result/location.rb +++ b/lib/tdlib/types/input_inline_query_result/location.rb @@ -9,10 +9,11 @@ module TD::Types # @attr thumbnail_url [String] URL of the result thumbnail, if it exists. # @attr thumbnail_width [Integer] Thumbnail width, if known. # @attr thumbnail_height [Integer] Thumbnail height, if known. - # @attr reply_markup [TD::Types::ReplyMarkup::InlineKeyboard, nil] The message reply markup. - # @attr input_message_content [TD::Types::InputMessageContent::Text, TD::Types::InputMessageContent::Location, - # TD::Types::InputMessageContent::Venue, TD::Types::InputMessageContent::Contact] The content of the message to be - # sent. + # @attr reply_markup [TD::Types::ReplyMarkup] The message reply markup. + # Must be of type {TD::Types::ReplyMarkup::InlineKeyboard} or null. + # @attr input_message_content [TD::Types::InputMessageContent] The content of the message to be sent. + # Must be one of the following types: InputMessageText, InputMessageLocation, InputMessageVenue or + # InputMessageContact. class InputInlineQueryResult::Location < InputInlineQueryResult attribute :id, TD::Types::String attribute :location, TD::Types::Location diff --git a/lib/tdlib/types/input_inline_query_result/photo.rb b/lib/tdlib/types/input_inline_query_result/photo.rb index d315cab..78f4959 100644 --- a/lib/tdlib/types/input_inline_query_result/photo.rb +++ b/lib/tdlib/types/input_inline_query_result/photo.rb @@ -8,9 +8,11 @@ module TD::Types # @attr photo_url [String] The URL of the JPEG photo (photo size must not exceed 5MB). # @attr photo_width [Integer] Width of the photo. # @attr photo_height [Integer] Height of the photo. - # @attr input_message_content [TD::Types::InputMessageContent::Text, TD::Types::InputMessageContent::Photo, - # TD::Types::InputMessageContent::Location, TD::Types::InputMessageContent::Venue, - # TD::Types::InputMessageContent::Contact] The content of the message to be sent. + # @attr reply_markup [TD::Types::ReplyMarkup] The message reply markup. + # Must be of type {TD::Types::ReplyMarkup::InlineKeyboard} or null. + # @attr input_message_content [TD::Types::InputMessageContent] The content of the message to be sent. + # Must be one of the following types: InputMessageText, InputMessagePhoto, InputMessageLocation, InputMessageVenue + # or InputMessageContact. class InputInlineQueryResult::Photo < InputInlineQueryResult attribute :id, TD::Types::String attribute :title, TD::Types::String diff --git a/lib/tdlib/types/input_inline_query_result/sticker.rb b/lib/tdlib/types/input_inline_query_result/sticker.rb index 7fe843f..c44402c 100644 --- a/lib/tdlib/types/input_inline_query_result/sticker.rb +++ b/lib/tdlib/types/input_inline_query_result/sticker.rb @@ -1,15 +1,16 @@ module TD::Types - # Represents a link to a WEBP sticker. + # Represents a link to a WEBP or a TGS sticker. # # @attr id [String] Unique identifier of the query result. # @attr thumbnail_url [String] URL of the sticker thumbnail, if it exists. - # @attr sticker_url [String] The URL of the WEBP sticker (sticker file size must not exceed 5MB). + # @attr sticker_url [String] The URL of the WEBP or a TGS sticker (sticker file size must not exceed 5MB). # @attr sticker_width [Integer] Width of the sticker. # @attr sticker_height [Integer] Height of the sticker. - # @attr reply_markup [TD::Types::ReplyMarkup::InlineKeyboard, nil] The message reply markup. - # @attr input_message_content [TD::Types::InputMessageContent::Text, TD::Types::InputMessageContent::Sticker, - # TD::Types::InputMessageContent::Location, TD::Types::InputMessageContent::Venue, - # TD::Types::InputMessageContent::Contact] The content of the message to be sent. + # @attr reply_markup [TD::Types::ReplyMarkup] The message reply markup. + # Must be of type {TD::Types::ReplyMarkup::InlineKeyboard} or null. + # @attr input_message_content [TD::Types::InputMessageContent] The content of the message to be sent. + # Must be one of the following types: InputMessageText, inputMessageSticker, InputMessageLocation, + # InputMessageVenue or InputMessageContact. class InputInlineQueryResult::Sticker < InputInlineQueryResult attribute :id, TD::Types::String attribute :thumbnail_url, TD::Types::String diff --git a/lib/tdlib/types/input_inline_query_result/venue.rb b/lib/tdlib/types/input_inline_query_result/venue.rb index f3f91e7..5842c30 100644 --- a/lib/tdlib/types/input_inline_query_result/venue.rb +++ b/lib/tdlib/types/input_inline_query_result/venue.rb @@ -6,10 +6,11 @@ module TD::Types # @attr thumbnail_url [String] URL of the result thumbnail, if it exists. # @attr thumbnail_width [Integer] Thumbnail width, if known. # @attr thumbnail_height [Integer] Thumbnail height, if known. - # @attr reply_markup [TD::Types::ReplyMarkup::InlineKeyboard, nil] The message reply markup. - # @attr input_message_content [TD::Types::InputMessageContent::Text, TD::Types::InputMessageContent::Location, - # TD::Types::InputMessageContent::Venue, TD::Types::InputMessageContent::Contact] The content of the message to be - # sent. + # @attr reply_markup [TD::Types::ReplyMarkup] The message reply markup. + # Must be of type {TD::Types::ReplyMarkup::InlineKeyboard} or null. + # @attr input_message_content [TD::Types::InputMessageContent] The content of the message to be sent. + # Must be one of the following types: InputMessageText, InputMessageLocation, InputMessageVenue or + # InputMessageContact. class InputInlineQueryResult::Venue < InputInlineQueryResult attribute :id, TD::Types::String attribute :venue, TD::Types::Venue diff --git a/lib/tdlib/types/input_inline_query_result/video.rb b/lib/tdlib/types/input_inline_query_result/video.rb index 08a4ded..2382e7e 100644 --- a/lib/tdlib/types/input_inline_query_result/video.rb +++ b/lib/tdlib/types/input_inline_query_result/video.rb @@ -11,10 +11,11 @@ module TD::Types # @attr video_width [Integer] Width of the video. # @attr video_height [Integer] Height of the video. # @attr video_duration [Integer] Video duration, in seconds. - # @attr reply_markup [TD::Types::ReplyMarkup::InlineKeyboard, nil] The message reply markup. - # @attr input_message_content [TD::Types::InputMessageContent::Text, TD::Types::InputMessageContent::Video, - # TD::Types::InputMessageContent::Location, TD::Types::InputMessageContent::Venue, - # TD::Types::InputMessageContent::Contact] The content of the message to be sent. + # @attr reply_markup [TD::Types::ReplyMarkup] The message reply markup. + # Must be of type {TD::Types::ReplyMarkup::InlineKeyboard} or null. + # @attr input_message_content [TD::Types::InputMessageContent] The content of the message to be sent. + # Must be one of the following types: InputMessageText, InputMessageVideo, InputMessageLocation, InputMessageVenue + # or InputMessageContact. class InputInlineQueryResult::Video < InputInlineQueryResult attribute :id, TD::Types::String attribute :title, TD::Types::String diff --git a/lib/tdlib/types/input_inline_query_result/voice_note.rb b/lib/tdlib/types/input_inline_query_result/voice_note.rb index fbc37af..3cfc479 100644 --- a/lib/tdlib/types/input_inline_query_result/voice_note.rb +++ b/lib/tdlib/types/input_inline_query_result/voice_note.rb @@ -5,10 +5,11 @@ module TD::Types # @attr title [String] Title of the voice note. # @attr voice_note_url [String] The URL of the voice note file. # @attr voice_note_duration [Integer] Duration of the voice note, in seconds. - # @attr reply_markup [TD::Types::ReplyMarkup::InlineKeyboard, nil] The message reply markup. - # @attr input_message_content [TD::Types::InputMessageContent::Text, TD::Types::InputMessageContent::VoiceNote, - # TD::Types::InputMessageContent::Location, TD::Types::InputMessageContent::Venue, - # TD::Types::InputMessageContent::Contact] The content of the message to be sent. + # @attr reply_markup [TD::Types::ReplyMarkup] The message reply markup. + # Must be of type {TD::Types::ReplyMarkup::InlineKeyboard} or null. + # @attr input_message_content [TD::Types::InputMessageContent] The content of the message to be sent. + # Must be one of the following types: InputMessageText, InputMessageVoiceNote, InputMessageLocation, + # InputMessageVenue or InputMessageContact. class InputInlineQueryResult::VoiceNote < InputInlineQueryResult attribute :id, TD::Types::String attribute :title, TD::Types::String diff --git a/lib/tdlib/types/input_message_content.rb b/lib/tdlib/types/input_message_content.rb index 3544a6d..3276290 100644 --- a/lib/tdlib/types/input_message_content.rb +++ b/lib/tdlib/types/input_message_content.rb @@ -16,6 +16,7 @@ class InputMessageContent < Base contact game invoice + poll forwarded ].each do |type| autoload TD::Types.camelize(type), "tdlib/types/input_message_content/#{type}" diff --git a/lib/tdlib/types/input_message_content/forwarded.rb b/lib/tdlib/types/input_message_content/forwarded.rb index c29edc4..907f6b4 100644 --- a/lib/tdlib/types/input_message_content/forwarded.rb +++ b/lib/tdlib/types/input_message_content/forwarded.rb @@ -5,9 +5,16 @@ module TD::Types # @attr message_id [Integer] Identifier of the message to forward. # @attr in_game_share [Boolean] True, if a game message should be shared within a launched game; applies only to game # messages. + # @attr send_copy [Boolean] True, if content of the message needs to be copied without a link to the original + # message. + # Always true if the message is forwarded to a secret chat. + # @attr remove_caption [Boolean] True, if media caption of the message copy needs to be removed. + # Ignored if send_copy is false. class InputMessageContent::Forwarded < InputMessageContent attribute :from_chat_id, TD::Types::Integer attribute :message_id, TD::Types::Integer attribute :in_game_share, TD::Types::Bool + attribute :send_copy, TD::Types::Bool + attribute :remove_caption, TD::Types::Bool end end diff --git a/lib/tdlib/types/input_message_content/poll.rb b/lib/tdlib/types/input_message_content/poll.rb new file mode 100644 index 0000000..e45ad1b --- /dev/null +++ b/lib/tdlib/types/input_message_content/poll.rb @@ -0,0 +1,11 @@ +module TD::Types + # A message with a poll. + # Polls can't be sent to private or secret chats. + # + # @attr question [String] Poll question, 1-255 characters. + # @attr options [Array] List of poll answer options, 2-10 strings 1-100 characters each. + class InputMessageContent::Poll < InputMessageContent + attribute :question, TD::Types::String + attribute :options, TD::Types::Array.of(TD::Types::String) + end +end diff --git a/lib/tdlib/types/input_thumbnail.rb b/lib/tdlib/types/input_thumbnail.rb index 0f0d6b2..33ebbde 100644 --- a/lib/tdlib/types/input_thumbnail.rb +++ b/lib/tdlib/types/input_thumbnail.rb @@ -4,9 +4,9 @@ module TD::Types # # @attr thumbnail [TD::Types::InputFile] Thumbnail file to send. # Sending thumbnails by file_id is currently not supported. - # @attr width [Integer] Thumbnail width, usually shouldn't exceed 90. + # @attr width [Integer] Thumbnail width, usually shouldn't exceed 320. # Use 0 if unknown. - # @attr height [Integer] Thumbnail height, usually shouldn't exceed 90. + # @attr height [Integer] Thumbnail height, usually shouldn't exceed 320. # Use 0 if unknown. class InputThumbnail < Base attribute :thumbnail, TD::Types::InputFile diff --git a/lib/tdlib/types/json_object_member.rb b/lib/tdlib/types/json_object_member.rb new file mode 100644 index 0000000..345b71b --- /dev/null +++ b/lib/tdlib/types/json_object_member.rb @@ -0,0 +1,10 @@ +module TD::Types + # Represents one member of a JSON object. + # + # @attr key [String] Member's key. + # @attr value [TD::Types::JsonValue] Member's value. + class JsonObjectMember < Base + attribute :key, TD::Types::String + attribute :value, TD::Types::JsonValue + end +end diff --git a/lib/tdlib/types/json_value.rb b/lib/tdlib/types/json_value.rb new file mode 100644 index 0000000..ed56ae9 --- /dev/null +++ b/lib/tdlib/types/json_value.rb @@ -0,0 +1,15 @@ +module TD::Types + # Represents a JSON value. + class JsonValue < Base + %w[ + null + boolean + number + string + array + object + ].each do |type| + autoload TD::Types.camelize(type), "tdlib/types/json_value/#{type}" + end + end +end diff --git a/lib/tdlib/types/json_value/array.rb b/lib/tdlib/types/json_value/array.rb new file mode 100644 index 0000000..6845ca1 --- /dev/null +++ b/lib/tdlib/types/json_value/array.rb @@ -0,0 +1,8 @@ +module TD::Types + # Represents a JSON array. + # + # @attr values [Array] The list of array elements. + class JsonValue::Array < JsonValue + attribute :values, TD::Types::Array.of(TD::Types::JsonValue) + end +end diff --git a/lib/tdlib/types/json_value/boolean.rb b/lib/tdlib/types/json_value/boolean.rb new file mode 100644 index 0000000..a8f9438 --- /dev/null +++ b/lib/tdlib/types/json_value/boolean.rb @@ -0,0 +1,8 @@ +module TD::Types + # Represents a boolean JSON value. + # + # @attr value [Boolean] The value. + class JsonValue::Boolean < JsonValue + attribute :value, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/json_value/null.rb b/lib/tdlib/types/json_value/null.rb new file mode 100644 index 0000000..500792d --- /dev/null +++ b/lib/tdlib/types/json_value/null.rb @@ -0,0 +1,5 @@ +module TD::Types + # Represents a null JSON value. + class JsonValue::Null < JsonValue + end +end diff --git a/lib/tdlib/types/json_value/number.rb b/lib/tdlib/types/json_value/number.rb new file mode 100644 index 0000000..e97151b --- /dev/null +++ b/lib/tdlib/types/json_value/number.rb @@ -0,0 +1,8 @@ +module TD::Types + # Represents a numeric JSON value. + # + # @attr value [Float] The value. + class JsonValue::Number < JsonValue + attribute :value, TD::Types::Float + end +end diff --git a/lib/tdlib/types/json_value/object.rb b/lib/tdlib/types/json_value/object.rb new file mode 100644 index 0000000..35c90b0 --- /dev/null +++ b/lib/tdlib/types/json_value/object.rb @@ -0,0 +1,8 @@ +module TD::Types + # Represents a JSON object. + # + # @attr members [Array] The list of object members. + class JsonValue::Object < JsonValue + attribute :members, TD::Types::Array.of(TD::Types::JsonObjectMember) + end +end diff --git a/lib/tdlib/types/json_value/string.rb b/lib/tdlib/types/json_value/string.rb new file mode 100644 index 0000000..3be456c --- /dev/null +++ b/lib/tdlib/types/json_value/string.rb @@ -0,0 +1,8 @@ +module TD::Types + # Represents a string JSON value. + # + # @attr value [String] The value. + class JsonValue::String < JsonValue + attribute :value, TD::Types::String + end +end diff --git a/lib/tdlib/types/language_pack_info.rb b/lib/tdlib/types/language_pack_info.rb index 3e5594a..e40d914 100644 --- a/lib/tdlib/types/language_pack_info.rb +++ b/lib/tdlib/types/language_pack_info.rb @@ -2,13 +2,34 @@ module TD::Types # Contains information about a language pack. # # @attr id [String] Unique language pack identifier. + # @attr base_language_pack_id [String, nil] Identifier of a base language pack; may be empty. + # If a string is missed in the language pack, then it should be fetched from base language pack. + # Unsupported in custom language packs. # @attr name [String] Language name. # @attr native_name [String] Name of the language in that language. + # @attr plural_code [String] A language code to be used to apply plural forms. + # See https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html for more info. + # @attr is_official [Boolean] True, if the language pack is official. + # @attr is_rtl [Boolean] True, if the language pack strings are RTL. + # @attr is_beta [Boolean] True, if the language pack is a beta language pack. + # @attr is_installed [Boolean] True, if the language pack is installed by the current user. + # @attr total_string_count [Integer] Total number of non-deleted strings from the language pack. + # @attr translated_string_count [Integer] Total number of translated strings from the language pack. # @attr local_string_count [Integer] Total number of non-deleted strings from the language pack available locally. + # @attr translation_url [String, nil] Link to language translation interface; empty for custom local language packs. class LanguagePackInfo < Base attribute :id, TD::Types::String + attribute :base_language_pack_id, TD::Types::String.optional.default(nil) attribute :name, TD::Types::String attribute :native_name, TD::Types::String + attribute :plural_code, TD::Types::String + attribute :is_official, TD::Types::Bool + attribute :is_rtl, TD::Types::Bool + attribute :is_beta, TD::Types::Bool + attribute :is_installed, TD::Types::Bool + attribute :total_string_count, TD::Types::Integer + attribute :translated_string_count, TD::Types::Integer attribute :local_string_count, TD::Types::Integer + attribute :translation_url, TD::Types::String.optional.default(nil) end end diff --git a/lib/tdlib/types/language_pack_string_value/pluralized.rb b/lib/tdlib/types/language_pack_string_value/pluralized.rb index 07858a2..06b96c1 100644 --- a/lib/tdlib/types/language_pack_string_value/pluralized.rb +++ b/lib/tdlib/types/language_pack_string_value/pluralized.rb @@ -1,5 +1,6 @@ module TD::Types # A language pack string which has different forms based on the number of some object it mentions. + # See https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html for more info. # # @attr zero_value [String] Value for zero objects. # @attr one_value [String] Value for one object. diff --git a/lib/tdlib/types/link_state/is_contact.rb b/lib/tdlib/types/link_state/is_contact.rb index acd3e49..626387e 100644 --- a/lib/tdlib/types/link_state/is_contact.rb +++ b/lib/tdlib/types/link_state/is_contact.rb @@ -1,5 +1,5 @@ module TD::Types - # The phone number of user A has been saved to the contacts list of user B. + # The phone number of user A has been saved to the contact list of user B. class LinkState::IsContact < LinkState end end diff --git a/lib/tdlib/types/link_state/knows_phone_number.rb b/lib/tdlib/types/link_state/knows_phone_number.rb index 15b913c..7109ee4 100644 --- a/lib/tdlib/types/link_state/knows_phone_number.rb +++ b/lib/tdlib/types/link_state/knows_phone_number.rb @@ -1,5 +1,5 @@ module TD::Types - # The phone number of user A is known but that number has not been saved to the contacts list of user B. + # The phone number of user A is known but that number has not been saved to the contact list of user B. class LinkState::KnowsPhoneNumber < LinkState end end diff --git a/lib/tdlib/types/local_file.rb b/lib/tdlib/types/local_file.rb index 068bb8b..70790dd 100644 --- a/lib/tdlib/types/local_file.rb +++ b/lib/tdlib/types/local_file.rb @@ -7,8 +7,10 @@ module TD::Types # @attr is_downloading_active [Boolean] True, if the file is currently being downloaded (or a local copy is being # generated by some other means). # @attr is_downloading_completed [Boolean] True, if the local copy is fully available. - # @attr downloaded_prefix_size [Integer] If is_downloading_completed is false, then only some prefix of the file is - # ready to be read. + # @attr download_offset [Integer] Download will be started from this offset. + # downloaded_prefix_size is calculated from this offset. + # @attr downloaded_prefix_size [Integer] If is_downloading_completed is false, then only some prefix of the file + # starting from download_offset is ready to be read. # downloaded_prefix_size is the size of that prefix. # @attr downloaded_size [Integer] Total downloaded file bytes. # Should be used only for calculating download progress. @@ -19,6 +21,7 @@ class LocalFile < Base attribute :can_be_deleted, TD::Types::Bool attribute :is_downloading_active, TD::Types::Bool attribute :is_downloading_completed, TD::Types::Bool + attribute :download_offset, TD::Types::Integer attribute :downloaded_prefix_size, TD::Types::Integer attribute :downloaded_size, TD::Types::Integer end diff --git a/lib/tdlib/types/log_stream.rb b/lib/tdlib/types/log_stream.rb new file mode 100644 index 0000000..9b7fbdb --- /dev/null +++ b/lib/tdlib/types/log_stream.rb @@ -0,0 +1,12 @@ +module TD::Types + # Describes a stream to which TDLib internal log is written. + class LogStream < Base + %w[ + default + file + empty + ].each do |type| + autoload TD::Types.camelize(type), "tdlib/types/log_stream/#{type}" + end + end +end diff --git a/lib/tdlib/types/log_stream/default.rb b/lib/tdlib/types/log_stream/default.rb new file mode 100644 index 0000000..db2f175 --- /dev/null +++ b/lib/tdlib/types/log_stream/default.rb @@ -0,0 +1,5 @@ +module TD::Types + # The log is written to stderr or an OS specific log. + class LogStream::Default < LogStream + end +end diff --git a/lib/tdlib/types/log_stream/empty.rb b/lib/tdlib/types/log_stream/empty.rb new file mode 100644 index 0000000..5f8780d --- /dev/null +++ b/lib/tdlib/types/log_stream/empty.rb @@ -0,0 +1,5 @@ +module TD::Types + # The log is written nowhere. + class LogStream::Empty < LogStream + end +end diff --git a/lib/tdlib/types/log_stream/file.rb b/lib/tdlib/types/log_stream/file.rb new file mode 100644 index 0000000..79eb386 --- /dev/null +++ b/lib/tdlib/types/log_stream/file.rb @@ -0,0 +1,11 @@ +module TD::Types + # The log is written to a file. + # + # @attr path [String] Path to the file to where the internal TDLib log will be written. + # @attr max_file_size [Integer] Maximum size of the file to where the internal TDLib log is written before the file + # will be auto-rotated. + class LogStream::File < LogStream + attribute :path, TD::Types::String + attribute :max_file_size, TD::Types::Integer + end +end diff --git a/lib/tdlib/types/log_tags.rb b/lib/tdlib/types/log_tags.rb new file mode 100644 index 0000000..f0bce62 --- /dev/null +++ b/lib/tdlib/types/log_tags.rb @@ -0,0 +1,8 @@ +module TD::Types + # Contains a list of available TDLib internal log tags. + # + # @attr tags [Array] List of log tags. + class LogTags < Base + attribute :tags, TD::Types::Array.of(TD::Types::String) + end +end diff --git a/lib/tdlib/types/log_verbosity_level.rb b/lib/tdlib/types/log_verbosity_level.rb new file mode 100644 index 0000000..26e4c81 --- /dev/null +++ b/lib/tdlib/types/log_verbosity_level.rb @@ -0,0 +1,8 @@ +module TD::Types + # Contains a TDLib internal log verbosity level. + # + # @attr verbosity_level [Integer] Log verbosity level. + class LogVerbosityLevel < Base + attribute :verbosity_level, TD::Types::Integer + end +end diff --git a/lib/tdlib/types/message.rb b/lib/tdlib/types/message.rb index c43599c..fbb55c2 100644 --- a/lib/tdlib/types/message.rb +++ b/lib/tdlib/types/message.rb @@ -3,12 +3,14 @@ module TD::Types # # @attr id [Integer] Message identifier, unique for the chat to which the message belongs. # @attr sender_user_id [Integer] Identifier of the user who sent the message; 0 if unknown. - # It is unknown for channel posts. + # Currently, it is unknown for channel posts and for channel posts automatically forwarded to discussion group. # @attr chat_id [Integer] Chat identifier. # @attr sending_state [TD::Types::MessageSendingState, nil] Information about the sending state of the message; may # be null. # @attr is_outgoing [Boolean] True, if the message is outgoing. # @attr can_be_edited [Boolean] True, if the message can be edited. + # For live location and poll messages this fields shows, whether editMessageLiveLocation or stopPoll can be used + # with this message by the client. # @attr can_be_forwarded [Boolean] True, if the message can be forwarded. # @attr can_be_deleted_only_for_self [Boolean] True, if the message can be deleted only for the current user while # other users will continue to see it. diff --git a/lib/tdlib/types/message_content.rb b/lib/tdlib/types/message_content.rb index 322f1d4..eec08ef 100644 --- a/lib/tdlib/types/message_content.rb +++ b/lib/tdlib/types/message_content.rb @@ -17,6 +17,7 @@ class MessageContent < Base venue contact game + poll invoice call basic_group_chat_create diff --git a/lib/tdlib/types/message_content/game_score.rb b/lib/tdlib/types/message_content/game_score.rb index 49c1b23..39c24cb 100644 --- a/lib/tdlib/types/message_content/game_score.rb +++ b/lib/tdlib/types/message_content/game_score.rb @@ -2,7 +2,7 @@ module TD::Types # A new high score was achieved in a game. # # @attr game_message_id [Integer] Identifier of the message with the game, can be an identifier of a deleted message. - # @attr game_id [Integer] Identifier of the game, may be different from the games presented in the message with the + # @attr game_id [Integer] Identifier of the game; may be different from the games presented in the message with the # game. # @attr score [Integer] New score. class MessageContent::GameScore < MessageContent diff --git a/lib/tdlib/types/message_content/pin_message.rb b/lib/tdlib/types/message_content/pin_message.rb index 92fa0bc..f0f17bf 100644 --- a/lib/tdlib/types/message_content/pin_message.rb +++ b/lib/tdlib/types/message_content/pin_message.rb @@ -1,7 +1,7 @@ module TD::Types # A message has been pinned. # - # @attr message_id [Integer] Identifier of the pinned message, can be an identifier of a deleted message. + # @attr message_id [Integer] Identifier of the pinned message, can be an identifier of a deleted message or 0. class MessageContent::PinMessage < MessageContent attribute :message_id, TD::Types::Integer end diff --git a/lib/tdlib/types/message_content/poll.rb b/lib/tdlib/types/message_content/poll.rb new file mode 100644 index 0000000..e068cda --- /dev/null +++ b/lib/tdlib/types/message_content/poll.rb @@ -0,0 +1,8 @@ +module TD::Types + # A message with a poll. + # + # @attr poll [TD::Types::Poll] Poll. + class MessageContent::Poll < MessageContent + attribute :poll, TD::Types::Poll + end +end diff --git a/lib/tdlib/types/message_forward_info.rb b/lib/tdlib/types/message_forward_info.rb index 44455c6..6d22e5a 100644 --- a/lib/tdlib/types/message_forward_info.rb +++ b/lib/tdlib/types/message_forward_info.rb @@ -1,11 +1,17 @@ module TD::Types - # Contains information about the initial sender of a forwarded message. + # Contains information about a forwarded message. + # + # @attr origin [TD::Types::MessageForwardOrigin] Origin of a forwarded message. + # @attr date [Integer] Point in time (Unix timestamp) when the message was originally sent. + # @attr from_chat_id [Integer] For messages forwarded to the chat with the current user (saved messages) or to the + # channel discussion supergroup, the identifier of the chat from which the message was forwarded last time; 0 if unknown. + # @attr from_message_id [Integer] For messages forwarded to the chat with the current user (saved messages) or to the + # channel discussion supergroup, the identifier of the original message from which the new message was forwarded last + # time; 0 if unknown. class MessageForwardInfo < Base - %w[ - message_forwarded_from_user - message_forwarded_post - ].each do |type| - autoload TD::Types.camelize(type), "tdlib/types/message_forward_info/#{type}" - end + attribute :origin, TD::Types::MessageForwardOrigin + attribute :date, TD::Types::Integer + attribute :from_chat_id, TD::Types::Integer + attribute :from_message_id, TD::Types::Integer end end diff --git a/lib/tdlib/types/message_forward_info/message_forwarded_from_user.rb b/lib/tdlib/types/message_forward_info/message_forwarded_from_user.rb deleted file mode 100644 index 347f7df..0000000 --- a/lib/tdlib/types/message_forward_info/message_forwarded_from_user.rb +++ /dev/null @@ -1,16 +0,0 @@ -module TD::Types - # The message was originally written by a known user. - # - # @attr sender_user_id [Integer] Identifier of the user that originally sent this message. - # @attr date [Integer] Point in time (Unix timestamp) when the message was originally sent. - # @attr forwarded_from_chat_id [Integer] For messages forwarded to the chat with the current user (saved messages), - # the identifier of the chat from which the message was forwarded; 0 if unknown. - # @attr forwarded_from_message_id [Integer] For messages forwarded to the chat with the current user (saved messages) - # the identifier of the original message from which the new message was forwarded; 0 if unknown. - class MessageForwardInfo::MessageForwardedFromUser < MessageForwardInfo - attribute :sender_user_id, TD::Types::Integer - attribute :date, TD::Types::Integer - attribute :forwarded_from_chat_id, TD::Types::Integer - attribute :forwarded_from_message_id, TD::Types::Integer - end -end diff --git a/lib/tdlib/types/message_forward_info/message_forwarded_post.rb b/lib/tdlib/types/message_forward_info/message_forwarded_post.rb deleted file mode 100644 index 3601420..0000000 --- a/lib/tdlib/types/message_forward_info/message_forwarded_post.rb +++ /dev/null @@ -1,21 +0,0 @@ -module TD::Types - # The message was originally a post in a channel. - # - # @attr chat_id [Integer] Identifier of the chat from which the message was forwarded. - # @attr author_signature [String] Post author signature. - # @attr date [Integer] Point in time (Unix timestamp) when the message was originally sent. - # @attr message_id [Integer] Message identifier of the original message from which the new message was forwarded; 0 - # if unknown. - # @attr forwarded_from_chat_id [Integer] For messages forwarded to the chat with the current user (saved messages), - # the identifier of the chat from which the message was forwarded; 0 if unknown. - # @attr forwarded_from_message_id [Integer] For messages forwarded to the chat with the current user (saved - # messages), the identifier of the original message from which the new message was forwarded; 0 if unknown. - class MessageForwardInfo::MessageForwardedPost < MessageForwardInfo - attribute :chat_id, TD::Types::Integer - attribute :author_signature, TD::Types::String - attribute :date, TD::Types::Integer - attribute :message_id, TD::Types::Integer - attribute :forwarded_from_chat_id, TD::Types::Integer - attribute :forwarded_from_message_id, TD::Types::Integer - end -end diff --git a/lib/tdlib/types/message_forward_origin.rb b/lib/tdlib/types/message_forward_origin.rb new file mode 100644 index 0000000..6a07b27 --- /dev/null +++ b/lib/tdlib/types/message_forward_origin.rb @@ -0,0 +1,12 @@ +module TD::Types + # Contains information about the origin of a forwarded message. + class MessageForwardOrigin < Base + %w[ + user + hidden_user + channel + ].each do |type| + autoload TD::Types.camelize(type), "tdlib/types/message_forward_origin/#{type}" + end + end +end diff --git a/lib/tdlib/types/message_forward_origin/channel.rb b/lib/tdlib/types/message_forward_origin/channel.rb new file mode 100644 index 0000000..3042e1a --- /dev/null +++ b/lib/tdlib/types/message_forward_origin/channel.rb @@ -0,0 +1,12 @@ +module TD::Types + # The message was originally a post in a channel. + # + # @attr chat_id [Integer] Identifier of the chat from which the message was originally forwarded. + # @attr message_id [Integer] Message identifier of the original message; 0 if unknown. + # @attr author_signature [String] Original post author signature. + class MessageForwardOrigin::Channel < MessageForwardOrigin + attribute :chat_id, TD::Types::Integer + attribute :message_id, TD::Types::Integer + attribute :author_signature, TD::Types::String + end +end diff --git a/lib/tdlib/types/message_forward_origin/hidden_user.rb b/lib/tdlib/types/message_forward_origin/hidden_user.rb new file mode 100644 index 0000000..7cf7bf4 --- /dev/null +++ b/lib/tdlib/types/message_forward_origin/hidden_user.rb @@ -0,0 +1,8 @@ +module TD::Types + # The message was originally written by a user, which is hidden by their privacy settings. + # + # @attr sender_name [String] Name of the sender. + class MessageForwardOrigin::HiddenUser < MessageForwardOrigin + attribute :sender_name, TD::Types::String + end +end diff --git a/lib/tdlib/types/message_forward_origin/user.rb b/lib/tdlib/types/message_forward_origin/user.rb new file mode 100644 index 0000000..f8f0782 --- /dev/null +++ b/lib/tdlib/types/message_forward_origin/user.rb @@ -0,0 +1,8 @@ +module TD::Types + # The message was originally written by a known user. + # + # @attr sender_user_id [Integer] Identifier of the user that originally sent the message. + class MessageForwardOrigin::User < MessageForwardOrigin + attribute :sender_user_id, TD::Types::Integer + end +end diff --git a/lib/tdlib/types/message_link_info.rb b/lib/tdlib/types/message_link_info.rb new file mode 100644 index 0000000..f812f01 --- /dev/null +++ b/lib/tdlib/types/message_link_info.rb @@ -0,0 +1,14 @@ +module TD::Types + # Contains information about a link to a message in a chat. + # + # @attr is_public [Boolean] True, if the link is a public link for a message in a chat. + # @attr chat_id [Integer] If found, identifier of the chat to which the message belongs, 0 otherwise. + # @attr message [TD::Types::Message, nil] If found, the linked message; may be null. + # @attr for_album [Boolean] True, if the whole media album to which the message belongs is linked. + class MessageLinkInfo < Base + attribute :is_public, TD::Types::Bool + attribute :chat_id, TD::Types::Integer + attribute :message, TD::Types::Message.optional.default(nil) + attribute :for_album, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/message_sending_state/failed.rb b/lib/tdlib/types/message_sending_state/failed.rb index 7632634..f66e04b 100644 --- a/lib/tdlib/types/message_sending_state/failed.rb +++ b/lib/tdlib/types/message_sending_state/failed.rb @@ -1,5 +1,15 @@ module TD::Types # The message failed to be sent. + # + # @attr error_code [Integer] An error code; 0 if unknown. + # @attr error_message [String] Error message. + # @attr can_retry [Boolean] True, if the message can be re-sent. + # @attr retry_after [Float] Time left before the message can be re-sent, in seconds. + # No update is sent when this field changes. class MessageSendingState::Failed < MessageSendingState + attribute :error_code, TD::Types::Integer + attribute :error_message, TD::Types::String + attribute :can_retry, TD::Types::Bool + attribute :retry_after, TD::Types::Float end end diff --git a/lib/tdlib/types/minithumbnail.rb b/lib/tdlib/types/minithumbnail.rb new file mode 100644 index 0000000..f9b00a0 --- /dev/null +++ b/lib/tdlib/types/minithumbnail.rb @@ -0,0 +1,12 @@ +module TD::Types + # Thumbnail image of a very poor quality and low resolution. + # + # @attr width [Integer] Thumbnail width, usually doesn't exceed 40. + # @attr height [Integer] Thumbnail height, usually doesn't exceed 40. + # @attr data [String] The thumbnail in JPEG format. + class Minithumbnail < Base + attribute :width, TD::Types::Integer + attribute :height, TD::Types::Integer + attribute :data, TD::Types::String + end +end diff --git a/lib/tdlib/types/notification.rb b/lib/tdlib/types/notification.rb new file mode 100644 index 0000000..57e6bf6 --- /dev/null +++ b/lib/tdlib/types/notification.rb @@ -0,0 +1,12 @@ +module TD::Types + # Contains information about a notification. + # + # @attr id [Integer] Unique persistent identifier of this notification. + # @attr date [Integer] Notification date. + # @attr type [TD::Types::NotificationType] Notification type. + class Notification < Base + attribute :id, TD::Types::Integer + attribute :date, TD::Types::Integer + attribute :type, TD::Types::NotificationType + end +end diff --git a/lib/tdlib/types/notification_group.rb b/lib/tdlib/types/notification_group.rb new file mode 100644 index 0000000..bb3e075 --- /dev/null +++ b/lib/tdlib/types/notification_group.rb @@ -0,0 +1,16 @@ +module TD::Types + # Describes a group of notifications. + # + # @attr id [Integer] Unique persistent auto-incremented from 1 identifier of the notification group. + # @attr type [TD::Types::NotificationGroupType] Type of the group. + # @attr chat_id [Integer] Identifier of a chat to which all notifications in the group belong. + # @attr total_count [Integer] Total number of active notifications in the group. + # @attr notifications [Array] The list of active notifications. + class NotificationGroup < Base + attribute :id, TD::Types::Integer + attribute :type, TD::Types::NotificationGroupType + attribute :chat_id, TD::Types::Integer + attribute :total_count, TD::Types::Integer + attribute :notifications, TD::Types::Array.of(TD::Types::Notification) + end +end diff --git a/lib/tdlib/types/notification_group_type.rb b/lib/tdlib/types/notification_group_type.rb new file mode 100644 index 0000000..84f4021 --- /dev/null +++ b/lib/tdlib/types/notification_group_type.rb @@ -0,0 +1,13 @@ +module TD::Types + # Describes type of notifications in the group. + class NotificationGroupType < Base + %w[ + messages + mentions + secret_chat + calls + ].each do |type| + autoload TD::Types.camelize(type), "tdlib/types/notification_group_type/#{type}" + end + end +end diff --git a/lib/tdlib/types/notification_group_type/calls.rb b/lib/tdlib/types/notification_group_type/calls.rb new file mode 100644 index 0000000..4c782d7 --- /dev/null +++ b/lib/tdlib/types/notification_group_type/calls.rb @@ -0,0 +1,5 @@ +module TD::Types + # A group containing notifications of type notificationTypeNewCall. + class NotificationGroupType::Calls < NotificationGroupType + end +end diff --git a/lib/tdlib/types/notification_group_type/mentions.rb b/lib/tdlib/types/notification_group_type/mentions.rb new file mode 100644 index 0000000..a34a542 --- /dev/null +++ b/lib/tdlib/types/notification_group_type/mentions.rb @@ -0,0 +1,6 @@ +module TD::Types + # A group containing notifications of type notificationTypeNewMessage and notificationTypeNewPushMessage with unread + # mentions of the current user, replies to their messages, or a pinned message. + class NotificationGroupType::Mentions < NotificationGroupType + end +end diff --git a/lib/tdlib/types/notification_group_type/messages.rb b/lib/tdlib/types/notification_group_type/messages.rb new file mode 100644 index 0000000..ead2605 --- /dev/null +++ b/lib/tdlib/types/notification_group_type/messages.rb @@ -0,0 +1,6 @@ +module TD::Types + # A group containing notifications of type notificationTypeNewMessage and notificationTypeNewPushMessage with + # ordinary unread messages. + class NotificationGroupType::Messages < NotificationGroupType + end +end diff --git a/lib/tdlib/types/notification_group_type/secret_chat.rb b/lib/tdlib/types/notification_group_type/secret_chat.rb new file mode 100644 index 0000000..c41abbe --- /dev/null +++ b/lib/tdlib/types/notification_group_type/secret_chat.rb @@ -0,0 +1,5 @@ +module TD::Types + # A group containing a notification of type notificationTypeNewSecretChat. + class NotificationGroupType::SecretChat < NotificationGroupType + end +end diff --git a/lib/tdlib/types/notification_settings_scope.rb b/lib/tdlib/types/notification_settings_scope.rb index 9d30800..6b0f98e 100644 --- a/lib/tdlib/types/notification_settings_scope.rb +++ b/lib/tdlib/types/notification_settings_scope.rb @@ -4,6 +4,7 @@ class NotificationSettingsScope < Base %w[ private_chats group_chats + channel_chats ].each do |type| autoload TD::Types.camelize(type), "tdlib/types/notification_settings_scope/#{type}" end diff --git a/lib/tdlib/types/notification_settings_scope/channel_chats.rb b/lib/tdlib/types/notification_settings_scope/channel_chats.rb new file mode 100644 index 0000000..31ae655 --- /dev/null +++ b/lib/tdlib/types/notification_settings_scope/channel_chats.rb @@ -0,0 +1,5 @@ +module TD::Types + # Notification settings applied to all channels when the corresponding chat setting has a default value. + class NotificationSettingsScope::ChannelChats < NotificationSettingsScope + end +end diff --git a/lib/tdlib/types/notification_settings_scope/group_chats.rb b/lib/tdlib/types/notification_settings_scope/group_chats.rb index 83e83d5..c64f8cc 100644 --- a/lib/tdlib/types/notification_settings_scope/group_chats.rb +++ b/lib/tdlib/types/notification_settings_scope/group_chats.rb @@ -1,6 +1,6 @@ module TD::Types - # Notification settings applied to all basic groups, supergroups and channels when the corresponding chat setting has - # a default value. + # Notification settings applied to all basic groups and supergroups when the corresponding chat setting has a default + # value. class NotificationSettingsScope::GroupChats < NotificationSettingsScope end end diff --git a/lib/tdlib/types/notification_type.rb b/lib/tdlib/types/notification_type.rb new file mode 100644 index 0000000..4d6703d --- /dev/null +++ b/lib/tdlib/types/notification_type.rb @@ -0,0 +1,13 @@ +module TD::Types + # Contains detailed information about a notification. + class NotificationType < Base + %w[ + new_message + new_secret_chat + new_call + new_push_message + ].each do |type| + autoload TD::Types.camelize(type), "tdlib/types/notification_type/#{type}" + end + end +end diff --git a/lib/tdlib/types/notification_type/new_call.rb b/lib/tdlib/types/notification_type/new_call.rb new file mode 100644 index 0000000..b59400c --- /dev/null +++ b/lib/tdlib/types/notification_type/new_call.rb @@ -0,0 +1,8 @@ +module TD::Types + # New call was received. + # + # @attr call_id [Integer] Call identifier. + class NotificationType::NewCall < NotificationType + attribute :call_id, TD::Types::Integer + end +end diff --git a/lib/tdlib/types/notification_type/new_message.rb b/lib/tdlib/types/notification_type/new_message.rb new file mode 100644 index 0000000..849a52f --- /dev/null +++ b/lib/tdlib/types/notification_type/new_message.rb @@ -0,0 +1,8 @@ +module TD::Types + # New message was received. + # + # @attr message [TD::Types::Message] The message. + class NotificationType::NewMessage < NotificationType + attribute :message, TD::Types::Message + end +end diff --git a/lib/tdlib/types/notification_type/new_push_message.rb b/lib/tdlib/types/notification_type/new_push_message.rb new file mode 100644 index 0000000..f455fa3 --- /dev/null +++ b/lib/tdlib/types/notification_type/new_push_message.rb @@ -0,0 +1,15 @@ +module TD::Types + # New message was received through a push notification. + # + # @attr message_id [Integer] The message identifier. + # The message will not be available in the chat history, but the ID can be used in viewMessages and as + # reply_to_message_id. + # @attr sender_user_id [Integer] Sender of the message. + # Corresponding user may be inaccessible. + # @attr content [TD::Types::PushMessageContent] Push message content. + class NotificationType::NewPushMessage < NotificationType + attribute :message_id, TD::Types::Integer + attribute :sender_user_id, TD::Types::Integer + attribute :content, TD::Types::PushMessageContent + end +end diff --git a/lib/tdlib/types/notification_type/new_secret_chat.rb b/lib/tdlib/types/notification_type/new_secret_chat.rb new file mode 100644 index 0000000..26befb7 --- /dev/null +++ b/lib/tdlib/types/notification_type/new_secret_chat.rb @@ -0,0 +1,5 @@ +module TD::Types + # New secret chat was created. + class NotificationType::NewSecretChat < NotificationType + end +end diff --git a/lib/tdlib/types/option_value/boolean.rb b/lib/tdlib/types/option_value/boolean.rb index a926cad..fa8914c 100644 --- a/lib/tdlib/types/option_value/boolean.rb +++ b/lib/tdlib/types/option_value/boolean.rb @@ -1,5 +1,5 @@ module TD::Types - # Boolean option. + # Represents a boolean option. # # @attr value [Boolean] The value of the option. class OptionValue::Boolean < OptionValue diff --git a/lib/tdlib/types/option_value/empty.rb b/lib/tdlib/types/option_value/empty.rb index 2bcc6f7..06640e2 100644 --- a/lib/tdlib/types/option_value/empty.rb +++ b/lib/tdlib/types/option_value/empty.rb @@ -1,5 +1,5 @@ module TD::Types - # An unknown option or an option which has a default value. + # Represents an unknown option or an option which has a default value. class OptionValue::Empty < OptionValue end end diff --git a/lib/tdlib/types/option_value/integer.rb b/lib/tdlib/types/option_value/integer.rb index 1c24f16..03f6149 100644 --- a/lib/tdlib/types/option_value/integer.rb +++ b/lib/tdlib/types/option_value/integer.rb @@ -1,5 +1,5 @@ module TD::Types - # An integer option. + # Represents an integer option. # # @attr value [Integer] The value of the option. class OptionValue::Integer < OptionValue diff --git a/lib/tdlib/types/option_value/string.rb b/lib/tdlib/types/option_value/string.rb index f59118d..1f7c5c6 100644 --- a/lib/tdlib/types/option_value/string.rb +++ b/lib/tdlib/types/option_value/string.rb @@ -1,5 +1,5 @@ module TD::Types - # A string option. + # Represents a string option. # # @attr value [String] The value of the option. class OptionValue::String < OptionValue diff --git a/lib/tdlib/types/page_block.rb b/lib/tdlib/types/page_block.rb index ff096cb..9176632 100644 --- a/lib/tdlib/types/page_block.rb +++ b/lib/tdlib/types/page_block.rb @@ -7,6 +7,7 @@ class PageBlock < Base author_date header subheader + kicker paragraph preformatted footer @@ -25,6 +26,10 @@ class PageBlock < Base collage slideshow chat_link + table + details + related_articles + map ].each do |type| autoload TD::Types.camelize(type), "tdlib/types/page_block/#{type}" end diff --git a/lib/tdlib/types/page_block/animation.rb b/lib/tdlib/types/page_block/animation.rb index 6242a06..ed0b0b2 100644 --- a/lib/tdlib/types/page_block/animation.rb +++ b/lib/tdlib/types/page_block/animation.rb @@ -2,11 +2,11 @@ module TD::Types # An animation. # # @attr animation [TD::Types::Animation, nil] Animation file; may be null. - # @attr caption [TD::Types::RichText] Animation caption. + # @attr caption [TD::Types::PageBlockCaption] Animation caption. # @attr need_autoplay [Boolean] True, if the animation should be played automatically. class PageBlock::Animation < PageBlock attribute :animation, TD::Types::Animation.optional.default(nil) - attribute :caption, TD::Types::RichText + attribute :caption, TD::Types::PageBlockCaption attribute :need_autoplay, TD::Types::Bool end end diff --git a/lib/tdlib/types/page_block/audio.rb b/lib/tdlib/types/page_block/audio.rb index f93b7a1..184805b 100644 --- a/lib/tdlib/types/page_block/audio.rb +++ b/lib/tdlib/types/page_block/audio.rb @@ -2,9 +2,9 @@ module TD::Types # An audio file. # # @attr audio [TD::Types::Audio, nil] Audio file; may be null. - # @attr caption [TD::Types::RichText] Audio file caption. + # @attr caption [TD::Types::PageBlockCaption] Audio file caption. class PageBlock::Audio < PageBlock attribute :audio, TD::Types::Audio.optional.default(nil) - attribute :caption, TD::Types::RichText + attribute :caption, TD::Types::PageBlockCaption end end diff --git a/lib/tdlib/types/page_block/block_quote.rb b/lib/tdlib/types/page_block/block_quote.rb index 9797014..f675fe4 100644 --- a/lib/tdlib/types/page_block/block_quote.rb +++ b/lib/tdlib/types/page_block/block_quote.rb @@ -2,9 +2,9 @@ module TD::Types # A block quote. # # @attr text [TD::Types::RichText] Quote text. - # @attr caption [TD::Types::RichText] Quote caption. + # @attr credit [TD::Types::RichText] Quote credit. class PageBlock::BlockQuote < PageBlock attribute :text, TD::Types::RichText - attribute :caption, TD::Types::RichText + attribute :credit, TD::Types::RichText end end diff --git a/lib/tdlib/types/page_block/collage.rb b/lib/tdlib/types/page_block/collage.rb index d3f18b6..6fd9e3f 100644 --- a/lib/tdlib/types/page_block/collage.rb +++ b/lib/tdlib/types/page_block/collage.rb @@ -2,9 +2,9 @@ module TD::Types # A collage. # # @attr page_blocks [Array] Collage item contents. - # @attr caption [TD::Types::RichText] Block caption. + # @attr caption [TD::Types::PageBlockCaption] Block caption. class PageBlock::Collage < PageBlock attribute :page_blocks, TD::Types::Array.of(TD::Types::PageBlock) - attribute :caption, TD::Types::RichText + attribute :caption, TD::Types::PageBlockCaption end end diff --git a/lib/tdlib/types/page_block/details.rb b/lib/tdlib/types/page_block/details.rb new file mode 100644 index 0000000..69d4501 --- /dev/null +++ b/lib/tdlib/types/page_block/details.rb @@ -0,0 +1,12 @@ +module TD::Types + # A collapsible block. + # + # @attr header [TD::Types::RichText] Always visible heading for the block. + # @attr page_blocks [Array] Block contents. + # @attr is_open [Boolean] True, if the block is open by default. + class PageBlock::Details < PageBlock + attribute :header, TD::Types::RichText + attribute :page_blocks, TD::Types::Array.of(TD::Types::PageBlock) + attribute :is_open, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/page_block/embedded.rb b/lib/tdlib/types/page_block/embedded.rb index 313bfa9..17ccd4a 100644 --- a/lib/tdlib/types/page_block/embedded.rb +++ b/lib/tdlib/types/page_block/embedded.rb @@ -4,9 +4,9 @@ module TD::Types # @attr url [String, nil] Web page URL, if available. # @attr html [String] HTML-markup of the embedded page. # @attr poster_photo [TD::Types::Photo, nil] Poster photo, if available; may be null. - # @attr width [Integer] Block width. - # @attr height [Integer] Block height. - # @attr caption [TD::Types::RichText] Block caption. + # @attr width [Integer] Block width; 0 if unknown. + # @attr height [Integer] Block height; 0 if unknown. + # @attr caption [TD::Types::PageBlockCaption] Block caption. # @attr is_full_width [Boolean] True, if the block should be full width. # @attr allow_scrolling [Boolean] True, if scrolling should be allowed. class PageBlock::Embedded < PageBlock @@ -15,7 +15,7 @@ class PageBlock::Embedded < PageBlock attribute :poster_photo, TD::Types::Photo.optional.default(nil) attribute :width, TD::Types::Integer attribute :height, TD::Types::Integer - attribute :caption, TD::Types::RichText + attribute :caption, TD::Types::PageBlockCaption attribute :is_full_width, TD::Types::Bool attribute :allow_scrolling, TD::Types::Bool end diff --git a/lib/tdlib/types/page_block/embedded_post.rb b/lib/tdlib/types/page_block/embedded_post.rb index e512bde..b7eeaab 100644 --- a/lib/tdlib/types/page_block/embedded_post.rb +++ b/lib/tdlib/types/page_block/embedded_post.rb @@ -3,16 +3,16 @@ module TD::Types # # @attr url [String] Web page URL. # @attr author [String] Post author. - # @attr author_photo [TD::Types::Photo] Post author photo. + # @attr author_photo [TD::Types::Photo, nil] Post author photo; may be null. # @attr date [Integer] Point in time (Unix timestamp) when the post was created; 0 if unknown. # @attr page_blocks [Array] Post content. - # @attr caption [TD::Types::RichText] Post caption. + # @attr caption [TD::Types::PageBlockCaption] Post caption. class PageBlock::EmbeddedPost < PageBlock attribute :url, TD::Types::String attribute :author, TD::Types::String - attribute :author_photo, TD::Types::Photo + attribute :author_photo, TD::Types::Photo.optional.default(nil) attribute :date, TD::Types::Integer attribute :page_blocks, TD::Types::Array.of(TD::Types::PageBlock) - attribute :caption, TD::Types::RichText + attribute :caption, TD::Types::PageBlockCaption end end diff --git a/lib/tdlib/types/page_block/kicker.rb b/lib/tdlib/types/page_block/kicker.rb new file mode 100644 index 0000000..c743875 --- /dev/null +++ b/lib/tdlib/types/page_block/kicker.rb @@ -0,0 +1,8 @@ +module TD::Types + # A kicker. + # + # @attr kicker [TD::Types::RichText] Kicker. + class PageBlock::Kicker < PageBlock + attribute :kicker, TD::Types::RichText + end +end diff --git a/lib/tdlib/types/page_block/list.rb b/lib/tdlib/types/page_block/list.rb index 54b062f..0fa67a0 100644 --- a/lib/tdlib/types/page_block/list.rb +++ b/lib/tdlib/types/page_block/list.rb @@ -1,10 +1,8 @@ module TD::Types - # A list of texts. + # A list of data blocks. # - # @attr items [Array] Texts. - # @attr is_ordered [Boolean] True, if the items should be marked with numbers. + # @attr items [Array] The items of the list. class PageBlock::List < PageBlock - attribute :items, TD::Types::Array.of(TD::Types::RichText) - attribute :is_ordered, TD::Types::Bool + attribute :items, TD::Types::Array.of(TD::Types::PageBlockListItem) end end diff --git a/lib/tdlib/types/page_block/map.rb b/lib/tdlib/types/page_block/map.rb new file mode 100644 index 0000000..1fa72f8 --- /dev/null +++ b/lib/tdlib/types/page_block/map.rb @@ -0,0 +1,16 @@ +module TD::Types + # A map. + # + # @attr location [TD::Types::Location] Location of the map center. + # @attr zoom [Integer] Map zoom level. + # @attr width [Integer] Map width. + # @attr height [Integer] Map height. + # @attr caption [TD::Types::PageBlockCaption] Block caption. + class PageBlock::Map < PageBlock + attribute :location, TD::Types::Location + attribute :zoom, TD::Types::Integer + attribute :width, TD::Types::Integer + attribute :height, TD::Types::Integer + attribute :caption, TD::Types::PageBlockCaption + end +end diff --git a/lib/tdlib/types/page_block/photo.rb b/lib/tdlib/types/page_block/photo.rb index 084cc46..a3cf21b 100644 --- a/lib/tdlib/types/page_block/photo.rb +++ b/lib/tdlib/types/page_block/photo.rb @@ -2,9 +2,11 @@ module TD::Types # A photo. # # @attr photo [TD::Types::Photo, nil] Photo file; may be null. - # @attr caption [TD::Types::RichText] Photo caption. + # @attr caption [TD::Types::PageBlockCaption] Photo caption. + # @attr url [String] URL that needs to be opened when the photo is clicked. class PageBlock::Photo < PageBlock attribute :photo, TD::Types::Photo.optional.default(nil) - attribute :caption, TD::Types::RichText + attribute :caption, TD::Types::PageBlockCaption + attribute :url, TD::Types::String end end diff --git a/lib/tdlib/types/page_block/pull_quote.rb b/lib/tdlib/types/page_block/pull_quote.rb index 928ed6d..83cc236 100644 --- a/lib/tdlib/types/page_block/pull_quote.rb +++ b/lib/tdlib/types/page_block/pull_quote.rb @@ -2,9 +2,9 @@ module TD::Types # A pull quote. # # @attr text [TD::Types::RichText] Quote text. - # @attr caption [TD::Types::RichText] Quote caption. + # @attr credit [TD::Types::RichText] Quote credit. class PageBlock::PullQuote < PageBlock attribute :text, TD::Types::RichText - attribute :caption, TD::Types::RichText + attribute :credit, TD::Types::RichText end end diff --git a/lib/tdlib/types/page_block/related_articles.rb b/lib/tdlib/types/page_block/related_articles.rb new file mode 100644 index 0000000..d5cbe3f --- /dev/null +++ b/lib/tdlib/types/page_block/related_articles.rb @@ -0,0 +1,10 @@ +module TD::Types + # Related articles. + # + # @attr header [TD::Types::RichText] Block header. + # @attr articles [Array] List of related articles. + class PageBlock::RelatedArticles < PageBlock + attribute :header, TD::Types::RichText + attribute :articles, TD::Types::Array.of(TD::Types::PageBlockRelatedArticle) + end +end diff --git a/lib/tdlib/types/page_block/slideshow.rb b/lib/tdlib/types/page_block/slideshow.rb index 82396e4..e59cc21 100644 --- a/lib/tdlib/types/page_block/slideshow.rb +++ b/lib/tdlib/types/page_block/slideshow.rb @@ -2,9 +2,9 @@ module TD::Types # A slideshow. # # @attr page_blocks [Array] Slideshow item contents. - # @attr caption [TD::Types::RichText] Block caption. + # @attr caption [TD::Types::PageBlockCaption] Block caption. class PageBlock::Slideshow < PageBlock attribute :page_blocks, TD::Types::Array.of(TD::Types::PageBlock) - attribute :caption, TD::Types::RichText + attribute :caption, TD::Types::PageBlockCaption end end diff --git a/lib/tdlib/types/page_block/table.rb b/lib/tdlib/types/page_block/table.rb new file mode 100644 index 0000000..8c5e1df --- /dev/null +++ b/lib/tdlib/types/page_block/table.rb @@ -0,0 +1,14 @@ +module TD::Types + # A table. + # + # @attr caption [TD::Types::RichText] Table caption. + # @attr cells [Array>] Table cells. + # @attr is_bordered [Boolean] True, if the table is bordered. + # @attr is_striped [Boolean] True, if the table is striped. + class PageBlock::Table < PageBlock + attribute :caption, TD::Types::RichText + attribute :cells, TD::Types::Array.of(TD::Types::Array.of(TD::Types::PageBlockTableCell)) + attribute :is_bordered, TD::Types::Bool + attribute :is_striped, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/page_block/video.rb b/lib/tdlib/types/page_block/video.rb index c4f6420..a0f2613 100644 --- a/lib/tdlib/types/page_block/video.rb +++ b/lib/tdlib/types/page_block/video.rb @@ -2,12 +2,12 @@ module TD::Types # A video. # # @attr video [TD::Types::Video, nil] Video file; may be null. - # @attr caption [TD::Types::RichText] Video caption. + # @attr caption [TD::Types::PageBlockCaption] Video caption. # @attr need_autoplay [Boolean] True, if the video should be played automatically. # @attr is_looped [Boolean] True, if the video should be looped. class PageBlock::Video < PageBlock attribute :video, TD::Types::Video.optional.default(nil) - attribute :caption, TD::Types::RichText + attribute :caption, TD::Types::PageBlockCaption attribute :need_autoplay, TD::Types::Bool attribute :is_looped, TD::Types::Bool end diff --git a/lib/tdlib/types/page_block_caption.rb b/lib/tdlib/types/page_block_caption.rb new file mode 100644 index 0000000..f7e1252 --- /dev/null +++ b/lib/tdlib/types/page_block_caption.rb @@ -0,0 +1,10 @@ +module TD::Types + # Contains a caption of an instant view web page block, consisting of a text and a trailing credit. + # + # @attr text [TD::Types::RichText] Content of the caption. + # @attr credit [TD::Types::RichText] Block credit (like HTML tag ). + class PageBlockCaption < Base + attribute :text, TD::Types::RichText + attribute :credit, TD::Types::RichText + end +end diff --git a/lib/tdlib/types/page_block_horizontal_alignment.rb b/lib/tdlib/types/page_block_horizontal_alignment.rb new file mode 100644 index 0000000..ef4269c --- /dev/null +++ b/lib/tdlib/types/page_block_horizontal_alignment.rb @@ -0,0 +1,12 @@ +module TD::Types + # Describes a horizontal alignment of a table cell content. + class PageBlockHorizontalAlignment < Base + %w[ + left + center + right + ].each do |type| + autoload TD::Types.camelize(type), "tdlib/types/page_block_horizontal_alignment/#{type}" + end + end +end diff --git a/lib/tdlib/types/page_block_horizontal_alignment/center.rb b/lib/tdlib/types/page_block_horizontal_alignment/center.rb new file mode 100644 index 0000000..46daf4e --- /dev/null +++ b/lib/tdlib/types/page_block_horizontal_alignment/center.rb @@ -0,0 +1,5 @@ +module TD::Types + # The content should be center-aligned. + class PageBlockHorizontalAlignment::Center < PageBlockHorizontalAlignment + end +end diff --git a/lib/tdlib/types/page_block_horizontal_alignment/left.rb b/lib/tdlib/types/page_block_horizontal_alignment/left.rb new file mode 100644 index 0000000..6d51f05 --- /dev/null +++ b/lib/tdlib/types/page_block_horizontal_alignment/left.rb @@ -0,0 +1,5 @@ +module TD::Types + # The content should be left-aligned. + class PageBlockHorizontalAlignment::Left < PageBlockHorizontalAlignment + end +end diff --git a/lib/tdlib/types/page_block_horizontal_alignment/right.rb b/lib/tdlib/types/page_block_horizontal_alignment/right.rb new file mode 100644 index 0000000..542bc55 --- /dev/null +++ b/lib/tdlib/types/page_block_horizontal_alignment/right.rb @@ -0,0 +1,5 @@ +module TD::Types + # The content should be right-aligned. + class PageBlockHorizontalAlignment::Right < PageBlockHorizontalAlignment + end +end diff --git a/lib/tdlib/types/page_block_list_item.rb b/lib/tdlib/types/page_block_list_item.rb new file mode 100644 index 0000000..4196402 --- /dev/null +++ b/lib/tdlib/types/page_block_list_item.rb @@ -0,0 +1,10 @@ +module TD::Types + # Describes an item of a list page block. + # + # @attr label [String] Item label. + # @attr page_blocks [Array] Item blocks. + class PageBlockListItem < Base + attribute :label, TD::Types::String + attribute :page_blocks, TD::Types::Array.of(TD::Types::PageBlock) + end +end diff --git a/lib/tdlib/types/page_block_related_article.rb b/lib/tdlib/types/page_block_related_article.rb new file mode 100644 index 0000000..4e33eeb --- /dev/null +++ b/lib/tdlib/types/page_block_related_article.rb @@ -0,0 +1,18 @@ +module TD::Types + # Contains information about a related article. + # + # @attr url [String] Related article URL. + # @attr title [String, nil] Article title; may be empty. + # @attr description [String, nil] Article description; may be empty. + # @attr photo [TD::Types::Photo, nil] Article photo; may be null. + # @attr author [String, nil] Article author; may be empty. + # @attr publish_date [Integer] Point in time (Unix timestamp) when the article was published; 0 if unknown. + class PageBlockRelatedArticle < Base + attribute :url, TD::Types::String + attribute :title, TD::Types::String.optional.default(nil) + attribute :description, TD::Types::String.optional.default(nil) + attribute :photo, TD::Types::Photo.optional.default(nil) + attribute :author, TD::Types::String.optional.default(nil) + attribute :publish_date, TD::Types::Integer + end +end diff --git a/lib/tdlib/types/page_block_table_cell.rb b/lib/tdlib/types/page_block_table_cell.rb new file mode 100644 index 0000000..9b22b4f --- /dev/null +++ b/lib/tdlib/types/page_block_table_cell.rb @@ -0,0 +1,18 @@ +module TD::Types + # Represents a cell of a table. + # + # @attr text [TD::Types::RichText] Cell text. + # @attr is_header [Boolean] True, if it is a header cell. + # @attr colspan [Integer] The number of columns the cell should span. + # @attr rowspan [Integer] The number of rows the cell should span. + # @attr align [TD::Types::PageBlockHorizontalAlignment] Horizontal cell content alignment. + # @attr valign [TD::Types::PageBlockVerticalAlignment] Vertical cell content alignment. + class PageBlockTableCell < Base + attribute :text, TD::Types::RichText + attribute :is_header, TD::Types::Bool + attribute :colspan, TD::Types::Integer + attribute :rowspan, TD::Types::Integer + attribute :align, TD::Types::PageBlockHorizontalAlignment + attribute :valign, TD::Types::PageBlockVerticalAlignment + end +end diff --git a/lib/tdlib/types/page_block_vertical_alignment.rb b/lib/tdlib/types/page_block_vertical_alignment.rb new file mode 100644 index 0000000..db196dc --- /dev/null +++ b/lib/tdlib/types/page_block_vertical_alignment.rb @@ -0,0 +1,12 @@ +module TD::Types + # Describes a Vertical alignment of a table cell content. + class PageBlockVerticalAlignment < Base + %w[ + top + middle + bottom + ].each do |type| + autoload TD::Types.camelize(type), "tdlib/types/page_block_vertical_alignment/#{type}" + end + end +end diff --git a/lib/tdlib/types/page_block_vertical_alignment/bottom.rb b/lib/tdlib/types/page_block_vertical_alignment/bottom.rb new file mode 100644 index 0000000..6a0b695 --- /dev/null +++ b/lib/tdlib/types/page_block_vertical_alignment/bottom.rb @@ -0,0 +1,5 @@ +module TD::Types + # The content should be bottom-aligned. + class PageBlockVerticalAlignment::Bottom < PageBlockVerticalAlignment + end +end diff --git a/lib/tdlib/types/page_block_vertical_alignment/middle.rb b/lib/tdlib/types/page_block_vertical_alignment/middle.rb new file mode 100644 index 0000000..13b9a5d --- /dev/null +++ b/lib/tdlib/types/page_block_vertical_alignment/middle.rb @@ -0,0 +1,5 @@ +module TD::Types + # The content should be middle-aligned. + class PageBlockVerticalAlignment::Middle < PageBlockVerticalAlignment + end +end diff --git a/lib/tdlib/types/page_block_vertical_alignment/top.rb b/lib/tdlib/types/page_block_vertical_alignment/top.rb new file mode 100644 index 0000000..5a662b7 --- /dev/null +++ b/lib/tdlib/types/page_block_vertical_alignment/top.rb @@ -0,0 +1,5 @@ +module TD::Types + # The content should be top-aligned. + class PageBlockVerticalAlignment::Top < PageBlockVerticalAlignment + end +end diff --git a/lib/tdlib/types/passport_authorization_form.rb b/lib/tdlib/types/passport_authorization_form.rb index c326dad..b016b2b 100644 --- a/lib/tdlib/types/passport_authorization_form.rb +++ b/lib/tdlib/types/passport_authorization_form.rb @@ -4,14 +4,10 @@ module TD::Types # @attr id [Integer] Unique identifier of the authorization form. # @attr required_elements [Array] Information about the Telegram Passport # elements that need to be provided to complete the form. - # @attr elements [Array] Already available Telegram Passport elements. - # @attr errors [Array] Errors in the elements that are already available. - # @attr privacy_policy_url [String, nil] URL for the privacy policy of the service; can be empty. + # @attr privacy_policy_url [String, nil] URL for the privacy policy of the service; may be empty. class PassportAuthorizationForm < Base attribute :id, TD::Types::Integer attribute :required_elements, TD::Types::Array.of(TD::Types::PassportRequiredElement) - attribute :elements, TD::Types::Array.of(TD::Types::PassportElement) - attribute :errors, TD::Types::Array.of(TD::Types::PassportElementError) attribute :privacy_policy_url, TD::Types::String.optional.default(nil) end end diff --git a/lib/tdlib/types/passport_element_error_source/file.rb b/lib/tdlib/types/passport_element_error_source/file.rb index 49399b2..0c1c164 100644 --- a/lib/tdlib/types/passport_element_error_source/file.rb +++ b/lib/tdlib/types/passport_element_error_source/file.rb @@ -1,6 +1,9 @@ module TD::Types # The file contains an error. # The error will be considered resolved when the file changes. + # + # @attr file_index [Integer] Index of a file with the error. class PassportElementErrorSource::File < PassportElementErrorSource + attribute :file_index, TD::Types::Integer end end diff --git a/lib/tdlib/types/passport_element_error_source/translation_file.rb b/lib/tdlib/types/passport_element_error_source/translation_file.rb index 120e038..dba8e8a 100644 --- a/lib/tdlib/types/passport_element_error_source/translation_file.rb +++ b/lib/tdlib/types/passport_element_error_source/translation_file.rb @@ -1,6 +1,9 @@ module TD::Types # One of files with the translation of the document contains an error. # The error will be considered resolved when the file changes. + # + # @attr file_index [Integer] Index of a file with the error. class PassportElementErrorSource::TranslationFile < PassportElementErrorSource + attribute :file_index, TD::Types::Integer end end diff --git a/lib/tdlib/types/passport_elements_with_errors.rb b/lib/tdlib/types/passport_elements_with_errors.rb new file mode 100644 index 0000000..a6ee284 --- /dev/null +++ b/lib/tdlib/types/passport_elements_with_errors.rb @@ -0,0 +1,10 @@ +module TD::Types + # Contains information about a Telegram Passport elements and corresponding errors. + # + # @attr elements [Array] Telegram Passport elements. + # @attr errors [Array] Errors in the elements that are already available. + class PassportElementsWithErrors < Base + attribute :elements, TD::Types::Array.of(TD::Types::PassportElement) + attribute :errors, TD::Types::Array.of(TD::Types::PassportElementError) + end +end diff --git a/lib/tdlib/types/password_state.rb b/lib/tdlib/types/password_state.rb index 92c2d9a..6b5d300 100644 --- a/lib/tdlib/types/password_state.rb +++ b/lib/tdlib/types/password_state.rb @@ -1,17 +1,17 @@ module TD::Types # Represents the current state of 2-step verification. # - # @attr has_password [Boolean] True if a 2-step verification password is set. - # @attr password_hint [String, nil] Hint for the password; can be empty. - # @attr has_recovery_email_address [Boolean] True if a recovery email is set. - # @attr has_passport_data [Boolean] True if some Telegram Passport elements were saved. - # @attr unconfirmed_recovery_email_address_pattern [String] Pattern of the email address to which the confirmation - # email was sent. + # @attr has_password [Boolean] True, if a 2-step verification password is set. + # @attr password_hint [String, nil] Hint for the password; may be empty. + # @attr has_recovery_email_address [Boolean] True, if a recovery email is set. + # @attr has_passport_data [Boolean] True, if some Telegram Passport elements were saved. + # @attr recovery_email_address_code_info [TD::Types::EmailAddressAuthenticationCodeInfo, nil] Information about the + # recovery email address to which the confirmation email was sent; may be null. class PasswordState < Base attribute :has_password, TD::Types::Bool attribute :password_hint, TD::Types::String.optional.default(nil) attribute :has_recovery_email_address, TD::Types::Bool attribute :has_passport_data, TD::Types::Bool - attribute :unconfirmed_recovery_email_address_pattern, TD::Types::String + attribute :recovery_email_address_code_info, TD::Types::EmailAddressAuthenticationCodeInfo.optional.default(nil) end end diff --git a/lib/tdlib/types/phone_number_authentication_settings.rb b/lib/tdlib/types/phone_number_authentication_settings.rb new file mode 100644 index 0000000..19dd369 --- /dev/null +++ b/lib/tdlib/types/phone_number_authentication_settings.rb @@ -0,0 +1,16 @@ +module TD::Types + # Contains settings for the authentication of the user's phone number. + # + # @attr allow_flash_call [Boolean] Pass true if the authentication code may be sent via flash call to the specified + # phone number. + # @attr is_current_phone_number [Boolean] Pass true if the authenticated phone number is used on the current device. + # @attr allow_sms_retriever_api [Boolean] For official applications only. + # True, if the app can use Android SMS Retriever API (requires Google Play Services >= 10.2) to automatically + # receive the authentication code from the SMS. + # See https://developers.google.com/identity/sms-retriever/ for more details. + class PhoneNumberAuthenticationSettings < Base + attribute :allow_flash_call, TD::Types::Bool + attribute :is_current_phone_number, TD::Types::Bool + attribute :allow_sms_retriever_api, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/photo.rb b/lib/tdlib/types/photo.rb index 02f447d..9677758 100644 --- a/lib/tdlib/types/photo.rb +++ b/lib/tdlib/types/photo.rb @@ -1,12 +1,12 @@ module TD::Types # Describes a photo. # - # @attr id [Integer] Photo identifier; 0 for deleted photos. # @attr has_stickers [Boolean] True, if stickers were added to the photo. + # @attr minithumbnail [TD::Types::Minithumbnail, nil] Photo minithumbnail; may be null. # @attr sizes [Array] Available variants of the photo, in different sizes. class Photo < Base - attribute :id, TD::Types::Integer attribute :has_stickers, TD::Types::Bool + attribute :minithumbnail, TD::Types::Minithumbnail.optional.default(nil) attribute :sizes, TD::Types::Array.of(TD::Types::PhotoSize) end end diff --git a/lib/tdlib/types/poll.rb b/lib/tdlib/types/poll.rb new file mode 100644 index 0000000..ba8efd2 --- /dev/null +++ b/lib/tdlib/types/poll.rb @@ -0,0 +1,16 @@ +module TD::Types + # Describes a poll. + # + # @attr id [Integer] Unique poll identifier. + # @attr question [String] Poll question, 1-255 characters. + # @attr options [Array] List of poll answer options. + # @attr total_voter_count [Integer] Total number of voters, participating in the poll. + # @attr is_closed [Boolean] True, if the poll is closed. + class Poll < Base + attribute :id, TD::Types::Integer + attribute :question, TD::Types::String + attribute :options, TD::Types::Array.of(TD::Types::PollOption) + attribute :total_voter_count, TD::Types::Integer + attribute :is_closed, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/poll_option.rb b/lib/tdlib/types/poll_option.rb new file mode 100644 index 0000000..b540755 --- /dev/null +++ b/lib/tdlib/types/poll_option.rb @@ -0,0 +1,16 @@ +module TD::Types + # Describes one answer option of a poll. + # + # @attr text [String] Option text, 1-100 characters. + # @attr voter_count [Integer] Number of voters for this option, available only for closed or voted polls. + # @attr vote_percentage [Integer] The percentage of votes for this option, 0-100. + # @attr is_chosen [Boolean] True, if the option was chosen by the user. + # @attr is_being_chosen [Boolean] True, if the option is being chosen by a pending setPollAnswer request. + class PollOption < Base + attribute :text, TD::Types::String + attribute :voter_count, TD::Types::Integer + attribute :vote_percentage, TD::Types::Integer + attribute :is_chosen, TD::Types::Bool + attribute :is_being_chosen, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/profile_photo.rb b/lib/tdlib/types/profile_photo.rb index 34abfe6..ecec464 100644 --- a/lib/tdlib/types/profile_photo.rb +++ b/lib/tdlib/types/profile_photo.rb @@ -4,7 +4,9 @@ module TD::Types # @attr id [Integer] Photo identifier; 0 for an empty photo. # Can be used to find a photo in a list of userProfilePhotos. # @attr small [TD::Types::File] A small (160x160) user profile photo. + # The file can be downloaded only before the photo is changed. # @attr big [TD::Types::File] A big (640x640) user profile photo. + # The file can be downloaded only before the photo is changed. class ProfilePhoto < Base attribute :id, TD::Types::Integer attribute :small, TD::Types::File diff --git a/lib/tdlib/types/public_message_link.rb b/lib/tdlib/types/public_message_link.rb index 93d3011..f23f082 100644 --- a/lib/tdlib/types/public_message_link.rb +++ b/lib/tdlib/types/public_message_link.rb @@ -1,5 +1,5 @@ module TD::Types - # Contains a public HTTPS link to a message in a public supergroup or channel. + # Contains a public HTTPS link to a message in a public supergroup or channel with a username. # # @attr link [String] Message link. # @attr html [String] HTML-code for embedding the message. diff --git a/lib/tdlib/types/push_message_content.rb b/lib/tdlib/types/push_message_content.rb new file mode 100644 index 0000000..d2e5dd2 --- /dev/null +++ b/lib/tdlib/types/push_message_content.rb @@ -0,0 +1,35 @@ +module TD::Types + # Contains content of a push message notification. + class PushMessageContent < Base + %w[ + hidden + animation + audio + contact + contact_registered + document + game + game_score + invoice + location + photo + poll + screenshot_taken + sticker + text + video + video_note + voice_note + basic_group_chat_create + chat_add_members + chat_change_photo + chat_change_title + chat_delete_member + chat_join_by_link + message_forwards + media_album + ].each do |type| + autoload TD::Types.camelize(type), "tdlib/types/push_message_content/#{type}" + end + end +end diff --git a/lib/tdlib/types/push_message_content/animation.rb b/lib/tdlib/types/push_message_content/animation.rb new file mode 100644 index 0000000..7ab426f --- /dev/null +++ b/lib/tdlib/types/push_message_content/animation.rb @@ -0,0 +1,12 @@ +module TD::Types + # An animation message (GIF-style).. + # + # @attr animation [TD::Types::Animation, nil] Message content; may be null. + # @attr caption [String] Animation caption. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::Animation < PushMessageContent + attribute :animation, TD::Types::Animation.optional.default(nil) + attribute :caption, TD::Types::String + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/audio.rb b/lib/tdlib/types/push_message_content/audio.rb new file mode 100644 index 0000000..bbbd98d --- /dev/null +++ b/lib/tdlib/types/push_message_content/audio.rb @@ -0,0 +1,10 @@ +module TD::Types + # An audio message. + # + # @attr audio [TD::Types::Audio, nil] Message content; may be null. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::Audio < PushMessageContent + attribute :audio, TD::Types::Audio.optional.default(nil) + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/basic_group_chat_create.rb b/lib/tdlib/types/push_message_content/basic_group_chat_create.rb new file mode 100644 index 0000000..02a1816 --- /dev/null +++ b/lib/tdlib/types/push_message_content/basic_group_chat_create.rb @@ -0,0 +1,5 @@ +module TD::Types + # A newly created basic group. + class PushMessageContent::BasicGroupChatCreate < PushMessageContent + end +end diff --git a/lib/tdlib/types/push_message_content/chat_add_members.rb b/lib/tdlib/types/push_message_content/chat_add_members.rb new file mode 100644 index 0000000..612d512 --- /dev/null +++ b/lib/tdlib/types/push_message_content/chat_add_members.rb @@ -0,0 +1,12 @@ +module TD::Types + # New chat members were invited to a group. + # + # @attr member_name [String] Name of the added member. + # @attr is_current_user [Boolean] True, if the current user was added to the group. + # @attr is_returned [Boolean] True, if the user has returned to the group himself. + class PushMessageContent::ChatAddMembers < PushMessageContent + attribute :member_name, TD::Types::String + attribute :is_current_user, TD::Types::Bool + attribute :is_returned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/chat_change_photo.rb b/lib/tdlib/types/push_message_content/chat_change_photo.rb new file mode 100644 index 0000000..ebdcc3b --- /dev/null +++ b/lib/tdlib/types/push_message_content/chat_change_photo.rb @@ -0,0 +1,5 @@ +module TD::Types + # A chat photo was edited. + class PushMessageContent::ChatChangePhoto < PushMessageContent + end +end diff --git a/lib/tdlib/types/push_message_content/chat_change_title.rb b/lib/tdlib/types/push_message_content/chat_change_title.rb new file mode 100644 index 0000000..0c35c51 --- /dev/null +++ b/lib/tdlib/types/push_message_content/chat_change_title.rb @@ -0,0 +1,8 @@ +module TD::Types + # A chat title was edited. + # + # @attr title [String] New chat title. + class PushMessageContent::ChatChangeTitle < PushMessageContent + attribute :title, TD::Types::String + end +end diff --git a/lib/tdlib/types/push_message_content/chat_delete_member.rb b/lib/tdlib/types/push_message_content/chat_delete_member.rb new file mode 100644 index 0000000..a974d33 --- /dev/null +++ b/lib/tdlib/types/push_message_content/chat_delete_member.rb @@ -0,0 +1,12 @@ +module TD::Types + # A chat member was deleted. + # + # @attr member_name [String] Name of the deleted member. + # @attr is_current_user [Boolean] True, if the current user was deleted from the group. + # @attr is_left [Boolean] True, if the user has left the group himself. + class PushMessageContent::ChatDeleteMember < PushMessageContent + attribute :member_name, TD::Types::String + attribute :is_current_user, TD::Types::Bool + attribute :is_left, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/chat_join_by_link.rb b/lib/tdlib/types/push_message_content/chat_join_by_link.rb new file mode 100644 index 0000000..97a3c62 --- /dev/null +++ b/lib/tdlib/types/push_message_content/chat_join_by_link.rb @@ -0,0 +1,5 @@ +module TD::Types + # A new member joined the chat by invite link. + class PushMessageContent::ChatJoinByLink < PushMessageContent + end +end diff --git a/lib/tdlib/types/push_message_content/contact.rb b/lib/tdlib/types/push_message_content/contact.rb new file mode 100644 index 0000000..fde76fd --- /dev/null +++ b/lib/tdlib/types/push_message_content/contact.rb @@ -0,0 +1,10 @@ +module TD::Types + # A message with a user contact. + # + # @attr name [String] Contact's name. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::Contact < PushMessageContent + attribute :name, TD::Types::String + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/contact_registered.rb b/lib/tdlib/types/push_message_content/contact_registered.rb new file mode 100644 index 0000000..536e24e --- /dev/null +++ b/lib/tdlib/types/push_message_content/contact_registered.rb @@ -0,0 +1,5 @@ +module TD::Types + # A contact has registered with Telegram. + class PushMessageContent::ContactRegistered < PushMessageContent + end +end diff --git a/lib/tdlib/types/push_message_content/document.rb b/lib/tdlib/types/push_message_content/document.rb new file mode 100644 index 0000000..05e694c --- /dev/null +++ b/lib/tdlib/types/push_message_content/document.rb @@ -0,0 +1,10 @@ +module TD::Types + # A document message (a general file). + # + # @attr document [TD::Types::Document, nil] Message content; may be null. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::Document < PushMessageContent + attribute :document, TD::Types::Document.optional.default(nil) + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/game.rb b/lib/tdlib/types/push_message_content/game.rb new file mode 100644 index 0000000..5bb8a41 --- /dev/null +++ b/lib/tdlib/types/push_message_content/game.rb @@ -0,0 +1,10 @@ +module TD::Types + # A message with a game. + # + # @attr title [String, nil] Game title, empty for pinned game message. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::Game < PushMessageContent + attribute :title, TD::Types::String.optional.default(nil) + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/game_score.rb b/lib/tdlib/types/push_message_content/game_score.rb new file mode 100644 index 0000000..0333c6f --- /dev/null +++ b/lib/tdlib/types/push_message_content/game_score.rb @@ -0,0 +1,12 @@ +module TD::Types + # A new high score was achieved in a game. + # + # @attr title [String, nil] Game title, empty for pinned message. + # @attr score [Integer] New score, 0 for pinned message. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::GameScore < PushMessageContent + attribute :title, TD::Types::String.optional.default(nil) + attribute :score, TD::Types::Integer + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/hidden.rb b/lib/tdlib/types/push_message_content/hidden.rb new file mode 100644 index 0000000..aaec8da --- /dev/null +++ b/lib/tdlib/types/push_message_content/hidden.rb @@ -0,0 +1,8 @@ +module TD::Types + # A general message with hidden content. + # + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::Hidden < PushMessageContent + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/invoice.rb b/lib/tdlib/types/push_message_content/invoice.rb new file mode 100644 index 0000000..90d6858 --- /dev/null +++ b/lib/tdlib/types/push_message_content/invoice.rb @@ -0,0 +1,10 @@ +module TD::Types + # A message with an invoice from a bot. + # + # @attr price [String] Product price. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::Invoice < PushMessageContent + attribute :price, TD::Types::String + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/location.rb b/lib/tdlib/types/push_message_content/location.rb new file mode 100644 index 0000000..d5513ec --- /dev/null +++ b/lib/tdlib/types/push_message_content/location.rb @@ -0,0 +1,10 @@ +module TD::Types + # A message with a location. + # + # @attr is_live [Boolean] True, if the location is live. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::Location < PushMessageContent + attribute :is_live, TD::Types::Bool + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/media_album.rb b/lib/tdlib/types/push_message_content/media_album.rb new file mode 100644 index 0000000..73b131e --- /dev/null +++ b/lib/tdlib/types/push_message_content/media_album.rb @@ -0,0 +1,12 @@ +module TD::Types + # A media album. + # + # @attr total_count [Integer] Number of messages in the album. + # @attr has_photos [Boolean] True, if the album has at least one photo. + # @attr has_videos [Boolean] True, if the album has at least one video. + class PushMessageContent::MediaAlbum < PushMessageContent + attribute :total_count, TD::Types::Integer + attribute :has_photos, TD::Types::Bool + attribute :has_videos, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/message_forwards.rb b/lib/tdlib/types/push_message_content/message_forwards.rb new file mode 100644 index 0000000..a636377 --- /dev/null +++ b/lib/tdlib/types/push_message_content/message_forwards.rb @@ -0,0 +1,8 @@ +module TD::Types + # A forwarded messages. + # + # @attr total_count [Integer] Number of forwarded messages. + class PushMessageContent::MessageForwards < PushMessageContent + attribute :total_count, TD::Types::Integer + end +end diff --git a/lib/tdlib/types/push_message_content/photo.rb b/lib/tdlib/types/push_message_content/photo.rb new file mode 100644 index 0000000..6ebc287 --- /dev/null +++ b/lib/tdlib/types/push_message_content/photo.rb @@ -0,0 +1,14 @@ +module TD::Types + # A photo message. + # + # @attr photo [TD::Types::Photo, nil] Message content; may be null. + # @attr caption [String] Photo caption. + # @attr is_secret [Boolean] True, if the photo is secret. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::Photo < PushMessageContent + attribute :photo, TD::Types::Photo.optional.default(nil) + attribute :caption, TD::Types::String + attribute :is_secret, TD::Types::Bool + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/poll.rb b/lib/tdlib/types/push_message_content/poll.rb new file mode 100644 index 0000000..22eb5c9 --- /dev/null +++ b/lib/tdlib/types/push_message_content/poll.rb @@ -0,0 +1,10 @@ +module TD::Types + # A message with a poll. + # + # @attr question [String] Poll question. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::Poll < PushMessageContent + attribute :question, TD::Types::String + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/screenshot_taken.rb b/lib/tdlib/types/push_message_content/screenshot_taken.rb new file mode 100644 index 0000000..c88732a --- /dev/null +++ b/lib/tdlib/types/push_message_content/screenshot_taken.rb @@ -0,0 +1,5 @@ +module TD::Types + # A screenshot of a message in the chat has been taken. + class PushMessageContent::ScreenshotTaken < PushMessageContent + end +end diff --git a/lib/tdlib/types/push_message_content/sticker.rb b/lib/tdlib/types/push_message_content/sticker.rb new file mode 100644 index 0000000..14f173e --- /dev/null +++ b/lib/tdlib/types/push_message_content/sticker.rb @@ -0,0 +1,12 @@ +module TD::Types + # A message with a sticker. + # + # @attr sticker [TD::Types::Sticker, nil] Message content; may be null. + # @attr emoji [String, nil] Emoji corresponding to the sticker; may be empty. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::Sticker < PushMessageContent + attribute :sticker, TD::Types::Sticker.optional.default(nil) + attribute :emoji, TD::Types::String.optional.default(nil) + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/text.rb b/lib/tdlib/types/push_message_content/text.rb new file mode 100644 index 0000000..81ea2f6 --- /dev/null +++ b/lib/tdlib/types/push_message_content/text.rb @@ -0,0 +1,10 @@ +module TD::Types + # A text message. + # + # @attr text [String] Message text. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::Text < PushMessageContent + attribute :text, TD::Types::String + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/video.rb b/lib/tdlib/types/push_message_content/video.rb new file mode 100644 index 0000000..484c412 --- /dev/null +++ b/lib/tdlib/types/push_message_content/video.rb @@ -0,0 +1,14 @@ +module TD::Types + # A video message. + # + # @attr video [TD::Types::Video, nil] Message content; may be null. + # @attr caption [String] Video caption. + # @attr is_secret [Boolean] True, if the video is secret. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::Video < PushMessageContent + attribute :video, TD::Types::Video.optional.default(nil) + attribute :caption, TD::Types::String + attribute :is_secret, TD::Types::Bool + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/video_note.rb b/lib/tdlib/types/push_message_content/video_note.rb new file mode 100644 index 0000000..5c0f47a --- /dev/null +++ b/lib/tdlib/types/push_message_content/video_note.rb @@ -0,0 +1,10 @@ +module TD::Types + # A video note message. + # + # @attr video_note [TD::Types::VideoNote, nil] Message content; may be null. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::VideoNote < PushMessageContent + attribute :video_note, TD::Types::VideoNote.optional.default(nil) + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_message_content/voice_note.rb b/lib/tdlib/types/push_message_content/voice_note.rb new file mode 100644 index 0000000..f409787 --- /dev/null +++ b/lib/tdlib/types/push_message_content/voice_note.rb @@ -0,0 +1,10 @@ +module TD::Types + # A voice note message. + # + # @attr voice_note [TD::Types::VoiceNote, nil] Message content; may be null. + # @attr is_pinned [Boolean] True, if the message is a pinned message with the specified content. + class PushMessageContent::VoiceNote < PushMessageContent + attribute :voice_note, TD::Types::VoiceNote.optional.default(nil) + attribute :is_pinned, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/push_receiver_id.rb b/lib/tdlib/types/push_receiver_id.rb new file mode 100644 index 0000000..da6ace5 --- /dev/null +++ b/lib/tdlib/types/push_receiver_id.rb @@ -0,0 +1,9 @@ +module TD::Types + # Contains a globally unique push receiver identifier, which can be used to identify which account has received a + # push notification. + # + # @attr id [Integer] The globally unique identifier of push notification subscription. + class PushReceiverId < Base + attribute :id, TD::Types::Integer + end +end diff --git a/lib/tdlib/types/rich_text.rb b/lib/tdlib/types/rich_text.rb index 4c8b131..e37afe7 100644 --- a/lib/tdlib/types/rich_text.rb +++ b/lib/tdlib/types/rich_text.rb @@ -10,6 +10,12 @@ class RichText < Base fixed url email_address + subscript + superscript + marked + phone_number + icon + anchor s ].each do |type| autoload TD::Types.camelize(type), "tdlib/types/rich_text/#{type}" diff --git a/lib/tdlib/types/rich_text/anchor.rb b/lib/tdlib/types/rich_text/anchor.rb new file mode 100644 index 0000000..8bb6da5 --- /dev/null +++ b/lib/tdlib/types/rich_text/anchor.rb @@ -0,0 +1,10 @@ +module TD::Types + # A rich text anchor. + # + # @attr text [TD::Types::RichText] Text. + # @attr name [String] Anchor name. + class RichText::Anchor < RichText + attribute :text, TD::Types::RichText + attribute :name, TD::Types::String + end +end diff --git a/lib/tdlib/types/rich_text/icon.rb b/lib/tdlib/types/rich_text/icon.rb new file mode 100644 index 0000000..a6e8562 --- /dev/null +++ b/lib/tdlib/types/rich_text/icon.rb @@ -0,0 +1,13 @@ +module TD::Types + # A small image inside the text. + # + # @attr document [TD::Types::Document] The image represented as a document. + # The image can be in GIF, JPEG or PNG format. + # @attr width [Integer] Width of a bounding box in which the image should be shown; 0 if unknown. + # @attr height [Integer] Height of a bounding box in which the image should be shown; 0 if unknown. + class RichText::Icon < RichText + attribute :document, TD::Types::Document + attribute :width, TD::Types::Integer + attribute :height, TD::Types::Integer + end +end diff --git a/lib/tdlib/types/rich_text/marked.rb b/lib/tdlib/types/rich_text/marked.rb new file mode 100644 index 0000000..97e5077 --- /dev/null +++ b/lib/tdlib/types/rich_text/marked.rb @@ -0,0 +1,8 @@ +module TD::Types + # A marked rich text. + # + # @attr text [TD::Types::RichText] Text. + class RichText::Marked < RichText + attribute :text, TD::Types::RichText + end +end diff --git a/lib/tdlib/types/rich_text/phone_number.rb b/lib/tdlib/types/rich_text/phone_number.rb new file mode 100644 index 0000000..174446a --- /dev/null +++ b/lib/tdlib/types/rich_text/phone_number.rb @@ -0,0 +1,10 @@ +module TD::Types + # A rich text phone number. + # + # @attr text [TD::Types::RichText] Text. + # @attr phone_number [String] Phone number. + class RichText::PhoneNumber < RichText + attribute :text, TD::Types::RichText + attribute :phone_number, TD::Types::String + end +end diff --git a/lib/tdlib/types/rich_text/subscript.rb b/lib/tdlib/types/rich_text/subscript.rb new file mode 100644 index 0000000..60d2923 --- /dev/null +++ b/lib/tdlib/types/rich_text/subscript.rb @@ -0,0 +1,8 @@ +module TD::Types + # A subscript rich text. + # + # @attr text [TD::Types::RichText] Text. + class RichText::Subscript < RichText + attribute :text, TD::Types::RichText + end +end diff --git a/lib/tdlib/types/rich_text/superscript.rb b/lib/tdlib/types/rich_text/superscript.rb new file mode 100644 index 0000000..0ad55f0 --- /dev/null +++ b/lib/tdlib/types/rich_text/superscript.rb @@ -0,0 +1,8 @@ +module TD::Types + # A superscript rich text. + # + # @attr text [TD::Types::RichText] Text. + class RichText::Superscript < RichText + attribute :text, TD::Types::RichText + end +end diff --git a/lib/tdlib/types/scope_notification_settings.rb b/lib/tdlib/types/scope_notification_settings.rb index 6348546..dfbe910 100644 --- a/lib/tdlib/types/scope_notification_settings.rb +++ b/lib/tdlib/types/scope_notification_settings.rb @@ -5,9 +5,15 @@ module TD::Types # @attr sound [String] The name of an audio file to be used for notification sounds; only applies to iOS # applications. # @attr show_preview [Boolean] True, if message content should be displayed in notifications. + # @attr disable_pinned_message_notifications [Boolean] True, if notifications for incoming pinned messages will be + # created as for an ordinary unread message. + # @attr disable_mention_notifications [Boolean] True, if notifications for messages with mentions will be created as + # for an ordinary unread message. class ScopeNotificationSettings < Base attribute :mute_for, TD::Types::Integer attribute :sound, TD::Types::String attribute :show_preview, TD::Types::Bool + attribute :disable_pinned_message_notifications, TD::Types::Bool + attribute :disable_mention_notifications, TD::Types::Bool end end diff --git a/lib/tdlib/types/search_messages_filter/unread_mention.rb b/lib/tdlib/types/search_messages_filter/unread_mention.rb index d792398..85384c4 100644 --- a/lib/tdlib/types/search_messages_filter/unread_mention.rb +++ b/lib/tdlib/types/search_messages_filter/unread_mention.rb @@ -1,5 +1,5 @@ module TD::Types - # Returns only messages with unread mentions of the current user or messages that are replies to their messages. + # Returns only messages with unread mentions of the current user, or messages that are replies to their messages. # When using this filter the results can't be additionally filtered by a query or by the sending user. class SearchMessagesFilter::UnreadMention < SearchMessagesFilter end diff --git a/lib/tdlib/types/session.rb b/lib/tdlib/types/session.rb index caf52fd..bf5ea6a 100644 --- a/lib/tdlib/types/session.rb +++ b/lib/tdlib/types/session.rb @@ -1,8 +1,10 @@ module TD::Types # Contains information about one session in a Telegram application used by the current user. + # Sessions should be shown to the user in the returned order. # # @attr id [Integer] Session identifier. # @attr is_current [Boolean] True, if this session is the current session. + # @attr is_password_pending [Boolean] True, if a password is needed to complete authorization of the session. # @attr api_id [Integer] Telegram API identifier, as provided by the application. # @attr application_name [String] Name of the application, as provided by the application. # @attr application_version [String] The version of the application, as provided by the application. @@ -23,6 +25,7 @@ module TD::Types class Session < Base attribute :id, TD::Types::Integer attribute :is_current, TD::Types::Bool + attribute :is_password_pending, TD::Types::Bool attribute :api_id, TD::Types::Integer attribute :application_name, TD::Types::String attribute :application_version, TD::Types::String diff --git a/lib/tdlib/types/sticker.rb b/lib/tdlib/types/sticker.rb index 2fa75f5..d74482a 100644 --- a/lib/tdlib/types/sticker.rb +++ b/lib/tdlib/types/sticker.rb @@ -5,6 +5,7 @@ module TD::Types # @attr width [Integer] Sticker width; as defined by the sender. # @attr height [Integer] Sticker height; as defined by the sender. # @attr emoji [String] Emoji corresponding to the sticker. + # @attr is_animated [Boolean] True, if the sticker is an animated sticker in TGS format. # @attr is_mask [Boolean] True, if the sticker is a mask. # @attr mask_position [TD::Types::MaskPosition, nil] Position where the mask should be placed; may be null. # @attr thumbnail [TD::Types::PhotoSize, nil] Sticker thumbnail in WEBP or JPEG format; may be null. @@ -14,6 +15,7 @@ class Sticker < Base attribute :width, TD::Types::Integer attribute :height, TD::Types::Integer attribute :emoji, TD::Types::String + attribute :is_animated, TD::Types::Bool attribute :is_mask, TD::Types::Bool attribute :mask_position, TD::Types::MaskPosition.optional.default(nil) attribute :thumbnail, TD::Types::PhotoSize.optional.default(nil) diff --git a/lib/tdlib/types/sticker_emojis.rb b/lib/tdlib/types/sticker_emojis.rb deleted file mode 100644 index 83b731d..0000000 --- a/lib/tdlib/types/sticker_emojis.rb +++ /dev/null @@ -1,10 +0,0 @@ -module TD::Types - # Represents a list of all emoji corresponding to a sticker in a sticker set. - # The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the - # corresponding Sticker object. - # - # @attr emojis [Array] List of emojis. - class StickerEmojis < Base - attribute :emojis, TD::Types::Array.of(TD::Types::String) - end -end diff --git a/lib/tdlib/types/sticker_set.rb b/lib/tdlib/types/sticker_set.rb index bfa9c59..9a1ce15 100644 --- a/lib/tdlib/types/sticker_set.rb +++ b/lib/tdlib/types/sticker_set.rb @@ -4,24 +4,32 @@ module TD::Types # @attr id [Integer] Identifier of the sticker set. # @attr title [String] Title of the sticker set. # @attr name [String] Name of the sticker set. + # @attr thumbnail [TD::Types::PhotoSize, nil] Sticker set thumbnail in WEBP format with width and height 100; may be + # null. + # The file can be downloaded only before the thumbnail is changed. # @attr is_installed [Boolean] True, if the sticker set has been installed by the current user. # @attr is_archived [Boolean] True, if the sticker set has been archived. # A sticker set can't be installed and archived simultaneously. # @attr is_official [Boolean] True, if the sticker set is official. + # @attr is_animated [Boolean] True, is the stickers in the set are animated. # @attr is_masks [Boolean] True, if the stickers in the set are masks. # @attr is_viewed [Boolean] True for already viewed trending sticker sets. # @attr stickers [Array] List of stickers in this set. - # @attr emojis [Array] A list of emoji corresponding to the stickers in the same order. + # @attr emojis [Array] A list of emoji corresponding to the stickers in the same order. + # The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the + # corresponding Sticker object. class StickerSet < Base attribute :id, TD::Types::Integer attribute :title, TD::Types::String attribute :name, TD::Types::String + attribute :thumbnail, TD::Types::PhotoSize.optional.default(nil) attribute :is_installed, TD::Types::Bool attribute :is_archived, TD::Types::Bool attribute :is_official, TD::Types::Bool + attribute :is_animated, TD::Types::Bool attribute :is_masks, TD::Types::Bool attribute :is_viewed, TD::Types::Bool attribute :stickers, TD::Types::Array.of(TD::Types::Sticker) - attribute :emojis, TD::Types::Array.of(TD::Types::StickerEmojis) + attribute :emojis, TD::Types::Array.of(TD::Types::Emojis) end end diff --git a/lib/tdlib/types/sticker_set_info.rb b/lib/tdlib/types/sticker_set_info.rb index 30b8dd4..f7af561 100644 --- a/lib/tdlib/types/sticker_set_info.rb +++ b/lib/tdlib/types/sticker_set_info.rb @@ -4,10 +4,13 @@ module TD::Types # @attr id [Integer] Identifier of the sticker set. # @attr title [String] Title of the sticker set. # @attr name [String] Name of the sticker set. + # @attr thumbnail [TD::Types::PhotoSize, nil] Sticker set thumbnail in WEBP format with width and height 100; may be + # null. # @attr is_installed [Boolean] True, if the sticker set has been installed by current user. # @attr is_archived [Boolean] True, if the sticker set has been archived. # A sticker set can't be installed and archived simultaneously. # @attr is_official [Boolean] True, if the sticker set is official. + # @attr is_animated [Boolean] True, is the stickers in the set are animated. # @attr is_masks [Boolean] True, if the stickers in the set are masks. # @attr is_viewed [Boolean] True for already viewed trending sticker sets. # @attr size [Integer] Total number of stickers in the set. @@ -18,9 +21,11 @@ class StickerSetInfo < Base attribute :id, TD::Types::Integer attribute :title, TD::Types::String attribute :name, TD::Types::String + attribute :thumbnail, TD::Types::PhotoSize.optional.default(nil) attribute :is_installed, TD::Types::Bool attribute :is_archived, TD::Types::Bool attribute :is_official, TD::Types::Bool + attribute :is_animated, TD::Types::Bool attribute :is_masks, TD::Types::Bool attribute :is_viewed, TD::Types::Bool attribute :size, TD::Types::Integer diff --git a/lib/tdlib/types/storage_statistics_fast.rb b/lib/tdlib/types/storage_statistics_fast.rb index 302fbf4..f1b0a05 100644 --- a/lib/tdlib/types/storage_statistics_fast.rb +++ b/lib/tdlib/types/storage_statistics_fast.rb @@ -4,9 +4,13 @@ module TD::Types # @attr files_size [Integer] Approximate total size of files. # @attr file_count [Integer] Approximate number of files. # @attr database_size [Integer] Size of the database. + # @attr language_pack_database_size [Integer] Size of the language pack database. + # @attr log_size [Integer] Size of the TDLib internal log. class StorageStatisticsFast < Base attribute :files_size, TD::Types::Integer attribute :file_count, TD::Types::Integer attribute :database_size, TD::Types::Integer + attribute :language_pack_database_size, TD::Types::Integer + attribute :log_size, TD::Types::Integer end end diff --git a/lib/tdlib/types/supergroup.rb b/lib/tdlib/types/supergroup.rb index 5c739c4..7e03e38 100644 --- a/lib/tdlib/types/supergroup.rb +++ b/lib/tdlib/types/supergroup.rb @@ -12,8 +12,6 @@ module TD::Types # @attr status [TD::Types::ChatMemberStatus] Status of the current user in the supergroup or channel. # @attr member_count [Integer] Member count; 0 if unknown. # Currently it is guaranteed to be known only if the supergroup or channel was found through SearchPublicChats. - # @attr anyone_can_invite [Boolean] True, if any member of the supergroup can invite other members. - # This field has no meaning for channels. # @attr sign_messages [Boolean] True, if messages sent to the channel should contain information about the sender. # This field is only applicable to channels. # @attr is_channel [Boolean] True, if the supergroup is a channel. @@ -25,16 +23,17 @@ module TD::Types # "-wp", which describe the platforms on which access should be restricted. # (For example, "terms-ios-android". # {description} contains a human-readable description of the restriction, which can be shown to the user). + # @attr is_scam [Boolean] True, if many users reported this supergroup as a scam. class Supergroup < Base attribute :id, TD::Types::Integer attribute :username, TD::Types::String.optional.default(nil) attribute :date, TD::Types::Integer attribute :status, TD::Types::ChatMemberStatus attribute :member_count, TD::Types::Integer - attribute :anyone_can_invite, TD::Types::Bool attribute :sign_messages, TD::Types::Bool attribute :is_channel, TD::Types::Bool attribute :is_verified, TD::Types::Bool attribute :restriction_reason, TD::Types::String + attribute :is_scam, TD::Types::Bool end end diff --git a/lib/tdlib/types/supergroup_full_info.rb b/lib/tdlib/types/supergroup_full_info.rb index 004a7a3..5a437bc 100644 --- a/lib/tdlib/types/supergroup_full_info.rb +++ b/lib/tdlib/types/supergroup_full_info.rb @@ -9,13 +9,13 @@ module TD::Types # @attr can_get_members [Boolean] True, if members of the chat can be retrieved. # @attr can_set_username [Boolean] True, if the chat can be made public. # @attr can_set_sticker_set [Boolean] True, if the supergroup sticker set can be changed. + # @attr can_view_statistics [Boolean] True, if the channel statistics is available through getChatStatisticsUrl. # @attr is_all_history_available [Boolean] True, if new chat members will have access to old messages. # In public supergroups and both public and private channels, old messages are always available, so this option # affects only private supergroups. # The value of this field is only available for chat administrators. # @attr sticker_set_id [Integer] Identifier of the supergroup sticker set; 0 if none. # @attr invite_link [String] Invite link for this chat. - # @attr pinned_message_id [Integer] Identifier of the pinned message in the chat; 0 if none. # @attr upgraded_from_basic_group_id [Integer] Identifier of the basic group from which supergroup was upgraded; 0 if # none. # @attr upgraded_from_max_message_id [Integer] Identifier of the last message in the basic group from which @@ -29,10 +29,10 @@ class SupergroupFullInfo < Base attribute :can_get_members, TD::Types::Bool attribute :can_set_username, TD::Types::Bool attribute :can_set_sticker_set, TD::Types::Bool + attribute :can_view_statistics, TD::Types::Bool attribute :is_all_history_available, TD::Types::Bool attribute :sticker_set_id, TD::Types::Integer attribute :invite_link, TD::Types::String - attribute :pinned_message_id, TD::Types::Integer attribute :upgraded_from_basic_group_id, TD::Types::Integer attribute :upgraded_from_max_message_id, TD::Types::Integer end diff --git a/lib/tdlib/types/supergroup_members_filter.rb b/lib/tdlib/types/supergroup_members_filter.rb index 64a2c01..a43365c 100644 --- a/lib/tdlib/types/supergroup_members_filter.rb +++ b/lib/tdlib/types/supergroup_members_filter.rb @@ -3,6 +3,7 @@ module TD::Types class SupergroupMembersFilter < Base %w[ recent + contacts administrators search restricted diff --git a/lib/tdlib/types/supergroup_members_filter/contacts.rb b/lib/tdlib/types/supergroup_members_filter/contacts.rb new file mode 100644 index 0000000..87770d8 --- /dev/null +++ b/lib/tdlib/types/supergroup_members_filter/contacts.rb @@ -0,0 +1,8 @@ +module TD::Types + # Returns contacts of the user, which are members of the supergroup or channel. + # + # @attr query [String] Query to search for. + class SupergroupMembersFilter::Contacts < SupergroupMembersFilter + attribute :query, TD::Types::String + end +end diff --git a/lib/tdlib/types/terms_of_service.rb b/lib/tdlib/types/terms_of_service.rb index bdfd532..ae79ac7 100644 --- a/lib/tdlib/types/terms_of_service.rb +++ b/lib/tdlib/types/terms_of_service.rb @@ -2,7 +2,7 @@ module TD::Types # Contains Telegram terms of service. # # @attr text [TD::Types::FormattedText] Text of the terms of service. - # @attr min_user_age [Integer] Mininum age of a user to be able to accept the terms; 0 if any. + # @attr min_user_age [Integer] Minimum age of a user to be able to accept the terms; 0 if any. # @attr show_popup [Boolean] True, if a blocking popup with terms of service must be shown to the user. class TermsOfService < Base attribute :text, TD::Types::FormattedText diff --git a/lib/tdlib/types/update.rb b/lib/tdlib/types/update.rb index 6e4cf19..5626229 100644 --- a/lib/tdlib/types/update.rb +++ b/lib/tdlib/types/update.rb @@ -15,6 +15,7 @@ class Update < Base new_chat chat_title chat_photo + chat_permissions chat_last_message chat_order chat_is_pinned @@ -26,8 +27,14 @@ class Update < Base chat_unread_mention_count chat_notification_settings scope_notification_settings + chat_pinned_message chat_reply_markup chat_draft_message + chat_online_member_count + notification + notification_group + active_notifications + have_pending_notifications delete_messages user_chat_action user_status @@ -52,6 +59,7 @@ class Update < Base recent_stickers favorite_stickers saved_animations + selected_background language_pack_strings connection_state terms_of_service @@ -63,6 +71,7 @@ class Update < Base new_pre_checkout_query new_custom_event new_custom_query + poll ].each do |type| autoload TD::Types.camelize(type), "tdlib/types/update/#{type}" end diff --git a/lib/tdlib/types/update/active_notifications.rb b/lib/tdlib/types/update/active_notifications.rb new file mode 100644 index 0000000..900a0a2 --- /dev/null +++ b/lib/tdlib/types/update/active_notifications.rb @@ -0,0 +1,10 @@ +module TD::Types + # Contains active notifications that was shown on previous application launches. + # This update is sent only if a message database is used. + # In that case it comes once before any updateNotification and updateNotificationGroup update. + # + # @attr groups [Array] Lists of active notification groups. + class Update::ActiveNotifications < Update + attribute :groups, TD::Types::Array.of(TD::Types::NotificationGroup) + end +end diff --git a/lib/tdlib/types/update/chat_online_member_count.rb b/lib/tdlib/types/update/chat_online_member_count.rb new file mode 100644 index 0000000..ece3069 --- /dev/null +++ b/lib/tdlib/types/update/chat_online_member_count.rb @@ -0,0 +1,12 @@ +module TD::Types + # The number of online group members has changed. + # This update with non-zero count is sent only for currently opened chats. + # There is no guarantee that it will be sent just after the count has changed. + # + # @attr chat_id [Integer] Identifier of the chat. + # @attr online_member_count [Integer] New number of online members in the chat, or 0 if unknown. + class Update::ChatOnlineMemberCount < Update + attribute :chat_id, TD::Types::Integer + attribute :online_member_count, TD::Types::Integer + end +end diff --git a/lib/tdlib/types/update/chat_order.rb b/lib/tdlib/types/update/chat_order.rb index e7480cb..ad8341d 100644 --- a/lib/tdlib/types/update/chat_order.rb +++ b/lib/tdlib/types/update/chat_order.rb @@ -1,5 +1,5 @@ module TD::Types - # The order of the chat in the chats list has changed. + # The order of the chat in the chat list has changed. # Instead of this update updateChatLastMessage, updateChatIsPinned or updateChatDraftMessage might be sent. # # @attr chat_id [Integer] Chat identifier. diff --git a/lib/tdlib/types/update/chat_permissions.rb b/lib/tdlib/types/update/chat_permissions.rb new file mode 100644 index 0000000..30d6e96 --- /dev/null +++ b/lib/tdlib/types/update/chat_permissions.rb @@ -0,0 +1,10 @@ +module TD::Types + # Chat permissions was changed. + # + # @attr chat_id [Integer] Chat identifier. + # @attr permissions [TD::Types::ChatPermissions] The new chat permissions. + class Update::ChatPermissions < Update + attribute :chat_id, TD::Types::Integer + attribute :permissions, TD::Types::ChatPermissions + end +end diff --git a/lib/tdlib/types/update/chat_pinned_message.rb b/lib/tdlib/types/update/chat_pinned_message.rb new file mode 100644 index 0000000..f7cf7c2 --- /dev/null +++ b/lib/tdlib/types/update/chat_pinned_message.rb @@ -0,0 +1,11 @@ +module TD::Types + # The chat pinned message was changed. + # + # @attr chat_id [Integer] Chat identifier. + # @attr pinned_message_id [Integer] The new identifier of the pinned message; 0 if there is no pinned message in the + # chat. + class Update::ChatPinnedMessage < Update + attribute :chat_id, TD::Types::Integer + attribute :pinned_message_id, TD::Types::Integer + end +end diff --git a/lib/tdlib/types/update/delete_messages.rb b/lib/tdlib/types/update/delete_messages.rb index 20579a4..9373337 100644 --- a/lib/tdlib/types/update/delete_messages.rb +++ b/lib/tdlib/types/update/delete_messages.rb @@ -4,7 +4,7 @@ module TD::Types # @attr chat_id [Integer] Chat identifier. # @attr message_ids [Array] Identifiers of the deleted messages. # @attr is_permanent [Boolean] True, if the messages are permanently deleted by a user (as opposed to just becoming - # unaccessible). + # inaccessible). # @attr from_cache [Boolean] True, if the messages are deleted only from the cache and can possibly be retrieved # again in the future. class Update::DeleteMessages < Update diff --git a/lib/tdlib/types/update/have_pending_notifications.rb b/lib/tdlib/types/update/have_pending_notifications.rb new file mode 100644 index 0000000..3fc1d29 --- /dev/null +++ b/lib/tdlib/types/update/have_pending_notifications.rb @@ -0,0 +1,13 @@ +module TD::Types + # Describes, whether there are some pending notification updates. + # Can be used to prevent application from killing, while there are some pending notifications. + # + # @attr have_delayed_notifications [Boolean] True, if there are some delayed notification updates, which will be sent + # soon. + # @attr have_unreceived_notifications [Boolean] True, if there can be some yet unreceived notifications, which are + # being fetched from the server. + class Update::HavePendingNotifications < Update + attribute :have_delayed_notifications, TD::Types::Bool + attribute :have_unreceived_notifications, TD::Types::Bool + end +end diff --git a/lib/tdlib/types/update/message_send_failed.rb b/lib/tdlib/types/update/message_send_failed.rb index 7c33901..5420125 100644 --- a/lib/tdlib/types/update/message_send_failed.rb +++ b/lib/tdlib/types/update/message_send_failed.rb @@ -3,7 +3,7 @@ module TD::Types # Be aware that some messages being sent can be irrecoverably deleted, in which case updateDeleteMessages will be # received instead of this update. # - # @attr message [TD::Types::Message] Contains information about the message that failed to send. + # @attr message [TD::Types::Message] Contains information about the message which failed to send. # @attr old_message_id [Integer] The previous temporary message identifier. # @attr error_code [Integer] An error code. # @attr error_message [String] Error message. diff --git a/lib/tdlib/types/update/new_message.rb b/lib/tdlib/types/update/new_message.rb index 3f1464e..4c54595 100644 --- a/lib/tdlib/types/update/new_message.rb +++ b/lib/tdlib/types/update/new_message.rb @@ -2,11 +2,7 @@ module TD::Types # A new message was received; can also be an outgoing message. # # @attr message [TD::Types::Message] The new message. - # @attr disable_notification [Boolean] True, if this message must not generate a notification. - # @attr contains_mention [Boolean] True, if the message contains a mention of the current user. class Update::NewMessage < Update attribute :message, TD::Types::Message - attribute :disable_notification, TD::Types::Bool - attribute :contains_mention, TD::Types::Bool end end diff --git a/lib/tdlib/types/update/notification.rb b/lib/tdlib/types/update/notification.rb new file mode 100644 index 0000000..da21698 --- /dev/null +++ b/lib/tdlib/types/update/notification.rb @@ -0,0 +1,10 @@ +module TD::Types + # A notification was changed. + # + # @attr notification_group_id [Integer] Unique notification group identifier. + # @attr notification [TD::Types::Notification] Changed notification. + class Update::Notification < Update + attribute :notification_group_id, TD::Types::Integer + attribute :notification, TD::Types::Notification + end +end diff --git a/lib/tdlib/types/update/notification_group.rb b/lib/tdlib/types/update/notification_group.rb new file mode 100644 index 0000000..cca5284 --- /dev/null +++ b/lib/tdlib/types/update/notification_group.rb @@ -0,0 +1,26 @@ +module TD::Types + # A list of active notifications in a notification group has changed. + # + # @attr notification_group_id [Integer] Unique notification group identifier. + # @attr type [TD::Types::NotificationGroupType] New type of the notification group. + # @attr chat_id [Integer] Identifier of a chat to which all notifications in the group belong. + # @attr notification_settings_chat_id [Integer] Chat identifier, which notification settings must be applied to the + # added notifications. + # @attr is_silent [Boolean] True, if the notifications should be shown without sound. + # @attr total_count [Integer] Total number of unread notifications in the group, can be bigger than number of active + # notifications. + # @attr added_notifications [Array] List of added group notifications, sorted by + # notification ID. + # @attr removed_notification_ids [Array] Identifiers of removed group notifications, sorted by notification + # ID. + class Update::NotificationGroup < Update + attribute :notification_group_id, TD::Types::Integer + attribute :type, TD::Types::NotificationGroupType + attribute :chat_id, TD::Types::Integer + attribute :notification_settings_chat_id, TD::Types::Integer + attribute :is_silent, TD::Types::Bool + attribute :total_count, TD::Types::Integer + attribute :added_notifications, TD::Types::Array.of(TD::Types::Notification) + attribute :removed_notification_ids, TD::Types::Array.of(TD::Types::Integer) + end +end diff --git a/lib/tdlib/types/update/poll.rb b/lib/tdlib/types/update/poll.rb new file mode 100644 index 0000000..f7203a2 --- /dev/null +++ b/lib/tdlib/types/update/poll.rb @@ -0,0 +1,8 @@ +module TD::Types + # Information about a poll was updated; for bots only. + # + # @attr poll [TD::Types::Poll] New data about the poll. + class Update::Poll < Update + attribute :poll, TD::Types::Poll + end +end diff --git a/lib/tdlib/types/update/selected_background.rb b/lib/tdlib/types/update/selected_background.rb new file mode 100644 index 0000000..bff27d4 --- /dev/null +++ b/lib/tdlib/types/update/selected_background.rb @@ -0,0 +1,10 @@ +module TD::Types + # The selected background has changed. + # + # @attr for_dark_theme [Boolean] True, if background for dark theme has changed. + # @attr background [TD::Types::Background, nil] The new selected background; may be null. + class Update::SelectedBackground < Update + attribute :for_dark_theme, TD::Types::Bool + attribute :background, TD::Types::Background.optional.default(nil) + end +end diff --git a/lib/tdlib/types/updates.rb b/lib/tdlib/types/updates.rb new file mode 100644 index 0000000..2107b2f --- /dev/null +++ b/lib/tdlib/types/updates.rb @@ -0,0 +1,8 @@ +module TD::Types + # Contains a list of updates. + # + # @attr updates [Array] List of updates. + class Updates < Base + attribute :updates, TD::Types::Array.of(TD::Types::Update) + end +end diff --git a/lib/tdlib/types/user.rb b/lib/tdlib/types/user.rb index 23e89db..4a10d25 100644 --- a/lib/tdlib/types/user.rb +++ b/lib/tdlib/types/user.rb @@ -11,12 +11,14 @@ module TD::Types # @attr outgoing_link [TD::Types::LinkState] Relationship from the current user to the other user. # @attr incoming_link [TD::Types::LinkState] Relationship from the other user to the current user. # @attr is_verified [Boolean] True, if the user is verified. + # @attr is_support [Boolean] True, if the user is Telegram support account. # @attr restriction_reason [String] If non-empty, it contains the reason why access to this user must be restricted. # The format of the string is "{type}: {description}". # {type} contains the type of the restriction and at least one of the suffixes "-all", "-ios", "-android", or # "-wp", which describe the platforms on which access should be restricted. # (For example, "terms-ios-android". # {description} contains a human-readable description of the restriction, which can be shown to the user). + # @attr is_scam [Boolean] True, if many users reported this user as a scam. # @attr have_access [Boolean] If false, the user is inaccessible, and the only information known about the user is # inside this class. # It can't be passed to any method except GetUser. @@ -33,7 +35,9 @@ class User < Base attribute :outgoing_link, TD::Types::LinkState attribute :incoming_link, TD::Types::LinkState attribute :is_verified, TD::Types::Bool + attribute :is_support, TD::Types::Bool attribute :restriction_reason, TD::Types::String + attribute :is_scam, TD::Types::Bool attribute :have_access, TD::Types::Bool attribute :type, TD::Types::UserType attribute :language_code, TD::Types::String diff --git a/lib/tdlib/types/user_privacy_setting.rb b/lib/tdlib/types/user_privacy_setting.rb index 623272b..e96630e 100644 --- a/lib/tdlib/types/user_privacy_setting.rb +++ b/lib/tdlib/types/user_privacy_setting.rb @@ -3,8 +3,11 @@ module TD::Types class UserPrivacySetting < Base %w[ show_status + show_profile_photo + show_link_in_forwarded_messages allow_chat_invites allow_calls + allow_peer_to_peer_calls ].each do |type| autoload TD::Types.camelize(type), "tdlib/types/user_privacy_setting/#{type}" end diff --git a/lib/tdlib/types/user_privacy_setting/allow_peer_to_peer_calls.rb b/lib/tdlib/types/user_privacy_setting/allow_peer_to_peer_calls.rb new file mode 100644 index 0000000..45d924e --- /dev/null +++ b/lib/tdlib/types/user_privacy_setting/allow_peer_to_peer_calls.rb @@ -0,0 +1,5 @@ +module TD::Types + # A privacy setting for managing whether peer-to-peer connections can be used for calls. + class UserPrivacySetting::AllowPeerToPeerCalls < UserPrivacySetting + end +end diff --git a/lib/tdlib/types/user_privacy_setting/show_link_in_forwarded_messages.rb b/lib/tdlib/types/user_privacy_setting/show_link_in_forwarded_messages.rb new file mode 100644 index 0000000..e096801 --- /dev/null +++ b/lib/tdlib/types/user_privacy_setting/show_link_in_forwarded_messages.rb @@ -0,0 +1,5 @@ +module TD::Types + # A privacy setting for managing whether a link to the user's account is included in forwarded messages. + class UserPrivacySetting::ShowLinkInForwardedMessages < UserPrivacySetting + end +end diff --git a/lib/tdlib/types/user_privacy_setting/show_profile_photo.rb b/lib/tdlib/types/user_privacy_setting/show_profile_photo.rb new file mode 100644 index 0000000..d562db2 --- /dev/null +++ b/lib/tdlib/types/user_privacy_setting/show_profile_photo.rb @@ -0,0 +1,5 @@ +module TD::Types + # A privacy setting for managing whether the user's profile photo is visible. + class UserPrivacySetting::ShowProfilePhoto < UserPrivacySetting + end +end diff --git a/lib/tdlib/types/user_profile_photo.rb b/lib/tdlib/types/user_profile_photo.rb new file mode 100644 index 0000000..15c1fb5 --- /dev/null +++ b/lib/tdlib/types/user_profile_photo.rb @@ -0,0 +1,12 @@ +module TD::Types + # Contains full information about a user profile photo. + # + # @attr id [Integer] Unique user profile photo identifier. + # @attr added_date [Integer] Point in time (Unix timestamp) when the photo has been added. + # @attr sizes [Array] Available variants of the user photo, in different sizes. + class UserProfilePhoto < Base + attribute :id, TD::Types::Integer + attribute :added_date, TD::Types::Integer + attribute :sizes, TD::Types::Array.of(TD::Types::PhotoSize) + end +end diff --git a/lib/tdlib/types/user_profile_photos.rb b/lib/tdlib/types/user_profile_photos.rb index 9fab4e9..b3a8bed 100644 --- a/lib/tdlib/types/user_profile_photos.rb +++ b/lib/tdlib/types/user_profile_photos.rb @@ -2,9 +2,9 @@ module TD::Types # Contains part of the list of user photos. # # @attr total_count [Integer] Total number of user profile photos. - # @attr photos [Array] A list of photos. + # @attr photos [Array] A list of photos. class UserProfilePhotos < Base attribute :total_count, TD::Types::Integer - attribute :photos, TD::Types::Array.of(TD::Types::Photo) + attribute :photos, TD::Types::Array.of(TD::Types::UserProfilePhoto) end end diff --git a/lib/tdlib/types/video.rb b/lib/tdlib/types/video.rb index f2b3faf..f97dd4c 100644 --- a/lib/tdlib/types/video.rb +++ b/lib/tdlib/types/video.rb @@ -8,6 +8,7 @@ module TD::Types # @attr mime_type [String] MIME type of the file; as defined by the sender. # @attr has_stickers [Boolean] True, if stickers were added to the photo. # @attr supports_streaming [Boolean] True, if the video should be tried to be streamed. + # @attr minithumbnail [TD::Types::Minithumbnail, nil] Video minithumbnail; may be null. # @attr thumbnail [TD::Types::PhotoSize, nil] Video thumbnail; as defined by the sender; may be null. # @attr video [TD::Types::File] File containing the video. class Video < Base @@ -18,6 +19,7 @@ class Video < Base attribute :mime_type, TD::Types::String attribute :has_stickers, TD::Types::Bool attribute :supports_streaming, TD::Types::Bool + attribute :minithumbnail, TD::Types::Minithumbnail.optional.default(nil) attribute :thumbnail, TD::Types::PhotoSize.optional.default(nil) attribute :video, TD::Types::File end diff --git a/lib/tdlib/types/video_note.rb b/lib/tdlib/types/video_note.rb index abe0129..aeea6a7 100644 --- a/lib/tdlib/types/video_note.rb +++ b/lib/tdlib/types/video_note.rb @@ -4,11 +4,13 @@ module TD::Types # # @attr duration [Integer] Duration of the video, in seconds; as defined by the sender. # @attr length [Integer] Video width and height; as defined by the sender. + # @attr minithumbnail [TD::Types::Minithumbnail, nil] Video minithumbnail; may be null. # @attr thumbnail [TD::Types::PhotoSize, nil] Video thumbnail; as defined by the sender; may be null. # @attr video [TD::Types::File] File containing the video. class VideoNote < Base attribute :duration, TD::Types::Integer attribute :length, TD::Types::Integer + attribute :minithumbnail, TD::Types::Minithumbnail.optional.default(nil) attribute :thumbnail, TD::Types::PhotoSize.optional.default(nil) attribute :video, TD::Types::File end diff --git a/lib/tdlib/types/wallpaper.rb b/lib/tdlib/types/wallpaper.rb deleted file mode 100644 index 34b95db..0000000 --- a/lib/tdlib/types/wallpaper.rb +++ /dev/null @@ -1,14 +0,0 @@ -module TD::Types - # Contains information about a wallpaper. - # - # @attr id [Integer] Unique persistent wallpaper identifier. - # @attr sizes [Array] Available variants of the wallpaper in different sizes. - # These photos can only be downloaded; they can't be sent in a message. - # @attr color [Integer] Main color of the wallpaper in RGB24 format; should be treated as background color if no - # photos are specified. - class Wallpaper < Base - attribute :id, TD::Types::Integer - attribute :sizes, TD::Types::Array.of(TD::Types::PhotoSize) - attribute :color, TD::Types::Integer - end -end diff --git a/lib/tdlib/types/wallpapers.rb b/lib/tdlib/types/wallpapers.rb deleted file mode 100644 index cd8ff1d..0000000 --- a/lib/tdlib/types/wallpapers.rb +++ /dev/null @@ -1,8 +0,0 @@ -module TD::Types - # Contains a list of wallpapers. - # - # @attr wallpapers [Array] A list of wallpapers. - class Wallpapers < Base - attribute :wallpapers, TD::Types::Array.of(TD::Types::Wallpaper) - end -end diff --git a/lib/tdlib/types/web_page.rb b/lib/tdlib/types/web_page.rb index ba56fae..49197cf 100644 --- a/lib/tdlib/types/web_page.rb +++ b/lib/tdlib/types/web_page.rb @@ -24,7 +24,8 @@ module TD::Types # @attr video [TD::Types::Video, nil] Preview of the content as a video, if available; may be null. # @attr video_note [TD::Types::VideoNote, nil] Preview of the content as a video note, if available; may be null. # @attr voice_note [TD::Types::VoiceNote, nil] Preview of the content as a voice note, if available; may be null. - # @attr has_instant_view [Boolean] True, if the web page has an instant view. + # @attr instant_view_version [Integer] Version of instant view, available for the web page (currently can be 1 or 2), + # 0 if none. class WebPage < Base attribute :url, TD::Types::String attribute :display_url, TD::Types::String @@ -46,6 +47,6 @@ class WebPage < Base attribute :video, TD::Types::Video.optional.default(nil) attribute :video_note, TD::Types::VideoNote.optional.default(nil) attribute :voice_note, TD::Types::VoiceNote.optional.default(nil) - attribute :has_instant_view, TD::Types::Bool + attribute :instant_view_version, TD::Types::Integer end end diff --git a/lib/tdlib/types/web_page_instant_view.rb b/lib/tdlib/types/web_page_instant_view.rb index b0b90a1..33c0341 100644 --- a/lib/tdlib/types/web_page_instant_view.rb +++ b/lib/tdlib/types/web_page_instant_view.rb @@ -2,10 +2,17 @@ module TD::Types # Describes an instant view page for a web page. # # @attr page_blocks [Array] Content of the web page. + # @attr version [Integer] Version of the instant view, currently can be 1 or 2. + # @attr url [String] Instant view URL; may be different from WebPage.url and must be used for the correct anchors + # handling. + # @attr is_rtl [Boolean] True, if the instant view must be shown from right to left. # @attr is_full [Boolean] True, if the instant view contains the full page. # A network request might be needed to get the full web page instant view. class WebPageInstantView < Base attribute :page_blocks, TD::Types::Array.of(TD::Types::PageBlock) + attribute :version, TD::Types::Integer + attribute :url, TD::Types::String + attribute :is_rtl, TD::Types::Bool attribute :is_full, TD::Types::Bool end end diff --git a/lib/tdlib/update_manager.rb b/lib/tdlib/update_manager.rb index dab98da..cefd942 100644 --- a/lib/tdlib/update_manager.rb +++ b/lib/tdlib/update_manager.rb @@ -13,31 +13,24 @@ def add_handler(handler) alias << add_handler - def run + def run(callback: nil) Thread.start do - loop { stopped? ? break : handle_update } + catch(:client_closed) { loop { handle_update(callback: callback) } } + @mutex.synchronize { @handlers = [] } end end - def stop - @stopped = true - @mutex.synchronize { @handlers = [] } - end - - def stopped? - !!@stopped - end - private attr_reader :handlers - def handle_update + def handle_update(callback: nil) update = TD::Api.client_receive(@td_client, TIMEOUT) unless update.nil? extra = update.delete('@extra') update = TD::Types.wrap(update) + callback&.call(update) match_handlers!(update, extra).each { |h| h.async.run(update) } end diff --git a/lib/tdlib/version.rb b/lib/tdlib/version.rb index ee62dd7..1fc514a 100644 --- a/lib/tdlib/version.rb +++ b/lib/tdlib/version.rb @@ -1,4 +1,4 @@ module TD # tdlib-ruby version - VERSION = "2.0.0" + VERSION = "2.1.0" end diff --git a/spec/integration/tdlib_spec.rb b/spec/integration/tdlib_spec.rb index 5ee5fe2..38e384b 100644 --- a/spec/integration/tdlib_spec.rb +++ b/spec/integration/tdlib_spec.rb @@ -19,6 +19,14 @@ TD::Api.set_log_verbosity_level(1) end + around do |example| + begin + example.run + ensure + client.dispose + end + end + describe '#on_ready' do subject { client.on_ready { [client, 'ready'] } } diff --git a/td b/td index a9608ca..a2429d5 160000 --- a/td +++ b/td @@ -1 +1 @@ -Subproject commit a9608ca379e1582552d7a123912aa9d68c2bb1ca +Subproject commit a2429d595ce38456240717219fe4e61c3ba8b38a