From 7793f0b0bc6fc21396a99b6447e2dbd81ca54975 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 4 Sep 2022 07:46:29 +0000 Subject: [PATCH] feat(schema): update Telegram to the latest layer --- _schema/tdesktop.tl | 132 +++- _schema/telegram.tl | 132 +++- telegram/query/cached/queries.gen.go | 344 ++++++++ ...account_clear_recent_emoji_statuses_gen.go | 142 ++++ ...clear_recent_emoji_statuses_slices_gen.go} | 0 tg/tl_account_email_verified_gen.go | 419 ++++++++++ tg/tl_account_email_verified_slices_gen.go | 307 ++++++++ tg/tl_account_emoji_statuses_gen.go | 419 ++++++++++ tg/tl_account_emoji_statuses_slices_gen.go | 267 +++++++ ..._account_get_default_emoji_statuses_gen.go | 176 +++++ ...t_get_default_emoji_statuses_slices_gen.go | 35 + ...l_account_get_recent_emoji_statuses_gen.go | 176 +++++ ...nt_get_recent_emoji_statuses_slices_gen.go | 35 + tg/tl_account_password_gen.go | 96 ++- tg/tl_account_send_verify_email_code_gen.go | 55 +- tg/tl_account_update_emoji_status_gen.go | 187 +++++ ..._account_update_emoji_status_slices_gen.go | 35 + tg/tl_account_verify_email_gen.go | 91 ++- tg/tl_auth_sent_code_type_gen.go | 508 ++++++++++++ tg/tl_auth_sent_code_type_slices_gen.go | 190 +++++ tg/tl_auth_sign_in_gen.go | 128 ++- tg/tl_channel_admin_log_event_action_gen.go | 78 +- tg/tl_channels_send_as_peers_gen.go | 56 +- tg/tl_chat_full_gen.go | 272 +++---- tg/tl_chat_reactions_gen.go | 547 +++++++++++++ tg/tl_chat_reactions_slices_gen.go | 307 ++++++++ tg/tl_config_gen.go | 163 ++-- tg/tl_email_verification_gen.go | 531 +++++++++++++ tg/tl_email_verification_slices_gen.go | 402 ++++++++++ tg/tl_email_verify_purpose_gen.go | 492 ++++++++++++ tg/tl_email_verify_purpose_slices_gen.go | 212 +++++ tg/tl_emoji_status_gen.go | 569 ++++++++++++++ tg/tl_emoji_status_slices_gen.go | 362 +++++++++ tg/tl_handlers_gen.go | 40 + tg/tl_help_premium_promo_gen.go | 121 ++- tg/tl_input_sticker_set_gen.go | 218 ++++++ tg/tl_message_peer_reaction_gen.go | 43 +- tg/tl_messages_clear_recent_reactions_gen.go | 142 ++++ ...sages_clear_recent_reactions_slices_gen.go | 35 + ...messages_get_message_reactions_list_gen.go | 55 +- tg/tl_messages_get_recent_reactions_gen.go | 200 +++++ ...essages_get_recent_reactions_slices_gen.go | 35 + tg/tl_messages_get_top_reactions_gen.go | 200 +++++ ...l_messages_get_top_reactions_slices_gen.go | 35 + tg/tl_messages_reactions_gen.go | 419 ++++++++++ tg/tl_messages_reactions_slices_gen.go | 267 +++++++ tg/tl_messages_report_reaction_gen.go | 238 ++++++ tg/tl_messages_report_reaction_slices_gen.go | 35 + tg/tl_messages_request_simple_web_view_gen.go | 59 +- tg/tl_messages_request_web_view_gen.go | 75 +- tg/tl_messages_send_media_gen.go | 35 + tg/tl_messages_send_message_gen.go | 35 + tg/tl_messages_send_multi_media_gen.go | 35 + tg/tl_messages_send_reaction_gen.go | 109 ++- ...ssages_set_chat_available_reactions_gen.go | 52 +- tg/tl_messages_set_default_reaction_gen.go | 37 +- ..._payments_request_recurring_payment_gen.go | 237 ------ tg/tl_premium_subscription_option_gen.go | 378 +++++++++ ..._premium_subscription_option_slices_gen.go | 35 + tg/tl_reaction_count_gen.go | 94 ++- tg/tl_reaction_gen.go | 498 ++++++++++++ tg/tl_reaction_slices_gen.go | 307 ++++++++ tg/tl_registry_gen.go | 207 ++++- tg/tl_send_as_peer_gen.go | 219 ++++++ tg/tl_send_as_peer_slices_gen.go | 35 + tg/tl_server_gen.go | 183 ++++- tg/tl_update_gen.go | 736 +++++++++++++++++- tg/tl_update_slices_gen.go | 285 +++++++ tg/tl_user_gen.go | 111 ++- 69 files changed, 12691 insertions(+), 1019 deletions(-) create mode 100644 tg/tl_account_clear_recent_emoji_statuses_gen.go rename tg/{tl_payments_request_recurring_payment_slices_gen.go => tl_account_clear_recent_emoji_statuses_slices_gen.go} (100%) create mode 100644 tg/tl_account_email_verified_gen.go create mode 100644 tg/tl_account_email_verified_slices_gen.go create mode 100644 tg/tl_account_emoji_statuses_gen.go create mode 100644 tg/tl_account_emoji_statuses_slices_gen.go create mode 100644 tg/tl_account_get_default_emoji_statuses_gen.go create mode 100644 tg/tl_account_get_default_emoji_statuses_slices_gen.go create mode 100644 tg/tl_account_get_recent_emoji_statuses_gen.go create mode 100644 tg/tl_account_get_recent_emoji_statuses_slices_gen.go create mode 100644 tg/tl_account_update_emoji_status_gen.go create mode 100644 tg/tl_account_update_emoji_status_slices_gen.go create mode 100644 tg/tl_chat_reactions_gen.go create mode 100644 tg/tl_chat_reactions_slices_gen.go create mode 100644 tg/tl_email_verification_gen.go create mode 100644 tg/tl_email_verification_slices_gen.go create mode 100644 tg/tl_email_verify_purpose_gen.go create mode 100644 tg/tl_email_verify_purpose_slices_gen.go create mode 100644 tg/tl_emoji_status_gen.go create mode 100644 tg/tl_emoji_status_slices_gen.go create mode 100644 tg/tl_messages_clear_recent_reactions_gen.go create mode 100644 tg/tl_messages_clear_recent_reactions_slices_gen.go create mode 100644 tg/tl_messages_get_recent_reactions_gen.go create mode 100644 tg/tl_messages_get_recent_reactions_slices_gen.go create mode 100644 tg/tl_messages_get_top_reactions_gen.go create mode 100644 tg/tl_messages_get_top_reactions_slices_gen.go create mode 100644 tg/tl_messages_reactions_gen.go create mode 100644 tg/tl_messages_reactions_slices_gen.go create mode 100644 tg/tl_messages_report_reaction_gen.go create mode 100644 tg/tl_messages_report_reaction_slices_gen.go delete mode 100644 tg/tl_payments_request_recurring_payment_gen.go create mode 100644 tg/tl_premium_subscription_option_gen.go create mode 100644 tg/tl_premium_subscription_option_slices_gen.go create mode 100644 tg/tl_reaction_gen.go create mode 100644 tg/tl_reaction_slices_gen.go create mode 100644 tg/tl_send_as_peer_gen.go create mode 100644 tg/tl_send_as_peer_slices_gen.go diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index 5a6db895bf..c33f34b887 100644 --- a/_schema/tdesktop.tl +++ b/_schema/tdesktop.tl @@ -1,8 +1,8 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/Resources/tl/api.tl -// Layer: 144 -// SHA256: 4f7ff5bf96b712b8884b6d220e003e47dc45f00674709adbc9938d3ee34d83c2 +// Layer: 145 +// SHA256: 17d2ed0473e0ed2bfc22018d387654b8474b7412b3ba66cfa5a3cb377b4ccaaf boolFalse#bc799737 = Bool; @@ -134,7 +134,7 @@ storage.fileWebp#1081464c = storage.FileType; userEmpty#d3bc4b7a id:long = User; -user#3ff6ecb0 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User; +user#5d99adee flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; @@ -162,9 +162,9 @@ channel#8261ac61 flags:# creator:flags.0?true left:flags.2?true broadcast:flags. channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat; -chatFull#d18ee226 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?Vector = ChatFull; +chatFull#c9d31138 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions = ChatFull; -channelFull#ea68a619 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?Vector = ChatFull; +channelFull#f2355507 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions = ChatFull; chatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant; @@ -488,7 +488,7 @@ updateNewStickerSet#688a30aa stickerset:messages.StickerSet = Update; updateStickerSetsOrder#bb2d201 flags:# masks:flags.0?true emojis:flags.1?true order:Vector = Update; -updateStickerSets#43ae3dec = Update; +updateStickerSets#31c24808 flags:# masks:flags.0?true emojis:flags.1?true = Update; updateSavedGifs#9375341e = Update; @@ -626,6 +626,14 @@ updateTranscribedAudio#84cd5a flags:# pending:flags.0?true peer:Peer msg_id:int updateReadFeaturedEmojiStickers#fb4c496c = Update; +updateUserEmojiStatus#28373599 user_id:long emoji_status:EmojiStatus = Update; + +updateRecentEmojiStatuses#30f443db = Update; + +updateRecentReactions#6f7863f4 = Update; + +updateMoveStickerSetToTop#86fccf85 flags:# masks:flags.0?true emojis:flags.1?true stickerset:long = Update; + updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.differenceEmpty#5d75a138 date:int seq:int = updates.Difference; @@ -662,7 +670,7 @@ upload.fileCdnRedirect#f18cda44 dc_id:int file_token:bytes encryption_key:bytes dcOption#18b7a10d flags:# ipv6:flags.0?true media_only:flags.1?true tcpo_only:flags.2?true cdn:flags.3?true static:flags.4?true this_port_only:flags.5?true id:int ip_address:string port:int secret:flags.10?bytes = DcOption; -config#330b4067 flags:# phonecalls_enabled:flags.1?true default_p2p_contacts:flags.3?true preload_featured_stickers:flags.4?true ignore_phone_entities:flags.5?true revoke_pm_inbox:flags.6?true blocked_mode:flags.8?true pfs_enabled:flags.13?true force_try_ipv6:flags.14?true date:int expires:int test_mode:Bool this_dc:int dc_options:Vector dc_txt_domain_name:string chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int push_chat_period_ms:int push_chat_limit:int saved_gifs_limit:int edit_time_limit:int revoke_time_limit:int revoke_pm_time_limit:int rating_e_decay:int stickers_recent_limit:int stickers_faved_limit:int channels_read_media_period:int tmp_sessions:flags.0?int pinned_dialogs_count_max:int pinned_infolder_count_max:int call_receive_timeout_ms:int call_ring_timeout_ms:int call_connect_timeout_ms:int call_packet_timeout_ms:int me_url_prefix:string autoupdate_url_prefix:flags.7?string gif_search_username:flags.9?string venue_search_username:flags.10?string img_search_username:flags.11?string static_maps_provider:flags.12?string caption_length_max:int message_length_max:int webfile_dc_id:int suggested_lang_code:flags.2?string lang_pack_version:flags.2?int base_lang_pack_version:flags.2?int = Config; +config#232566ac flags:# phonecalls_enabled:flags.1?true default_p2p_contacts:flags.3?true preload_featured_stickers:flags.4?true ignore_phone_entities:flags.5?true revoke_pm_inbox:flags.6?true blocked_mode:flags.8?true pfs_enabled:flags.13?true force_try_ipv6:flags.14?true date:int expires:int test_mode:Bool this_dc:int dc_options:Vector dc_txt_domain_name:string chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int push_chat_period_ms:int push_chat_limit:int saved_gifs_limit:int edit_time_limit:int revoke_time_limit:int revoke_pm_time_limit:int rating_e_decay:int stickers_recent_limit:int stickers_faved_limit:int channels_read_media_period:int tmp_sessions:flags.0?int pinned_dialogs_count_max:int pinned_infolder_count_max:int call_receive_timeout_ms:int call_ring_timeout_ms:int call_connect_timeout_ms:int call_packet_timeout_ms:int me_url_prefix:string autoupdate_url_prefix:flags.7?string gif_search_username:flags.9?string venue_search_username:flags.10?string img_search_username:flags.11?string static_maps_provider:flags.12?string caption_length_max:int message_length_max:int webfile_dc_id:int suggested_lang_code:flags.2?string lang_pack_version:flags.2?int base_lang_pack_version:flags.2?int reactions_default:flags.15?Reaction = Config; nearestDc#8e1a1775 country:string this_dc:int nearest_dc:int = NearestDc; @@ -876,7 +884,7 @@ authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true pa account.authorizations#4bff8ea0 authorization_ttl_days:int authorizations:Vector = account.Authorizations; -account.password#185b184f flags:# has_recovery:flags.0?true has_secure_values:flags.1?true has_password:flags.2?true current_algo:flags.2?PasswordKdfAlgo srp_B:flags.2?bytes srp_id:flags.2?long hint:flags.3?string email_unconfirmed_pattern:flags.4?string new_algo:PasswordKdfAlgo new_secure_algo:SecurePasswordKdfAlgo secure_random:bytes pending_reset_date:flags.5?int = account.Password; +account.password#957b50fb flags:# has_recovery:flags.0?true has_secure_values:flags.1?true has_password:flags.2?true current_algo:flags.2?PasswordKdfAlgo srp_B:flags.2?bytes srp_id:flags.2?long hint:flags.3?string email_unconfirmed_pattern:flags.4?string new_algo:PasswordKdfAlgo new_secure_algo:SecurePasswordKdfAlgo secure_random:bytes pending_reset_date:flags.5?int login_email_pattern:flags.6?string = account.Password; account.passwordSettings#9a5c33e5 flags:# email:flags.0?string secure_settings:flags.1?SecureSecretSettings = account.PasswordSettings; @@ -910,6 +918,10 @@ inputStickerSetAnimatedEmojiAnimations#cde3739 = InputStickerSet; inputStickerSetPremiumGifts#c88b3b02 = InputStickerSet; +inputStickerSetEmojiGenericAnimations#4c4d4ce = InputStickerSet; + +inputStickerSetEmojiDefaultStatuses#29d0f5ee = InputStickerSet; + stickerSet#2dd14edc flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true animated:flags.5?true videos:flags.6?true emojis:flags.7?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumbs:flags.4?Vector thumb_dc_id:flags.4?int thumb_version:flags.4?int thumb_document_id:flags.8?long count:int hash:int = StickerSet; messages.stickerSet#b60a24a6 set:StickerSet packs:Vector documents:Vector = messages.StickerSet; @@ -1124,6 +1136,10 @@ auth.sentCodeTypeFlashCall#ab03c6d9 pattern:string = auth.SentCodeType; auth.sentCodeTypeMissedCall#82006484 prefix:string length:int = auth.SentCodeType; +auth.sentCodeTypeEmailCode#5a159841 flags:# apple_signin_allowed:flags.0?true google_signin_allowed:flags.1?true email_pattern:string length:int next_phone_login_date:flags.2?int = auth.SentCodeType; + +auth.sentCodeTypeSetUpEmailRequired#a5491dea flags:# apple_signin_allowed:flags.0?true google_signin_allowed:flags.1?true = auth.SentCodeType; + messages.botCallbackAnswer#36585ea4 flags:# alert:flags.1?true has_url:flags.3?true native_ui:flags.4?true message:flags.0?string url:flags.2?string cache_time:int = messages.BotCallbackAnswer; messages.messageEditData#26b5dde6 flags:# caption:flags.0?true = messages.MessageEditData; @@ -1464,7 +1480,7 @@ channelAdminLogEventActionToggleNoForwards#cb2ac766 new_value:Bool = ChannelAdmi channelAdminLogEventActionSendMessage#278f2868 message:Message = ChannelAdminLogEventAction; -channelAdminLogEventActionChangeAvailableReactions#9cf7f76a prev_value:Vector new_value:Vector = ChannelAdminLogEventAction; +channelAdminLogEventActionChangeAvailableReactions#be4e0ef8 prev_value:ChatReactions new_value:ChatReactions = ChannelAdminLogEventAction; channelAdminLogEvent#1fad68cd id:long date:int user_id:long action:ChannelAdminLogEventAction = ChannelAdminLogEvent; @@ -1928,7 +1944,7 @@ searchResultPosition#7f648b67 msg_id:int date:int offset:int = SearchResultsPosi messages.searchResultsPositions#53b22baf count:int positions:Vector = messages.SearchResultsPositions; -channels.sendAsPeers#8356cda9 peers:Vector chats:Vector users:Vector = channels.SendAsPeers; +channels.sendAsPeers#f496b0c6 peers:Vector chats:Vector users:Vector = channels.SendAsPeers; users.userFull#3b6d152e full_user:UserFull chats:Vector users:Vector = users.UserFull; @@ -1936,7 +1952,7 @@ messages.peerSettings#6880b94d settings:PeerSettings chats:Vector users:Ve auth.loggedOut#c3a2835f flags:# future_auth_token:flags.0?bytes = auth.LoggedOut; -reactionCount#6fb250d1 flags:# chosen:flags.0?true reaction:string count:int = ReactionCount; +reactionCount#a3d1cb80 flags:# chosen_order:flags.0?int reaction:Reaction count:int = ReactionCount; messageReactions#4f2b9479 flags:# min:flags.0?true can_see_list:flags.2?true results:Vector recent_reactions:flags.1?Vector = MessageReactions; @@ -1952,7 +1968,7 @@ messages.translateNoResult#67ca4737 = messages.TranslatedText; messages.translateResultText#a214f7d0 text:string = messages.TranslatedText; -messagePeerReaction#51b67eff flags:# big:flags.0?true unread:flags.1?true peer_id:Peer reaction:string = MessagePeerReaction; +messagePeerReaction#b156fe9c flags:# big:flags.0?true unread:flags.1?true peer_id:Peer reaction:Reaction = MessagePeerReaction; groupCallStreamChannel#80eb48af channel:int scale:int last_timestamp_ms:long = GroupCallStreamChannel; @@ -2018,7 +2034,7 @@ payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice; messages.transcribedAudio#93752c52 flags:# pending:flags.0?true transcription_id:long text:string = messages.TranscribedAudio; -help.premiumPromo#8a4f3c29 status_text:string status_entities:Vector video_sections:Vector videos:Vector currency:string monthly_amount:long users:Vector = help.PremiumPromo; +help.premiumPromo#5334759c status_text:string status_entities:Vector video_sections:Vector videos:Vector period_options:Vector users:Vector = help.PremiumPromo; inputStorePaymentPremiumSubscription#a6751e66 flags:# restore:flags.0?true = InputStorePaymentPurpose; @@ -2028,6 +2044,52 @@ premiumGiftOption#74c34319 flags:# months:int currency:string amount:long bot_ur paymentFormMethod#88f8f21b url:string title:string = PaymentFormMethod; +emojiStatusEmpty#2de11aae = EmojiStatus; + +emojiStatus#929b619d document_id:long = EmojiStatus; + +emojiStatusUntil#fa30a8c7 document_id:long until:int = EmojiStatus; + +account.emojiStatusesNotModified#d08ce645 = account.EmojiStatuses; + +account.emojiStatuses#90c467d1 hash:long statuses:Vector = account.EmojiStatuses; + +reactionEmpty#79f5d419 = Reaction; + +reactionEmoji#1b2286b8 emoticon:string = Reaction; + +reactionCustomEmoji#8935fc73 document_id:long = Reaction; + +chatReactionsNone#eafc32bc = ChatReactions; + +chatReactionsAll#52928bca flags:# allow_custom:flags.0?true = ChatReactions; + +chatReactionsSome#661d4037 reactions:Vector = ChatReactions; + +messages.reactionsNotModified#b06fdbdf = messages.Reactions; + +messages.reactions#eafdf716 hash:long reactions:Vector = messages.Reactions; + +emailVerifyPurposeLoginSetup#4345be73 phone_number:string phone_code_hash:string = EmailVerifyPurpose; + +emailVerifyPurposeLoginChange#527d22eb = EmailVerifyPurpose; + +emailVerifyPurposePassport#bbf51685 = EmailVerifyPurpose; + +emailVerificationCode#922e55a9 code:string = EmailVerification; + +emailVerificationGoogle#db909ec2 token:string = EmailVerification; + +emailVerificationApple#96d074fd token:string = EmailVerification; + +account.emailVerified#2b96cd1b email:string = account.EmailVerified; + +account.emailVerifiedLogin#e1bb0d61 email:string sent_code:auth.SentCode = account.EmailVerified; + +premiumSubscriptionOption#b6f11ebe flags:# current:flags.1?true can_purchase_upgrade:flags.2?true months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumSubscriptionOption; + +sendAsPeer#b81c7034 flags:# premium_required:flags.0?true peer:Peer = SendAsPeer; + ---functions--- @@ -2049,7 +2111,7 @@ auth.sendCode#a677244f phone_number:string api_id:int api_hash:string settings:C auth.signUp#80eee427 phone_number:string phone_code_hash:string first_name:string last_name:string = auth.Authorization; -auth.signIn#bcd51581 phone_number:string phone_code_hash:string phone_code:string = auth.Authorization; +auth.signIn#8d52a951 flags:# phone_number:string phone_code_hash:string phone_code:flags.0?string email_verification:flags.1?EmailVerification = auth.Authorization; auth.logOut#3e72ba19 = auth.LoggedOut; @@ -2159,9 +2221,9 @@ account.sendVerifyPhoneCode#a5a356f9 phone_number:string settings:CodeSettings = account.verifyPhone#4dd3a7f6 phone_number:string phone_code_hash:string phone_code:string = Bool; -account.sendVerifyEmailCode#7011509f email:string = account.SentEmailCode; +account.sendVerifyEmailCode#98e037bb purpose:EmailVerifyPurpose email:string = account.SentEmailCode; -account.verifyEmail#ecba39db email:string code:string = Bool; +account.verifyEmail#32da4cf purpose:EmailVerifyPurpose verification:EmailVerification = account.EmailVerified; account.initTakeoutSession#8ef3eab0 flags:# contacts:flags.0?true message_users:flags.1?true message_chats:flags.2?true message_megagroups:flags.3?true message_channels:flags.4?true files:flags.5?true file_max_size:flags.5?long = account.Takeout; @@ -2235,6 +2297,14 @@ account.saveRingtone#3dea5b03 id:InputDocument unsave:Bool = account.SavedRingto account.uploadRingtone#831a83a2 file:InputFile file_name:string mime_type:string = Document; +account.updateEmojiStatus#fbd3de6b emoji_status:EmojiStatus = Bool; + +account.getDefaultEmojiStatuses#d6753386 hash:long = account.EmojiStatuses; + +account.getRecentEmojiStatuses#f578105 hash:long = account.EmojiStatuses; + +account.clearRecentEmojiStatuses#18201aae = Bool; + users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#b60f5918 id:InputUser = users.UserFull; @@ -2301,9 +2371,9 @@ messages.receivedMessages#5a954c0 max_id:int = Vector; messages.setTyping#58943ee2 flags:# peer:InputPeer top_msg_id:flags.0?int action:SendMessageAction = Bool; -messages.sendMessage#d9d75a4 flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true peer:InputPeer reply_to_msg_id:flags.0?int message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMessage#d9d75a4 flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; -messages.sendMedia#e25ff8e0 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMedia#e25ff8e0 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.forwardMessages#cc30290b flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; @@ -2463,7 +2533,7 @@ messages.readMentions#f0189d3 peer:InputPeer = messages.AffectedHistory; messages.getRecentLocations#702a40e0 peer:InputPeer limit:int hash:long = messages.Messages; -messages.sendMultiMedia#f803138f flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true peer:InputPeer reply_to_msg_id:flags.0?int multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMultiMedia#f803138f flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.uploadEncryptedFile#5057c497 peer:InputEncryptedChat file:InputEncryptedFile = EncryptedFile; @@ -2581,17 +2651,17 @@ messages.toggleNoForwards#b11eafa2 peer:InputPeer enabled:Bool = Updates; messages.saveDefaultSendAs#ccfddf96 peer:InputPeer send_as:InputPeer = Bool; -messages.sendReaction#25690ce4 flags:# big:flags.1?true peer:InputPeer msg_id:int reaction:flags.0?string = Updates; +messages.sendReaction#d30d78d4 flags:# big:flags.1?true add_to_recent:flags.2?true peer:InputPeer msg_id:int reaction:flags.0?Vector = Updates; messages.getMessagesReactions#8bba90e6 peer:InputPeer id:Vector = Updates; -messages.getMessageReactionsList#e0ee6b77 flags:# peer:InputPeer id:int reaction:flags.0?string offset:flags.1?string limit:int = messages.MessageReactionsList; +messages.getMessageReactionsList#461b3f48 flags:# peer:InputPeer id:int reaction:flags.0?Reaction offset:flags.1?string limit:int = messages.MessageReactionsList; -messages.setChatAvailableReactions#14050ea6 peer:InputPeer available_reactions:Vector = Updates; +messages.setChatAvailableReactions#feb16771 peer:InputPeer available_reactions:ChatReactions = Updates; messages.getAvailableReactions#18dea0ac hash:int = messages.AvailableReactions; -messages.setDefaultReaction#d960c4d4 reaction:string = Bool; +messages.setDefaultReaction#4f47a016 reaction:Reaction = Bool; messages.translateText#24ce6dee flags:# peer:flags.0?InputPeer msg_id:flags.0?int text:flags.1?string from_lang:flags.2?string to_lang:string = messages.TranslatedText; @@ -2607,11 +2677,11 @@ messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot; messages.toggleBotInAttachMenu#1aee33af bot:InputUser enabled:Bool = Bool; -messages.requestWebView#91b15831 flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON reply_to_msg_id:flags.0?int send_as:flags.13?InputPeer = WebViewResult; +messages.requestWebView#fc87a53c flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON platform:string reply_to_msg_id:flags.0?int send_as:flags.13?InputPeer = WebViewResult; messages.prolongWebView#ea5fbcce flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to_msg_id:flags.0?int send_as:flags.13?InputPeer = Bool; -messages.requestSimpleWebView#6abb2f73 flags:# bot:InputUser url:string theme_params:flags.0?DataJSON = SimpleWebViewResult; +messages.requestSimpleWebView#299bec8e flags:# bot:InputUser url:string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; messages.sendWebViewResultMessage#a4314f5 bot_query_id:string result:InputBotInlineResult = WebViewMessageSent; @@ -2627,6 +2697,14 @@ messages.getEmojiStickers#fbfca18f hash:long = messages.AllStickers; messages.getFeaturedEmojiStickers#ecf6736 hash:long = messages.FeaturedStickers; +messages.reportReaction#3f64c076 peer:InputPeer id:int reaction_peer:InputPeer = Bool; + +messages.getTopReactions#bb8125ba limit:int hash:long = messages.Reactions; + +messages.getRecentReactions#39461db2 limit:int hash:long = messages.Reactions; + +messages.clearRecentReactions#9dfeefb4 = Bool; + updates.getState#edd4882a = updates.State; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; @@ -2825,8 +2903,6 @@ payments.assignPlayMarketTransaction#dffd50d3 receipt:DataJSON purpose:InputStor payments.canPurchasePremium#9fc19eb6 purpose:InputStorePaymentPurpose = Bool; -payments.requestRecurringPayment#146e958d user_id:InputUser recurring_init_charge:string invoice_media:InputMedia = Updates; - stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true animated:flags.1?true videos:flags.4?true user_id:InputUser title:string short_name:string thumb:flags.2?InputDocument stickers:Vector software:flags.3?string = messages.StickerSet; stickers.removeStickerFromSet#f7760f51 sticker:InputDocument = messages.StickerSet; @@ -2927,4 +3003,4 @@ stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_r stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats; -// LAYER 144 +// LAYER 145 diff --git a/_schema/telegram.tl b/_schema/telegram.tl index 50b04fa8b8..d8612c6e5d 100644 --- a/_schema/telegram.tl +++ b/_schema/telegram.tl @@ -2,8 +2,8 @@ // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/Resources/tl/api.tl // Merge: _schema/legacy.tl -// Layer: 144 -// SHA256: 4f7ff5bf96b712b8884b6d220e003e47dc45f00674709adbc9938d3ee34d83c2 +// Layer: 145 +// SHA256: 17d2ed0473e0ed2bfc22018d387654b8474b7412b3ba66cfa5a3cb377b4ccaaf boolFalse#bc799737 = Bool; @@ -135,7 +135,7 @@ storage.fileWebp#1081464c = storage.FileType; userEmpty#d3bc4b7a id:long = User; -user#3ff6ecb0 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User; +user#5d99adee flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; @@ -163,9 +163,9 @@ channel#8261ac61 flags:# creator:flags.0?true left:flags.2?true broadcast:flags. channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat; -chatFull#d18ee226 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?Vector = ChatFull; +chatFull#c9d31138 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions = ChatFull; -channelFull#ea68a619 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?Vector = ChatFull; +channelFull#f2355507 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions = ChatFull; chatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant; @@ -489,7 +489,7 @@ updateNewStickerSet#688a30aa stickerset:messages.StickerSet = Update; updateStickerSetsOrder#bb2d201 flags:# masks:flags.0?true emojis:flags.1?true order:Vector = Update; -updateStickerSets#43ae3dec = Update; +updateStickerSets#31c24808 flags:# masks:flags.0?true emojis:flags.1?true = Update; updateSavedGifs#9375341e = Update; @@ -627,6 +627,14 @@ updateTranscribedAudio#84cd5a flags:# pending:flags.0?true peer:Peer msg_id:int updateReadFeaturedEmojiStickers#fb4c496c = Update; +updateUserEmojiStatus#28373599 user_id:long emoji_status:EmojiStatus = Update; + +updateRecentEmojiStatuses#30f443db = Update; + +updateRecentReactions#6f7863f4 = Update; + +updateMoveStickerSetToTop#86fccf85 flags:# masks:flags.0?true emojis:flags.1?true stickerset:long = Update; + updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.differenceEmpty#5d75a138 date:int seq:int = updates.Difference; @@ -663,7 +671,7 @@ upload.fileCdnRedirect#f18cda44 dc_id:int file_token:bytes encryption_key:bytes dcOption#18b7a10d flags:# ipv6:flags.0?true media_only:flags.1?true tcpo_only:flags.2?true cdn:flags.3?true static:flags.4?true this_port_only:flags.5?true id:int ip_address:string port:int secret:flags.10?bytes = DcOption; -config#330b4067 flags:# phonecalls_enabled:flags.1?true default_p2p_contacts:flags.3?true preload_featured_stickers:flags.4?true ignore_phone_entities:flags.5?true revoke_pm_inbox:flags.6?true blocked_mode:flags.8?true pfs_enabled:flags.13?true force_try_ipv6:flags.14?true date:int expires:int test_mode:Bool this_dc:int dc_options:Vector dc_txt_domain_name:string chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int push_chat_period_ms:int push_chat_limit:int saved_gifs_limit:int edit_time_limit:int revoke_time_limit:int revoke_pm_time_limit:int rating_e_decay:int stickers_recent_limit:int stickers_faved_limit:int channels_read_media_period:int tmp_sessions:flags.0?int pinned_dialogs_count_max:int pinned_infolder_count_max:int call_receive_timeout_ms:int call_ring_timeout_ms:int call_connect_timeout_ms:int call_packet_timeout_ms:int me_url_prefix:string autoupdate_url_prefix:flags.7?string gif_search_username:flags.9?string venue_search_username:flags.10?string img_search_username:flags.11?string static_maps_provider:flags.12?string caption_length_max:int message_length_max:int webfile_dc_id:int suggested_lang_code:flags.2?string lang_pack_version:flags.2?int base_lang_pack_version:flags.2?int = Config; +config#232566ac flags:# phonecalls_enabled:flags.1?true default_p2p_contacts:flags.3?true preload_featured_stickers:flags.4?true ignore_phone_entities:flags.5?true revoke_pm_inbox:flags.6?true blocked_mode:flags.8?true pfs_enabled:flags.13?true force_try_ipv6:flags.14?true date:int expires:int test_mode:Bool this_dc:int dc_options:Vector dc_txt_domain_name:string chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int push_chat_period_ms:int push_chat_limit:int saved_gifs_limit:int edit_time_limit:int revoke_time_limit:int revoke_pm_time_limit:int rating_e_decay:int stickers_recent_limit:int stickers_faved_limit:int channels_read_media_period:int tmp_sessions:flags.0?int pinned_dialogs_count_max:int pinned_infolder_count_max:int call_receive_timeout_ms:int call_ring_timeout_ms:int call_connect_timeout_ms:int call_packet_timeout_ms:int me_url_prefix:string autoupdate_url_prefix:flags.7?string gif_search_username:flags.9?string venue_search_username:flags.10?string img_search_username:flags.11?string static_maps_provider:flags.12?string caption_length_max:int message_length_max:int webfile_dc_id:int suggested_lang_code:flags.2?string lang_pack_version:flags.2?int base_lang_pack_version:flags.2?int reactions_default:flags.15?Reaction = Config; nearestDc#8e1a1775 country:string this_dc:int nearest_dc:int = NearestDc; @@ -877,7 +885,7 @@ authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true pa account.authorizations#4bff8ea0 authorization_ttl_days:int authorizations:Vector = account.Authorizations; -account.password#185b184f flags:# has_recovery:flags.0?true has_secure_values:flags.1?true has_password:flags.2?true current_algo:flags.2?PasswordKdfAlgo srp_B:flags.2?bytes srp_id:flags.2?long hint:flags.3?string email_unconfirmed_pattern:flags.4?string new_algo:PasswordKdfAlgo new_secure_algo:SecurePasswordKdfAlgo secure_random:bytes pending_reset_date:flags.5?int = account.Password; +account.password#957b50fb flags:# has_recovery:flags.0?true has_secure_values:flags.1?true has_password:flags.2?true current_algo:flags.2?PasswordKdfAlgo srp_B:flags.2?bytes srp_id:flags.2?long hint:flags.3?string email_unconfirmed_pattern:flags.4?string new_algo:PasswordKdfAlgo new_secure_algo:SecurePasswordKdfAlgo secure_random:bytes pending_reset_date:flags.5?int login_email_pattern:flags.6?string = account.Password; account.passwordSettings#9a5c33e5 flags:# email:flags.0?string secure_settings:flags.1?SecureSecretSettings = account.PasswordSettings; @@ -911,6 +919,10 @@ inputStickerSetAnimatedEmojiAnimations#cde3739 = InputStickerSet; inputStickerSetPremiumGifts#c88b3b02 = InputStickerSet; +inputStickerSetEmojiGenericAnimations#4c4d4ce = InputStickerSet; + +inputStickerSetEmojiDefaultStatuses#29d0f5ee = InputStickerSet; + stickerSet#2dd14edc flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true animated:flags.5?true videos:flags.6?true emojis:flags.7?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumbs:flags.4?Vector thumb_dc_id:flags.4?int thumb_version:flags.4?int thumb_document_id:flags.8?long count:int hash:int = StickerSet; messages.stickerSet#b60a24a6 set:StickerSet packs:Vector documents:Vector = messages.StickerSet; @@ -1125,6 +1137,10 @@ auth.sentCodeTypeFlashCall#ab03c6d9 pattern:string = auth.SentCodeType; auth.sentCodeTypeMissedCall#82006484 prefix:string length:int = auth.SentCodeType; +auth.sentCodeTypeEmailCode#5a159841 flags:# apple_signin_allowed:flags.0?true google_signin_allowed:flags.1?true email_pattern:string length:int next_phone_login_date:flags.2?int = auth.SentCodeType; + +auth.sentCodeTypeSetUpEmailRequired#a5491dea flags:# apple_signin_allowed:flags.0?true google_signin_allowed:flags.1?true = auth.SentCodeType; + messages.botCallbackAnswer#36585ea4 flags:# alert:flags.1?true has_url:flags.3?true native_ui:flags.4?true message:flags.0?string url:flags.2?string cache_time:int = messages.BotCallbackAnswer; messages.messageEditData#26b5dde6 flags:# caption:flags.0?true = messages.MessageEditData; @@ -1465,7 +1481,7 @@ channelAdminLogEventActionToggleNoForwards#cb2ac766 new_value:Bool = ChannelAdmi channelAdminLogEventActionSendMessage#278f2868 message:Message = ChannelAdminLogEventAction; -channelAdminLogEventActionChangeAvailableReactions#9cf7f76a prev_value:Vector new_value:Vector = ChannelAdminLogEventAction; +channelAdminLogEventActionChangeAvailableReactions#be4e0ef8 prev_value:ChatReactions new_value:ChatReactions = ChannelAdminLogEventAction; channelAdminLogEvent#1fad68cd id:long date:int user_id:long action:ChannelAdminLogEventAction = ChannelAdminLogEvent; @@ -1929,7 +1945,7 @@ searchResultPosition#7f648b67 msg_id:int date:int offset:int = SearchResultsPosi messages.searchResultsPositions#53b22baf count:int positions:Vector = messages.SearchResultsPositions; -channels.sendAsPeers#8356cda9 peers:Vector chats:Vector users:Vector = channels.SendAsPeers; +channels.sendAsPeers#f496b0c6 peers:Vector chats:Vector users:Vector = channels.SendAsPeers; users.userFull#3b6d152e full_user:UserFull chats:Vector users:Vector = users.UserFull; @@ -1937,7 +1953,7 @@ messages.peerSettings#6880b94d settings:PeerSettings chats:Vector users:Ve auth.loggedOut#c3a2835f flags:# future_auth_token:flags.0?bytes = auth.LoggedOut; -reactionCount#6fb250d1 flags:# chosen:flags.0?true reaction:string count:int = ReactionCount; +reactionCount#a3d1cb80 flags:# chosen_order:flags.0?int reaction:Reaction count:int = ReactionCount; messageReactions#4f2b9479 flags:# min:flags.0?true can_see_list:flags.2?true results:Vector recent_reactions:flags.1?Vector = MessageReactions; @@ -1953,7 +1969,7 @@ messages.translateNoResult#67ca4737 = messages.TranslatedText; messages.translateResultText#a214f7d0 text:string = messages.TranslatedText; -messagePeerReaction#51b67eff flags:# big:flags.0?true unread:flags.1?true peer_id:Peer reaction:string = MessagePeerReaction; +messagePeerReaction#b156fe9c flags:# big:flags.0?true unread:flags.1?true peer_id:Peer reaction:Reaction = MessagePeerReaction; groupCallStreamChannel#80eb48af channel:int scale:int last_timestamp_ms:long = GroupCallStreamChannel; @@ -2019,7 +2035,7 @@ payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice; messages.transcribedAudio#93752c52 flags:# pending:flags.0?true transcription_id:long text:string = messages.TranscribedAudio; -help.premiumPromo#8a4f3c29 status_text:string status_entities:Vector video_sections:Vector videos:Vector currency:string monthly_amount:long users:Vector = help.PremiumPromo; +help.premiumPromo#5334759c status_text:string status_entities:Vector video_sections:Vector videos:Vector period_options:Vector users:Vector = help.PremiumPromo; inputStorePaymentPremiumSubscription#a6751e66 flags:# restore:flags.0?true = InputStorePaymentPurpose; @@ -2029,6 +2045,52 @@ premiumGiftOption#74c34319 flags:# months:int currency:string amount:long bot_ur paymentFormMethod#88f8f21b url:string title:string = PaymentFormMethod; +emojiStatusEmpty#2de11aae = EmojiStatus; + +emojiStatus#929b619d document_id:long = EmojiStatus; + +emojiStatusUntil#fa30a8c7 document_id:long until:int = EmojiStatus; + +account.emojiStatusesNotModified#d08ce645 = account.EmojiStatuses; + +account.emojiStatuses#90c467d1 hash:long statuses:Vector = account.EmojiStatuses; + +reactionEmpty#79f5d419 = Reaction; + +reactionEmoji#1b2286b8 emoticon:string = Reaction; + +reactionCustomEmoji#8935fc73 document_id:long = Reaction; + +chatReactionsNone#eafc32bc = ChatReactions; + +chatReactionsAll#52928bca flags:# allow_custom:flags.0?true = ChatReactions; + +chatReactionsSome#661d4037 reactions:Vector = ChatReactions; + +messages.reactionsNotModified#b06fdbdf = messages.Reactions; + +messages.reactions#eafdf716 hash:long reactions:Vector = messages.Reactions; + +emailVerifyPurposeLoginSetup#4345be73 phone_number:string phone_code_hash:string = EmailVerifyPurpose; + +emailVerifyPurposeLoginChange#527d22eb = EmailVerifyPurpose; + +emailVerifyPurposePassport#bbf51685 = EmailVerifyPurpose; + +emailVerificationCode#922e55a9 code:string = EmailVerification; + +emailVerificationGoogle#db909ec2 token:string = EmailVerification; + +emailVerificationApple#96d074fd token:string = EmailVerification; + +account.emailVerified#2b96cd1b email:string = account.EmailVerified; + +account.emailVerifiedLogin#e1bb0d61 email:string sent_code:auth.SentCode = account.EmailVerified; + +premiumSubscriptionOption#b6f11ebe flags:# current:flags.1?true can_purchase_upgrade:flags.2?true months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumSubscriptionOption; + +sendAsPeer#b81c7034 flags:# premium_required:flags.0?true peer:Peer = SendAsPeer; + ---functions--- @@ -2050,7 +2112,7 @@ auth.sendCode#a677244f phone_number:string api_id:int api_hash:string settings:C auth.signUp#80eee427 phone_number:string phone_code_hash:string first_name:string last_name:string = auth.Authorization; -auth.signIn#bcd51581 phone_number:string phone_code_hash:string phone_code:string = auth.Authorization; +auth.signIn#8d52a951 flags:# phone_number:string phone_code_hash:string phone_code:flags.0?string email_verification:flags.1?EmailVerification = auth.Authorization; auth.logOut#3e72ba19 = auth.LoggedOut; @@ -2160,9 +2222,9 @@ account.sendVerifyPhoneCode#a5a356f9 phone_number:string settings:CodeSettings = account.verifyPhone#4dd3a7f6 phone_number:string phone_code_hash:string phone_code:string = Bool; -account.sendVerifyEmailCode#7011509f email:string = account.SentEmailCode; +account.sendVerifyEmailCode#98e037bb purpose:EmailVerifyPurpose email:string = account.SentEmailCode; -account.verifyEmail#ecba39db email:string code:string = Bool; +account.verifyEmail#32da4cf purpose:EmailVerifyPurpose verification:EmailVerification = account.EmailVerified; account.initTakeoutSession#8ef3eab0 flags:# contacts:flags.0?true message_users:flags.1?true message_chats:flags.2?true message_megagroups:flags.3?true message_channels:flags.4?true files:flags.5?true file_max_size:flags.5?long = account.Takeout; @@ -2236,6 +2298,14 @@ account.saveRingtone#3dea5b03 id:InputDocument unsave:Bool = account.SavedRingto account.uploadRingtone#831a83a2 file:InputFile file_name:string mime_type:string = Document; +account.updateEmojiStatus#fbd3de6b emoji_status:EmojiStatus = Bool; + +account.getDefaultEmojiStatuses#d6753386 hash:long = account.EmojiStatuses; + +account.getRecentEmojiStatuses#f578105 hash:long = account.EmojiStatuses; + +account.clearRecentEmojiStatuses#18201aae = Bool; + users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#b60f5918 id:InputUser = users.UserFull; @@ -2302,9 +2372,9 @@ messages.receivedMessages#5a954c0 max_id:int = Vector; messages.setTyping#58943ee2 flags:# peer:InputPeer top_msg_id:flags.0?int action:SendMessageAction = Bool; -messages.sendMessage#d9d75a4 flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true peer:InputPeer reply_to_msg_id:flags.0?int message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMessage#d9d75a4 flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; -messages.sendMedia#e25ff8e0 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMedia#e25ff8e0 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.forwardMessages#cc30290b flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; @@ -2464,7 +2534,7 @@ messages.readMentions#f0189d3 peer:InputPeer = messages.AffectedHistory; messages.getRecentLocations#702a40e0 peer:InputPeer limit:int hash:long = messages.Messages; -messages.sendMultiMedia#f803138f flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true peer:InputPeer reply_to_msg_id:flags.0?int multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMultiMedia#f803138f flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.uploadEncryptedFile#5057c497 peer:InputEncryptedChat file:InputEncryptedFile = EncryptedFile; @@ -2582,17 +2652,17 @@ messages.toggleNoForwards#b11eafa2 peer:InputPeer enabled:Bool = Updates; messages.saveDefaultSendAs#ccfddf96 peer:InputPeer send_as:InputPeer = Bool; -messages.sendReaction#25690ce4 flags:# big:flags.1?true peer:InputPeer msg_id:int reaction:flags.0?string = Updates; +messages.sendReaction#d30d78d4 flags:# big:flags.1?true add_to_recent:flags.2?true peer:InputPeer msg_id:int reaction:flags.0?Vector = Updates; messages.getMessagesReactions#8bba90e6 peer:InputPeer id:Vector = Updates; -messages.getMessageReactionsList#e0ee6b77 flags:# peer:InputPeer id:int reaction:flags.0?string offset:flags.1?string limit:int = messages.MessageReactionsList; +messages.getMessageReactionsList#461b3f48 flags:# peer:InputPeer id:int reaction:flags.0?Reaction offset:flags.1?string limit:int = messages.MessageReactionsList; -messages.setChatAvailableReactions#14050ea6 peer:InputPeer available_reactions:Vector = Updates; +messages.setChatAvailableReactions#feb16771 peer:InputPeer available_reactions:ChatReactions = Updates; messages.getAvailableReactions#18dea0ac hash:int = messages.AvailableReactions; -messages.setDefaultReaction#d960c4d4 reaction:string = Bool; +messages.setDefaultReaction#4f47a016 reaction:Reaction = Bool; messages.translateText#24ce6dee flags:# peer:flags.0?InputPeer msg_id:flags.0?int text:flags.1?string from_lang:flags.2?string to_lang:string = messages.TranslatedText; @@ -2608,11 +2678,11 @@ messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot; messages.toggleBotInAttachMenu#1aee33af bot:InputUser enabled:Bool = Bool; -messages.requestWebView#91b15831 flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON reply_to_msg_id:flags.0?int send_as:flags.13?InputPeer = WebViewResult; +messages.requestWebView#fc87a53c flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON platform:string reply_to_msg_id:flags.0?int send_as:flags.13?InputPeer = WebViewResult; messages.prolongWebView#ea5fbcce flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to_msg_id:flags.0?int send_as:flags.13?InputPeer = Bool; -messages.requestSimpleWebView#6abb2f73 flags:# bot:InputUser url:string theme_params:flags.0?DataJSON = SimpleWebViewResult; +messages.requestSimpleWebView#299bec8e flags:# bot:InputUser url:string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; messages.sendWebViewResultMessage#a4314f5 bot_query_id:string result:InputBotInlineResult = WebViewMessageSent; @@ -2628,6 +2698,14 @@ messages.getEmojiStickers#fbfca18f hash:long = messages.AllStickers; messages.getFeaturedEmojiStickers#ecf6736 hash:long = messages.FeaturedStickers; +messages.reportReaction#3f64c076 peer:InputPeer id:int reaction_peer:InputPeer = Bool; + +messages.getTopReactions#bb8125ba limit:int hash:long = messages.Reactions; + +messages.getRecentReactions#39461db2 limit:int hash:long = messages.Reactions; + +messages.clearRecentReactions#9dfeefb4 = Bool; + updates.getState#edd4882a = updates.State; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; @@ -2826,8 +2904,6 @@ payments.assignPlayMarketTransaction#dffd50d3 receipt:DataJSON purpose:InputStor payments.canPurchasePremium#9fc19eb6 purpose:InputStorePaymentPurpose = Bool; -payments.requestRecurringPayment#146e958d user_id:InputUser recurring_init_charge:string invoice_media:InputMedia = Updates; - stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true animated:flags.1?true videos:flags.4?true user_id:InputUser title:string short_name:string thumb:flags.2?InputDocument stickers:Vector software:flags.3?string = messages.StickerSet; stickers.removeStickerFromSet#f7760f51 sticker:InputDocument = messages.StickerSet; @@ -2960,4 +3036,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 144 +// LAYER 145 diff --git a/telegram/query/cached/queries.gen.go b/telegram/query/cached/queries.gen.go index 429bc53665..1ca281b56c 100644 --- a/telegram/query/cached/queries.gen.go +++ b/telegram/query/cached/queries.gen.go @@ -98,6 +98,174 @@ func (s *AccountGetChatThemes) Fetch(ctx context.Context) (bool, error) { } } +type innerAccountGetDefaultEmojiStatuses struct { + // Last received hash. + hash int64 + // Last received result. + value *tg.AccountEmojiStatuses +} + +type AccountGetDefaultEmojiStatuses struct { + // Result state. + last atomic.Value + + // Reference to RPC client to make requests. + raw *tg.Client +} + +// NewAccountGetDefaultEmojiStatuses creates new AccountGetDefaultEmojiStatuses. +func NewAccountGetDefaultEmojiStatuses(raw *tg.Client) *AccountGetDefaultEmojiStatuses { + q := &AccountGetDefaultEmojiStatuses{ + raw: raw, + } + + return q +} + +func (s *AccountGetDefaultEmojiStatuses) store(v innerAccountGetDefaultEmojiStatuses) { + s.last.Store(v) +} + +func (s *AccountGetDefaultEmojiStatuses) load() (innerAccountGetDefaultEmojiStatuses, bool) { + v, ok := s.last.Load().(innerAccountGetDefaultEmojiStatuses) + return v, ok +} + +// Value returns last received result. +// NB: May be nil. Returned AccountEmojiStatuses must not be mutated. +func (s *AccountGetDefaultEmojiStatuses) Value() *tg.AccountEmojiStatuses { + inner, _ := s.load() + return inner.value +} + +// Hash returns last received hash. +func (s *AccountGetDefaultEmojiStatuses) Hash() int64 { + inner, _ := s.load() + return inner.hash +} + +// Get updates data if needed and returns it. +func (s *AccountGetDefaultEmojiStatuses) Get(ctx context.Context) (*tg.AccountEmojiStatuses, error) { + if _, err := s.Fetch(ctx); err != nil { + return nil, err + } + + return s.Value(), nil +} + +// Fetch updates data if needed and returns true if data was modified. +func (s *AccountGetDefaultEmojiStatuses) Fetch(ctx context.Context) (bool, error) { + lastHash := s.Hash() + + req := lastHash + result, err := s.raw.AccountGetDefaultEmojiStatuses(ctx, req) + if err != nil { + return false, errors.Wrap(err, "execute AccountGetDefaultEmojiStatuses") + } + + switch variant := result.(type) { + case *tg.AccountEmojiStatuses: + hash := variant.Hash + + s.store(innerAccountGetDefaultEmojiStatuses{ + hash: hash, + value: variant, + }) + return true, nil + case *tg.AccountEmojiStatusesNotModified: + if lastHash == 0 { + return false, errors.Errorf("got unexpected %T result", result) + } + return false, nil + default: + return false, errors.Errorf("unexpected type %T", result) + } +} + +type innerAccountGetRecentEmojiStatuses struct { + // Last received hash. + hash int64 + // Last received result. + value *tg.AccountEmojiStatuses +} + +type AccountGetRecentEmojiStatuses struct { + // Result state. + last atomic.Value + + // Reference to RPC client to make requests. + raw *tg.Client +} + +// NewAccountGetRecentEmojiStatuses creates new AccountGetRecentEmojiStatuses. +func NewAccountGetRecentEmojiStatuses(raw *tg.Client) *AccountGetRecentEmojiStatuses { + q := &AccountGetRecentEmojiStatuses{ + raw: raw, + } + + return q +} + +func (s *AccountGetRecentEmojiStatuses) store(v innerAccountGetRecentEmojiStatuses) { + s.last.Store(v) +} + +func (s *AccountGetRecentEmojiStatuses) load() (innerAccountGetRecentEmojiStatuses, bool) { + v, ok := s.last.Load().(innerAccountGetRecentEmojiStatuses) + return v, ok +} + +// Value returns last received result. +// NB: May be nil. Returned AccountEmojiStatuses must not be mutated. +func (s *AccountGetRecentEmojiStatuses) Value() *tg.AccountEmojiStatuses { + inner, _ := s.load() + return inner.value +} + +// Hash returns last received hash. +func (s *AccountGetRecentEmojiStatuses) Hash() int64 { + inner, _ := s.load() + return inner.hash +} + +// Get updates data if needed and returns it. +func (s *AccountGetRecentEmojiStatuses) Get(ctx context.Context) (*tg.AccountEmojiStatuses, error) { + if _, err := s.Fetch(ctx); err != nil { + return nil, err + } + + return s.Value(), nil +} + +// Fetch updates data if needed and returns true if data was modified. +func (s *AccountGetRecentEmojiStatuses) Fetch(ctx context.Context) (bool, error) { + lastHash := s.Hash() + + req := lastHash + result, err := s.raw.AccountGetRecentEmojiStatuses(ctx, req) + if err != nil { + return false, errors.Wrap(err, "execute AccountGetRecentEmojiStatuses") + } + + switch variant := result.(type) { + case *tg.AccountEmojiStatuses: + hash := variant.Hash + + s.store(innerAccountGetRecentEmojiStatuses{ + hash: hash, + value: variant, + }) + return true, nil + case *tg.AccountEmojiStatusesNotModified: + if lastHash == 0 { + return false, errors.Errorf("got unexpected %T result", result) + } + return false, nil + default: + return false, errors.Errorf("unexpected type %T", result) + } +} + type innerAccountGetSavedRingtones struct { // Last received hash. hash int64 @@ -1026,6 +1194,94 @@ func (s *MessagesGetMaskStickers) Fetch(ctx context.Context) (bool, error) { } } +type innerMessagesGetRecentReactions struct { + // Last received hash. + hash int64 + // Last received result. + value *tg.MessagesReactions +} + +type MessagesGetRecentReactions struct { + // Query to send. + req *tg.MessagesGetRecentReactionsRequest + // Result state. + last atomic.Value + + // Reference to RPC client to make requests. + raw *tg.Client +} + +// NewMessagesGetRecentReactions creates new MessagesGetRecentReactions. +func NewMessagesGetRecentReactions(raw *tg.Client, initial *tg.MessagesGetRecentReactionsRequest) *MessagesGetRecentReactions { + q := &MessagesGetRecentReactions{ + req: initial, + raw: raw, + } + + return q +} + +func (s *MessagesGetRecentReactions) store(v innerMessagesGetRecentReactions) { + s.last.Store(v) +} + +func (s *MessagesGetRecentReactions) load() (innerMessagesGetRecentReactions, bool) { + v, ok := s.last.Load().(innerMessagesGetRecentReactions) + return v, ok +} + +// Value returns last received result. +// NB: May be nil. Returned MessagesReactions must not be mutated. +func (s *MessagesGetRecentReactions) Value() *tg.MessagesReactions { + inner, _ := s.load() + return inner.value +} + +// Hash returns last received hash. +func (s *MessagesGetRecentReactions) Hash() int64 { + inner, _ := s.load() + return inner.hash +} + +// Get updates data if needed and returns it. +func (s *MessagesGetRecentReactions) Get(ctx context.Context) (*tg.MessagesReactions, error) { + if _, err := s.Fetch(ctx); err != nil { + return nil, err + } + + return s.Value(), nil +} + +// Fetch updates data if needed and returns true if data was modified. +func (s *MessagesGetRecentReactions) Fetch(ctx context.Context) (bool, error) { + lastHash := s.Hash() + + req := s.req + req.Hash = lastHash + result, err := s.raw.MessagesGetRecentReactions(ctx, req) + if err != nil { + return false, errors.Wrap(err, "execute MessagesGetRecentReactions") + } + + switch variant := result.(type) { + case *tg.MessagesReactions: + hash := variant.Hash + + s.store(innerMessagesGetRecentReactions{ + hash: hash, + value: variant, + }) + return true, nil + case *tg.MessagesReactionsNotModified: + if lastHash == 0 { + return false, errors.Errorf("got unexpected %T result", result) + } + return false, nil + default: + return false, errors.Errorf("unexpected type %T", result) + } +} + type innerMessagesGetRecentStickers struct { // Last received hash. hash int64 @@ -1286,6 +1542,94 @@ func (s *MessagesGetStickers) Fetch(ctx context.Context) (bool, error) { } } +type innerMessagesGetTopReactions struct { + // Last received hash. + hash int64 + // Last received result. + value *tg.MessagesReactions +} + +type MessagesGetTopReactions struct { + // Query to send. + req *tg.MessagesGetTopReactionsRequest + // Result state. + last atomic.Value + + // Reference to RPC client to make requests. + raw *tg.Client +} + +// NewMessagesGetTopReactions creates new MessagesGetTopReactions. +func NewMessagesGetTopReactions(raw *tg.Client, initial *tg.MessagesGetTopReactionsRequest) *MessagesGetTopReactions { + q := &MessagesGetTopReactions{ + req: initial, + raw: raw, + } + + return q +} + +func (s *MessagesGetTopReactions) store(v innerMessagesGetTopReactions) { + s.last.Store(v) +} + +func (s *MessagesGetTopReactions) load() (innerMessagesGetTopReactions, bool) { + v, ok := s.last.Load().(innerMessagesGetTopReactions) + return v, ok +} + +// Value returns last received result. +// NB: May be nil. Returned MessagesReactions must not be mutated. +func (s *MessagesGetTopReactions) Value() *tg.MessagesReactions { + inner, _ := s.load() + return inner.value +} + +// Hash returns last received hash. +func (s *MessagesGetTopReactions) Hash() int64 { + inner, _ := s.load() + return inner.hash +} + +// Get updates data if needed and returns it. +func (s *MessagesGetTopReactions) Get(ctx context.Context) (*tg.MessagesReactions, error) { + if _, err := s.Fetch(ctx); err != nil { + return nil, err + } + + return s.Value(), nil +} + +// Fetch updates data if needed and returns true if data was modified. +func (s *MessagesGetTopReactions) Fetch(ctx context.Context) (bool, error) { + lastHash := s.Hash() + + req := s.req + req.Hash = lastHash + result, err := s.raw.MessagesGetTopReactions(ctx, req) + if err != nil { + return false, errors.Wrap(err, "execute MessagesGetTopReactions") + } + + switch variant := result.(type) { + case *tg.MessagesReactions: + hash := variant.Hash + + s.store(innerMessagesGetTopReactions{ + hash: hash, + value: variant, + }) + return true, nil + case *tg.MessagesReactionsNotModified: + if lastHash == 0 { + return false, errors.Errorf("got unexpected %T result", result) + } + return false, nil + default: + return false, errors.Errorf("unexpected type %T", result) + } +} + type innerMessagesSearchStickerSets struct { // Last received hash. hash int64 diff --git a/tg/tl_account_clear_recent_emoji_statuses_gen.go b/tg/tl_account_clear_recent_emoji_statuses_gen.go new file mode 100644 index 0000000000..5b085dffe9 --- /dev/null +++ b/tg/tl_account_clear_recent_emoji_statuses_gen.go @@ -0,0 +1,142 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AccountClearRecentEmojiStatusesRequest represents TL type `account.clearRecentEmojiStatuses#18201aae`. +// +// See https://core.telegram.org/method/account.clearRecentEmojiStatuses for reference. +type AccountClearRecentEmojiStatusesRequest struct { +} + +// AccountClearRecentEmojiStatusesRequestTypeID is TL type id of AccountClearRecentEmojiStatusesRequest. +const AccountClearRecentEmojiStatusesRequestTypeID = 0x18201aae + +// Ensuring interfaces in compile-time for AccountClearRecentEmojiStatusesRequest. +var ( + _ bin.Encoder = &AccountClearRecentEmojiStatusesRequest{} + _ bin.Decoder = &AccountClearRecentEmojiStatusesRequest{} + _ bin.BareEncoder = &AccountClearRecentEmojiStatusesRequest{} + _ bin.BareDecoder = &AccountClearRecentEmojiStatusesRequest{} +) + +func (c *AccountClearRecentEmojiStatusesRequest) Zero() bool { + if c == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (c *AccountClearRecentEmojiStatusesRequest) String() string { + if c == nil { + return "AccountClearRecentEmojiStatusesRequest(nil)" + } + type Alias AccountClearRecentEmojiStatusesRequest + return fmt.Sprintf("AccountClearRecentEmojiStatusesRequest%+v", Alias(*c)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountClearRecentEmojiStatusesRequest) TypeID() uint32 { + return AccountClearRecentEmojiStatusesRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountClearRecentEmojiStatusesRequest) TypeName() string { + return "account.clearRecentEmojiStatuses" +} + +// TypeInfo returns info about TL type. +func (c *AccountClearRecentEmojiStatusesRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.clearRecentEmojiStatuses", + ID: AccountClearRecentEmojiStatusesRequestTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (c *AccountClearRecentEmojiStatusesRequest) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode account.clearRecentEmojiStatuses#18201aae as nil") + } + b.PutID(AccountClearRecentEmojiStatusesRequestTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *AccountClearRecentEmojiStatusesRequest) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode account.clearRecentEmojiStatuses#18201aae as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (c *AccountClearRecentEmojiStatusesRequest) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode account.clearRecentEmojiStatuses#18201aae to nil") + } + if err := b.ConsumeID(AccountClearRecentEmojiStatusesRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.clearRecentEmojiStatuses#18201aae: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *AccountClearRecentEmojiStatusesRequest) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode account.clearRecentEmojiStatuses#18201aae to nil") + } + return nil +} + +// AccountClearRecentEmojiStatuses invokes method account.clearRecentEmojiStatuses#18201aae returning error if any. +// +// See https://core.telegram.org/method/account.clearRecentEmojiStatuses for reference. +func (c *Client) AccountClearRecentEmojiStatuses(ctx context.Context) (bool, error) { + var result BoolBox + + request := &AccountClearRecentEmojiStatusesRequest{} + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return false, err + } + _, ok := result.Bool.(*BoolTrue) + return ok, nil +} diff --git a/tg/tl_payments_request_recurring_payment_slices_gen.go b/tg/tl_account_clear_recent_emoji_statuses_slices_gen.go similarity index 100% rename from tg/tl_payments_request_recurring_payment_slices_gen.go rename to tg/tl_account_clear_recent_emoji_statuses_slices_gen.go diff --git a/tg/tl_account_email_verified_gen.go b/tg/tl_account_email_verified_gen.go new file mode 100644 index 0000000000..4cf5c83b4e --- /dev/null +++ b/tg/tl_account_email_verified_gen.go @@ -0,0 +1,419 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AccountEmailVerified represents TL type `account.emailVerified#2b96cd1b`. +// +// See https://core.telegram.org/constructor/account.emailVerified for reference. +type AccountEmailVerified struct { + // Email field of AccountEmailVerified. + Email string +} + +// AccountEmailVerifiedTypeID is TL type id of AccountEmailVerified. +const AccountEmailVerifiedTypeID = 0x2b96cd1b + +// construct implements constructor of AccountEmailVerifiedClass. +func (e AccountEmailVerified) construct() AccountEmailVerifiedClass { return &e } + +// Ensuring interfaces in compile-time for AccountEmailVerified. +var ( + _ bin.Encoder = &AccountEmailVerified{} + _ bin.Decoder = &AccountEmailVerified{} + _ bin.BareEncoder = &AccountEmailVerified{} + _ bin.BareDecoder = &AccountEmailVerified{} + + _ AccountEmailVerifiedClass = &AccountEmailVerified{} +) + +func (e *AccountEmailVerified) Zero() bool { + if e == nil { + return true + } + if !(e.Email == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *AccountEmailVerified) String() string { + if e == nil { + return "AccountEmailVerified(nil)" + } + type Alias AccountEmailVerified + return fmt.Sprintf("AccountEmailVerified%+v", Alias(*e)) +} + +// FillFrom fills AccountEmailVerified from given interface. +func (e *AccountEmailVerified) FillFrom(from interface { + GetEmail() (value string) +}) { + e.Email = from.GetEmail() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountEmailVerified) TypeID() uint32 { + return AccountEmailVerifiedTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountEmailVerified) TypeName() string { + return "account.emailVerified" +} + +// TypeInfo returns info about TL type. +func (e *AccountEmailVerified) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.emailVerified", + ID: AccountEmailVerifiedTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Email", + SchemaName: "email", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (e *AccountEmailVerified) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode account.emailVerified#2b96cd1b as nil") + } + b.PutID(AccountEmailVerifiedTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *AccountEmailVerified) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode account.emailVerified#2b96cd1b as nil") + } + b.PutString(e.Email) + return nil +} + +// Decode implements bin.Decoder. +func (e *AccountEmailVerified) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode account.emailVerified#2b96cd1b to nil") + } + if err := b.ConsumeID(AccountEmailVerifiedTypeID); err != nil { + return fmt.Errorf("unable to decode account.emailVerified#2b96cd1b: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *AccountEmailVerified) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode account.emailVerified#2b96cd1b to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode account.emailVerified#2b96cd1b: field email: %w", err) + } + e.Email = value + } + return nil +} + +// GetEmail returns value of Email field. +func (e *AccountEmailVerified) GetEmail() (value string) { + if e == nil { + return + } + return e.Email +} + +// AccountEmailVerifiedLogin represents TL type `account.emailVerifiedLogin#e1bb0d61`. +// +// See https://core.telegram.org/constructor/account.emailVerifiedLogin for reference. +type AccountEmailVerifiedLogin struct { + // Email field of AccountEmailVerifiedLogin. + Email string + // SentCode field of AccountEmailVerifiedLogin. + SentCode AuthSentCode +} + +// AccountEmailVerifiedLoginTypeID is TL type id of AccountEmailVerifiedLogin. +const AccountEmailVerifiedLoginTypeID = 0xe1bb0d61 + +// construct implements constructor of AccountEmailVerifiedClass. +func (e AccountEmailVerifiedLogin) construct() AccountEmailVerifiedClass { return &e } + +// Ensuring interfaces in compile-time for AccountEmailVerifiedLogin. +var ( + _ bin.Encoder = &AccountEmailVerifiedLogin{} + _ bin.Decoder = &AccountEmailVerifiedLogin{} + _ bin.BareEncoder = &AccountEmailVerifiedLogin{} + _ bin.BareDecoder = &AccountEmailVerifiedLogin{} + + _ AccountEmailVerifiedClass = &AccountEmailVerifiedLogin{} +) + +func (e *AccountEmailVerifiedLogin) Zero() bool { + if e == nil { + return true + } + if !(e.Email == "") { + return false + } + if !(e.SentCode.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *AccountEmailVerifiedLogin) String() string { + if e == nil { + return "AccountEmailVerifiedLogin(nil)" + } + type Alias AccountEmailVerifiedLogin + return fmt.Sprintf("AccountEmailVerifiedLogin%+v", Alias(*e)) +} + +// FillFrom fills AccountEmailVerifiedLogin from given interface. +func (e *AccountEmailVerifiedLogin) FillFrom(from interface { + GetEmail() (value string) + GetSentCode() (value AuthSentCode) +}) { + e.Email = from.GetEmail() + e.SentCode = from.GetSentCode() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountEmailVerifiedLogin) TypeID() uint32 { + return AccountEmailVerifiedLoginTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountEmailVerifiedLogin) TypeName() string { + return "account.emailVerifiedLogin" +} + +// TypeInfo returns info about TL type. +func (e *AccountEmailVerifiedLogin) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.emailVerifiedLogin", + ID: AccountEmailVerifiedLoginTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Email", + SchemaName: "email", + }, + { + Name: "SentCode", + SchemaName: "sent_code", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (e *AccountEmailVerifiedLogin) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode account.emailVerifiedLogin#e1bb0d61 as nil") + } + b.PutID(AccountEmailVerifiedLoginTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *AccountEmailVerifiedLogin) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode account.emailVerifiedLogin#e1bb0d61 as nil") + } + b.PutString(e.Email) + if err := e.SentCode.Encode(b); err != nil { + return fmt.Errorf("unable to encode account.emailVerifiedLogin#e1bb0d61: field sent_code: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (e *AccountEmailVerifiedLogin) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode account.emailVerifiedLogin#e1bb0d61 to nil") + } + if err := b.ConsumeID(AccountEmailVerifiedLoginTypeID); err != nil { + return fmt.Errorf("unable to decode account.emailVerifiedLogin#e1bb0d61: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *AccountEmailVerifiedLogin) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode account.emailVerifiedLogin#e1bb0d61 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode account.emailVerifiedLogin#e1bb0d61: field email: %w", err) + } + e.Email = value + } + { + if err := e.SentCode.Decode(b); err != nil { + return fmt.Errorf("unable to decode account.emailVerifiedLogin#e1bb0d61: field sent_code: %w", err) + } + } + return nil +} + +// GetEmail returns value of Email field. +func (e *AccountEmailVerifiedLogin) GetEmail() (value string) { + if e == nil { + return + } + return e.Email +} + +// GetSentCode returns value of SentCode field. +func (e *AccountEmailVerifiedLogin) GetSentCode() (value AuthSentCode) { + if e == nil { + return + } + return e.SentCode +} + +// AccountEmailVerifiedClassName is schema name of AccountEmailVerifiedClass. +const AccountEmailVerifiedClassName = "account.EmailVerified" + +// AccountEmailVerifiedClass represents account.EmailVerified generic type. +// +// See https://core.telegram.org/type/account.EmailVerified for reference. +// +// Example: +// +// g, err := tg.DecodeAccountEmailVerified(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.AccountEmailVerified: // account.emailVerified#2b96cd1b +// case *tg.AccountEmailVerifiedLogin: // account.emailVerifiedLogin#e1bb0d61 +// default: panic(v) +// } +type AccountEmailVerifiedClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() AccountEmailVerifiedClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool + + // Email field of AccountEmailVerified. + GetEmail() (value string) +} + +// DecodeAccountEmailVerified implements binary de-serialization for AccountEmailVerifiedClass. +func DecodeAccountEmailVerified(buf *bin.Buffer) (AccountEmailVerifiedClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case AccountEmailVerifiedTypeID: + // Decoding account.emailVerified#2b96cd1b. + v := AccountEmailVerified{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AccountEmailVerifiedClass: %w", err) + } + return &v, nil + case AccountEmailVerifiedLoginTypeID: + // Decoding account.emailVerifiedLogin#e1bb0d61. + v := AccountEmailVerifiedLogin{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AccountEmailVerifiedClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode AccountEmailVerifiedClass: %w", bin.NewUnexpectedID(id)) + } +} + +// AccountEmailVerified boxes the AccountEmailVerifiedClass providing a helper. +type AccountEmailVerifiedBox struct { + EmailVerified AccountEmailVerifiedClass +} + +// Decode implements bin.Decoder for AccountEmailVerifiedBox. +func (b *AccountEmailVerifiedBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode AccountEmailVerifiedBox to nil") + } + v, err := DecodeAccountEmailVerified(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.EmailVerified = v + return nil +} + +// Encode implements bin.Encode for AccountEmailVerifiedBox. +func (b *AccountEmailVerifiedBox) Encode(buf *bin.Buffer) error { + if b == nil || b.EmailVerified == nil { + return fmt.Errorf("unable to encode AccountEmailVerifiedClass as nil") + } + return b.EmailVerified.Encode(buf) +} diff --git a/tg/tl_account_email_verified_slices_gen.go b/tg/tl_account_email_verified_slices_gen.go new file mode 100644 index 0000000000..96be66b80b --- /dev/null +++ b/tg/tl_account_email_verified_slices_gen.go @@ -0,0 +1,307 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AccountEmailVerifiedClassArray is adapter for slice of AccountEmailVerifiedClass. +type AccountEmailVerifiedClassArray []AccountEmailVerifiedClass + +// Sort sorts slice of AccountEmailVerifiedClass. +func (s AccountEmailVerifiedClassArray) Sort(less func(a, b AccountEmailVerifiedClass) bool) AccountEmailVerifiedClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AccountEmailVerifiedClass. +func (s AccountEmailVerifiedClassArray) SortStable(less func(a, b AccountEmailVerifiedClass) bool) AccountEmailVerifiedClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AccountEmailVerifiedClass. +func (s AccountEmailVerifiedClassArray) Retain(keep func(x AccountEmailVerifiedClass) bool) AccountEmailVerifiedClassArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s AccountEmailVerifiedClassArray) First() (v AccountEmailVerifiedClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AccountEmailVerifiedClassArray) Last() (v AccountEmailVerifiedClass, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *AccountEmailVerifiedClassArray) PopFirst() (v AccountEmailVerifiedClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero AccountEmailVerifiedClass + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *AccountEmailVerifiedClassArray) Pop() (v AccountEmailVerifiedClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// AsAccountEmailVerified returns copy with only AccountEmailVerified constructors. +func (s AccountEmailVerifiedClassArray) AsAccountEmailVerified() (to AccountEmailVerifiedArray) { + for _, elem := range s { + value, ok := elem.(*AccountEmailVerified) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsAccountEmailVerifiedLogin returns copy with only AccountEmailVerifiedLogin constructors. +func (s AccountEmailVerifiedClassArray) AsAccountEmailVerifiedLogin() (to AccountEmailVerifiedLoginArray) { + for _, elem := range s { + value, ok := elem.(*AccountEmailVerifiedLogin) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AccountEmailVerifiedArray is adapter for slice of AccountEmailVerified. +type AccountEmailVerifiedArray []AccountEmailVerified + +// Sort sorts slice of AccountEmailVerified. +func (s AccountEmailVerifiedArray) Sort(less func(a, b AccountEmailVerified) bool) AccountEmailVerifiedArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AccountEmailVerified. +func (s AccountEmailVerifiedArray) SortStable(less func(a, b AccountEmailVerified) bool) AccountEmailVerifiedArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AccountEmailVerified. +func (s AccountEmailVerifiedArray) Retain(keep func(x AccountEmailVerified) bool) AccountEmailVerifiedArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s AccountEmailVerifiedArray) First() (v AccountEmailVerified, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AccountEmailVerifiedArray) Last() (v AccountEmailVerified, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *AccountEmailVerifiedArray) PopFirst() (v AccountEmailVerified, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero AccountEmailVerified + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *AccountEmailVerifiedArray) Pop() (v AccountEmailVerified, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// AccountEmailVerifiedLoginArray is adapter for slice of AccountEmailVerifiedLogin. +type AccountEmailVerifiedLoginArray []AccountEmailVerifiedLogin + +// Sort sorts slice of AccountEmailVerifiedLogin. +func (s AccountEmailVerifiedLoginArray) Sort(less func(a, b AccountEmailVerifiedLogin) bool) AccountEmailVerifiedLoginArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AccountEmailVerifiedLogin. +func (s AccountEmailVerifiedLoginArray) SortStable(less func(a, b AccountEmailVerifiedLogin) bool) AccountEmailVerifiedLoginArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AccountEmailVerifiedLogin. +func (s AccountEmailVerifiedLoginArray) Retain(keep func(x AccountEmailVerifiedLogin) bool) AccountEmailVerifiedLoginArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s AccountEmailVerifiedLoginArray) First() (v AccountEmailVerifiedLogin, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AccountEmailVerifiedLoginArray) Last() (v AccountEmailVerifiedLogin, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *AccountEmailVerifiedLoginArray) PopFirst() (v AccountEmailVerifiedLogin, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero AccountEmailVerifiedLogin + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *AccountEmailVerifiedLoginArray) Pop() (v AccountEmailVerifiedLogin, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_account_emoji_statuses_gen.go b/tg/tl_account_emoji_statuses_gen.go new file mode 100644 index 0000000000..9a76360c56 --- /dev/null +++ b/tg/tl_account_emoji_statuses_gen.go @@ -0,0 +1,419 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AccountEmojiStatusesNotModified represents TL type `account.emojiStatusesNotModified#d08ce645`. +// +// See https://core.telegram.org/constructor/account.emojiStatusesNotModified for reference. +type AccountEmojiStatusesNotModified struct { +} + +// AccountEmojiStatusesNotModifiedTypeID is TL type id of AccountEmojiStatusesNotModified. +const AccountEmojiStatusesNotModifiedTypeID = 0xd08ce645 + +// construct implements constructor of AccountEmojiStatusesClass. +func (e AccountEmojiStatusesNotModified) construct() AccountEmojiStatusesClass { return &e } + +// Ensuring interfaces in compile-time for AccountEmojiStatusesNotModified. +var ( + _ bin.Encoder = &AccountEmojiStatusesNotModified{} + _ bin.Decoder = &AccountEmojiStatusesNotModified{} + _ bin.BareEncoder = &AccountEmojiStatusesNotModified{} + _ bin.BareDecoder = &AccountEmojiStatusesNotModified{} + + _ AccountEmojiStatusesClass = &AccountEmojiStatusesNotModified{} +) + +func (e *AccountEmojiStatusesNotModified) Zero() bool { + if e == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (e *AccountEmojiStatusesNotModified) String() string { + if e == nil { + return "AccountEmojiStatusesNotModified(nil)" + } + type Alias AccountEmojiStatusesNotModified + return fmt.Sprintf("AccountEmojiStatusesNotModified%+v", Alias(*e)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountEmojiStatusesNotModified) TypeID() uint32 { + return AccountEmojiStatusesNotModifiedTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountEmojiStatusesNotModified) TypeName() string { + return "account.emojiStatusesNotModified" +} + +// TypeInfo returns info about TL type. +func (e *AccountEmojiStatusesNotModified) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.emojiStatusesNotModified", + ID: AccountEmojiStatusesNotModifiedTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (e *AccountEmojiStatusesNotModified) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode account.emojiStatusesNotModified#d08ce645 as nil") + } + b.PutID(AccountEmojiStatusesNotModifiedTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *AccountEmojiStatusesNotModified) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode account.emojiStatusesNotModified#d08ce645 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (e *AccountEmojiStatusesNotModified) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode account.emojiStatusesNotModified#d08ce645 to nil") + } + if err := b.ConsumeID(AccountEmojiStatusesNotModifiedTypeID); err != nil { + return fmt.Errorf("unable to decode account.emojiStatusesNotModified#d08ce645: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *AccountEmojiStatusesNotModified) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode account.emojiStatusesNotModified#d08ce645 to nil") + } + return nil +} + +// AccountEmojiStatuses represents TL type `account.emojiStatuses#90c467d1`. +// +// See https://core.telegram.org/constructor/account.emojiStatuses for reference. +type AccountEmojiStatuses struct { + // Hash field of AccountEmojiStatuses. + Hash int64 + // Statuses field of AccountEmojiStatuses. + Statuses []EmojiStatusClass +} + +// AccountEmojiStatusesTypeID is TL type id of AccountEmojiStatuses. +const AccountEmojiStatusesTypeID = 0x90c467d1 + +// construct implements constructor of AccountEmojiStatusesClass. +func (e AccountEmojiStatuses) construct() AccountEmojiStatusesClass { return &e } + +// Ensuring interfaces in compile-time for AccountEmojiStatuses. +var ( + _ bin.Encoder = &AccountEmojiStatuses{} + _ bin.Decoder = &AccountEmojiStatuses{} + _ bin.BareEncoder = &AccountEmojiStatuses{} + _ bin.BareDecoder = &AccountEmojiStatuses{} + + _ AccountEmojiStatusesClass = &AccountEmojiStatuses{} +) + +func (e *AccountEmojiStatuses) Zero() bool { + if e == nil { + return true + } + if !(e.Hash == 0) { + return false + } + if !(e.Statuses == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *AccountEmojiStatuses) String() string { + if e == nil { + return "AccountEmojiStatuses(nil)" + } + type Alias AccountEmojiStatuses + return fmt.Sprintf("AccountEmojiStatuses%+v", Alias(*e)) +} + +// FillFrom fills AccountEmojiStatuses from given interface. +func (e *AccountEmojiStatuses) FillFrom(from interface { + GetHash() (value int64) + GetStatuses() (value []EmojiStatusClass) +}) { + e.Hash = from.GetHash() + e.Statuses = from.GetStatuses() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountEmojiStatuses) TypeID() uint32 { + return AccountEmojiStatusesTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountEmojiStatuses) TypeName() string { + return "account.emojiStatuses" +} + +// TypeInfo returns info about TL type. +func (e *AccountEmojiStatuses) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.emojiStatuses", + ID: AccountEmojiStatusesTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + { + Name: "Statuses", + SchemaName: "statuses", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (e *AccountEmojiStatuses) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode account.emojiStatuses#90c467d1 as nil") + } + b.PutID(AccountEmojiStatusesTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *AccountEmojiStatuses) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode account.emojiStatuses#90c467d1 as nil") + } + b.PutLong(e.Hash) + b.PutVectorHeader(len(e.Statuses)) + for idx, v := range e.Statuses { + if v == nil { + return fmt.Errorf("unable to encode account.emojiStatuses#90c467d1: field statuses element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode account.emojiStatuses#90c467d1: field statuses element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (e *AccountEmojiStatuses) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode account.emojiStatuses#90c467d1 to nil") + } + if err := b.ConsumeID(AccountEmojiStatusesTypeID); err != nil { + return fmt.Errorf("unable to decode account.emojiStatuses#90c467d1: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *AccountEmojiStatuses) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode account.emojiStatuses#90c467d1 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode account.emojiStatuses#90c467d1: field hash: %w", err) + } + e.Hash = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode account.emojiStatuses#90c467d1: field statuses: %w", err) + } + + if headerLen > 0 { + e.Statuses = make([]EmojiStatusClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeEmojiStatus(b) + if err != nil { + return fmt.Errorf("unable to decode account.emojiStatuses#90c467d1: field statuses: %w", err) + } + e.Statuses = append(e.Statuses, value) + } + } + return nil +} + +// GetHash returns value of Hash field. +func (e *AccountEmojiStatuses) GetHash() (value int64) { + if e == nil { + return + } + return e.Hash +} + +// GetStatuses returns value of Statuses field. +func (e *AccountEmojiStatuses) GetStatuses() (value []EmojiStatusClass) { + if e == nil { + return + } + return e.Statuses +} + +// MapStatuses returns field Statuses wrapped in EmojiStatusClassArray helper. +func (e *AccountEmojiStatuses) MapStatuses() (value EmojiStatusClassArray) { + return EmojiStatusClassArray(e.Statuses) +} + +// AccountEmojiStatusesClassName is schema name of AccountEmojiStatusesClass. +const AccountEmojiStatusesClassName = "account.EmojiStatuses" + +// AccountEmojiStatusesClass represents account.EmojiStatuses generic type. +// +// See https://core.telegram.org/type/account.EmojiStatuses for reference. +// +// Example: +// +// g, err := tg.DecodeAccountEmojiStatuses(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.AccountEmojiStatusesNotModified: // account.emojiStatusesNotModified#d08ce645 +// case *tg.AccountEmojiStatuses: // account.emojiStatuses#90c467d1 +// default: panic(v) +// } +type AccountEmojiStatusesClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() AccountEmojiStatusesClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool + + // AsModified tries to map AccountEmojiStatusesClass to AccountEmojiStatuses. + AsModified() (*AccountEmojiStatuses, bool) +} + +// AsModified tries to map AccountEmojiStatusesNotModified to AccountEmojiStatuses. +func (e *AccountEmojiStatusesNotModified) AsModified() (*AccountEmojiStatuses, bool) { + return nil, false +} + +// AsModified tries to map AccountEmojiStatuses to AccountEmojiStatuses. +func (e *AccountEmojiStatuses) AsModified() (*AccountEmojiStatuses, bool) { + return e, true +} + +// DecodeAccountEmojiStatuses implements binary de-serialization for AccountEmojiStatusesClass. +func DecodeAccountEmojiStatuses(buf *bin.Buffer) (AccountEmojiStatusesClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case AccountEmojiStatusesNotModifiedTypeID: + // Decoding account.emojiStatusesNotModified#d08ce645. + v := AccountEmojiStatusesNotModified{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AccountEmojiStatusesClass: %w", err) + } + return &v, nil + case AccountEmojiStatusesTypeID: + // Decoding account.emojiStatuses#90c467d1. + v := AccountEmojiStatuses{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AccountEmojiStatusesClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode AccountEmojiStatusesClass: %w", bin.NewUnexpectedID(id)) + } +} + +// AccountEmojiStatuses boxes the AccountEmojiStatusesClass providing a helper. +type AccountEmojiStatusesBox struct { + EmojiStatuses AccountEmojiStatusesClass +} + +// Decode implements bin.Decoder for AccountEmojiStatusesBox. +func (b *AccountEmojiStatusesBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode AccountEmojiStatusesBox to nil") + } + v, err := DecodeAccountEmojiStatuses(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.EmojiStatuses = v + return nil +} + +// Encode implements bin.Encode for AccountEmojiStatusesBox. +func (b *AccountEmojiStatusesBox) Encode(buf *bin.Buffer) error { + if b == nil || b.EmojiStatuses == nil { + return fmt.Errorf("unable to encode AccountEmojiStatusesClass as nil") + } + return b.EmojiStatuses.Encode(buf) +} diff --git a/tg/tl_account_emoji_statuses_slices_gen.go b/tg/tl_account_emoji_statuses_slices_gen.go new file mode 100644 index 0000000000..fea51ead7a --- /dev/null +++ b/tg/tl_account_emoji_statuses_slices_gen.go @@ -0,0 +1,267 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AccountEmojiStatusesClassArray is adapter for slice of AccountEmojiStatusesClass. +type AccountEmojiStatusesClassArray []AccountEmojiStatusesClass + +// Sort sorts slice of AccountEmojiStatusesClass. +func (s AccountEmojiStatusesClassArray) Sort(less func(a, b AccountEmojiStatusesClass) bool) AccountEmojiStatusesClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AccountEmojiStatusesClass. +func (s AccountEmojiStatusesClassArray) SortStable(less func(a, b AccountEmojiStatusesClass) bool) AccountEmojiStatusesClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AccountEmojiStatusesClass. +func (s AccountEmojiStatusesClassArray) Retain(keep func(x AccountEmojiStatusesClass) bool) AccountEmojiStatusesClassArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s AccountEmojiStatusesClassArray) First() (v AccountEmojiStatusesClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AccountEmojiStatusesClassArray) Last() (v AccountEmojiStatusesClass, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *AccountEmojiStatusesClassArray) PopFirst() (v AccountEmojiStatusesClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero AccountEmojiStatusesClass + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *AccountEmojiStatusesClassArray) Pop() (v AccountEmojiStatusesClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// AsAccountEmojiStatuses returns copy with only AccountEmojiStatuses constructors. +func (s AccountEmojiStatusesClassArray) AsAccountEmojiStatuses() (to AccountEmojiStatusesArray) { + for _, elem := range s { + value, ok := elem.(*AccountEmojiStatuses) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AppendOnlyModified appends only Modified constructors to +// given slice. +func (s AccountEmojiStatusesClassArray) AppendOnlyModified(to []*AccountEmojiStatuses) []*AccountEmojiStatuses { + for _, elem := range s { + value, ok := elem.AsModified() + if !ok { + continue + } + to = append(to, value) + } + + return to +} + +// AsModified returns copy with only Modified constructors. +func (s AccountEmojiStatusesClassArray) AsModified() (to []*AccountEmojiStatuses) { + return s.AppendOnlyModified(to) +} + +// FirstAsModified returns first element of slice (if exists). +func (s AccountEmojiStatusesClassArray) FirstAsModified() (v *AccountEmojiStatuses, ok bool) { + value, ok := s.First() + if !ok { + return + } + return value.AsModified() +} + +// LastAsModified returns last element of slice (if exists). +func (s AccountEmojiStatusesClassArray) LastAsModified() (v *AccountEmojiStatuses, ok bool) { + value, ok := s.Last() + if !ok { + return + } + return value.AsModified() +} + +// PopFirstAsModified returns element of slice (if exists). +func (s *AccountEmojiStatusesClassArray) PopFirstAsModified() (v *AccountEmojiStatuses, ok bool) { + value, ok := s.PopFirst() + if !ok { + return + } + return value.AsModified() +} + +// PopAsModified returns element of slice (if exists). +func (s *AccountEmojiStatusesClassArray) PopAsModified() (v *AccountEmojiStatuses, ok bool) { + value, ok := s.Pop() + if !ok { + return + } + return value.AsModified() +} + +// AccountEmojiStatusesArray is adapter for slice of AccountEmojiStatuses. +type AccountEmojiStatusesArray []AccountEmojiStatuses + +// Sort sorts slice of AccountEmojiStatuses. +func (s AccountEmojiStatusesArray) Sort(less func(a, b AccountEmojiStatuses) bool) AccountEmojiStatusesArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AccountEmojiStatuses. +func (s AccountEmojiStatusesArray) SortStable(less func(a, b AccountEmojiStatuses) bool) AccountEmojiStatusesArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AccountEmojiStatuses. +func (s AccountEmojiStatusesArray) Retain(keep func(x AccountEmojiStatuses) bool) AccountEmojiStatusesArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s AccountEmojiStatusesArray) First() (v AccountEmojiStatuses, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AccountEmojiStatusesArray) Last() (v AccountEmojiStatuses, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *AccountEmojiStatusesArray) PopFirst() (v AccountEmojiStatuses, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero AccountEmojiStatuses + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *AccountEmojiStatusesArray) Pop() (v AccountEmojiStatuses, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_account_get_default_emoji_statuses_gen.go b/tg/tl_account_get_default_emoji_statuses_gen.go new file mode 100644 index 0000000000..9336cb55d4 --- /dev/null +++ b/tg/tl_account_get_default_emoji_statuses_gen.go @@ -0,0 +1,176 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AccountGetDefaultEmojiStatusesRequest represents TL type `account.getDefaultEmojiStatuses#d6753386`. +// +// See https://core.telegram.org/method/account.getDefaultEmojiStatuses for reference. +type AccountGetDefaultEmojiStatusesRequest struct { + // Hash field of AccountGetDefaultEmojiStatusesRequest. + Hash int64 +} + +// AccountGetDefaultEmojiStatusesRequestTypeID is TL type id of AccountGetDefaultEmojiStatusesRequest. +const AccountGetDefaultEmojiStatusesRequestTypeID = 0xd6753386 + +// Ensuring interfaces in compile-time for AccountGetDefaultEmojiStatusesRequest. +var ( + _ bin.Encoder = &AccountGetDefaultEmojiStatusesRequest{} + _ bin.Decoder = &AccountGetDefaultEmojiStatusesRequest{} + _ bin.BareEncoder = &AccountGetDefaultEmojiStatusesRequest{} + _ bin.BareDecoder = &AccountGetDefaultEmojiStatusesRequest{} +) + +func (g *AccountGetDefaultEmojiStatusesRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *AccountGetDefaultEmojiStatusesRequest) String() string { + if g == nil { + return "AccountGetDefaultEmojiStatusesRequest(nil)" + } + type Alias AccountGetDefaultEmojiStatusesRequest + return fmt.Sprintf("AccountGetDefaultEmojiStatusesRequest%+v", Alias(*g)) +} + +// FillFrom fills AccountGetDefaultEmojiStatusesRequest from given interface. +func (g *AccountGetDefaultEmojiStatusesRequest) FillFrom(from interface { + GetHash() (value int64) +}) { + g.Hash = from.GetHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountGetDefaultEmojiStatusesRequest) TypeID() uint32 { + return AccountGetDefaultEmojiStatusesRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountGetDefaultEmojiStatusesRequest) TypeName() string { + return "account.getDefaultEmojiStatuses" +} + +// TypeInfo returns info about TL type. +func (g *AccountGetDefaultEmojiStatusesRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.getDefaultEmojiStatuses", + ID: AccountGetDefaultEmojiStatusesRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *AccountGetDefaultEmojiStatusesRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode account.getDefaultEmojiStatuses#d6753386 as nil") + } + b.PutID(AccountGetDefaultEmojiStatusesRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *AccountGetDefaultEmojiStatusesRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode account.getDefaultEmojiStatuses#d6753386 as nil") + } + b.PutLong(g.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (g *AccountGetDefaultEmojiStatusesRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode account.getDefaultEmojiStatuses#d6753386 to nil") + } + if err := b.ConsumeID(AccountGetDefaultEmojiStatusesRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.getDefaultEmojiStatuses#d6753386: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *AccountGetDefaultEmojiStatusesRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode account.getDefaultEmojiStatuses#d6753386 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode account.getDefaultEmojiStatuses#d6753386: field hash: %w", err) + } + g.Hash = value + } + return nil +} + +// GetHash returns value of Hash field. +func (g *AccountGetDefaultEmojiStatusesRequest) GetHash() (value int64) { + if g == nil { + return + } + return g.Hash +} + +// AccountGetDefaultEmojiStatuses invokes method account.getDefaultEmojiStatuses#d6753386 returning error if any. +// +// See https://core.telegram.org/method/account.getDefaultEmojiStatuses for reference. +func (c *Client) AccountGetDefaultEmojiStatuses(ctx context.Context, hash int64) (AccountEmojiStatusesClass, error) { + var result AccountEmojiStatusesBox + + request := &AccountGetDefaultEmojiStatusesRequest{ + Hash: hash, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.EmojiStatuses, nil +} diff --git a/tg/tl_account_get_default_emoji_statuses_slices_gen.go b/tg/tl_account_get_default_emoji_statuses_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_account_get_default_emoji_statuses_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_account_get_recent_emoji_statuses_gen.go b/tg/tl_account_get_recent_emoji_statuses_gen.go new file mode 100644 index 0000000000..e27941f403 --- /dev/null +++ b/tg/tl_account_get_recent_emoji_statuses_gen.go @@ -0,0 +1,176 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AccountGetRecentEmojiStatusesRequest represents TL type `account.getRecentEmojiStatuses#f578105`. +// +// See https://core.telegram.org/method/account.getRecentEmojiStatuses for reference. +type AccountGetRecentEmojiStatusesRequest struct { + // Hash field of AccountGetRecentEmojiStatusesRequest. + Hash int64 +} + +// AccountGetRecentEmojiStatusesRequestTypeID is TL type id of AccountGetRecentEmojiStatusesRequest. +const AccountGetRecentEmojiStatusesRequestTypeID = 0xf578105 + +// Ensuring interfaces in compile-time for AccountGetRecentEmojiStatusesRequest. +var ( + _ bin.Encoder = &AccountGetRecentEmojiStatusesRequest{} + _ bin.Decoder = &AccountGetRecentEmojiStatusesRequest{} + _ bin.BareEncoder = &AccountGetRecentEmojiStatusesRequest{} + _ bin.BareDecoder = &AccountGetRecentEmojiStatusesRequest{} +) + +func (g *AccountGetRecentEmojiStatusesRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *AccountGetRecentEmojiStatusesRequest) String() string { + if g == nil { + return "AccountGetRecentEmojiStatusesRequest(nil)" + } + type Alias AccountGetRecentEmojiStatusesRequest + return fmt.Sprintf("AccountGetRecentEmojiStatusesRequest%+v", Alias(*g)) +} + +// FillFrom fills AccountGetRecentEmojiStatusesRequest from given interface. +func (g *AccountGetRecentEmojiStatusesRequest) FillFrom(from interface { + GetHash() (value int64) +}) { + g.Hash = from.GetHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountGetRecentEmojiStatusesRequest) TypeID() uint32 { + return AccountGetRecentEmojiStatusesRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountGetRecentEmojiStatusesRequest) TypeName() string { + return "account.getRecentEmojiStatuses" +} + +// TypeInfo returns info about TL type. +func (g *AccountGetRecentEmojiStatusesRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.getRecentEmojiStatuses", + ID: AccountGetRecentEmojiStatusesRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *AccountGetRecentEmojiStatusesRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode account.getRecentEmojiStatuses#f578105 as nil") + } + b.PutID(AccountGetRecentEmojiStatusesRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *AccountGetRecentEmojiStatusesRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode account.getRecentEmojiStatuses#f578105 as nil") + } + b.PutLong(g.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (g *AccountGetRecentEmojiStatusesRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode account.getRecentEmojiStatuses#f578105 to nil") + } + if err := b.ConsumeID(AccountGetRecentEmojiStatusesRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.getRecentEmojiStatuses#f578105: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *AccountGetRecentEmojiStatusesRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode account.getRecentEmojiStatuses#f578105 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode account.getRecentEmojiStatuses#f578105: field hash: %w", err) + } + g.Hash = value + } + return nil +} + +// GetHash returns value of Hash field. +func (g *AccountGetRecentEmojiStatusesRequest) GetHash() (value int64) { + if g == nil { + return + } + return g.Hash +} + +// AccountGetRecentEmojiStatuses invokes method account.getRecentEmojiStatuses#f578105 returning error if any. +// +// See https://core.telegram.org/method/account.getRecentEmojiStatuses for reference. +func (c *Client) AccountGetRecentEmojiStatuses(ctx context.Context, hash int64) (AccountEmojiStatusesClass, error) { + var result AccountEmojiStatusesBox + + request := &AccountGetRecentEmojiStatusesRequest{ + Hash: hash, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.EmojiStatuses, nil +} diff --git a/tg/tl_account_get_recent_emoji_statuses_slices_gen.go b/tg/tl_account_get_recent_emoji_statuses_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_account_get_recent_emoji_statuses_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_account_password_gen.go b/tg/tl_account_password_gen.go index 9832da257b..6aad5bec5f 100644 --- a/tg/tl_account_password_gen.go +++ b/tg/tl_account_password_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// AccountPassword represents TL type `account.password#185b184f`. +// AccountPassword represents TL type `account.password#957b50fb`. // Configuration for two-factor authorization // // See https://core.telegram.org/constructor/account.password for reference. @@ -102,10 +102,14 @@ type AccountPassword struct { // // Use SetPendingResetDate and GetPendingResetDate helpers. PendingResetDate int + // LoginEmailPattern field of AccountPassword. + // + // Use SetLoginEmailPattern and GetLoginEmailPattern helpers. + LoginEmailPattern string } // AccountPasswordTypeID is TL type id of AccountPassword. -const AccountPasswordTypeID = 0x185b184f +const AccountPasswordTypeID = 0x957b50fb // Ensuring interfaces in compile-time for AccountPassword. var ( @@ -158,6 +162,9 @@ func (p *AccountPassword) Zero() bool { if !(p.PendingResetDate == 0) { return false } + if !(p.LoginEmailPattern == "") { + return false + } return true } @@ -185,6 +192,7 @@ func (p *AccountPassword) FillFrom(from interface { GetNewSecureAlgo() (value SecurePasswordKdfAlgoClass) GetSecureRandom() (value []byte) GetPendingResetDate() (value int, ok bool) + GetLoginEmailPattern() (value string, ok bool) }) { p.HasRecovery = from.GetHasRecovery() p.HasSecureValues = from.GetHasSecureValues() @@ -216,6 +224,10 @@ func (p *AccountPassword) FillFrom(from interface { p.PendingResetDate = val } + if val, ok := from.GetLoginEmailPattern(); ok { + p.LoginEmailPattern = val + } + } // TypeID returns type id in TL schema. @@ -298,6 +310,11 @@ func (p *AccountPassword) TypeInfo() tdp.Type { SchemaName: "pending_reset_date", Null: !p.Flags.Has(5), }, + { + Name: "LoginEmailPattern", + SchemaName: "login_email_pattern", + Null: !p.Flags.Has(6), + }, } return typ } @@ -331,12 +348,15 @@ func (p *AccountPassword) SetFlags() { if !(p.PendingResetDate == 0) { p.Flags.Set(5) } + if !(p.LoginEmailPattern == "") { + p.Flags.Set(6) + } } // Encode implements bin.Encoder. func (p *AccountPassword) Encode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode account.password#185b184f as nil") + return fmt.Errorf("can't encode account.password#957b50fb as nil") } b.PutID(AccountPasswordTypeID) return p.EncodeBare(b) @@ -345,18 +365,18 @@ func (p *AccountPassword) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (p *AccountPassword) EncodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode account.password#185b184f as nil") + return fmt.Errorf("can't encode account.password#957b50fb as nil") } p.SetFlags() if err := p.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode account.password#185b184f: field flags: %w", err) + return fmt.Errorf("unable to encode account.password#957b50fb: field flags: %w", err) } if p.Flags.Has(2) { if p.CurrentAlgo == nil { - return fmt.Errorf("unable to encode account.password#185b184f: field current_algo is nil") + return fmt.Errorf("unable to encode account.password#957b50fb: field current_algo is nil") } if err := p.CurrentAlgo.Encode(b); err != nil { - return fmt.Errorf("unable to encode account.password#185b184f: field current_algo: %w", err) + return fmt.Errorf("unable to encode account.password#957b50fb: field current_algo: %w", err) } } if p.Flags.Has(2) { @@ -372,31 +392,34 @@ func (p *AccountPassword) EncodeBare(b *bin.Buffer) error { b.PutString(p.EmailUnconfirmedPattern) } if p.NewAlgo == nil { - return fmt.Errorf("unable to encode account.password#185b184f: field new_algo is nil") + return fmt.Errorf("unable to encode account.password#957b50fb: field new_algo is nil") } if err := p.NewAlgo.Encode(b); err != nil { - return fmt.Errorf("unable to encode account.password#185b184f: field new_algo: %w", err) + return fmt.Errorf("unable to encode account.password#957b50fb: field new_algo: %w", err) } if p.NewSecureAlgo == nil { - return fmt.Errorf("unable to encode account.password#185b184f: field new_secure_algo is nil") + return fmt.Errorf("unable to encode account.password#957b50fb: field new_secure_algo is nil") } if err := p.NewSecureAlgo.Encode(b); err != nil { - return fmt.Errorf("unable to encode account.password#185b184f: field new_secure_algo: %w", err) + return fmt.Errorf("unable to encode account.password#957b50fb: field new_secure_algo: %w", err) } b.PutBytes(p.SecureRandom) if p.Flags.Has(5) { b.PutInt(p.PendingResetDate) } + if p.Flags.Has(6) { + b.PutString(p.LoginEmailPattern) + } return nil } // Decode implements bin.Decoder. func (p *AccountPassword) Decode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode account.password#185b184f to nil") + return fmt.Errorf("can't decode account.password#957b50fb to nil") } if err := b.ConsumeID(AccountPasswordTypeID); err != nil { - return fmt.Errorf("unable to decode account.password#185b184f: %w", err) + return fmt.Errorf("unable to decode account.password#957b50fb: %w", err) } return p.DecodeBare(b) } @@ -404,11 +427,11 @@ func (p *AccountPassword) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (p *AccountPassword) DecodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode account.password#185b184f to nil") + return fmt.Errorf("can't decode account.password#957b50fb to nil") } { if err := p.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode account.password#185b184f: field flags: %w", err) + return fmt.Errorf("unable to decode account.password#957b50fb: field flags: %w", err) } } p.HasRecovery = p.Flags.Has(0) @@ -417,66 +440,73 @@ func (p *AccountPassword) DecodeBare(b *bin.Buffer) error { if p.Flags.Has(2) { value, err := DecodePasswordKdfAlgo(b) if err != nil { - return fmt.Errorf("unable to decode account.password#185b184f: field current_algo: %w", err) + return fmt.Errorf("unable to decode account.password#957b50fb: field current_algo: %w", err) } p.CurrentAlgo = value } if p.Flags.Has(2) { value, err := b.Bytes() if err != nil { - return fmt.Errorf("unable to decode account.password#185b184f: field srp_B: %w", err) + return fmt.Errorf("unable to decode account.password#957b50fb: field srp_B: %w", err) } p.SRPB = value } if p.Flags.Has(2) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode account.password#185b184f: field srp_id: %w", err) + return fmt.Errorf("unable to decode account.password#957b50fb: field srp_id: %w", err) } p.SRPID = value } if p.Flags.Has(3) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode account.password#185b184f: field hint: %w", err) + return fmt.Errorf("unable to decode account.password#957b50fb: field hint: %w", err) } p.Hint = value } if p.Flags.Has(4) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode account.password#185b184f: field email_unconfirmed_pattern: %w", err) + return fmt.Errorf("unable to decode account.password#957b50fb: field email_unconfirmed_pattern: %w", err) } p.EmailUnconfirmedPattern = value } { value, err := DecodePasswordKdfAlgo(b) if err != nil { - return fmt.Errorf("unable to decode account.password#185b184f: field new_algo: %w", err) + return fmt.Errorf("unable to decode account.password#957b50fb: field new_algo: %w", err) } p.NewAlgo = value } { value, err := DecodeSecurePasswordKdfAlgo(b) if err != nil { - return fmt.Errorf("unable to decode account.password#185b184f: field new_secure_algo: %w", err) + return fmt.Errorf("unable to decode account.password#957b50fb: field new_secure_algo: %w", err) } p.NewSecureAlgo = value } { value, err := b.Bytes() if err != nil { - return fmt.Errorf("unable to decode account.password#185b184f: field secure_random: %w", err) + return fmt.Errorf("unable to decode account.password#957b50fb: field secure_random: %w", err) } p.SecureRandom = value } if p.Flags.Has(5) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode account.password#185b184f: field pending_reset_date: %w", err) + return fmt.Errorf("unable to decode account.password#957b50fb: field pending_reset_date: %w", err) } p.PendingResetDate = value } + if p.Flags.Has(6) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode account.password#957b50fb: field login_email_pattern: %w", err) + } + p.LoginEmailPattern = value + } return nil } @@ -668,3 +698,21 @@ func (p *AccountPassword) GetPendingResetDate() (value int, ok bool) { } return p.PendingResetDate, true } + +// SetLoginEmailPattern sets value of LoginEmailPattern conditional field. +func (p *AccountPassword) SetLoginEmailPattern(value string) { + p.Flags.Set(6) + p.LoginEmailPattern = value +} + +// GetLoginEmailPattern returns value of LoginEmailPattern conditional field and +// boolean which is true if field was set. +func (p *AccountPassword) GetLoginEmailPattern() (value string, ok bool) { + if p == nil { + return + } + if !p.Flags.Has(6) { + return value, false + } + return p.LoginEmailPattern, true +} diff --git a/tg/tl_account_send_verify_email_code_gen.go b/tg/tl_account_send_verify_email_code_gen.go index 5cd096dbeb..2daa8f5f8f 100644 --- a/tg/tl_account_send_verify_email_code_gen.go +++ b/tg/tl_account_send_verify_email_code_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// AccountSendVerifyEmailCodeRequest represents TL type `account.sendVerifyEmailCode#7011509f`. +// AccountSendVerifyEmailCodeRequest represents TL type `account.sendVerifyEmailCode#98e037bb`. // Send the verification email code for telegram passport¹. // // Links: @@ -39,12 +39,14 @@ var ( // // See https://core.telegram.org/method/account.sendVerifyEmailCode for reference. type AccountSendVerifyEmailCodeRequest struct { + // Purpose field of AccountSendVerifyEmailCodeRequest. + Purpose EmailVerifyPurposeClass // The email where to send the code Email string } // AccountSendVerifyEmailCodeRequestTypeID is TL type id of AccountSendVerifyEmailCodeRequest. -const AccountSendVerifyEmailCodeRequestTypeID = 0x7011509f +const AccountSendVerifyEmailCodeRequestTypeID = 0x98e037bb // Ensuring interfaces in compile-time for AccountSendVerifyEmailCodeRequest. var ( @@ -58,6 +60,9 @@ func (s *AccountSendVerifyEmailCodeRequest) Zero() bool { if s == nil { return true } + if !(s.Purpose == nil) { + return false + } if !(s.Email == "") { return false } @@ -76,8 +81,10 @@ func (s *AccountSendVerifyEmailCodeRequest) String() string { // FillFrom fills AccountSendVerifyEmailCodeRequest from given interface. func (s *AccountSendVerifyEmailCodeRequest) FillFrom(from interface { + GetPurpose() (value EmailVerifyPurposeClass) GetEmail() (value string) }) { + s.Purpose = from.GetPurpose() s.Email = from.GetEmail() } @@ -104,6 +111,10 @@ func (s *AccountSendVerifyEmailCodeRequest) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Purpose", + SchemaName: "purpose", + }, { Name: "Email", SchemaName: "email", @@ -115,7 +126,7 @@ func (s *AccountSendVerifyEmailCodeRequest) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (s *AccountSendVerifyEmailCodeRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode account.sendVerifyEmailCode#7011509f as nil") + return fmt.Errorf("can't encode account.sendVerifyEmailCode#98e037bb as nil") } b.PutID(AccountSendVerifyEmailCodeRequestTypeID) return s.EncodeBare(b) @@ -124,7 +135,13 @@ func (s *AccountSendVerifyEmailCodeRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *AccountSendVerifyEmailCodeRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode account.sendVerifyEmailCode#7011509f as nil") + return fmt.Errorf("can't encode account.sendVerifyEmailCode#98e037bb as nil") + } + if s.Purpose == nil { + return fmt.Errorf("unable to encode account.sendVerifyEmailCode#98e037bb: field purpose is nil") + } + if err := s.Purpose.Encode(b); err != nil { + return fmt.Errorf("unable to encode account.sendVerifyEmailCode#98e037bb: field purpose: %w", err) } b.PutString(s.Email) return nil @@ -133,10 +150,10 @@ func (s *AccountSendVerifyEmailCodeRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *AccountSendVerifyEmailCodeRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode account.sendVerifyEmailCode#7011509f to nil") + return fmt.Errorf("can't decode account.sendVerifyEmailCode#98e037bb to nil") } if err := b.ConsumeID(AccountSendVerifyEmailCodeRequestTypeID); err != nil { - return fmt.Errorf("unable to decode account.sendVerifyEmailCode#7011509f: %w", err) + return fmt.Errorf("unable to decode account.sendVerifyEmailCode#98e037bb: %w", err) } return s.DecodeBare(b) } @@ -144,18 +161,33 @@ func (s *AccountSendVerifyEmailCodeRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *AccountSendVerifyEmailCodeRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode account.sendVerifyEmailCode#7011509f to nil") + return fmt.Errorf("can't decode account.sendVerifyEmailCode#98e037bb to nil") + } + { + value, err := DecodeEmailVerifyPurpose(b) + if err != nil { + return fmt.Errorf("unable to decode account.sendVerifyEmailCode#98e037bb: field purpose: %w", err) + } + s.Purpose = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode account.sendVerifyEmailCode#7011509f: field email: %w", err) + return fmt.Errorf("unable to decode account.sendVerifyEmailCode#98e037bb: field email: %w", err) } s.Email = value } return nil } +// GetPurpose returns value of Purpose field. +func (s *AccountSendVerifyEmailCodeRequest) GetPurpose() (value EmailVerifyPurposeClass) { + if s == nil { + return + } + return s.Purpose +} + // GetEmail returns value of Email field. func (s *AccountSendVerifyEmailCodeRequest) GetEmail() (value string) { if s == nil { @@ -164,7 +196,7 @@ func (s *AccountSendVerifyEmailCodeRequest) GetEmail() (value string) { return s.Email } -// AccountSendVerifyEmailCode invokes method account.sendVerifyEmailCode#7011509f returning error if any. +// AccountSendVerifyEmailCode invokes method account.sendVerifyEmailCode#98e037bb returning error if any. // Send the verification email code for telegram passport¹. // // Links: @@ -175,12 +207,9 @@ func (s *AccountSendVerifyEmailCodeRequest) GetEmail() (value string) { // 400 EMAIL_INVALID: The specified email is invalid. // // See https://core.telegram.org/method/account.sendVerifyEmailCode for reference. -func (c *Client) AccountSendVerifyEmailCode(ctx context.Context, email string) (*AccountSentEmailCode, error) { +func (c *Client) AccountSendVerifyEmailCode(ctx context.Context, request *AccountSendVerifyEmailCodeRequest) (*AccountSentEmailCode, error) { var result AccountSentEmailCode - request := &AccountSendVerifyEmailCodeRequest{ - Email: email, - } if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } diff --git a/tg/tl_account_update_emoji_status_gen.go b/tg/tl_account_update_emoji_status_gen.go new file mode 100644 index 0000000000..43d6e12c0c --- /dev/null +++ b/tg/tl_account_update_emoji_status_gen.go @@ -0,0 +1,187 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AccountUpdateEmojiStatusRequest represents TL type `account.updateEmojiStatus#fbd3de6b`. +// +// See https://core.telegram.org/method/account.updateEmojiStatus for reference. +type AccountUpdateEmojiStatusRequest struct { + // EmojiStatus field of AccountUpdateEmojiStatusRequest. + EmojiStatus EmojiStatusClass +} + +// AccountUpdateEmojiStatusRequestTypeID is TL type id of AccountUpdateEmojiStatusRequest. +const AccountUpdateEmojiStatusRequestTypeID = 0xfbd3de6b + +// Ensuring interfaces in compile-time for AccountUpdateEmojiStatusRequest. +var ( + _ bin.Encoder = &AccountUpdateEmojiStatusRequest{} + _ bin.Decoder = &AccountUpdateEmojiStatusRequest{} + _ bin.BareEncoder = &AccountUpdateEmojiStatusRequest{} + _ bin.BareDecoder = &AccountUpdateEmojiStatusRequest{} +) + +func (u *AccountUpdateEmojiStatusRequest) Zero() bool { + if u == nil { + return true + } + if !(u.EmojiStatus == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *AccountUpdateEmojiStatusRequest) String() string { + if u == nil { + return "AccountUpdateEmojiStatusRequest(nil)" + } + type Alias AccountUpdateEmojiStatusRequest + return fmt.Sprintf("AccountUpdateEmojiStatusRequest%+v", Alias(*u)) +} + +// FillFrom fills AccountUpdateEmojiStatusRequest from given interface. +func (u *AccountUpdateEmojiStatusRequest) FillFrom(from interface { + GetEmojiStatus() (value EmojiStatusClass) +}) { + u.EmojiStatus = from.GetEmojiStatus() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountUpdateEmojiStatusRequest) TypeID() uint32 { + return AccountUpdateEmojiStatusRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountUpdateEmojiStatusRequest) TypeName() string { + return "account.updateEmojiStatus" +} + +// TypeInfo returns info about TL type. +func (u *AccountUpdateEmojiStatusRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.updateEmojiStatus", + ID: AccountUpdateEmojiStatusRequestTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "EmojiStatus", + SchemaName: "emoji_status", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *AccountUpdateEmojiStatusRequest) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode account.updateEmojiStatus#fbd3de6b as nil") + } + b.PutID(AccountUpdateEmojiStatusRequestTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *AccountUpdateEmojiStatusRequest) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode account.updateEmojiStatus#fbd3de6b as nil") + } + if u.EmojiStatus == nil { + return fmt.Errorf("unable to encode account.updateEmojiStatus#fbd3de6b: field emoji_status is nil") + } + if err := u.EmojiStatus.Encode(b); err != nil { + return fmt.Errorf("unable to encode account.updateEmojiStatus#fbd3de6b: field emoji_status: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *AccountUpdateEmojiStatusRequest) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode account.updateEmojiStatus#fbd3de6b to nil") + } + if err := b.ConsumeID(AccountUpdateEmojiStatusRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.updateEmojiStatus#fbd3de6b: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *AccountUpdateEmojiStatusRequest) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode account.updateEmojiStatus#fbd3de6b to nil") + } + { + value, err := DecodeEmojiStatus(b) + if err != nil { + return fmt.Errorf("unable to decode account.updateEmojiStatus#fbd3de6b: field emoji_status: %w", err) + } + u.EmojiStatus = value + } + return nil +} + +// GetEmojiStatus returns value of EmojiStatus field. +func (u *AccountUpdateEmojiStatusRequest) GetEmojiStatus() (value EmojiStatusClass) { + if u == nil { + return + } + return u.EmojiStatus +} + +// GetEmojiStatusAsNotEmpty returns mapped value of EmojiStatus field. +func (u *AccountUpdateEmojiStatusRequest) GetEmojiStatusAsNotEmpty() (NotEmptyEmojiStatus, bool) { + return u.EmojiStatus.AsNotEmpty() +} + +// AccountUpdateEmojiStatus invokes method account.updateEmojiStatus#fbd3de6b returning error if any. +// +// See https://core.telegram.org/method/account.updateEmojiStatus for reference. +func (c *Client) AccountUpdateEmojiStatus(ctx context.Context, emojistatus EmojiStatusClass) (bool, error) { + var result BoolBox + + request := &AccountUpdateEmojiStatusRequest{ + EmojiStatus: emojistatus, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return false, err + } + _, ok := result.Bool.(*BoolTrue) + return ok, nil +} diff --git a/tg/tl_account_update_emoji_status_slices_gen.go b/tg/tl_account_update_emoji_status_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_account_update_emoji_status_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_account_verify_email_gen.go b/tg/tl_account_verify_email_gen.go index 4326a1f5ad..0dadec1193 100644 --- a/tg/tl_account_verify_email_gen.go +++ b/tg/tl_account_verify_email_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// AccountVerifyEmailRequest represents TL type `account.verifyEmail#ecba39db`. +// AccountVerifyEmailRequest represents TL type `account.verifyEmail#32da4cf`. // Verify an email address for telegram passport¹. // // Links: @@ -39,14 +39,14 @@ var ( // // See https://core.telegram.org/method/account.verifyEmail for reference. type AccountVerifyEmailRequest struct { - // The email to verify - Email string - // The verification code that was received - Code string + // Purpose field of AccountVerifyEmailRequest. + Purpose EmailVerifyPurposeClass + // Verification field of AccountVerifyEmailRequest. + Verification EmailVerificationClass } // AccountVerifyEmailRequestTypeID is TL type id of AccountVerifyEmailRequest. -const AccountVerifyEmailRequestTypeID = 0xecba39db +const AccountVerifyEmailRequestTypeID = 0x32da4cf // Ensuring interfaces in compile-time for AccountVerifyEmailRequest. var ( @@ -60,10 +60,10 @@ func (v *AccountVerifyEmailRequest) Zero() bool { if v == nil { return true } - if !(v.Email == "") { + if !(v.Purpose == nil) { return false } - if !(v.Code == "") { + if !(v.Verification == nil) { return false } @@ -81,11 +81,11 @@ func (v *AccountVerifyEmailRequest) String() string { // FillFrom fills AccountVerifyEmailRequest from given interface. func (v *AccountVerifyEmailRequest) FillFrom(from interface { - GetEmail() (value string) - GetCode() (value string) + GetPurpose() (value EmailVerifyPurposeClass) + GetVerification() (value EmailVerificationClass) }) { - v.Email = from.GetEmail() - v.Code = from.GetCode() + v.Purpose = from.GetPurpose() + v.Verification = from.GetVerification() } // TypeID returns type id in TL schema. @@ -112,12 +112,12 @@ func (v *AccountVerifyEmailRequest) TypeInfo() tdp.Type { } typ.Fields = []tdp.Field{ { - Name: "Email", - SchemaName: "email", + Name: "Purpose", + SchemaName: "purpose", }, { - Name: "Code", - SchemaName: "code", + Name: "Verification", + SchemaName: "verification", }, } return typ @@ -126,7 +126,7 @@ func (v *AccountVerifyEmailRequest) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (v *AccountVerifyEmailRequest) Encode(b *bin.Buffer) error { if v == nil { - return fmt.Errorf("can't encode account.verifyEmail#ecba39db as nil") + return fmt.Errorf("can't encode account.verifyEmail#32da4cf as nil") } b.PutID(AccountVerifyEmailRequestTypeID) return v.EncodeBare(b) @@ -135,20 +135,30 @@ func (v *AccountVerifyEmailRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (v *AccountVerifyEmailRequest) EncodeBare(b *bin.Buffer) error { if v == nil { - return fmt.Errorf("can't encode account.verifyEmail#ecba39db as nil") + return fmt.Errorf("can't encode account.verifyEmail#32da4cf as nil") + } + if v.Purpose == nil { + return fmt.Errorf("unable to encode account.verifyEmail#32da4cf: field purpose is nil") + } + if err := v.Purpose.Encode(b); err != nil { + return fmt.Errorf("unable to encode account.verifyEmail#32da4cf: field purpose: %w", err) + } + if v.Verification == nil { + return fmt.Errorf("unable to encode account.verifyEmail#32da4cf: field verification is nil") + } + if err := v.Verification.Encode(b); err != nil { + return fmt.Errorf("unable to encode account.verifyEmail#32da4cf: field verification: %w", err) } - b.PutString(v.Email) - b.PutString(v.Code) return nil } // Decode implements bin.Decoder. func (v *AccountVerifyEmailRequest) Decode(b *bin.Buffer) error { if v == nil { - return fmt.Errorf("can't decode account.verifyEmail#ecba39db to nil") + return fmt.Errorf("can't decode account.verifyEmail#32da4cf to nil") } if err := b.ConsumeID(AccountVerifyEmailRequestTypeID); err != nil { - return fmt.Errorf("unable to decode account.verifyEmail#ecba39db: %w", err) + return fmt.Errorf("unable to decode account.verifyEmail#32da4cf: %w", err) } return v.DecodeBare(b) } @@ -156,42 +166,42 @@ func (v *AccountVerifyEmailRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (v *AccountVerifyEmailRequest) DecodeBare(b *bin.Buffer) error { if v == nil { - return fmt.Errorf("can't decode account.verifyEmail#ecba39db to nil") + return fmt.Errorf("can't decode account.verifyEmail#32da4cf to nil") } { - value, err := b.String() + value, err := DecodeEmailVerifyPurpose(b) if err != nil { - return fmt.Errorf("unable to decode account.verifyEmail#ecba39db: field email: %w", err) + return fmt.Errorf("unable to decode account.verifyEmail#32da4cf: field purpose: %w", err) } - v.Email = value + v.Purpose = value } { - value, err := b.String() + value, err := DecodeEmailVerification(b) if err != nil { - return fmt.Errorf("unable to decode account.verifyEmail#ecba39db: field code: %w", err) + return fmt.Errorf("unable to decode account.verifyEmail#32da4cf: field verification: %w", err) } - v.Code = value + v.Verification = value } return nil } -// GetEmail returns value of Email field. -func (v *AccountVerifyEmailRequest) GetEmail() (value string) { +// GetPurpose returns value of Purpose field. +func (v *AccountVerifyEmailRequest) GetPurpose() (value EmailVerifyPurposeClass) { if v == nil { return } - return v.Email + return v.Purpose } -// GetCode returns value of Code field. -func (v *AccountVerifyEmailRequest) GetCode() (value string) { +// GetVerification returns value of Verification field. +func (v *AccountVerifyEmailRequest) GetVerification() (value EmailVerificationClass) { if v == nil { return } - return v.Code + return v.Verification } -// AccountVerifyEmail invokes method account.verifyEmail#ecba39db returning error if any. +// AccountVerifyEmail invokes method account.verifyEmail#32da4cf returning error if any. // Verify an email address for telegram passport¹. // // Links: @@ -203,12 +213,11 @@ func (v *AccountVerifyEmailRequest) GetCode() (value string) { // 400 EMAIL_VERIFY_EXPIRED: The verification email has expired. // // See https://core.telegram.org/method/account.verifyEmail for reference. -func (c *Client) AccountVerifyEmail(ctx context.Context, request *AccountVerifyEmailRequest) (bool, error) { - var result BoolBox +func (c *Client) AccountVerifyEmail(ctx context.Context, request *AccountVerifyEmailRequest) (AccountEmailVerifiedClass, error) { + var result AccountEmailVerifiedBox if err := c.rpc.Invoke(ctx, request, &result); err != nil { - return false, err + return nil, err } - _, ok := result.Bool.(*BoolTrue) - return ok, nil + return result.EmailVerified, nil } diff --git a/tg/tl_auth_sent_code_type_gen.go b/tg/tl_auth_sent_code_type_gen.go index 2bab539426..e9c9ae6cb5 100644 --- a/tg/tl_auth_sent_code_type_gen.go +++ b/tg/tl_auth_sent_code_type_gen.go @@ -741,6 +741,498 @@ func (s *AuthSentCodeTypeMissedCall) GetLength() (value int) { return s.Length } +// AuthSentCodeTypeEmailCode represents TL type `auth.sentCodeTypeEmailCode#5a159841`. +// +// See https://core.telegram.org/constructor/auth.sentCodeTypeEmailCode for reference. +type AuthSentCodeTypeEmailCode struct { + // Flags field of AuthSentCodeTypeEmailCode. + Flags bin.Fields + // AppleSigninAllowed field of AuthSentCodeTypeEmailCode. + AppleSigninAllowed bool + // GoogleSigninAllowed field of AuthSentCodeTypeEmailCode. + GoogleSigninAllowed bool + // EmailPattern field of AuthSentCodeTypeEmailCode. + EmailPattern string + // Length field of AuthSentCodeTypeEmailCode. + Length int + // NextPhoneLoginDate field of AuthSentCodeTypeEmailCode. + // + // Use SetNextPhoneLoginDate and GetNextPhoneLoginDate helpers. + NextPhoneLoginDate int +} + +// AuthSentCodeTypeEmailCodeTypeID is TL type id of AuthSentCodeTypeEmailCode. +const AuthSentCodeTypeEmailCodeTypeID = 0x5a159841 + +// construct implements constructor of AuthSentCodeTypeClass. +func (s AuthSentCodeTypeEmailCode) construct() AuthSentCodeTypeClass { return &s } + +// Ensuring interfaces in compile-time for AuthSentCodeTypeEmailCode. +var ( + _ bin.Encoder = &AuthSentCodeTypeEmailCode{} + _ bin.Decoder = &AuthSentCodeTypeEmailCode{} + _ bin.BareEncoder = &AuthSentCodeTypeEmailCode{} + _ bin.BareDecoder = &AuthSentCodeTypeEmailCode{} + + _ AuthSentCodeTypeClass = &AuthSentCodeTypeEmailCode{} +) + +func (s *AuthSentCodeTypeEmailCode) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.AppleSigninAllowed == false) { + return false + } + if !(s.GoogleSigninAllowed == false) { + return false + } + if !(s.EmailPattern == "") { + return false + } + if !(s.Length == 0) { + return false + } + if !(s.NextPhoneLoginDate == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *AuthSentCodeTypeEmailCode) String() string { + if s == nil { + return "AuthSentCodeTypeEmailCode(nil)" + } + type Alias AuthSentCodeTypeEmailCode + return fmt.Sprintf("AuthSentCodeTypeEmailCode%+v", Alias(*s)) +} + +// FillFrom fills AuthSentCodeTypeEmailCode from given interface. +func (s *AuthSentCodeTypeEmailCode) FillFrom(from interface { + GetAppleSigninAllowed() (value bool) + GetGoogleSigninAllowed() (value bool) + GetEmailPattern() (value string) + GetLength() (value int) + GetNextPhoneLoginDate() (value int, ok bool) +}) { + s.AppleSigninAllowed = from.GetAppleSigninAllowed() + s.GoogleSigninAllowed = from.GetGoogleSigninAllowed() + s.EmailPattern = from.GetEmailPattern() + s.Length = from.GetLength() + if val, ok := from.GetNextPhoneLoginDate(); ok { + s.NextPhoneLoginDate = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AuthSentCodeTypeEmailCode) TypeID() uint32 { + return AuthSentCodeTypeEmailCodeTypeID +} + +// TypeName returns name of type in TL schema. +func (*AuthSentCodeTypeEmailCode) TypeName() string { + return "auth.sentCodeTypeEmailCode" +} + +// TypeInfo returns info about TL type. +func (s *AuthSentCodeTypeEmailCode) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "auth.sentCodeTypeEmailCode", + ID: AuthSentCodeTypeEmailCodeTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "AppleSigninAllowed", + SchemaName: "apple_signin_allowed", + Null: !s.Flags.Has(0), + }, + { + Name: "GoogleSigninAllowed", + SchemaName: "google_signin_allowed", + Null: !s.Flags.Has(1), + }, + { + Name: "EmailPattern", + SchemaName: "email_pattern", + }, + { + Name: "Length", + SchemaName: "length", + }, + { + Name: "NextPhoneLoginDate", + SchemaName: "next_phone_login_date", + Null: !s.Flags.Has(2), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *AuthSentCodeTypeEmailCode) SetFlags() { + if !(s.AppleSigninAllowed == false) { + s.Flags.Set(0) + } + if !(s.GoogleSigninAllowed == false) { + s.Flags.Set(1) + } + if !(s.NextPhoneLoginDate == 0) { + s.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (s *AuthSentCodeTypeEmailCode) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode auth.sentCodeTypeEmailCode#5a159841 as nil") + } + b.PutID(AuthSentCodeTypeEmailCodeTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *AuthSentCodeTypeEmailCode) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode auth.sentCodeTypeEmailCode#5a159841 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode auth.sentCodeTypeEmailCode#5a159841: field flags: %w", err) + } + b.PutString(s.EmailPattern) + b.PutInt(s.Length) + if s.Flags.Has(2) { + b.PutInt(s.NextPhoneLoginDate) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *AuthSentCodeTypeEmailCode) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode auth.sentCodeTypeEmailCode#5a159841 to nil") + } + if err := b.ConsumeID(AuthSentCodeTypeEmailCodeTypeID); err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeEmailCode#5a159841: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *AuthSentCodeTypeEmailCode) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode auth.sentCodeTypeEmailCode#5a159841 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeEmailCode#5a159841: field flags: %w", err) + } + } + s.AppleSigninAllowed = s.Flags.Has(0) + s.GoogleSigninAllowed = s.Flags.Has(1) + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeEmailCode#5a159841: field email_pattern: %w", err) + } + s.EmailPattern = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeEmailCode#5a159841: field length: %w", err) + } + s.Length = value + } + if s.Flags.Has(2) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeEmailCode#5a159841: field next_phone_login_date: %w", err) + } + s.NextPhoneLoginDate = value + } + return nil +} + +// SetAppleSigninAllowed sets value of AppleSigninAllowed conditional field. +func (s *AuthSentCodeTypeEmailCode) SetAppleSigninAllowed(value bool) { + if value { + s.Flags.Set(0) + s.AppleSigninAllowed = true + } else { + s.Flags.Unset(0) + s.AppleSigninAllowed = false + } +} + +// GetAppleSigninAllowed returns value of AppleSigninAllowed conditional field. +func (s *AuthSentCodeTypeEmailCode) GetAppleSigninAllowed() (value bool) { + if s == nil { + return + } + return s.Flags.Has(0) +} + +// SetGoogleSigninAllowed sets value of GoogleSigninAllowed conditional field. +func (s *AuthSentCodeTypeEmailCode) SetGoogleSigninAllowed(value bool) { + if value { + s.Flags.Set(1) + s.GoogleSigninAllowed = true + } else { + s.Flags.Unset(1) + s.GoogleSigninAllowed = false + } +} + +// GetGoogleSigninAllowed returns value of GoogleSigninAllowed conditional field. +func (s *AuthSentCodeTypeEmailCode) GetGoogleSigninAllowed() (value bool) { + if s == nil { + return + } + return s.Flags.Has(1) +} + +// GetEmailPattern returns value of EmailPattern field. +func (s *AuthSentCodeTypeEmailCode) GetEmailPattern() (value string) { + if s == nil { + return + } + return s.EmailPattern +} + +// GetLength returns value of Length field. +func (s *AuthSentCodeTypeEmailCode) GetLength() (value int) { + if s == nil { + return + } + return s.Length +} + +// SetNextPhoneLoginDate sets value of NextPhoneLoginDate conditional field. +func (s *AuthSentCodeTypeEmailCode) SetNextPhoneLoginDate(value int) { + s.Flags.Set(2) + s.NextPhoneLoginDate = value +} + +// GetNextPhoneLoginDate returns value of NextPhoneLoginDate conditional field and +// boolean which is true if field was set. +func (s *AuthSentCodeTypeEmailCode) GetNextPhoneLoginDate() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(2) { + return value, false + } + return s.NextPhoneLoginDate, true +} + +// AuthSentCodeTypeSetUpEmailRequired represents TL type `auth.sentCodeTypeSetUpEmailRequired#a5491dea`. +// +// See https://core.telegram.org/constructor/auth.sentCodeTypeSetUpEmailRequired for reference. +type AuthSentCodeTypeSetUpEmailRequired struct { + // Flags field of AuthSentCodeTypeSetUpEmailRequired. + Flags bin.Fields + // AppleSigninAllowed field of AuthSentCodeTypeSetUpEmailRequired. + AppleSigninAllowed bool + // GoogleSigninAllowed field of AuthSentCodeTypeSetUpEmailRequired. + GoogleSigninAllowed bool +} + +// AuthSentCodeTypeSetUpEmailRequiredTypeID is TL type id of AuthSentCodeTypeSetUpEmailRequired. +const AuthSentCodeTypeSetUpEmailRequiredTypeID = 0xa5491dea + +// construct implements constructor of AuthSentCodeTypeClass. +func (s AuthSentCodeTypeSetUpEmailRequired) construct() AuthSentCodeTypeClass { return &s } + +// Ensuring interfaces in compile-time for AuthSentCodeTypeSetUpEmailRequired. +var ( + _ bin.Encoder = &AuthSentCodeTypeSetUpEmailRequired{} + _ bin.Decoder = &AuthSentCodeTypeSetUpEmailRequired{} + _ bin.BareEncoder = &AuthSentCodeTypeSetUpEmailRequired{} + _ bin.BareDecoder = &AuthSentCodeTypeSetUpEmailRequired{} + + _ AuthSentCodeTypeClass = &AuthSentCodeTypeSetUpEmailRequired{} +) + +func (s *AuthSentCodeTypeSetUpEmailRequired) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.AppleSigninAllowed == false) { + return false + } + if !(s.GoogleSigninAllowed == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *AuthSentCodeTypeSetUpEmailRequired) String() string { + if s == nil { + return "AuthSentCodeTypeSetUpEmailRequired(nil)" + } + type Alias AuthSentCodeTypeSetUpEmailRequired + return fmt.Sprintf("AuthSentCodeTypeSetUpEmailRequired%+v", Alias(*s)) +} + +// FillFrom fills AuthSentCodeTypeSetUpEmailRequired from given interface. +func (s *AuthSentCodeTypeSetUpEmailRequired) FillFrom(from interface { + GetAppleSigninAllowed() (value bool) + GetGoogleSigninAllowed() (value bool) +}) { + s.AppleSigninAllowed = from.GetAppleSigninAllowed() + s.GoogleSigninAllowed = from.GetGoogleSigninAllowed() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AuthSentCodeTypeSetUpEmailRequired) TypeID() uint32 { + return AuthSentCodeTypeSetUpEmailRequiredTypeID +} + +// TypeName returns name of type in TL schema. +func (*AuthSentCodeTypeSetUpEmailRequired) TypeName() string { + return "auth.sentCodeTypeSetUpEmailRequired" +} + +// TypeInfo returns info about TL type. +func (s *AuthSentCodeTypeSetUpEmailRequired) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "auth.sentCodeTypeSetUpEmailRequired", + ID: AuthSentCodeTypeSetUpEmailRequiredTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "AppleSigninAllowed", + SchemaName: "apple_signin_allowed", + Null: !s.Flags.Has(0), + }, + { + Name: "GoogleSigninAllowed", + SchemaName: "google_signin_allowed", + Null: !s.Flags.Has(1), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *AuthSentCodeTypeSetUpEmailRequired) SetFlags() { + if !(s.AppleSigninAllowed == false) { + s.Flags.Set(0) + } + if !(s.GoogleSigninAllowed == false) { + s.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (s *AuthSentCodeTypeSetUpEmailRequired) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode auth.sentCodeTypeSetUpEmailRequired#a5491dea as nil") + } + b.PutID(AuthSentCodeTypeSetUpEmailRequiredTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *AuthSentCodeTypeSetUpEmailRequired) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode auth.sentCodeTypeSetUpEmailRequired#a5491dea as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode auth.sentCodeTypeSetUpEmailRequired#a5491dea: field flags: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *AuthSentCodeTypeSetUpEmailRequired) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode auth.sentCodeTypeSetUpEmailRequired#a5491dea to nil") + } + if err := b.ConsumeID(AuthSentCodeTypeSetUpEmailRequiredTypeID); err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeSetUpEmailRequired#a5491dea: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *AuthSentCodeTypeSetUpEmailRequired) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode auth.sentCodeTypeSetUpEmailRequired#a5491dea to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeSetUpEmailRequired#a5491dea: field flags: %w", err) + } + } + s.AppleSigninAllowed = s.Flags.Has(0) + s.GoogleSigninAllowed = s.Flags.Has(1) + return nil +} + +// SetAppleSigninAllowed sets value of AppleSigninAllowed conditional field. +func (s *AuthSentCodeTypeSetUpEmailRequired) SetAppleSigninAllowed(value bool) { + if value { + s.Flags.Set(0) + s.AppleSigninAllowed = true + } else { + s.Flags.Unset(0) + s.AppleSigninAllowed = false + } +} + +// GetAppleSigninAllowed returns value of AppleSigninAllowed conditional field. +func (s *AuthSentCodeTypeSetUpEmailRequired) GetAppleSigninAllowed() (value bool) { + if s == nil { + return + } + return s.Flags.Has(0) +} + +// SetGoogleSigninAllowed sets value of GoogleSigninAllowed conditional field. +func (s *AuthSentCodeTypeSetUpEmailRequired) SetGoogleSigninAllowed(value bool) { + if value { + s.Flags.Set(1) + s.GoogleSigninAllowed = true + } else { + s.Flags.Unset(1) + s.GoogleSigninAllowed = false + } +} + +// GetGoogleSigninAllowed returns value of GoogleSigninAllowed conditional field. +func (s *AuthSentCodeTypeSetUpEmailRequired) GetGoogleSigninAllowed() (value bool) { + if s == nil { + return + } + return s.Flags.Has(1) +} + // AuthSentCodeTypeClassName is schema name of AuthSentCodeTypeClass. const AuthSentCodeTypeClassName = "auth.SentCodeType" @@ -760,6 +1252,8 @@ const AuthSentCodeTypeClassName = "auth.SentCodeType" // case *tg.AuthSentCodeTypeCall: // auth.sentCodeTypeCall#5353e5a7 // case *tg.AuthSentCodeTypeFlashCall: // auth.sentCodeTypeFlashCall#ab03c6d9 // case *tg.AuthSentCodeTypeMissedCall: // auth.sentCodeTypeMissedCall#82006484 +// case *tg.AuthSentCodeTypeEmailCode: // auth.sentCodeTypeEmailCode#5a159841 +// case *tg.AuthSentCodeTypeSetUpEmailRequired: // auth.sentCodeTypeSetUpEmailRequired#a5491dea // default: panic(v) // } type AuthSentCodeTypeClass interface { @@ -823,6 +1317,20 @@ func DecodeAuthSentCodeType(buf *bin.Buffer) (AuthSentCodeTypeClass, error) { return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", err) } return &v, nil + case AuthSentCodeTypeEmailCodeTypeID: + // Decoding auth.sentCodeTypeEmailCode#5a159841. + v := AuthSentCodeTypeEmailCode{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", err) + } + return &v, nil + case AuthSentCodeTypeSetUpEmailRequiredTypeID: + // Decoding auth.sentCodeTypeSetUpEmailRequired#a5491dea. + v := AuthSentCodeTypeSetUpEmailRequired{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_auth_sent_code_type_slices_gen.go b/tg/tl_auth_sent_code_type_slices_gen.go index ea075544c4..5868bdb1f7 100644 --- a/tg/tl_auth_sent_code_type_slices_gen.go +++ b/tg/tl_auth_sent_code_type_slices_gen.go @@ -181,6 +181,32 @@ func (s AuthSentCodeTypeClassArray) AsAuthSentCodeTypeMissedCall() (to AuthSentC return to } +// AsAuthSentCodeTypeEmailCode returns copy with only AuthSentCodeTypeEmailCode constructors. +func (s AuthSentCodeTypeClassArray) AsAuthSentCodeTypeEmailCode() (to AuthSentCodeTypeEmailCodeArray) { + for _, elem := range s { + value, ok := elem.(*AuthSentCodeTypeEmailCode) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsAuthSentCodeTypeSetUpEmailRequired returns copy with only AuthSentCodeTypeSetUpEmailRequired constructors. +func (s AuthSentCodeTypeClassArray) AsAuthSentCodeTypeSetUpEmailRequired() (to AuthSentCodeTypeSetUpEmailRequiredArray) { + for _, elem := range s { + value, ok := elem.(*AuthSentCodeTypeSetUpEmailRequired) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // AuthSentCodeTypeAppArray is adapter for slice of AuthSentCodeTypeApp. type AuthSentCodeTypeAppArray []AuthSentCodeTypeApp @@ -590,3 +616,167 @@ func (s *AuthSentCodeTypeMissedCallArray) Pop() (v AuthSentCodeTypeMissedCall, o return v, true } + +// AuthSentCodeTypeEmailCodeArray is adapter for slice of AuthSentCodeTypeEmailCode. +type AuthSentCodeTypeEmailCodeArray []AuthSentCodeTypeEmailCode + +// Sort sorts slice of AuthSentCodeTypeEmailCode. +func (s AuthSentCodeTypeEmailCodeArray) Sort(less func(a, b AuthSentCodeTypeEmailCode) bool) AuthSentCodeTypeEmailCodeArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AuthSentCodeTypeEmailCode. +func (s AuthSentCodeTypeEmailCodeArray) SortStable(less func(a, b AuthSentCodeTypeEmailCode) bool) AuthSentCodeTypeEmailCodeArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AuthSentCodeTypeEmailCode. +func (s AuthSentCodeTypeEmailCodeArray) Retain(keep func(x AuthSentCodeTypeEmailCode) bool) AuthSentCodeTypeEmailCodeArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s AuthSentCodeTypeEmailCodeArray) First() (v AuthSentCodeTypeEmailCode, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AuthSentCodeTypeEmailCodeArray) Last() (v AuthSentCodeTypeEmailCode, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *AuthSentCodeTypeEmailCodeArray) PopFirst() (v AuthSentCodeTypeEmailCode, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero AuthSentCodeTypeEmailCode + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *AuthSentCodeTypeEmailCodeArray) Pop() (v AuthSentCodeTypeEmailCode, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// AuthSentCodeTypeSetUpEmailRequiredArray is adapter for slice of AuthSentCodeTypeSetUpEmailRequired. +type AuthSentCodeTypeSetUpEmailRequiredArray []AuthSentCodeTypeSetUpEmailRequired + +// Sort sorts slice of AuthSentCodeTypeSetUpEmailRequired. +func (s AuthSentCodeTypeSetUpEmailRequiredArray) Sort(less func(a, b AuthSentCodeTypeSetUpEmailRequired) bool) AuthSentCodeTypeSetUpEmailRequiredArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AuthSentCodeTypeSetUpEmailRequired. +func (s AuthSentCodeTypeSetUpEmailRequiredArray) SortStable(less func(a, b AuthSentCodeTypeSetUpEmailRequired) bool) AuthSentCodeTypeSetUpEmailRequiredArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AuthSentCodeTypeSetUpEmailRequired. +func (s AuthSentCodeTypeSetUpEmailRequiredArray) Retain(keep func(x AuthSentCodeTypeSetUpEmailRequired) bool) AuthSentCodeTypeSetUpEmailRequiredArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s AuthSentCodeTypeSetUpEmailRequiredArray) First() (v AuthSentCodeTypeSetUpEmailRequired, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AuthSentCodeTypeSetUpEmailRequiredArray) Last() (v AuthSentCodeTypeSetUpEmailRequired, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *AuthSentCodeTypeSetUpEmailRequiredArray) PopFirst() (v AuthSentCodeTypeSetUpEmailRequired, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero AuthSentCodeTypeSetUpEmailRequired + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *AuthSentCodeTypeSetUpEmailRequiredArray) Pop() (v AuthSentCodeTypeSetUpEmailRequired, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_auth_sign_in_gen.go b/tg/tl_auth_sign_in_gen.go index 9ae1c38cbc..6464c1748d 100644 --- a/tg/tl_auth_sign_in_gen.go +++ b/tg/tl_auth_sign_in_gen.go @@ -31,11 +31,13 @@ var ( _ = tdjson.Encoder{} ) -// AuthSignInRequest represents TL type `auth.signIn#bcd51581`. +// AuthSignInRequest represents TL type `auth.signIn#8d52a951`. // Signs in a user with a validated phone number. // // See https://core.telegram.org/method/auth.signIn for reference. type AuthSignInRequest struct { + // Flags field of AuthSignInRequest. + Flags bin.Fields // Phone number in the international format PhoneNumber string // SMS-message ID, obtained from auth.sendCode¹ @@ -44,11 +46,17 @@ type AuthSignInRequest struct { // 1) https://core.telegram.org/method/auth.sendCode PhoneCodeHash string // Valid numerical code from the SMS-message + // + // Use SetPhoneCode and GetPhoneCode helpers. PhoneCode string + // EmailVerification field of AuthSignInRequest. + // + // Use SetEmailVerification and GetEmailVerification helpers. + EmailVerification EmailVerificationClass } // AuthSignInRequestTypeID is TL type id of AuthSignInRequest. -const AuthSignInRequestTypeID = 0xbcd51581 +const AuthSignInRequestTypeID = 0x8d52a951 // Ensuring interfaces in compile-time for AuthSignInRequest. var ( @@ -62,6 +70,9 @@ func (s *AuthSignInRequest) Zero() bool { if s == nil { return true } + if !(s.Flags.Zero()) { + return false + } if !(s.PhoneNumber == "") { return false } @@ -71,6 +82,9 @@ func (s *AuthSignInRequest) Zero() bool { if !(s.PhoneCode == "") { return false } + if !(s.EmailVerification == nil) { + return false + } return true } @@ -88,11 +102,19 @@ func (s *AuthSignInRequest) String() string { func (s *AuthSignInRequest) FillFrom(from interface { GetPhoneNumber() (value string) GetPhoneCodeHash() (value string) - GetPhoneCode() (value string) + GetPhoneCode() (value string, ok bool) + GetEmailVerification() (value EmailVerificationClass, ok bool) }) { s.PhoneNumber = from.GetPhoneNumber() s.PhoneCodeHash = from.GetPhoneCodeHash() - s.PhoneCode = from.GetPhoneCode() + if val, ok := from.GetPhoneCode(); ok { + s.PhoneCode = val + } + + if val, ok := from.GetEmailVerification(); ok { + s.EmailVerification = val + } + } // TypeID returns type id in TL schema. @@ -129,15 +151,31 @@ func (s *AuthSignInRequest) TypeInfo() tdp.Type { { Name: "PhoneCode", SchemaName: "phone_code", + Null: !s.Flags.Has(0), + }, + { + Name: "EmailVerification", + SchemaName: "email_verification", + Null: !s.Flags.Has(1), }, } return typ } +// SetFlags sets flags for non-zero fields. +func (s *AuthSignInRequest) SetFlags() { + if !(s.PhoneCode == "") { + s.Flags.Set(0) + } + if !(s.EmailVerification == nil) { + s.Flags.Set(1) + } +} + // Encode implements bin.Encoder. func (s *AuthSignInRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode auth.signIn#bcd51581 as nil") + return fmt.Errorf("can't encode auth.signIn#8d52a951 as nil") } b.PutID(AuthSignInRequestTypeID) return s.EncodeBare(b) @@ -146,21 +184,35 @@ func (s *AuthSignInRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *AuthSignInRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode auth.signIn#bcd51581 as nil") + return fmt.Errorf("can't encode auth.signIn#8d52a951 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode auth.signIn#8d52a951: field flags: %w", err) } b.PutString(s.PhoneNumber) b.PutString(s.PhoneCodeHash) - b.PutString(s.PhoneCode) + if s.Flags.Has(0) { + b.PutString(s.PhoneCode) + } + if s.Flags.Has(1) { + if s.EmailVerification == nil { + return fmt.Errorf("unable to encode auth.signIn#8d52a951: field email_verification is nil") + } + if err := s.EmailVerification.Encode(b); err != nil { + return fmt.Errorf("unable to encode auth.signIn#8d52a951: field email_verification: %w", err) + } + } return nil } // Decode implements bin.Decoder. func (s *AuthSignInRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode auth.signIn#bcd51581 to nil") + return fmt.Errorf("can't decode auth.signIn#8d52a951 to nil") } if err := b.ConsumeID(AuthSignInRequestTypeID); err != nil { - return fmt.Errorf("unable to decode auth.signIn#bcd51581: %w", err) + return fmt.Errorf("unable to decode auth.signIn#8d52a951: %w", err) } return s.DecodeBare(b) } @@ -168,29 +220,41 @@ func (s *AuthSignInRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *AuthSignInRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode auth.signIn#bcd51581 to nil") + return fmt.Errorf("can't decode auth.signIn#8d52a951 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode auth.signIn#8d52a951: field flags: %w", err) + } } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode auth.signIn#bcd51581: field phone_number: %w", err) + return fmt.Errorf("unable to decode auth.signIn#8d52a951: field phone_number: %w", err) } s.PhoneNumber = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode auth.signIn#bcd51581: field phone_code_hash: %w", err) + return fmt.Errorf("unable to decode auth.signIn#8d52a951: field phone_code_hash: %w", err) } s.PhoneCodeHash = value } - { + if s.Flags.Has(0) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode auth.signIn#bcd51581: field phone_code: %w", err) + return fmt.Errorf("unable to decode auth.signIn#8d52a951: field phone_code: %w", err) } s.PhoneCode = value } + if s.Flags.Has(1) { + value, err := DecodeEmailVerification(b) + if err != nil { + return fmt.Errorf("unable to decode auth.signIn#8d52a951: field email_verification: %w", err) + } + s.EmailVerification = value + } return nil } @@ -210,15 +274,43 @@ func (s *AuthSignInRequest) GetPhoneCodeHash() (value string) { return s.PhoneCodeHash } -// GetPhoneCode returns value of PhoneCode field. -func (s *AuthSignInRequest) GetPhoneCode() (value string) { +// SetPhoneCode sets value of PhoneCode conditional field. +func (s *AuthSignInRequest) SetPhoneCode(value string) { + s.Flags.Set(0) + s.PhoneCode = value +} + +// GetPhoneCode returns value of PhoneCode conditional field and +// boolean which is true if field was set. +func (s *AuthSignInRequest) GetPhoneCode() (value string, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.PhoneCode, true +} + +// SetEmailVerification sets value of EmailVerification conditional field. +func (s *AuthSignInRequest) SetEmailVerification(value EmailVerificationClass) { + s.Flags.Set(1) + s.EmailVerification = value +} + +// GetEmailVerification returns value of EmailVerification conditional field and +// boolean which is true if field was set. +func (s *AuthSignInRequest) GetEmailVerification() (value EmailVerificationClass, ok bool) { if s == nil { return } - return s.PhoneCode + if !s.Flags.Has(1) { + return value, false + } + return s.EmailVerification, true } -// AuthSignIn invokes method auth.signIn#bcd51581 returning error if any. +// AuthSignIn invokes method auth.signIn#8d52a951 returning error if any. // Signs in a user with a validated phone number. // // Possible errors: diff --git a/tg/tl_channel_admin_log_event_action_gen.go b/tg/tl_channel_admin_log_event_action_gen.go index af072b3c80..b8d998c9d9 100644 --- a/tg/tl_channel_admin_log_event_action_gen.go +++ b/tg/tl_channel_admin_log_event_action_gen.go @@ -5295,7 +5295,7 @@ func (c *ChannelAdminLogEventActionSendMessage) GetMessage() (value MessageClass return c.Message } -// ChannelAdminLogEventActionChangeAvailableReactions represents TL type `channelAdminLogEventActionChangeAvailableReactions#9cf7f76a`. +// ChannelAdminLogEventActionChangeAvailableReactions represents TL type `channelAdminLogEventActionChangeAvailableReactions#be4e0ef8`. // The set of allowed message reactions »¹ for this channel has changed // // Links: @@ -5304,13 +5304,13 @@ func (c *ChannelAdminLogEventActionSendMessage) GetMessage() (value MessageClass // See https://core.telegram.org/constructor/channelAdminLogEventActionChangeAvailableReactions for reference. type ChannelAdminLogEventActionChangeAvailableReactions struct { // Previously allowed reaction emojis - PrevValue []string + PrevValue ChatReactionsClass // New allowed reaction emojis - NewValue []string + NewValue ChatReactionsClass } // ChannelAdminLogEventActionChangeAvailableReactionsTypeID is TL type id of ChannelAdminLogEventActionChangeAvailableReactions. -const ChannelAdminLogEventActionChangeAvailableReactionsTypeID = 0x9cf7f76a +const ChannelAdminLogEventActionChangeAvailableReactionsTypeID = 0xbe4e0ef8 // construct implements constructor of ChannelAdminLogEventActionClass. func (c ChannelAdminLogEventActionChangeAvailableReactions) construct() ChannelAdminLogEventActionClass { @@ -5352,8 +5352,8 @@ func (c *ChannelAdminLogEventActionChangeAvailableReactions) String() string { // FillFrom fills ChannelAdminLogEventActionChangeAvailableReactions from given interface. func (c *ChannelAdminLogEventActionChangeAvailableReactions) FillFrom(from interface { - GetPrevValue() (value []string) - GetNewValue() (value []string) + GetPrevValue() (value ChatReactionsClass) + GetNewValue() (value ChatReactionsClass) }) { c.PrevValue = from.GetPrevValue() c.NewValue = from.GetNewValue() @@ -5397,7 +5397,7 @@ func (c *ChannelAdminLogEventActionChangeAvailableReactions) TypeInfo() tdp.Type // Encode implements bin.Encoder. func (c *ChannelAdminLogEventActionChangeAvailableReactions) Encode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channelAdminLogEventActionChangeAvailableReactions#9cf7f76a as nil") + return fmt.Errorf("can't encode channelAdminLogEventActionChangeAvailableReactions#be4e0ef8 as nil") } b.PutID(ChannelAdminLogEventActionChangeAvailableReactionsTypeID) return c.EncodeBare(b) @@ -5406,15 +5406,19 @@ func (c *ChannelAdminLogEventActionChangeAvailableReactions) Encode(b *bin.Buffe // EncodeBare implements bin.BareEncoder. func (c *ChannelAdminLogEventActionChangeAvailableReactions) EncodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channelAdminLogEventActionChangeAvailableReactions#9cf7f76a as nil") + return fmt.Errorf("can't encode channelAdminLogEventActionChangeAvailableReactions#be4e0ef8 as nil") } - b.PutVectorHeader(len(c.PrevValue)) - for _, v := range c.PrevValue { - b.PutString(v) + if c.PrevValue == nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionChangeAvailableReactions#be4e0ef8: field prev_value is nil") + } + if err := c.PrevValue.Encode(b); err != nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionChangeAvailableReactions#be4e0ef8: field prev_value: %w", err) } - b.PutVectorHeader(len(c.NewValue)) - for _, v := range c.NewValue { - b.PutString(v) + if c.NewValue == nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionChangeAvailableReactions#be4e0ef8: field new_value is nil") + } + if err := c.NewValue.Encode(b); err != nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionChangeAvailableReactions#be4e0ef8: field new_value: %w", err) } return nil } @@ -5422,10 +5426,10 @@ func (c *ChannelAdminLogEventActionChangeAvailableReactions) EncodeBare(b *bin.B // Decode implements bin.Decoder. func (c *ChannelAdminLogEventActionChangeAvailableReactions) Decode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channelAdminLogEventActionChangeAvailableReactions#9cf7f76a to nil") + return fmt.Errorf("can't decode channelAdminLogEventActionChangeAvailableReactions#be4e0ef8 to nil") } if err := b.ConsumeID(ChannelAdminLogEventActionChangeAvailableReactionsTypeID); err != nil { - return fmt.Errorf("unable to decode channelAdminLogEventActionChangeAvailableReactions#9cf7f76a: %w", err) + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeAvailableReactions#be4e0ef8: %w", err) } return c.DecodeBare(b) } @@ -5433,47 +5437,27 @@ func (c *ChannelAdminLogEventActionChangeAvailableReactions) Decode(b *bin.Buffe // DecodeBare implements bin.BareDecoder. func (c *ChannelAdminLogEventActionChangeAvailableReactions) DecodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channelAdminLogEventActionChangeAvailableReactions#9cf7f76a to nil") + return fmt.Errorf("can't decode channelAdminLogEventActionChangeAvailableReactions#be4e0ef8 to nil") } { - headerLen, err := b.VectorHeader() + value, err := DecodeChatReactions(b) if err != nil { - return fmt.Errorf("unable to decode channelAdminLogEventActionChangeAvailableReactions#9cf7f76a: field prev_value: %w", err) - } - - if headerLen > 0 { - c.PrevValue = make([]string, 0, headerLen%bin.PreallocateLimit) - } - for idx := 0; idx < headerLen; idx++ { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode channelAdminLogEventActionChangeAvailableReactions#9cf7f76a: field prev_value: %w", err) - } - c.PrevValue = append(c.PrevValue, value) + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeAvailableReactions#be4e0ef8: field prev_value: %w", err) } + c.PrevValue = value } { - headerLen, err := b.VectorHeader() + value, err := DecodeChatReactions(b) if err != nil { - return fmt.Errorf("unable to decode channelAdminLogEventActionChangeAvailableReactions#9cf7f76a: field new_value: %w", err) - } - - if headerLen > 0 { - c.NewValue = make([]string, 0, headerLen%bin.PreallocateLimit) - } - for idx := 0; idx < headerLen; idx++ { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode channelAdminLogEventActionChangeAvailableReactions#9cf7f76a: field new_value: %w", err) - } - c.NewValue = append(c.NewValue, value) + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeAvailableReactions#be4e0ef8: field new_value: %w", err) } + c.NewValue = value } return nil } // GetPrevValue returns value of PrevValue field. -func (c *ChannelAdminLogEventActionChangeAvailableReactions) GetPrevValue() (value []string) { +func (c *ChannelAdminLogEventActionChangeAvailableReactions) GetPrevValue() (value ChatReactionsClass) { if c == nil { return } @@ -5481,7 +5465,7 @@ func (c *ChannelAdminLogEventActionChangeAvailableReactions) GetPrevValue() (val } // GetNewValue returns value of NewValue field. -func (c *ChannelAdminLogEventActionChangeAvailableReactions) GetNewValue() (value []string) { +func (c *ChannelAdminLogEventActionChangeAvailableReactions) GetNewValue() (value ChatReactionsClass) { if c == nil { return } @@ -5537,7 +5521,7 @@ const ChannelAdminLogEventActionClassName = "ChannelAdminLogEventAction" // case *tg.ChannelAdminLogEventActionParticipantJoinByRequest: // channelAdminLogEventActionParticipantJoinByRequest#afb6144a // case *tg.ChannelAdminLogEventActionToggleNoForwards: // channelAdminLogEventActionToggleNoForwards#cb2ac766 // case *tg.ChannelAdminLogEventActionSendMessage: // channelAdminLogEventActionSendMessage#278f2868 -// case *tg.ChannelAdminLogEventActionChangeAvailableReactions: // channelAdminLogEventActionChangeAvailableReactions#9cf7f76a +// case *tg.ChannelAdminLogEventActionChangeAvailableReactions: // channelAdminLogEventActionChangeAvailableReactions#be4e0ef8 // default: panic(v) // } type ChannelAdminLogEventActionClass interface { @@ -5812,7 +5796,7 @@ func DecodeChannelAdminLogEventAction(buf *bin.Buffer) (ChannelAdminLogEventActi } return &v, nil case ChannelAdminLogEventActionChangeAvailableReactionsTypeID: - // Decoding channelAdminLogEventActionChangeAvailableReactions#9cf7f76a. + // Decoding channelAdminLogEventActionChangeAvailableReactions#be4e0ef8. v := ChannelAdminLogEventActionChangeAvailableReactions{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", err) diff --git a/tg/tl_channels_send_as_peers_gen.go b/tg/tl_channels_send_as_peers_gen.go index 7db041bda0..dc8afd2832 100644 --- a/tg/tl_channels_send_as_peers_gen.go +++ b/tg/tl_channels_send_as_peers_gen.go @@ -31,13 +31,13 @@ var ( _ = tdjson.Encoder{} ) -// ChannelsSendAsPeers represents TL type `channels.sendAsPeers#8356cda9`. +// ChannelsSendAsPeers represents TL type `channels.sendAsPeers#f496b0c6`. // A list of peers that can be used to send messages in a specific group // // See https://core.telegram.org/constructor/channels.sendAsPeers for reference. type ChannelsSendAsPeers struct { // Peers that can be used to send messages to the group - Peers []PeerClass + Peers []SendAsPeer // Mentioned chats Chats []ChatClass // Mentioned users @@ -45,7 +45,7 @@ type ChannelsSendAsPeers struct { } // ChannelsSendAsPeersTypeID is TL type id of ChannelsSendAsPeers. -const ChannelsSendAsPeersTypeID = 0x8356cda9 +const ChannelsSendAsPeersTypeID = 0xf496b0c6 // Ensuring interfaces in compile-time for ChannelsSendAsPeers. var ( @@ -83,7 +83,7 @@ func (s *ChannelsSendAsPeers) String() string { // FillFrom fills ChannelsSendAsPeers from given interface. func (s *ChannelsSendAsPeers) FillFrom(from interface { - GetPeers() (value []PeerClass) + GetPeers() (value []SendAsPeer) GetChats() (value []ChatClass) GetUsers() (value []UserClass) }) { @@ -134,7 +134,7 @@ func (s *ChannelsSendAsPeers) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (s *ChannelsSendAsPeers) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode channels.sendAsPeers#8356cda9 as nil") + return fmt.Errorf("can't encode channels.sendAsPeers#f496b0c6 as nil") } b.PutID(ChannelsSendAsPeersTypeID) return s.EncodeBare(b) @@ -143,33 +143,30 @@ func (s *ChannelsSendAsPeers) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *ChannelsSendAsPeers) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode channels.sendAsPeers#8356cda9 as nil") + return fmt.Errorf("can't encode channels.sendAsPeers#f496b0c6 as nil") } b.PutVectorHeader(len(s.Peers)) for idx, v := range s.Peers { - if v == nil { - return fmt.Errorf("unable to encode channels.sendAsPeers#8356cda9: field peers element with index %d is nil", idx) - } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode channels.sendAsPeers#8356cda9: field peers element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode channels.sendAsPeers#f496b0c6: field peers element with index %d: %w", idx, err) } } b.PutVectorHeader(len(s.Chats)) for idx, v := range s.Chats { if v == nil { - return fmt.Errorf("unable to encode channels.sendAsPeers#8356cda9: field chats element with index %d is nil", idx) + return fmt.Errorf("unable to encode channels.sendAsPeers#f496b0c6: field chats element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode channels.sendAsPeers#8356cda9: field chats element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode channels.sendAsPeers#f496b0c6: field chats element with index %d: %w", idx, err) } } b.PutVectorHeader(len(s.Users)) for idx, v := range s.Users { if v == nil { - return fmt.Errorf("unable to encode channels.sendAsPeers#8356cda9: field users element with index %d is nil", idx) + return fmt.Errorf("unable to encode channels.sendAsPeers#f496b0c6: field users element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode channels.sendAsPeers#8356cda9: field users element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode channels.sendAsPeers#f496b0c6: field users element with index %d: %w", idx, err) } } return nil @@ -178,10 +175,10 @@ func (s *ChannelsSendAsPeers) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *ChannelsSendAsPeers) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode channels.sendAsPeers#8356cda9 to nil") + return fmt.Errorf("can't decode channels.sendAsPeers#f496b0c6 to nil") } if err := b.ConsumeID(ChannelsSendAsPeersTypeID); err != nil { - return fmt.Errorf("unable to decode channels.sendAsPeers#8356cda9: %w", err) + return fmt.Errorf("unable to decode channels.sendAsPeers#f496b0c6: %w", err) } return s.DecodeBare(b) } @@ -189,21 +186,21 @@ func (s *ChannelsSendAsPeers) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *ChannelsSendAsPeers) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode channels.sendAsPeers#8356cda9 to nil") + return fmt.Errorf("can't decode channels.sendAsPeers#f496b0c6 to nil") } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channels.sendAsPeers#8356cda9: field peers: %w", err) + return fmt.Errorf("unable to decode channels.sendAsPeers#f496b0c6: field peers: %w", err) } if headerLen > 0 { - s.Peers = make([]PeerClass, 0, headerLen%bin.PreallocateLimit) + s.Peers = make([]SendAsPeer, 0, headerLen%bin.PreallocateLimit) } for idx := 0; idx < headerLen; idx++ { - value, err := DecodePeer(b) - if err != nil { - return fmt.Errorf("unable to decode channels.sendAsPeers#8356cda9: field peers: %w", err) + var value SendAsPeer + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode channels.sendAsPeers#f496b0c6: field peers: %w", err) } s.Peers = append(s.Peers, value) } @@ -211,7 +208,7 @@ func (s *ChannelsSendAsPeers) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channels.sendAsPeers#8356cda9: field chats: %w", err) + return fmt.Errorf("unable to decode channels.sendAsPeers#f496b0c6: field chats: %w", err) } if headerLen > 0 { @@ -220,7 +217,7 @@ func (s *ChannelsSendAsPeers) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeChat(b) if err != nil { - return fmt.Errorf("unable to decode channels.sendAsPeers#8356cda9: field chats: %w", err) + return fmt.Errorf("unable to decode channels.sendAsPeers#f496b0c6: field chats: %w", err) } s.Chats = append(s.Chats, value) } @@ -228,7 +225,7 @@ func (s *ChannelsSendAsPeers) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channels.sendAsPeers#8356cda9: field users: %w", err) + return fmt.Errorf("unable to decode channels.sendAsPeers#f496b0c6: field users: %w", err) } if headerLen > 0 { @@ -237,7 +234,7 @@ func (s *ChannelsSendAsPeers) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeUser(b) if err != nil { - return fmt.Errorf("unable to decode channels.sendAsPeers#8356cda9: field users: %w", err) + return fmt.Errorf("unable to decode channels.sendAsPeers#f496b0c6: field users: %w", err) } s.Users = append(s.Users, value) } @@ -246,7 +243,7 @@ func (s *ChannelsSendAsPeers) DecodeBare(b *bin.Buffer) error { } // GetPeers returns value of Peers field. -func (s *ChannelsSendAsPeers) GetPeers() (value []PeerClass) { +func (s *ChannelsSendAsPeers) GetPeers() (value []SendAsPeer) { if s == nil { return } @@ -269,11 +266,6 @@ func (s *ChannelsSendAsPeers) GetUsers() (value []UserClass) { return s.Users } -// MapPeers returns field Peers wrapped in PeerClassArray helper. -func (s *ChannelsSendAsPeers) MapPeers() (value PeerClassArray) { - return PeerClassArray(s.Peers) -} - // MapChats returns field Chats wrapped in ChatClassArray helper. func (s *ChannelsSendAsPeers) MapChats() (value ChatClassArray) { return ChatClassArray(s.Chats) diff --git a/tg/tl_chat_full_gen.go b/tg/tl_chat_full_gen.go index 32fa205a7b..de04a70c7e 100644 --- a/tg/tl_chat_full_gen.go +++ b/tg/tl_chat_full_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// ChatFull represents TL type `chatFull#d18ee226`. +// ChatFull represents TL type `chatFull#c9d31138`. // Full info about a basic group¹. // // Links: @@ -122,11 +122,11 @@ type ChatFull struct { // 1) https://core.telegram.org/api/reactions // // Use SetAvailableReactions and GetAvailableReactions helpers. - AvailableReactions []string + AvailableReactions ChatReactionsClass } // ChatFullTypeID is TL type id of ChatFull. -const ChatFullTypeID = 0xd18ee226 +const ChatFullTypeID = 0xc9d31138 // construct implements constructor of ChatFullClass. func (c ChatFull) construct() ChatFullClass { return &c } @@ -234,7 +234,7 @@ func (c *ChatFull) FillFrom(from interface { GetThemeEmoticon() (value string, ok bool) GetRequestsPending() (value int, ok bool) GetRecentRequesters() (value []int64, ok bool) - GetAvailableReactions() (value []string, ok bool) + GetAvailableReactions() (value ChatReactionsClass, ok bool) }) { c.CanSetUsername = from.GetCanSetUsername() c.HasScheduled = from.GetHasScheduled() @@ -454,7 +454,7 @@ func (c *ChatFull) SetFlags() { // Encode implements bin.Encoder. func (c *ChatFull) Encode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode chatFull#d18ee226 as nil") + return fmt.Errorf("can't encode chatFull#c9d31138 as nil") } b.PutID(ChatFullTypeID) return c.EncodeBare(b) @@ -463,44 +463,44 @@ func (c *ChatFull) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (c *ChatFull) EncodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode chatFull#d18ee226 as nil") + return fmt.Errorf("can't encode chatFull#c9d31138 as nil") } c.SetFlags() if err := c.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#d18ee226: field flags: %w", err) + return fmt.Errorf("unable to encode chatFull#c9d31138: field flags: %w", err) } b.PutLong(c.ID) b.PutString(c.About) if c.Participants == nil { - return fmt.Errorf("unable to encode chatFull#d18ee226: field participants is nil") + return fmt.Errorf("unable to encode chatFull#c9d31138: field participants is nil") } if err := c.Participants.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#d18ee226: field participants: %w", err) + return fmt.Errorf("unable to encode chatFull#c9d31138: field participants: %w", err) } if c.Flags.Has(2) { if c.ChatPhoto == nil { - return fmt.Errorf("unable to encode chatFull#d18ee226: field chat_photo is nil") + return fmt.Errorf("unable to encode chatFull#c9d31138: field chat_photo is nil") } if err := c.ChatPhoto.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#d18ee226: field chat_photo: %w", err) + return fmt.Errorf("unable to encode chatFull#c9d31138: field chat_photo: %w", err) } } if err := c.NotifySettings.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#d18ee226: field notify_settings: %w", err) + return fmt.Errorf("unable to encode chatFull#c9d31138: field notify_settings: %w", err) } if c.Flags.Has(13) { if c.ExportedInvite == nil { - return fmt.Errorf("unable to encode chatFull#d18ee226: field exported_invite is nil") + return fmt.Errorf("unable to encode chatFull#c9d31138: field exported_invite is nil") } if err := c.ExportedInvite.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#d18ee226: field exported_invite: %w", err) + return fmt.Errorf("unable to encode chatFull#c9d31138: field exported_invite: %w", err) } } if c.Flags.Has(3) { b.PutVectorHeader(len(c.BotInfo)) for idx, v := range c.BotInfo { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#d18ee226: field bot_info element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode chatFull#c9d31138: field bot_info element with index %d: %w", idx, err) } } } @@ -512,7 +512,7 @@ func (c *ChatFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(12) { if err := c.Call.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#d18ee226: field call: %w", err) + return fmt.Errorf("unable to encode chatFull#c9d31138: field call: %w", err) } } if c.Flags.Has(14) { @@ -520,10 +520,10 @@ func (c *ChatFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(15) { if c.GroupcallDefaultJoinAs == nil { - return fmt.Errorf("unable to encode chatFull#d18ee226: field groupcall_default_join_as is nil") + return fmt.Errorf("unable to encode chatFull#c9d31138: field groupcall_default_join_as is nil") } if err := c.GroupcallDefaultJoinAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#d18ee226: field groupcall_default_join_as: %w", err) + return fmt.Errorf("unable to encode chatFull#c9d31138: field groupcall_default_join_as: %w", err) } } if c.Flags.Has(16) { @@ -539,9 +539,11 @@ func (c *ChatFull) EncodeBare(b *bin.Buffer) error { } } if c.Flags.Has(18) { - b.PutVectorHeader(len(c.AvailableReactions)) - for _, v := range c.AvailableReactions { - b.PutString(v) + if c.AvailableReactions == nil { + return fmt.Errorf("unable to encode chatFull#c9d31138: field available_reactions is nil") + } + if err := c.AvailableReactions.Encode(b); err != nil { + return fmt.Errorf("unable to encode chatFull#c9d31138: field available_reactions: %w", err) } } return nil @@ -550,10 +552,10 @@ func (c *ChatFull) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (c *ChatFull) Decode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode chatFull#d18ee226 to nil") + return fmt.Errorf("can't decode chatFull#c9d31138 to nil") } if err := b.ConsumeID(ChatFullTypeID); err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: %w", err) } return c.DecodeBare(b) } @@ -561,11 +563,11 @@ func (c *ChatFull) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (c *ChatFull) DecodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode chatFull#d18ee226 to nil") + return fmt.Errorf("can't decode chatFull#c9d31138 to nil") } { if err := c.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field flags: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field flags: %w", err) } } c.CanSetUsername = c.Flags.Has(7) @@ -573,47 +575,47 @@ func (c *ChatFull) DecodeBare(b *bin.Buffer) error { { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field id: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field id: %w", err) } c.ID = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field about: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field about: %w", err) } c.About = value } { value, err := DecodeChatParticipants(b) if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field participants: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field participants: %w", err) } c.Participants = value } if c.Flags.Has(2) { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field chat_photo: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field chat_photo: %w", err) } c.ChatPhoto = value } { if err := c.NotifySettings.Decode(b); err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field notify_settings: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field notify_settings: %w", err) } } if c.Flags.Has(13) { value, err := DecodeExportedChatInvite(b) if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field exported_invite: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field exported_invite: %w", err) } c.ExportedInvite = value } if c.Flags.Has(3) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field bot_info: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field bot_info: %w", err) } if headerLen > 0 { @@ -622,7 +624,7 @@ func (c *ChatFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value BotInfo if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field bot_info: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field bot_info: %w", err) } c.BotInfo = append(c.BotInfo, value) } @@ -630,54 +632,54 @@ func (c *ChatFull) DecodeBare(b *bin.Buffer) error { if c.Flags.Has(6) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field pinned_msg_id: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field pinned_msg_id: %w", err) } c.PinnedMsgID = value } if c.Flags.Has(11) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field folder_id: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field folder_id: %w", err) } c.FolderID = value } if c.Flags.Has(12) { if err := c.Call.Decode(b); err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field call: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field call: %w", err) } } if c.Flags.Has(14) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field ttl_period: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field ttl_period: %w", err) } c.TTLPeriod = value } if c.Flags.Has(15) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field groupcall_default_join_as: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field groupcall_default_join_as: %w", err) } c.GroupcallDefaultJoinAs = value } if c.Flags.Has(16) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field theme_emoticon: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field theme_emoticon: %w", err) } c.ThemeEmoticon = value } if c.Flags.Has(17) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field requests_pending: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field requests_pending: %w", err) } c.RequestsPending = value } if c.Flags.Has(17) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field recent_requesters: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field recent_requesters: %w", err) } if headerLen > 0 { @@ -686,27 +688,17 @@ func (c *ChatFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field recent_requesters: %w", err) + return fmt.Errorf("unable to decode chatFull#c9d31138: field recent_requesters: %w", err) } c.RecentRequesters = append(c.RecentRequesters, value) } } if c.Flags.Has(18) { - headerLen, err := b.VectorHeader() + value, err := DecodeChatReactions(b) if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field available_reactions: %w", err) - } - - if headerLen > 0 { - c.AvailableReactions = make([]string, 0, headerLen%bin.PreallocateLimit) - } - for idx := 0; idx < headerLen; idx++ { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode chatFull#d18ee226: field available_reactions: %w", err) - } - c.AvailableReactions = append(c.AvailableReactions, value) + return fmt.Errorf("unable to decode chatFull#c9d31138: field available_reactions: %w", err) } + c.AvailableReactions = value } return nil } @@ -980,14 +972,14 @@ func (c *ChatFull) GetRecentRequesters() (value []int64, ok bool) { } // SetAvailableReactions sets value of AvailableReactions conditional field. -func (c *ChatFull) SetAvailableReactions(value []string) { +func (c *ChatFull) SetAvailableReactions(value ChatReactionsClass) { c.Flags.Set(18) c.AvailableReactions = value } // GetAvailableReactions returns value of AvailableReactions conditional field and // boolean which is true if field was set. -func (c *ChatFull) GetAvailableReactions() (value []string, ok bool) { +func (c *ChatFull) GetAvailableReactions() (value ChatReactionsClass, ok bool) { if c == nil { return } @@ -997,7 +989,7 @@ func (c *ChatFull) GetAvailableReactions() (value []string, ok bool) { return c.AvailableReactions, true } -// ChannelFull represents TL type `channelFull#ea68a619`. +// ChannelFull represents TL type `channelFull#f2355507`. // Full info about a channel¹, supergroup² or gigagroup³. // // Links: @@ -1206,11 +1198,11 @@ type ChannelFull struct { // 1) https://core.telegram.org/api/reactions // // Use SetAvailableReactions and GetAvailableReactions helpers. - AvailableReactions []string + AvailableReactions ChatReactionsClass } // ChannelFullTypeID is TL type id of ChannelFull. -const ChannelFullTypeID = 0xea68a619 +const ChannelFullTypeID = 0xf2355507 // construct implements constructor of ChatFullClass. func (c ChannelFull) construct() ChatFullClass { return &c } @@ -1425,7 +1417,7 @@ func (c *ChannelFull) FillFrom(from interface { GetRequestsPending() (value int, ok bool) GetRecentRequesters() (value []int64, ok bool) GetDefaultSendAs() (value PeerClass, ok bool) - GetAvailableReactions() (value []string, ok bool) + GetAvailableReactions() (value ChatReactionsClass, ok bool) }) { c.CanViewParticipants = from.GetCanViewParticipants() c.CanSetUsername = from.GetCanSetUsername() @@ -1901,7 +1893,7 @@ func (c *ChannelFull) SetFlags() { // Encode implements bin.Encoder. func (c *ChannelFull) Encode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channelFull#ea68a619 as nil") + return fmt.Errorf("can't encode channelFull#f2355507 as nil") } b.PutID(ChannelFullTypeID) return c.EncodeBare(b) @@ -1910,14 +1902,14 @@ func (c *ChannelFull) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channelFull#ea68a619 as nil") + return fmt.Errorf("can't encode channelFull#f2355507 as nil") } c.SetFlags() if err := c.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field flags: %w", err) + return fmt.Errorf("unable to encode channelFull#f2355507: field flags: %w", err) } if err := c.Flags2.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field flags2: %w", err) + return fmt.Errorf("unable to encode channelFull#f2355507: field flags2: %w", err) } b.PutLong(c.ID) b.PutString(c.About) @@ -1940,26 +1932,26 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { b.PutInt(c.ReadOutboxMaxID) b.PutInt(c.UnreadCount) if c.ChatPhoto == nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field chat_photo is nil") + return fmt.Errorf("unable to encode channelFull#f2355507: field chat_photo is nil") } if err := c.ChatPhoto.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field chat_photo: %w", err) + return fmt.Errorf("unable to encode channelFull#f2355507: field chat_photo: %w", err) } if err := c.NotifySettings.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field notify_settings: %w", err) + return fmt.Errorf("unable to encode channelFull#f2355507: field notify_settings: %w", err) } if c.Flags.Has(23) { if c.ExportedInvite == nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field exported_invite is nil") + return fmt.Errorf("unable to encode channelFull#f2355507: field exported_invite is nil") } if err := c.ExportedInvite.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field exported_invite: %w", err) + return fmt.Errorf("unable to encode channelFull#f2355507: field exported_invite: %w", err) } } b.PutVectorHeader(len(c.BotInfo)) for idx, v := range c.BotInfo { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field bot_info element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode channelFull#f2355507: field bot_info element with index %d: %w", idx, err) } } if c.Flags.Has(4) { @@ -1973,7 +1965,7 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(8) { if err := c.Stickerset.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field stickerset: %w", err) + return fmt.Errorf("unable to encode channelFull#f2355507: field stickerset: %w", err) } } if c.Flags.Has(9) { @@ -1987,10 +1979,10 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(15) { if c.Location == nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field location is nil") + return fmt.Errorf("unable to encode channelFull#f2355507: field location is nil") } if err := c.Location.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field location: %w", err) + return fmt.Errorf("unable to encode channelFull#f2355507: field location: %w", err) } } if c.Flags.Has(17) { @@ -2005,7 +1997,7 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { b.PutInt(c.Pts) if c.Flags.Has(21) { if err := c.Call.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field call: %w", err) + return fmt.Errorf("unable to encode channelFull#f2355507: field call: %w", err) } } if c.Flags.Has(24) { @@ -2019,10 +2011,10 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(26) { if c.GroupcallDefaultJoinAs == nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field groupcall_default_join_as is nil") + return fmt.Errorf("unable to encode channelFull#f2355507: field groupcall_default_join_as is nil") } if err := c.GroupcallDefaultJoinAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field groupcall_default_join_as: %w", err) + return fmt.Errorf("unable to encode channelFull#f2355507: field groupcall_default_join_as: %w", err) } } if c.Flags.Has(27) { @@ -2039,16 +2031,18 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(29) { if c.DefaultSendAs == nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field default_send_as is nil") + return fmt.Errorf("unable to encode channelFull#f2355507: field default_send_as is nil") } if err := c.DefaultSendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#ea68a619: field default_send_as: %w", err) + return fmt.Errorf("unable to encode channelFull#f2355507: field default_send_as: %w", err) } } if c.Flags.Has(30) { - b.PutVectorHeader(len(c.AvailableReactions)) - for _, v := range c.AvailableReactions { - b.PutString(v) + if c.AvailableReactions == nil { + return fmt.Errorf("unable to encode channelFull#f2355507: field available_reactions is nil") + } + if err := c.AvailableReactions.Encode(b); err != nil { + return fmt.Errorf("unable to encode channelFull#f2355507: field available_reactions: %w", err) } } return nil @@ -2057,10 +2051,10 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (c *ChannelFull) Decode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channelFull#ea68a619 to nil") + return fmt.Errorf("can't decode channelFull#f2355507 to nil") } if err := b.ConsumeID(ChannelFullTypeID); err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: %w", err) } return c.DecodeBare(b) } @@ -2068,11 +2062,11 @@ func (c *ChannelFull) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channelFull#ea68a619 to nil") + return fmt.Errorf("can't decode channelFull#f2355507 to nil") } { if err := c.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field flags: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field flags: %w", err) } } c.CanViewParticipants = c.Flags.Has(3) @@ -2085,103 +2079,103 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { c.Blocked = c.Flags.Has(22) { if err := c.Flags2.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field flags2: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field flags2: %w", err) } } c.CanDeleteChannel = c.Flags2.Has(0) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field id: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field id: %w", err) } c.ID = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field about: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field about: %w", err) } c.About = value } if c.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field participants_count: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field participants_count: %w", err) } c.ParticipantsCount = value } if c.Flags.Has(1) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field admins_count: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field admins_count: %w", err) } c.AdminsCount = value } if c.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field kicked_count: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field kicked_count: %w", err) } c.KickedCount = value } if c.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field banned_count: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field banned_count: %w", err) } c.BannedCount = value } if c.Flags.Has(13) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field online_count: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field online_count: %w", err) } c.OnlineCount = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field read_inbox_max_id: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field read_inbox_max_id: %w", err) } c.ReadInboxMaxID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field read_outbox_max_id: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field read_outbox_max_id: %w", err) } c.ReadOutboxMaxID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field unread_count: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field unread_count: %w", err) } c.UnreadCount = value } { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field chat_photo: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field chat_photo: %w", err) } c.ChatPhoto = value } { if err := c.NotifySettings.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field notify_settings: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field notify_settings: %w", err) } } if c.Flags.Has(23) { value, err := DecodeExportedChatInvite(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field exported_invite: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field exported_invite: %w", err) } c.ExportedInvite = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field bot_info: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field bot_info: %w", err) } if headerLen > 0 { @@ -2190,7 +2184,7 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value BotInfo if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field bot_info: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field bot_info: %w", err) } c.BotInfo = append(c.BotInfo, value) } @@ -2198,101 +2192,101 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { if c.Flags.Has(4) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field migrated_from_chat_id: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field migrated_from_chat_id: %w", err) } c.MigratedFromChatID = value } if c.Flags.Has(4) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field migrated_from_max_id: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field migrated_from_max_id: %w", err) } c.MigratedFromMaxID = value } if c.Flags.Has(5) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field pinned_msg_id: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field pinned_msg_id: %w", err) } c.PinnedMsgID = value } if c.Flags.Has(8) { if err := c.Stickerset.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field stickerset: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field stickerset: %w", err) } } if c.Flags.Has(9) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field available_min_id: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field available_min_id: %w", err) } c.AvailableMinID = value } if c.Flags.Has(11) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field folder_id: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field folder_id: %w", err) } c.FolderID = value } if c.Flags.Has(14) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field linked_chat_id: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field linked_chat_id: %w", err) } c.LinkedChatID = value } if c.Flags.Has(15) { value, err := DecodeChannelLocation(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field location: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field location: %w", err) } c.Location = value } if c.Flags.Has(17) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field slowmode_seconds: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field slowmode_seconds: %w", err) } c.SlowmodeSeconds = value } if c.Flags.Has(18) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field slowmode_next_send_date: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field slowmode_next_send_date: %w", err) } c.SlowmodeNextSendDate = value } if c.Flags.Has(12) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field stats_dc: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field stats_dc: %w", err) } c.StatsDC = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field pts: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field pts: %w", err) } c.Pts = value } if c.Flags.Has(21) { if err := c.Call.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field call: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field call: %w", err) } } if c.Flags.Has(24) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field ttl_period: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field ttl_period: %w", err) } c.TTLPeriod = value } if c.Flags.Has(25) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field pending_suggestions: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field pending_suggestions: %w", err) } if headerLen > 0 { @@ -2301,7 +2295,7 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field pending_suggestions: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field pending_suggestions: %w", err) } c.PendingSuggestions = append(c.PendingSuggestions, value) } @@ -2309,28 +2303,28 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { if c.Flags.Has(26) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field groupcall_default_join_as: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field groupcall_default_join_as: %w", err) } c.GroupcallDefaultJoinAs = value } if c.Flags.Has(27) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field theme_emoticon: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field theme_emoticon: %w", err) } c.ThemeEmoticon = value } if c.Flags.Has(28) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field requests_pending: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field requests_pending: %w", err) } c.RequestsPending = value } if c.Flags.Has(28) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field recent_requesters: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field recent_requesters: %w", err) } if headerLen > 0 { @@ -2339,7 +2333,7 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field recent_requesters: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field recent_requesters: %w", err) } c.RecentRequesters = append(c.RecentRequesters, value) } @@ -2347,26 +2341,16 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { if c.Flags.Has(29) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field default_send_as: %w", err) + return fmt.Errorf("unable to decode channelFull#f2355507: field default_send_as: %w", err) } c.DefaultSendAs = value } if c.Flags.Has(30) { - headerLen, err := b.VectorHeader() + value, err := DecodeChatReactions(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field available_reactions: %w", err) - } - - if headerLen > 0 { - c.AvailableReactions = make([]string, 0, headerLen%bin.PreallocateLimit) - } - for idx := 0; idx < headerLen; idx++ { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode channelFull#ea68a619: field available_reactions: %w", err) - } - c.AvailableReactions = append(c.AvailableReactions, value) + return fmt.Errorf("unable to decode channelFull#f2355507: field available_reactions: %w", err) } + c.AvailableReactions = value } return nil } @@ -3065,14 +3049,14 @@ func (c *ChannelFull) GetDefaultSendAs() (value PeerClass, ok bool) { } // SetAvailableReactions sets value of AvailableReactions conditional field. -func (c *ChannelFull) SetAvailableReactions(value []string) { +func (c *ChannelFull) SetAvailableReactions(value ChatReactionsClass) { c.Flags.Set(30) c.AvailableReactions = value } // GetAvailableReactions returns value of AvailableReactions conditional field and // boolean which is true if field was set. -func (c *ChannelFull) GetAvailableReactions() (value []string, ok bool) { +func (c *ChannelFull) GetAvailableReactions() (value ChatReactionsClass, ok bool) { if c == nil { return } @@ -3096,8 +3080,8 @@ const ChatFullClassName = "ChatFull" // panic(err) // } // switch v := g.(type) { -// case *tg.ChatFull: // chatFull#d18ee226 -// case *tg.ChannelFull: // channelFull#ea68a619 +// case *tg.ChatFull: // chatFull#c9d31138 +// case *tg.ChannelFull: // channelFull#f2355507 // default: panic(v) // } type ChatFullClass interface { @@ -3179,7 +3163,7 @@ type ChatFullClass interface { // // Links: // 1) https://core.telegram.org/api/reactions - GetAvailableReactions() (value []string, ok bool) + GetAvailableReactions() (value ChatReactionsClass, ok bool) } // DecodeChatFull implements binary de-serialization for ChatFullClass. @@ -3190,14 +3174,14 @@ func DecodeChatFull(buf *bin.Buffer) (ChatFullClass, error) { } switch id { case ChatFullTypeID: - // Decoding chatFull#d18ee226. + // Decoding chatFull#c9d31138. v := ChatFull{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ChatFullClass: %w", err) } return &v, nil case ChannelFullTypeID: - // Decoding channelFull#ea68a619. + // Decoding channelFull#f2355507. v := ChannelFull{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ChatFullClass: %w", err) diff --git a/tg/tl_chat_reactions_gen.go b/tg/tl_chat_reactions_gen.go new file mode 100644 index 0000000000..26dc5a20fb --- /dev/null +++ b/tg/tl_chat_reactions_gen.go @@ -0,0 +1,547 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// ChatReactionsNone represents TL type `chatReactionsNone#eafc32bc`. +// +// See https://core.telegram.org/constructor/chatReactionsNone for reference. +type ChatReactionsNone struct { +} + +// ChatReactionsNoneTypeID is TL type id of ChatReactionsNone. +const ChatReactionsNoneTypeID = 0xeafc32bc + +// construct implements constructor of ChatReactionsClass. +func (c ChatReactionsNone) construct() ChatReactionsClass { return &c } + +// Ensuring interfaces in compile-time for ChatReactionsNone. +var ( + _ bin.Encoder = &ChatReactionsNone{} + _ bin.Decoder = &ChatReactionsNone{} + _ bin.BareEncoder = &ChatReactionsNone{} + _ bin.BareDecoder = &ChatReactionsNone{} + + _ ChatReactionsClass = &ChatReactionsNone{} +) + +func (c *ChatReactionsNone) Zero() bool { + if c == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChatReactionsNone) String() string { + if c == nil { + return "ChatReactionsNone(nil)" + } + type Alias ChatReactionsNone + return fmt.Sprintf("ChatReactionsNone%+v", Alias(*c)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChatReactionsNone) TypeID() uint32 { + return ChatReactionsNoneTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChatReactionsNone) TypeName() string { + return "chatReactionsNone" +} + +// TypeInfo returns info about TL type. +func (c *ChatReactionsNone) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "chatReactionsNone", + ID: ChatReactionsNoneTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (c *ChatReactionsNone) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode chatReactionsNone#eafc32bc as nil") + } + b.PutID(ChatReactionsNoneTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChatReactionsNone) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode chatReactionsNone#eafc32bc as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (c *ChatReactionsNone) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode chatReactionsNone#eafc32bc to nil") + } + if err := b.ConsumeID(ChatReactionsNoneTypeID); err != nil { + return fmt.Errorf("unable to decode chatReactionsNone#eafc32bc: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChatReactionsNone) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode chatReactionsNone#eafc32bc to nil") + } + return nil +} + +// ChatReactionsAll represents TL type `chatReactionsAll#52928bca`. +// +// See https://core.telegram.org/constructor/chatReactionsAll for reference. +type ChatReactionsAll struct { + // Flags field of ChatReactionsAll. + Flags bin.Fields + // AllowCustom field of ChatReactionsAll. + AllowCustom bool +} + +// ChatReactionsAllTypeID is TL type id of ChatReactionsAll. +const ChatReactionsAllTypeID = 0x52928bca + +// construct implements constructor of ChatReactionsClass. +func (c ChatReactionsAll) construct() ChatReactionsClass { return &c } + +// Ensuring interfaces in compile-time for ChatReactionsAll. +var ( + _ bin.Encoder = &ChatReactionsAll{} + _ bin.Decoder = &ChatReactionsAll{} + _ bin.BareEncoder = &ChatReactionsAll{} + _ bin.BareDecoder = &ChatReactionsAll{} + + _ ChatReactionsClass = &ChatReactionsAll{} +) + +func (c *ChatReactionsAll) Zero() bool { + if c == nil { + return true + } + if !(c.Flags.Zero()) { + return false + } + if !(c.AllowCustom == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChatReactionsAll) String() string { + if c == nil { + return "ChatReactionsAll(nil)" + } + type Alias ChatReactionsAll + return fmt.Sprintf("ChatReactionsAll%+v", Alias(*c)) +} + +// FillFrom fills ChatReactionsAll from given interface. +func (c *ChatReactionsAll) FillFrom(from interface { + GetAllowCustom() (value bool) +}) { + c.AllowCustom = from.GetAllowCustom() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChatReactionsAll) TypeID() uint32 { + return ChatReactionsAllTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChatReactionsAll) TypeName() string { + return "chatReactionsAll" +} + +// TypeInfo returns info about TL type. +func (c *ChatReactionsAll) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "chatReactionsAll", + ID: ChatReactionsAllTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "AllowCustom", + SchemaName: "allow_custom", + Null: !c.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (c *ChatReactionsAll) SetFlags() { + if !(c.AllowCustom == false) { + c.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (c *ChatReactionsAll) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode chatReactionsAll#52928bca as nil") + } + b.PutID(ChatReactionsAllTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChatReactionsAll) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode chatReactionsAll#52928bca as nil") + } + c.SetFlags() + if err := c.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode chatReactionsAll#52928bca: field flags: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (c *ChatReactionsAll) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode chatReactionsAll#52928bca to nil") + } + if err := b.ConsumeID(ChatReactionsAllTypeID); err != nil { + return fmt.Errorf("unable to decode chatReactionsAll#52928bca: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChatReactionsAll) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode chatReactionsAll#52928bca to nil") + } + { + if err := c.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode chatReactionsAll#52928bca: field flags: %w", err) + } + } + c.AllowCustom = c.Flags.Has(0) + return nil +} + +// SetAllowCustom sets value of AllowCustom conditional field. +func (c *ChatReactionsAll) SetAllowCustom(value bool) { + if value { + c.Flags.Set(0) + c.AllowCustom = true + } else { + c.Flags.Unset(0) + c.AllowCustom = false + } +} + +// GetAllowCustom returns value of AllowCustom conditional field. +func (c *ChatReactionsAll) GetAllowCustom() (value bool) { + if c == nil { + return + } + return c.Flags.Has(0) +} + +// ChatReactionsSome represents TL type `chatReactionsSome#661d4037`. +// +// See https://core.telegram.org/constructor/chatReactionsSome for reference. +type ChatReactionsSome struct { + // Reactions field of ChatReactionsSome. + Reactions []ReactionClass +} + +// ChatReactionsSomeTypeID is TL type id of ChatReactionsSome. +const ChatReactionsSomeTypeID = 0x661d4037 + +// construct implements constructor of ChatReactionsClass. +func (c ChatReactionsSome) construct() ChatReactionsClass { return &c } + +// Ensuring interfaces in compile-time for ChatReactionsSome. +var ( + _ bin.Encoder = &ChatReactionsSome{} + _ bin.Decoder = &ChatReactionsSome{} + _ bin.BareEncoder = &ChatReactionsSome{} + _ bin.BareDecoder = &ChatReactionsSome{} + + _ ChatReactionsClass = &ChatReactionsSome{} +) + +func (c *ChatReactionsSome) Zero() bool { + if c == nil { + return true + } + if !(c.Reactions == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChatReactionsSome) String() string { + if c == nil { + return "ChatReactionsSome(nil)" + } + type Alias ChatReactionsSome + return fmt.Sprintf("ChatReactionsSome%+v", Alias(*c)) +} + +// FillFrom fills ChatReactionsSome from given interface. +func (c *ChatReactionsSome) FillFrom(from interface { + GetReactions() (value []ReactionClass) +}) { + c.Reactions = from.GetReactions() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChatReactionsSome) TypeID() uint32 { + return ChatReactionsSomeTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChatReactionsSome) TypeName() string { + return "chatReactionsSome" +} + +// TypeInfo returns info about TL type. +func (c *ChatReactionsSome) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "chatReactionsSome", + ID: ChatReactionsSomeTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Reactions", + SchemaName: "reactions", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *ChatReactionsSome) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode chatReactionsSome#661d4037 as nil") + } + b.PutID(ChatReactionsSomeTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChatReactionsSome) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode chatReactionsSome#661d4037 as nil") + } + b.PutVectorHeader(len(c.Reactions)) + for idx, v := range c.Reactions { + if v == nil { + return fmt.Errorf("unable to encode chatReactionsSome#661d4037: field reactions element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode chatReactionsSome#661d4037: field reactions element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (c *ChatReactionsSome) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode chatReactionsSome#661d4037 to nil") + } + if err := b.ConsumeID(ChatReactionsSomeTypeID); err != nil { + return fmt.Errorf("unable to decode chatReactionsSome#661d4037: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChatReactionsSome) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode chatReactionsSome#661d4037 to nil") + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode chatReactionsSome#661d4037: field reactions: %w", err) + } + + if headerLen > 0 { + c.Reactions = make([]ReactionClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeReaction(b) + if err != nil { + return fmt.Errorf("unable to decode chatReactionsSome#661d4037: field reactions: %w", err) + } + c.Reactions = append(c.Reactions, value) + } + } + return nil +} + +// GetReactions returns value of Reactions field. +func (c *ChatReactionsSome) GetReactions() (value []ReactionClass) { + if c == nil { + return + } + return c.Reactions +} + +// MapReactions returns field Reactions wrapped in ReactionClassArray helper. +func (c *ChatReactionsSome) MapReactions() (value ReactionClassArray) { + return ReactionClassArray(c.Reactions) +} + +// ChatReactionsClassName is schema name of ChatReactionsClass. +const ChatReactionsClassName = "ChatReactions" + +// ChatReactionsClass represents ChatReactions generic type. +// +// See https://core.telegram.org/type/ChatReactions for reference. +// +// Example: +// +// g, err := tg.DecodeChatReactions(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.ChatReactionsNone: // chatReactionsNone#eafc32bc +// case *tg.ChatReactionsAll: // chatReactionsAll#52928bca +// case *tg.ChatReactionsSome: // chatReactionsSome#661d4037 +// default: panic(v) +// } +type ChatReactionsClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() ChatReactionsClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool +} + +// DecodeChatReactions implements binary de-serialization for ChatReactionsClass. +func DecodeChatReactions(buf *bin.Buffer) (ChatReactionsClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case ChatReactionsNoneTypeID: + // Decoding chatReactionsNone#eafc32bc. + v := ChatReactionsNone{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ChatReactionsClass: %w", err) + } + return &v, nil + case ChatReactionsAllTypeID: + // Decoding chatReactionsAll#52928bca. + v := ChatReactionsAll{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ChatReactionsClass: %w", err) + } + return &v, nil + case ChatReactionsSomeTypeID: + // Decoding chatReactionsSome#661d4037. + v := ChatReactionsSome{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ChatReactionsClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode ChatReactionsClass: %w", bin.NewUnexpectedID(id)) + } +} + +// ChatReactions boxes the ChatReactionsClass providing a helper. +type ChatReactionsBox struct { + ChatReactions ChatReactionsClass +} + +// Decode implements bin.Decoder for ChatReactionsBox. +func (b *ChatReactionsBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode ChatReactionsBox to nil") + } + v, err := DecodeChatReactions(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.ChatReactions = v + return nil +} + +// Encode implements bin.Encode for ChatReactionsBox. +func (b *ChatReactionsBox) Encode(buf *bin.Buffer) error { + if b == nil || b.ChatReactions == nil { + return fmt.Errorf("unable to encode ChatReactionsClass as nil") + } + return b.ChatReactions.Encode(buf) +} diff --git a/tg/tl_chat_reactions_slices_gen.go b/tg/tl_chat_reactions_slices_gen.go new file mode 100644 index 0000000000..359f696ce1 --- /dev/null +++ b/tg/tl_chat_reactions_slices_gen.go @@ -0,0 +1,307 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// ChatReactionsClassArray is adapter for slice of ChatReactionsClass. +type ChatReactionsClassArray []ChatReactionsClass + +// Sort sorts slice of ChatReactionsClass. +func (s ChatReactionsClassArray) Sort(less func(a, b ChatReactionsClass) bool) ChatReactionsClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ChatReactionsClass. +func (s ChatReactionsClassArray) SortStable(less func(a, b ChatReactionsClass) bool) ChatReactionsClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ChatReactionsClass. +func (s ChatReactionsClassArray) Retain(keep func(x ChatReactionsClass) bool) ChatReactionsClassArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s ChatReactionsClassArray) First() (v ChatReactionsClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ChatReactionsClassArray) Last() (v ChatReactionsClass, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *ChatReactionsClassArray) PopFirst() (v ChatReactionsClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero ChatReactionsClass + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *ChatReactionsClassArray) Pop() (v ChatReactionsClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// AsChatReactionsAll returns copy with only ChatReactionsAll constructors. +func (s ChatReactionsClassArray) AsChatReactionsAll() (to ChatReactionsAllArray) { + for _, elem := range s { + value, ok := elem.(*ChatReactionsAll) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsChatReactionsSome returns copy with only ChatReactionsSome constructors. +func (s ChatReactionsClassArray) AsChatReactionsSome() (to ChatReactionsSomeArray) { + for _, elem := range s { + value, ok := elem.(*ChatReactionsSome) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// ChatReactionsAllArray is adapter for slice of ChatReactionsAll. +type ChatReactionsAllArray []ChatReactionsAll + +// Sort sorts slice of ChatReactionsAll. +func (s ChatReactionsAllArray) Sort(less func(a, b ChatReactionsAll) bool) ChatReactionsAllArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ChatReactionsAll. +func (s ChatReactionsAllArray) SortStable(less func(a, b ChatReactionsAll) bool) ChatReactionsAllArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ChatReactionsAll. +func (s ChatReactionsAllArray) Retain(keep func(x ChatReactionsAll) bool) ChatReactionsAllArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s ChatReactionsAllArray) First() (v ChatReactionsAll, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ChatReactionsAllArray) Last() (v ChatReactionsAll, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *ChatReactionsAllArray) PopFirst() (v ChatReactionsAll, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero ChatReactionsAll + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *ChatReactionsAllArray) Pop() (v ChatReactionsAll, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// ChatReactionsSomeArray is adapter for slice of ChatReactionsSome. +type ChatReactionsSomeArray []ChatReactionsSome + +// Sort sorts slice of ChatReactionsSome. +func (s ChatReactionsSomeArray) Sort(less func(a, b ChatReactionsSome) bool) ChatReactionsSomeArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ChatReactionsSome. +func (s ChatReactionsSomeArray) SortStable(less func(a, b ChatReactionsSome) bool) ChatReactionsSomeArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ChatReactionsSome. +func (s ChatReactionsSomeArray) Retain(keep func(x ChatReactionsSome) bool) ChatReactionsSomeArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s ChatReactionsSomeArray) First() (v ChatReactionsSome, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ChatReactionsSomeArray) Last() (v ChatReactionsSome, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *ChatReactionsSomeArray) PopFirst() (v ChatReactionsSome, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero ChatReactionsSome + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *ChatReactionsSomeArray) Pop() (v ChatReactionsSome, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_config_gen.go b/tg/tl_config_gen.go index 04dc12e947..a00fcf7b93 100644 --- a/tg/tl_config_gen.go +++ b/tg/tl_config_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// Config represents TL type `config#330b4067`. +// Config represents TL type `config#232566ac`. // Current configuration // // See https://core.telegram.org/constructor/config for reference. @@ -211,10 +211,14 @@ type Config struct { // // Use SetBaseLangPackVersion and GetBaseLangPackVersion helpers. BaseLangPackVersion int + // ReactionsDefault field of Config. + // + // Use SetReactionsDefault and GetReactionsDefault helpers. + ReactionsDefault ReactionClass } // ConfigTypeID is TL type id of Config. -const ConfigTypeID = 0x330b4067 +const ConfigTypeID = 0x232566ac // Ensuring interfaces in compile-time for Config. var ( @@ -387,6 +391,9 @@ func (c *Config) Zero() bool { if !(c.BaseLangPackVersion == 0) { return false } + if !(c.ReactionsDefault == nil) { + return false + } return true } @@ -454,6 +461,7 @@ func (c *Config) FillFrom(from interface { GetSuggestedLangCode() (value string, ok bool) GetLangPackVersion() (value int, ok bool) GetBaseLangPackVersion() (value int, ok bool) + GetReactionsDefault() (value ReactionClass, ok bool) }) { c.PhonecallsEnabled = from.GetPhonecallsEnabled() c.DefaultP2PContacts = from.GetDefaultP2PContacts() @@ -534,6 +542,10 @@ func (c *Config) FillFrom(from interface { c.BaseLangPackVersion = val } + if val, ok := from.GetReactionsDefault(); ok { + c.ReactionsDefault = val + } + } // TypeID returns type id in TL schema. @@ -784,6 +796,11 @@ func (c *Config) TypeInfo() tdp.Type { SchemaName: "base_lang_pack_version", Null: !c.Flags.Has(2), }, + { + Name: "ReactionsDefault", + SchemaName: "reactions_default", + Null: !c.Flags.Has(15), + }, } return typ } @@ -841,12 +858,15 @@ func (c *Config) SetFlags() { if !(c.BaseLangPackVersion == 0) { c.Flags.Set(2) } + if !(c.ReactionsDefault == nil) { + c.Flags.Set(15) + } } // Encode implements bin.Encoder. func (c *Config) Encode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode config#330b4067 as nil") + return fmt.Errorf("can't encode config#232566ac as nil") } b.PutID(ConfigTypeID) return c.EncodeBare(b) @@ -855,11 +875,11 @@ func (c *Config) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (c *Config) EncodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode config#330b4067 as nil") + return fmt.Errorf("can't encode config#232566ac as nil") } c.SetFlags() if err := c.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode config#330b4067: field flags: %w", err) + return fmt.Errorf("unable to encode config#232566ac: field flags: %w", err) } b.PutInt(c.Date) b.PutInt(c.Expires) @@ -868,7 +888,7 @@ func (c *Config) EncodeBare(b *bin.Buffer) error { b.PutVectorHeader(len(c.DCOptions)) for idx, v := range c.DCOptions { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode config#330b4067: field dc_options element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode config#232566ac: field dc_options element with index %d: %w", idx, err) } } b.PutString(c.DCTxtDomainName) @@ -928,16 +948,24 @@ func (c *Config) EncodeBare(b *bin.Buffer) error { if c.Flags.Has(2) { b.PutInt(c.BaseLangPackVersion) } + if c.Flags.Has(15) { + if c.ReactionsDefault == nil { + return fmt.Errorf("unable to encode config#232566ac: field reactions_default is nil") + } + if err := c.ReactionsDefault.Encode(b); err != nil { + return fmt.Errorf("unable to encode config#232566ac: field reactions_default: %w", err) + } + } return nil } // Decode implements bin.Decoder. func (c *Config) Decode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode config#330b4067 to nil") + return fmt.Errorf("can't decode config#232566ac to nil") } if err := b.ConsumeID(ConfigTypeID); err != nil { - return fmt.Errorf("unable to decode config#330b4067: %w", err) + return fmt.Errorf("unable to decode config#232566ac: %w", err) } return c.DecodeBare(b) } @@ -945,11 +973,11 @@ func (c *Config) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (c *Config) DecodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode config#330b4067 to nil") + return fmt.Errorf("can't decode config#232566ac to nil") } { if err := c.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode config#330b4067: field flags: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field flags: %w", err) } } c.PhonecallsEnabled = c.Flags.Has(1) @@ -963,35 +991,35 @@ func (c *Config) DecodeBare(b *bin.Buffer) error { { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field date: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field date: %w", err) } c.Date = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field expires: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field expires: %w", err) } c.Expires = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field test_mode: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field test_mode: %w", err) } c.TestMode = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field this_dc: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field this_dc: %w", err) } c.ThisDC = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field dc_options: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field dc_options: %w", err) } if headerLen > 0 { @@ -1000,7 +1028,7 @@ func (c *Config) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value DCOption if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode config#330b4067: field dc_options: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field dc_options: %w", err) } c.DCOptions = append(c.DCOptions, value) } @@ -1008,276 +1036,283 @@ func (c *Config) DecodeBare(b *bin.Buffer) error { { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field dc_txt_domain_name: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field dc_txt_domain_name: %w", err) } c.DCTxtDomainName = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field chat_size_max: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field chat_size_max: %w", err) } c.ChatSizeMax = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field megagroup_size_max: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field megagroup_size_max: %w", err) } c.MegagroupSizeMax = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field forwarded_count_max: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field forwarded_count_max: %w", err) } c.ForwardedCountMax = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field online_update_period_ms: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field online_update_period_ms: %w", err) } c.OnlineUpdatePeriodMs = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field offline_blur_timeout_ms: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field offline_blur_timeout_ms: %w", err) } c.OfflineBlurTimeoutMs = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field offline_idle_timeout_ms: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field offline_idle_timeout_ms: %w", err) } c.OfflineIdleTimeoutMs = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field online_cloud_timeout_ms: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field online_cloud_timeout_ms: %w", err) } c.OnlineCloudTimeoutMs = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field notify_cloud_delay_ms: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field notify_cloud_delay_ms: %w", err) } c.NotifyCloudDelayMs = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field notify_default_delay_ms: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field notify_default_delay_ms: %w", err) } c.NotifyDefaultDelayMs = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field push_chat_period_ms: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field push_chat_period_ms: %w", err) } c.PushChatPeriodMs = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field push_chat_limit: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field push_chat_limit: %w", err) } c.PushChatLimit = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field saved_gifs_limit: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field saved_gifs_limit: %w", err) } c.SavedGifsLimit = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field edit_time_limit: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field edit_time_limit: %w", err) } c.EditTimeLimit = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field revoke_time_limit: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field revoke_time_limit: %w", err) } c.RevokeTimeLimit = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field revoke_pm_time_limit: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field revoke_pm_time_limit: %w", err) } c.RevokePmTimeLimit = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field rating_e_decay: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field rating_e_decay: %w", err) } c.RatingEDecay = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field stickers_recent_limit: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field stickers_recent_limit: %w", err) } c.StickersRecentLimit = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field stickers_faved_limit: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field stickers_faved_limit: %w", err) } c.StickersFavedLimit = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field channels_read_media_period: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field channels_read_media_period: %w", err) } c.ChannelsReadMediaPeriod = value } if c.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field tmp_sessions: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field tmp_sessions: %w", err) } c.TmpSessions = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field pinned_dialogs_count_max: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field pinned_dialogs_count_max: %w", err) } c.PinnedDialogsCountMax = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field pinned_infolder_count_max: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field pinned_infolder_count_max: %w", err) } c.PinnedInfolderCountMax = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field call_receive_timeout_ms: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field call_receive_timeout_ms: %w", err) } c.CallReceiveTimeoutMs = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field call_ring_timeout_ms: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field call_ring_timeout_ms: %w", err) } c.CallRingTimeoutMs = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field call_connect_timeout_ms: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field call_connect_timeout_ms: %w", err) } c.CallConnectTimeoutMs = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field call_packet_timeout_ms: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field call_packet_timeout_ms: %w", err) } c.CallPacketTimeoutMs = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field me_url_prefix: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field me_url_prefix: %w", err) } c.MeURLPrefix = value } if c.Flags.Has(7) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field autoupdate_url_prefix: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field autoupdate_url_prefix: %w", err) } c.AutoupdateURLPrefix = value } if c.Flags.Has(9) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field gif_search_username: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field gif_search_username: %w", err) } c.GifSearchUsername = value } if c.Flags.Has(10) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field venue_search_username: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field venue_search_username: %w", err) } c.VenueSearchUsername = value } if c.Flags.Has(11) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field img_search_username: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field img_search_username: %w", err) } c.ImgSearchUsername = value } if c.Flags.Has(12) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field static_maps_provider: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field static_maps_provider: %w", err) } c.StaticMapsProvider = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field caption_length_max: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field caption_length_max: %w", err) } c.CaptionLengthMax = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field message_length_max: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field message_length_max: %w", err) } c.MessageLengthMax = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field webfile_dc_id: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field webfile_dc_id: %w", err) } c.WebfileDCID = value } if c.Flags.Has(2) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field suggested_lang_code: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field suggested_lang_code: %w", err) } c.SuggestedLangCode = value } if c.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field lang_pack_version: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field lang_pack_version: %w", err) } c.LangPackVersion = value } if c.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode config#330b4067: field base_lang_pack_version: %w", err) + return fmt.Errorf("unable to decode config#232566ac: field base_lang_pack_version: %w", err) } c.BaseLangPackVersion = value } + if c.Flags.Has(15) { + value, err := DecodeReaction(b) + if err != nil { + return fmt.Errorf("unable to decode config#232566ac: field reactions_default: %w", err) + } + c.ReactionsDefault = value + } return nil } @@ -1874,3 +1909,21 @@ func (c *Config) GetBaseLangPackVersion() (value int, ok bool) { } return c.BaseLangPackVersion, true } + +// SetReactionsDefault sets value of ReactionsDefault conditional field. +func (c *Config) SetReactionsDefault(value ReactionClass) { + c.Flags.Set(15) + c.ReactionsDefault = value +} + +// GetReactionsDefault returns value of ReactionsDefault conditional field and +// boolean which is true if field was set. +func (c *Config) GetReactionsDefault() (value ReactionClass, ok bool) { + if c == nil { + return + } + if !c.Flags.Has(15) { + return value, false + } + return c.ReactionsDefault, true +} diff --git a/tg/tl_email_verification_gen.go b/tg/tl_email_verification_gen.go new file mode 100644 index 0000000000..438269a37e --- /dev/null +++ b/tg/tl_email_verification_gen.go @@ -0,0 +1,531 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// EmailVerificationCode represents TL type `emailVerificationCode#922e55a9`. +// +// See https://core.telegram.org/constructor/emailVerificationCode for reference. +type EmailVerificationCode struct { + // Code field of EmailVerificationCode. + Code string +} + +// EmailVerificationCodeTypeID is TL type id of EmailVerificationCode. +const EmailVerificationCodeTypeID = 0x922e55a9 + +// construct implements constructor of EmailVerificationClass. +func (e EmailVerificationCode) construct() EmailVerificationClass { return &e } + +// Ensuring interfaces in compile-time for EmailVerificationCode. +var ( + _ bin.Encoder = &EmailVerificationCode{} + _ bin.Decoder = &EmailVerificationCode{} + _ bin.BareEncoder = &EmailVerificationCode{} + _ bin.BareDecoder = &EmailVerificationCode{} + + _ EmailVerificationClass = &EmailVerificationCode{} +) + +func (e *EmailVerificationCode) Zero() bool { + if e == nil { + return true + } + if !(e.Code == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *EmailVerificationCode) String() string { + if e == nil { + return "EmailVerificationCode(nil)" + } + type Alias EmailVerificationCode + return fmt.Sprintf("EmailVerificationCode%+v", Alias(*e)) +} + +// FillFrom fills EmailVerificationCode from given interface. +func (e *EmailVerificationCode) FillFrom(from interface { + GetCode() (value string) +}) { + e.Code = from.GetCode() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EmailVerificationCode) TypeID() uint32 { + return EmailVerificationCodeTypeID +} + +// TypeName returns name of type in TL schema. +func (*EmailVerificationCode) TypeName() string { + return "emailVerificationCode" +} + +// TypeInfo returns info about TL type. +func (e *EmailVerificationCode) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "emailVerificationCode", + ID: EmailVerificationCodeTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Code", + SchemaName: "code", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (e *EmailVerificationCode) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emailVerificationCode#922e55a9 as nil") + } + b.PutID(EmailVerificationCodeTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *EmailVerificationCode) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emailVerificationCode#922e55a9 as nil") + } + b.PutString(e.Code) + return nil +} + +// Decode implements bin.Decoder. +func (e *EmailVerificationCode) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emailVerificationCode#922e55a9 to nil") + } + if err := b.ConsumeID(EmailVerificationCodeTypeID); err != nil { + return fmt.Errorf("unable to decode emailVerificationCode#922e55a9: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *EmailVerificationCode) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emailVerificationCode#922e55a9 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode emailVerificationCode#922e55a9: field code: %w", err) + } + e.Code = value + } + return nil +} + +// GetCode returns value of Code field. +func (e *EmailVerificationCode) GetCode() (value string) { + if e == nil { + return + } + return e.Code +} + +// EmailVerificationGoogle represents TL type `emailVerificationGoogle#db909ec2`. +// +// See https://core.telegram.org/constructor/emailVerificationGoogle for reference. +type EmailVerificationGoogle struct { + // Token field of EmailVerificationGoogle. + Token string +} + +// EmailVerificationGoogleTypeID is TL type id of EmailVerificationGoogle. +const EmailVerificationGoogleTypeID = 0xdb909ec2 + +// construct implements constructor of EmailVerificationClass. +func (e EmailVerificationGoogle) construct() EmailVerificationClass { return &e } + +// Ensuring interfaces in compile-time for EmailVerificationGoogle. +var ( + _ bin.Encoder = &EmailVerificationGoogle{} + _ bin.Decoder = &EmailVerificationGoogle{} + _ bin.BareEncoder = &EmailVerificationGoogle{} + _ bin.BareDecoder = &EmailVerificationGoogle{} + + _ EmailVerificationClass = &EmailVerificationGoogle{} +) + +func (e *EmailVerificationGoogle) Zero() bool { + if e == nil { + return true + } + if !(e.Token == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *EmailVerificationGoogle) String() string { + if e == nil { + return "EmailVerificationGoogle(nil)" + } + type Alias EmailVerificationGoogle + return fmt.Sprintf("EmailVerificationGoogle%+v", Alias(*e)) +} + +// FillFrom fills EmailVerificationGoogle from given interface. +func (e *EmailVerificationGoogle) FillFrom(from interface { + GetToken() (value string) +}) { + e.Token = from.GetToken() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EmailVerificationGoogle) TypeID() uint32 { + return EmailVerificationGoogleTypeID +} + +// TypeName returns name of type in TL schema. +func (*EmailVerificationGoogle) TypeName() string { + return "emailVerificationGoogle" +} + +// TypeInfo returns info about TL type. +func (e *EmailVerificationGoogle) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "emailVerificationGoogle", + ID: EmailVerificationGoogleTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Token", + SchemaName: "token", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (e *EmailVerificationGoogle) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emailVerificationGoogle#db909ec2 as nil") + } + b.PutID(EmailVerificationGoogleTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *EmailVerificationGoogle) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emailVerificationGoogle#db909ec2 as nil") + } + b.PutString(e.Token) + return nil +} + +// Decode implements bin.Decoder. +func (e *EmailVerificationGoogle) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emailVerificationGoogle#db909ec2 to nil") + } + if err := b.ConsumeID(EmailVerificationGoogleTypeID); err != nil { + return fmt.Errorf("unable to decode emailVerificationGoogle#db909ec2: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *EmailVerificationGoogle) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emailVerificationGoogle#db909ec2 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode emailVerificationGoogle#db909ec2: field token: %w", err) + } + e.Token = value + } + return nil +} + +// GetToken returns value of Token field. +func (e *EmailVerificationGoogle) GetToken() (value string) { + if e == nil { + return + } + return e.Token +} + +// EmailVerificationApple represents TL type `emailVerificationApple#96d074fd`. +// +// See https://core.telegram.org/constructor/emailVerificationApple for reference. +type EmailVerificationApple struct { + // Token field of EmailVerificationApple. + Token string +} + +// EmailVerificationAppleTypeID is TL type id of EmailVerificationApple. +const EmailVerificationAppleTypeID = 0x96d074fd + +// construct implements constructor of EmailVerificationClass. +func (e EmailVerificationApple) construct() EmailVerificationClass { return &e } + +// Ensuring interfaces in compile-time for EmailVerificationApple. +var ( + _ bin.Encoder = &EmailVerificationApple{} + _ bin.Decoder = &EmailVerificationApple{} + _ bin.BareEncoder = &EmailVerificationApple{} + _ bin.BareDecoder = &EmailVerificationApple{} + + _ EmailVerificationClass = &EmailVerificationApple{} +) + +func (e *EmailVerificationApple) Zero() bool { + if e == nil { + return true + } + if !(e.Token == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *EmailVerificationApple) String() string { + if e == nil { + return "EmailVerificationApple(nil)" + } + type Alias EmailVerificationApple + return fmt.Sprintf("EmailVerificationApple%+v", Alias(*e)) +} + +// FillFrom fills EmailVerificationApple from given interface. +func (e *EmailVerificationApple) FillFrom(from interface { + GetToken() (value string) +}) { + e.Token = from.GetToken() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EmailVerificationApple) TypeID() uint32 { + return EmailVerificationAppleTypeID +} + +// TypeName returns name of type in TL schema. +func (*EmailVerificationApple) TypeName() string { + return "emailVerificationApple" +} + +// TypeInfo returns info about TL type. +func (e *EmailVerificationApple) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "emailVerificationApple", + ID: EmailVerificationAppleTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Token", + SchemaName: "token", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (e *EmailVerificationApple) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emailVerificationApple#96d074fd as nil") + } + b.PutID(EmailVerificationAppleTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *EmailVerificationApple) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emailVerificationApple#96d074fd as nil") + } + b.PutString(e.Token) + return nil +} + +// Decode implements bin.Decoder. +func (e *EmailVerificationApple) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emailVerificationApple#96d074fd to nil") + } + if err := b.ConsumeID(EmailVerificationAppleTypeID); err != nil { + return fmt.Errorf("unable to decode emailVerificationApple#96d074fd: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *EmailVerificationApple) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emailVerificationApple#96d074fd to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode emailVerificationApple#96d074fd: field token: %w", err) + } + e.Token = value + } + return nil +} + +// GetToken returns value of Token field. +func (e *EmailVerificationApple) GetToken() (value string) { + if e == nil { + return + } + return e.Token +} + +// EmailVerificationClassName is schema name of EmailVerificationClass. +const EmailVerificationClassName = "EmailVerification" + +// EmailVerificationClass represents EmailVerification generic type. +// +// See https://core.telegram.org/type/EmailVerification for reference. +// +// Example: +// +// g, err := tg.DecodeEmailVerification(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.EmailVerificationCode: // emailVerificationCode#922e55a9 +// case *tg.EmailVerificationGoogle: // emailVerificationGoogle#db909ec2 +// case *tg.EmailVerificationApple: // emailVerificationApple#96d074fd +// default: panic(v) +// } +type EmailVerificationClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() EmailVerificationClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool +} + +// DecodeEmailVerification implements binary de-serialization for EmailVerificationClass. +func DecodeEmailVerification(buf *bin.Buffer) (EmailVerificationClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case EmailVerificationCodeTypeID: + // Decoding emailVerificationCode#922e55a9. + v := EmailVerificationCode{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EmailVerificationClass: %w", err) + } + return &v, nil + case EmailVerificationGoogleTypeID: + // Decoding emailVerificationGoogle#db909ec2. + v := EmailVerificationGoogle{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EmailVerificationClass: %w", err) + } + return &v, nil + case EmailVerificationAppleTypeID: + // Decoding emailVerificationApple#96d074fd. + v := EmailVerificationApple{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EmailVerificationClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode EmailVerificationClass: %w", bin.NewUnexpectedID(id)) + } +} + +// EmailVerification boxes the EmailVerificationClass providing a helper. +type EmailVerificationBox struct { + EmailVerification EmailVerificationClass +} + +// Decode implements bin.Decoder for EmailVerificationBox. +func (b *EmailVerificationBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode EmailVerificationBox to nil") + } + v, err := DecodeEmailVerification(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.EmailVerification = v + return nil +} + +// Encode implements bin.Encode for EmailVerificationBox. +func (b *EmailVerificationBox) Encode(buf *bin.Buffer) error { + if b == nil || b.EmailVerification == nil { + return fmt.Errorf("unable to encode EmailVerificationClass as nil") + } + return b.EmailVerification.Encode(buf) +} diff --git a/tg/tl_email_verification_slices_gen.go b/tg/tl_email_verification_slices_gen.go new file mode 100644 index 0000000000..09fb92d504 --- /dev/null +++ b/tg/tl_email_verification_slices_gen.go @@ -0,0 +1,402 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// EmailVerificationClassArray is adapter for slice of EmailVerificationClass. +type EmailVerificationClassArray []EmailVerificationClass + +// Sort sorts slice of EmailVerificationClass. +func (s EmailVerificationClassArray) Sort(less func(a, b EmailVerificationClass) bool) EmailVerificationClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EmailVerificationClass. +func (s EmailVerificationClassArray) SortStable(less func(a, b EmailVerificationClass) bool) EmailVerificationClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EmailVerificationClass. +func (s EmailVerificationClassArray) Retain(keep func(x EmailVerificationClass) bool) EmailVerificationClassArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s EmailVerificationClassArray) First() (v EmailVerificationClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EmailVerificationClassArray) Last() (v EmailVerificationClass, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *EmailVerificationClassArray) PopFirst() (v EmailVerificationClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero EmailVerificationClass + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *EmailVerificationClassArray) Pop() (v EmailVerificationClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// AsEmailVerificationCode returns copy with only EmailVerificationCode constructors. +func (s EmailVerificationClassArray) AsEmailVerificationCode() (to EmailVerificationCodeArray) { + for _, elem := range s { + value, ok := elem.(*EmailVerificationCode) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsEmailVerificationGoogle returns copy with only EmailVerificationGoogle constructors. +func (s EmailVerificationClassArray) AsEmailVerificationGoogle() (to EmailVerificationGoogleArray) { + for _, elem := range s { + value, ok := elem.(*EmailVerificationGoogle) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsEmailVerificationApple returns copy with only EmailVerificationApple constructors. +func (s EmailVerificationClassArray) AsEmailVerificationApple() (to EmailVerificationAppleArray) { + for _, elem := range s { + value, ok := elem.(*EmailVerificationApple) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// EmailVerificationCodeArray is adapter for slice of EmailVerificationCode. +type EmailVerificationCodeArray []EmailVerificationCode + +// Sort sorts slice of EmailVerificationCode. +func (s EmailVerificationCodeArray) Sort(less func(a, b EmailVerificationCode) bool) EmailVerificationCodeArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EmailVerificationCode. +func (s EmailVerificationCodeArray) SortStable(less func(a, b EmailVerificationCode) bool) EmailVerificationCodeArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EmailVerificationCode. +func (s EmailVerificationCodeArray) Retain(keep func(x EmailVerificationCode) bool) EmailVerificationCodeArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s EmailVerificationCodeArray) First() (v EmailVerificationCode, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EmailVerificationCodeArray) Last() (v EmailVerificationCode, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *EmailVerificationCodeArray) PopFirst() (v EmailVerificationCode, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero EmailVerificationCode + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *EmailVerificationCodeArray) Pop() (v EmailVerificationCode, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// EmailVerificationGoogleArray is adapter for slice of EmailVerificationGoogle. +type EmailVerificationGoogleArray []EmailVerificationGoogle + +// Sort sorts slice of EmailVerificationGoogle. +func (s EmailVerificationGoogleArray) Sort(less func(a, b EmailVerificationGoogle) bool) EmailVerificationGoogleArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EmailVerificationGoogle. +func (s EmailVerificationGoogleArray) SortStable(less func(a, b EmailVerificationGoogle) bool) EmailVerificationGoogleArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EmailVerificationGoogle. +func (s EmailVerificationGoogleArray) Retain(keep func(x EmailVerificationGoogle) bool) EmailVerificationGoogleArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s EmailVerificationGoogleArray) First() (v EmailVerificationGoogle, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EmailVerificationGoogleArray) Last() (v EmailVerificationGoogle, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *EmailVerificationGoogleArray) PopFirst() (v EmailVerificationGoogle, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero EmailVerificationGoogle + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *EmailVerificationGoogleArray) Pop() (v EmailVerificationGoogle, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// EmailVerificationAppleArray is adapter for slice of EmailVerificationApple. +type EmailVerificationAppleArray []EmailVerificationApple + +// Sort sorts slice of EmailVerificationApple. +func (s EmailVerificationAppleArray) Sort(less func(a, b EmailVerificationApple) bool) EmailVerificationAppleArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EmailVerificationApple. +func (s EmailVerificationAppleArray) SortStable(less func(a, b EmailVerificationApple) bool) EmailVerificationAppleArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EmailVerificationApple. +func (s EmailVerificationAppleArray) Retain(keep func(x EmailVerificationApple) bool) EmailVerificationAppleArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s EmailVerificationAppleArray) First() (v EmailVerificationApple, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EmailVerificationAppleArray) Last() (v EmailVerificationApple, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *EmailVerificationAppleArray) PopFirst() (v EmailVerificationApple, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero EmailVerificationApple + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *EmailVerificationAppleArray) Pop() (v EmailVerificationApple, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_email_verify_purpose_gen.go b/tg/tl_email_verify_purpose_gen.go new file mode 100644 index 0000000000..9851dd0558 --- /dev/null +++ b/tg/tl_email_verify_purpose_gen.go @@ -0,0 +1,492 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// EmailVerifyPurposeLoginSetup represents TL type `emailVerifyPurposeLoginSetup#4345be73`. +// +// See https://core.telegram.org/constructor/emailVerifyPurposeLoginSetup for reference. +type EmailVerifyPurposeLoginSetup struct { + // PhoneNumber field of EmailVerifyPurposeLoginSetup. + PhoneNumber string + // PhoneCodeHash field of EmailVerifyPurposeLoginSetup. + PhoneCodeHash string +} + +// EmailVerifyPurposeLoginSetupTypeID is TL type id of EmailVerifyPurposeLoginSetup. +const EmailVerifyPurposeLoginSetupTypeID = 0x4345be73 + +// construct implements constructor of EmailVerifyPurposeClass. +func (e EmailVerifyPurposeLoginSetup) construct() EmailVerifyPurposeClass { return &e } + +// Ensuring interfaces in compile-time for EmailVerifyPurposeLoginSetup. +var ( + _ bin.Encoder = &EmailVerifyPurposeLoginSetup{} + _ bin.Decoder = &EmailVerifyPurposeLoginSetup{} + _ bin.BareEncoder = &EmailVerifyPurposeLoginSetup{} + _ bin.BareDecoder = &EmailVerifyPurposeLoginSetup{} + + _ EmailVerifyPurposeClass = &EmailVerifyPurposeLoginSetup{} +) + +func (e *EmailVerifyPurposeLoginSetup) Zero() bool { + if e == nil { + return true + } + if !(e.PhoneNumber == "") { + return false + } + if !(e.PhoneCodeHash == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *EmailVerifyPurposeLoginSetup) String() string { + if e == nil { + return "EmailVerifyPurposeLoginSetup(nil)" + } + type Alias EmailVerifyPurposeLoginSetup + return fmt.Sprintf("EmailVerifyPurposeLoginSetup%+v", Alias(*e)) +} + +// FillFrom fills EmailVerifyPurposeLoginSetup from given interface. +func (e *EmailVerifyPurposeLoginSetup) FillFrom(from interface { + GetPhoneNumber() (value string) + GetPhoneCodeHash() (value string) +}) { + e.PhoneNumber = from.GetPhoneNumber() + e.PhoneCodeHash = from.GetPhoneCodeHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EmailVerifyPurposeLoginSetup) TypeID() uint32 { + return EmailVerifyPurposeLoginSetupTypeID +} + +// TypeName returns name of type in TL schema. +func (*EmailVerifyPurposeLoginSetup) TypeName() string { + return "emailVerifyPurposeLoginSetup" +} + +// TypeInfo returns info about TL type. +func (e *EmailVerifyPurposeLoginSetup) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "emailVerifyPurposeLoginSetup", + ID: EmailVerifyPurposeLoginSetupTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "PhoneNumber", + SchemaName: "phone_number", + }, + { + Name: "PhoneCodeHash", + SchemaName: "phone_code_hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (e *EmailVerifyPurposeLoginSetup) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emailVerifyPurposeLoginSetup#4345be73 as nil") + } + b.PutID(EmailVerifyPurposeLoginSetupTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *EmailVerifyPurposeLoginSetup) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emailVerifyPurposeLoginSetup#4345be73 as nil") + } + b.PutString(e.PhoneNumber) + b.PutString(e.PhoneCodeHash) + return nil +} + +// Decode implements bin.Decoder. +func (e *EmailVerifyPurposeLoginSetup) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emailVerifyPurposeLoginSetup#4345be73 to nil") + } + if err := b.ConsumeID(EmailVerifyPurposeLoginSetupTypeID); err != nil { + return fmt.Errorf("unable to decode emailVerifyPurposeLoginSetup#4345be73: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *EmailVerifyPurposeLoginSetup) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emailVerifyPurposeLoginSetup#4345be73 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode emailVerifyPurposeLoginSetup#4345be73: field phone_number: %w", err) + } + e.PhoneNumber = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode emailVerifyPurposeLoginSetup#4345be73: field phone_code_hash: %w", err) + } + e.PhoneCodeHash = value + } + return nil +} + +// GetPhoneNumber returns value of PhoneNumber field. +func (e *EmailVerifyPurposeLoginSetup) GetPhoneNumber() (value string) { + if e == nil { + return + } + return e.PhoneNumber +} + +// GetPhoneCodeHash returns value of PhoneCodeHash field. +func (e *EmailVerifyPurposeLoginSetup) GetPhoneCodeHash() (value string) { + if e == nil { + return + } + return e.PhoneCodeHash +} + +// EmailVerifyPurposeLoginChange represents TL type `emailVerifyPurposeLoginChange#527d22eb`. +// +// See https://core.telegram.org/constructor/emailVerifyPurposeLoginChange for reference. +type EmailVerifyPurposeLoginChange struct { +} + +// EmailVerifyPurposeLoginChangeTypeID is TL type id of EmailVerifyPurposeLoginChange. +const EmailVerifyPurposeLoginChangeTypeID = 0x527d22eb + +// construct implements constructor of EmailVerifyPurposeClass. +func (e EmailVerifyPurposeLoginChange) construct() EmailVerifyPurposeClass { return &e } + +// Ensuring interfaces in compile-time for EmailVerifyPurposeLoginChange. +var ( + _ bin.Encoder = &EmailVerifyPurposeLoginChange{} + _ bin.Decoder = &EmailVerifyPurposeLoginChange{} + _ bin.BareEncoder = &EmailVerifyPurposeLoginChange{} + _ bin.BareDecoder = &EmailVerifyPurposeLoginChange{} + + _ EmailVerifyPurposeClass = &EmailVerifyPurposeLoginChange{} +) + +func (e *EmailVerifyPurposeLoginChange) Zero() bool { + if e == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (e *EmailVerifyPurposeLoginChange) String() string { + if e == nil { + return "EmailVerifyPurposeLoginChange(nil)" + } + type Alias EmailVerifyPurposeLoginChange + return fmt.Sprintf("EmailVerifyPurposeLoginChange%+v", Alias(*e)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EmailVerifyPurposeLoginChange) TypeID() uint32 { + return EmailVerifyPurposeLoginChangeTypeID +} + +// TypeName returns name of type in TL schema. +func (*EmailVerifyPurposeLoginChange) TypeName() string { + return "emailVerifyPurposeLoginChange" +} + +// TypeInfo returns info about TL type. +func (e *EmailVerifyPurposeLoginChange) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "emailVerifyPurposeLoginChange", + ID: EmailVerifyPurposeLoginChangeTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (e *EmailVerifyPurposeLoginChange) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emailVerifyPurposeLoginChange#527d22eb as nil") + } + b.PutID(EmailVerifyPurposeLoginChangeTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *EmailVerifyPurposeLoginChange) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emailVerifyPurposeLoginChange#527d22eb as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (e *EmailVerifyPurposeLoginChange) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emailVerifyPurposeLoginChange#527d22eb to nil") + } + if err := b.ConsumeID(EmailVerifyPurposeLoginChangeTypeID); err != nil { + return fmt.Errorf("unable to decode emailVerifyPurposeLoginChange#527d22eb: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *EmailVerifyPurposeLoginChange) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emailVerifyPurposeLoginChange#527d22eb to nil") + } + return nil +} + +// EmailVerifyPurposePassport represents TL type `emailVerifyPurposePassport#bbf51685`. +// +// See https://core.telegram.org/constructor/emailVerifyPurposePassport for reference. +type EmailVerifyPurposePassport struct { +} + +// EmailVerifyPurposePassportTypeID is TL type id of EmailVerifyPurposePassport. +const EmailVerifyPurposePassportTypeID = 0xbbf51685 + +// construct implements constructor of EmailVerifyPurposeClass. +func (e EmailVerifyPurposePassport) construct() EmailVerifyPurposeClass { return &e } + +// Ensuring interfaces in compile-time for EmailVerifyPurposePassport. +var ( + _ bin.Encoder = &EmailVerifyPurposePassport{} + _ bin.Decoder = &EmailVerifyPurposePassport{} + _ bin.BareEncoder = &EmailVerifyPurposePassport{} + _ bin.BareDecoder = &EmailVerifyPurposePassport{} + + _ EmailVerifyPurposeClass = &EmailVerifyPurposePassport{} +) + +func (e *EmailVerifyPurposePassport) Zero() bool { + if e == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (e *EmailVerifyPurposePassport) String() string { + if e == nil { + return "EmailVerifyPurposePassport(nil)" + } + type Alias EmailVerifyPurposePassport + return fmt.Sprintf("EmailVerifyPurposePassport%+v", Alias(*e)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EmailVerifyPurposePassport) TypeID() uint32 { + return EmailVerifyPurposePassportTypeID +} + +// TypeName returns name of type in TL schema. +func (*EmailVerifyPurposePassport) TypeName() string { + return "emailVerifyPurposePassport" +} + +// TypeInfo returns info about TL type. +func (e *EmailVerifyPurposePassport) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "emailVerifyPurposePassport", + ID: EmailVerifyPurposePassportTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (e *EmailVerifyPurposePassport) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emailVerifyPurposePassport#bbf51685 as nil") + } + b.PutID(EmailVerifyPurposePassportTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *EmailVerifyPurposePassport) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emailVerifyPurposePassport#bbf51685 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (e *EmailVerifyPurposePassport) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emailVerifyPurposePassport#bbf51685 to nil") + } + if err := b.ConsumeID(EmailVerifyPurposePassportTypeID); err != nil { + return fmt.Errorf("unable to decode emailVerifyPurposePassport#bbf51685: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *EmailVerifyPurposePassport) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emailVerifyPurposePassport#bbf51685 to nil") + } + return nil +} + +// EmailVerifyPurposeClassName is schema name of EmailVerifyPurposeClass. +const EmailVerifyPurposeClassName = "EmailVerifyPurpose" + +// EmailVerifyPurposeClass represents EmailVerifyPurpose generic type. +// +// See https://core.telegram.org/type/EmailVerifyPurpose for reference. +// +// Example: +// +// g, err := tg.DecodeEmailVerifyPurpose(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.EmailVerifyPurposeLoginSetup: // emailVerifyPurposeLoginSetup#4345be73 +// case *tg.EmailVerifyPurposeLoginChange: // emailVerifyPurposeLoginChange#527d22eb +// case *tg.EmailVerifyPurposePassport: // emailVerifyPurposePassport#bbf51685 +// default: panic(v) +// } +type EmailVerifyPurposeClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() EmailVerifyPurposeClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool +} + +// DecodeEmailVerifyPurpose implements binary de-serialization for EmailVerifyPurposeClass. +func DecodeEmailVerifyPurpose(buf *bin.Buffer) (EmailVerifyPurposeClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case EmailVerifyPurposeLoginSetupTypeID: + // Decoding emailVerifyPurposeLoginSetup#4345be73. + v := EmailVerifyPurposeLoginSetup{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EmailVerifyPurposeClass: %w", err) + } + return &v, nil + case EmailVerifyPurposeLoginChangeTypeID: + // Decoding emailVerifyPurposeLoginChange#527d22eb. + v := EmailVerifyPurposeLoginChange{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EmailVerifyPurposeClass: %w", err) + } + return &v, nil + case EmailVerifyPurposePassportTypeID: + // Decoding emailVerifyPurposePassport#bbf51685. + v := EmailVerifyPurposePassport{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EmailVerifyPurposeClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode EmailVerifyPurposeClass: %w", bin.NewUnexpectedID(id)) + } +} + +// EmailVerifyPurpose boxes the EmailVerifyPurposeClass providing a helper. +type EmailVerifyPurposeBox struct { + EmailVerifyPurpose EmailVerifyPurposeClass +} + +// Decode implements bin.Decoder for EmailVerifyPurposeBox. +func (b *EmailVerifyPurposeBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode EmailVerifyPurposeBox to nil") + } + v, err := DecodeEmailVerifyPurpose(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.EmailVerifyPurpose = v + return nil +} + +// Encode implements bin.Encode for EmailVerifyPurposeBox. +func (b *EmailVerifyPurposeBox) Encode(buf *bin.Buffer) error { + if b == nil || b.EmailVerifyPurpose == nil { + return fmt.Errorf("unable to encode EmailVerifyPurposeClass as nil") + } + return b.EmailVerifyPurpose.Encode(buf) +} diff --git a/tg/tl_email_verify_purpose_slices_gen.go b/tg/tl_email_verify_purpose_slices_gen.go new file mode 100644 index 0000000000..61f169b953 --- /dev/null +++ b/tg/tl_email_verify_purpose_slices_gen.go @@ -0,0 +1,212 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// EmailVerifyPurposeClassArray is adapter for slice of EmailVerifyPurposeClass. +type EmailVerifyPurposeClassArray []EmailVerifyPurposeClass + +// Sort sorts slice of EmailVerifyPurposeClass. +func (s EmailVerifyPurposeClassArray) Sort(less func(a, b EmailVerifyPurposeClass) bool) EmailVerifyPurposeClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EmailVerifyPurposeClass. +func (s EmailVerifyPurposeClassArray) SortStable(less func(a, b EmailVerifyPurposeClass) bool) EmailVerifyPurposeClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EmailVerifyPurposeClass. +func (s EmailVerifyPurposeClassArray) Retain(keep func(x EmailVerifyPurposeClass) bool) EmailVerifyPurposeClassArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s EmailVerifyPurposeClassArray) First() (v EmailVerifyPurposeClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EmailVerifyPurposeClassArray) Last() (v EmailVerifyPurposeClass, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *EmailVerifyPurposeClassArray) PopFirst() (v EmailVerifyPurposeClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero EmailVerifyPurposeClass + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *EmailVerifyPurposeClassArray) Pop() (v EmailVerifyPurposeClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// AsEmailVerifyPurposeLoginSetup returns copy with only EmailVerifyPurposeLoginSetup constructors. +func (s EmailVerifyPurposeClassArray) AsEmailVerifyPurposeLoginSetup() (to EmailVerifyPurposeLoginSetupArray) { + for _, elem := range s { + value, ok := elem.(*EmailVerifyPurposeLoginSetup) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// EmailVerifyPurposeLoginSetupArray is adapter for slice of EmailVerifyPurposeLoginSetup. +type EmailVerifyPurposeLoginSetupArray []EmailVerifyPurposeLoginSetup + +// Sort sorts slice of EmailVerifyPurposeLoginSetup. +func (s EmailVerifyPurposeLoginSetupArray) Sort(less func(a, b EmailVerifyPurposeLoginSetup) bool) EmailVerifyPurposeLoginSetupArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EmailVerifyPurposeLoginSetup. +func (s EmailVerifyPurposeLoginSetupArray) SortStable(less func(a, b EmailVerifyPurposeLoginSetup) bool) EmailVerifyPurposeLoginSetupArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EmailVerifyPurposeLoginSetup. +func (s EmailVerifyPurposeLoginSetupArray) Retain(keep func(x EmailVerifyPurposeLoginSetup) bool) EmailVerifyPurposeLoginSetupArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s EmailVerifyPurposeLoginSetupArray) First() (v EmailVerifyPurposeLoginSetup, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EmailVerifyPurposeLoginSetupArray) Last() (v EmailVerifyPurposeLoginSetup, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *EmailVerifyPurposeLoginSetupArray) PopFirst() (v EmailVerifyPurposeLoginSetup, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero EmailVerifyPurposeLoginSetup + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *EmailVerifyPurposeLoginSetupArray) Pop() (v EmailVerifyPurposeLoginSetup, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_emoji_status_gen.go b/tg/tl_emoji_status_gen.go new file mode 100644 index 0000000000..dd1ef30df6 --- /dev/null +++ b/tg/tl_emoji_status_gen.go @@ -0,0 +1,569 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// EmojiStatusEmpty represents TL type `emojiStatusEmpty#2de11aae`. +// +// See https://core.telegram.org/constructor/emojiStatusEmpty for reference. +type EmojiStatusEmpty struct { +} + +// EmojiStatusEmptyTypeID is TL type id of EmojiStatusEmpty. +const EmojiStatusEmptyTypeID = 0x2de11aae + +// construct implements constructor of EmojiStatusClass. +func (e EmojiStatusEmpty) construct() EmojiStatusClass { return &e } + +// Ensuring interfaces in compile-time for EmojiStatusEmpty. +var ( + _ bin.Encoder = &EmojiStatusEmpty{} + _ bin.Decoder = &EmojiStatusEmpty{} + _ bin.BareEncoder = &EmojiStatusEmpty{} + _ bin.BareDecoder = &EmojiStatusEmpty{} + + _ EmojiStatusClass = &EmojiStatusEmpty{} +) + +func (e *EmojiStatusEmpty) Zero() bool { + if e == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (e *EmojiStatusEmpty) String() string { + if e == nil { + return "EmojiStatusEmpty(nil)" + } + type Alias EmojiStatusEmpty + return fmt.Sprintf("EmojiStatusEmpty%+v", Alias(*e)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EmojiStatusEmpty) TypeID() uint32 { + return EmojiStatusEmptyTypeID +} + +// TypeName returns name of type in TL schema. +func (*EmojiStatusEmpty) TypeName() string { + return "emojiStatusEmpty" +} + +// TypeInfo returns info about TL type. +func (e *EmojiStatusEmpty) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "emojiStatusEmpty", + ID: EmojiStatusEmptyTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (e *EmojiStatusEmpty) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emojiStatusEmpty#2de11aae as nil") + } + b.PutID(EmojiStatusEmptyTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *EmojiStatusEmpty) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emojiStatusEmpty#2de11aae as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (e *EmojiStatusEmpty) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emojiStatusEmpty#2de11aae to nil") + } + if err := b.ConsumeID(EmojiStatusEmptyTypeID); err != nil { + return fmt.Errorf("unable to decode emojiStatusEmpty#2de11aae: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *EmojiStatusEmpty) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emojiStatusEmpty#2de11aae to nil") + } + return nil +} + +// EmojiStatus represents TL type `emojiStatus#929b619d`. +// +// See https://core.telegram.org/constructor/emojiStatus for reference. +type EmojiStatus struct { + // DocumentID field of EmojiStatus. + DocumentID int64 +} + +// EmojiStatusTypeID is TL type id of EmojiStatus. +const EmojiStatusTypeID = 0x929b619d + +// construct implements constructor of EmojiStatusClass. +func (e EmojiStatus) construct() EmojiStatusClass { return &e } + +// Ensuring interfaces in compile-time for EmojiStatus. +var ( + _ bin.Encoder = &EmojiStatus{} + _ bin.Decoder = &EmojiStatus{} + _ bin.BareEncoder = &EmojiStatus{} + _ bin.BareDecoder = &EmojiStatus{} + + _ EmojiStatusClass = &EmojiStatus{} +) + +func (e *EmojiStatus) Zero() bool { + if e == nil { + return true + } + if !(e.DocumentID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *EmojiStatus) String() string { + if e == nil { + return "EmojiStatus(nil)" + } + type Alias EmojiStatus + return fmt.Sprintf("EmojiStatus%+v", Alias(*e)) +} + +// FillFrom fills EmojiStatus from given interface. +func (e *EmojiStatus) FillFrom(from interface { + GetDocumentID() (value int64) +}) { + e.DocumentID = from.GetDocumentID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EmojiStatus) TypeID() uint32 { + return EmojiStatusTypeID +} + +// TypeName returns name of type in TL schema. +func (*EmojiStatus) TypeName() string { + return "emojiStatus" +} + +// TypeInfo returns info about TL type. +func (e *EmojiStatus) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "emojiStatus", + ID: EmojiStatusTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "DocumentID", + SchemaName: "document_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (e *EmojiStatus) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emojiStatus#929b619d as nil") + } + b.PutID(EmojiStatusTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *EmojiStatus) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emojiStatus#929b619d as nil") + } + b.PutLong(e.DocumentID) + return nil +} + +// Decode implements bin.Decoder. +func (e *EmojiStatus) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emojiStatus#929b619d to nil") + } + if err := b.ConsumeID(EmojiStatusTypeID); err != nil { + return fmt.Errorf("unable to decode emojiStatus#929b619d: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *EmojiStatus) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emojiStatus#929b619d to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode emojiStatus#929b619d: field document_id: %w", err) + } + e.DocumentID = value + } + return nil +} + +// GetDocumentID returns value of DocumentID field. +func (e *EmojiStatus) GetDocumentID() (value int64) { + if e == nil { + return + } + return e.DocumentID +} + +// EmojiStatusUntil represents TL type `emojiStatusUntil#fa30a8c7`. +// +// See https://core.telegram.org/constructor/emojiStatusUntil for reference. +type EmojiStatusUntil struct { + // DocumentID field of EmojiStatusUntil. + DocumentID int64 + // Until field of EmojiStatusUntil. + Until int +} + +// EmojiStatusUntilTypeID is TL type id of EmojiStatusUntil. +const EmojiStatusUntilTypeID = 0xfa30a8c7 + +// construct implements constructor of EmojiStatusClass. +func (e EmojiStatusUntil) construct() EmojiStatusClass { return &e } + +// Ensuring interfaces in compile-time for EmojiStatusUntil. +var ( + _ bin.Encoder = &EmojiStatusUntil{} + _ bin.Decoder = &EmojiStatusUntil{} + _ bin.BareEncoder = &EmojiStatusUntil{} + _ bin.BareDecoder = &EmojiStatusUntil{} + + _ EmojiStatusClass = &EmojiStatusUntil{} +) + +func (e *EmojiStatusUntil) Zero() bool { + if e == nil { + return true + } + if !(e.DocumentID == 0) { + return false + } + if !(e.Until == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *EmojiStatusUntil) String() string { + if e == nil { + return "EmojiStatusUntil(nil)" + } + type Alias EmojiStatusUntil + return fmt.Sprintf("EmojiStatusUntil%+v", Alias(*e)) +} + +// FillFrom fills EmojiStatusUntil from given interface. +func (e *EmojiStatusUntil) FillFrom(from interface { + GetDocumentID() (value int64) + GetUntil() (value int) +}) { + e.DocumentID = from.GetDocumentID() + e.Until = from.GetUntil() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EmojiStatusUntil) TypeID() uint32 { + return EmojiStatusUntilTypeID +} + +// TypeName returns name of type in TL schema. +func (*EmojiStatusUntil) TypeName() string { + return "emojiStatusUntil" +} + +// TypeInfo returns info about TL type. +func (e *EmojiStatusUntil) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "emojiStatusUntil", + ID: EmojiStatusUntilTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "DocumentID", + SchemaName: "document_id", + }, + { + Name: "Until", + SchemaName: "until", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (e *EmojiStatusUntil) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emojiStatusUntil#fa30a8c7 as nil") + } + b.PutID(EmojiStatusUntilTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *EmojiStatusUntil) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode emojiStatusUntil#fa30a8c7 as nil") + } + b.PutLong(e.DocumentID) + b.PutInt(e.Until) + return nil +} + +// Decode implements bin.Decoder. +func (e *EmojiStatusUntil) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emojiStatusUntil#fa30a8c7 to nil") + } + if err := b.ConsumeID(EmojiStatusUntilTypeID); err != nil { + return fmt.Errorf("unable to decode emojiStatusUntil#fa30a8c7: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *EmojiStatusUntil) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode emojiStatusUntil#fa30a8c7 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode emojiStatusUntil#fa30a8c7: field document_id: %w", err) + } + e.DocumentID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode emojiStatusUntil#fa30a8c7: field until: %w", err) + } + e.Until = value + } + return nil +} + +// GetDocumentID returns value of DocumentID field. +func (e *EmojiStatusUntil) GetDocumentID() (value int64) { + if e == nil { + return + } + return e.DocumentID +} + +// GetUntil returns value of Until field. +func (e *EmojiStatusUntil) GetUntil() (value int) { + if e == nil { + return + } + return e.Until +} + +// EmojiStatusClassName is schema name of EmojiStatusClass. +const EmojiStatusClassName = "EmojiStatus" + +// EmojiStatusClass represents EmojiStatus generic type. +// +// See https://core.telegram.org/type/EmojiStatus for reference. +// +// Example: +// +// g, err := tg.DecodeEmojiStatus(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.EmojiStatusEmpty: // emojiStatusEmpty#2de11aae +// case *tg.EmojiStatus: // emojiStatus#929b619d +// case *tg.EmojiStatusUntil: // emojiStatusUntil#fa30a8c7 +// default: panic(v) +// } +type EmojiStatusClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() EmojiStatusClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool + + // AsNotEmpty tries to map EmojiStatusClass to NotEmptyEmojiStatus. + AsNotEmpty() (NotEmptyEmojiStatus, bool) +} + +// NotEmptyEmojiStatus represents NotEmpty subset of EmojiStatusClass. +type NotEmptyEmojiStatus interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() EmojiStatusClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool + + // DocumentID field of EmojiStatus. + GetDocumentID() (value int64) +} + +// AsNotEmpty tries to map EmojiStatusEmpty to NotEmptyEmojiStatus. +func (e *EmojiStatusEmpty) AsNotEmpty() (NotEmptyEmojiStatus, bool) { + value, ok := (EmojiStatusClass(e)).(NotEmptyEmojiStatus) + return value, ok +} + +// AsNotEmpty tries to map EmojiStatus to NotEmptyEmojiStatus. +func (e *EmojiStatus) AsNotEmpty() (NotEmptyEmojiStatus, bool) { + value, ok := (EmojiStatusClass(e)).(NotEmptyEmojiStatus) + return value, ok +} + +// AsNotEmpty tries to map EmojiStatusUntil to NotEmptyEmojiStatus. +func (e *EmojiStatusUntil) AsNotEmpty() (NotEmptyEmojiStatus, bool) { + value, ok := (EmojiStatusClass(e)).(NotEmptyEmojiStatus) + return value, ok +} + +// DecodeEmojiStatus implements binary de-serialization for EmojiStatusClass. +func DecodeEmojiStatus(buf *bin.Buffer) (EmojiStatusClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case EmojiStatusEmptyTypeID: + // Decoding emojiStatusEmpty#2de11aae. + v := EmojiStatusEmpty{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EmojiStatusClass: %w", err) + } + return &v, nil + case EmojiStatusTypeID: + // Decoding emojiStatus#929b619d. + v := EmojiStatus{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EmojiStatusClass: %w", err) + } + return &v, nil + case EmojiStatusUntilTypeID: + // Decoding emojiStatusUntil#fa30a8c7. + v := EmojiStatusUntil{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EmojiStatusClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode EmojiStatusClass: %w", bin.NewUnexpectedID(id)) + } +} + +// EmojiStatus boxes the EmojiStatusClass providing a helper. +type EmojiStatusBox struct { + EmojiStatus EmojiStatusClass +} + +// Decode implements bin.Decoder for EmojiStatusBox. +func (b *EmojiStatusBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode EmojiStatusBox to nil") + } + v, err := DecodeEmojiStatus(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.EmojiStatus = v + return nil +} + +// Encode implements bin.Encode for EmojiStatusBox. +func (b *EmojiStatusBox) Encode(buf *bin.Buffer) error { + if b == nil || b.EmojiStatus == nil { + return fmt.Errorf("unable to encode EmojiStatusClass as nil") + } + return b.EmojiStatus.Encode(buf) +} diff --git a/tg/tl_emoji_status_slices_gen.go b/tg/tl_emoji_status_slices_gen.go new file mode 100644 index 0000000000..efe995a2d1 --- /dev/null +++ b/tg/tl_emoji_status_slices_gen.go @@ -0,0 +1,362 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// EmojiStatusClassArray is adapter for slice of EmojiStatusClass. +type EmojiStatusClassArray []EmojiStatusClass + +// Sort sorts slice of EmojiStatusClass. +func (s EmojiStatusClassArray) Sort(less func(a, b EmojiStatusClass) bool) EmojiStatusClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EmojiStatusClass. +func (s EmojiStatusClassArray) SortStable(less func(a, b EmojiStatusClass) bool) EmojiStatusClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EmojiStatusClass. +func (s EmojiStatusClassArray) Retain(keep func(x EmojiStatusClass) bool) EmojiStatusClassArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s EmojiStatusClassArray) First() (v EmojiStatusClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EmojiStatusClassArray) Last() (v EmojiStatusClass, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *EmojiStatusClassArray) PopFirst() (v EmojiStatusClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero EmojiStatusClass + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *EmojiStatusClassArray) Pop() (v EmojiStatusClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// AsEmojiStatus returns copy with only EmojiStatus constructors. +func (s EmojiStatusClassArray) AsEmojiStatus() (to EmojiStatusArray) { + for _, elem := range s { + value, ok := elem.(*EmojiStatus) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsEmojiStatusUntil returns copy with only EmojiStatusUntil constructors. +func (s EmojiStatusClassArray) AsEmojiStatusUntil() (to EmojiStatusUntilArray) { + for _, elem := range s { + value, ok := elem.(*EmojiStatusUntil) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AppendOnlyNotEmpty appends only NotEmpty constructors to +// given slice. +func (s EmojiStatusClassArray) AppendOnlyNotEmpty(to []NotEmptyEmojiStatus) []NotEmptyEmojiStatus { + for _, elem := range s { + value, ok := elem.AsNotEmpty() + if !ok { + continue + } + to = append(to, value) + } + + return to +} + +// AsNotEmpty returns copy with only NotEmpty constructors. +func (s EmojiStatusClassArray) AsNotEmpty() (to []NotEmptyEmojiStatus) { + return s.AppendOnlyNotEmpty(to) +} + +// FirstAsNotEmpty returns first element of slice (if exists). +func (s EmojiStatusClassArray) FirstAsNotEmpty() (v NotEmptyEmojiStatus, ok bool) { + value, ok := s.First() + if !ok { + return + } + return value.AsNotEmpty() +} + +// LastAsNotEmpty returns last element of slice (if exists). +func (s EmojiStatusClassArray) LastAsNotEmpty() (v NotEmptyEmojiStatus, ok bool) { + value, ok := s.Last() + if !ok { + return + } + return value.AsNotEmpty() +} + +// PopFirstAsNotEmpty returns element of slice (if exists). +func (s *EmojiStatusClassArray) PopFirstAsNotEmpty() (v NotEmptyEmojiStatus, ok bool) { + value, ok := s.PopFirst() + if !ok { + return + } + return value.AsNotEmpty() +} + +// PopAsNotEmpty returns element of slice (if exists). +func (s *EmojiStatusClassArray) PopAsNotEmpty() (v NotEmptyEmojiStatus, ok bool) { + value, ok := s.Pop() + if !ok { + return + } + return value.AsNotEmpty() +} + +// EmojiStatusArray is adapter for slice of EmojiStatus. +type EmojiStatusArray []EmojiStatus + +// Sort sorts slice of EmojiStatus. +func (s EmojiStatusArray) Sort(less func(a, b EmojiStatus) bool) EmojiStatusArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EmojiStatus. +func (s EmojiStatusArray) SortStable(less func(a, b EmojiStatus) bool) EmojiStatusArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EmojiStatus. +func (s EmojiStatusArray) Retain(keep func(x EmojiStatus) bool) EmojiStatusArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s EmojiStatusArray) First() (v EmojiStatus, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EmojiStatusArray) Last() (v EmojiStatus, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *EmojiStatusArray) PopFirst() (v EmojiStatus, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero EmojiStatus + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *EmojiStatusArray) Pop() (v EmojiStatus, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// EmojiStatusUntilArray is adapter for slice of EmojiStatusUntil. +type EmojiStatusUntilArray []EmojiStatusUntil + +// Sort sorts slice of EmojiStatusUntil. +func (s EmojiStatusUntilArray) Sort(less func(a, b EmojiStatusUntil) bool) EmojiStatusUntilArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EmojiStatusUntil. +func (s EmojiStatusUntilArray) SortStable(less func(a, b EmojiStatusUntil) bool) EmojiStatusUntilArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EmojiStatusUntil. +func (s EmojiStatusUntilArray) Retain(keep func(x EmojiStatusUntil) bool) EmojiStatusUntilArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s EmojiStatusUntilArray) First() (v EmojiStatusUntil, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EmojiStatusUntilArray) Last() (v EmojiStatusUntil, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *EmojiStatusUntilArray) PopFirst() (v EmojiStatusUntil, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero EmojiStatusUntil + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *EmojiStatusUntilArray) Pop() (v EmojiStatusUntil, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_handlers_gen.go b/tg/tl_handlers_gen.go index e0f67eaffb..fb80cd781d 100644 --- a/tg/tl_handlers_gen.go +++ b/tg/tl_handlers_gen.go @@ -1125,3 +1125,43 @@ func (u UpdateDispatcher) OnReadFeaturedEmojiStickers(handler ReadFeaturedEmojiS return handler(ctx, e, update.(*UpdateReadFeaturedEmojiStickers)) } } + +// UserEmojiStatusHandler is a UserEmojiStatus event handler. +type UserEmojiStatusHandler func(ctx context.Context, e Entities, update *UpdateUserEmojiStatus) error + +// OnUserEmojiStatus sets UserEmojiStatus handler. +func (u UpdateDispatcher) OnUserEmojiStatus(handler UserEmojiStatusHandler) { + u.handlers[UpdateUserEmojiStatusTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateUserEmojiStatus)) + } +} + +// RecentEmojiStatusesHandler is a RecentEmojiStatuses event handler. +type RecentEmojiStatusesHandler func(ctx context.Context, e Entities, update *UpdateRecentEmojiStatuses) error + +// OnRecentEmojiStatuses sets RecentEmojiStatuses handler. +func (u UpdateDispatcher) OnRecentEmojiStatuses(handler RecentEmojiStatusesHandler) { + u.handlers[UpdateRecentEmojiStatusesTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateRecentEmojiStatuses)) + } +} + +// RecentReactionsHandler is a RecentReactions event handler. +type RecentReactionsHandler func(ctx context.Context, e Entities, update *UpdateRecentReactions) error + +// OnRecentReactions sets RecentReactions handler. +func (u UpdateDispatcher) OnRecentReactions(handler RecentReactionsHandler) { + u.handlers[UpdateRecentReactionsTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateRecentReactions)) + } +} + +// MoveStickerSetToTopHandler is a MoveStickerSetToTop event handler. +type MoveStickerSetToTopHandler func(ctx context.Context, e Entities, update *UpdateMoveStickerSetToTop) error + +// OnMoveStickerSetToTop sets MoveStickerSetToTop handler. +func (u UpdateDispatcher) OnMoveStickerSetToTop(handler MoveStickerSetToTopHandler) { + u.handlers[UpdateMoveStickerSetToTopTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateMoveStickerSetToTop)) + } +} diff --git a/tg/tl_help_premium_promo_gen.go b/tg/tl_help_premium_promo_gen.go index 0550a95c63..afd92877e7 100644 --- a/tg/tl_help_premium_promo_gen.go +++ b/tg/tl_help_premium_promo_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// HelpPremiumPromo represents TL type `help.premiumPromo#8a4f3c29`. +// HelpPremiumPromo represents TL type `help.premiumPromo#5334759c`. // Telegram Premium promotion information // // See https://core.telegram.org/constructor/help.premiumPromo for reference. @@ -50,25 +50,14 @@ type HelpPremiumPromo struct { VideoSections []string // A list of videos Videos []DocumentClass - // Three-letter ISO 4217 currency¹ code - // - // Links: - // 1) https://core.telegram.org/bots/payments#supported-currencies - Currency string - // Monthly price of the product in the smallest units of the currency (integer, not - // float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp - // parameter in currencies.json¹, it shows the number of digits past the decimal point - // for each currency (2 for the majority of currencies). - // - // Links: - // 1) https://core.telegram.org/bots/payments/currencies.json - MonthlyAmount int64 + // PeriodOptions field of HelpPremiumPromo. + PeriodOptions []PremiumSubscriptionOption // Related user information Users []UserClass } // HelpPremiumPromoTypeID is TL type id of HelpPremiumPromo. -const HelpPremiumPromoTypeID = 0x8a4f3c29 +const HelpPremiumPromoTypeID = 0x5334759c // Ensuring interfaces in compile-time for HelpPremiumPromo. var ( @@ -94,10 +83,7 @@ func (p *HelpPremiumPromo) Zero() bool { if !(p.Videos == nil) { return false } - if !(p.Currency == "") { - return false - } - if !(p.MonthlyAmount == 0) { + if !(p.PeriodOptions == nil) { return false } if !(p.Users == nil) { @@ -122,16 +108,14 @@ func (p *HelpPremiumPromo) FillFrom(from interface { GetStatusEntities() (value []MessageEntityClass) GetVideoSections() (value []string) GetVideos() (value []DocumentClass) - GetCurrency() (value string) - GetMonthlyAmount() (value int64) + GetPeriodOptions() (value []PremiumSubscriptionOption) GetUsers() (value []UserClass) }) { p.StatusText = from.GetStatusText() p.StatusEntities = from.GetStatusEntities() p.VideoSections = from.GetVideoSections() p.Videos = from.GetVideos() - p.Currency = from.GetCurrency() - p.MonthlyAmount = from.GetMonthlyAmount() + p.PeriodOptions = from.GetPeriodOptions() p.Users = from.GetUsers() } @@ -175,12 +159,8 @@ func (p *HelpPremiumPromo) TypeInfo() tdp.Type { SchemaName: "videos", }, { - Name: "Currency", - SchemaName: "currency", - }, - { - Name: "MonthlyAmount", - SchemaName: "monthly_amount", + Name: "PeriodOptions", + SchemaName: "period_options", }, { Name: "Users", @@ -193,7 +173,7 @@ func (p *HelpPremiumPromo) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (p *HelpPremiumPromo) Encode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode help.premiumPromo#8a4f3c29 as nil") + return fmt.Errorf("can't encode help.premiumPromo#5334759c as nil") } b.PutID(HelpPremiumPromoTypeID) return p.EncodeBare(b) @@ -202,16 +182,16 @@ func (p *HelpPremiumPromo) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (p *HelpPremiumPromo) EncodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode help.premiumPromo#8a4f3c29 as nil") + return fmt.Errorf("can't encode help.premiumPromo#5334759c as nil") } b.PutString(p.StatusText) b.PutVectorHeader(len(p.StatusEntities)) for idx, v := range p.StatusEntities { if v == nil { - return fmt.Errorf("unable to encode help.premiumPromo#8a4f3c29: field status_entities element with index %d is nil", idx) + return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field status_entities element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode help.premiumPromo#8a4f3c29: field status_entities element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field status_entities element with index %d: %w", idx, err) } } b.PutVectorHeader(len(p.VideoSections)) @@ -221,21 +201,25 @@ func (p *HelpPremiumPromo) EncodeBare(b *bin.Buffer) error { b.PutVectorHeader(len(p.Videos)) for idx, v := range p.Videos { if v == nil { - return fmt.Errorf("unable to encode help.premiumPromo#8a4f3c29: field videos element with index %d is nil", idx) + return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field videos element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field videos element with index %d: %w", idx, err) } + } + b.PutVectorHeader(len(p.PeriodOptions)) + for idx, v := range p.PeriodOptions { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode help.premiumPromo#8a4f3c29: field videos element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field period_options element with index %d: %w", idx, err) } } - b.PutString(p.Currency) - b.PutLong(p.MonthlyAmount) b.PutVectorHeader(len(p.Users)) for idx, v := range p.Users { if v == nil { - return fmt.Errorf("unable to encode help.premiumPromo#8a4f3c29: field users element with index %d is nil", idx) + return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field users element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode help.premiumPromo#8a4f3c29: field users element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field users element with index %d: %w", idx, err) } } return nil @@ -244,10 +228,10 @@ func (p *HelpPremiumPromo) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (p *HelpPremiumPromo) Decode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode help.premiumPromo#8a4f3c29 to nil") + return fmt.Errorf("can't decode help.premiumPromo#5334759c to nil") } if err := b.ConsumeID(HelpPremiumPromoTypeID); err != nil { - return fmt.Errorf("unable to decode help.premiumPromo#8a4f3c29: %w", err) + return fmt.Errorf("unable to decode help.premiumPromo#5334759c: %w", err) } return p.DecodeBare(b) } @@ -255,19 +239,19 @@ func (p *HelpPremiumPromo) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (p *HelpPremiumPromo) DecodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode help.premiumPromo#8a4f3c29 to nil") + return fmt.Errorf("can't decode help.premiumPromo#5334759c to nil") } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode help.premiumPromo#8a4f3c29: field status_text: %w", err) + return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field status_text: %w", err) } p.StatusText = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode help.premiumPromo#8a4f3c29: field status_entities: %w", err) + return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field status_entities: %w", err) } if headerLen > 0 { @@ -276,7 +260,7 @@ func (p *HelpPremiumPromo) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageEntity(b) if err != nil { - return fmt.Errorf("unable to decode help.premiumPromo#8a4f3c29: field status_entities: %w", err) + return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field status_entities: %w", err) } p.StatusEntities = append(p.StatusEntities, value) } @@ -284,7 +268,7 @@ func (p *HelpPremiumPromo) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode help.premiumPromo#8a4f3c29: field video_sections: %w", err) + return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field video_sections: %w", err) } if headerLen > 0 { @@ -293,7 +277,7 @@ func (p *HelpPremiumPromo) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode help.premiumPromo#8a4f3c29: field video_sections: %w", err) + return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field video_sections: %w", err) } p.VideoSections = append(p.VideoSections, value) } @@ -301,7 +285,7 @@ func (p *HelpPremiumPromo) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode help.premiumPromo#8a4f3c29: field videos: %w", err) + return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field videos: %w", err) } if headerLen > 0 { @@ -310,29 +294,32 @@ func (p *HelpPremiumPromo) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeDocument(b) if err != nil { - return fmt.Errorf("unable to decode help.premiumPromo#8a4f3c29: field videos: %w", err) + return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field videos: %w", err) } p.Videos = append(p.Videos, value) } } { - value, err := b.String() + headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode help.premiumPromo#8a4f3c29: field currency: %w", err) + return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field period_options: %w", err) } - p.Currency = value - } - { - value, err := b.Long() - if err != nil { - return fmt.Errorf("unable to decode help.premiumPromo#8a4f3c29: field monthly_amount: %w", err) + + if headerLen > 0 { + p.PeriodOptions = make([]PremiumSubscriptionOption, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value PremiumSubscriptionOption + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field period_options: %w", err) + } + p.PeriodOptions = append(p.PeriodOptions, value) } - p.MonthlyAmount = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode help.premiumPromo#8a4f3c29: field users: %w", err) + return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field users: %w", err) } if headerLen > 0 { @@ -341,7 +328,7 @@ func (p *HelpPremiumPromo) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeUser(b) if err != nil { - return fmt.Errorf("unable to decode help.premiumPromo#8a4f3c29: field users: %w", err) + return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field users: %w", err) } p.Users = append(p.Users, value) } @@ -381,20 +368,12 @@ func (p *HelpPremiumPromo) GetVideos() (value []DocumentClass) { return p.Videos } -// GetCurrency returns value of Currency field. -func (p *HelpPremiumPromo) GetCurrency() (value string) { - if p == nil { - return - } - return p.Currency -} - -// GetMonthlyAmount returns value of MonthlyAmount field. -func (p *HelpPremiumPromo) GetMonthlyAmount() (value int64) { +// GetPeriodOptions returns value of PeriodOptions field. +func (p *HelpPremiumPromo) GetPeriodOptions() (value []PremiumSubscriptionOption) { if p == nil { return } - return p.MonthlyAmount + return p.PeriodOptions } // GetUsers returns value of Users field. diff --git a/tg/tl_input_sticker_set_gen.go b/tg/tl_input_sticker_set_gen.go index f16517c8e9..c4f1bfa50c 100644 --- a/tg/tl_input_sticker_set_gen.go +++ b/tg/tl_input_sticker_set_gen.go @@ -881,6 +881,208 @@ func (i *InputStickerSetPremiumGifts) DecodeBare(b *bin.Buffer) error { return nil } +// InputStickerSetEmojiGenericAnimations represents TL type `inputStickerSetEmojiGenericAnimations#4c4d4ce`. +// +// See https://core.telegram.org/constructor/inputStickerSetEmojiGenericAnimations for reference. +type InputStickerSetEmojiGenericAnimations struct { +} + +// InputStickerSetEmojiGenericAnimationsTypeID is TL type id of InputStickerSetEmojiGenericAnimations. +const InputStickerSetEmojiGenericAnimationsTypeID = 0x4c4d4ce + +// construct implements constructor of InputStickerSetClass. +func (i InputStickerSetEmojiGenericAnimations) construct() InputStickerSetClass { return &i } + +// Ensuring interfaces in compile-time for InputStickerSetEmojiGenericAnimations. +var ( + _ bin.Encoder = &InputStickerSetEmojiGenericAnimations{} + _ bin.Decoder = &InputStickerSetEmojiGenericAnimations{} + _ bin.BareEncoder = &InputStickerSetEmojiGenericAnimations{} + _ bin.BareDecoder = &InputStickerSetEmojiGenericAnimations{} + + _ InputStickerSetClass = &InputStickerSetEmojiGenericAnimations{} +) + +func (i *InputStickerSetEmojiGenericAnimations) Zero() bool { + if i == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputStickerSetEmojiGenericAnimations) String() string { + if i == nil { + return "InputStickerSetEmojiGenericAnimations(nil)" + } + type Alias InputStickerSetEmojiGenericAnimations + return fmt.Sprintf("InputStickerSetEmojiGenericAnimations%+v", Alias(*i)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputStickerSetEmojiGenericAnimations) TypeID() uint32 { + return InputStickerSetEmojiGenericAnimationsTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputStickerSetEmojiGenericAnimations) TypeName() string { + return "inputStickerSetEmojiGenericAnimations" +} + +// TypeInfo returns info about TL type. +func (i *InputStickerSetEmojiGenericAnimations) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputStickerSetEmojiGenericAnimations", + ID: InputStickerSetEmojiGenericAnimationsTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (i *InputStickerSetEmojiGenericAnimations) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStickerSetEmojiGenericAnimations#4c4d4ce as nil") + } + b.PutID(InputStickerSetEmojiGenericAnimationsTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputStickerSetEmojiGenericAnimations) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStickerSetEmojiGenericAnimations#4c4d4ce as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InputStickerSetEmojiGenericAnimations) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStickerSetEmojiGenericAnimations#4c4d4ce to nil") + } + if err := b.ConsumeID(InputStickerSetEmojiGenericAnimationsTypeID); err != nil { + return fmt.Errorf("unable to decode inputStickerSetEmojiGenericAnimations#4c4d4ce: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputStickerSetEmojiGenericAnimations) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStickerSetEmojiGenericAnimations#4c4d4ce to nil") + } + return nil +} + +// InputStickerSetEmojiDefaultStatuses represents TL type `inputStickerSetEmojiDefaultStatuses#29d0f5ee`. +// +// See https://core.telegram.org/constructor/inputStickerSetEmojiDefaultStatuses for reference. +type InputStickerSetEmojiDefaultStatuses struct { +} + +// InputStickerSetEmojiDefaultStatusesTypeID is TL type id of InputStickerSetEmojiDefaultStatuses. +const InputStickerSetEmojiDefaultStatusesTypeID = 0x29d0f5ee + +// construct implements constructor of InputStickerSetClass. +func (i InputStickerSetEmojiDefaultStatuses) construct() InputStickerSetClass { return &i } + +// Ensuring interfaces in compile-time for InputStickerSetEmojiDefaultStatuses. +var ( + _ bin.Encoder = &InputStickerSetEmojiDefaultStatuses{} + _ bin.Decoder = &InputStickerSetEmojiDefaultStatuses{} + _ bin.BareEncoder = &InputStickerSetEmojiDefaultStatuses{} + _ bin.BareDecoder = &InputStickerSetEmojiDefaultStatuses{} + + _ InputStickerSetClass = &InputStickerSetEmojiDefaultStatuses{} +) + +func (i *InputStickerSetEmojiDefaultStatuses) Zero() bool { + if i == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputStickerSetEmojiDefaultStatuses) String() string { + if i == nil { + return "InputStickerSetEmojiDefaultStatuses(nil)" + } + type Alias InputStickerSetEmojiDefaultStatuses + return fmt.Sprintf("InputStickerSetEmojiDefaultStatuses%+v", Alias(*i)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputStickerSetEmojiDefaultStatuses) TypeID() uint32 { + return InputStickerSetEmojiDefaultStatusesTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputStickerSetEmojiDefaultStatuses) TypeName() string { + return "inputStickerSetEmojiDefaultStatuses" +} + +// TypeInfo returns info about TL type. +func (i *InputStickerSetEmojiDefaultStatuses) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputStickerSetEmojiDefaultStatuses", + ID: InputStickerSetEmojiDefaultStatusesTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (i *InputStickerSetEmojiDefaultStatuses) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStickerSetEmojiDefaultStatuses#29d0f5ee as nil") + } + b.PutID(InputStickerSetEmojiDefaultStatusesTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputStickerSetEmojiDefaultStatuses) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStickerSetEmojiDefaultStatuses#29d0f5ee as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InputStickerSetEmojiDefaultStatuses) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStickerSetEmojiDefaultStatuses#29d0f5ee to nil") + } + if err := b.ConsumeID(InputStickerSetEmojiDefaultStatusesTypeID); err != nil { + return fmt.Errorf("unable to decode inputStickerSetEmojiDefaultStatuses#29d0f5ee: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputStickerSetEmojiDefaultStatuses) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStickerSetEmojiDefaultStatuses#29d0f5ee to nil") + } + return nil +} + // InputStickerSetClassName is schema name of InputStickerSetClass. const InputStickerSetClassName = "InputStickerSet" @@ -902,6 +1104,8 @@ const InputStickerSetClassName = "InputStickerSet" // case *tg.InputStickerSetDice: // inputStickerSetDice#e67f520e // case *tg.InputStickerSetAnimatedEmojiAnimations: // inputStickerSetAnimatedEmojiAnimations#cde3739 // case *tg.InputStickerSetPremiumGifts: // inputStickerSetPremiumGifts#c88b3b02 +// case *tg.InputStickerSetEmojiGenericAnimations: // inputStickerSetEmojiGenericAnimations#4c4d4ce +// case *tg.InputStickerSetEmojiDefaultStatuses: // inputStickerSetEmojiDefaultStatuses#29d0f5ee // default: panic(v) // } type InputStickerSetClass interface { @@ -979,6 +1183,20 @@ func DecodeInputStickerSet(buf *bin.Buffer) (InputStickerSetClass, error) { return nil, fmt.Errorf("unable to decode InputStickerSetClass: %w", err) } return &v, nil + case InputStickerSetEmojiGenericAnimationsTypeID: + // Decoding inputStickerSetEmojiGenericAnimations#4c4d4ce. + v := InputStickerSetEmojiGenericAnimations{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InputStickerSetClass: %w", err) + } + return &v, nil + case InputStickerSetEmojiDefaultStatusesTypeID: + // Decoding inputStickerSetEmojiDefaultStatuses#29d0f5ee. + v := InputStickerSetEmojiDefaultStatuses{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InputStickerSetClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode InputStickerSetClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_message_peer_reaction_gen.go b/tg/tl_message_peer_reaction_gen.go index 07a5cc7843..15877ee5c1 100644 --- a/tg/tl_message_peer_reaction_gen.go +++ b/tg/tl_message_peer_reaction_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagePeerReaction represents TL type `messagePeerReaction#51b67eff`. +// MessagePeerReaction represents TL type `messagePeerReaction#b156fe9c`. // How a certain peer reacted to the message // // See https://core.telegram.org/constructor/messagePeerReaction for reference. @@ -51,11 +51,11 @@ type MessagePeerReaction struct { // Peer that reacted to the message PeerID PeerClass // Reaction emoji - Reaction string + Reaction ReactionClass } // MessagePeerReactionTypeID is TL type id of MessagePeerReaction. -const MessagePeerReactionTypeID = 0x51b67eff +const MessagePeerReactionTypeID = 0xb156fe9c // Ensuring interfaces in compile-time for MessagePeerReaction. var ( @@ -81,7 +81,7 @@ func (m *MessagePeerReaction) Zero() bool { if !(m.PeerID == nil) { return false } - if !(m.Reaction == "") { + if !(m.Reaction == nil) { return false } @@ -102,7 +102,7 @@ func (m *MessagePeerReaction) FillFrom(from interface { GetBig() (value bool) GetUnread() (value bool) GetPeerID() (value PeerClass) - GetReaction() (value string) + GetReaction() (value ReactionClass) }) { m.Big = from.GetBig() m.Unread = from.GetUnread() @@ -168,7 +168,7 @@ func (m *MessagePeerReaction) SetFlags() { // Encode implements bin.Encoder. func (m *MessagePeerReaction) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messagePeerReaction#51b67eff as nil") + return fmt.Errorf("can't encode messagePeerReaction#b156fe9c as nil") } b.PutID(MessagePeerReactionTypeID) return m.EncodeBare(b) @@ -177,29 +177,34 @@ func (m *MessagePeerReaction) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *MessagePeerReaction) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messagePeerReaction#51b67eff as nil") + return fmt.Errorf("can't encode messagePeerReaction#b156fe9c as nil") } m.SetFlags() if err := m.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messagePeerReaction#51b67eff: field flags: %w", err) + return fmt.Errorf("unable to encode messagePeerReaction#b156fe9c: field flags: %w", err) } if m.PeerID == nil { - return fmt.Errorf("unable to encode messagePeerReaction#51b67eff: field peer_id is nil") + return fmt.Errorf("unable to encode messagePeerReaction#b156fe9c: field peer_id is nil") } if err := m.PeerID.Encode(b); err != nil { - return fmt.Errorf("unable to encode messagePeerReaction#51b67eff: field peer_id: %w", err) + return fmt.Errorf("unable to encode messagePeerReaction#b156fe9c: field peer_id: %w", err) + } + if m.Reaction == nil { + return fmt.Errorf("unable to encode messagePeerReaction#b156fe9c: field reaction is nil") + } + if err := m.Reaction.Encode(b); err != nil { + return fmt.Errorf("unable to encode messagePeerReaction#b156fe9c: field reaction: %w", err) } - b.PutString(m.Reaction) return nil } // Decode implements bin.Decoder. func (m *MessagePeerReaction) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messagePeerReaction#51b67eff to nil") + return fmt.Errorf("can't decode messagePeerReaction#b156fe9c to nil") } if err := b.ConsumeID(MessagePeerReactionTypeID); err != nil { - return fmt.Errorf("unable to decode messagePeerReaction#51b67eff: %w", err) + return fmt.Errorf("unable to decode messagePeerReaction#b156fe9c: %w", err) } return m.DecodeBare(b) } @@ -207,11 +212,11 @@ func (m *MessagePeerReaction) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *MessagePeerReaction) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messagePeerReaction#51b67eff to nil") + return fmt.Errorf("can't decode messagePeerReaction#b156fe9c to nil") } { if err := m.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messagePeerReaction#51b67eff: field flags: %w", err) + return fmt.Errorf("unable to decode messagePeerReaction#b156fe9c: field flags: %w", err) } } m.Big = m.Flags.Has(0) @@ -219,14 +224,14 @@ func (m *MessagePeerReaction) DecodeBare(b *bin.Buffer) error { { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode messagePeerReaction#51b67eff: field peer_id: %w", err) + return fmt.Errorf("unable to decode messagePeerReaction#b156fe9c: field peer_id: %w", err) } m.PeerID = value } { - value, err := b.String() + value, err := DecodeReaction(b) if err != nil { - return fmt.Errorf("unable to decode messagePeerReaction#51b67eff: field reaction: %w", err) + return fmt.Errorf("unable to decode messagePeerReaction#b156fe9c: field reaction: %w", err) } m.Reaction = value } @@ -280,7 +285,7 @@ func (m *MessagePeerReaction) GetPeerID() (value PeerClass) { } // GetReaction returns value of Reaction field. -func (m *MessagePeerReaction) GetReaction() (value string) { +func (m *MessagePeerReaction) GetReaction() (value ReactionClass) { if m == nil { return } diff --git a/tg/tl_messages_clear_recent_reactions_gen.go b/tg/tl_messages_clear_recent_reactions_gen.go new file mode 100644 index 0000000000..0ec6127a61 --- /dev/null +++ b/tg/tl_messages_clear_recent_reactions_gen.go @@ -0,0 +1,142 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// MessagesClearRecentReactionsRequest represents TL type `messages.clearRecentReactions#9dfeefb4`. +// +// See https://core.telegram.org/method/messages.clearRecentReactions for reference. +type MessagesClearRecentReactionsRequest struct { +} + +// MessagesClearRecentReactionsRequestTypeID is TL type id of MessagesClearRecentReactionsRequest. +const MessagesClearRecentReactionsRequestTypeID = 0x9dfeefb4 + +// Ensuring interfaces in compile-time for MessagesClearRecentReactionsRequest. +var ( + _ bin.Encoder = &MessagesClearRecentReactionsRequest{} + _ bin.Decoder = &MessagesClearRecentReactionsRequest{} + _ bin.BareEncoder = &MessagesClearRecentReactionsRequest{} + _ bin.BareDecoder = &MessagesClearRecentReactionsRequest{} +) + +func (c *MessagesClearRecentReactionsRequest) Zero() bool { + if c == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (c *MessagesClearRecentReactionsRequest) String() string { + if c == nil { + return "MessagesClearRecentReactionsRequest(nil)" + } + type Alias MessagesClearRecentReactionsRequest + return fmt.Sprintf("MessagesClearRecentReactionsRequest%+v", Alias(*c)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesClearRecentReactionsRequest) TypeID() uint32 { + return MessagesClearRecentReactionsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesClearRecentReactionsRequest) TypeName() string { + return "messages.clearRecentReactions" +} + +// TypeInfo returns info about TL type. +func (c *MessagesClearRecentReactionsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.clearRecentReactions", + ID: MessagesClearRecentReactionsRequestTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (c *MessagesClearRecentReactionsRequest) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode messages.clearRecentReactions#9dfeefb4 as nil") + } + b.PutID(MessagesClearRecentReactionsRequestTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *MessagesClearRecentReactionsRequest) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode messages.clearRecentReactions#9dfeefb4 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (c *MessagesClearRecentReactionsRequest) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode messages.clearRecentReactions#9dfeefb4 to nil") + } + if err := b.ConsumeID(MessagesClearRecentReactionsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.clearRecentReactions#9dfeefb4: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *MessagesClearRecentReactionsRequest) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode messages.clearRecentReactions#9dfeefb4 to nil") + } + return nil +} + +// MessagesClearRecentReactions invokes method messages.clearRecentReactions#9dfeefb4 returning error if any. +// +// See https://core.telegram.org/method/messages.clearRecentReactions for reference. +func (c *Client) MessagesClearRecentReactions(ctx context.Context) (bool, error) { + var result BoolBox + + request := &MessagesClearRecentReactionsRequest{} + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return false, err + } + _, ok := result.Bool.(*BoolTrue) + return ok, nil +} diff --git a/tg/tl_messages_clear_recent_reactions_slices_gen.go b/tg/tl_messages_clear_recent_reactions_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_clear_recent_reactions_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_get_message_reactions_list_gen.go b/tg/tl_messages_get_message_reactions_list_gen.go index 4b472466cf..c38073fb9b 100644 --- a/tg/tl_messages_get_message_reactions_list_gen.go +++ b/tg/tl_messages_get_message_reactions_list_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesGetMessageReactionsListRequest represents TL type `messages.getMessageReactionsList#e0ee6b77`. +// MessagesGetMessageReactionsListRequest represents TL type `messages.getMessageReactionsList#461b3f48`. // Get message reaction¹ list, along with the sender of each reaction. // // Links: @@ -51,7 +51,7 @@ type MessagesGetMessageReactionsListRequest struct { // Get only reactions of this type (UTF8 emoji) // // Use SetReaction and GetReaction helpers. - Reaction string + Reaction ReactionClass // Offset (typically taken from the next_offset field of the returned messages // MessageReactionsList¹) // @@ -68,7 +68,7 @@ type MessagesGetMessageReactionsListRequest struct { } // MessagesGetMessageReactionsListRequestTypeID is TL type id of MessagesGetMessageReactionsListRequest. -const MessagesGetMessageReactionsListRequestTypeID = 0xe0ee6b77 +const MessagesGetMessageReactionsListRequestTypeID = 0x461b3f48 // Ensuring interfaces in compile-time for MessagesGetMessageReactionsListRequest. var ( @@ -91,7 +91,7 @@ func (g *MessagesGetMessageReactionsListRequest) Zero() bool { if !(g.ID == 0) { return false } - if !(g.Reaction == "") { + if !(g.Reaction == nil) { return false } if !(g.Offset == "") { @@ -117,7 +117,7 @@ func (g *MessagesGetMessageReactionsListRequest) String() string { func (g *MessagesGetMessageReactionsListRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) GetID() (value int) - GetReaction() (value string, ok bool) + GetReaction() (value ReactionClass, ok bool) GetOffset() (value string, ok bool) GetLimit() (value int) }) { @@ -185,7 +185,7 @@ func (g *MessagesGetMessageReactionsListRequest) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (g *MessagesGetMessageReactionsListRequest) SetFlags() { - if !(g.Reaction == "") { + if !(g.Reaction == nil) { g.Flags.Set(0) } if !(g.Offset == "") { @@ -196,7 +196,7 @@ func (g *MessagesGetMessageReactionsListRequest) SetFlags() { // Encode implements bin.Encoder. func (g *MessagesGetMessageReactionsListRequest) Encode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode messages.getMessageReactionsList#e0ee6b77 as nil") + return fmt.Errorf("can't encode messages.getMessageReactionsList#461b3f48 as nil") } b.PutID(MessagesGetMessageReactionsListRequestTypeID) return g.EncodeBare(b) @@ -205,21 +205,26 @@ func (g *MessagesGetMessageReactionsListRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (g *MessagesGetMessageReactionsListRequest) EncodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode messages.getMessageReactionsList#e0ee6b77 as nil") + return fmt.Errorf("can't encode messages.getMessageReactionsList#461b3f48 as nil") } g.SetFlags() if err := g.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.getMessageReactionsList#e0ee6b77: field flags: %w", err) + return fmt.Errorf("unable to encode messages.getMessageReactionsList#461b3f48: field flags: %w", err) } if g.Peer == nil { - return fmt.Errorf("unable to encode messages.getMessageReactionsList#e0ee6b77: field peer is nil") + return fmt.Errorf("unable to encode messages.getMessageReactionsList#461b3f48: field peer is nil") } if err := g.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.getMessageReactionsList#e0ee6b77: field peer: %w", err) + return fmt.Errorf("unable to encode messages.getMessageReactionsList#461b3f48: field peer: %w", err) } b.PutInt(g.ID) if g.Flags.Has(0) { - b.PutString(g.Reaction) + if g.Reaction == nil { + return fmt.Errorf("unable to encode messages.getMessageReactionsList#461b3f48: field reaction is nil") + } + if err := g.Reaction.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getMessageReactionsList#461b3f48: field reaction: %w", err) + } } if g.Flags.Has(1) { b.PutString(g.Offset) @@ -231,10 +236,10 @@ func (g *MessagesGetMessageReactionsListRequest) EncodeBare(b *bin.Buffer) error // Decode implements bin.Decoder. func (g *MessagesGetMessageReactionsListRequest) Decode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode messages.getMessageReactionsList#e0ee6b77 to nil") + return fmt.Errorf("can't decode messages.getMessageReactionsList#461b3f48 to nil") } if err := b.ConsumeID(MessagesGetMessageReactionsListRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.getMessageReactionsList#e0ee6b77: %w", err) + return fmt.Errorf("unable to decode messages.getMessageReactionsList#461b3f48: %w", err) } return g.DecodeBare(b) } @@ -242,45 +247,45 @@ func (g *MessagesGetMessageReactionsListRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (g *MessagesGetMessageReactionsListRequest) DecodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode messages.getMessageReactionsList#e0ee6b77 to nil") + return fmt.Errorf("can't decode messages.getMessageReactionsList#461b3f48 to nil") } { if err := g.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.getMessageReactionsList#e0ee6b77: field flags: %w", err) + return fmt.Errorf("unable to decode messages.getMessageReactionsList#461b3f48: field flags: %w", err) } } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.getMessageReactionsList#e0ee6b77: field peer: %w", err) + return fmt.Errorf("unable to decode messages.getMessageReactionsList#461b3f48: field peer: %w", err) } g.Peer = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getMessageReactionsList#e0ee6b77: field id: %w", err) + return fmt.Errorf("unable to decode messages.getMessageReactionsList#461b3f48: field id: %w", err) } g.ID = value } if g.Flags.Has(0) { - value, err := b.String() + value, err := DecodeReaction(b) if err != nil { - return fmt.Errorf("unable to decode messages.getMessageReactionsList#e0ee6b77: field reaction: %w", err) + return fmt.Errorf("unable to decode messages.getMessageReactionsList#461b3f48: field reaction: %w", err) } g.Reaction = value } if g.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.getMessageReactionsList#e0ee6b77: field offset: %w", err) + return fmt.Errorf("unable to decode messages.getMessageReactionsList#461b3f48: field offset: %w", err) } g.Offset = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getMessageReactionsList#e0ee6b77: field limit: %w", err) + return fmt.Errorf("unable to decode messages.getMessageReactionsList#461b3f48: field limit: %w", err) } g.Limit = value } @@ -304,14 +309,14 @@ func (g *MessagesGetMessageReactionsListRequest) GetID() (value int) { } // SetReaction sets value of Reaction conditional field. -func (g *MessagesGetMessageReactionsListRequest) SetReaction(value string) { +func (g *MessagesGetMessageReactionsListRequest) SetReaction(value ReactionClass) { g.Flags.Set(0) g.Reaction = value } // GetReaction returns value of Reaction conditional field and // boolean which is true if field was set. -func (g *MessagesGetMessageReactionsListRequest) GetReaction() (value string, ok bool) { +func (g *MessagesGetMessageReactionsListRequest) GetReaction() (value ReactionClass, ok bool) { if g == nil { return } @@ -347,7 +352,7 @@ func (g *MessagesGetMessageReactionsListRequest) GetLimit() (value int) { return g.Limit } -// MessagesGetMessageReactionsList invokes method messages.getMessageReactionsList#e0ee6b77 returning error if any. +// MessagesGetMessageReactionsList invokes method messages.getMessageReactionsList#461b3f48 returning error if any. // Get message reaction¹ list, along with the sender of each reaction. // // Links: diff --git a/tg/tl_messages_get_recent_reactions_gen.go b/tg/tl_messages_get_recent_reactions_gen.go new file mode 100644 index 0000000000..3b727138bf --- /dev/null +++ b/tg/tl_messages_get_recent_reactions_gen.go @@ -0,0 +1,200 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// MessagesGetRecentReactionsRequest represents TL type `messages.getRecentReactions#39461db2`. +// +// See https://core.telegram.org/method/messages.getRecentReactions for reference. +type MessagesGetRecentReactionsRequest struct { + // Limit field of MessagesGetRecentReactionsRequest. + Limit int + // Hash field of MessagesGetRecentReactionsRequest. + Hash int64 +} + +// MessagesGetRecentReactionsRequestTypeID is TL type id of MessagesGetRecentReactionsRequest. +const MessagesGetRecentReactionsRequestTypeID = 0x39461db2 + +// Ensuring interfaces in compile-time for MessagesGetRecentReactionsRequest. +var ( + _ bin.Encoder = &MessagesGetRecentReactionsRequest{} + _ bin.Decoder = &MessagesGetRecentReactionsRequest{} + _ bin.BareEncoder = &MessagesGetRecentReactionsRequest{} + _ bin.BareDecoder = &MessagesGetRecentReactionsRequest{} +) + +func (g *MessagesGetRecentReactionsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Limit == 0) { + return false + } + if !(g.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *MessagesGetRecentReactionsRequest) String() string { + if g == nil { + return "MessagesGetRecentReactionsRequest(nil)" + } + type Alias MessagesGetRecentReactionsRequest + return fmt.Sprintf("MessagesGetRecentReactionsRequest%+v", Alias(*g)) +} + +// FillFrom fills MessagesGetRecentReactionsRequest from given interface. +func (g *MessagesGetRecentReactionsRequest) FillFrom(from interface { + GetLimit() (value int) + GetHash() (value int64) +}) { + g.Limit = from.GetLimit() + g.Hash = from.GetHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesGetRecentReactionsRequest) TypeID() uint32 { + return MessagesGetRecentReactionsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesGetRecentReactionsRequest) TypeName() string { + return "messages.getRecentReactions" +} + +// TypeInfo returns info about TL type. +func (g *MessagesGetRecentReactionsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.getRecentReactions", + ID: MessagesGetRecentReactionsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Limit", + SchemaName: "limit", + }, + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *MessagesGetRecentReactionsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getRecentReactions#39461db2 as nil") + } + b.PutID(MessagesGetRecentReactionsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *MessagesGetRecentReactionsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getRecentReactions#39461db2 as nil") + } + b.PutInt(g.Limit) + b.PutLong(g.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (g *MessagesGetRecentReactionsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getRecentReactions#39461db2 to nil") + } + if err := b.ConsumeID(MessagesGetRecentReactionsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.getRecentReactions#39461db2: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *MessagesGetRecentReactionsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getRecentReactions#39461db2 to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getRecentReactions#39461db2: field limit: %w", err) + } + g.Limit = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messages.getRecentReactions#39461db2: field hash: %w", err) + } + g.Hash = value + } + return nil +} + +// GetLimit returns value of Limit field. +func (g *MessagesGetRecentReactionsRequest) GetLimit() (value int) { + if g == nil { + return + } + return g.Limit +} + +// GetHash returns value of Hash field. +func (g *MessagesGetRecentReactionsRequest) GetHash() (value int64) { + if g == nil { + return + } + return g.Hash +} + +// MessagesGetRecentReactions invokes method messages.getRecentReactions#39461db2 returning error if any. +// +// See https://core.telegram.org/method/messages.getRecentReactions for reference. +func (c *Client) MessagesGetRecentReactions(ctx context.Context, request *MessagesGetRecentReactionsRequest) (MessagesReactionsClass, error) { + var result MessagesReactionsBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Reactions, nil +} diff --git a/tg/tl_messages_get_recent_reactions_slices_gen.go b/tg/tl_messages_get_recent_reactions_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_get_recent_reactions_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_get_top_reactions_gen.go b/tg/tl_messages_get_top_reactions_gen.go new file mode 100644 index 0000000000..b3ad54489e --- /dev/null +++ b/tg/tl_messages_get_top_reactions_gen.go @@ -0,0 +1,200 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// MessagesGetTopReactionsRequest represents TL type `messages.getTopReactions#bb8125ba`. +// +// See https://core.telegram.org/method/messages.getTopReactions for reference. +type MessagesGetTopReactionsRequest struct { + // Limit field of MessagesGetTopReactionsRequest. + Limit int + // Hash field of MessagesGetTopReactionsRequest. + Hash int64 +} + +// MessagesGetTopReactionsRequestTypeID is TL type id of MessagesGetTopReactionsRequest. +const MessagesGetTopReactionsRequestTypeID = 0xbb8125ba + +// Ensuring interfaces in compile-time for MessagesGetTopReactionsRequest. +var ( + _ bin.Encoder = &MessagesGetTopReactionsRequest{} + _ bin.Decoder = &MessagesGetTopReactionsRequest{} + _ bin.BareEncoder = &MessagesGetTopReactionsRequest{} + _ bin.BareDecoder = &MessagesGetTopReactionsRequest{} +) + +func (g *MessagesGetTopReactionsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Limit == 0) { + return false + } + if !(g.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *MessagesGetTopReactionsRequest) String() string { + if g == nil { + return "MessagesGetTopReactionsRequest(nil)" + } + type Alias MessagesGetTopReactionsRequest + return fmt.Sprintf("MessagesGetTopReactionsRequest%+v", Alias(*g)) +} + +// FillFrom fills MessagesGetTopReactionsRequest from given interface. +func (g *MessagesGetTopReactionsRequest) FillFrom(from interface { + GetLimit() (value int) + GetHash() (value int64) +}) { + g.Limit = from.GetLimit() + g.Hash = from.GetHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesGetTopReactionsRequest) TypeID() uint32 { + return MessagesGetTopReactionsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesGetTopReactionsRequest) TypeName() string { + return "messages.getTopReactions" +} + +// TypeInfo returns info about TL type. +func (g *MessagesGetTopReactionsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.getTopReactions", + ID: MessagesGetTopReactionsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Limit", + SchemaName: "limit", + }, + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *MessagesGetTopReactionsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getTopReactions#bb8125ba as nil") + } + b.PutID(MessagesGetTopReactionsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *MessagesGetTopReactionsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getTopReactions#bb8125ba as nil") + } + b.PutInt(g.Limit) + b.PutLong(g.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (g *MessagesGetTopReactionsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getTopReactions#bb8125ba to nil") + } + if err := b.ConsumeID(MessagesGetTopReactionsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.getTopReactions#bb8125ba: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *MessagesGetTopReactionsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getTopReactions#bb8125ba to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getTopReactions#bb8125ba: field limit: %w", err) + } + g.Limit = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messages.getTopReactions#bb8125ba: field hash: %w", err) + } + g.Hash = value + } + return nil +} + +// GetLimit returns value of Limit field. +func (g *MessagesGetTopReactionsRequest) GetLimit() (value int) { + if g == nil { + return + } + return g.Limit +} + +// GetHash returns value of Hash field. +func (g *MessagesGetTopReactionsRequest) GetHash() (value int64) { + if g == nil { + return + } + return g.Hash +} + +// MessagesGetTopReactions invokes method messages.getTopReactions#bb8125ba returning error if any. +// +// See https://core.telegram.org/method/messages.getTopReactions for reference. +func (c *Client) MessagesGetTopReactions(ctx context.Context, request *MessagesGetTopReactionsRequest) (MessagesReactionsClass, error) { + var result MessagesReactionsBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Reactions, nil +} diff --git a/tg/tl_messages_get_top_reactions_slices_gen.go b/tg/tl_messages_get_top_reactions_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_get_top_reactions_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_reactions_gen.go b/tg/tl_messages_reactions_gen.go new file mode 100644 index 0000000000..747c21e650 --- /dev/null +++ b/tg/tl_messages_reactions_gen.go @@ -0,0 +1,419 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// MessagesReactionsNotModified represents TL type `messages.reactionsNotModified#b06fdbdf`. +// +// See https://core.telegram.org/constructor/messages.reactionsNotModified for reference. +type MessagesReactionsNotModified struct { +} + +// MessagesReactionsNotModifiedTypeID is TL type id of MessagesReactionsNotModified. +const MessagesReactionsNotModifiedTypeID = 0xb06fdbdf + +// construct implements constructor of MessagesReactionsClass. +func (r MessagesReactionsNotModified) construct() MessagesReactionsClass { return &r } + +// Ensuring interfaces in compile-time for MessagesReactionsNotModified. +var ( + _ bin.Encoder = &MessagesReactionsNotModified{} + _ bin.Decoder = &MessagesReactionsNotModified{} + _ bin.BareEncoder = &MessagesReactionsNotModified{} + _ bin.BareDecoder = &MessagesReactionsNotModified{} + + _ MessagesReactionsClass = &MessagesReactionsNotModified{} +) + +func (r *MessagesReactionsNotModified) Zero() bool { + if r == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (r *MessagesReactionsNotModified) String() string { + if r == nil { + return "MessagesReactionsNotModified(nil)" + } + type Alias MessagesReactionsNotModified + return fmt.Sprintf("MessagesReactionsNotModified%+v", Alias(*r)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesReactionsNotModified) TypeID() uint32 { + return MessagesReactionsNotModifiedTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesReactionsNotModified) TypeName() string { + return "messages.reactionsNotModified" +} + +// TypeInfo returns info about TL type. +func (r *MessagesReactionsNotModified) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.reactionsNotModified", + ID: MessagesReactionsNotModifiedTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (r *MessagesReactionsNotModified) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.reactionsNotModified#b06fdbdf as nil") + } + b.PutID(MessagesReactionsNotModifiedTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *MessagesReactionsNotModified) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.reactionsNotModified#b06fdbdf as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (r *MessagesReactionsNotModified) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.reactionsNotModified#b06fdbdf to nil") + } + if err := b.ConsumeID(MessagesReactionsNotModifiedTypeID); err != nil { + return fmt.Errorf("unable to decode messages.reactionsNotModified#b06fdbdf: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *MessagesReactionsNotModified) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.reactionsNotModified#b06fdbdf to nil") + } + return nil +} + +// MessagesReactions represents TL type `messages.reactions#eafdf716`. +// +// See https://core.telegram.org/constructor/messages.reactions for reference. +type MessagesReactions struct { + // Hash field of MessagesReactions. + Hash int64 + // Reactions field of MessagesReactions. + Reactions []ReactionClass +} + +// MessagesReactionsTypeID is TL type id of MessagesReactions. +const MessagesReactionsTypeID = 0xeafdf716 + +// construct implements constructor of MessagesReactionsClass. +func (r MessagesReactions) construct() MessagesReactionsClass { return &r } + +// Ensuring interfaces in compile-time for MessagesReactions. +var ( + _ bin.Encoder = &MessagesReactions{} + _ bin.Decoder = &MessagesReactions{} + _ bin.BareEncoder = &MessagesReactions{} + _ bin.BareDecoder = &MessagesReactions{} + + _ MessagesReactionsClass = &MessagesReactions{} +) + +func (r *MessagesReactions) Zero() bool { + if r == nil { + return true + } + if !(r.Hash == 0) { + return false + } + if !(r.Reactions == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *MessagesReactions) String() string { + if r == nil { + return "MessagesReactions(nil)" + } + type Alias MessagesReactions + return fmt.Sprintf("MessagesReactions%+v", Alias(*r)) +} + +// FillFrom fills MessagesReactions from given interface. +func (r *MessagesReactions) FillFrom(from interface { + GetHash() (value int64) + GetReactions() (value []ReactionClass) +}) { + r.Hash = from.GetHash() + r.Reactions = from.GetReactions() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesReactions) TypeID() uint32 { + return MessagesReactionsTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesReactions) TypeName() string { + return "messages.reactions" +} + +// TypeInfo returns info about TL type. +func (r *MessagesReactions) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.reactions", + ID: MessagesReactionsTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + { + Name: "Reactions", + SchemaName: "reactions", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (r *MessagesReactions) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.reactions#eafdf716 as nil") + } + b.PutID(MessagesReactionsTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *MessagesReactions) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.reactions#eafdf716 as nil") + } + b.PutLong(r.Hash) + b.PutVectorHeader(len(r.Reactions)) + for idx, v := range r.Reactions { + if v == nil { + return fmt.Errorf("unable to encode messages.reactions#eafdf716: field reactions element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.reactions#eafdf716: field reactions element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (r *MessagesReactions) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.reactions#eafdf716 to nil") + } + if err := b.ConsumeID(MessagesReactionsTypeID); err != nil { + return fmt.Errorf("unable to decode messages.reactions#eafdf716: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *MessagesReactions) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.reactions#eafdf716 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messages.reactions#eafdf716: field hash: %w", err) + } + r.Hash = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.reactions#eafdf716: field reactions: %w", err) + } + + if headerLen > 0 { + r.Reactions = make([]ReactionClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeReaction(b) + if err != nil { + return fmt.Errorf("unable to decode messages.reactions#eafdf716: field reactions: %w", err) + } + r.Reactions = append(r.Reactions, value) + } + } + return nil +} + +// GetHash returns value of Hash field. +func (r *MessagesReactions) GetHash() (value int64) { + if r == nil { + return + } + return r.Hash +} + +// GetReactions returns value of Reactions field. +func (r *MessagesReactions) GetReactions() (value []ReactionClass) { + if r == nil { + return + } + return r.Reactions +} + +// MapReactions returns field Reactions wrapped in ReactionClassArray helper. +func (r *MessagesReactions) MapReactions() (value ReactionClassArray) { + return ReactionClassArray(r.Reactions) +} + +// MessagesReactionsClassName is schema name of MessagesReactionsClass. +const MessagesReactionsClassName = "messages.Reactions" + +// MessagesReactionsClass represents messages.Reactions generic type. +// +// See https://core.telegram.org/type/messages.Reactions for reference. +// +// Example: +// +// g, err := tg.DecodeMessagesReactions(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.MessagesReactionsNotModified: // messages.reactionsNotModified#b06fdbdf +// case *tg.MessagesReactions: // messages.reactions#eafdf716 +// default: panic(v) +// } +type MessagesReactionsClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() MessagesReactionsClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool + + // AsModified tries to map MessagesReactionsClass to MessagesReactions. + AsModified() (*MessagesReactions, bool) +} + +// AsModified tries to map MessagesReactionsNotModified to MessagesReactions. +func (r *MessagesReactionsNotModified) AsModified() (*MessagesReactions, bool) { + return nil, false +} + +// AsModified tries to map MessagesReactions to MessagesReactions. +func (r *MessagesReactions) AsModified() (*MessagesReactions, bool) { + return r, true +} + +// DecodeMessagesReactions implements binary de-serialization for MessagesReactionsClass. +func DecodeMessagesReactions(buf *bin.Buffer) (MessagesReactionsClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case MessagesReactionsNotModifiedTypeID: + // Decoding messages.reactionsNotModified#b06fdbdf. + v := MessagesReactionsNotModified{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessagesReactionsClass: %w", err) + } + return &v, nil + case MessagesReactionsTypeID: + // Decoding messages.reactions#eafdf716. + v := MessagesReactions{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessagesReactionsClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode MessagesReactionsClass: %w", bin.NewUnexpectedID(id)) + } +} + +// MessagesReactions boxes the MessagesReactionsClass providing a helper. +type MessagesReactionsBox struct { + Reactions MessagesReactionsClass +} + +// Decode implements bin.Decoder for MessagesReactionsBox. +func (b *MessagesReactionsBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode MessagesReactionsBox to nil") + } + v, err := DecodeMessagesReactions(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.Reactions = v + return nil +} + +// Encode implements bin.Encode for MessagesReactionsBox. +func (b *MessagesReactionsBox) Encode(buf *bin.Buffer) error { + if b == nil || b.Reactions == nil { + return fmt.Errorf("unable to encode MessagesReactionsClass as nil") + } + return b.Reactions.Encode(buf) +} diff --git a/tg/tl_messages_reactions_slices_gen.go b/tg/tl_messages_reactions_slices_gen.go new file mode 100644 index 0000000000..ab96b38682 --- /dev/null +++ b/tg/tl_messages_reactions_slices_gen.go @@ -0,0 +1,267 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// MessagesReactionsClassArray is adapter for slice of MessagesReactionsClass. +type MessagesReactionsClassArray []MessagesReactionsClass + +// Sort sorts slice of MessagesReactionsClass. +func (s MessagesReactionsClassArray) Sort(less func(a, b MessagesReactionsClass) bool) MessagesReactionsClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessagesReactionsClass. +func (s MessagesReactionsClassArray) SortStable(less func(a, b MessagesReactionsClass) bool) MessagesReactionsClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessagesReactionsClass. +func (s MessagesReactionsClassArray) Retain(keep func(x MessagesReactionsClass) bool) MessagesReactionsClassArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s MessagesReactionsClassArray) First() (v MessagesReactionsClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessagesReactionsClassArray) Last() (v MessagesReactionsClass, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *MessagesReactionsClassArray) PopFirst() (v MessagesReactionsClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero MessagesReactionsClass + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *MessagesReactionsClassArray) Pop() (v MessagesReactionsClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// AsMessagesReactions returns copy with only MessagesReactions constructors. +func (s MessagesReactionsClassArray) AsMessagesReactions() (to MessagesReactionsArray) { + for _, elem := range s { + value, ok := elem.(*MessagesReactions) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AppendOnlyModified appends only Modified constructors to +// given slice. +func (s MessagesReactionsClassArray) AppendOnlyModified(to []*MessagesReactions) []*MessagesReactions { + for _, elem := range s { + value, ok := elem.AsModified() + if !ok { + continue + } + to = append(to, value) + } + + return to +} + +// AsModified returns copy with only Modified constructors. +func (s MessagesReactionsClassArray) AsModified() (to []*MessagesReactions) { + return s.AppendOnlyModified(to) +} + +// FirstAsModified returns first element of slice (if exists). +func (s MessagesReactionsClassArray) FirstAsModified() (v *MessagesReactions, ok bool) { + value, ok := s.First() + if !ok { + return + } + return value.AsModified() +} + +// LastAsModified returns last element of slice (if exists). +func (s MessagesReactionsClassArray) LastAsModified() (v *MessagesReactions, ok bool) { + value, ok := s.Last() + if !ok { + return + } + return value.AsModified() +} + +// PopFirstAsModified returns element of slice (if exists). +func (s *MessagesReactionsClassArray) PopFirstAsModified() (v *MessagesReactions, ok bool) { + value, ok := s.PopFirst() + if !ok { + return + } + return value.AsModified() +} + +// PopAsModified returns element of slice (if exists). +func (s *MessagesReactionsClassArray) PopAsModified() (v *MessagesReactions, ok bool) { + value, ok := s.Pop() + if !ok { + return + } + return value.AsModified() +} + +// MessagesReactionsArray is adapter for slice of MessagesReactions. +type MessagesReactionsArray []MessagesReactions + +// Sort sorts slice of MessagesReactions. +func (s MessagesReactionsArray) Sort(less func(a, b MessagesReactions) bool) MessagesReactionsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessagesReactions. +func (s MessagesReactionsArray) SortStable(less func(a, b MessagesReactions) bool) MessagesReactionsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessagesReactions. +func (s MessagesReactionsArray) Retain(keep func(x MessagesReactions) bool) MessagesReactionsArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s MessagesReactionsArray) First() (v MessagesReactions, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessagesReactionsArray) Last() (v MessagesReactions, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *MessagesReactionsArray) PopFirst() (v MessagesReactions, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero MessagesReactions + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *MessagesReactionsArray) Pop() (v MessagesReactions, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_messages_report_reaction_gen.go b/tg/tl_messages_report_reaction_gen.go new file mode 100644 index 0000000000..30bb8a292d --- /dev/null +++ b/tg/tl_messages_report_reaction_gen.go @@ -0,0 +1,238 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// MessagesReportReactionRequest represents TL type `messages.reportReaction#3f64c076`. +// +// See https://core.telegram.org/method/messages.reportReaction for reference. +type MessagesReportReactionRequest struct { + // Peer field of MessagesReportReactionRequest. + Peer InputPeerClass + // ID field of MessagesReportReactionRequest. + ID int + // ReactionPeer field of MessagesReportReactionRequest. + ReactionPeer InputPeerClass +} + +// MessagesReportReactionRequestTypeID is TL type id of MessagesReportReactionRequest. +const MessagesReportReactionRequestTypeID = 0x3f64c076 + +// Ensuring interfaces in compile-time for MessagesReportReactionRequest. +var ( + _ bin.Encoder = &MessagesReportReactionRequest{} + _ bin.Decoder = &MessagesReportReactionRequest{} + _ bin.BareEncoder = &MessagesReportReactionRequest{} + _ bin.BareDecoder = &MessagesReportReactionRequest{} +) + +func (r *MessagesReportReactionRequest) Zero() bool { + if r == nil { + return true + } + if !(r.Peer == nil) { + return false + } + if !(r.ID == 0) { + return false + } + if !(r.ReactionPeer == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *MessagesReportReactionRequest) String() string { + if r == nil { + return "MessagesReportReactionRequest(nil)" + } + type Alias MessagesReportReactionRequest + return fmt.Sprintf("MessagesReportReactionRequest%+v", Alias(*r)) +} + +// FillFrom fills MessagesReportReactionRequest from given interface. +func (r *MessagesReportReactionRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetID() (value int) + GetReactionPeer() (value InputPeerClass) +}) { + r.Peer = from.GetPeer() + r.ID = from.GetID() + r.ReactionPeer = from.GetReactionPeer() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesReportReactionRequest) TypeID() uint32 { + return MessagesReportReactionRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesReportReactionRequest) TypeName() string { + return "messages.reportReaction" +} + +// TypeInfo returns info about TL type. +func (r *MessagesReportReactionRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.reportReaction", + ID: MessagesReportReactionRequestTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "ID", + SchemaName: "id", + }, + { + Name: "ReactionPeer", + SchemaName: "reaction_peer", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (r *MessagesReportReactionRequest) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.reportReaction#3f64c076 as nil") + } + b.PutID(MessagesReportReactionRequestTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *MessagesReportReactionRequest) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.reportReaction#3f64c076 as nil") + } + if r.Peer == nil { + return fmt.Errorf("unable to encode messages.reportReaction#3f64c076: field peer is nil") + } + if err := r.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.reportReaction#3f64c076: field peer: %w", err) + } + b.PutInt(r.ID) + if r.ReactionPeer == nil { + return fmt.Errorf("unable to encode messages.reportReaction#3f64c076: field reaction_peer is nil") + } + if err := r.ReactionPeer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.reportReaction#3f64c076: field reaction_peer: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (r *MessagesReportReactionRequest) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.reportReaction#3f64c076 to nil") + } + if err := b.ConsumeID(MessagesReportReactionRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.reportReaction#3f64c076: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *MessagesReportReactionRequest) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.reportReaction#3f64c076 to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.reportReaction#3f64c076: field peer: %w", err) + } + r.Peer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.reportReaction#3f64c076: field id: %w", err) + } + r.ID = value + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.reportReaction#3f64c076: field reaction_peer: %w", err) + } + r.ReactionPeer = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (r *MessagesReportReactionRequest) GetPeer() (value InputPeerClass) { + if r == nil { + return + } + return r.Peer +} + +// GetID returns value of ID field. +func (r *MessagesReportReactionRequest) GetID() (value int) { + if r == nil { + return + } + return r.ID +} + +// GetReactionPeer returns value of ReactionPeer field. +func (r *MessagesReportReactionRequest) GetReactionPeer() (value InputPeerClass) { + if r == nil { + return + } + return r.ReactionPeer +} + +// MessagesReportReaction invokes method messages.reportReaction#3f64c076 returning error if any. +// +// See https://core.telegram.org/method/messages.reportReaction for reference. +func (c *Client) MessagesReportReaction(ctx context.Context, request *MessagesReportReactionRequest) (bool, error) { + var result BoolBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return false, err + } + _, ok := result.Bool.(*BoolTrue) + return ok, nil +} diff --git a/tg/tl_messages_report_reaction_slices_gen.go b/tg/tl_messages_report_reaction_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_report_reaction_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_request_simple_web_view_gen.go b/tg/tl_messages_request_simple_web_view_gen.go index 655848a7dd..6fb8a66a1d 100644 --- a/tg/tl_messages_request_simple_web_view_gen.go +++ b/tg/tl_messages_request_simple_web_view_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesRequestSimpleWebViewRequest represents TL type `messages.requestSimpleWebView#6abb2f73`. +// MessagesRequestSimpleWebViewRequest represents TL type `messages.requestSimpleWebView#299bec8e`. // Open a bot web app¹. // // Links: @@ -52,10 +52,12 @@ type MessagesRequestSimpleWebViewRequest struct { // // Use SetThemeParams and GetThemeParams helpers. ThemeParams DataJSON + // Platform field of MessagesRequestSimpleWebViewRequest. + Platform string } // MessagesRequestSimpleWebViewRequestTypeID is TL type id of MessagesRequestSimpleWebViewRequest. -const MessagesRequestSimpleWebViewRequestTypeID = 0x6abb2f73 +const MessagesRequestSimpleWebViewRequestTypeID = 0x299bec8e // Ensuring interfaces in compile-time for MessagesRequestSimpleWebViewRequest. var ( @@ -81,6 +83,9 @@ func (r *MessagesRequestSimpleWebViewRequest) Zero() bool { if !(r.ThemeParams.Zero()) { return false } + if !(r.Platform == "") { + return false + } return true } @@ -99,6 +104,7 @@ func (r *MessagesRequestSimpleWebViewRequest) FillFrom(from interface { GetBot() (value InputUserClass) GetURL() (value string) GetThemeParams() (value DataJSON, ok bool) + GetPlatform() (value string) }) { r.Bot = from.GetBot() r.URL = from.GetURL() @@ -106,6 +112,7 @@ func (r *MessagesRequestSimpleWebViewRequest) FillFrom(from interface { r.ThemeParams = val } + r.Platform = from.GetPlatform() } // TypeID returns type id in TL schema. @@ -144,6 +151,10 @@ func (r *MessagesRequestSimpleWebViewRequest) TypeInfo() tdp.Type { SchemaName: "theme_params", Null: !r.Flags.Has(0), }, + { + Name: "Platform", + SchemaName: "platform", + }, } return typ } @@ -158,7 +169,7 @@ func (r *MessagesRequestSimpleWebViewRequest) SetFlags() { // Encode implements bin.Encoder. func (r *MessagesRequestSimpleWebViewRequest) Encode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.requestSimpleWebView#6abb2f73 as nil") + return fmt.Errorf("can't encode messages.requestSimpleWebView#299bec8e as nil") } b.PutID(MessagesRequestSimpleWebViewRequestTypeID) return r.EncodeBare(b) @@ -167,34 +178,35 @@ func (r *MessagesRequestSimpleWebViewRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (r *MessagesRequestSimpleWebViewRequest) EncodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.requestSimpleWebView#6abb2f73 as nil") + return fmt.Errorf("can't encode messages.requestSimpleWebView#299bec8e as nil") } r.SetFlags() if err := r.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestSimpleWebView#6abb2f73: field flags: %w", err) + return fmt.Errorf("unable to encode messages.requestSimpleWebView#299bec8e: field flags: %w", err) } if r.Bot == nil { - return fmt.Errorf("unable to encode messages.requestSimpleWebView#6abb2f73: field bot is nil") + return fmt.Errorf("unable to encode messages.requestSimpleWebView#299bec8e: field bot is nil") } if err := r.Bot.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestSimpleWebView#6abb2f73: field bot: %w", err) + return fmt.Errorf("unable to encode messages.requestSimpleWebView#299bec8e: field bot: %w", err) } b.PutString(r.URL) if r.Flags.Has(0) { if err := r.ThemeParams.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestSimpleWebView#6abb2f73: field theme_params: %w", err) + return fmt.Errorf("unable to encode messages.requestSimpleWebView#299bec8e: field theme_params: %w", err) } } + b.PutString(r.Platform) return nil } // Decode implements bin.Decoder. func (r *MessagesRequestSimpleWebViewRequest) Decode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.requestSimpleWebView#6abb2f73 to nil") + return fmt.Errorf("can't decode messages.requestSimpleWebView#299bec8e to nil") } if err := b.ConsumeID(MessagesRequestSimpleWebViewRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.requestSimpleWebView#6abb2f73: %w", err) + return fmt.Errorf("unable to decode messages.requestSimpleWebView#299bec8e: %w", err) } return r.DecodeBare(b) } @@ -202,31 +214,38 @@ func (r *MessagesRequestSimpleWebViewRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (r *MessagesRequestSimpleWebViewRequest) DecodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.requestSimpleWebView#6abb2f73 to nil") + return fmt.Errorf("can't decode messages.requestSimpleWebView#299bec8e to nil") } { if err := r.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.requestSimpleWebView#6abb2f73: field flags: %w", err) + return fmt.Errorf("unable to decode messages.requestSimpleWebView#299bec8e: field flags: %w", err) } } { value, err := DecodeInputUser(b) if err != nil { - return fmt.Errorf("unable to decode messages.requestSimpleWebView#6abb2f73: field bot: %w", err) + return fmt.Errorf("unable to decode messages.requestSimpleWebView#299bec8e: field bot: %w", err) } r.Bot = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.requestSimpleWebView#6abb2f73: field url: %w", err) + return fmt.Errorf("unable to decode messages.requestSimpleWebView#299bec8e: field url: %w", err) } r.URL = value } if r.Flags.Has(0) { if err := r.ThemeParams.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.requestSimpleWebView#6abb2f73: field theme_params: %w", err) + return fmt.Errorf("unable to decode messages.requestSimpleWebView#299bec8e: field theme_params: %w", err) + } + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messages.requestSimpleWebView#299bec8e: field platform: %w", err) } + r.Platform = value } return nil } @@ -265,7 +284,15 @@ func (r *MessagesRequestSimpleWebViewRequest) GetThemeParams() (value DataJSON, return r.ThemeParams, true } -// MessagesRequestSimpleWebView invokes method messages.requestSimpleWebView#6abb2f73 returning error if any. +// GetPlatform returns value of Platform field. +func (r *MessagesRequestSimpleWebViewRequest) GetPlatform() (value string) { + if r == nil { + return + } + return r.Platform +} + +// MessagesRequestSimpleWebView invokes method messages.requestSimpleWebView#299bec8e returning error if any. // Open a bot web app¹. // // Links: diff --git a/tg/tl_messages_request_web_view_gen.go b/tg/tl_messages_request_web_view_gen.go index 2709d233f7..db129bf2e9 100644 --- a/tg/tl_messages_request_web_view_gen.go +++ b/tg/tl_messages_request_web_view_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesRequestWebViewRequest represents TL type `messages.requestWebView#91b15831`. +// MessagesRequestWebViewRequest represents TL type `messages.requestWebView#fc87a53c`. // Open a bot web app¹, sending over user information after user confirmation. // After calling this method, until the user closes the webview, messages // prolongWebView¹ must be called every 60 seconds. @@ -89,6 +89,8 @@ type MessagesRequestWebViewRequest struct { // // Use SetThemeParams and GetThemeParams helpers. ThemeParams DataJSON + // Platform field of MessagesRequestWebViewRequest. + Platform string // Whether the inline message that will be sent by the bot on behalf of the user once the // web app interaction is terminated¹ should be sent in reply to this message ID. // @@ -105,7 +107,7 @@ type MessagesRequestWebViewRequest struct { } // MessagesRequestWebViewRequestTypeID is TL type id of MessagesRequestWebViewRequest. -const MessagesRequestWebViewRequestTypeID = 0x91b15831 +const MessagesRequestWebViewRequestTypeID = 0xfc87a53c // Ensuring interfaces in compile-time for MessagesRequestWebViewRequest. var ( @@ -143,6 +145,9 @@ func (r *MessagesRequestWebViewRequest) Zero() bool { if !(r.ThemeParams.Zero()) { return false } + if !(r.Platform == "") { + return false + } if !(r.ReplyToMsgID == 0) { return false } @@ -171,6 +176,7 @@ func (r *MessagesRequestWebViewRequest) FillFrom(from interface { GetURL() (value string, ok bool) GetStartParam() (value string, ok bool) GetThemeParams() (value DataJSON, ok bool) + GetPlatform() (value string) GetReplyToMsgID() (value int, ok bool) GetSendAs() (value InputPeerClass, ok bool) }) { @@ -190,6 +196,7 @@ func (r *MessagesRequestWebViewRequest) FillFrom(from interface { r.ThemeParams = val } + r.Platform = from.GetPlatform() if val, ok := from.GetReplyToMsgID(); ok { r.ReplyToMsgID = val } @@ -256,6 +263,10 @@ func (r *MessagesRequestWebViewRequest) TypeInfo() tdp.Type { SchemaName: "theme_params", Null: !r.Flags.Has(2), }, + { + Name: "Platform", + SchemaName: "platform", + }, { Name: "ReplyToMsgID", SchemaName: "reply_to_msg_id", @@ -298,7 +309,7 @@ func (r *MessagesRequestWebViewRequest) SetFlags() { // Encode implements bin.Encoder. func (r *MessagesRequestWebViewRequest) Encode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.requestWebView#91b15831 as nil") + return fmt.Errorf("can't encode messages.requestWebView#fc87a53c as nil") } b.PutID(MessagesRequestWebViewRequestTypeID) return r.EncodeBare(b) @@ -307,23 +318,23 @@ func (r *MessagesRequestWebViewRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (r *MessagesRequestWebViewRequest) EncodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.requestWebView#91b15831 as nil") + return fmt.Errorf("can't encode messages.requestWebView#fc87a53c as nil") } r.SetFlags() if err := r.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestWebView#91b15831: field flags: %w", err) + return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field flags: %w", err) } if r.Peer == nil { - return fmt.Errorf("unable to encode messages.requestWebView#91b15831: field peer is nil") + return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field peer is nil") } if err := r.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestWebView#91b15831: field peer: %w", err) + return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field peer: %w", err) } if r.Bot == nil { - return fmt.Errorf("unable to encode messages.requestWebView#91b15831: field bot is nil") + return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field bot is nil") } if err := r.Bot.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestWebView#91b15831: field bot: %w", err) + return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field bot: %w", err) } if r.Flags.Has(1) { b.PutString(r.URL) @@ -333,18 +344,19 @@ func (r *MessagesRequestWebViewRequest) EncodeBare(b *bin.Buffer) error { } if r.Flags.Has(2) { if err := r.ThemeParams.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestWebView#91b15831: field theme_params: %w", err) + return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field theme_params: %w", err) } } + b.PutString(r.Platform) if r.Flags.Has(0) { b.PutInt(r.ReplyToMsgID) } if r.Flags.Has(13) { if r.SendAs == nil { - return fmt.Errorf("unable to encode messages.requestWebView#91b15831: field send_as is nil") + return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field send_as is nil") } if err := r.SendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestWebView#91b15831: field send_as: %w", err) + return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field send_as: %w", err) } } return nil @@ -353,10 +365,10 @@ func (r *MessagesRequestWebViewRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (r *MessagesRequestWebViewRequest) Decode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.requestWebView#91b15831 to nil") + return fmt.Errorf("can't decode messages.requestWebView#fc87a53c to nil") } if err := b.ConsumeID(MessagesRequestWebViewRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#91b15831: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: %w", err) } return r.DecodeBare(b) } @@ -364,11 +376,11 @@ func (r *MessagesRequestWebViewRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (r *MessagesRequestWebViewRequest) DecodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.requestWebView#91b15831 to nil") + return fmt.Errorf("can't decode messages.requestWebView#fc87a53c to nil") } { if err := r.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#91b15831: field flags: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field flags: %w", err) } } r.FromBotMenu = r.Flags.Has(4) @@ -376,47 +388,54 @@ func (r *MessagesRequestWebViewRequest) DecodeBare(b *bin.Buffer) error { { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#91b15831: field peer: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field peer: %w", err) } r.Peer = value } { value, err := DecodeInputUser(b) if err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#91b15831: field bot: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field bot: %w", err) } r.Bot = value } if r.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#91b15831: field url: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field url: %w", err) } r.URL = value } if r.Flags.Has(3) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#91b15831: field start_param: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field start_param: %w", err) } r.StartParam = value } if r.Flags.Has(2) { if err := r.ThemeParams.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#91b15831: field theme_params: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field theme_params: %w", err) + } + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field platform: %w", err) } + r.Platform = value } if r.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#91b15831: field reply_to_msg_id: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field reply_to_msg_id: %w", err) } r.ReplyToMsgID = value } if r.Flags.Has(13) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#91b15831: field send_as: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field send_as: %w", err) } r.SendAs = value } @@ -531,6 +550,14 @@ func (r *MessagesRequestWebViewRequest) GetThemeParams() (value DataJSON, ok boo return r.ThemeParams, true } +// GetPlatform returns value of Platform field. +func (r *MessagesRequestWebViewRequest) GetPlatform() (value string) { + if r == nil { + return + } + return r.Platform +} + // SetReplyToMsgID sets value of ReplyToMsgID conditional field. func (r *MessagesRequestWebViewRequest) SetReplyToMsgID(value int) { r.Flags.Set(0) @@ -567,7 +594,7 @@ func (r *MessagesRequestWebViewRequest) GetSendAs() (value InputPeerClass, ok bo return r.SendAs, true } -// MessagesRequestWebView invokes method messages.requestWebView#91b15831 returning error if any. +// MessagesRequestWebView invokes method messages.requestWebView#fc87a53c returning error if any. // Open a bot web app¹, sending over user information after user confirmation. // After calling this method, until the user closes the webview, messages // prolongWebView¹ must be called every 60 seconds. diff --git a/tg/tl_messages_send_media_gen.go b/tg/tl_messages_send_media_gen.go index a2ef1989f6..9951853b92 100644 --- a/tg/tl_messages_send_media_gen.go +++ b/tg/tl_messages_send_media_gen.go @@ -53,6 +53,8 @@ type MessagesSendMediaRequest struct { // Links: // 1) https://telegram.org/blog/protected-content-delete-by-date-and-more Noforwards bool + // UpdateStickersetsOrder field of MessagesSendMediaRequest. + UpdateStickersetsOrder bool // Destination Peer InputPeerClass // Message ID to which this message should reply to @@ -119,6 +121,9 @@ func (s *MessagesSendMediaRequest) Zero() bool { if !(s.Noforwards == false) { return false } + if !(s.UpdateStickersetsOrder == false) { + return false + } if !(s.Peer == nil) { return false } @@ -165,6 +170,7 @@ func (s *MessagesSendMediaRequest) FillFrom(from interface { GetBackground() (value bool) GetClearDraft() (value bool) GetNoforwards() (value bool) + GetUpdateStickersetsOrder() (value bool) GetPeer() (value InputPeerClass) GetReplyToMsgID() (value int, ok bool) GetMedia() (value InputMediaClass) @@ -179,6 +185,7 @@ func (s *MessagesSendMediaRequest) FillFrom(from interface { s.Background = from.GetBackground() s.ClearDraft = from.GetClearDraft() s.Noforwards = from.GetNoforwards() + s.UpdateStickersetsOrder = from.GetUpdateStickersetsOrder() s.Peer = from.GetPeer() if val, ok := from.GetReplyToMsgID(); ok { s.ReplyToMsgID = val @@ -248,6 +255,11 @@ func (s *MessagesSendMediaRequest) TypeInfo() tdp.Type { SchemaName: "noforwards", Null: !s.Flags.Has(14), }, + { + Name: "UpdateStickersetsOrder", + SchemaName: "update_stickersets_order", + Null: !s.Flags.Has(15), + }, { Name: "Peer", SchemaName: "peer", @@ -307,6 +319,9 @@ func (s *MessagesSendMediaRequest) SetFlags() { if !(s.Noforwards == false) { s.Flags.Set(14) } + if !(s.UpdateStickersetsOrder == false) { + s.Flags.Set(15) + } if !(s.ReplyToMsgID == 0) { s.Flags.Set(0) } @@ -417,6 +432,7 @@ func (s *MessagesSendMediaRequest) DecodeBare(b *bin.Buffer) error { s.Background = s.Flags.Has(6) s.ClearDraft = s.Flags.Has(7) s.Noforwards = s.Flags.Has(14) + s.UpdateStickersetsOrder = s.Flags.Has(15) { value, err := DecodeInputPeer(b) if err != nil { @@ -569,6 +585,25 @@ func (s *MessagesSendMediaRequest) GetNoforwards() (value bool) { return s.Flags.Has(14) } +// SetUpdateStickersetsOrder sets value of UpdateStickersetsOrder conditional field. +func (s *MessagesSendMediaRequest) SetUpdateStickersetsOrder(value bool) { + if value { + s.Flags.Set(15) + s.UpdateStickersetsOrder = true + } else { + s.Flags.Unset(15) + s.UpdateStickersetsOrder = false + } +} + +// GetUpdateStickersetsOrder returns value of UpdateStickersetsOrder conditional field. +func (s *MessagesSendMediaRequest) GetUpdateStickersetsOrder() (value bool) { + if s == nil { + return + } + return s.Flags.Has(15) +} + // GetPeer returns value of Peer field. func (s *MessagesSendMediaRequest) GetPeer() (value InputPeerClass) { if s == nil { diff --git a/tg/tl_messages_send_message_gen.go b/tg/tl_messages_send_message_gen.go index da684ed264..aa9401c37d 100644 --- a/tg/tl_messages_send_message_gen.go +++ b/tg/tl_messages_send_message_gen.go @@ -55,6 +55,8 @@ type MessagesSendMessageRequest struct { // Links: // 1) https://telegram.org/blog/protected-content-delete-by-date-and-more Noforwards bool + // UpdateStickersetsOrder field of MessagesSendMessageRequest. + UpdateStickersetsOrder bool // The destination where the message will be sent Peer InputPeerClass // The message ID to which this message will reply to @@ -122,6 +124,9 @@ func (s *MessagesSendMessageRequest) Zero() bool { if !(s.Noforwards == false) { return false } + if !(s.UpdateStickersetsOrder == false) { + return false + } if !(s.Peer == nil) { return false } @@ -166,6 +171,7 @@ func (s *MessagesSendMessageRequest) FillFrom(from interface { GetBackground() (value bool) GetClearDraft() (value bool) GetNoforwards() (value bool) + GetUpdateStickersetsOrder() (value bool) GetPeer() (value InputPeerClass) GetReplyToMsgID() (value int, ok bool) GetMessage() (value string) @@ -180,6 +186,7 @@ func (s *MessagesSendMessageRequest) FillFrom(from interface { s.Background = from.GetBackground() s.ClearDraft = from.GetClearDraft() s.Noforwards = from.GetNoforwards() + s.UpdateStickersetsOrder = from.GetUpdateStickersetsOrder() s.Peer = from.GetPeer() if val, ok := from.GetReplyToMsgID(); ok { s.ReplyToMsgID = val @@ -253,6 +260,11 @@ func (s *MessagesSendMessageRequest) TypeInfo() tdp.Type { SchemaName: "noforwards", Null: !s.Flags.Has(14), }, + { + Name: "UpdateStickersetsOrder", + SchemaName: "update_stickersets_order", + Null: !s.Flags.Has(15), + }, { Name: "Peer", SchemaName: "peer", @@ -311,6 +323,9 @@ func (s *MessagesSendMessageRequest) SetFlags() { if !(s.Noforwards == false) { s.Flags.Set(14) } + if !(s.UpdateStickersetsOrder == false) { + s.Flags.Set(15) + } if !(s.ReplyToMsgID == 0) { s.Flags.Set(0) } @@ -416,6 +431,7 @@ func (s *MessagesSendMessageRequest) DecodeBare(b *bin.Buffer) error { s.Background = s.Flags.Has(6) s.ClearDraft = s.Flags.Has(7) s.Noforwards = s.Flags.Has(14) + s.UpdateStickersetsOrder = s.Flags.Has(15) { value, err := DecodeInputPeer(b) if err != nil { @@ -580,6 +596,25 @@ func (s *MessagesSendMessageRequest) GetNoforwards() (value bool) { return s.Flags.Has(14) } +// SetUpdateStickersetsOrder sets value of UpdateStickersetsOrder conditional field. +func (s *MessagesSendMessageRequest) SetUpdateStickersetsOrder(value bool) { + if value { + s.Flags.Set(15) + s.UpdateStickersetsOrder = true + } else { + s.Flags.Unset(15) + s.UpdateStickersetsOrder = false + } +} + +// GetUpdateStickersetsOrder returns value of UpdateStickersetsOrder conditional field. +func (s *MessagesSendMessageRequest) GetUpdateStickersetsOrder() (value bool) { + if s == nil { + return + } + return s.Flags.Has(15) +} + // GetPeer returns value of Peer field. func (s *MessagesSendMessageRequest) GetPeer() (value InputPeerClass) { if s == nil { diff --git a/tg/tl_messages_send_multi_media_gen.go b/tg/tl_messages_send_multi_media_gen.go index 3afa7e45e8..ae3adf238d 100644 --- a/tg/tl_messages_send_multi_media_gen.go +++ b/tg/tl_messages_send_multi_media_gen.go @@ -59,6 +59,8 @@ type MessagesSendMultiMediaRequest struct { // Links: // 1) https://telegram.org/blog/protected-content-delete-by-date-and-more Noforwards bool + // UpdateStickersetsOrder field of MessagesSendMultiMediaRequest. + UpdateStickersetsOrder bool // The destination chat Peer InputPeerClass // The message to reply to @@ -107,6 +109,9 @@ func (s *MessagesSendMultiMediaRequest) Zero() bool { if !(s.Noforwards == false) { return false } + if !(s.UpdateStickersetsOrder == false) { + return false + } if !(s.Peer == nil) { return false } @@ -141,6 +146,7 @@ func (s *MessagesSendMultiMediaRequest) FillFrom(from interface { GetBackground() (value bool) GetClearDraft() (value bool) GetNoforwards() (value bool) + GetUpdateStickersetsOrder() (value bool) GetPeer() (value InputPeerClass) GetReplyToMsgID() (value int, ok bool) GetMultiMedia() (value []InputSingleMedia) @@ -151,6 +157,7 @@ func (s *MessagesSendMultiMediaRequest) FillFrom(from interface { s.Background = from.GetBackground() s.ClearDraft = from.GetClearDraft() s.Noforwards = from.GetNoforwards() + s.UpdateStickersetsOrder = from.GetUpdateStickersetsOrder() s.Peer = from.GetPeer() if val, ok := from.GetReplyToMsgID(); ok { s.ReplyToMsgID = val @@ -210,6 +217,11 @@ func (s *MessagesSendMultiMediaRequest) TypeInfo() tdp.Type { SchemaName: "noforwards", Null: !s.Flags.Has(14), }, + { + Name: "UpdateStickersetsOrder", + SchemaName: "update_stickersets_order", + Null: !s.Flags.Has(15), + }, { Name: "Peer", SchemaName: "peer", @@ -251,6 +263,9 @@ func (s *MessagesSendMultiMediaRequest) SetFlags() { if !(s.Noforwards == false) { s.Flags.Set(14) } + if !(s.UpdateStickersetsOrder == false) { + s.Flags.Set(15) + } if !(s.ReplyToMsgID == 0) { s.Flags.Set(0) } @@ -334,6 +349,7 @@ func (s *MessagesSendMultiMediaRequest) DecodeBare(b *bin.Buffer) error { s.Background = s.Flags.Has(6) s.ClearDraft = s.Flags.Has(7) s.Noforwards = s.Flags.Has(14) + s.UpdateStickersetsOrder = s.Flags.Has(15) { value, err := DecodeInputPeer(b) if err != nil { @@ -458,6 +474,25 @@ func (s *MessagesSendMultiMediaRequest) GetNoforwards() (value bool) { return s.Flags.Has(14) } +// SetUpdateStickersetsOrder sets value of UpdateStickersetsOrder conditional field. +func (s *MessagesSendMultiMediaRequest) SetUpdateStickersetsOrder(value bool) { + if value { + s.Flags.Set(15) + s.UpdateStickersetsOrder = true + } else { + s.Flags.Unset(15) + s.UpdateStickersetsOrder = false + } +} + +// GetUpdateStickersetsOrder returns value of UpdateStickersetsOrder conditional field. +func (s *MessagesSendMultiMediaRequest) GetUpdateStickersetsOrder() (value bool) { + if s == nil { + return + } + return s.Flags.Has(15) +} + // GetPeer returns value of Peer field. func (s *MessagesSendMultiMediaRequest) GetPeer() (value InputPeerClass) { if s == nil { diff --git a/tg/tl_messages_send_reaction_gen.go b/tg/tl_messages_send_reaction_gen.go index 566ac6a777..3fae4b5801 100644 --- a/tg/tl_messages_send_reaction_gen.go +++ b/tg/tl_messages_send_reaction_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSendReactionRequest represents TL type `messages.sendReaction#25690ce4`. +// MessagesSendReactionRequest represents TL type `messages.sendReaction#d30d78d4`. // React to message // // See https://core.telegram.org/method/messages.sendReaction for reference. @@ -43,6 +43,8 @@ type MessagesSendReactionRequest struct { Flags bin.Fields // Whether a bigger and longer reaction should be shown Big bool + // AddToRecent field of MessagesSendReactionRequest. + AddToRecent bool // Peer Peer InputPeerClass // Message ID to react to @@ -50,11 +52,11 @@ type MessagesSendReactionRequest struct { // Reaction (a UTF8 emoji) // // Use SetReaction and GetReaction helpers. - Reaction string + Reaction []ReactionClass } // MessagesSendReactionRequestTypeID is TL type id of MessagesSendReactionRequest. -const MessagesSendReactionRequestTypeID = 0x25690ce4 +const MessagesSendReactionRequestTypeID = 0xd30d78d4 // Ensuring interfaces in compile-time for MessagesSendReactionRequest. var ( @@ -74,13 +76,16 @@ func (s *MessagesSendReactionRequest) Zero() bool { if !(s.Big == false) { return false } + if !(s.AddToRecent == false) { + return false + } if !(s.Peer == nil) { return false } if !(s.MsgID == 0) { return false } - if !(s.Reaction == "") { + if !(s.Reaction == nil) { return false } @@ -99,11 +104,13 @@ func (s *MessagesSendReactionRequest) String() string { // FillFrom fills MessagesSendReactionRequest from given interface. func (s *MessagesSendReactionRequest) FillFrom(from interface { GetBig() (value bool) + GetAddToRecent() (value bool) GetPeer() (value InputPeerClass) GetMsgID() (value int) - GetReaction() (value string, ok bool) + GetReaction() (value []ReactionClass, ok bool) }) { s.Big = from.GetBig() + s.AddToRecent = from.GetAddToRecent() s.Peer = from.GetPeer() s.MsgID = from.GetMsgID() if val, ok := from.GetReaction(); ok { @@ -140,6 +147,11 @@ func (s *MessagesSendReactionRequest) TypeInfo() tdp.Type { SchemaName: "big", Null: !s.Flags.Has(1), }, + { + Name: "AddToRecent", + SchemaName: "add_to_recent", + Null: !s.Flags.Has(2), + }, { Name: "Peer", SchemaName: "peer", @@ -162,7 +174,10 @@ func (s *MessagesSendReactionRequest) SetFlags() { if !(s.Big == false) { s.Flags.Set(1) } - if !(s.Reaction == "") { + if !(s.AddToRecent == false) { + s.Flags.Set(2) + } + if !(s.Reaction == nil) { s.Flags.Set(0) } } @@ -170,7 +185,7 @@ func (s *MessagesSendReactionRequest) SetFlags() { // Encode implements bin.Encoder. func (s *MessagesSendReactionRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendReaction#25690ce4 as nil") + return fmt.Errorf("can't encode messages.sendReaction#d30d78d4 as nil") } b.PutID(MessagesSendReactionRequestTypeID) return s.EncodeBare(b) @@ -179,21 +194,29 @@ func (s *MessagesSendReactionRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSendReactionRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendReaction#25690ce4 as nil") + return fmt.Errorf("can't encode messages.sendReaction#d30d78d4 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendReaction#25690ce4: field flags: %w", err) + return fmt.Errorf("unable to encode messages.sendReaction#d30d78d4: field flags: %w", err) } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.sendReaction#25690ce4: field peer is nil") + return fmt.Errorf("unable to encode messages.sendReaction#d30d78d4: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendReaction#25690ce4: field peer: %w", err) + return fmt.Errorf("unable to encode messages.sendReaction#d30d78d4: field peer: %w", err) } b.PutInt(s.MsgID) if s.Flags.Has(0) { - b.PutString(s.Reaction) + b.PutVectorHeader(len(s.Reaction)) + for idx, v := range s.Reaction { + if v == nil { + return fmt.Errorf("unable to encode messages.sendReaction#d30d78d4: field reaction element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.sendReaction#d30d78d4: field reaction element with index %d: %w", idx, err) + } + } } return nil } @@ -201,10 +224,10 @@ func (s *MessagesSendReactionRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *MessagesSendReactionRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendReaction#25690ce4 to nil") + return fmt.Errorf("can't decode messages.sendReaction#d30d78d4 to nil") } if err := b.ConsumeID(MessagesSendReactionRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.sendReaction#25690ce4: %w", err) + return fmt.Errorf("unable to decode messages.sendReaction#d30d78d4: %w", err) } return s.DecodeBare(b) } @@ -212,34 +235,45 @@ func (s *MessagesSendReactionRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSendReactionRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendReaction#25690ce4 to nil") + return fmt.Errorf("can't decode messages.sendReaction#d30d78d4 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.sendReaction#25690ce4: field flags: %w", err) + return fmt.Errorf("unable to decode messages.sendReaction#d30d78d4: field flags: %w", err) } } s.Big = s.Flags.Has(1) + s.AddToRecent = s.Flags.Has(2) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendReaction#25690ce4: field peer: %w", err) + return fmt.Errorf("unable to decode messages.sendReaction#d30d78d4: field peer: %w", err) } s.Peer = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendReaction#25690ce4: field msg_id: %w", err) + return fmt.Errorf("unable to decode messages.sendReaction#d30d78d4: field msg_id: %w", err) } s.MsgID = value } if s.Flags.Has(0) { - value, err := b.String() + headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.sendReaction#25690ce4: field reaction: %w", err) + return fmt.Errorf("unable to decode messages.sendReaction#d30d78d4: field reaction: %w", err) + } + + if headerLen > 0 { + s.Reaction = make([]ReactionClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeReaction(b) + if err != nil { + return fmt.Errorf("unable to decode messages.sendReaction#d30d78d4: field reaction: %w", err) + } + s.Reaction = append(s.Reaction, value) } - s.Reaction = value } return nil } @@ -263,6 +297,25 @@ func (s *MessagesSendReactionRequest) GetBig() (value bool) { return s.Flags.Has(1) } +// SetAddToRecent sets value of AddToRecent conditional field. +func (s *MessagesSendReactionRequest) SetAddToRecent(value bool) { + if value { + s.Flags.Set(2) + s.AddToRecent = true + } else { + s.Flags.Unset(2) + s.AddToRecent = false + } +} + +// GetAddToRecent returns value of AddToRecent conditional field. +func (s *MessagesSendReactionRequest) GetAddToRecent() (value bool) { + if s == nil { + return + } + return s.Flags.Has(2) +} + // GetPeer returns value of Peer field. func (s *MessagesSendReactionRequest) GetPeer() (value InputPeerClass) { if s == nil { @@ -280,14 +333,14 @@ func (s *MessagesSendReactionRequest) GetMsgID() (value int) { } // SetReaction sets value of Reaction conditional field. -func (s *MessagesSendReactionRequest) SetReaction(value string) { +func (s *MessagesSendReactionRequest) SetReaction(value []ReactionClass) { s.Flags.Set(0) s.Reaction = value } // GetReaction returns value of Reaction conditional field and // boolean which is true if field was set. -func (s *MessagesSendReactionRequest) GetReaction() (value string, ok bool) { +func (s *MessagesSendReactionRequest) GetReaction() (value []ReactionClass, ok bool) { if s == nil { return } @@ -297,7 +350,15 @@ func (s *MessagesSendReactionRequest) GetReaction() (value string, ok bool) { return s.Reaction, true } -// MessagesSendReaction invokes method messages.sendReaction#25690ce4 returning error if any. +// MapReaction returns field Reaction wrapped in ReactionClassArray helper. +func (s *MessagesSendReactionRequest) MapReaction() (value ReactionClassArray, ok bool) { + if !s.Flags.Has(0) { + return value, false + } + return ReactionClassArray(s.Reaction), true +} + +// MessagesSendReaction invokes method messages.sendReaction#d30d78d4 returning error if any. // React to message // // Possible errors: diff --git a/tg/tl_messages_set_chat_available_reactions_gen.go b/tg/tl_messages_set_chat_available_reactions_gen.go index 5dbae1fb37..c21168b1f7 100644 --- a/tg/tl_messages_set_chat_available_reactions_gen.go +++ b/tg/tl_messages_set_chat_available_reactions_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSetChatAvailableReactionsRequest represents TL type `messages.setChatAvailableReactions#14050ea6`. +// MessagesSetChatAvailableReactionsRequest represents TL type `messages.setChatAvailableReactions#feb16771`. // Change the set of message reactions »¹ that can be used in a certain group, // supergroup or channel // @@ -43,11 +43,11 @@ type MessagesSetChatAvailableReactionsRequest struct { // Group where to apply changes Peer InputPeerClass // Allowed reaction emojis - AvailableReactions []string + AvailableReactions ChatReactionsClass } // MessagesSetChatAvailableReactionsRequestTypeID is TL type id of MessagesSetChatAvailableReactionsRequest. -const MessagesSetChatAvailableReactionsRequestTypeID = 0x14050ea6 +const MessagesSetChatAvailableReactionsRequestTypeID = 0xfeb16771 // Ensuring interfaces in compile-time for MessagesSetChatAvailableReactionsRequest. var ( @@ -83,7 +83,7 @@ func (s *MessagesSetChatAvailableReactionsRequest) String() string { // FillFrom fills MessagesSetChatAvailableReactionsRequest from given interface. func (s *MessagesSetChatAvailableReactionsRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) - GetAvailableReactions() (value []string) + GetAvailableReactions() (value ChatReactionsClass) }) { s.Peer = from.GetPeer() s.AvailableReactions = from.GetAvailableReactions() @@ -127,7 +127,7 @@ func (s *MessagesSetChatAvailableReactionsRequest) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (s *MessagesSetChatAvailableReactionsRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.setChatAvailableReactions#14050ea6 as nil") + return fmt.Errorf("can't encode messages.setChatAvailableReactions#feb16771 as nil") } b.PutID(MessagesSetChatAvailableReactionsRequestTypeID) return s.EncodeBare(b) @@ -136,17 +136,19 @@ func (s *MessagesSetChatAvailableReactionsRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSetChatAvailableReactionsRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.setChatAvailableReactions#14050ea6 as nil") + return fmt.Errorf("can't encode messages.setChatAvailableReactions#feb16771 as nil") } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.setChatAvailableReactions#14050ea6: field peer is nil") + return fmt.Errorf("unable to encode messages.setChatAvailableReactions#feb16771: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.setChatAvailableReactions#14050ea6: field peer: %w", err) + return fmt.Errorf("unable to encode messages.setChatAvailableReactions#feb16771: field peer: %w", err) } - b.PutVectorHeader(len(s.AvailableReactions)) - for _, v := range s.AvailableReactions { - b.PutString(v) + if s.AvailableReactions == nil { + return fmt.Errorf("unable to encode messages.setChatAvailableReactions#feb16771: field available_reactions is nil") + } + if err := s.AvailableReactions.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.setChatAvailableReactions#feb16771: field available_reactions: %w", err) } return nil } @@ -154,10 +156,10 @@ func (s *MessagesSetChatAvailableReactionsRequest) EncodeBare(b *bin.Buffer) err // Decode implements bin.Decoder. func (s *MessagesSetChatAvailableReactionsRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.setChatAvailableReactions#14050ea6 to nil") + return fmt.Errorf("can't decode messages.setChatAvailableReactions#feb16771 to nil") } if err := b.ConsumeID(MessagesSetChatAvailableReactionsRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.setChatAvailableReactions#14050ea6: %w", err) + return fmt.Errorf("unable to decode messages.setChatAvailableReactions#feb16771: %w", err) } return s.DecodeBare(b) } @@ -165,31 +167,21 @@ func (s *MessagesSetChatAvailableReactionsRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSetChatAvailableReactionsRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.setChatAvailableReactions#14050ea6 to nil") + return fmt.Errorf("can't decode messages.setChatAvailableReactions#feb16771 to nil") } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.setChatAvailableReactions#14050ea6: field peer: %w", err) + return fmt.Errorf("unable to decode messages.setChatAvailableReactions#feb16771: field peer: %w", err) } s.Peer = value } { - headerLen, err := b.VectorHeader() + value, err := DecodeChatReactions(b) if err != nil { - return fmt.Errorf("unable to decode messages.setChatAvailableReactions#14050ea6: field available_reactions: %w", err) - } - - if headerLen > 0 { - s.AvailableReactions = make([]string, 0, headerLen%bin.PreallocateLimit) - } - for idx := 0; idx < headerLen; idx++ { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode messages.setChatAvailableReactions#14050ea6: field available_reactions: %w", err) - } - s.AvailableReactions = append(s.AvailableReactions, value) + return fmt.Errorf("unable to decode messages.setChatAvailableReactions#feb16771: field available_reactions: %w", err) } + s.AvailableReactions = value } return nil } @@ -203,14 +195,14 @@ func (s *MessagesSetChatAvailableReactionsRequest) GetPeer() (value InputPeerCla } // GetAvailableReactions returns value of AvailableReactions field. -func (s *MessagesSetChatAvailableReactionsRequest) GetAvailableReactions() (value []string) { +func (s *MessagesSetChatAvailableReactionsRequest) GetAvailableReactions() (value ChatReactionsClass) { if s == nil { return } return s.AvailableReactions } -// MessagesSetChatAvailableReactions invokes method messages.setChatAvailableReactions#14050ea6 returning error if any. +// MessagesSetChatAvailableReactions invokes method messages.setChatAvailableReactions#feb16771 returning error if any. // Change the set of message reactions »¹ that can be used in a certain group, // supergroup or channel // diff --git a/tg/tl_messages_set_default_reaction_gen.go b/tg/tl_messages_set_default_reaction_gen.go index 09ea3fbbd6..c5d0ed9f17 100644 --- a/tg/tl_messages_set_default_reaction_gen.go +++ b/tg/tl_messages_set_default_reaction_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSetDefaultReactionRequest represents TL type `messages.setDefaultReaction#d960c4d4`. +// MessagesSetDefaultReactionRequest represents TL type `messages.setDefaultReaction#4f47a016`. // Change default emoji reaction to use in the quick reaction menu: the value is synced // across devices and can be fetched using help.getAppConfig, reactions_default field¹. // @@ -41,11 +41,11 @@ var ( // See https://core.telegram.org/method/messages.setDefaultReaction for reference. type MessagesSetDefaultReactionRequest struct { // New emoji reaction - Reaction string + Reaction ReactionClass } // MessagesSetDefaultReactionRequestTypeID is TL type id of MessagesSetDefaultReactionRequest. -const MessagesSetDefaultReactionRequestTypeID = 0xd960c4d4 +const MessagesSetDefaultReactionRequestTypeID = 0x4f47a016 // Ensuring interfaces in compile-time for MessagesSetDefaultReactionRequest. var ( @@ -59,7 +59,7 @@ func (s *MessagesSetDefaultReactionRequest) Zero() bool { if s == nil { return true } - if !(s.Reaction == "") { + if !(s.Reaction == nil) { return false } @@ -77,7 +77,7 @@ func (s *MessagesSetDefaultReactionRequest) String() string { // FillFrom fills MessagesSetDefaultReactionRequest from given interface. func (s *MessagesSetDefaultReactionRequest) FillFrom(from interface { - GetReaction() (value string) + GetReaction() (value ReactionClass) }) { s.Reaction = from.GetReaction() } @@ -116,7 +116,7 @@ func (s *MessagesSetDefaultReactionRequest) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (s *MessagesSetDefaultReactionRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.setDefaultReaction#d960c4d4 as nil") + return fmt.Errorf("can't encode messages.setDefaultReaction#4f47a016 as nil") } b.PutID(MessagesSetDefaultReactionRequestTypeID) return s.EncodeBare(b) @@ -125,19 +125,24 @@ func (s *MessagesSetDefaultReactionRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSetDefaultReactionRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.setDefaultReaction#d960c4d4 as nil") + return fmt.Errorf("can't encode messages.setDefaultReaction#4f47a016 as nil") + } + if s.Reaction == nil { + return fmt.Errorf("unable to encode messages.setDefaultReaction#4f47a016: field reaction is nil") + } + if err := s.Reaction.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.setDefaultReaction#4f47a016: field reaction: %w", err) } - b.PutString(s.Reaction) return nil } // Decode implements bin.Decoder. func (s *MessagesSetDefaultReactionRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.setDefaultReaction#d960c4d4 to nil") + return fmt.Errorf("can't decode messages.setDefaultReaction#4f47a016 to nil") } if err := b.ConsumeID(MessagesSetDefaultReactionRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.setDefaultReaction#d960c4d4: %w", err) + return fmt.Errorf("unable to decode messages.setDefaultReaction#4f47a016: %w", err) } return s.DecodeBare(b) } @@ -145,12 +150,12 @@ func (s *MessagesSetDefaultReactionRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSetDefaultReactionRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.setDefaultReaction#d960c4d4 to nil") + return fmt.Errorf("can't decode messages.setDefaultReaction#4f47a016 to nil") } { - value, err := b.String() + value, err := DecodeReaction(b) if err != nil { - return fmt.Errorf("unable to decode messages.setDefaultReaction#d960c4d4: field reaction: %w", err) + return fmt.Errorf("unable to decode messages.setDefaultReaction#4f47a016: field reaction: %w", err) } s.Reaction = value } @@ -158,14 +163,14 @@ func (s *MessagesSetDefaultReactionRequest) DecodeBare(b *bin.Buffer) error { } // GetReaction returns value of Reaction field. -func (s *MessagesSetDefaultReactionRequest) GetReaction() (value string) { +func (s *MessagesSetDefaultReactionRequest) GetReaction() (value ReactionClass) { if s == nil { return } return s.Reaction } -// MessagesSetDefaultReaction invokes method messages.setDefaultReaction#d960c4d4 returning error if any. +// MessagesSetDefaultReaction invokes method messages.setDefaultReaction#4f47a016 returning error if any. // Change default emoji reaction to use in the quick reaction menu: the value is synced // across devices and can be fetched using help.getAppConfig, reactions_default field¹. // @@ -173,7 +178,7 @@ func (s *MessagesSetDefaultReactionRequest) GetReaction() (value string) { // 1. https://core.telegram.org/api/config#client-configuration // // See https://core.telegram.org/method/messages.setDefaultReaction for reference. -func (c *Client) MessagesSetDefaultReaction(ctx context.Context, reaction string) (bool, error) { +func (c *Client) MessagesSetDefaultReaction(ctx context.Context, reaction ReactionClass) (bool, error) { var result BoolBox request := &MessagesSetDefaultReactionRequest{ diff --git a/tg/tl_payments_request_recurring_payment_gen.go b/tg/tl_payments_request_recurring_payment_gen.go deleted file mode 100644 index 6c8f569825..0000000000 --- a/tg/tl_payments_request_recurring_payment_gen.go +++ /dev/null @@ -1,237 +0,0 @@ -// Code generated by gotdgen, DO NOT EDIT. - -package tg - -import ( - "context" - "errors" - "fmt" - "sort" - "strings" - - "go.uber.org/multierr" - - "github.com/gotd/td/bin" - "github.com/gotd/td/tdjson" - "github.com/gotd/td/tdp" - "github.com/gotd/td/tgerr" -) - -// No-op definition for keeping imports. -var ( - _ = bin.Buffer{} - _ = context.Background() - _ = fmt.Stringer(nil) - _ = strings.Builder{} - _ = errors.Is - _ = multierr.AppendInto - _ = sort.Ints - _ = tdp.Format - _ = tgerr.Error{} - _ = tdjson.Encoder{} -) - -// PaymentsRequestRecurringPaymentRequest represents TL type `payments.requestRecurringPayment#146e958d`. -// -// See https://core.telegram.org/method/payments.requestRecurringPayment for reference. -type PaymentsRequestRecurringPaymentRequest struct { - // UserID field of PaymentsRequestRecurringPaymentRequest. - UserID InputUserClass - // RecurringInitCharge field of PaymentsRequestRecurringPaymentRequest. - RecurringInitCharge string - // InvoiceMedia field of PaymentsRequestRecurringPaymentRequest. - InvoiceMedia InputMediaClass -} - -// PaymentsRequestRecurringPaymentRequestTypeID is TL type id of PaymentsRequestRecurringPaymentRequest. -const PaymentsRequestRecurringPaymentRequestTypeID = 0x146e958d - -// Ensuring interfaces in compile-time for PaymentsRequestRecurringPaymentRequest. -var ( - _ bin.Encoder = &PaymentsRequestRecurringPaymentRequest{} - _ bin.Decoder = &PaymentsRequestRecurringPaymentRequest{} - _ bin.BareEncoder = &PaymentsRequestRecurringPaymentRequest{} - _ bin.BareDecoder = &PaymentsRequestRecurringPaymentRequest{} -) - -func (r *PaymentsRequestRecurringPaymentRequest) Zero() bool { - if r == nil { - return true - } - if !(r.UserID == nil) { - return false - } - if !(r.RecurringInitCharge == "") { - return false - } - if !(r.InvoiceMedia == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (r *PaymentsRequestRecurringPaymentRequest) String() string { - if r == nil { - return "PaymentsRequestRecurringPaymentRequest(nil)" - } - type Alias PaymentsRequestRecurringPaymentRequest - return fmt.Sprintf("PaymentsRequestRecurringPaymentRequest%+v", Alias(*r)) -} - -// FillFrom fills PaymentsRequestRecurringPaymentRequest from given interface. -func (r *PaymentsRequestRecurringPaymentRequest) FillFrom(from interface { - GetUserID() (value InputUserClass) - GetRecurringInitCharge() (value string) - GetInvoiceMedia() (value InputMediaClass) -}) { - r.UserID = from.GetUserID() - r.RecurringInitCharge = from.GetRecurringInitCharge() - r.InvoiceMedia = from.GetInvoiceMedia() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*PaymentsRequestRecurringPaymentRequest) TypeID() uint32 { - return PaymentsRequestRecurringPaymentRequestTypeID -} - -// TypeName returns name of type in TL schema. -func (*PaymentsRequestRecurringPaymentRequest) TypeName() string { - return "payments.requestRecurringPayment" -} - -// TypeInfo returns info about TL type. -func (r *PaymentsRequestRecurringPaymentRequest) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "payments.requestRecurringPayment", - ID: PaymentsRequestRecurringPaymentRequestTypeID, - } - if r == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "UserID", - SchemaName: "user_id", - }, - { - Name: "RecurringInitCharge", - SchemaName: "recurring_init_charge", - }, - { - Name: "InvoiceMedia", - SchemaName: "invoice_media", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (r *PaymentsRequestRecurringPaymentRequest) Encode(b *bin.Buffer) error { - if r == nil { - return fmt.Errorf("can't encode payments.requestRecurringPayment#146e958d as nil") - } - b.PutID(PaymentsRequestRecurringPaymentRequestTypeID) - return r.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (r *PaymentsRequestRecurringPaymentRequest) EncodeBare(b *bin.Buffer) error { - if r == nil { - return fmt.Errorf("can't encode payments.requestRecurringPayment#146e958d as nil") - } - if r.UserID == nil { - return fmt.Errorf("unable to encode payments.requestRecurringPayment#146e958d: field user_id is nil") - } - if err := r.UserID.Encode(b); err != nil { - return fmt.Errorf("unable to encode payments.requestRecurringPayment#146e958d: field user_id: %w", err) - } - b.PutString(r.RecurringInitCharge) - if r.InvoiceMedia == nil { - return fmt.Errorf("unable to encode payments.requestRecurringPayment#146e958d: field invoice_media is nil") - } - if err := r.InvoiceMedia.Encode(b); err != nil { - return fmt.Errorf("unable to encode payments.requestRecurringPayment#146e958d: field invoice_media: %w", err) - } - return nil -} - -// Decode implements bin.Decoder. -func (r *PaymentsRequestRecurringPaymentRequest) Decode(b *bin.Buffer) error { - if r == nil { - return fmt.Errorf("can't decode payments.requestRecurringPayment#146e958d to nil") - } - if err := b.ConsumeID(PaymentsRequestRecurringPaymentRequestTypeID); err != nil { - return fmt.Errorf("unable to decode payments.requestRecurringPayment#146e958d: %w", err) - } - return r.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (r *PaymentsRequestRecurringPaymentRequest) DecodeBare(b *bin.Buffer) error { - if r == nil { - return fmt.Errorf("can't decode payments.requestRecurringPayment#146e958d to nil") - } - { - value, err := DecodeInputUser(b) - if err != nil { - return fmt.Errorf("unable to decode payments.requestRecurringPayment#146e958d: field user_id: %w", err) - } - r.UserID = value - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode payments.requestRecurringPayment#146e958d: field recurring_init_charge: %w", err) - } - r.RecurringInitCharge = value - } - { - value, err := DecodeInputMedia(b) - if err != nil { - return fmt.Errorf("unable to decode payments.requestRecurringPayment#146e958d: field invoice_media: %w", err) - } - r.InvoiceMedia = value - } - return nil -} - -// GetUserID returns value of UserID field. -func (r *PaymentsRequestRecurringPaymentRequest) GetUserID() (value InputUserClass) { - if r == nil { - return - } - return r.UserID -} - -// GetRecurringInitCharge returns value of RecurringInitCharge field. -func (r *PaymentsRequestRecurringPaymentRequest) GetRecurringInitCharge() (value string) { - if r == nil { - return - } - return r.RecurringInitCharge -} - -// GetInvoiceMedia returns value of InvoiceMedia field. -func (r *PaymentsRequestRecurringPaymentRequest) GetInvoiceMedia() (value InputMediaClass) { - if r == nil { - return - } - return r.InvoiceMedia -} - -// PaymentsRequestRecurringPayment invokes method payments.requestRecurringPayment#146e958d returning error if any. -// -// See https://core.telegram.org/method/payments.requestRecurringPayment for reference. -func (c *Client) PaymentsRequestRecurringPayment(ctx context.Context, request *PaymentsRequestRecurringPaymentRequest) (UpdatesClass, error) { - var result UpdatesBox - - if err := c.rpc.Invoke(ctx, request, &result); err != nil { - return nil, err - } - return result.Updates, nil -} diff --git a/tg/tl_premium_subscription_option_gen.go b/tg/tl_premium_subscription_option_gen.go new file mode 100644 index 0000000000..5a9a600f1e --- /dev/null +++ b/tg/tl_premium_subscription_option_gen.go @@ -0,0 +1,378 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// PremiumSubscriptionOption represents TL type `premiumSubscriptionOption#b6f11ebe`. +// +// See https://core.telegram.org/constructor/premiumSubscriptionOption for reference. +type PremiumSubscriptionOption struct { + // Flags field of PremiumSubscriptionOption. + Flags bin.Fields + // Current field of PremiumSubscriptionOption. + Current bool + // CanPurchaseUpgrade field of PremiumSubscriptionOption. + CanPurchaseUpgrade bool + // Months field of PremiumSubscriptionOption. + Months int + // Currency field of PremiumSubscriptionOption. + Currency string + // Amount field of PremiumSubscriptionOption. + Amount int64 + // BotURL field of PremiumSubscriptionOption. + BotURL string + // StoreProduct field of PremiumSubscriptionOption. + // + // Use SetStoreProduct and GetStoreProduct helpers. + StoreProduct string +} + +// PremiumSubscriptionOptionTypeID is TL type id of PremiumSubscriptionOption. +const PremiumSubscriptionOptionTypeID = 0xb6f11ebe + +// Ensuring interfaces in compile-time for PremiumSubscriptionOption. +var ( + _ bin.Encoder = &PremiumSubscriptionOption{} + _ bin.Decoder = &PremiumSubscriptionOption{} + _ bin.BareEncoder = &PremiumSubscriptionOption{} + _ bin.BareDecoder = &PremiumSubscriptionOption{} +) + +func (p *PremiumSubscriptionOption) Zero() bool { + if p == nil { + return true + } + if !(p.Flags.Zero()) { + return false + } + if !(p.Current == false) { + return false + } + if !(p.CanPurchaseUpgrade == false) { + return false + } + if !(p.Months == 0) { + return false + } + if !(p.Currency == "") { + return false + } + if !(p.Amount == 0) { + return false + } + if !(p.BotURL == "") { + return false + } + if !(p.StoreProduct == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (p *PremiumSubscriptionOption) String() string { + if p == nil { + return "PremiumSubscriptionOption(nil)" + } + type Alias PremiumSubscriptionOption + return fmt.Sprintf("PremiumSubscriptionOption%+v", Alias(*p)) +} + +// FillFrom fills PremiumSubscriptionOption from given interface. +func (p *PremiumSubscriptionOption) FillFrom(from interface { + GetCurrent() (value bool) + GetCanPurchaseUpgrade() (value bool) + GetMonths() (value int) + GetCurrency() (value string) + GetAmount() (value int64) + GetBotURL() (value string) + GetStoreProduct() (value string, ok bool) +}) { + p.Current = from.GetCurrent() + p.CanPurchaseUpgrade = from.GetCanPurchaseUpgrade() + p.Months = from.GetMonths() + p.Currency = from.GetCurrency() + p.Amount = from.GetAmount() + p.BotURL = from.GetBotURL() + if val, ok := from.GetStoreProduct(); ok { + p.StoreProduct = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PremiumSubscriptionOption) TypeID() uint32 { + return PremiumSubscriptionOptionTypeID +} + +// TypeName returns name of type in TL schema. +func (*PremiumSubscriptionOption) TypeName() string { + return "premiumSubscriptionOption" +} + +// TypeInfo returns info about TL type. +func (p *PremiumSubscriptionOption) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "premiumSubscriptionOption", + ID: PremiumSubscriptionOptionTypeID, + } + if p == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Current", + SchemaName: "current", + Null: !p.Flags.Has(1), + }, + { + Name: "CanPurchaseUpgrade", + SchemaName: "can_purchase_upgrade", + Null: !p.Flags.Has(2), + }, + { + Name: "Months", + SchemaName: "months", + }, + { + Name: "Currency", + SchemaName: "currency", + }, + { + Name: "Amount", + SchemaName: "amount", + }, + { + Name: "BotURL", + SchemaName: "bot_url", + }, + { + Name: "StoreProduct", + SchemaName: "store_product", + Null: !p.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (p *PremiumSubscriptionOption) SetFlags() { + if !(p.Current == false) { + p.Flags.Set(1) + } + if !(p.CanPurchaseUpgrade == false) { + p.Flags.Set(2) + } + if !(p.StoreProduct == "") { + p.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (p *PremiumSubscriptionOption) Encode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode premiumSubscriptionOption#b6f11ebe as nil") + } + b.PutID(PremiumSubscriptionOptionTypeID) + return p.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (p *PremiumSubscriptionOption) EncodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode premiumSubscriptionOption#b6f11ebe as nil") + } + p.SetFlags() + if err := p.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode premiumSubscriptionOption#b6f11ebe: field flags: %w", err) + } + b.PutInt(p.Months) + b.PutString(p.Currency) + b.PutLong(p.Amount) + b.PutString(p.BotURL) + if p.Flags.Has(0) { + b.PutString(p.StoreProduct) + } + return nil +} + +// Decode implements bin.Decoder. +func (p *PremiumSubscriptionOption) Decode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode premiumSubscriptionOption#b6f11ebe to nil") + } + if err := b.ConsumeID(PremiumSubscriptionOptionTypeID); err != nil { + return fmt.Errorf("unable to decode premiumSubscriptionOption#b6f11ebe: %w", err) + } + return p.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (p *PremiumSubscriptionOption) DecodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode premiumSubscriptionOption#b6f11ebe to nil") + } + { + if err := p.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode premiumSubscriptionOption#b6f11ebe: field flags: %w", err) + } + } + p.Current = p.Flags.Has(1) + p.CanPurchaseUpgrade = p.Flags.Has(2) + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode premiumSubscriptionOption#b6f11ebe: field months: %w", err) + } + p.Months = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode premiumSubscriptionOption#b6f11ebe: field currency: %w", err) + } + p.Currency = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode premiumSubscriptionOption#b6f11ebe: field amount: %w", err) + } + p.Amount = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode premiumSubscriptionOption#b6f11ebe: field bot_url: %w", err) + } + p.BotURL = value + } + if p.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode premiumSubscriptionOption#b6f11ebe: field store_product: %w", err) + } + p.StoreProduct = value + } + return nil +} + +// SetCurrent sets value of Current conditional field. +func (p *PremiumSubscriptionOption) SetCurrent(value bool) { + if value { + p.Flags.Set(1) + p.Current = true + } else { + p.Flags.Unset(1) + p.Current = false + } +} + +// GetCurrent returns value of Current conditional field. +func (p *PremiumSubscriptionOption) GetCurrent() (value bool) { + if p == nil { + return + } + return p.Flags.Has(1) +} + +// SetCanPurchaseUpgrade sets value of CanPurchaseUpgrade conditional field. +func (p *PremiumSubscriptionOption) SetCanPurchaseUpgrade(value bool) { + if value { + p.Flags.Set(2) + p.CanPurchaseUpgrade = true + } else { + p.Flags.Unset(2) + p.CanPurchaseUpgrade = false + } +} + +// GetCanPurchaseUpgrade returns value of CanPurchaseUpgrade conditional field. +func (p *PremiumSubscriptionOption) GetCanPurchaseUpgrade() (value bool) { + if p == nil { + return + } + return p.Flags.Has(2) +} + +// GetMonths returns value of Months field. +func (p *PremiumSubscriptionOption) GetMonths() (value int) { + if p == nil { + return + } + return p.Months +} + +// GetCurrency returns value of Currency field. +func (p *PremiumSubscriptionOption) GetCurrency() (value string) { + if p == nil { + return + } + return p.Currency +} + +// GetAmount returns value of Amount field. +func (p *PremiumSubscriptionOption) GetAmount() (value int64) { + if p == nil { + return + } + return p.Amount +} + +// GetBotURL returns value of BotURL field. +func (p *PremiumSubscriptionOption) GetBotURL() (value string) { + if p == nil { + return + } + return p.BotURL +} + +// SetStoreProduct sets value of StoreProduct conditional field. +func (p *PremiumSubscriptionOption) SetStoreProduct(value string) { + p.Flags.Set(0) + p.StoreProduct = value +} + +// GetStoreProduct returns value of StoreProduct conditional field and +// boolean which is true if field was set. +func (p *PremiumSubscriptionOption) GetStoreProduct() (value string, ok bool) { + if p == nil { + return + } + if !p.Flags.Has(0) { + return value, false + } + return p.StoreProduct, true +} diff --git a/tg/tl_premium_subscription_option_slices_gen.go b/tg/tl_premium_subscription_option_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_premium_subscription_option_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_reaction_count_gen.go b/tg/tl_reaction_count_gen.go index e87d495d82..0a3998863a 100644 --- a/tg/tl_reaction_count_gen.go +++ b/tg/tl_reaction_count_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// ReactionCount represents TL type `reactionCount#6fb250d1`. +// ReactionCount represents TL type `reactionCount#a3d1cb80`. // Reactions // // See https://core.telegram.org/constructor/reactionCount for reference. @@ -41,16 +41,18 @@ type ReactionCount struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields - // Whether the current user sent this reaction - Chosen bool + // ChosenOrder field of ReactionCount. + // + // Use SetChosenOrder and GetChosenOrder helpers. + ChosenOrder int // Reaction (a UTF8 emoji) - Reaction string + Reaction ReactionClass // NUmber of users that reacted with this emoji Count int } // ReactionCountTypeID is TL type id of ReactionCount. -const ReactionCountTypeID = 0x6fb250d1 +const ReactionCountTypeID = 0xa3d1cb80 // Ensuring interfaces in compile-time for ReactionCount. var ( @@ -67,10 +69,10 @@ func (r *ReactionCount) Zero() bool { if !(r.Flags.Zero()) { return false } - if !(r.Chosen == false) { + if !(r.ChosenOrder == 0) { return false } - if !(r.Reaction == "") { + if !(r.Reaction == nil) { return false } if !(r.Count == 0) { @@ -91,11 +93,14 @@ func (r *ReactionCount) String() string { // FillFrom fills ReactionCount from given interface. func (r *ReactionCount) FillFrom(from interface { - GetChosen() (value bool) - GetReaction() (value string) + GetChosenOrder() (value int, ok bool) + GetReaction() (value ReactionClass) GetCount() (value int) }) { - r.Chosen = from.GetChosen() + if val, ok := from.GetChosenOrder(); ok { + r.ChosenOrder = val + } + r.Reaction = from.GetReaction() r.Count = from.GetCount() } @@ -124,8 +129,8 @@ func (r *ReactionCount) TypeInfo() tdp.Type { } typ.Fields = []tdp.Field{ { - Name: "Chosen", - SchemaName: "chosen", + Name: "ChosenOrder", + SchemaName: "chosen_order", Null: !r.Flags.Has(0), }, { @@ -142,7 +147,7 @@ func (r *ReactionCount) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (r *ReactionCount) SetFlags() { - if !(r.Chosen == false) { + if !(r.ChosenOrder == 0) { r.Flags.Set(0) } } @@ -150,7 +155,7 @@ func (r *ReactionCount) SetFlags() { // Encode implements bin.Encoder. func (r *ReactionCount) Encode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode reactionCount#6fb250d1 as nil") + return fmt.Errorf("can't encode reactionCount#a3d1cb80 as nil") } b.PutID(ReactionCountTypeID) return r.EncodeBare(b) @@ -159,13 +164,21 @@ func (r *ReactionCount) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (r *ReactionCount) EncodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode reactionCount#6fb250d1 as nil") + return fmt.Errorf("can't encode reactionCount#a3d1cb80 as nil") } r.SetFlags() if err := r.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode reactionCount#6fb250d1: field flags: %w", err) + return fmt.Errorf("unable to encode reactionCount#a3d1cb80: field flags: %w", err) + } + if r.Flags.Has(0) { + b.PutInt(r.ChosenOrder) + } + if r.Reaction == nil { + return fmt.Errorf("unable to encode reactionCount#a3d1cb80: field reaction is nil") + } + if err := r.Reaction.Encode(b); err != nil { + return fmt.Errorf("unable to encode reactionCount#a3d1cb80: field reaction: %w", err) } - b.PutString(r.Reaction) b.PutInt(r.Count) return nil } @@ -173,10 +186,10 @@ func (r *ReactionCount) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (r *ReactionCount) Decode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode reactionCount#6fb250d1 to nil") + return fmt.Errorf("can't decode reactionCount#a3d1cb80 to nil") } if err := b.ConsumeID(ReactionCountTypeID); err != nil { - return fmt.Errorf("unable to decode reactionCount#6fb250d1: %w", err) + return fmt.Errorf("unable to decode reactionCount#a3d1cb80: %w", err) } return r.DecodeBare(b) } @@ -184,52 +197,57 @@ func (r *ReactionCount) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (r *ReactionCount) DecodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode reactionCount#6fb250d1 to nil") + return fmt.Errorf("can't decode reactionCount#a3d1cb80 to nil") } { if err := r.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode reactionCount#6fb250d1: field flags: %w", err) + return fmt.Errorf("unable to decode reactionCount#a3d1cb80: field flags: %w", err) } } - r.Chosen = r.Flags.Has(0) + if r.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode reactionCount#a3d1cb80: field chosen_order: %w", err) + } + r.ChosenOrder = value + } { - value, err := b.String() + value, err := DecodeReaction(b) if err != nil { - return fmt.Errorf("unable to decode reactionCount#6fb250d1: field reaction: %w", err) + return fmt.Errorf("unable to decode reactionCount#a3d1cb80: field reaction: %w", err) } r.Reaction = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode reactionCount#6fb250d1: field count: %w", err) + return fmt.Errorf("unable to decode reactionCount#a3d1cb80: field count: %w", err) } r.Count = value } return nil } -// SetChosen sets value of Chosen conditional field. -func (r *ReactionCount) SetChosen(value bool) { - if value { - r.Flags.Set(0) - r.Chosen = true - } else { - r.Flags.Unset(0) - r.Chosen = false - } +// SetChosenOrder sets value of ChosenOrder conditional field. +func (r *ReactionCount) SetChosenOrder(value int) { + r.Flags.Set(0) + r.ChosenOrder = value } -// GetChosen returns value of Chosen conditional field. -func (r *ReactionCount) GetChosen() (value bool) { +// GetChosenOrder returns value of ChosenOrder conditional field and +// boolean which is true if field was set. +func (r *ReactionCount) GetChosenOrder() (value int, ok bool) { if r == nil { return } - return r.Flags.Has(0) + if !r.Flags.Has(0) { + return value, false + } + return r.ChosenOrder, true } // GetReaction returns value of Reaction field. -func (r *ReactionCount) GetReaction() (value string) { +func (r *ReactionCount) GetReaction() (value ReactionClass) { if r == nil { return } diff --git a/tg/tl_reaction_gen.go b/tg/tl_reaction_gen.go new file mode 100644 index 0000000000..2886489da4 --- /dev/null +++ b/tg/tl_reaction_gen.go @@ -0,0 +1,498 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// ReactionEmpty represents TL type `reactionEmpty#79f5d419`. +// +// See https://core.telegram.org/constructor/reactionEmpty for reference. +type ReactionEmpty struct { +} + +// ReactionEmptyTypeID is TL type id of ReactionEmpty. +const ReactionEmptyTypeID = 0x79f5d419 + +// construct implements constructor of ReactionClass. +func (r ReactionEmpty) construct() ReactionClass { return &r } + +// Ensuring interfaces in compile-time for ReactionEmpty. +var ( + _ bin.Encoder = &ReactionEmpty{} + _ bin.Decoder = &ReactionEmpty{} + _ bin.BareEncoder = &ReactionEmpty{} + _ bin.BareDecoder = &ReactionEmpty{} + + _ ReactionClass = &ReactionEmpty{} +) + +func (r *ReactionEmpty) Zero() bool { + if r == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (r *ReactionEmpty) String() string { + if r == nil { + return "ReactionEmpty(nil)" + } + type Alias ReactionEmpty + return fmt.Sprintf("ReactionEmpty%+v", Alias(*r)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ReactionEmpty) TypeID() uint32 { + return ReactionEmptyTypeID +} + +// TypeName returns name of type in TL schema. +func (*ReactionEmpty) TypeName() string { + return "reactionEmpty" +} + +// TypeInfo returns info about TL type. +func (r *ReactionEmpty) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "reactionEmpty", + ID: ReactionEmptyTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (r *ReactionEmpty) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reactionEmpty#79f5d419 as nil") + } + b.PutID(ReactionEmptyTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *ReactionEmpty) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reactionEmpty#79f5d419 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (r *ReactionEmpty) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reactionEmpty#79f5d419 to nil") + } + if err := b.ConsumeID(ReactionEmptyTypeID); err != nil { + return fmt.Errorf("unable to decode reactionEmpty#79f5d419: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *ReactionEmpty) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reactionEmpty#79f5d419 to nil") + } + return nil +} + +// ReactionEmoji represents TL type `reactionEmoji#1b2286b8`. +// +// See https://core.telegram.org/constructor/reactionEmoji for reference. +type ReactionEmoji struct { + // Emoticon field of ReactionEmoji. + Emoticon string +} + +// ReactionEmojiTypeID is TL type id of ReactionEmoji. +const ReactionEmojiTypeID = 0x1b2286b8 + +// construct implements constructor of ReactionClass. +func (r ReactionEmoji) construct() ReactionClass { return &r } + +// Ensuring interfaces in compile-time for ReactionEmoji. +var ( + _ bin.Encoder = &ReactionEmoji{} + _ bin.Decoder = &ReactionEmoji{} + _ bin.BareEncoder = &ReactionEmoji{} + _ bin.BareDecoder = &ReactionEmoji{} + + _ ReactionClass = &ReactionEmoji{} +) + +func (r *ReactionEmoji) Zero() bool { + if r == nil { + return true + } + if !(r.Emoticon == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *ReactionEmoji) String() string { + if r == nil { + return "ReactionEmoji(nil)" + } + type Alias ReactionEmoji + return fmt.Sprintf("ReactionEmoji%+v", Alias(*r)) +} + +// FillFrom fills ReactionEmoji from given interface. +func (r *ReactionEmoji) FillFrom(from interface { + GetEmoticon() (value string) +}) { + r.Emoticon = from.GetEmoticon() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ReactionEmoji) TypeID() uint32 { + return ReactionEmojiTypeID +} + +// TypeName returns name of type in TL schema. +func (*ReactionEmoji) TypeName() string { + return "reactionEmoji" +} + +// TypeInfo returns info about TL type. +func (r *ReactionEmoji) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "reactionEmoji", + ID: ReactionEmojiTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Emoticon", + SchemaName: "emoticon", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (r *ReactionEmoji) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reactionEmoji#1b2286b8 as nil") + } + b.PutID(ReactionEmojiTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *ReactionEmoji) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reactionEmoji#1b2286b8 as nil") + } + b.PutString(r.Emoticon) + return nil +} + +// Decode implements bin.Decoder. +func (r *ReactionEmoji) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reactionEmoji#1b2286b8 to nil") + } + if err := b.ConsumeID(ReactionEmojiTypeID); err != nil { + return fmt.Errorf("unable to decode reactionEmoji#1b2286b8: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *ReactionEmoji) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reactionEmoji#1b2286b8 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode reactionEmoji#1b2286b8: field emoticon: %w", err) + } + r.Emoticon = value + } + return nil +} + +// GetEmoticon returns value of Emoticon field. +func (r *ReactionEmoji) GetEmoticon() (value string) { + if r == nil { + return + } + return r.Emoticon +} + +// ReactionCustomEmoji represents TL type `reactionCustomEmoji#8935fc73`. +// +// See https://core.telegram.org/constructor/reactionCustomEmoji for reference. +type ReactionCustomEmoji struct { + // DocumentID field of ReactionCustomEmoji. + DocumentID int64 +} + +// ReactionCustomEmojiTypeID is TL type id of ReactionCustomEmoji. +const ReactionCustomEmojiTypeID = 0x8935fc73 + +// construct implements constructor of ReactionClass. +func (r ReactionCustomEmoji) construct() ReactionClass { return &r } + +// Ensuring interfaces in compile-time for ReactionCustomEmoji. +var ( + _ bin.Encoder = &ReactionCustomEmoji{} + _ bin.Decoder = &ReactionCustomEmoji{} + _ bin.BareEncoder = &ReactionCustomEmoji{} + _ bin.BareDecoder = &ReactionCustomEmoji{} + + _ ReactionClass = &ReactionCustomEmoji{} +) + +func (r *ReactionCustomEmoji) Zero() bool { + if r == nil { + return true + } + if !(r.DocumentID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *ReactionCustomEmoji) String() string { + if r == nil { + return "ReactionCustomEmoji(nil)" + } + type Alias ReactionCustomEmoji + return fmt.Sprintf("ReactionCustomEmoji%+v", Alias(*r)) +} + +// FillFrom fills ReactionCustomEmoji from given interface. +func (r *ReactionCustomEmoji) FillFrom(from interface { + GetDocumentID() (value int64) +}) { + r.DocumentID = from.GetDocumentID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ReactionCustomEmoji) TypeID() uint32 { + return ReactionCustomEmojiTypeID +} + +// TypeName returns name of type in TL schema. +func (*ReactionCustomEmoji) TypeName() string { + return "reactionCustomEmoji" +} + +// TypeInfo returns info about TL type. +func (r *ReactionCustomEmoji) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "reactionCustomEmoji", + ID: ReactionCustomEmojiTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "DocumentID", + SchemaName: "document_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (r *ReactionCustomEmoji) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reactionCustomEmoji#8935fc73 as nil") + } + b.PutID(ReactionCustomEmojiTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *ReactionCustomEmoji) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reactionCustomEmoji#8935fc73 as nil") + } + b.PutLong(r.DocumentID) + return nil +} + +// Decode implements bin.Decoder. +func (r *ReactionCustomEmoji) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reactionCustomEmoji#8935fc73 to nil") + } + if err := b.ConsumeID(ReactionCustomEmojiTypeID); err != nil { + return fmt.Errorf("unable to decode reactionCustomEmoji#8935fc73: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *ReactionCustomEmoji) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reactionCustomEmoji#8935fc73 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode reactionCustomEmoji#8935fc73: field document_id: %w", err) + } + r.DocumentID = value + } + return nil +} + +// GetDocumentID returns value of DocumentID field. +func (r *ReactionCustomEmoji) GetDocumentID() (value int64) { + if r == nil { + return + } + return r.DocumentID +} + +// ReactionClassName is schema name of ReactionClass. +const ReactionClassName = "Reaction" + +// ReactionClass represents Reaction generic type. +// +// See https://core.telegram.org/type/Reaction for reference. +// +// Example: +// +// g, err := tg.DecodeReaction(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.ReactionEmpty: // reactionEmpty#79f5d419 +// case *tg.ReactionEmoji: // reactionEmoji#1b2286b8 +// case *tg.ReactionCustomEmoji: // reactionCustomEmoji#8935fc73 +// default: panic(v) +// } +type ReactionClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() ReactionClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool +} + +// DecodeReaction implements binary de-serialization for ReactionClass. +func DecodeReaction(buf *bin.Buffer) (ReactionClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case ReactionEmptyTypeID: + // Decoding reactionEmpty#79f5d419. + v := ReactionEmpty{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ReactionClass: %w", err) + } + return &v, nil + case ReactionEmojiTypeID: + // Decoding reactionEmoji#1b2286b8. + v := ReactionEmoji{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ReactionClass: %w", err) + } + return &v, nil + case ReactionCustomEmojiTypeID: + // Decoding reactionCustomEmoji#8935fc73. + v := ReactionCustomEmoji{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ReactionClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode ReactionClass: %w", bin.NewUnexpectedID(id)) + } +} + +// Reaction boxes the ReactionClass providing a helper. +type ReactionBox struct { + Reaction ReactionClass +} + +// Decode implements bin.Decoder for ReactionBox. +func (b *ReactionBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode ReactionBox to nil") + } + v, err := DecodeReaction(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.Reaction = v + return nil +} + +// Encode implements bin.Encode for ReactionBox. +func (b *ReactionBox) Encode(buf *bin.Buffer) error { + if b == nil || b.Reaction == nil { + return fmt.Errorf("unable to encode ReactionClass as nil") + } + return b.Reaction.Encode(buf) +} diff --git a/tg/tl_reaction_slices_gen.go b/tg/tl_reaction_slices_gen.go new file mode 100644 index 0000000000..1057b8dd65 --- /dev/null +++ b/tg/tl_reaction_slices_gen.go @@ -0,0 +1,307 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// ReactionClassArray is adapter for slice of ReactionClass. +type ReactionClassArray []ReactionClass + +// Sort sorts slice of ReactionClass. +func (s ReactionClassArray) Sort(less func(a, b ReactionClass) bool) ReactionClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ReactionClass. +func (s ReactionClassArray) SortStable(less func(a, b ReactionClass) bool) ReactionClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ReactionClass. +func (s ReactionClassArray) Retain(keep func(x ReactionClass) bool) ReactionClassArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s ReactionClassArray) First() (v ReactionClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ReactionClassArray) Last() (v ReactionClass, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *ReactionClassArray) PopFirst() (v ReactionClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero ReactionClass + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *ReactionClassArray) Pop() (v ReactionClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// AsReactionEmoji returns copy with only ReactionEmoji constructors. +func (s ReactionClassArray) AsReactionEmoji() (to ReactionEmojiArray) { + for _, elem := range s { + value, ok := elem.(*ReactionEmoji) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsReactionCustomEmoji returns copy with only ReactionCustomEmoji constructors. +func (s ReactionClassArray) AsReactionCustomEmoji() (to ReactionCustomEmojiArray) { + for _, elem := range s { + value, ok := elem.(*ReactionCustomEmoji) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// ReactionEmojiArray is adapter for slice of ReactionEmoji. +type ReactionEmojiArray []ReactionEmoji + +// Sort sorts slice of ReactionEmoji. +func (s ReactionEmojiArray) Sort(less func(a, b ReactionEmoji) bool) ReactionEmojiArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ReactionEmoji. +func (s ReactionEmojiArray) SortStable(less func(a, b ReactionEmoji) bool) ReactionEmojiArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ReactionEmoji. +func (s ReactionEmojiArray) Retain(keep func(x ReactionEmoji) bool) ReactionEmojiArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s ReactionEmojiArray) First() (v ReactionEmoji, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ReactionEmojiArray) Last() (v ReactionEmoji, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *ReactionEmojiArray) PopFirst() (v ReactionEmoji, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero ReactionEmoji + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *ReactionEmojiArray) Pop() (v ReactionEmoji, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// ReactionCustomEmojiArray is adapter for slice of ReactionCustomEmoji. +type ReactionCustomEmojiArray []ReactionCustomEmoji + +// Sort sorts slice of ReactionCustomEmoji. +func (s ReactionCustomEmojiArray) Sort(less func(a, b ReactionCustomEmoji) bool) ReactionCustomEmojiArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ReactionCustomEmoji. +func (s ReactionCustomEmojiArray) SortStable(less func(a, b ReactionCustomEmoji) bool) ReactionCustomEmojiArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ReactionCustomEmoji. +func (s ReactionCustomEmojiArray) Retain(keep func(x ReactionCustomEmoji) bool) ReactionCustomEmojiArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s ReactionCustomEmojiArray) First() (v ReactionCustomEmoji, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ReactionCustomEmojiArray) Last() (v ReactionCustomEmoji, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *ReactionCustomEmojiArray) PopFirst() (v ReactionCustomEmoji, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero ReactionCustomEmoji + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *ReactionCustomEmojiArray) Pop() (v ReactionCustomEmoji, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_registry_gen.go b/tg/tl_registry_gen.go index c48a749b63..24120d842a 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 144 +const Layer = 145 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -102,7 +102,7 @@ func TypesMap() map[uint32]string { StorageFileMp4TypeID: "storage.fileMp4#b3cea0e4", StorageFileWebpTypeID: "storage.fileWebp#1081464c", UserEmptyTypeID: "userEmpty#d3bc4b7a", - UserTypeID: "user#3ff6ecb0", + UserTypeID: "user#5d99adee", UserProfilePhotoEmptyTypeID: "userProfilePhotoEmpty#4f11bae1", UserProfilePhotoTypeID: "userProfilePhoto#82d1f706", UserStatusEmptyTypeID: "userStatusEmpty#9d05049", @@ -116,8 +116,8 @@ func TypesMap() map[uint32]string { ChatForbiddenTypeID: "chatForbidden#6592a1a7", ChannelTypeID: "channel#8261ac61", ChannelForbiddenTypeID: "channelForbidden#17d493d5", - ChatFullTypeID: "chatFull#d18ee226", - ChannelFullTypeID: "channelFull#ea68a619", + ChatFullTypeID: "chatFull#c9d31138", + ChannelFullTypeID: "channelFull#f2355507", ChatParticipantTypeID: "chatParticipant#c02d4007", ChatParticipantCreatorTypeID: "chatParticipantCreator#e46bcee4", ChatParticipantAdminTypeID: "chatParticipantAdmin#a0933f5b", @@ -279,7 +279,7 @@ func TypesMap() map[uint32]string { UpdateChatParticipantAdminTypeID: "updateChatParticipantAdmin#d7ca61a2", UpdateNewStickerSetTypeID: "updateNewStickerSet#688a30aa", UpdateStickerSetsOrderTypeID: "updateStickerSetsOrder#bb2d201", - UpdateStickerSetsTypeID: "updateStickerSets#43ae3dec", + UpdateStickerSetsTypeID: "updateStickerSets#31c24808", UpdateSavedGifsTypeID: "updateSavedGifs#9375341e", UpdateBotInlineQueryTypeID: "updateBotInlineQuery#496f379c", UpdateBotInlineSendTypeID: "updateBotInlineSend#12f12a07", @@ -348,6 +348,10 @@ func TypesMap() map[uint32]string { UpdateSavedRingtonesTypeID: "updateSavedRingtones#74d8be99", UpdateTranscribedAudioTypeID: "updateTranscribedAudio#84cd5a", UpdateReadFeaturedEmojiStickersTypeID: "updateReadFeaturedEmojiStickers#fb4c496c", + UpdateUserEmojiStatusTypeID: "updateUserEmojiStatus#28373599", + UpdateRecentEmojiStatusesTypeID: "updateRecentEmojiStatuses#30f443db", + UpdateRecentReactionsTypeID: "updateRecentReactions#6f7863f4", + UpdateMoveStickerSetToTopTypeID: "updateMoveStickerSetToTop#86fccf85", UpdatesStateTypeID: "updates.state#a56c2a3e", UpdatesDifferenceEmptyTypeID: "updates.differenceEmpty#5d75a138", UpdatesDifferenceTypeID: "updates.difference#f49ca0", @@ -366,7 +370,7 @@ func TypesMap() map[uint32]string { UploadFileTypeID: "upload.file#96a18d5", UploadFileCDNRedirectTypeID: "upload.fileCdnRedirect#f18cda44", DCOptionTypeID: "dcOption#18b7a10d", - ConfigTypeID: "config#330b4067", + ConfigTypeID: "config#232566ac", NearestDCTypeID: "nearestDc#8e1a1775", HelpAppUpdateTypeID: "help.appUpdate#ccbbce30", HelpNoAppUpdateTypeID: "help.noAppUpdate#c45a6536", @@ -473,7 +477,7 @@ func TypesMap() map[uint32]string { WebPageNotModifiedTypeID: "webPageNotModified#7311ca11", AuthorizationTypeID: "authorization#ad01d61d", AccountAuthorizationsTypeID: "account.authorizations#4bff8ea0", - AccountPasswordTypeID: "account.password#185b184f", + AccountPasswordTypeID: "account.password#957b50fb", AccountPasswordSettingsTypeID: "account.passwordSettings#9a5c33e5", AccountPasswordInputSettingsTypeID: "account.passwordInputSettings#c23727c9", AuthPasswordRecoveryTypeID: "auth.passwordRecovery#137948a5", @@ -490,6 +494,8 @@ func TypesMap() map[uint32]string { InputStickerSetDiceTypeID: "inputStickerSetDice#e67f520e", InputStickerSetAnimatedEmojiAnimationsTypeID: "inputStickerSetAnimatedEmojiAnimations#cde3739", InputStickerSetPremiumGiftsTypeID: "inputStickerSetPremiumGifts#c88b3b02", + InputStickerSetEmojiGenericAnimationsTypeID: "inputStickerSetEmojiGenericAnimations#4c4d4ce", + InputStickerSetEmojiDefaultStatusesTypeID: "inputStickerSetEmojiDefaultStatuses#29d0f5ee", StickerSetTypeID: "stickerSet#2dd14edc", MessagesStickerSetTypeID: "messages.stickerSet#b60a24a6", MessagesStickerSetNotModifiedTypeID: "messages.stickerSetNotModified#d3f924eb", @@ -597,6 +603,8 @@ func TypesMap() map[uint32]string { AuthSentCodeTypeCallTypeID: "auth.sentCodeTypeCall#5353e5a7", AuthSentCodeTypeFlashCallTypeID: "auth.sentCodeTypeFlashCall#ab03c6d9", AuthSentCodeTypeMissedCallTypeID: "auth.sentCodeTypeMissedCall#82006484", + AuthSentCodeTypeEmailCodeTypeID: "auth.sentCodeTypeEmailCode#5a159841", + AuthSentCodeTypeSetUpEmailRequiredTypeID: "auth.sentCodeTypeSetUpEmailRequired#a5491dea", MessagesBotCallbackAnswerTypeID: "messages.botCallbackAnswer#36585ea4", MessagesMessageEditDataTypeID: "messages.messageEditData#26b5dde6", InputBotInlineMessageIDTypeID: "inputBotInlineMessageID#890c3d89", @@ -767,7 +775,7 @@ func TypesMap() map[uint32]string { ChannelAdminLogEventActionParticipantJoinByRequestTypeID: "channelAdminLogEventActionParticipantJoinByRequest#afb6144a", ChannelAdminLogEventActionToggleNoForwardsTypeID: "channelAdminLogEventActionToggleNoForwards#cb2ac766", ChannelAdminLogEventActionSendMessageTypeID: "channelAdminLogEventActionSendMessage#278f2868", - ChannelAdminLogEventActionChangeAvailableReactionsTypeID: "channelAdminLogEventActionChangeAvailableReactions#9cf7f76a", + ChannelAdminLogEventActionChangeAvailableReactionsTypeID: "channelAdminLogEventActionChangeAvailableReactions#be4e0ef8", ChannelAdminLogEventTypeID: "channelAdminLogEvent#1fad68cd", ChannelsAdminLogResultsTypeID: "channels.adminLogResults#ed8af74d", ChannelAdminLogEventsFilterTypeID: "channelAdminLogEventsFilter#ea107ae4", @@ -999,11 +1007,11 @@ func TypesMap() map[uint32]string { MessagesSearchResultsCalendarTypeID: "messages.searchResultsCalendar#147ee23c", SearchResultPositionTypeID: "searchResultPosition#7f648b67", MessagesSearchResultsPositionsTypeID: "messages.searchResultsPositions#53b22baf", - ChannelsSendAsPeersTypeID: "channels.sendAsPeers#8356cda9", + ChannelsSendAsPeersTypeID: "channels.sendAsPeers#f496b0c6", UsersUserFullTypeID: "users.userFull#3b6d152e", MessagesPeerSettingsTypeID: "messages.peerSettings#6880b94d", AuthLoggedOutTypeID: "auth.loggedOut#c3a2835f", - ReactionCountTypeID: "reactionCount#6fb250d1", + ReactionCountTypeID: "reactionCount#a3d1cb80", MessageReactionsTypeID: "messageReactions#4f2b9479", MessagesMessageReactionsListTypeID: "messages.messageReactionsList#31bd492d", AvailableReactionTypeID: "availableReaction#c077ec01", @@ -1011,7 +1019,7 @@ func TypesMap() map[uint32]string { MessagesAvailableReactionsTypeID: "messages.availableReactions#768e3aad", MessagesTranslateNoResultTypeID: "messages.translateNoResult#67ca4737", MessagesTranslateResultTextTypeID: "messages.translateResultText#a214f7d0", - MessagePeerReactionTypeID: "messagePeerReaction#51b67eff", + MessagePeerReactionTypeID: "messagePeerReaction#b156fe9c", GroupCallStreamChannelTypeID: "groupCallStreamChannel#80eb48af", PhoneGroupCallStreamChannelsTypeID: "phone.groupCallStreamChannels#d0e482b2", PhoneGroupCallStreamRtmpURLTypeID: "phone.groupCallStreamRtmpUrl#2dbf3432", @@ -1044,11 +1052,34 @@ func TypesMap() map[uint32]string { InputInvoiceSlugTypeID: "inputInvoiceSlug#c326caef", PaymentsExportedInvoiceTypeID: "payments.exportedInvoice#aed0cbd9", MessagesTranscribedAudioTypeID: "messages.transcribedAudio#93752c52", - HelpPremiumPromoTypeID: "help.premiumPromo#8a4f3c29", + HelpPremiumPromoTypeID: "help.premiumPromo#5334759c", InputStorePaymentPremiumSubscriptionTypeID: "inputStorePaymentPremiumSubscription#a6751e66", InputStorePaymentGiftPremiumTypeID: "inputStorePaymentGiftPremium#616f7fe8", PremiumGiftOptionTypeID: "premiumGiftOption#74c34319", PaymentFormMethodTypeID: "paymentFormMethod#88f8f21b", + EmojiStatusEmptyTypeID: "emojiStatusEmpty#2de11aae", + EmojiStatusTypeID: "emojiStatus#929b619d", + EmojiStatusUntilTypeID: "emojiStatusUntil#fa30a8c7", + AccountEmojiStatusesNotModifiedTypeID: "account.emojiStatusesNotModified#d08ce645", + AccountEmojiStatusesTypeID: "account.emojiStatuses#90c467d1", + ReactionEmptyTypeID: "reactionEmpty#79f5d419", + ReactionEmojiTypeID: "reactionEmoji#1b2286b8", + ReactionCustomEmojiTypeID: "reactionCustomEmoji#8935fc73", + ChatReactionsNoneTypeID: "chatReactionsNone#eafc32bc", + ChatReactionsAllTypeID: "chatReactionsAll#52928bca", + ChatReactionsSomeTypeID: "chatReactionsSome#661d4037", + MessagesReactionsNotModifiedTypeID: "messages.reactionsNotModified#b06fdbdf", + MessagesReactionsTypeID: "messages.reactions#eafdf716", + EmailVerifyPurposeLoginSetupTypeID: "emailVerifyPurposeLoginSetup#4345be73", + EmailVerifyPurposeLoginChangeTypeID: "emailVerifyPurposeLoginChange#527d22eb", + EmailVerifyPurposePassportTypeID: "emailVerifyPurposePassport#bbf51685", + EmailVerificationCodeTypeID: "emailVerificationCode#922e55a9", + EmailVerificationGoogleTypeID: "emailVerificationGoogle#db909ec2", + EmailVerificationAppleTypeID: "emailVerificationApple#96d074fd", + AccountEmailVerifiedTypeID: "account.emailVerified#2b96cd1b", + AccountEmailVerifiedLoginTypeID: "account.emailVerifiedLogin#e1bb0d61", + PremiumSubscriptionOptionTypeID: "premiumSubscriptionOption#b6f11ebe", + SendAsPeerTypeID: "sendAsPeer#b81c7034", InvokeAfterMsgRequestTypeID: "invokeAfterMsg#cb9f372d", InvokeAfterMsgsRequestTypeID: "invokeAfterMsgs#3dc4b4f0", InitConnectionRequestTypeID: "initConnection#c1cd5ea9", @@ -1058,7 +1089,7 @@ func TypesMap() map[uint32]string { InvokeWithTakeoutRequestTypeID: "invokeWithTakeout#aca9fd2e", AuthSendCodeRequestTypeID: "auth.sendCode#a677244f", AuthSignUpRequestTypeID: "auth.signUp#80eee427", - AuthSignInRequestTypeID: "auth.signIn#bcd51581", + AuthSignInRequestTypeID: "auth.signIn#8d52a951", AuthLogOutRequestTypeID: "auth.logOut#3e72ba19", AuthResetAuthorizationsRequestTypeID: "auth.resetAuthorizations#9fab0d1a", AuthExportAuthorizationRequestTypeID: "auth.exportAuthorization#e5bfffcd", @@ -1113,8 +1144,8 @@ func TypesMap() map[uint32]string { AccountAcceptAuthorizationRequestTypeID: "account.acceptAuthorization#f3ed4c73", AccountSendVerifyPhoneCodeRequestTypeID: "account.sendVerifyPhoneCode#a5a356f9", AccountVerifyPhoneRequestTypeID: "account.verifyPhone#4dd3a7f6", - AccountSendVerifyEmailCodeRequestTypeID: "account.sendVerifyEmailCode#7011509f", - AccountVerifyEmailRequestTypeID: "account.verifyEmail#ecba39db", + AccountSendVerifyEmailCodeRequestTypeID: "account.sendVerifyEmailCode#98e037bb", + AccountVerifyEmailRequestTypeID: "account.verifyEmail#32da4cf", AccountInitTakeoutSessionRequestTypeID: "account.initTakeoutSession#8ef3eab0", AccountFinishTakeoutSessionRequestTypeID: "account.finishTakeoutSession#1d2652ee", AccountConfirmPasswordEmailRequestTypeID: "account.confirmPasswordEmail#8fdf1920", @@ -1151,6 +1182,10 @@ func TypesMap() map[uint32]string { AccountGetSavedRingtonesRequestTypeID: "account.getSavedRingtones#e1902288", AccountSaveRingtoneRequestTypeID: "account.saveRingtone#3dea5b03", AccountUploadRingtoneRequestTypeID: "account.uploadRingtone#831a83a2", + AccountUpdateEmojiStatusRequestTypeID: "account.updateEmojiStatus#fbd3de6b", + AccountGetDefaultEmojiStatusesRequestTypeID: "account.getDefaultEmojiStatuses#d6753386", + AccountGetRecentEmojiStatusesRequestTypeID: "account.getRecentEmojiStatuses#f578105", + AccountClearRecentEmojiStatusesRequestTypeID: "account.clearRecentEmojiStatuses#18201aae", UsersGetUsersRequestTypeID: "users.getUsers#d91a548", UsersGetFullUserRequestTypeID: "users.getFullUser#b60f5918", UsersSetSecureValueErrorsRequestTypeID: "users.setSecureValueErrors#90c894b5", @@ -1324,12 +1359,12 @@ func TypesMap() map[uint32]string { MessagesHideAllChatJoinRequestsRequestTypeID: "messages.hideAllChatJoinRequests#e085f4ea", MessagesToggleNoForwardsRequestTypeID: "messages.toggleNoForwards#b11eafa2", MessagesSaveDefaultSendAsRequestTypeID: "messages.saveDefaultSendAs#ccfddf96", - MessagesSendReactionRequestTypeID: "messages.sendReaction#25690ce4", + MessagesSendReactionRequestTypeID: "messages.sendReaction#d30d78d4", MessagesGetMessagesReactionsRequestTypeID: "messages.getMessagesReactions#8bba90e6", - MessagesGetMessageReactionsListRequestTypeID: "messages.getMessageReactionsList#e0ee6b77", - MessagesSetChatAvailableReactionsRequestTypeID: "messages.setChatAvailableReactions#14050ea6", + MessagesGetMessageReactionsListRequestTypeID: "messages.getMessageReactionsList#461b3f48", + MessagesSetChatAvailableReactionsRequestTypeID: "messages.setChatAvailableReactions#feb16771", MessagesGetAvailableReactionsRequestTypeID: "messages.getAvailableReactions#18dea0ac", - MessagesSetDefaultReactionRequestTypeID: "messages.setDefaultReaction#d960c4d4", + MessagesSetDefaultReactionRequestTypeID: "messages.setDefaultReaction#4f47a016", MessagesTranslateTextRequestTypeID: "messages.translateText#24ce6dee", MessagesGetUnreadReactionsRequestTypeID: "messages.getUnreadReactions#e85bae1a", MessagesReadReactionsRequestTypeID: "messages.readReactions#82e251d7", @@ -1337,9 +1372,9 @@ func TypesMap() map[uint32]string { MessagesGetAttachMenuBotsRequestTypeID: "messages.getAttachMenuBots#16fcc2cb", MessagesGetAttachMenuBotRequestTypeID: "messages.getAttachMenuBot#77216192", MessagesToggleBotInAttachMenuRequestTypeID: "messages.toggleBotInAttachMenu#1aee33af", - MessagesRequestWebViewRequestTypeID: "messages.requestWebView#91b15831", + MessagesRequestWebViewRequestTypeID: "messages.requestWebView#fc87a53c", MessagesProlongWebViewRequestTypeID: "messages.prolongWebView#ea5fbcce", - MessagesRequestSimpleWebViewRequestTypeID: "messages.requestSimpleWebView#6abb2f73", + MessagesRequestSimpleWebViewRequestTypeID: "messages.requestSimpleWebView#299bec8e", MessagesSendWebViewResultMessageRequestTypeID: "messages.sendWebViewResultMessage#a4314f5", MessagesSendWebViewDataRequestTypeID: "messages.sendWebViewData#dc0242c8", MessagesTranscribeAudioRequestTypeID: "messages.transcribeAudio#269e9a49", @@ -1347,6 +1382,10 @@ func TypesMap() map[uint32]string { MessagesGetCustomEmojiDocumentsRequestTypeID: "messages.getCustomEmojiDocuments#d9ab0f54", MessagesGetEmojiStickersRequestTypeID: "messages.getEmojiStickers#fbfca18f", MessagesGetFeaturedEmojiStickersRequestTypeID: "messages.getFeaturedEmojiStickers#ecf6736", + MessagesReportReactionRequestTypeID: "messages.reportReaction#3f64c076", + MessagesGetTopReactionsRequestTypeID: "messages.getTopReactions#bb8125ba", + MessagesGetRecentReactionsRequestTypeID: "messages.getRecentReactions#39461db2", + MessagesClearRecentReactionsRequestTypeID: "messages.clearRecentReactions#9dfeefb4", UpdatesGetStateRequestTypeID: "updates.getState#edd4882a", UpdatesGetDifferenceRequestTypeID: "updates.getDifference#25939651", UpdatesGetChannelDifferenceRequestTypeID: "updates.getChannelDifference#3173d78", @@ -1446,7 +1485,6 @@ func TypesMap() map[uint32]string { PaymentsAssignAppStoreTransactionRequestTypeID: "payments.assignAppStoreTransaction#80ed747d", PaymentsAssignPlayMarketTransactionRequestTypeID: "payments.assignPlayMarketTransaction#dffd50d3", PaymentsCanPurchasePremiumRequestTypeID: "payments.canPurchasePremium#9fc19eb6", - PaymentsRequestRecurringPaymentRequestTypeID: "payments.requestRecurringPayment#146e958d", StickersCreateStickerSetRequestTypeID: "stickers.createStickerSet#9021ab67", StickersRemoveStickerFromSetRequestTypeID: "stickers.removeStickerFromSet#f7760f51", StickersChangeStickerPositionRequestTypeID: "stickers.changeStickerPosition#ffb6d4ca", @@ -1827,6 +1865,10 @@ func NamesMap() map[string]uint32 { "updateSavedRingtones": UpdateSavedRingtonesTypeID, "updateTranscribedAudio": UpdateTranscribedAudioTypeID, "updateReadFeaturedEmojiStickers": UpdateReadFeaturedEmojiStickersTypeID, + "updateUserEmojiStatus": UpdateUserEmojiStatusTypeID, + "updateRecentEmojiStatuses": UpdateRecentEmojiStatusesTypeID, + "updateRecentReactions": UpdateRecentReactionsTypeID, + "updateMoveStickerSetToTop": UpdateMoveStickerSetToTopTypeID, "updates.state": UpdatesStateTypeID, "updates.differenceEmpty": UpdatesDifferenceEmptyTypeID, "updates.difference": UpdatesDifferenceTypeID, @@ -1969,6 +2011,8 @@ func NamesMap() map[string]uint32 { "inputStickerSetDice": InputStickerSetDiceTypeID, "inputStickerSetAnimatedEmojiAnimations": InputStickerSetAnimatedEmojiAnimationsTypeID, "inputStickerSetPremiumGifts": InputStickerSetPremiumGiftsTypeID, + "inputStickerSetEmojiGenericAnimations": InputStickerSetEmojiGenericAnimationsTypeID, + "inputStickerSetEmojiDefaultStatuses": InputStickerSetEmojiDefaultStatusesTypeID, "stickerSet": StickerSetTypeID, "messages.stickerSet": MessagesStickerSetTypeID, "messages.stickerSetNotModified": MessagesStickerSetNotModifiedTypeID, @@ -2076,6 +2120,8 @@ func NamesMap() map[string]uint32 { "auth.sentCodeTypeCall": AuthSentCodeTypeCallTypeID, "auth.sentCodeTypeFlashCall": AuthSentCodeTypeFlashCallTypeID, "auth.sentCodeTypeMissedCall": AuthSentCodeTypeMissedCallTypeID, + "auth.sentCodeTypeEmailCode": AuthSentCodeTypeEmailCodeTypeID, + "auth.sentCodeTypeSetUpEmailRequired": AuthSentCodeTypeSetUpEmailRequiredTypeID, "messages.botCallbackAnswer": MessagesBotCallbackAnswerTypeID, "messages.messageEditData": MessagesMessageEditDataTypeID, "inputBotInlineMessageID": InputBotInlineMessageIDTypeID, @@ -2528,6 +2574,29 @@ func NamesMap() map[string]uint32 { "inputStorePaymentGiftPremium": InputStorePaymentGiftPremiumTypeID, "premiumGiftOption": PremiumGiftOptionTypeID, "paymentFormMethod": PaymentFormMethodTypeID, + "emojiStatusEmpty": EmojiStatusEmptyTypeID, + "emojiStatus": EmojiStatusTypeID, + "emojiStatusUntil": EmojiStatusUntilTypeID, + "account.emojiStatusesNotModified": AccountEmojiStatusesNotModifiedTypeID, + "account.emojiStatuses": AccountEmojiStatusesTypeID, + "reactionEmpty": ReactionEmptyTypeID, + "reactionEmoji": ReactionEmojiTypeID, + "reactionCustomEmoji": ReactionCustomEmojiTypeID, + "chatReactionsNone": ChatReactionsNoneTypeID, + "chatReactionsAll": ChatReactionsAllTypeID, + "chatReactionsSome": ChatReactionsSomeTypeID, + "messages.reactionsNotModified": MessagesReactionsNotModifiedTypeID, + "messages.reactions": MessagesReactionsTypeID, + "emailVerifyPurposeLoginSetup": EmailVerifyPurposeLoginSetupTypeID, + "emailVerifyPurposeLoginChange": EmailVerifyPurposeLoginChangeTypeID, + "emailVerifyPurposePassport": EmailVerifyPurposePassportTypeID, + "emailVerificationCode": EmailVerificationCodeTypeID, + "emailVerificationGoogle": EmailVerificationGoogleTypeID, + "emailVerificationApple": EmailVerificationAppleTypeID, + "account.emailVerified": AccountEmailVerifiedTypeID, + "account.emailVerifiedLogin": AccountEmailVerifiedLoginTypeID, + "premiumSubscriptionOption": PremiumSubscriptionOptionTypeID, + "sendAsPeer": SendAsPeerTypeID, "invokeAfterMsg": InvokeAfterMsgRequestTypeID, "invokeAfterMsgs": InvokeAfterMsgsRequestTypeID, "initConnection": InitConnectionRequestTypeID, @@ -2630,6 +2699,10 @@ func NamesMap() map[string]uint32 { "account.getSavedRingtones": AccountGetSavedRingtonesRequestTypeID, "account.saveRingtone": AccountSaveRingtoneRequestTypeID, "account.uploadRingtone": AccountUploadRingtoneRequestTypeID, + "account.updateEmojiStatus": AccountUpdateEmojiStatusRequestTypeID, + "account.getDefaultEmojiStatuses": AccountGetDefaultEmojiStatusesRequestTypeID, + "account.getRecentEmojiStatuses": AccountGetRecentEmojiStatusesRequestTypeID, + "account.clearRecentEmojiStatuses": AccountClearRecentEmojiStatusesRequestTypeID, "users.getUsers": UsersGetUsersRequestTypeID, "users.getFullUser": UsersGetFullUserRequestTypeID, "users.setSecureValueErrors": UsersSetSecureValueErrorsRequestTypeID, @@ -2826,6 +2899,10 @@ func NamesMap() map[string]uint32 { "messages.getCustomEmojiDocuments": MessagesGetCustomEmojiDocumentsRequestTypeID, "messages.getEmojiStickers": MessagesGetEmojiStickersRequestTypeID, "messages.getFeaturedEmojiStickers": MessagesGetFeaturedEmojiStickersRequestTypeID, + "messages.reportReaction": MessagesReportReactionRequestTypeID, + "messages.getTopReactions": MessagesGetTopReactionsRequestTypeID, + "messages.getRecentReactions": MessagesGetRecentReactionsRequestTypeID, + "messages.clearRecentReactions": MessagesClearRecentReactionsRequestTypeID, "updates.getState": UpdatesGetStateRequestTypeID, "updates.getDifference": UpdatesGetDifferenceRequestTypeID, "updates.getChannelDifference": UpdatesGetChannelDifferenceRequestTypeID, @@ -2925,7 +3002,6 @@ func NamesMap() map[string]uint32 { "payments.assignAppStoreTransaction": PaymentsAssignAppStoreTransactionRequestTypeID, "payments.assignPlayMarketTransaction": PaymentsAssignPlayMarketTransactionRequestTypeID, "payments.canPurchasePremium": PaymentsCanPurchasePremiumRequestTypeID, - "payments.requestRecurringPayment": PaymentsRequestRecurringPaymentRequestTypeID, "stickers.createStickerSet": StickersCreateStickerSetRequestTypeID, "stickers.removeStickerFromSet": StickersRemoveStickerFromSetRequestTypeID, "stickers.changeStickerPosition": StickersChangeStickerPositionRequestTypeID, @@ -3306,6 +3382,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UpdateSavedRingtonesTypeID: func() bin.Object { return &UpdateSavedRingtones{} }, UpdateTranscribedAudioTypeID: func() bin.Object { return &UpdateTranscribedAudio{} }, UpdateReadFeaturedEmojiStickersTypeID: func() bin.Object { return &UpdateReadFeaturedEmojiStickers{} }, + UpdateUserEmojiStatusTypeID: func() bin.Object { return &UpdateUserEmojiStatus{} }, + UpdateRecentEmojiStatusesTypeID: func() bin.Object { return &UpdateRecentEmojiStatuses{} }, + UpdateRecentReactionsTypeID: func() bin.Object { return &UpdateRecentReactions{} }, + UpdateMoveStickerSetToTopTypeID: func() bin.Object { return &UpdateMoveStickerSetToTop{} }, UpdatesStateTypeID: func() bin.Object { return &UpdatesState{} }, UpdatesDifferenceEmptyTypeID: func() bin.Object { return &UpdatesDifferenceEmpty{} }, UpdatesDifferenceTypeID: func() bin.Object { return &UpdatesDifference{} }, @@ -3448,6 +3528,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputStickerSetDiceTypeID: func() bin.Object { return &InputStickerSetDice{} }, InputStickerSetAnimatedEmojiAnimationsTypeID: func() bin.Object { return &InputStickerSetAnimatedEmojiAnimations{} }, InputStickerSetPremiumGiftsTypeID: func() bin.Object { return &InputStickerSetPremiumGifts{} }, + InputStickerSetEmojiGenericAnimationsTypeID: func() bin.Object { return &InputStickerSetEmojiGenericAnimations{} }, + InputStickerSetEmojiDefaultStatusesTypeID: func() bin.Object { return &InputStickerSetEmojiDefaultStatuses{} }, StickerSetTypeID: func() bin.Object { return &StickerSet{} }, MessagesStickerSetTypeID: func() bin.Object { return &MessagesStickerSet{} }, MessagesStickerSetNotModifiedTypeID: func() bin.Object { return &MessagesStickerSetNotModified{} }, @@ -3555,6 +3637,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { AuthSentCodeTypeCallTypeID: func() bin.Object { return &AuthSentCodeTypeCall{} }, AuthSentCodeTypeFlashCallTypeID: func() bin.Object { return &AuthSentCodeTypeFlashCall{} }, AuthSentCodeTypeMissedCallTypeID: func() bin.Object { return &AuthSentCodeTypeMissedCall{} }, + AuthSentCodeTypeEmailCodeTypeID: func() bin.Object { return &AuthSentCodeTypeEmailCode{} }, + AuthSentCodeTypeSetUpEmailRequiredTypeID: func() bin.Object { return &AuthSentCodeTypeSetUpEmailRequired{} }, MessagesBotCallbackAnswerTypeID: func() bin.Object { return &MessagesBotCallbackAnswer{} }, MessagesMessageEditDataTypeID: func() bin.Object { return &MessagesMessageEditData{} }, InputBotInlineMessageIDTypeID: func() bin.Object { return &InputBotInlineMessageID{} }, @@ -4007,6 +4091,29 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputStorePaymentGiftPremiumTypeID: func() bin.Object { return &InputStorePaymentGiftPremium{} }, PremiumGiftOptionTypeID: func() bin.Object { return &PremiumGiftOption{} }, PaymentFormMethodTypeID: func() bin.Object { return &PaymentFormMethod{} }, + EmojiStatusEmptyTypeID: func() bin.Object { return &EmojiStatusEmpty{} }, + EmojiStatusTypeID: func() bin.Object { return &EmojiStatus{} }, + EmojiStatusUntilTypeID: func() bin.Object { return &EmojiStatusUntil{} }, + AccountEmojiStatusesNotModifiedTypeID: func() bin.Object { return &AccountEmojiStatusesNotModified{} }, + AccountEmojiStatusesTypeID: func() bin.Object { return &AccountEmojiStatuses{} }, + ReactionEmptyTypeID: func() bin.Object { return &ReactionEmpty{} }, + ReactionEmojiTypeID: func() bin.Object { return &ReactionEmoji{} }, + ReactionCustomEmojiTypeID: func() bin.Object { return &ReactionCustomEmoji{} }, + ChatReactionsNoneTypeID: func() bin.Object { return &ChatReactionsNone{} }, + ChatReactionsAllTypeID: func() bin.Object { return &ChatReactionsAll{} }, + ChatReactionsSomeTypeID: func() bin.Object { return &ChatReactionsSome{} }, + MessagesReactionsNotModifiedTypeID: func() bin.Object { return &MessagesReactionsNotModified{} }, + MessagesReactionsTypeID: func() bin.Object { return &MessagesReactions{} }, + EmailVerifyPurposeLoginSetupTypeID: func() bin.Object { return &EmailVerifyPurposeLoginSetup{} }, + EmailVerifyPurposeLoginChangeTypeID: func() bin.Object { return &EmailVerifyPurposeLoginChange{} }, + EmailVerifyPurposePassportTypeID: func() bin.Object { return &EmailVerifyPurposePassport{} }, + EmailVerificationCodeTypeID: func() bin.Object { return &EmailVerificationCode{} }, + EmailVerificationGoogleTypeID: func() bin.Object { return &EmailVerificationGoogle{} }, + EmailVerificationAppleTypeID: func() bin.Object { return &EmailVerificationApple{} }, + AccountEmailVerifiedTypeID: func() bin.Object { return &AccountEmailVerified{} }, + AccountEmailVerifiedLoginTypeID: func() bin.Object { return &AccountEmailVerifiedLogin{} }, + PremiumSubscriptionOptionTypeID: func() bin.Object { return &PremiumSubscriptionOption{} }, + SendAsPeerTypeID: func() bin.Object { return &SendAsPeer{} }, InvokeAfterMsgRequestTypeID: func() bin.Object { return &InvokeAfterMsgRequest{} }, InvokeAfterMsgsRequestTypeID: func() bin.Object { return &InvokeAfterMsgsRequest{} }, InitConnectionRequestTypeID: func() bin.Object { return &InitConnectionRequest{} }, @@ -4109,6 +4216,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { AccountGetSavedRingtonesRequestTypeID: func() bin.Object { return &AccountGetSavedRingtonesRequest{} }, AccountSaveRingtoneRequestTypeID: func() bin.Object { return &AccountSaveRingtoneRequest{} }, AccountUploadRingtoneRequestTypeID: func() bin.Object { return &AccountUploadRingtoneRequest{} }, + AccountUpdateEmojiStatusRequestTypeID: func() bin.Object { return &AccountUpdateEmojiStatusRequest{} }, + AccountGetDefaultEmojiStatusesRequestTypeID: func() bin.Object { return &AccountGetDefaultEmojiStatusesRequest{} }, + AccountGetRecentEmojiStatusesRequestTypeID: func() bin.Object { return &AccountGetRecentEmojiStatusesRequest{} }, + AccountClearRecentEmojiStatusesRequestTypeID: func() bin.Object { return &AccountClearRecentEmojiStatusesRequest{} }, UsersGetUsersRequestTypeID: func() bin.Object { return &UsersGetUsersRequest{} }, UsersGetFullUserRequestTypeID: func() bin.Object { return &UsersGetFullUserRequest{} }, UsersSetSecureValueErrorsRequestTypeID: func() bin.Object { return &UsersSetSecureValueErrorsRequest{} }, @@ -4305,6 +4416,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessagesGetCustomEmojiDocumentsRequestTypeID: func() bin.Object { return &MessagesGetCustomEmojiDocumentsRequest{} }, MessagesGetEmojiStickersRequestTypeID: func() bin.Object { return &MessagesGetEmojiStickersRequest{} }, MessagesGetFeaturedEmojiStickersRequestTypeID: func() bin.Object { return &MessagesGetFeaturedEmojiStickersRequest{} }, + MessagesReportReactionRequestTypeID: func() bin.Object { return &MessagesReportReactionRequest{} }, + MessagesGetTopReactionsRequestTypeID: func() bin.Object { return &MessagesGetTopReactionsRequest{} }, + MessagesGetRecentReactionsRequestTypeID: func() bin.Object { return &MessagesGetRecentReactionsRequest{} }, + MessagesClearRecentReactionsRequestTypeID: func() bin.Object { return &MessagesClearRecentReactionsRequest{} }, UpdatesGetStateRequestTypeID: func() bin.Object { return &UpdatesGetStateRequest{} }, UpdatesGetDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetDifferenceRequest{} }, UpdatesGetChannelDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetChannelDifferenceRequest{} }, @@ -4404,7 +4519,6 @@ func TypesConstructorMap() map[uint32]func() bin.Object { PaymentsAssignAppStoreTransactionRequestTypeID: func() bin.Object { return &PaymentsAssignAppStoreTransactionRequest{} }, PaymentsAssignPlayMarketTransactionRequestTypeID: func() bin.Object { return &PaymentsAssignPlayMarketTransactionRequest{} }, PaymentsCanPurchasePremiumRequestTypeID: func() bin.Object { return &PaymentsCanPurchasePremiumRequest{} }, - PaymentsRequestRecurringPaymentRequestTypeID: func() bin.Object { return &PaymentsRequestRecurringPaymentRequest{} }, StickersCreateStickerSetRequestTypeID: func() bin.Object { return &StickersCreateStickerSetRequest{} }, StickersRemoveStickerFromSetRequestTypeID: func() bin.Object { return &StickersRemoveStickerFromSetRequest{} }, StickersChangeStickerPositionRequestTypeID: func() bin.Object { return &StickersChangeStickerPositionRequest{} }, @@ -4474,6 +4588,14 @@ func TypesConstructorMap() map[uint32]func() bin.Object { // ClassConstructorsMap maps class schema name to constructors type ids. func ClassConstructorsMap() map[string][]uint32 { return map[string][]uint32{ + AccountEmailVerifiedClassName: { + AccountEmailVerifiedTypeID, + AccountEmailVerifiedLoginTypeID, + }, + AccountEmojiStatusesClassName: { + AccountEmojiStatusesNotModifiedTypeID, + AccountEmojiStatusesTypeID, + }, AccountResetPasswordResultClassName: { AccountResetPasswordFailedWaitTypeID, AccountResetPasswordRequestedWaitTypeID, @@ -4527,6 +4649,8 @@ func ClassConstructorsMap() map[string][]uint32 { AuthSentCodeTypeCallTypeID, AuthSentCodeTypeFlashCallTypeID, AuthSentCodeTypeMissedCallTypeID, + AuthSentCodeTypeEmailCodeTypeID, + AuthSentCodeTypeSetUpEmailRequiredTypeID, }, BaseThemeClassName: { BaseThemeClassicTypeID, @@ -4662,6 +4786,11 @@ func ClassConstructorsMap() map[string][]uint32 { ChatPhotoEmptyTypeID, ChatPhotoTypeID, }, + ChatReactionsClassName: { + ChatReactionsNoneTypeID, + ChatReactionsAllTypeID, + ChatReactionsSomeTypeID, + }, ContactsBlockedClassName: { ContactsBlockedTypeID, ContactsBlockedSliceTypeID, @@ -4705,10 +4834,25 @@ func ClassConstructorsMap() map[string][]uint32 { DraftMessageEmptyTypeID, DraftMessageTypeID, }, + EmailVerificationClassName: { + EmailVerificationCodeTypeID, + EmailVerificationGoogleTypeID, + EmailVerificationAppleTypeID, + }, + EmailVerifyPurposeClassName: { + EmailVerifyPurposeLoginSetupTypeID, + EmailVerifyPurposeLoginChangeTypeID, + EmailVerifyPurposePassportTypeID, + }, EmojiKeywordClassName: { EmojiKeywordTypeID, EmojiKeywordDeletedTypeID, }, + EmojiStatusClassName: { + EmojiStatusEmptyTypeID, + EmojiStatusTypeID, + EmojiStatusUntilTypeID, + }, EncryptedChatClassName: { EncryptedChatEmptyTypeID, EncryptedChatWaitingTypeID, @@ -4933,6 +5077,8 @@ func ClassConstructorsMap() map[string][]uint32 { InputStickerSetDiceTypeID, InputStickerSetAnimatedEmojiAnimationsTypeID, InputStickerSetPremiumGiftsTypeID, + InputStickerSetEmojiGenericAnimationsTypeID, + InputStickerSetEmojiDefaultStatusesTypeID, }, InputStickeredMediaClassName: { InputStickeredMediaPhotoTypeID, @@ -5137,6 +5283,10 @@ func ClassConstructorsMap() map[string][]uint32 { MessagesChannelMessagesTypeID, MessagesMessagesNotModifiedTypeID, }, + MessagesReactionsClassName: { + MessagesReactionsNotModifiedTypeID, + MessagesReactionsTypeID, + }, MessagesRecentStickersClassName: { MessagesRecentStickersNotModifiedTypeID, MessagesRecentStickersTypeID, @@ -5288,6 +5438,11 @@ func ClassConstructorsMap() map[string][]uint32 { PrivacyValueAllowChatParticipantsTypeID, PrivacyValueDisallowChatParticipantsTypeID, }, + ReactionClassName: { + ReactionEmptyTypeID, + ReactionEmojiTypeID, + ReactionCustomEmojiTypeID, + }, RecentMeURLClassName: { RecentMeURLUnknownTypeID, RecentMeURLUserTypeID, @@ -5534,6 +5689,10 @@ func ClassConstructorsMap() map[string][]uint32 { UpdateSavedRingtonesTypeID, UpdateTranscribedAudioTypeID, UpdateReadFeaturedEmojiStickersTypeID, + UpdateUserEmojiStatusTypeID, + UpdateRecentEmojiStatusesTypeID, + UpdateRecentReactionsTypeID, + UpdateMoveStickerSetToTopTypeID, }, UpdatesChannelDifferenceClassName: { UpdatesChannelDifferenceEmptyTypeID, diff --git a/tg/tl_send_as_peer_gen.go b/tg/tl_send_as_peer_gen.go new file mode 100644 index 0000000000..2a5cf2b356 --- /dev/null +++ b/tg/tl_send_as_peer_gen.go @@ -0,0 +1,219 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// SendAsPeer represents TL type `sendAsPeer#b81c7034`. +// +// See https://core.telegram.org/constructor/sendAsPeer for reference. +type SendAsPeer struct { + // Flags field of SendAsPeer. + Flags bin.Fields + // PremiumRequired field of SendAsPeer. + PremiumRequired bool + // Peer field of SendAsPeer. + Peer PeerClass +} + +// SendAsPeerTypeID is TL type id of SendAsPeer. +const SendAsPeerTypeID = 0xb81c7034 + +// Ensuring interfaces in compile-time for SendAsPeer. +var ( + _ bin.Encoder = &SendAsPeer{} + _ bin.Decoder = &SendAsPeer{} + _ bin.BareEncoder = &SendAsPeer{} + _ bin.BareDecoder = &SendAsPeer{} +) + +func (s *SendAsPeer) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.PremiumRequired == false) { + return false + } + if !(s.Peer == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *SendAsPeer) String() string { + if s == nil { + return "SendAsPeer(nil)" + } + type Alias SendAsPeer + return fmt.Sprintf("SendAsPeer%+v", Alias(*s)) +} + +// FillFrom fills SendAsPeer from given interface. +func (s *SendAsPeer) FillFrom(from interface { + GetPremiumRequired() (value bool) + GetPeer() (value PeerClass) +}) { + s.PremiumRequired = from.GetPremiumRequired() + s.Peer = from.GetPeer() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*SendAsPeer) TypeID() uint32 { + return SendAsPeerTypeID +} + +// TypeName returns name of type in TL schema. +func (*SendAsPeer) TypeName() string { + return "sendAsPeer" +} + +// TypeInfo returns info about TL type. +func (s *SendAsPeer) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "sendAsPeer", + ID: SendAsPeerTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "PremiumRequired", + SchemaName: "premium_required", + Null: !s.Flags.Has(0), + }, + { + Name: "Peer", + SchemaName: "peer", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *SendAsPeer) SetFlags() { + if !(s.PremiumRequired == false) { + s.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (s *SendAsPeer) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode sendAsPeer#b81c7034 as nil") + } + b.PutID(SendAsPeerTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *SendAsPeer) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode sendAsPeer#b81c7034 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode sendAsPeer#b81c7034: field flags: %w", err) + } + if s.Peer == nil { + return fmt.Errorf("unable to encode sendAsPeer#b81c7034: field peer is nil") + } + if err := s.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode sendAsPeer#b81c7034: field peer: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *SendAsPeer) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode sendAsPeer#b81c7034 to nil") + } + if err := b.ConsumeID(SendAsPeerTypeID); err != nil { + return fmt.Errorf("unable to decode sendAsPeer#b81c7034: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *SendAsPeer) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode sendAsPeer#b81c7034 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode sendAsPeer#b81c7034: field flags: %w", err) + } + } + s.PremiumRequired = s.Flags.Has(0) + { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode sendAsPeer#b81c7034: field peer: %w", err) + } + s.Peer = value + } + return nil +} + +// SetPremiumRequired sets value of PremiumRequired conditional field. +func (s *SendAsPeer) SetPremiumRequired(value bool) { + if value { + s.Flags.Set(0) + s.PremiumRequired = true + } else { + s.Flags.Unset(0) + s.PremiumRequired = false + } +} + +// GetPremiumRequired returns value of PremiumRequired conditional field. +func (s *SendAsPeer) GetPremiumRequired() (value bool) { + if s == nil { + return + } + return s.Flags.Has(0) +} + +// GetPeer returns value of Peer field. +func (s *SendAsPeer) GetPeer() (value PeerClass) { + if s == nil { + return + } + return s.Peer +} diff --git a/tg/tl_send_as_peer_slices_gen.go b/tg/tl_send_as_peer_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_send_as_peer_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_server_gen.go b/tg/tl_server_gen.go index bf781d6cd2..a486093c01 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -1118,14 +1118,14 @@ func (s *ServerDispatcher) OnAccountVerifyPhone(f func(ctx context.Context, requ s.handlers[AccountVerifyPhoneRequestTypeID] = handler } -func (s *ServerDispatcher) OnAccountSendVerifyEmailCode(f func(ctx context.Context, email string) (*AccountSentEmailCode, error)) { +func (s *ServerDispatcher) OnAccountSendVerifyEmailCode(f func(ctx context.Context, request *AccountSendVerifyEmailCodeRequest) (*AccountSentEmailCode, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request AccountSendVerifyEmailCodeRequest if err := request.Decode(b); err != nil { return nil, err } - response, err := f(ctx, request.Email) + response, err := f(ctx, &request) if err != nil { return nil, err } @@ -1135,7 +1135,7 @@ func (s *ServerDispatcher) OnAccountSendVerifyEmailCode(f func(ctx context.Conte s.handlers[AccountSendVerifyEmailCodeRequestTypeID] = handler } -func (s *ServerDispatcher) OnAccountVerifyEmail(f func(ctx context.Context, request *AccountVerifyEmailRequest) (bool, error)) { +func (s *ServerDispatcher) OnAccountVerifyEmail(f func(ctx context.Context, request *AccountVerifyEmailRequest) (AccountEmailVerifiedClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request AccountVerifyEmailRequest if err := request.Decode(b); err != nil { @@ -1146,11 +1146,7 @@ func (s *ServerDispatcher) OnAccountVerifyEmail(f func(ctx context.Context, requ if err != nil { return nil, err } - if response { - return &BoolBox{Bool: &BoolTrue{}}, nil - } - - return &BoolBox{Bool: &BoolFalse{}}, nil + return &AccountEmailVerifiedBox{EmailVerified: response}, nil } s.handlers[AccountVerifyEmailRequestTypeID] = handler @@ -1836,6 +1832,82 @@ func (s *ServerDispatcher) OnAccountUploadRingtone(f func(ctx context.Context, r s.handlers[AccountUploadRingtoneRequestTypeID] = handler } +func (s *ServerDispatcher) OnAccountUpdateEmojiStatus(f func(ctx context.Context, emojistatus EmojiStatusClass) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountUpdateEmojiStatusRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.EmojiStatus) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[AccountUpdateEmojiStatusRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnAccountGetDefaultEmojiStatuses(f func(ctx context.Context, hash int64) (AccountEmojiStatusesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountGetDefaultEmojiStatusesRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Hash) + if err != nil { + return nil, err + } + return &AccountEmojiStatusesBox{EmojiStatuses: response}, nil + } + + s.handlers[AccountGetDefaultEmojiStatusesRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnAccountGetRecentEmojiStatuses(f func(ctx context.Context, hash int64) (AccountEmojiStatusesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountGetRecentEmojiStatusesRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Hash) + if err != nil { + return nil, err + } + return &AccountEmojiStatusesBox{EmojiStatuses: response}, nil + } + + s.handlers[AccountGetRecentEmojiStatusesRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnAccountClearRecentEmojiStatuses(f func(ctx context.Context) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountClearRecentEmojiStatusesRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[AccountClearRecentEmojiStatusesRequestTypeID] = handler +} + func (s *ServerDispatcher) OnUsersGetUsers(f func(ctx context.Context, id []InputUserClass) ([]UserClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request UsersGetUsersRequest @@ -5038,7 +5110,7 @@ func (s *ServerDispatcher) OnMessagesGetAvailableReactions(f func(ctx context.Co s.handlers[MessagesGetAvailableReactionsRequestTypeID] = handler } -func (s *ServerDispatcher) OnMessagesSetDefaultReaction(f func(ctx context.Context, reaction string) (bool, error)) { +func (s *ServerDispatcher) OnMessagesSetDefaultReaction(f func(ctx context.Context, reaction ReactionClass) (bool, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request MessagesSetDefaultReactionRequest if err := request.Decode(b); err != nil { @@ -5360,6 +5432,82 @@ func (s *ServerDispatcher) OnMessagesGetFeaturedEmojiStickers(f func(ctx context s.handlers[MessagesGetFeaturedEmojiStickersRequestTypeID] = handler } +func (s *ServerDispatcher) OnMessagesReportReaction(f func(ctx context.Context, request *MessagesReportReactionRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesReportReactionRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[MessagesReportReactionRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesGetTopReactions(f func(ctx context.Context, request *MessagesGetTopReactionsRequest) (MessagesReactionsClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesGetTopReactionsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &MessagesReactionsBox{Reactions: response}, nil + } + + s.handlers[MessagesGetTopReactionsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesGetRecentReactions(f func(ctx context.Context, request *MessagesGetRecentReactionsRequest) (MessagesReactionsClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesGetRecentReactionsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &MessagesReactionsBox{Reactions: response}, nil + } + + s.handlers[MessagesGetRecentReactionsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesClearRecentReactions(f func(ctx context.Context) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesClearRecentReactionsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[MessagesClearRecentReactionsRequestTypeID] = handler +} + func (s *ServerDispatcher) OnUpdatesGetState(f func(ctx context.Context) (*UpdatesState, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request UpdatesGetStateRequest @@ -7139,23 +7287,6 @@ func (s *ServerDispatcher) OnPaymentsCanPurchasePremium(f func(ctx context.Conte s.handlers[PaymentsCanPurchasePremiumRequestTypeID] = handler } -func (s *ServerDispatcher) OnPaymentsRequestRecurringPayment(f func(ctx context.Context, request *PaymentsRequestRecurringPaymentRequest) (UpdatesClass, error)) { - handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { - var request PaymentsRequestRecurringPaymentRequest - if err := request.Decode(b); err != nil { - return nil, err - } - - response, err := f(ctx, &request) - if err != nil { - return nil, err - } - return &UpdatesBox{Updates: response}, nil - } - - s.handlers[PaymentsRequestRecurringPaymentRequestTypeID] = handler -} - func (s *ServerDispatcher) OnStickersCreateStickerSet(f func(ctx context.Context, request *StickersCreateStickerSetRequest) (MessagesStickerSetClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request StickersCreateStickerSetRequest diff --git a/tg/tl_update_gen.go b/tg/tl_update_gen.go index f1081be1f6..a1abaa42bd 100644 --- a/tg/tl_update_gen.go +++ b/tg/tl_update_gen.go @@ -6692,7 +6692,7 @@ func (u *UpdateStickerSetsOrder) GetOrder() (value []int64) { return u.Order } -// UpdateStickerSets represents TL type `updateStickerSets#43ae3dec`. +// UpdateStickerSets represents TL type `updateStickerSets#31c24808`. // Installed stickersets have changed, the client should refetch them using messages // getAllStickers¹ // @@ -6701,10 +6701,16 @@ func (u *UpdateStickerSetsOrder) GetOrder() (value []int64) { // // See https://core.telegram.org/constructor/updateStickerSets for reference. type UpdateStickerSets struct { + // Flags field of UpdateStickerSets. + Flags bin.Fields + // Masks field of UpdateStickerSets. + Masks bool + // Emojis field of UpdateStickerSets. + Emojis bool } // UpdateStickerSetsTypeID is TL type id of UpdateStickerSets. -const UpdateStickerSetsTypeID = 0x43ae3dec +const UpdateStickerSetsTypeID = 0x31c24808 // construct implements constructor of UpdateClass. func (u UpdateStickerSets) construct() UpdateClass { return &u } @@ -6723,6 +6729,15 @@ func (u *UpdateStickerSets) Zero() bool { if u == nil { return true } + if !(u.Flags.Zero()) { + return false + } + if !(u.Masks == false) { + return false + } + if !(u.Emojis == false) { + return false + } return true } @@ -6736,6 +6751,15 @@ func (u *UpdateStickerSets) String() string { return fmt.Sprintf("UpdateStickerSets%+v", Alias(*u)) } +// FillFrom fills UpdateStickerSets from given interface. +func (u *UpdateStickerSets) FillFrom(from interface { + GetMasks() (value bool) + GetEmojis() (value bool) +}) { + u.Masks = from.GetMasks() + u.Emojis = from.GetEmojis() +} + // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. @@ -6758,14 +6782,35 @@ func (u *UpdateStickerSets) TypeInfo() tdp.Type { typ.Null = true return typ } - typ.Fields = []tdp.Field{} + typ.Fields = []tdp.Field{ + { + Name: "Masks", + SchemaName: "masks", + Null: !u.Flags.Has(0), + }, + { + Name: "Emojis", + SchemaName: "emojis", + Null: !u.Flags.Has(1), + }, + } return typ } +// SetFlags sets flags for non-zero fields. +func (u *UpdateStickerSets) SetFlags() { + if !(u.Masks == false) { + u.Flags.Set(0) + } + if !(u.Emojis == false) { + u.Flags.Set(1) + } +} + // Encode implements bin.Encoder. func (u *UpdateStickerSets) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateStickerSets#43ae3dec as nil") + return fmt.Errorf("can't encode updateStickerSets#31c24808 as nil") } b.PutID(UpdateStickerSetsTypeID) return u.EncodeBare(b) @@ -6774,7 +6819,11 @@ func (u *UpdateStickerSets) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UpdateStickerSets) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateStickerSets#43ae3dec as nil") + return fmt.Errorf("can't encode updateStickerSets#31c24808 as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateStickerSets#31c24808: field flags: %w", err) } return nil } @@ -6782,10 +6831,10 @@ func (u *UpdateStickerSets) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (u *UpdateStickerSets) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateStickerSets#43ae3dec to nil") + return fmt.Errorf("can't decode updateStickerSets#31c24808 to nil") } if err := b.ConsumeID(UpdateStickerSetsTypeID); err != nil { - return fmt.Errorf("unable to decode updateStickerSets#43ae3dec: %w", err) + return fmt.Errorf("unable to decode updateStickerSets#31c24808: %w", err) } return u.DecodeBare(b) } @@ -6793,11 +6842,56 @@ func (u *UpdateStickerSets) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UpdateStickerSets) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateStickerSets#43ae3dec to nil") + return fmt.Errorf("can't decode updateStickerSets#31c24808 to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateStickerSets#31c24808: field flags: %w", err) + } } + u.Masks = u.Flags.Has(0) + u.Emojis = u.Flags.Has(1) return nil } +// SetMasks sets value of Masks conditional field. +func (u *UpdateStickerSets) SetMasks(value bool) { + if value { + u.Flags.Set(0) + u.Masks = true + } else { + u.Flags.Unset(0) + u.Masks = false + } +} + +// GetMasks returns value of Masks conditional field. +func (u *UpdateStickerSets) GetMasks() (value bool) { + if u == nil { + return + } + return u.Flags.Has(0) +} + +// SetEmojis sets value of Emojis conditional field. +func (u *UpdateStickerSets) SetEmojis(value bool) { + if value { + u.Flags.Set(1) + u.Emojis = true + } else { + u.Flags.Unset(1) + u.Emojis = false + } +} + +// GetEmojis returns value of Emojis conditional field. +func (u *UpdateStickerSets) GetEmojis() (value bool) { + if u == nil { + return + } + return u.Flags.Has(1) +} + // UpdateSavedGifs represents TL type `updateSavedGifs#9375341e`. // The saved gif list has changed, the client should refetch it using messages // getSavedGifs¹ @@ -20369,6 +20463,596 @@ func (u *UpdateReadFeaturedEmojiStickers) DecodeBare(b *bin.Buffer) error { return nil } +// UpdateUserEmojiStatus represents TL type `updateUserEmojiStatus#28373599`. +// +// See https://core.telegram.org/constructor/updateUserEmojiStatus for reference. +type UpdateUserEmojiStatus struct { + // UserID field of UpdateUserEmojiStatus. + UserID int64 + // EmojiStatus field of UpdateUserEmojiStatus. + EmojiStatus EmojiStatusClass +} + +// UpdateUserEmojiStatusTypeID is TL type id of UpdateUserEmojiStatus. +const UpdateUserEmojiStatusTypeID = 0x28373599 + +// construct implements constructor of UpdateClass. +func (u UpdateUserEmojiStatus) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateUserEmojiStatus. +var ( + _ bin.Encoder = &UpdateUserEmojiStatus{} + _ bin.Decoder = &UpdateUserEmojiStatus{} + _ bin.BareEncoder = &UpdateUserEmojiStatus{} + _ bin.BareDecoder = &UpdateUserEmojiStatus{} + + _ UpdateClass = &UpdateUserEmojiStatus{} +) + +func (u *UpdateUserEmojiStatus) Zero() bool { + if u == nil { + return true + } + if !(u.UserID == 0) { + return false + } + if !(u.EmojiStatus == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateUserEmojiStatus) String() string { + if u == nil { + return "UpdateUserEmojiStatus(nil)" + } + type Alias UpdateUserEmojiStatus + return fmt.Sprintf("UpdateUserEmojiStatus%+v", Alias(*u)) +} + +// FillFrom fills UpdateUserEmojiStatus from given interface. +func (u *UpdateUserEmojiStatus) FillFrom(from interface { + GetUserID() (value int64) + GetEmojiStatus() (value EmojiStatusClass) +}) { + u.UserID = from.GetUserID() + u.EmojiStatus = from.GetEmojiStatus() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateUserEmojiStatus) TypeID() uint32 { + return UpdateUserEmojiStatusTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateUserEmojiStatus) TypeName() string { + return "updateUserEmojiStatus" +} + +// TypeInfo returns info about TL type. +func (u *UpdateUserEmojiStatus) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateUserEmojiStatus", + ID: UpdateUserEmojiStatusTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "EmojiStatus", + SchemaName: "emoji_status", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateUserEmojiStatus) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateUserEmojiStatus#28373599 as nil") + } + b.PutID(UpdateUserEmojiStatusTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateUserEmojiStatus) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateUserEmojiStatus#28373599 as nil") + } + b.PutLong(u.UserID) + if u.EmojiStatus == nil { + return fmt.Errorf("unable to encode updateUserEmojiStatus#28373599: field emoji_status is nil") + } + if err := u.EmojiStatus.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateUserEmojiStatus#28373599: field emoji_status: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateUserEmojiStatus) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateUserEmojiStatus#28373599 to nil") + } + if err := b.ConsumeID(UpdateUserEmojiStatusTypeID); err != nil { + return fmt.Errorf("unable to decode updateUserEmojiStatus#28373599: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateUserEmojiStatus) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateUserEmojiStatus#28373599 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateUserEmojiStatus#28373599: field user_id: %w", err) + } + u.UserID = value + } + { + value, err := DecodeEmojiStatus(b) + if err != nil { + return fmt.Errorf("unable to decode updateUserEmojiStatus#28373599: field emoji_status: %w", err) + } + u.EmojiStatus = value + } + return nil +} + +// GetUserID returns value of UserID field. +func (u *UpdateUserEmojiStatus) GetUserID() (value int64) { + if u == nil { + return + } + return u.UserID +} + +// GetEmojiStatus returns value of EmojiStatus field. +func (u *UpdateUserEmojiStatus) GetEmojiStatus() (value EmojiStatusClass) { + if u == nil { + return + } + return u.EmojiStatus +} + +// UpdateRecentEmojiStatuses represents TL type `updateRecentEmojiStatuses#30f443db`. +// +// See https://core.telegram.org/constructor/updateRecentEmojiStatuses for reference. +type UpdateRecentEmojiStatuses struct { +} + +// UpdateRecentEmojiStatusesTypeID is TL type id of UpdateRecentEmojiStatuses. +const UpdateRecentEmojiStatusesTypeID = 0x30f443db + +// construct implements constructor of UpdateClass. +func (u UpdateRecentEmojiStatuses) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateRecentEmojiStatuses. +var ( + _ bin.Encoder = &UpdateRecentEmojiStatuses{} + _ bin.Decoder = &UpdateRecentEmojiStatuses{} + _ bin.BareEncoder = &UpdateRecentEmojiStatuses{} + _ bin.BareDecoder = &UpdateRecentEmojiStatuses{} + + _ UpdateClass = &UpdateRecentEmojiStatuses{} +) + +func (u *UpdateRecentEmojiStatuses) Zero() bool { + if u == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateRecentEmojiStatuses) String() string { + if u == nil { + return "UpdateRecentEmojiStatuses(nil)" + } + type Alias UpdateRecentEmojiStatuses + return fmt.Sprintf("UpdateRecentEmojiStatuses%+v", Alias(*u)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateRecentEmojiStatuses) TypeID() uint32 { + return UpdateRecentEmojiStatusesTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateRecentEmojiStatuses) TypeName() string { + return "updateRecentEmojiStatuses" +} + +// TypeInfo returns info about TL type. +func (u *UpdateRecentEmojiStatuses) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateRecentEmojiStatuses", + ID: UpdateRecentEmojiStatusesTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateRecentEmojiStatuses) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateRecentEmojiStatuses#30f443db as nil") + } + b.PutID(UpdateRecentEmojiStatusesTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateRecentEmojiStatuses) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateRecentEmojiStatuses#30f443db as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateRecentEmojiStatuses) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateRecentEmojiStatuses#30f443db to nil") + } + if err := b.ConsumeID(UpdateRecentEmojiStatusesTypeID); err != nil { + return fmt.Errorf("unable to decode updateRecentEmojiStatuses#30f443db: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateRecentEmojiStatuses) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateRecentEmojiStatuses#30f443db to nil") + } + return nil +} + +// UpdateRecentReactions represents TL type `updateRecentReactions#6f7863f4`. +// +// See https://core.telegram.org/constructor/updateRecentReactions for reference. +type UpdateRecentReactions struct { +} + +// UpdateRecentReactionsTypeID is TL type id of UpdateRecentReactions. +const UpdateRecentReactionsTypeID = 0x6f7863f4 + +// construct implements constructor of UpdateClass. +func (u UpdateRecentReactions) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateRecentReactions. +var ( + _ bin.Encoder = &UpdateRecentReactions{} + _ bin.Decoder = &UpdateRecentReactions{} + _ bin.BareEncoder = &UpdateRecentReactions{} + _ bin.BareDecoder = &UpdateRecentReactions{} + + _ UpdateClass = &UpdateRecentReactions{} +) + +func (u *UpdateRecentReactions) Zero() bool { + if u == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateRecentReactions) String() string { + if u == nil { + return "UpdateRecentReactions(nil)" + } + type Alias UpdateRecentReactions + return fmt.Sprintf("UpdateRecentReactions%+v", Alias(*u)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateRecentReactions) TypeID() uint32 { + return UpdateRecentReactionsTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateRecentReactions) TypeName() string { + return "updateRecentReactions" +} + +// TypeInfo returns info about TL type. +func (u *UpdateRecentReactions) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateRecentReactions", + ID: UpdateRecentReactionsTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateRecentReactions) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateRecentReactions#6f7863f4 as nil") + } + b.PutID(UpdateRecentReactionsTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateRecentReactions) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateRecentReactions#6f7863f4 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateRecentReactions) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateRecentReactions#6f7863f4 to nil") + } + if err := b.ConsumeID(UpdateRecentReactionsTypeID); err != nil { + return fmt.Errorf("unable to decode updateRecentReactions#6f7863f4: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateRecentReactions) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateRecentReactions#6f7863f4 to nil") + } + return nil +} + +// UpdateMoveStickerSetToTop represents TL type `updateMoveStickerSetToTop#86fccf85`. +// +// See https://core.telegram.org/constructor/updateMoveStickerSetToTop for reference. +type UpdateMoveStickerSetToTop struct { + // Flags field of UpdateMoveStickerSetToTop. + Flags bin.Fields + // Masks field of UpdateMoveStickerSetToTop. + Masks bool + // Emojis field of UpdateMoveStickerSetToTop. + Emojis bool + // Stickerset field of UpdateMoveStickerSetToTop. + Stickerset int64 +} + +// UpdateMoveStickerSetToTopTypeID is TL type id of UpdateMoveStickerSetToTop. +const UpdateMoveStickerSetToTopTypeID = 0x86fccf85 + +// construct implements constructor of UpdateClass. +func (u UpdateMoveStickerSetToTop) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateMoveStickerSetToTop. +var ( + _ bin.Encoder = &UpdateMoveStickerSetToTop{} + _ bin.Decoder = &UpdateMoveStickerSetToTop{} + _ bin.BareEncoder = &UpdateMoveStickerSetToTop{} + _ bin.BareDecoder = &UpdateMoveStickerSetToTop{} + + _ UpdateClass = &UpdateMoveStickerSetToTop{} +) + +func (u *UpdateMoveStickerSetToTop) Zero() bool { + if u == nil { + return true + } + if !(u.Flags.Zero()) { + return false + } + if !(u.Masks == false) { + return false + } + if !(u.Emojis == false) { + return false + } + if !(u.Stickerset == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateMoveStickerSetToTop) String() string { + if u == nil { + return "UpdateMoveStickerSetToTop(nil)" + } + type Alias UpdateMoveStickerSetToTop + return fmt.Sprintf("UpdateMoveStickerSetToTop%+v", Alias(*u)) +} + +// FillFrom fills UpdateMoveStickerSetToTop from given interface. +func (u *UpdateMoveStickerSetToTop) FillFrom(from interface { + GetMasks() (value bool) + GetEmojis() (value bool) + GetStickerset() (value int64) +}) { + u.Masks = from.GetMasks() + u.Emojis = from.GetEmojis() + u.Stickerset = from.GetStickerset() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateMoveStickerSetToTop) TypeID() uint32 { + return UpdateMoveStickerSetToTopTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateMoveStickerSetToTop) TypeName() string { + return "updateMoveStickerSetToTop" +} + +// TypeInfo returns info about TL type. +func (u *UpdateMoveStickerSetToTop) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateMoveStickerSetToTop", + ID: UpdateMoveStickerSetToTopTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Masks", + SchemaName: "masks", + Null: !u.Flags.Has(0), + }, + { + Name: "Emojis", + SchemaName: "emojis", + Null: !u.Flags.Has(1), + }, + { + Name: "Stickerset", + SchemaName: "stickerset", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (u *UpdateMoveStickerSetToTop) SetFlags() { + if !(u.Masks == false) { + u.Flags.Set(0) + } + if !(u.Emojis == false) { + u.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (u *UpdateMoveStickerSetToTop) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateMoveStickerSetToTop#86fccf85 as nil") + } + b.PutID(UpdateMoveStickerSetToTopTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateMoveStickerSetToTop) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateMoveStickerSetToTop#86fccf85 as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateMoveStickerSetToTop#86fccf85: field flags: %w", err) + } + b.PutLong(u.Stickerset) + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateMoveStickerSetToTop) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateMoveStickerSetToTop#86fccf85 to nil") + } + if err := b.ConsumeID(UpdateMoveStickerSetToTopTypeID); err != nil { + return fmt.Errorf("unable to decode updateMoveStickerSetToTop#86fccf85: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateMoveStickerSetToTop) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateMoveStickerSetToTop#86fccf85 to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateMoveStickerSetToTop#86fccf85: field flags: %w", err) + } + } + u.Masks = u.Flags.Has(0) + u.Emojis = u.Flags.Has(1) + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateMoveStickerSetToTop#86fccf85: field stickerset: %w", err) + } + u.Stickerset = value + } + return nil +} + +// SetMasks sets value of Masks conditional field. +func (u *UpdateMoveStickerSetToTop) SetMasks(value bool) { + if value { + u.Flags.Set(0) + u.Masks = true + } else { + u.Flags.Unset(0) + u.Masks = false + } +} + +// GetMasks returns value of Masks conditional field. +func (u *UpdateMoveStickerSetToTop) GetMasks() (value bool) { + if u == nil { + return + } + return u.Flags.Has(0) +} + +// SetEmojis sets value of Emojis conditional field. +func (u *UpdateMoveStickerSetToTop) SetEmojis(value bool) { + if value { + u.Flags.Set(1) + u.Emojis = true + } else { + u.Flags.Unset(1) + u.Emojis = false + } +} + +// GetEmojis returns value of Emojis conditional field. +func (u *UpdateMoveStickerSetToTop) GetEmojis() (value bool) { + if u == nil { + return + } + return u.Flags.Has(1) +} + +// GetStickerset returns value of Stickerset field. +func (u *UpdateMoveStickerSetToTop) GetStickerset() (value int64) { + if u == nil { + return + } + return u.Stickerset +} + // UpdateClassName is schema name of UpdateClass. const UpdateClassName = "Update" @@ -20416,7 +21100,7 @@ const UpdateClassName = "Update" // case *tg.UpdateChatParticipantAdmin: // updateChatParticipantAdmin#d7ca61a2 // case *tg.UpdateNewStickerSet: // updateNewStickerSet#688a30aa // case *tg.UpdateStickerSetsOrder: // updateStickerSetsOrder#bb2d201 -// case *tg.UpdateStickerSets: // updateStickerSets#43ae3dec +// case *tg.UpdateStickerSets: // updateStickerSets#31c24808 // case *tg.UpdateSavedGifs: // updateSavedGifs#9375341e // case *tg.UpdateBotInlineQuery: // updateBotInlineQuery#496f379c // case *tg.UpdateBotInlineSend: // updateBotInlineSend#12f12a07 @@ -20485,6 +21169,10 @@ const UpdateClassName = "Update" // case *tg.UpdateSavedRingtones: // updateSavedRingtones#74d8be99 // case *tg.UpdateTranscribedAudio: // updateTranscribedAudio#84cd5a // case *tg.UpdateReadFeaturedEmojiStickers: // updateReadFeaturedEmojiStickers#fb4c496c +// case *tg.UpdateUserEmojiStatus: // updateUserEmojiStatus#28373599 +// case *tg.UpdateRecentEmojiStatuses: // updateRecentEmojiStatuses#30f443db +// case *tg.UpdateRecentReactions: // updateRecentReactions#6f7863f4 +// case *tg.UpdateMoveStickerSetToTop: // updateMoveStickerSetToTop#86fccf85 // default: panic(v) // } type UpdateClass interface { @@ -20745,7 +21433,7 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { } return &v, nil case UpdateStickerSetsTypeID: - // Decoding updateStickerSets#43ae3dec. + // Decoding updateStickerSets#31c24808. v := UpdateStickerSets{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) @@ -21227,6 +21915,34 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case UpdateUserEmojiStatusTypeID: + // Decoding updateUserEmojiStatus#28373599. + v := UpdateUserEmojiStatus{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil + case UpdateRecentEmojiStatusesTypeID: + // Decoding updateRecentEmojiStatuses#30f443db. + v := UpdateRecentEmojiStatuses{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil + case UpdateRecentReactionsTypeID: + // Decoding updateRecentReactions#6f7863f4. + v := UpdateRecentReactions{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil + case UpdateMoveStickerSetToTopTypeID: + // Decoding updateMoveStickerSetToTop#86fccf85. + v := UpdateMoveStickerSetToTop{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode UpdateClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_update_slices_gen.go b/tg/tl_update_slices_gen.go index d80a89b90a..2f639605b1 100644 --- a/tg/tl_update_slices_gen.go +++ b/tg/tl_update_slices_gen.go @@ -545,6 +545,19 @@ func (s UpdateClassArray) AsUpdateStickerSetsOrder() (to UpdateStickerSetsOrderA return to } +// AsUpdateStickerSets returns copy with only UpdateStickerSets constructors. +func (s UpdateClassArray) AsUpdateStickerSets() (to UpdateStickerSetsArray) { + for _, elem := range s { + value, ok := elem.(*UpdateStickerSets) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // AsUpdateBotInlineQuery returns copy with only UpdateBotInlineQuery constructors. func (s UpdateClassArray) AsUpdateBotInlineQuery() (to UpdateBotInlineQueryArray) { for _, elem := range s { @@ -1273,6 +1286,32 @@ func (s UpdateClassArray) AsUpdateTranscribedAudio() (to UpdateTranscribedAudioA return to } +// AsUpdateUserEmojiStatus returns copy with only UpdateUserEmojiStatus constructors. +func (s UpdateClassArray) AsUpdateUserEmojiStatus() (to UpdateUserEmojiStatusArray) { + for _, elem := range s { + value, ok := elem.(*UpdateUserEmojiStatus) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsUpdateMoveStickerSetToTop returns copy with only UpdateMoveStickerSetToTop constructors. +func (s UpdateClassArray) AsUpdateMoveStickerSetToTop() (to UpdateMoveStickerSetToTopArray) { + for _, elem := range s { + value, ok := elem.(*UpdateMoveStickerSetToTop) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // UpdateNewMessageArray is adapter for slice of UpdateNewMessage. type UpdateNewMessageArray []UpdateNewMessage @@ -4091,6 +4130,88 @@ func (s *UpdateStickerSetsOrderArray) Pop() (v UpdateStickerSetsOrder, ok bool) return v, true } +// UpdateStickerSetsArray is adapter for slice of UpdateStickerSets. +type UpdateStickerSetsArray []UpdateStickerSets + +// Sort sorts slice of UpdateStickerSets. +func (s UpdateStickerSetsArray) Sort(less func(a, b UpdateStickerSets) bool) UpdateStickerSetsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateStickerSets. +func (s UpdateStickerSetsArray) SortStable(less func(a, b UpdateStickerSets) bool) UpdateStickerSetsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateStickerSets. +func (s UpdateStickerSetsArray) Retain(keep func(x UpdateStickerSets) bool) UpdateStickerSetsArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s UpdateStickerSetsArray) First() (v UpdateStickerSets, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateStickerSetsArray) Last() (v UpdateStickerSets, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *UpdateStickerSetsArray) PopFirst() (v UpdateStickerSets, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero UpdateStickerSets + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *UpdateStickerSetsArray) Pop() (v UpdateStickerSets, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + // UpdateBotInlineQueryArray is adapter for slice of UpdateBotInlineQuery. type UpdateBotInlineQueryArray []UpdateBotInlineQuery @@ -8794,3 +8915,167 @@ func (s *UpdateTranscribedAudioArray) Pop() (v UpdateTranscribedAudio, ok bool) return v, true } + +// UpdateUserEmojiStatusArray is adapter for slice of UpdateUserEmojiStatus. +type UpdateUserEmojiStatusArray []UpdateUserEmojiStatus + +// Sort sorts slice of UpdateUserEmojiStatus. +func (s UpdateUserEmojiStatusArray) Sort(less func(a, b UpdateUserEmojiStatus) bool) UpdateUserEmojiStatusArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateUserEmojiStatus. +func (s UpdateUserEmojiStatusArray) SortStable(less func(a, b UpdateUserEmojiStatus) bool) UpdateUserEmojiStatusArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateUserEmojiStatus. +func (s UpdateUserEmojiStatusArray) Retain(keep func(x UpdateUserEmojiStatus) bool) UpdateUserEmojiStatusArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s UpdateUserEmojiStatusArray) First() (v UpdateUserEmojiStatus, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateUserEmojiStatusArray) Last() (v UpdateUserEmojiStatus, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *UpdateUserEmojiStatusArray) PopFirst() (v UpdateUserEmojiStatus, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero UpdateUserEmojiStatus + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *UpdateUserEmojiStatusArray) Pop() (v UpdateUserEmojiStatus, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// UpdateMoveStickerSetToTopArray is adapter for slice of UpdateMoveStickerSetToTop. +type UpdateMoveStickerSetToTopArray []UpdateMoveStickerSetToTop + +// Sort sorts slice of UpdateMoveStickerSetToTop. +func (s UpdateMoveStickerSetToTopArray) Sort(less func(a, b UpdateMoveStickerSetToTop) bool) UpdateMoveStickerSetToTopArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateMoveStickerSetToTop. +func (s UpdateMoveStickerSetToTopArray) SortStable(less func(a, b UpdateMoveStickerSetToTop) bool) UpdateMoveStickerSetToTopArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateMoveStickerSetToTop. +func (s UpdateMoveStickerSetToTopArray) Retain(keep func(x UpdateMoveStickerSetToTop) bool) UpdateMoveStickerSetToTopArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s UpdateMoveStickerSetToTopArray) First() (v UpdateMoveStickerSetToTop, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateMoveStickerSetToTopArray) Last() (v UpdateMoveStickerSetToTop, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *UpdateMoveStickerSetToTopArray) PopFirst() (v UpdateMoveStickerSetToTop, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero UpdateMoveStickerSetToTop + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *UpdateMoveStickerSetToTopArray) Pop() (v UpdateMoveStickerSetToTop, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_user_gen.go b/tg/tl_user_gen.go index e31121e626..edd5feb694 100644 --- a/tg/tl_user_gen.go +++ b/tg/tl_user_gen.go @@ -166,7 +166,7 @@ func (u *UserEmpty) GetID() (value int64) { return u.ID } -// User represents TL type `user#3ff6ecb0`. +// User represents TL type `user#5d99adee`. // Indicates info about a certain user // // See https://core.telegram.org/constructor/user for reference. @@ -271,10 +271,14 @@ type User struct { // // Use SetLangCode and GetLangCode helpers. LangCode string + // EmojiStatus field of User. + // + // Use SetEmojiStatus and GetEmojiStatus helpers. + EmojiStatus EmojiStatusClass } // UserTypeID is TL type id of User. -const UserTypeID = 0x3ff6ecb0 +const UserTypeID = 0x5d99adee // construct implements constructor of UserClass. func (u User) construct() UserClass { return &u } @@ -386,6 +390,9 @@ func (u *User) Zero() bool { if !(u.LangCode == "") { return false } + if !(u.EmojiStatus == nil) { + return false + } return true } @@ -431,6 +438,7 @@ func (u *User) FillFrom(from interface { GetRestrictionReason() (value []RestrictionReason, ok bool) GetBotInlinePlaceholder() (value string, ok bool) GetLangCode() (value string, ok bool) + GetEmojiStatus() (value EmojiStatusClass, ok bool) }) { u.Self = from.GetSelf() u.Contact = from.GetContact() @@ -495,6 +503,10 @@ func (u *User) FillFrom(from interface { u.LangCode = val } + if val, ok := from.GetEmojiStatus(); ok { + u.EmojiStatus = val + } + } // TypeID returns type id in TL schema. @@ -669,6 +681,11 @@ func (u *User) TypeInfo() tdp.Type { SchemaName: "lang_code", Null: !u.Flags.Has(22), }, + { + Name: "EmojiStatus", + SchemaName: "emoji_status", + Null: !u.Flags.Has(30), + }, } return typ } @@ -762,12 +779,15 @@ func (u *User) SetFlags() { if !(u.LangCode == "") { u.Flags.Set(22) } + if !(u.EmojiStatus == nil) { + u.Flags.Set(30) + } } // Encode implements bin.Encoder. func (u *User) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode user#3ff6ecb0 as nil") + return fmt.Errorf("can't encode user#5d99adee as nil") } b.PutID(UserTypeID) return u.EncodeBare(b) @@ -776,11 +796,11 @@ func (u *User) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *User) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode user#3ff6ecb0 as nil") + return fmt.Errorf("can't encode user#5d99adee as nil") } u.SetFlags() if err := u.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#3ff6ecb0: field flags: %w", err) + return fmt.Errorf("unable to encode user#5d99adee: field flags: %w", err) } b.PutLong(u.ID) if u.Flags.Has(0) { @@ -800,18 +820,18 @@ func (u *User) EncodeBare(b *bin.Buffer) error { } if u.Flags.Has(5) { if u.Photo == nil { - return fmt.Errorf("unable to encode user#3ff6ecb0: field photo is nil") + return fmt.Errorf("unable to encode user#5d99adee: field photo is nil") } if err := u.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#3ff6ecb0: field photo: %w", err) + return fmt.Errorf("unable to encode user#5d99adee: field photo: %w", err) } } if u.Flags.Has(6) { if u.Status == nil { - return fmt.Errorf("unable to encode user#3ff6ecb0: field status is nil") + return fmt.Errorf("unable to encode user#5d99adee: field status is nil") } if err := u.Status.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#3ff6ecb0: field status: %w", err) + return fmt.Errorf("unable to encode user#5d99adee: field status: %w", err) } } if u.Flags.Has(14) { @@ -821,7 +841,7 @@ func (u *User) EncodeBare(b *bin.Buffer) error { b.PutVectorHeader(len(u.RestrictionReason)) for idx, v := range u.RestrictionReason { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#3ff6ecb0: field restriction_reason element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode user#5d99adee: field restriction_reason element with index %d: %w", idx, err) } } } @@ -831,16 +851,24 @@ func (u *User) EncodeBare(b *bin.Buffer) error { if u.Flags.Has(22) { b.PutString(u.LangCode) } + if u.Flags.Has(30) { + if u.EmojiStatus == nil { + return fmt.Errorf("unable to encode user#5d99adee: field emoji_status is nil") + } + if err := u.EmojiStatus.Encode(b); err != nil { + return fmt.Errorf("unable to encode user#5d99adee: field emoji_status: %w", err) + } + } return nil } // Decode implements bin.Decoder. func (u *User) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode user#3ff6ecb0 to nil") + return fmt.Errorf("can't decode user#5d99adee to nil") } if err := b.ConsumeID(UserTypeID); err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: %w", err) } return u.DecodeBare(b) } @@ -848,11 +876,11 @@ func (u *User) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *User) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode user#3ff6ecb0 to nil") + return fmt.Errorf("can't decode user#5d99adee to nil") } { if err := u.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field flags: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field flags: %w", err) } } u.Self = u.Flags.Has(10) @@ -876,70 +904,70 @@ func (u *User) DecodeBare(b *bin.Buffer) error { { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field id: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field id: %w", err) } u.ID = value } if u.Flags.Has(0) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field access_hash: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field access_hash: %w", err) } u.AccessHash = value } if u.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field first_name: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field first_name: %w", err) } u.FirstName = value } if u.Flags.Has(2) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field last_name: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field last_name: %w", err) } u.LastName = value } if u.Flags.Has(3) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field username: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field username: %w", err) } u.Username = value } if u.Flags.Has(4) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field phone: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field phone: %w", err) } u.Phone = value } if u.Flags.Has(5) { value, err := DecodeUserProfilePhoto(b) if err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field photo: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field photo: %w", err) } u.Photo = value } if u.Flags.Has(6) { value, err := DecodeUserStatus(b) if err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field status: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field status: %w", err) } u.Status = value } if u.Flags.Has(14) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field bot_info_version: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field bot_info_version: %w", err) } u.BotInfoVersion = value } if u.Flags.Has(18) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field restriction_reason: %w", err) } if headerLen > 0 { @@ -948,7 +976,7 @@ func (u *User) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value RestrictionReason if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field restriction_reason: %w", err) } u.RestrictionReason = append(u.RestrictionReason, value) } @@ -956,17 +984,24 @@ func (u *User) DecodeBare(b *bin.Buffer) error { if u.Flags.Has(19) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field bot_inline_placeholder: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field bot_inline_placeholder: %w", err) } u.BotInlinePlaceholder = value } if u.Flags.Has(22) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode user#3ff6ecb0: field lang_code: %w", err) + return fmt.Errorf("unable to decode user#5d99adee: field lang_code: %w", err) } u.LangCode = value } + if u.Flags.Has(30) { + value, err := DecodeEmojiStatus(b) + if err != nil { + return fmt.Errorf("unable to decode user#5d99adee: field emoji_status: %w", err) + } + u.EmojiStatus = value + } return nil } @@ -1518,6 +1553,24 @@ func (u *User) GetLangCode() (value string, ok bool) { return u.LangCode, true } +// SetEmojiStatus sets value of EmojiStatus conditional field. +func (u *User) SetEmojiStatus(value EmojiStatusClass) { + u.Flags.Set(30) + u.EmojiStatus = value +} + +// GetEmojiStatus returns value of EmojiStatus conditional field and +// boolean which is true if field was set. +func (u *User) GetEmojiStatus() (value EmojiStatusClass, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(30) { + return value, false + } + return u.EmojiStatus, true +} + // UserClassName is schema name of UserClass. const UserClassName = "User" @@ -1533,7 +1586,7 @@ const UserClassName = "User" // } // switch v := g.(type) { // case *tg.UserEmpty: // userEmpty#d3bc4b7a -// case *tg.User: // user#3ff6ecb0 +// case *tg.User: // user#5d99adee // default: panic(v) // } type UserClass interface { @@ -1608,7 +1661,7 @@ func DecodeUser(buf *bin.Buffer) (UserClass, error) { } return &v, nil case UserTypeID: - // Decoding user#3ff6ecb0. + // Decoding user#5d99adee. v := User{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UserClass: %w", err)