Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tdlib version (#34) #35

Merged
merged 1 commit into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: ruby
rvm:
- 2.4.9
- 2.6.5
- 2.7.0
addons:
apt:
sources:
Expand All @@ -19,6 +19,7 @@ env:
global:
secure: DmAoRsr+dTPVNs486nBXzChjzCCVdoxfmSbvqMBBl0v8uuUIZD1rSfYKcEaL5pmE7vgYq3X+3Dk0gf4ef/p2xPVKqFKrkBiF/7t06WgQTH7003gHMLq3aC7R9+1xvqJDzpoc6UB59Y1fOJBe5YfqDuw1dT9a46tzY2uzoVpEpbN8M/hssaKf6Wuzvpz5yekFeXq2raPwi3aOqvkSG+ODoacVdYQgJ4Vn0//CI2HzWijkQCvdsefWQUKkbgtuLWRp3UNy8AEhVWzQnTcSM7oc+MwMsOI/90DZkTP5n2WJl/CFTM5b70VyrIciG92SvTAhhBo/p7t3QBJa6kJMPXAHh5q+3wqVQA411+CoVF48bO5rKjKY3Ply49uqAzVJRh+Tkhf5uC1pHiZ6QKGxu1Czde+mKItBpaDmJFmQi0CSdv2WYXLnJWOQIO6vc2P3liwpMDRDyaGWOQtUYS+gHAlRbD4NPycIkGjkcjmLMqSEEO1TdCpM+CYwTvNTkRS+9HrWXZNdEfWORDYHgYohoIP6kY6XWSgunUb6F6pVxLoPWJNEBEVuIMZeOa/s9oklxBzD5XXIzBx4QsPYanvfxoN1uOcXlBXbOGqwiqb+urokNDw+BzWhbA+xY03U2+yO0Ujh3HQDyMDtrXEQfaPC0SxpEvIINVYwznG4sMKvbOaCVSo=
before_install:
- gem install -v 2.1.2 bundler
- set -e
- cd td
- mkdir -p build
Expand Down
5 changes: 2 additions & 3 deletions bin/parser
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env ruby
require 'open-uri'
require 'active_support/all'

AUTOLOAD_BASE_DIR = 'tdlib/types'
TD_API_TL_LOCATION = "https://raw.githubusercontent.com/tdlib/td/v1.5.0/td/generate/scheme/td_api.tl"
TD_API_TL_LOCATION = 'td/td/generate/scheme/td_api.tl'


def parse_tl_type(type)
Expand Down Expand Up @@ -221,7 +220,7 @@ klass = <<-RUBY
module TD::Types
class Base < Dry::Struct
# throw an error when unknown keys provided
input input.strict
schema schema.strict

# convert string keys to symbols
transform_keys(&:to_sym)
Expand Down
449 changes: 341 additions & 108 deletions lib/tdlib/client_methods.rb

Large diffs are not rendered by default.

78 changes: 69 additions & 9 deletions lib/tdlib/types.rb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/tdlib/types/audio.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module TD::Types
# Describes an audio file.
# Audio is usually in MP3 format.
# Audio is usually in MP3 or M4A format.
#
# @attr duration [Integer] Duration of the audio, in seconds; as defined by the sender.
# @attr title [String] Title of the audio; as defined by the sender.
Expand Down
1 change: 1 addition & 0 deletions lib/tdlib/types/authorization_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class AuthorizationState < Base
wait_encryption_key
wait_phone_number
wait_code
wait_other_device_confirmation
wait_registration
wait_password
ready
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module TD::Types
# The user needs to confirm authorization on another logged in device by scanning a QR code with the provided link.
#
# @attr link [String] A tg:// URL for the QR code.
# The link will be updated frequently.
class AuthorizationState::WaitOtherDeviceConfirmation < AuthorizationState
attribute :link, TD::Types::String
end
end
2 changes: 2 additions & 0 deletions lib/tdlib/types/authorization_state/wait_phone_number.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module TD::Types
# TDLib needs the user's phone number to authorize.
# Call `setAuthenticationPhoneNumber` to provide the phone number, or use `requestQrCodeAuthentication`, or
# `checkAuthenticationBotToken` for other authentication options.
class AuthorizationState::WaitPhoneNumber < AuthorizationState
end
end
8 changes: 5 additions & 3 deletions lib/tdlib/types/auto_download_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ 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 max_photo_file_size [Integer] The maximum size of a photo file to be auto-downloaded.
# @attr max_video_file_size [Integer] The maximum size of a video file to be auto-downloaded.
# @attr max_other_file_size [Integer] The maximum size of other file types to be auto-downloaded.
# @attr video_upload_bitrate [Integer] The maximum suggested bitrate for uploaded videos.
# @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.
Expand All @@ -14,6 +15,7 @@ class AutoDownloadSettings < Base
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 :video_upload_bitrate, 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
Expand Down
2 changes: 1 addition & 1 deletion lib/tdlib/types/background.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module TD::Types
# @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.
# Null only for filled backgrounds.
# @attr type [TD::Types::BackgroundType] Type of the background.
class Background < Base
attribute :id, TD::Types::Integer
Expand Down
11 changes: 11 additions & 0 deletions lib/tdlib/types/background_fill.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module TD::Types
# Describes a fill of a background.
class BackgroundFill < Base
%w[
solid
gradient
].each do |type|
autoload TD::Types.camelize(type), "tdlib/types/background_fill/#{type}"
end
end
end
13 changes: 13 additions & 0 deletions lib/tdlib/types/background_fill/gradient.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module TD::Types
# Describes a gradient fill of a background.
#
# @attr top_color [Integer] A top color of the background in the RGB24 format.
# @attr bottom_color [Integer] A bottom color of the background in the RGB24 format.
# @attr rotation_angle [Integer] Clockwise rotation angle of the gradient, in degrees; 0-359.
# Should be always divisible by 45.
class BackgroundFill::Gradient < BackgroundFill
attribute :top_color, TD::Types::Integer
attribute :bottom_color, TD::Types::Integer
attribute :rotation_angle, TD::Types::Integer
end
end
8 changes: 8 additions & 0 deletions lib/tdlib/types/background_fill/solid.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module TD::Types
# Describes a solid fill of a background.
#
# @attr color [Integer] A color of the background in the RGB24 format.
class BackgroundFill::Solid < BackgroundFill
attribute :color, TD::Types::Integer
end
end
2 changes: 1 addition & 1 deletion lib/tdlib/types/background_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class BackgroundType < Base
%w[
wallpaper
pattern
solid
fill
].each do |type|
autoload TD::Types.camelize(type), "tdlib/types/background_type/#{type}"
end
Expand Down
8 changes: 8 additions & 0 deletions lib/tdlib/types/background_type/fill.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module TD::Types
# A filled background.
#
# @attr fill [TD::Types::BackgroundFill] Description of the background fill.
class BackgroundType::Fill < BackgroundType
attribute :fill, TD::Types::BackgroundFill
end
end
13 changes: 7 additions & 6 deletions lib/tdlib/types/background_type/pattern.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module TD::Types
# A PNG pattern to be combined with the color chosen by the user.
# A PNG or TGV (gzipped subset of SVG with MIME type "application/x-tgwallpattern") pattern to be combined with the
# background fill 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.
# @attr fill [TD::Types::BackgroundFill] Description of the background fill.
# @attr intensity [Integer] Intensity of the pattern when it is shown above the filled background, 0-100.
# @attr is_moving [Boolean] True, if the background needs to be slightly moved when device is tilted.
class BackgroundType::Pattern < BackgroundType
attribute :is_moving, TD::Types::Bool
attribute :color, TD::Types::Integer
attribute :fill, TD::Types::BackgroundFill
attribute :intensity, TD::Types::Integer
attribute :is_moving, TD::Types::Bool
end
end
8 changes: 0 additions & 8 deletions lib/tdlib/types/background_type/solid.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/tdlib/types/background_type/wallpaper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module TD::Types
#
# @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.
# @attr is_moving [Boolean] True, if the background needs to be slightly moved when device is tilted.
class BackgroundType::Wallpaper < BackgroundType
attribute :is_blurred, TD::Types::Bool
attribute :is_moving, TD::Types::Bool
Expand Down
2 changes: 1 addition & 1 deletion lib/tdlib/types/base.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module TD::Types
class Base < Dry::Struct
# throw an error when unknown keys provided
input input.strict
schema schema.strict

# convert string keys to symbols
transform_keys(&:to_sym)
Expand Down
4 changes: 2 additions & 2 deletions lib/tdlib/types/basic_group_full_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module TD::Types
# @attr description [String] Group description.
# @attr creator_user_id [Integer] User identifier of the creator of the group; 0 if unknown.
# @attr members [Array<TD::Types::ChatMember>] 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.
# @attr invite_link [String] Invite link for this group; available only after it has been generated at least once and
# only for the group creator.
class BasicGroupFullInfo < Base
attribute :description, TD::Types::String
attribute :creator_user_id, TD::Types::Integer
Expand Down
4 changes: 2 additions & 2 deletions lib/tdlib/types/call_protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module TD::Types
#
# @attr udp_p2p [Boolean] True, if UDP peer-to-peer connections are supported.
# @attr udp_reflector [Boolean] True, if connection through UDP reflectors is supported.
# @attr min_layer [Integer] Minimum supported API layer; use 65.
# @attr max_layer [Integer] Maximum supported API layer; use 65.
# @attr min_layer [Integer] The minimum supported API layer; use 65.
# @attr max_layer [Integer] The maximum supported API layer; use 65.
class CallProtocol < Base
attribute :udp_p2p, TD::Types::Bool
attribute :udp_reflector, TD::Types::Bool
Expand Down
13 changes: 13 additions & 0 deletions lib/tdlib/types/can_transfer_ownership_result.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module TD::Types
# Represents result of checking whether the current session can be used to transfer a chat ownership to another user.
class CanTransferOwnershipResult < Base
%w[
ok
password_needed
password_too_fresh
session_too_fresh
].each do |type|
autoload TD::Types.camelize(type), "tdlib/types/can_transfer_ownership_result/#{type}"
end
end
end
5 changes: 5 additions & 0 deletions lib/tdlib/types/can_transfer_ownership_result/ok.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module TD::Types
# The session can be used.
class CanTransferOwnershipResult::Ok < CanTransferOwnershipResult
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module TD::Types
# The 2-step verification needs to be enabled first.
class CanTransferOwnershipResult::PasswordNeeded < CanTransferOwnershipResult
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module TD::Types
# The 2-step verification was enabled recently, user needs to wait.
#
# @attr retry_after [Integer] Time left before the session can be used to transfer ownership of a chat, in seconds.
class CanTransferOwnershipResult::PasswordTooFresh < CanTransferOwnershipResult
attribute :retry_after, TD::Types::Integer
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module TD::Types
# The session was created recently, user needs to wait.
#
# @attr retry_after [Integer] Time left before the session can be used to transfer ownership of a chat, in seconds.
class CanTransferOwnershipResult::SessionTooFresh < CanTransferOwnershipResult
attribute :retry_after, TD::Types::Integer
end
end
11 changes: 9 additions & 2 deletions lib/tdlib/types/chat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module TD::Types
#
# @attr id [Integer] Chat unique identifier.
# @attr type [TD::Types::ChatType] Type of the chat.
# @attr chat_list [TD::Types::ChatList, nil] A chat list to which the chat belongs; may be null.
# @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
Expand All @@ -15,6 +16,7 @@ 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 has_scheduled_messages [Boolean] True, if the chat has scheduled messages.
# @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.
Expand All @@ -26,16 +28,19 @@ 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 action_bar [TD::Types::ChatActionBar, nil] Describes actions which should be possible to do through a chat
# action bar; may be null.
# @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.
# @attr client_data [String] Contains client-specific data associated with the chat.
# (For example, the chat position or local chat notification settings can be stored here.) Persistent if a message
# database is used.
# (For example, the chat position or local chat notification settings can be stored here.) Persistent if the
# message database is used.
class Chat < Base
attribute :id, TD::Types::Integer
attribute :type, TD::Types::ChatType
attribute :chat_list, TD::Types::ChatList.optional.default(nil)
attribute :title, TD::Types::String
attribute :photo, TD::Types::ChatPhoto.optional.default(nil)
attribute :permissions, TD::Types::ChatPermissions
Expand All @@ -44,6 +49,7 @@ class Chat < Base
attribute :is_pinned, TD::Types::Bool
attribute :is_marked_as_unread, TD::Types::Bool
attribute :is_sponsored, TD::Types::Bool
attribute :has_scheduled_messages, 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
Expand All @@ -53,6 +59,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 :action_bar, TD::Types::ChatActionBar.optional.default(nil)
attribute :pinned_message_id, TD::Types::Integer
attribute :reply_markup_message_id, TD::Types::Integer
attribute :draft_message, TD::Types::DraftMessage.optional.default(nil)
Expand Down
14 changes: 14 additions & 0 deletions lib/tdlib/types/chat_action_bar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module TD::Types
# Describes actions which should be possible to do through a chat action bar.
class ChatActionBar < Base
%w[
report_spam
report_unrelated_location
report_add_block
add_contact
share_phone_number
].each do |type|
autoload TD::Types.camelize(type), "tdlib/types/chat_action_bar/#{type}"
end
end
end
6 changes: 6 additions & 0 deletions lib/tdlib/types/chat_action_bar/add_contact.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module TD::Types
# The chat is a private or secret chat and the other user can be added to the contact list using the method
# addContact.
class ChatActionBar::AddContact < ChatActionBar
end
end
6 changes: 6 additions & 0 deletions lib/tdlib/types/chat_action_bar/report_add_block.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module TD::Types
# The chat is a private or secret chat, which can be reported using the method reportChat, or the other user can be
# added to the contact list using the method addContact, or the other user can be blocked using the method blockUser.
class ChatActionBar::ReportAddBlock < ChatActionBar
end
end
5 changes: 5 additions & 0 deletions lib/tdlib/types/chat_action_bar/report_spam.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module TD::Types
# The chat can be reported as spam using the method reportChat with the reason chatReportReasonSpam.
class ChatActionBar::ReportSpam < ChatActionBar
end
end
6 changes: 6 additions & 0 deletions lib/tdlib/types/chat_action_bar/report_unrelated_location.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module TD::Types
# The chat is a location-based supergroup, which can be reported as having unrelated location using the method
# reportChat with the reason chatReportReasonUnrelatedLocation.
class ChatActionBar::ReportUnrelatedLocation < ChatActionBar
end
end
6 changes: 6 additions & 0 deletions lib/tdlib/types/chat_action_bar/share_phone_number.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module TD::Types
# The chat is a private or secret chat with a mutual contact and the user's phone number can be shared with the other
# user using the method sharePhoneNumber.
class ChatActionBar::SharePhoneNumber < ChatActionBar
end
end
12 changes: 12 additions & 0 deletions lib/tdlib/types/chat_administrator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module TD::Types
# Contains information about a chat administrator.
#
# @attr user_id [Integer] User identifier of the administrator.
# @attr custom_title [String] Custom title of the administrator.
# @attr is_owner [Boolean] True, if the user is the owner of the chat.
class ChatAdministrator < Base
attribute :user_id, TD::Types::Integer
attribute :custom_title, TD::Types::String
attribute :is_owner, TD::Types::Bool
end
end
8 changes: 8 additions & 0 deletions lib/tdlib/types/chat_administrators.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module TD::Types
# Represents a list of chat administrators.
#
# @attr administrators [Array<TD::Types::ChatAdministrator>] A list of chat administrators.
class ChatAdministrators < Base
attribute :administrators, TD::Types::Array.of(TD::Types::ChatAdministrator)
end
end
Loading