From 5d31d2b44b488d4fdb2151bffffbd01cb71c3e0a Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 29 Oct 2023 07:45:25 +0000 Subject: [PATCH 1/4] feat(schema): update Telegram to the latest layer --- _schema/layer.tl | 6 +- _schema/tdesktop.tl | 120 ++- _schema/telegram.tl | 124 ++- telegram/message/entity/options.gen.go | 38 +- telegram/message/styling/options.gen.go | 20 +- telegram/query/cached/queries.gen.go | 84 ++ ...count_get_default_background_emojis_gen.go | 176 ++++ ...t_default_background_emojis_slices_gen.go} | 0 tg/tl_account_update_color_gen.go | 240 +++++ ... => tl_account_update_color_slices_gen.go} | 0 tg/tl_boost_gen.go | 530 +++++++++++ ...t_slices_gen.go => tl_boost_slices_gen.go} | 0 tg/tl_booster_gen.go | 188 ---- tg/tl_bot_inline_message_gen.go | 559 ++++++++++++ tg/tl_bot_inline_message_slices_gen.go | 95 ++ tg/tl_channel_admin_log_event_action_gen.go | 340 +++++++ ...annel_admin_log_event_action_slices_gen.go | 190 ++++ tg/tl_channels_update_color_gen.go | 276 ++++++ ...=> tl_channels_update_color_slices_gen.go} | 0 tg/tl_chat_gen.go | 166 +++- tg/tl_chat_invite_gen.go | 69 +- tg/tl_draft_message_gen.go | 179 +++- tg/tl_input_bot_inline_message_gen.go | 524 +++++++++++ tg/tl_input_bot_inline_message_slices_gen.go | 95 ++ tg/tl_input_invoice_gen.go | 174 ++++ tg/tl_input_invoice_slices_gen.go | 95 ++ tg/tl_input_media_gen.go | 265 ++++++ tg/tl_input_media_slices_gen.go | 95 ++ tg/tl_input_reply_to_gen.go | 201 ++++- tg/tl_input_store_payment_purpose_gen.go | 733 +++++++++++++++ ..._input_store_payment_purpose_slices_gen.go | 190 ++++ tg/tl_message_action_gen.go | 419 +++++++++ tg/tl_message_action_slices_gen.go | 95 ++ tg/tl_message_entity_gen.go | 352 ++++---- tg/tl_message_entity_slices_gen.go | 128 +-- tg/tl_message_gen.go | 35 + tg/tl_message_media_gen.go | 532 ++++++++++- tg/tl_message_media_slices_gen.go | 95 ++ tg/tl_message_reply_header_gen.go | 325 ++++++- tg/tl_messages_edit_inline_bot_message_gen.go | 35 + tg/tl_messages_edit_message_gen.go | 35 + tg/tl_messages_save_draft_gen.go | 208 +++-- 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_my_boost_gen.go | 334 +++++++ ...lices_gen.go => tl_my_boost_slices_gen.go} | 0 tg/tl_payments_apply_gift_code_gen.go | 176 ++++ ...tl_payments_apply_gift_code_slices_gen.go} | 0 tg/tl_payments_check_gift_code_gen.go | 176 ++++ ...tl_payments_check_gift_code_slices_gen.go} | 0 tg/tl_payments_checked_gift_code_gen.go | 517 +++++++++++ ...l_payments_checked_gift_code_slices_gen.go | 35 + tg/tl_payments_get_giveaway_info_gen.go | 205 +++++ ...l_payments_get_giveaway_info_slices_gen.go | 35 + ...ments_get_premium_gift_code_options_gen.go | 217 +++++ ...et_premium_gift_code_options_slices_gen.go | 35 + tg/tl_payments_giveaway_info_gen.go | 841 ++++++++++++++++++ tg/tl_payments_giveaway_info_slices_gen.go | 307 +++++++ tg/tl_payments_launch_prepaid_giveaway_gen.go | 237 +++++ ...ents_launch_prepaid_giveaway_slices_gen.go | 35 + tg/tl_premium_apply_boost_gen.go | 257 ++++++ tg/tl_premium_apply_boost_slices_gen.go | 35 + tg/tl_premium_boosts_list_gen.go | 319 +++++++ tg/tl_premium_boosts_list_slices_gen.go | 35 + tg/tl_premium_boosts_status_gen.go | 563 ++++++++++++ tg/tl_premium_boosts_status_slices_gen.go | 35 + tg/tl_premium_get_boosts_list_gen.go | 285 ++++++ tg/tl_premium_get_boosts_list_slices_gen.go | 35 + tg/tl_premium_get_boosts_status_gen.go | 181 ++++ tg/tl_premium_get_boosts_status_slices_gen.go | 35 + tg/tl_premium_get_my_boosts_gen.go | 141 +++ tg/tl_premium_get_my_boosts_slices_gen.go | 35 + tg/tl_premium_gift_code_option_gen.go | 356 ++++++++ tg/tl_premium_gift_code_option_slices_gen.go | 35 + tg/tl_premium_gift_code_option_vector_gen.go | 172 ++++ ...mium_gift_code_option_vector_slices_gen.go | 35 + tg/tl_premium_my_boosts_gen.go | 276 ++++++ tg/tl_premium_my_boosts_slices_gen.go | 35 + tg/tl_prepaid_giveaway_gen.go | 242 +++++ tg/tl_prepaid_giveaway_slices_gen.go | 35 + tg/tl_registry_gen.go | 175 +++- tg/tl_server_gen.go | 178 +++- tg/tl_sticker_set_gen.go | 35 + tg/tl_stories_apply_boost_gen.go | 182 ---- tg/tl_stories_boosters_list_gen.go | 319 ------- tg/tl_stories_boosts_status_gen.go | 391 -------- tg/tl_stories_can_apply_boost_gen.go | 181 ---- tg/tl_stories_can_apply_boost_result_gen.go | 411 --------- ...ories_can_apply_boost_result_slices_gen.go | 212 ----- tg/tl_stories_get_boosters_list_gen.go | 232 ----- tg/tl_stories_get_boosts_status_gen.go | 181 ---- tg/tl_update_gen.go | 35 + tg/tl_user_gen.go | 172 +++- tg/tl_web_page_gen.go | 209 ++++- 95 files changed, 14342 insertions(+), 2999 deletions(-) create mode 100644 tg/tl_account_get_default_background_emojis_gen.go rename tg/{tl_booster_slices_gen.go => tl_account_get_default_background_emojis_slices_gen.go} (100%) create mode 100644 tg/tl_account_update_color_gen.go rename tg/{tl_stories_apply_boost_slices_gen.go => tl_account_update_color_slices_gen.go} (100%) create mode 100644 tg/tl_boost_gen.go rename tg/{tl_stories_boosters_list_slices_gen.go => tl_boost_slices_gen.go} (100%) delete mode 100644 tg/tl_booster_gen.go create mode 100644 tg/tl_channels_update_color_gen.go rename tg/{tl_stories_boosts_status_slices_gen.go => tl_channels_update_color_slices_gen.go} (100%) create mode 100644 tg/tl_my_boost_gen.go rename tg/{tl_stories_can_apply_boost_slices_gen.go => tl_my_boost_slices_gen.go} (100%) create mode 100644 tg/tl_payments_apply_gift_code_gen.go rename tg/{tl_stories_get_boosters_list_slices_gen.go => tl_payments_apply_gift_code_slices_gen.go} (100%) create mode 100644 tg/tl_payments_check_gift_code_gen.go rename tg/{tl_stories_get_boosts_status_slices_gen.go => tl_payments_check_gift_code_slices_gen.go} (100%) create mode 100644 tg/tl_payments_checked_gift_code_gen.go create mode 100644 tg/tl_payments_checked_gift_code_slices_gen.go create mode 100644 tg/tl_payments_get_giveaway_info_gen.go create mode 100644 tg/tl_payments_get_giveaway_info_slices_gen.go create mode 100644 tg/tl_payments_get_premium_gift_code_options_gen.go create mode 100644 tg/tl_payments_get_premium_gift_code_options_slices_gen.go create mode 100644 tg/tl_payments_giveaway_info_gen.go create mode 100644 tg/tl_payments_giveaway_info_slices_gen.go create mode 100644 tg/tl_payments_launch_prepaid_giveaway_gen.go create mode 100644 tg/tl_payments_launch_prepaid_giveaway_slices_gen.go create mode 100644 tg/tl_premium_apply_boost_gen.go create mode 100644 tg/tl_premium_apply_boost_slices_gen.go create mode 100644 tg/tl_premium_boosts_list_gen.go create mode 100644 tg/tl_premium_boosts_list_slices_gen.go create mode 100644 tg/tl_premium_boosts_status_gen.go create mode 100644 tg/tl_premium_boosts_status_slices_gen.go create mode 100644 tg/tl_premium_get_boosts_list_gen.go create mode 100644 tg/tl_premium_get_boosts_list_slices_gen.go create mode 100644 tg/tl_premium_get_boosts_status_gen.go create mode 100644 tg/tl_premium_get_boosts_status_slices_gen.go create mode 100644 tg/tl_premium_get_my_boosts_gen.go create mode 100644 tg/tl_premium_get_my_boosts_slices_gen.go create mode 100644 tg/tl_premium_gift_code_option_gen.go create mode 100644 tg/tl_premium_gift_code_option_slices_gen.go create mode 100644 tg/tl_premium_gift_code_option_vector_gen.go create mode 100644 tg/tl_premium_gift_code_option_vector_slices_gen.go create mode 100644 tg/tl_premium_my_boosts_gen.go create mode 100644 tg/tl_premium_my_boosts_slices_gen.go create mode 100644 tg/tl_prepaid_giveaway_gen.go create mode 100644 tg/tl_prepaid_giveaway_slices_gen.go delete mode 100644 tg/tl_stories_apply_boost_gen.go delete mode 100644 tg/tl_stories_boosters_list_gen.go delete mode 100644 tg/tl_stories_boosts_status_gen.go delete mode 100644 tg/tl_stories_can_apply_boost_gen.go delete mode 100644 tg/tl_stories_can_apply_boost_result_gen.go delete mode 100644 tg/tl_stories_can_apply_boost_result_slices_gen.go delete mode 100644 tg/tl_stories_get_boosters_list_gen.go delete mode 100644 tg/tl_stories_get_boosts_status_gen.go diff --git a/_schema/layer.tl b/_schema/layer.tl index 020ade4d99..25f22bf557 100644 --- a/_schema/layer.tl +++ b/_schema/layer.tl @@ -1,7 +1,7 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/layer.tl -// Layer: 165 -// SHA256: 36b1cc02020b7961dbbce32a3b05ecc9409c447b0b202854a07c47676c665fa9 +// Layer: 166 +// SHA256: a0dbdfb46897445f2eb0ba70df15f042172b668dfbdd11f7fd12c3fb0af29837 -// LAYER 165 +// LAYER 166 diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index 03fee6297c..dcc690decd 100644 --- a/_schema/tdesktop.tl +++ b/_schema/tdesktop.tl @@ -1,7 +1,7 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl -// SHA256: 7bbf14403a05d0a385f4338ebfb196a278521b7f7e90881be20091de11ccd8ab +// SHA256: 4056d76f6bec7a43b31a625278ee24c0a29cbd462dfc4769be1361c0221b96c7 boolFalse#bc799737 = Bool; @@ -73,6 +73,8 @@ inputMediaDice#e66fbf7b emoticon:string = InputMedia; inputMediaStory#89fdd778 peer:InputPeer id:int = InputMedia; +inputMediaWebPage#c21b8849 flags:# force_large_media:flags.0?true force_small_media:flags.1?true optional:flags.2?true url:string = InputMedia; + inputChatPhotoEmpty#1ca48f57 = InputChatPhoto; inputChatUploadedPhoto#bdcdaec0 flags:# file:flags.0?InputFile video:flags.1?InputFile video_start_ts:flags.2?double video_emoji_markup:flags.3?VideoSize = InputChatPhoto; @@ -135,7 +137,7 @@ storage.fileWebp#1081464c = storage.FileType; userEmpty#d3bc4b7a id:long = User; -user#abb5f120 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 flags2:# bot_can_edit:flags2.1?true close_friend:flags2.2?true stories_hidden:flags2.3?true stories_unavailable:flags2.4?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 usernames:flags2.0?Vector stories_max_id:flags2.5?int = User; +user#eb602f25 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 flags2:# bot_can_edit:flags2.1?true close_friend:flags2.2?true stories_hidden:flags2.3?true stories_unavailable:flags2.4?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 usernames:flags2.0?Vector stories_max_id:flags2.5?int color:flags2.7?int background_emoji_id:flags2.6?long = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; @@ -159,7 +161,7 @@ chat#41cbf256 flags:# creator:flags.0?true left:flags.2?true deactivated:flags.5 chatForbidden#6592a1a7 id:long title:string = Chat; -channel#94f592db flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true forum:flags.30?true flags2:# stories_hidden:flags2.1?true stories_hidden_min:flags2.2?true stories_unavailable:flags2.3?true id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int usernames:flags2.0?Vector stories_max_id:flags2.4?int = Chat; +channel#1981ea7e flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true forum:flags.30?true flags2:# stories_hidden:flags2.1?true stories_hidden_min:flags2.2?true stories_unavailable:flags2.3?true id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int usernames:flags2.0?Vector stories_max_id:flags2.4?int color:flags2.6?int background_emoji_id:flags2.5?long = Chat; channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat; @@ -183,7 +185,7 @@ chatPhoto#1c6e1c11 flags:# has_video:flags.0?true photo_id:long stripped_thumb:f messageEmpty#90a6ca84 flags:# id:int peer_id:flags.0?Peer = Message; -message#38116ee0 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true id:int from_id:flags.8?Peer peer_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int = Message; +message#38116ee0 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true id:int from_id:flags.8?Peer peer_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int = Message; messageService#2b085862 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?Peer peer_id:Peer reply_to:flags.3?MessageReplyHeader date:int action:MessageAction ttl_period:flags.25?int = Message; @@ -199,7 +201,7 @@ messageMediaUnsupported#9f84f49e = MessageMedia; messageMediaDocument#4cf4d72d flags:# nopremium:flags.3?true spoiler:flags.4?true document:flags.0?Document alt_document:flags.5?Document ttl_seconds:flags.2?int = MessageMedia; -messageMediaWebPage#a32dd600 webpage:WebPage = MessageMedia; +messageMediaWebPage#ddf10c3b flags:# force_large_media:flags.0?true force_small_media:flags.1?true manual:flags.3?true safe:flags.4?true webpage:WebPage = MessageMedia; messageMediaVenue#2ec0533f geo:GeoPoint title:string address:string provider:string venue_id:string venue_type:string = MessageMedia; @@ -215,6 +217,8 @@ messageMediaDice#3f7ee58b value:int emoticon:string = MessageMedia; messageMediaStory#68cb6283 flags:# via_mention:flags.1?true peer:Peer id:int story:flags.0?StoryItem = MessageMedia; +messageMediaGiveaway#58260664 flags:# only_new_subscribers:flags.0?true channels:Vector countries_iso2:flags.1?Vector quantity:int months:int until_date:int = MessageMedia; + messageActionEmpty#b6aef7b0 = MessageAction; messageActionChatCreate#bd47cbad title:string users:Vector = MessageAction; @@ -293,6 +297,10 @@ messageActionSetChatWallPaper#bc44a927 wallpaper:WallPaper = MessageAction; messageActionSetSameChatWallPaper#c0787d6d wallpaper:WallPaper = MessageAction; +messageActionGiftCode#d2cfdb0e flags:# via_giveaway:flags.0?true unclaimed:flags.2?true boost_peer:flags.1?Peer months:int slug:string = MessageAction; + +messageActionGiveawayLaunch#332ba9ed = MessageAction; + dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -475,7 +483,7 @@ updateDcOptions#8e5e9873 dc_options:Vector = Update; updateNotifySettings#bec268ef peer:NotifyPeer notify_settings:PeerNotifySettings = Update; -updateServiceNotification#ebe46819 flags:# popup:flags.0?true inbox_date:flags.1?int type:string message:string media:MessageMedia entities:Vector = Update; +updateServiceNotification#ebe46819 flags:# popup:flags.0?true invert_media:flags.2?true inbox_date:flags.1?int type:string message:string media:MessageMedia entities:Vector = Update; updatePrivacy#ee3b272a key:PrivacyKey rules:Vector = Update; @@ -923,11 +931,11 @@ messages.allStickers#cdbbcebb hash:long sets:Vector = messages.AllSt messages.affectedMessages#84d19185 pts:int pts_count:int = messages.AffectedMessages; -webPageEmpty#eb1477e8 id:long = WebPage; +webPageEmpty#211a1788 flags:# id:long url:flags.0?string = WebPage; -webPagePending#c586da1c id:long date:int = WebPage; +webPagePending#b0d13e47 flags:# id:long url:flags.0?string date:int = WebPage; -webPage#e89c45b2 flags:# id:long url:string display_url:string hash:int type:flags.0?string site_name:flags.1?string title:flags.2?string description:flags.3?string photo:flags.4?Photo embed_url:flags.5?string embed_type:flags.5?string embed_width:flags.6?int embed_height:flags.6?int duration:flags.7?int author:flags.8?string document:flags.9?Document cached_page:flags.10?Page attributes:flags.12?Vector = WebPage; +webPage#e89c45b2 flags:# has_large_media:flags.13?true id:long url:string display_url:string hash:int type:flags.0?string site_name:flags.1?string title:flags.2?string description:flags.3?string photo:flags.4?Photo embed_url:flags.5?string embed_type:flags.5?string embed_width:flags.6?int embed_height:flags.6?int duration:flags.7?int author:flags.8?string document:flags.9?Document cached_page:flags.10?Page attributes:flags.12?Vector = WebPage; webPageNotModified#7311ca11 flags:# cached_page_views:flags.0?int = WebPage; @@ -951,7 +959,7 @@ chatInvitePublicJoinRequests#ed107ab7 = ExportedChatInvite; chatInviteAlready#5a686d7c chat:Chat = ChatInvite; -chatInvite#300c44c1 flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true request_needed:flags.6?true verified:flags.7?true scam:flags.8?true fake:flags.9?true title:string about:flags.5?string photo:Photo participants_count:int participants:flags.4?Vector = ChatInvite; +chatInvite#cde0ec40 flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true request_needed:flags.6?true verified:flags.7?true scam:flags.8?true fake:flags.9?true title:string about:flags.5?string photo:Photo participants_count:int participants:flags.4?Vector color:int = ChatInvite; chatInvitePeek#61695cb0 chat:Chat expires:int = ChatInvite; @@ -975,7 +983,7 @@ inputStickerSetEmojiDefaultStatuses#29d0f5ee = InputStickerSet; inputStickerSetEmojiDefaultTopicIcons#44c1f8e9 = 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; +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 text_color:flags.9?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#6e153f16 set:StickerSet packs:Vector keywords:Vector documents:Vector = messages.StickerSet; @@ -1061,14 +1069,14 @@ messageEntityUnderline#9c4e7e8b offset:int length:int = MessageEntity; messageEntityStrike#bf0693d4 offset:int length:int = MessageEntity; -messageEntityBlockquote#20df5d0 offset:int length:int = MessageEntity; - messageEntityBankCard#761e6af4 offset:int length:int = MessageEntity; messageEntitySpoiler#32ca960f offset:int length:int = MessageEntity; messageEntityCustomEmoji#c8cf05f8 offset:int length:int document_id:long = MessageEntity; +messageEntityBlockquote#20df5d0 offset:int length:int = MessageEntity; + inputChannelEmpty#ee8c1e86 = InputChannel; inputChannel#f35aec28 channel_id:long access_hash:long = InputChannel; @@ -1129,9 +1137,9 @@ messages.savedGifsNotModified#e8025ca2 = messages.SavedGifs; messages.savedGifs#84a02a0d hash:long gifs:Vector = messages.SavedGifs; -inputBotInlineMessageMediaAuto#3380c786 flags:# message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; +inputBotInlineMessageMediaAuto#3380c786 flags:# invert_media:flags.3?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; -inputBotInlineMessageText#3dcd7a87 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; +inputBotInlineMessageText#3dcd7a87 flags:# no_webpage:flags.0?true invert_media:flags.3?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; inputBotInlineMessageMediaGeo#96929a85 flags:# geo_point:InputGeoPoint heading:flags.0?int period:flags.1?int proximity_notification_radius:flags.3?int reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; @@ -1143,6 +1151,8 @@ inputBotInlineMessageGame#4b425864 flags:# reply_markup:flags.2?ReplyMarkup = In inputBotInlineMessageMediaInvoice#d7e78225 flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:string provider_data:DataJSON reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; +inputBotInlineMessageMediaWebPage#bddcc510 flags:# invert_media:flags.3?true force_large_media:flags.4?true force_small_media:flags.5?true optional:flags.6?true message:string entities:flags.1?Vector url:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; + inputBotInlineResult#88bf9319 flags:# id:string type:string title:flags.1?string description:flags.2?string url:flags.3?string thumb:flags.4?InputWebDocument content:flags.5?InputWebDocument send_message:InputBotInlineMessage = InputBotInlineResult; inputBotInlineResultPhoto#a8d864a7 id:string type:string photo:InputPhoto send_message:InputBotInlineMessage = InputBotInlineResult; @@ -1151,9 +1161,9 @@ inputBotInlineResultDocument#fff8fdc4 flags:# id:string type:string title:flags. inputBotInlineResultGame#4fa417f2 id:string short_name:string send_message:InputBotInlineMessage = InputBotInlineResult; -botInlineMessageMediaAuto#764cf810 flags:# message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = BotInlineMessage; +botInlineMessageMediaAuto#764cf810 flags:# invert_media:flags.3?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = BotInlineMessage; -botInlineMessageText#8c7f65e2 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = BotInlineMessage; +botInlineMessageText#8c7f65e2 flags:# no_webpage:flags.0?true invert_media:flags.3?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = BotInlineMessage; botInlineMessageMediaGeo#51846fd flags:# geo:GeoPoint heading:flags.0?int period:flags.1?int proximity_notification_radius:flags.3?int reply_markup:flags.2?ReplyMarkup = BotInlineMessage; @@ -1163,6 +1173,8 @@ botInlineMessageMediaContact#18d1cdc2 flags:# phone_number:string first_name:str botInlineMessageMediaInvoice#354a9b09 flags:# shipping_address_requested:flags.1?true test:flags.3?true title:string description:string photo:flags.0?WebDocument currency:string total_amount:long reply_markup:flags.2?ReplyMarkup = BotInlineMessage; +botInlineMessageMediaWebPage#809ad9a6 flags:# invert_media:flags.3?true force_large_media:flags.4?true force_small_media:flags.5?true manual:flags.7?true safe:flags.8?true message:string entities:flags.1?Vector url:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage; + botInlineResult#11965f3a flags:# id:string type:string title:flags.1?string description:flags.2?string url:flags.3?string thumb:flags.4?WebDocument content:flags.5?WebDocument send_message:BotInlineMessage = BotInlineResult; botInlineMediaResult#17db940b flags:# id:string type:string photo:flags.0?Photo document:flags.1?Document title:flags.2?string description:flags.3?string send_message:BotInlineMessage = BotInlineResult; @@ -1241,7 +1253,7 @@ contacts.topPeersDisabled#b52c939d = contacts.TopPeers; draftMessageEmpty#1b0c841a flags:# date:flags.0?int = DraftMessage; -draftMessage#fd8e711f flags:# no_webpage:flags.1?true reply_to_msg_id:flags.0?int message:string entities:flags.3?Vector date:int = DraftMessage; +draftMessage#3fccf7ef flags:# no_webpage:flags.1?true invert_media:flags.6?true reply_to:flags.4?InputReplyTo message:string entities:flags.3?Vector media:flags.5?InputMedia date:int = DraftMessage; messages.featuredStickersNotModified#c6dc0c66 count:int = messages.FeaturedStickers; @@ -1559,6 +1571,10 @@ channelAdminLogEventActionPinTopic#5d8d353b flags:# prev_topic:flags.0?ForumTopi channelAdminLogEventActionToggleAntiSpam#64f36dfc new_value:Bool = ChannelAdminLogEventAction; +channelAdminLogEventActionChangeColor#3c2b247b prev_value:int new_value:int = ChannelAdminLogEventAction; + +channelAdminLogEventActionChangeBackgroundEmoji#445fc434 prev_value:long new_value:long = ChannelAdminLogEventAction; + channelAdminLogEvent#1fad68cd id:long date:int user_id:long action:ChannelAdminLogEventAction = ChannelAdminLogEvent; channels.adminLogResults#ed8af74d events:Vector chats:Vector users:Vector = channels.AdminLogResults; @@ -1929,7 +1945,7 @@ messages.messageViews#b6c4f543 views:Vector chats:Vector use messages.discussionMessage#a6341782 flags:# messages:Vector max_id:flags.0?int read_inbox_max_id:flags.1?int read_outbox_max_id:flags.2?int unread_count:int chats:Vector users:Vector = messages.DiscussionMessage; -messageReplyHeader#a6d57763 flags:# reply_to_scheduled:flags.2?true forum_topic:flags.3?true reply_to_msg_id:int reply_to_peer_id:flags.0?Peer reply_to_top_id:flags.1?int = MessageReplyHeader; +messageReplyHeader#6eebcabd flags:# reply_to_scheduled:flags.2?true forum_topic:flags.3?true quote:flags.9?true reply_to_msg_id:flags.4?int reply_to_peer_id:flags.0?Peer reply_from:flags.5?MessageFwdHeader reply_media:flags.8?MessageMedia reply_to_top_id:flags.1?int quote_text:flags.6?string quote_entities:flags.7?Vector = MessageReplyHeader; messageReplyStoryHeader#9c98bfc1 user_id:long story_id:int = MessageReplyHeader; @@ -2111,6 +2127,8 @@ inputInvoiceMessage#c5b56859 peer:InputPeer msg_id:int = InputInvoice; inputInvoiceSlug#c326caef slug:string = InputInvoice; +inputInvoicePremiumGiftCode#98986c0d purpose:InputStorePaymentPurpose option:PremiumGiftCodeOption = InputInvoice; + payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice; messages.transcribedAudio#93752c52 flags:# pending:flags.0?true transcription_id:long text:string = messages.TranscribedAudio; @@ -2121,6 +2139,10 @@ inputStorePaymentPremiumSubscription#a6751e66 flags:# restore:flags.0?true upgra inputStorePaymentGiftPremium#616f7fe8 user_id:InputUser currency:string amount:long = InputStorePaymentPurpose; +inputStorePaymentPremiumGiftCode#a3805f3f flags:# users:Vector boost_peer:flags.0?InputPeer currency:string amount:long = InputStorePaymentPurpose; + +inputStorePaymentPremiumGiveaway#7c9375e6 flags:# only_new_subscribers:flags.0?true boost_peer:InputPeer additional_peers:flags.1?Vector countries_iso2:flags.2?Vector random_id:long until_date:int currency:string amount:long = InputStorePaymentPurpose; + premiumGiftOption#74c34319 flags:# months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumGiftOption; paymentFormMethod#88f8f21b url:string title:string = PaymentFormMethod; @@ -2279,7 +2301,7 @@ stories.storyViewsList#46e9b9ec flags:# count:int reactions_count:int views:Vect stories.storyViews#de9eed1d views:Vector users:Vector = stories.StoryViews; -inputReplyToMessage#9c5386e4 flags:# reply_to_msg_id:int top_msg_id:flags.0?int = InputReplyTo; +inputReplyToMessage#73ec805 flags:# reply_to_msg_id:int top_msg_id:flags.0?int reply_to_peer_id:flags.1?InputPeer quote_text:flags.2?string quote_entities:flags.3?Vector = InputReplyTo; inputReplyToStory#15b0f283 user_id:InputUser story_id:int = InputReplyTo; @@ -2301,17 +2323,27 @@ peerStories#9a35e999 flags:# peer:Peer max_read_id:flags.0?int stories:Vector users:Vector = stories.PeerStories; -stories.boostsStatus#e5c1aa5c flags:# my_boost:flags.2?true level:int current_level_boosts:int boosts:int next_level_boosts:flags.0?int premium_audience:flags.1?StatsPercentValue boost_url:string = stories.BoostsStatus; +messages.webPage#fd5e12bd webpage:WebPage chats:Vector users:Vector = messages.WebPage; -stories.canApplyBoostOk#c3173587 = stories.CanApplyBoostResult; +premiumGiftCodeOption#257e962b flags:# users:int months:int store_product:flags.0?string store_quantity:flags.1?int currency:string amount:long = PremiumGiftCodeOption; -stories.canApplyBoostReplace#712c4655 current_boost:Peer chats:Vector = stories.CanApplyBoostResult; +payments.checkedGiftCode#b722f158 flags:# via_giveaway:flags.2?true from_id:Peer giveaway_msg_id:flags.3?int to_id:flags.0?long date:int months:int used_date:flags.1?int chats:Vector users:Vector = payments.CheckedGiftCode; -booster#e9e6380 user_id:long expires:int = Booster; +payments.giveawayInfo#4367daa0 flags:# participating:flags.0?true preparing_results:flags.3?true start_date:int joined_too_early_date:flags.1?int admin_disallowed_chat_id:flags.2?long disallowed_country:flags.4?string = payments.GiveawayInfo; -stories.boostersList#f3dd3d1d flags:# count:int boosters:Vector next_offset:flags.0?string users:Vector = stories.BoostersList; +payments.giveawayInfoResults#cd5570 flags:# winner:flags.0?true refunded:flags.1?true start_date:int gift_code_slug:flags.0?string finish_date:int winners_count:int activated_count:int = payments.GiveawayInfo; -messages.webPage#fd5e12bd webpage:WebPage chats:Vector users:Vector = messages.WebPage; +prepaidGiveaway#b2539d54 id:long months:int quantity:int date:int = PrepaidGiveaway; + +boost#2a1c8c71 flags:# gift:flags.1?true giveaway:flags.2?true unclaimed:flags.3?true id:string user_id:flags.0?long giveaway_msg_id:flags.2?int date:int expires:int used_gift_slug:flags.4?string multiplier:flags.5?int = Boost; + +premium.boostsList#86f8613c flags:# count:int boosts:Vector next_offset:flags.0?string users:Vector = premium.BoostsList; + +myBoost#c448415c flags:# slot:int peer:flags.0?Peer date:int expires:int cooldown_until_date:flags.1?int = MyBoost; + +premium.myBoosts#9ae228e2 my_boosts:Vector chats:Vector users:Vector = premium.MyBoosts; + +premium.boostsStatus#4959427a flags:# my_boost:flags.2?true level:int current_level_boosts:int boosts:int gift_boosts:flags.4?int next_level_boosts:flags.0?int premium_audience:flags.1?StatsPercentValue boost_url:string prepaid_giveaways:flags.3?Vector my_boost_slots:flags.2?Vector = premium.BoostsStatus; ---functions--- @@ -2550,6 +2582,10 @@ account.deleteAutoSaveExceptions#53bc0020 = Bool; account.invalidateSignInCodes#ca8ae8ba codes:Vector = Bool; +account.updateColor#a001cc43 flags:# color:int background_emoji_id:flags.0?long = Bool; + +account.getDefaultBackgroundEmojis#a60ab9ce hash:long = EmojiList; + users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#b60f5918 id:InputUser = users.UserFull; @@ -2624,9 +2660,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#280d096f 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:flags.0?InputReplyTo 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#280d096f 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 invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo 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#72ccc23d 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:flags.0?InputReplyTo 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#72ccc23d flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo 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#c661bbc4 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 top_msg_id:flags.9?int schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; @@ -2718,9 +2754,9 @@ messages.sendInlineBotResult#f7bc68ba flags:# silent:flags.5?true background:fla messages.getMessageEditData#fda68d36 peer:InputPeer id:int = messages.MessageEditData; -messages.editMessage#48f71778 flags:# no_webpage:flags.1?true peer:InputPeer id:int message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.15?int = Updates; +messages.editMessage#48f71778 flags:# no_webpage:flags.1?true invert_media:flags.16?true peer:InputPeer id:int message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.15?int = Updates; -messages.editInlineBotMessage#83557dba flags:# no_webpage:flags.1?true id:InputBotInlineMessageID message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector = Bool; +messages.editInlineBotMessage#83557dba flags:# no_webpage:flags.1?true invert_media:flags.16?true id:InputBotInlineMessageID message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector = Bool; messages.getBotCallbackAnswer#9342ca07 flags:# game:flags.1?true peer:InputPeer msg_id:int data:flags.0?bytes password:flags.2?InputCheckPasswordSRP = messages.BotCallbackAnswer; @@ -2728,7 +2764,7 @@ messages.setBotCallbackAnswer#d58f130a flags:# alert:flags.1?true query_id:long messages.getPeerDialogs#e470bcfd peers:Vector = messages.PeerDialogs; -messages.saveDraft#b4331e3f flags:# no_webpage:flags.1?true reply_to_msg_id:flags.0?int top_msg_id:flags.2?int peer:InputPeer message:string entities:flags.3?Vector = Bool; +messages.saveDraft#7ff3b806 flags:# no_webpage:flags.1?true invert_media:flags.6?true reply_to:flags.4?InputReplyTo peer:InputPeer message:string entities:flags.3?Vector media:flags.5?InputMedia = Bool; messages.getAllDrafts#6a3f8d65 = Updates; @@ -2784,7 +2820,7 @@ messages.readMentions#36e5bf4d flags:# peer:InputPeer top_msg_id:flags.0?int = m messages.getRecentLocations#702a40e0 peer:InputPeer limit:int hash:long = messages.Messages; -messages.sendMultiMedia#456e8987 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:flags.0?InputReplyTo multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMultiMedia#456e8987 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.uploadEncryptedFile#5057c497 peer:InputEncryptedChat file:InputEncryptedFile = EncryptedFile; @@ -3170,6 +3206,8 @@ channels.toggleParticipantsHidden#6a6e7854 channel:InputChannel enabled:Bool = U channels.clickSponsoredMessage#18afbc93 channel:InputChannel random_id:bytes = Bool; +channels.updateColor#621a201f flags:# channel:InputChannel color:int background_emoji_id:flags.0?long = Updates; + bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; @@ -3224,6 +3262,16 @@ payments.assignPlayMarketTransaction#dffd50d3 receipt:DataJSON purpose:InputStor payments.canPurchasePremium#9fc19eb6 purpose:InputStorePaymentPurpose = Bool; +payments.getPremiumGiftCodeOptions#2757ba54 flags:# boost_peer:flags.0?InputPeer = Vector; + +payments.checkGiftCode#8e51b4c1 slug:string = payments.CheckedGiftCode; + +payments.applyGiftCode#f6e26854 slug:string = Updates; + +payments.getGiveawayInfo#f4239425 peer:InputPeer msg_id:int = payments.GiveawayInfo; + +payments.launchPrepaidGiveaway#5ff58f20 peer:InputPeer giveaway_id:long purpose:InputStorePaymentPurpose = Updates; + stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true animated:flags.1?true videos:flags.4?true emojis:flags.5?true text_color:flags.6?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; @@ -3396,11 +3444,11 @@ stories.getChatsToSend#a56a8b60 = messages.Chats; stories.togglePeerStoriesHidden#bd0415c4 peer:InputPeer hidden:Bool = Bool; -stories.getBoostsStatus#4c449472 peer:InputPeer = stories.BoostsStatus; +premium.getBoostsList#60f67660 flags:# gifts:flags.0?true peer:InputPeer offset:string limit:int = premium.BoostsList; -stories.getBoostersList#337ef980 peer:InputPeer offset:string limit:int = stories.BoostersList; +premium.getMyBoosts#be77b4a = premium.MyBoosts; -stories.canApplyBoost#db05c1bd peer:InputPeer = stories.CanApplyBoostResult; +premium.applyBoost#6b7da746 flags:# slots:flags.0?Vector peer:InputPeer = premium.MyBoosts; -stories.applyBoost#f29d7c2b peer:InputPeer = Bool; +premium.getBoostsStatus#42f1f61 peer:InputPeer = premium.BoostsStatus; diff --git a/_schema/telegram.tl b/_schema/telegram.tl index 5c33435721..e0fd5598e7 100644 --- a/_schema/telegram.tl +++ b/_schema/telegram.tl @@ -2,8 +2,8 @@ // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl // Merge: _schema/legacy.tl,_schema/layer.tl -// Layer: 165 -// SHA256: 7bbf14403a05d0a385f4338ebfb196a278521b7f7e90881be20091de11ccd8ab +// Layer: 166 +// SHA256: 4056d76f6bec7a43b31a625278ee24c0a29cbd462dfc4769be1361c0221b96c7 boolFalse#bc799737 = Bool; @@ -75,6 +75,8 @@ inputMediaDice#e66fbf7b emoticon:string = InputMedia; inputMediaStory#89fdd778 peer:InputPeer id:int = InputMedia; +inputMediaWebPage#c21b8849 flags:# force_large_media:flags.0?true force_small_media:flags.1?true optional:flags.2?true url:string = InputMedia; + inputChatPhotoEmpty#1ca48f57 = InputChatPhoto; inputChatUploadedPhoto#bdcdaec0 flags:# file:flags.0?InputFile video:flags.1?InputFile video_start_ts:flags.2?double video_emoji_markup:flags.3?VideoSize = InputChatPhoto; @@ -137,7 +139,7 @@ storage.fileWebp#1081464c = storage.FileType; userEmpty#d3bc4b7a id:long = User; -user#abb5f120 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 flags2:# bot_can_edit:flags2.1?true close_friend:flags2.2?true stories_hidden:flags2.3?true stories_unavailable:flags2.4?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 usernames:flags2.0?Vector stories_max_id:flags2.5?int = User; +user#eb602f25 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 flags2:# bot_can_edit:flags2.1?true close_friend:flags2.2?true stories_hidden:flags2.3?true stories_unavailable:flags2.4?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 usernames:flags2.0?Vector stories_max_id:flags2.5?int color:flags2.7?int background_emoji_id:flags2.6?long = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; @@ -161,7 +163,7 @@ chat#41cbf256 flags:# creator:flags.0?true left:flags.2?true deactivated:flags.5 chatForbidden#6592a1a7 id:long title:string = Chat; -channel#94f592db flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true forum:flags.30?true flags2:# stories_hidden:flags2.1?true stories_hidden_min:flags2.2?true stories_unavailable:flags2.3?true id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int usernames:flags2.0?Vector stories_max_id:flags2.4?int = Chat; +channel#1981ea7e flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true forum:flags.30?true flags2:# stories_hidden:flags2.1?true stories_hidden_min:flags2.2?true stories_unavailable:flags2.3?true id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int usernames:flags2.0?Vector stories_max_id:flags2.4?int color:flags2.6?int background_emoji_id:flags2.5?long = Chat; channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat; @@ -185,7 +187,7 @@ chatPhoto#1c6e1c11 flags:# has_video:flags.0?true photo_id:long stripped_thumb:f messageEmpty#90a6ca84 flags:# id:int peer_id:flags.0?Peer = Message; -message#38116ee0 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true id:int from_id:flags.8?Peer peer_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int = Message; +message#38116ee0 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true id:int from_id:flags.8?Peer peer_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int = Message; messageService#2b085862 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?Peer peer_id:Peer reply_to:flags.3?MessageReplyHeader date:int action:MessageAction ttl_period:flags.25?int = Message; @@ -201,7 +203,7 @@ messageMediaUnsupported#9f84f49e = MessageMedia; messageMediaDocument#4cf4d72d flags:# nopremium:flags.3?true spoiler:flags.4?true document:flags.0?Document alt_document:flags.5?Document ttl_seconds:flags.2?int = MessageMedia; -messageMediaWebPage#a32dd600 webpage:WebPage = MessageMedia; +messageMediaWebPage#ddf10c3b flags:# force_large_media:flags.0?true force_small_media:flags.1?true manual:flags.3?true safe:flags.4?true webpage:WebPage = MessageMedia; messageMediaVenue#2ec0533f geo:GeoPoint title:string address:string provider:string venue_id:string venue_type:string = MessageMedia; @@ -217,6 +219,8 @@ messageMediaDice#3f7ee58b value:int emoticon:string = MessageMedia; messageMediaStory#68cb6283 flags:# via_mention:flags.1?true peer:Peer id:int story:flags.0?StoryItem = MessageMedia; +messageMediaGiveaway#58260664 flags:# only_new_subscribers:flags.0?true channels:Vector countries_iso2:flags.1?Vector quantity:int months:int until_date:int = MessageMedia; + messageActionEmpty#b6aef7b0 = MessageAction; messageActionChatCreate#bd47cbad title:string users:Vector = MessageAction; @@ -295,6 +299,10 @@ messageActionSetChatWallPaper#bc44a927 wallpaper:WallPaper = MessageAction; messageActionSetSameChatWallPaper#c0787d6d wallpaper:WallPaper = MessageAction; +messageActionGiftCode#d2cfdb0e flags:# via_giveaway:flags.0?true unclaimed:flags.2?true boost_peer:flags.1?Peer months:int slug:string = MessageAction; + +messageActionGiveawayLaunch#332ba9ed = MessageAction; + dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -477,7 +485,7 @@ updateDcOptions#8e5e9873 dc_options:Vector = Update; updateNotifySettings#bec268ef peer:NotifyPeer notify_settings:PeerNotifySettings = Update; -updateServiceNotification#ebe46819 flags:# popup:flags.0?true inbox_date:flags.1?int type:string message:string media:MessageMedia entities:Vector = Update; +updateServiceNotification#ebe46819 flags:# popup:flags.0?true invert_media:flags.2?true inbox_date:flags.1?int type:string message:string media:MessageMedia entities:Vector = Update; updatePrivacy#ee3b272a key:PrivacyKey rules:Vector = Update; @@ -925,11 +933,11 @@ messages.allStickers#cdbbcebb hash:long sets:Vector = messages.AllSt messages.affectedMessages#84d19185 pts:int pts_count:int = messages.AffectedMessages; -webPageEmpty#eb1477e8 id:long = WebPage; +webPageEmpty#211a1788 flags:# id:long url:flags.0?string = WebPage; -webPagePending#c586da1c id:long date:int = WebPage; +webPagePending#b0d13e47 flags:# id:long url:flags.0?string date:int = WebPage; -webPage#e89c45b2 flags:# id:long url:string display_url:string hash:int type:flags.0?string site_name:flags.1?string title:flags.2?string description:flags.3?string photo:flags.4?Photo embed_url:flags.5?string embed_type:flags.5?string embed_width:flags.6?int embed_height:flags.6?int duration:flags.7?int author:flags.8?string document:flags.9?Document cached_page:flags.10?Page attributes:flags.12?Vector = WebPage; +webPage#e89c45b2 flags:# has_large_media:flags.13?true id:long url:string display_url:string hash:int type:flags.0?string site_name:flags.1?string title:flags.2?string description:flags.3?string photo:flags.4?Photo embed_url:flags.5?string embed_type:flags.5?string embed_width:flags.6?int embed_height:flags.6?int duration:flags.7?int author:flags.8?string document:flags.9?Document cached_page:flags.10?Page attributes:flags.12?Vector = WebPage; webPageNotModified#7311ca11 flags:# cached_page_views:flags.0?int = WebPage; @@ -953,7 +961,7 @@ chatInvitePublicJoinRequests#ed107ab7 = ExportedChatInvite; chatInviteAlready#5a686d7c chat:Chat = ChatInvite; -chatInvite#300c44c1 flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true request_needed:flags.6?true verified:flags.7?true scam:flags.8?true fake:flags.9?true title:string about:flags.5?string photo:Photo participants_count:int participants:flags.4?Vector = ChatInvite; +chatInvite#cde0ec40 flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true request_needed:flags.6?true verified:flags.7?true scam:flags.8?true fake:flags.9?true title:string about:flags.5?string photo:Photo participants_count:int participants:flags.4?Vector color:int = ChatInvite; chatInvitePeek#61695cb0 chat:Chat expires:int = ChatInvite; @@ -977,7 +985,7 @@ inputStickerSetEmojiDefaultStatuses#29d0f5ee = InputStickerSet; inputStickerSetEmojiDefaultTopicIcons#44c1f8e9 = 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; +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 text_color:flags.9?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#6e153f16 set:StickerSet packs:Vector keywords:Vector documents:Vector = messages.StickerSet; @@ -1063,14 +1071,14 @@ messageEntityUnderline#9c4e7e8b offset:int length:int = MessageEntity; messageEntityStrike#bf0693d4 offset:int length:int = MessageEntity; -messageEntityBlockquote#20df5d0 offset:int length:int = MessageEntity; - messageEntityBankCard#761e6af4 offset:int length:int = MessageEntity; messageEntitySpoiler#32ca960f offset:int length:int = MessageEntity; messageEntityCustomEmoji#c8cf05f8 offset:int length:int document_id:long = MessageEntity; +messageEntityBlockquote#20df5d0 offset:int length:int = MessageEntity; + inputChannelEmpty#ee8c1e86 = InputChannel; inputChannel#f35aec28 channel_id:long access_hash:long = InputChannel; @@ -1131,9 +1139,9 @@ messages.savedGifsNotModified#e8025ca2 = messages.SavedGifs; messages.savedGifs#84a02a0d hash:long gifs:Vector = messages.SavedGifs; -inputBotInlineMessageMediaAuto#3380c786 flags:# message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; +inputBotInlineMessageMediaAuto#3380c786 flags:# invert_media:flags.3?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; -inputBotInlineMessageText#3dcd7a87 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; +inputBotInlineMessageText#3dcd7a87 flags:# no_webpage:flags.0?true invert_media:flags.3?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; inputBotInlineMessageMediaGeo#96929a85 flags:# geo_point:InputGeoPoint heading:flags.0?int period:flags.1?int proximity_notification_radius:flags.3?int reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; @@ -1145,6 +1153,8 @@ inputBotInlineMessageGame#4b425864 flags:# reply_markup:flags.2?ReplyMarkup = In inputBotInlineMessageMediaInvoice#d7e78225 flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:string provider_data:DataJSON reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; +inputBotInlineMessageMediaWebPage#bddcc510 flags:# invert_media:flags.3?true force_large_media:flags.4?true force_small_media:flags.5?true optional:flags.6?true message:string entities:flags.1?Vector url:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; + inputBotInlineResult#88bf9319 flags:# id:string type:string title:flags.1?string description:flags.2?string url:flags.3?string thumb:flags.4?InputWebDocument content:flags.5?InputWebDocument send_message:InputBotInlineMessage = InputBotInlineResult; inputBotInlineResultPhoto#a8d864a7 id:string type:string photo:InputPhoto send_message:InputBotInlineMessage = InputBotInlineResult; @@ -1153,9 +1163,9 @@ inputBotInlineResultDocument#fff8fdc4 flags:# id:string type:string title:flags. inputBotInlineResultGame#4fa417f2 id:string short_name:string send_message:InputBotInlineMessage = InputBotInlineResult; -botInlineMessageMediaAuto#764cf810 flags:# message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = BotInlineMessage; +botInlineMessageMediaAuto#764cf810 flags:# invert_media:flags.3?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = BotInlineMessage; -botInlineMessageText#8c7f65e2 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = BotInlineMessage; +botInlineMessageText#8c7f65e2 flags:# no_webpage:flags.0?true invert_media:flags.3?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = BotInlineMessage; botInlineMessageMediaGeo#51846fd flags:# geo:GeoPoint heading:flags.0?int period:flags.1?int proximity_notification_radius:flags.3?int reply_markup:flags.2?ReplyMarkup = BotInlineMessage; @@ -1165,6 +1175,8 @@ botInlineMessageMediaContact#18d1cdc2 flags:# phone_number:string first_name:str botInlineMessageMediaInvoice#354a9b09 flags:# shipping_address_requested:flags.1?true test:flags.3?true title:string description:string photo:flags.0?WebDocument currency:string total_amount:long reply_markup:flags.2?ReplyMarkup = BotInlineMessage; +botInlineMessageMediaWebPage#809ad9a6 flags:# invert_media:flags.3?true force_large_media:flags.4?true force_small_media:flags.5?true manual:flags.7?true safe:flags.8?true message:string entities:flags.1?Vector url:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage; + botInlineResult#11965f3a flags:# id:string type:string title:flags.1?string description:flags.2?string url:flags.3?string thumb:flags.4?WebDocument content:flags.5?WebDocument send_message:BotInlineMessage = BotInlineResult; botInlineMediaResult#17db940b flags:# id:string type:string photo:flags.0?Photo document:flags.1?Document title:flags.2?string description:flags.3?string send_message:BotInlineMessage = BotInlineResult; @@ -1243,7 +1255,7 @@ contacts.topPeersDisabled#b52c939d = contacts.TopPeers; draftMessageEmpty#1b0c841a flags:# date:flags.0?int = DraftMessage; -draftMessage#fd8e711f flags:# no_webpage:flags.1?true reply_to_msg_id:flags.0?int message:string entities:flags.3?Vector date:int = DraftMessage; +draftMessage#3fccf7ef flags:# no_webpage:flags.1?true invert_media:flags.6?true reply_to:flags.4?InputReplyTo message:string entities:flags.3?Vector media:flags.5?InputMedia date:int = DraftMessage; messages.featuredStickersNotModified#c6dc0c66 count:int = messages.FeaturedStickers; @@ -1561,6 +1573,10 @@ channelAdminLogEventActionPinTopic#5d8d353b flags:# prev_topic:flags.0?ForumTopi channelAdminLogEventActionToggleAntiSpam#64f36dfc new_value:Bool = ChannelAdminLogEventAction; +channelAdminLogEventActionChangeColor#3c2b247b prev_value:int new_value:int = ChannelAdminLogEventAction; + +channelAdminLogEventActionChangeBackgroundEmoji#445fc434 prev_value:long new_value:long = ChannelAdminLogEventAction; + channelAdminLogEvent#1fad68cd id:long date:int user_id:long action:ChannelAdminLogEventAction = ChannelAdminLogEvent; channels.adminLogResults#ed8af74d events:Vector chats:Vector users:Vector = channels.AdminLogResults; @@ -1931,7 +1947,7 @@ messages.messageViews#b6c4f543 views:Vector chats:Vector use messages.discussionMessage#a6341782 flags:# messages:Vector max_id:flags.0?int read_inbox_max_id:flags.1?int read_outbox_max_id:flags.2?int unread_count:int chats:Vector users:Vector = messages.DiscussionMessage; -messageReplyHeader#a6d57763 flags:# reply_to_scheduled:flags.2?true forum_topic:flags.3?true reply_to_msg_id:int reply_to_peer_id:flags.0?Peer reply_to_top_id:flags.1?int = MessageReplyHeader; +messageReplyHeader#6eebcabd flags:# reply_to_scheduled:flags.2?true forum_topic:flags.3?true quote:flags.9?true reply_to_msg_id:flags.4?int reply_to_peer_id:flags.0?Peer reply_from:flags.5?MessageFwdHeader reply_media:flags.8?MessageMedia reply_to_top_id:flags.1?int quote_text:flags.6?string quote_entities:flags.7?Vector = MessageReplyHeader; messageReplyStoryHeader#9c98bfc1 user_id:long story_id:int = MessageReplyHeader; @@ -2113,6 +2129,8 @@ inputInvoiceMessage#c5b56859 peer:InputPeer msg_id:int = InputInvoice; inputInvoiceSlug#c326caef slug:string = InputInvoice; +inputInvoicePremiumGiftCode#98986c0d purpose:InputStorePaymentPurpose option:PremiumGiftCodeOption = InputInvoice; + payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice; messages.transcribedAudio#93752c52 flags:# pending:flags.0?true transcription_id:long text:string = messages.TranscribedAudio; @@ -2123,6 +2141,10 @@ inputStorePaymentPremiumSubscription#a6751e66 flags:# restore:flags.0?true upgra inputStorePaymentGiftPremium#616f7fe8 user_id:InputUser currency:string amount:long = InputStorePaymentPurpose; +inputStorePaymentPremiumGiftCode#a3805f3f flags:# users:Vector boost_peer:flags.0?InputPeer currency:string amount:long = InputStorePaymentPurpose; + +inputStorePaymentPremiumGiveaway#7c9375e6 flags:# only_new_subscribers:flags.0?true boost_peer:InputPeer additional_peers:flags.1?Vector countries_iso2:flags.2?Vector random_id:long until_date:int currency:string amount:long = InputStorePaymentPurpose; + premiumGiftOption#74c34319 flags:# months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumGiftOption; paymentFormMethod#88f8f21b url:string title:string = PaymentFormMethod; @@ -2281,7 +2303,7 @@ stories.storyViewsList#46e9b9ec flags:# count:int reactions_count:int views:Vect stories.storyViews#de9eed1d views:Vector users:Vector = stories.StoryViews; -inputReplyToMessage#9c5386e4 flags:# reply_to_msg_id:int top_msg_id:flags.0?int = InputReplyTo; +inputReplyToMessage#73ec805 flags:# reply_to_msg_id:int top_msg_id:flags.0?int reply_to_peer_id:flags.1?InputPeer quote_text:flags.2?string quote_entities:flags.3?Vector = InputReplyTo; inputReplyToStory#15b0f283 user_id:InputUser story_id:int = InputReplyTo; @@ -2303,17 +2325,27 @@ peerStories#9a35e999 flags:# peer:Peer max_read_id:flags.0?int stories:Vector users:Vector = stories.PeerStories; -stories.boostsStatus#e5c1aa5c flags:# my_boost:flags.2?true level:int current_level_boosts:int boosts:int next_level_boosts:flags.0?int premium_audience:flags.1?StatsPercentValue boost_url:string = stories.BoostsStatus; +messages.webPage#fd5e12bd webpage:WebPage chats:Vector users:Vector = messages.WebPage; -stories.canApplyBoostOk#c3173587 = stories.CanApplyBoostResult; +premiumGiftCodeOption#257e962b flags:# users:int months:int store_product:flags.0?string store_quantity:flags.1?int currency:string amount:long = PremiumGiftCodeOption; -stories.canApplyBoostReplace#712c4655 current_boost:Peer chats:Vector = stories.CanApplyBoostResult; +payments.checkedGiftCode#b722f158 flags:# via_giveaway:flags.2?true from_id:Peer giveaway_msg_id:flags.3?int to_id:flags.0?long date:int months:int used_date:flags.1?int chats:Vector users:Vector = payments.CheckedGiftCode; -booster#e9e6380 user_id:long expires:int = Booster; +payments.giveawayInfo#4367daa0 flags:# participating:flags.0?true preparing_results:flags.3?true start_date:int joined_too_early_date:flags.1?int admin_disallowed_chat_id:flags.2?long disallowed_country:flags.4?string = payments.GiveawayInfo; -stories.boostersList#f3dd3d1d flags:# count:int boosters:Vector next_offset:flags.0?string users:Vector = stories.BoostersList; +payments.giveawayInfoResults#cd5570 flags:# winner:flags.0?true refunded:flags.1?true start_date:int gift_code_slug:flags.0?string finish_date:int winners_count:int activated_count:int = payments.GiveawayInfo; -messages.webPage#fd5e12bd webpage:WebPage chats:Vector users:Vector = messages.WebPage; +prepaidGiveaway#b2539d54 id:long months:int quantity:int date:int = PrepaidGiveaway; + +boost#2a1c8c71 flags:# gift:flags.1?true giveaway:flags.2?true unclaimed:flags.3?true id:string user_id:flags.0?long giveaway_msg_id:flags.2?int date:int expires:int used_gift_slug:flags.4?string multiplier:flags.5?int = Boost; + +premium.boostsList#86f8613c flags:# count:int boosts:Vector next_offset:flags.0?string users:Vector = premium.BoostsList; + +myBoost#c448415c flags:# slot:int peer:flags.0?Peer date:int expires:int cooldown_until_date:flags.1?int = MyBoost; + +premium.myBoosts#9ae228e2 my_boosts:Vector chats:Vector users:Vector = premium.MyBoosts; + +premium.boostsStatus#4959427a flags:# my_boost:flags.2?true level:int current_level_boosts:int boosts:int gift_boosts:flags.4?int next_level_boosts:flags.0?int premium_audience:flags.1?StatsPercentValue boost_url:string prepaid_giveaways:flags.3?Vector my_boost_slots:flags.2?Vector = premium.BoostsStatus; ---functions--- @@ -2552,6 +2584,10 @@ account.deleteAutoSaveExceptions#53bc0020 = Bool; account.invalidateSignInCodes#ca8ae8ba codes:Vector = Bool; +account.updateColor#a001cc43 flags:# color:int background_emoji_id:flags.0?long = Bool; + +account.getDefaultBackgroundEmojis#a60ab9ce hash:long = EmojiList; + users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#b60f5918 id:InputUser = users.UserFull; @@ -2626,9 +2662,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#280d096f 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:flags.0?InputReplyTo 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#280d096f 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 invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo 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#72ccc23d 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:flags.0?InputReplyTo 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#72ccc23d flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo 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#c661bbc4 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 top_msg_id:flags.9?int schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; @@ -2720,9 +2756,9 @@ messages.sendInlineBotResult#f7bc68ba flags:# silent:flags.5?true background:fla messages.getMessageEditData#fda68d36 peer:InputPeer id:int = messages.MessageEditData; -messages.editMessage#48f71778 flags:# no_webpage:flags.1?true peer:InputPeer id:int message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.15?int = Updates; +messages.editMessage#48f71778 flags:# no_webpage:flags.1?true invert_media:flags.16?true peer:InputPeer id:int message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.15?int = Updates; -messages.editInlineBotMessage#83557dba flags:# no_webpage:flags.1?true id:InputBotInlineMessageID message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector = Bool; +messages.editInlineBotMessage#83557dba flags:# no_webpage:flags.1?true invert_media:flags.16?true id:InputBotInlineMessageID message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector = Bool; messages.getBotCallbackAnswer#9342ca07 flags:# game:flags.1?true peer:InputPeer msg_id:int data:flags.0?bytes password:flags.2?InputCheckPasswordSRP = messages.BotCallbackAnswer; @@ -2730,7 +2766,7 @@ messages.setBotCallbackAnswer#d58f130a flags:# alert:flags.1?true query_id:long messages.getPeerDialogs#e470bcfd peers:Vector = messages.PeerDialogs; -messages.saveDraft#b4331e3f flags:# no_webpage:flags.1?true reply_to_msg_id:flags.0?int top_msg_id:flags.2?int peer:InputPeer message:string entities:flags.3?Vector = Bool; +messages.saveDraft#7ff3b806 flags:# no_webpage:flags.1?true invert_media:flags.6?true reply_to:flags.4?InputReplyTo peer:InputPeer message:string entities:flags.3?Vector media:flags.5?InputMedia = Bool; messages.getAllDrafts#6a3f8d65 = Updates; @@ -2786,7 +2822,7 @@ messages.readMentions#36e5bf4d flags:# peer:InputPeer top_msg_id:flags.0?int = m messages.getRecentLocations#702a40e0 peer:InputPeer limit:int hash:long = messages.Messages; -messages.sendMultiMedia#456e8987 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:flags.0?InputReplyTo multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMultiMedia#456e8987 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.uploadEncryptedFile#5057c497 peer:InputEncryptedChat file:InputEncryptedFile = EncryptedFile; @@ -3172,6 +3208,8 @@ channels.toggleParticipantsHidden#6a6e7854 channel:InputChannel enabled:Bool = U channels.clickSponsoredMessage#18afbc93 channel:InputChannel random_id:bytes = Bool; +channels.updateColor#621a201f flags:# channel:InputChannel color:int background_emoji_id:flags.0?long = Updates; + bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; @@ -3226,6 +3264,16 @@ payments.assignPlayMarketTransaction#dffd50d3 receipt:DataJSON purpose:InputStor payments.canPurchasePremium#9fc19eb6 purpose:InputStorePaymentPurpose = Bool; +payments.getPremiumGiftCodeOptions#2757ba54 flags:# boost_peer:flags.0?InputPeer = Vector; + +payments.checkGiftCode#8e51b4c1 slug:string = payments.CheckedGiftCode; + +payments.applyGiftCode#f6e26854 slug:string = Updates; + +payments.getGiveawayInfo#f4239425 peer:InputPeer msg_id:int = payments.GiveawayInfo; + +payments.launchPrepaidGiveaway#5ff58f20 peer:InputPeer giveaway_id:long purpose:InputStorePaymentPurpose = Updates; + stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true animated:flags.1?true videos:flags.4?true emojis:flags.5?true text_color:flags.6?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; @@ -3398,13 +3446,13 @@ stories.getChatsToSend#a56a8b60 = messages.Chats; stories.togglePeerStoriesHidden#bd0415c4 peer:InputPeer hidden:Bool = Bool; -stories.getBoostsStatus#4c449472 peer:InputPeer = stories.BoostsStatus; +premium.getBoostsList#60f67660 flags:# gifts:flags.0?true peer:InputPeer offset:string limit:int = premium.BoostsList; -stories.getBoostersList#337ef980 peer:InputPeer offset:string limit:int = stories.BoostersList; +premium.getMyBoosts#be77b4a = premium.MyBoosts; -stories.canApplyBoost#db05c1bd peer:InputPeer = stories.CanApplyBoostResult; +premium.applyBoost#6b7da746 flags:# slots:flags.0?Vector peer:InputPeer = premium.MyBoosts; -stories.applyBoost#f29d7c2b peer:InputPeer = Bool; +premium.getBoostsStatus#42f1f61 peer:InputPeer = premium.BoostsStatus; ---types--- @@ -3438,4 +3486,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 165 +// LAYER 166 diff --git a/telegram/message/entity/options.gen.go b/telegram/message/entity/options.gen.go index 2839158ae3..9c67208eef 100644 --- a/telegram/message/entity/options.gen.go +++ b/telegram/message/entity/options.gen.go @@ -319,25 +319,6 @@ func (b *Builder) Strike(s string) *Builder { return b.Format(s, Strike()) } -// Blockquote creates Formatter of Blockquote message entity. -// -// See https://core.telegram.org/constructor/messageEntityBlockquote. -func Blockquote() Formatter { - return func(offset, length int) tg.MessageEntityClass { - return &tg.MessageEntityBlockquote{ - Offset: offset, - Length: length, - } - } -} - -// Blockquote adds and formats message as Blockquote message entity. -// -// See https://core.telegram.org/constructor/messageEntityBlockquote. -func (b *Builder) Blockquote(s string) *Builder { - return b.Format(s, Blockquote()) -} - // BankCard creates Formatter of BankCard message entity. // // See https://core.telegram.org/constructor/messageEntityBankCard. @@ -395,3 +376,22 @@ func CustomEmoji(documentID int64) Formatter { func (b *Builder) CustomEmoji(s string, documentID int64) *Builder { return b.Format(s, CustomEmoji(documentID)) } + +// Blockquote creates Formatter of Blockquote message entity. +// +// See https://core.telegram.org/constructor/messageEntityBlockquote. +func Blockquote() Formatter { + return func(offset, length int) tg.MessageEntityClass { + return &tg.MessageEntityBlockquote{ + Offset: offset, + Length: length, + } + } +} + +// Blockquote adds and formats message as Blockquote message entity. +// +// See https://core.telegram.org/constructor/messageEntityBlockquote. +func (b *Builder) Blockquote(s string) *Builder { + return b.Format(s, Blockquote()) +} diff --git a/telegram/message/styling/options.gen.go b/telegram/message/styling/options.gen.go index 4a3e977550..df6f7402a6 100644 --- a/telegram/message/styling/options.gen.go +++ b/telegram/message/styling/options.gen.go @@ -172,16 +172,6 @@ func Strike(s string) StyledTextOption { }) } -// Blockquote formats text as Blockquote entity. -// -// See https://core.telegram.org/constructor/messageEntityBlockquote. -func Blockquote(s string) StyledTextOption { - return styledTextOption(s, func(b *textBuilder) error { - b.Blockquote(s) - return nil - }) -} - // BankCard formats text as BankCard entity. // // See https://core.telegram.org/constructor/messageEntityBankCard. @@ -211,3 +201,13 @@ func CustomEmoji(s string, documentID int64) StyledTextOption { return nil }) } + +// Blockquote formats text as Blockquote entity. +// +// See https://core.telegram.org/constructor/messageEntityBlockquote. +func Blockquote(s string) StyledTextOption { + return styledTextOption(s, func(b *textBuilder) error { + b.Blockquote(s) + return nil + }) +} diff --git a/telegram/query/cached/queries.gen.go b/telegram/query/cached/queries.gen.go index 7422d97bfe..3572918f46 100644 --- a/telegram/query/cached/queries.gen.go +++ b/telegram/query/cached/queries.gen.go @@ -98,6 +98,90 @@ func (s *AccountGetChatThemes) Fetch(ctx context.Context) (bool, error) { } } +type innerAccountGetDefaultBackgroundEmojis struct { + // Last received hash. + hash int64 + // Last received result. + value *tg.EmojiList +} + +type AccountGetDefaultBackgroundEmojis struct { + // Result state. + last atomic.Value + + // Reference to RPC client to make requests. + raw *tg.Client +} + +// NewAccountGetDefaultBackgroundEmojis creates new AccountGetDefaultBackgroundEmojis. +func NewAccountGetDefaultBackgroundEmojis(raw *tg.Client) *AccountGetDefaultBackgroundEmojis { + q := &AccountGetDefaultBackgroundEmojis{ + raw: raw, + } + + return q +} + +func (s *AccountGetDefaultBackgroundEmojis) store(v innerAccountGetDefaultBackgroundEmojis) { + s.last.Store(v) +} + +func (s *AccountGetDefaultBackgroundEmojis) load() (innerAccountGetDefaultBackgroundEmojis, bool) { + v, ok := s.last.Load().(innerAccountGetDefaultBackgroundEmojis) + return v, ok +} + +// Value returns last received result. +// NB: May be nil. Returned EmojiList must not be mutated. +func (s *AccountGetDefaultBackgroundEmojis) Value() *tg.EmojiList { + inner, _ := s.load() + return inner.value +} + +// Hash returns last received hash. +func (s *AccountGetDefaultBackgroundEmojis) Hash() int64 { + inner, _ := s.load() + return inner.hash +} + +// Get updates data if needed and returns it. +func (s *AccountGetDefaultBackgroundEmojis) Get(ctx context.Context) (*tg.EmojiList, 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 *AccountGetDefaultBackgroundEmojis) Fetch(ctx context.Context) (bool, error) { + lastHash := s.Hash() + + req := lastHash + result, err := s.raw.AccountGetDefaultBackgroundEmojis(ctx, req) + if err != nil { + return false, errors.Wrap(err, "execute AccountGetDefaultBackgroundEmojis") + } + + switch variant := result.(type) { + case *tg.EmojiList: + hash := variant.Hash + + s.store(innerAccountGetDefaultBackgroundEmojis{ + hash: hash, + value: variant, + }) + return true, nil + case *tg.EmojiListNotModified: + 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 innerAccountGetDefaultEmojiStatuses struct { // Last received hash. hash int64 diff --git a/tg/tl_account_get_default_background_emojis_gen.go b/tg/tl_account_get_default_background_emojis_gen.go new file mode 100644 index 0000000000..f2870079c4 --- /dev/null +++ b/tg/tl_account_get_default_background_emojis_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{} +) + +// AccountGetDefaultBackgroundEmojisRequest represents TL type `account.getDefaultBackgroundEmojis#a60ab9ce`. +// +// See https://core.telegram.org/method/account.getDefaultBackgroundEmojis for reference. +type AccountGetDefaultBackgroundEmojisRequest struct { + // Hash field of AccountGetDefaultBackgroundEmojisRequest. + Hash int64 +} + +// AccountGetDefaultBackgroundEmojisRequestTypeID is TL type id of AccountGetDefaultBackgroundEmojisRequest. +const AccountGetDefaultBackgroundEmojisRequestTypeID = 0xa60ab9ce + +// Ensuring interfaces in compile-time for AccountGetDefaultBackgroundEmojisRequest. +var ( + _ bin.Encoder = &AccountGetDefaultBackgroundEmojisRequest{} + _ bin.Decoder = &AccountGetDefaultBackgroundEmojisRequest{} + _ bin.BareEncoder = &AccountGetDefaultBackgroundEmojisRequest{} + _ bin.BareDecoder = &AccountGetDefaultBackgroundEmojisRequest{} +) + +func (g *AccountGetDefaultBackgroundEmojisRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *AccountGetDefaultBackgroundEmojisRequest) String() string { + if g == nil { + return "AccountGetDefaultBackgroundEmojisRequest(nil)" + } + type Alias AccountGetDefaultBackgroundEmojisRequest + return fmt.Sprintf("AccountGetDefaultBackgroundEmojisRequest%+v", Alias(*g)) +} + +// FillFrom fills AccountGetDefaultBackgroundEmojisRequest from given interface. +func (g *AccountGetDefaultBackgroundEmojisRequest) 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 (*AccountGetDefaultBackgroundEmojisRequest) TypeID() uint32 { + return AccountGetDefaultBackgroundEmojisRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountGetDefaultBackgroundEmojisRequest) TypeName() string { + return "account.getDefaultBackgroundEmojis" +} + +// TypeInfo returns info about TL type. +func (g *AccountGetDefaultBackgroundEmojisRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.getDefaultBackgroundEmojis", + ID: AccountGetDefaultBackgroundEmojisRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *AccountGetDefaultBackgroundEmojisRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode account.getDefaultBackgroundEmojis#a60ab9ce as nil") + } + b.PutID(AccountGetDefaultBackgroundEmojisRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *AccountGetDefaultBackgroundEmojisRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode account.getDefaultBackgroundEmojis#a60ab9ce as nil") + } + b.PutLong(g.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (g *AccountGetDefaultBackgroundEmojisRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode account.getDefaultBackgroundEmojis#a60ab9ce to nil") + } + if err := b.ConsumeID(AccountGetDefaultBackgroundEmojisRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.getDefaultBackgroundEmojis#a60ab9ce: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *AccountGetDefaultBackgroundEmojisRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode account.getDefaultBackgroundEmojis#a60ab9ce to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode account.getDefaultBackgroundEmojis#a60ab9ce: field hash: %w", err) + } + g.Hash = value + } + return nil +} + +// GetHash returns value of Hash field. +func (g *AccountGetDefaultBackgroundEmojisRequest) GetHash() (value int64) { + if g == nil { + return + } + return g.Hash +} + +// AccountGetDefaultBackgroundEmojis invokes method account.getDefaultBackgroundEmojis#a60ab9ce returning error if any. +// +// See https://core.telegram.org/method/account.getDefaultBackgroundEmojis for reference. +func (c *Client) AccountGetDefaultBackgroundEmojis(ctx context.Context, hash int64) (EmojiListClass, error) { + var result EmojiListBox + + request := &AccountGetDefaultBackgroundEmojisRequest{ + Hash: hash, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.EmojiList, nil +} diff --git a/tg/tl_booster_slices_gen.go b/tg/tl_account_get_default_background_emojis_slices_gen.go similarity index 100% rename from tg/tl_booster_slices_gen.go rename to tg/tl_account_get_default_background_emojis_slices_gen.go diff --git a/tg/tl_account_update_color_gen.go b/tg/tl_account_update_color_gen.go new file mode 100644 index 0000000000..bda15cf03c --- /dev/null +++ b/tg/tl_account_update_color_gen.go @@ -0,0 +1,240 @@ +// 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{} +) + +// AccountUpdateColorRequest represents TL type `account.updateColor#a001cc43`. +// +// See https://core.telegram.org/method/account.updateColor for reference. +type AccountUpdateColorRequest struct { + // Flags field of AccountUpdateColorRequest. + Flags bin.Fields + // Color field of AccountUpdateColorRequest. + Color int + // BackgroundEmojiID field of AccountUpdateColorRequest. + // + // Use SetBackgroundEmojiID and GetBackgroundEmojiID helpers. + BackgroundEmojiID int64 +} + +// AccountUpdateColorRequestTypeID is TL type id of AccountUpdateColorRequest. +const AccountUpdateColorRequestTypeID = 0xa001cc43 + +// Ensuring interfaces in compile-time for AccountUpdateColorRequest. +var ( + _ bin.Encoder = &AccountUpdateColorRequest{} + _ bin.Decoder = &AccountUpdateColorRequest{} + _ bin.BareEncoder = &AccountUpdateColorRequest{} + _ bin.BareDecoder = &AccountUpdateColorRequest{} +) + +func (u *AccountUpdateColorRequest) Zero() bool { + if u == nil { + return true + } + if !(u.Flags.Zero()) { + return false + } + if !(u.Color == 0) { + return false + } + if !(u.BackgroundEmojiID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *AccountUpdateColorRequest) String() string { + if u == nil { + return "AccountUpdateColorRequest(nil)" + } + type Alias AccountUpdateColorRequest + return fmt.Sprintf("AccountUpdateColorRequest%+v", Alias(*u)) +} + +// FillFrom fills AccountUpdateColorRequest from given interface. +func (u *AccountUpdateColorRequest) FillFrom(from interface { + GetColor() (value int) + GetBackgroundEmojiID() (value int64, ok bool) +}) { + u.Color = from.GetColor() + if val, ok := from.GetBackgroundEmojiID(); ok { + u.BackgroundEmojiID = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountUpdateColorRequest) TypeID() uint32 { + return AccountUpdateColorRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountUpdateColorRequest) TypeName() string { + return "account.updateColor" +} + +// TypeInfo returns info about TL type. +func (u *AccountUpdateColorRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.updateColor", + ID: AccountUpdateColorRequestTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Color", + SchemaName: "color", + }, + { + Name: "BackgroundEmojiID", + SchemaName: "background_emoji_id", + Null: !u.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (u *AccountUpdateColorRequest) SetFlags() { + if !(u.BackgroundEmojiID == 0) { + u.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (u *AccountUpdateColorRequest) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode account.updateColor#a001cc43 as nil") + } + b.PutID(AccountUpdateColorRequestTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *AccountUpdateColorRequest) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode account.updateColor#a001cc43 as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode account.updateColor#a001cc43: field flags: %w", err) + } + b.PutInt(u.Color) + if u.Flags.Has(0) { + b.PutLong(u.BackgroundEmojiID) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *AccountUpdateColorRequest) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode account.updateColor#a001cc43 to nil") + } + if err := b.ConsumeID(AccountUpdateColorRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.updateColor#a001cc43: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *AccountUpdateColorRequest) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode account.updateColor#a001cc43 to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode account.updateColor#a001cc43: field flags: %w", err) + } + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode account.updateColor#a001cc43: field color: %w", err) + } + u.Color = value + } + if u.Flags.Has(0) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode account.updateColor#a001cc43: field background_emoji_id: %w", err) + } + u.BackgroundEmojiID = value + } + return nil +} + +// GetColor returns value of Color field. +func (u *AccountUpdateColorRequest) GetColor() (value int) { + if u == nil { + return + } + return u.Color +} + +// SetBackgroundEmojiID sets value of BackgroundEmojiID conditional field. +func (u *AccountUpdateColorRequest) SetBackgroundEmojiID(value int64) { + u.Flags.Set(0) + u.BackgroundEmojiID = value +} + +// GetBackgroundEmojiID returns value of BackgroundEmojiID conditional field and +// boolean which is true if field was set. +func (u *AccountUpdateColorRequest) GetBackgroundEmojiID() (value int64, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.BackgroundEmojiID, true +} + +// AccountUpdateColor invokes method account.updateColor#a001cc43 returning error if any. +// +// See https://core.telegram.org/method/account.updateColor for reference. +func (c *Client) AccountUpdateColor(ctx context.Context, request *AccountUpdateColorRequest) (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_stories_apply_boost_slices_gen.go b/tg/tl_account_update_color_slices_gen.go similarity index 100% rename from tg/tl_stories_apply_boost_slices_gen.go rename to tg/tl_account_update_color_slices_gen.go diff --git a/tg/tl_boost_gen.go b/tg/tl_boost_gen.go new file mode 100644 index 0000000000..37f4268107 --- /dev/null +++ b/tg/tl_boost_gen.go @@ -0,0 +1,530 @@ +// 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{} +) + +// Boost represents TL type `boost#2a1c8c71`. +// +// See https://core.telegram.org/constructor/boost for reference. +type Boost struct { + // Flags field of Boost. + Flags bin.Fields + // Gift field of Boost. + Gift bool + // Giveaway field of Boost. + Giveaway bool + // Unclaimed field of Boost. + Unclaimed bool + // ID field of Boost. + ID string + // UserID field of Boost. + // + // Use SetUserID and GetUserID helpers. + UserID int64 + // GiveawayMsgID field of Boost. + // + // Use SetGiveawayMsgID and GetGiveawayMsgID helpers. + GiveawayMsgID int + // Date field of Boost. + Date int + // Expires field of Boost. + Expires int + // UsedGiftSlug field of Boost. + // + // Use SetUsedGiftSlug and GetUsedGiftSlug helpers. + UsedGiftSlug string + // Multiplier field of Boost. + // + // Use SetMultiplier and GetMultiplier helpers. + Multiplier int +} + +// BoostTypeID is TL type id of Boost. +const BoostTypeID = 0x2a1c8c71 + +// Ensuring interfaces in compile-time for Boost. +var ( + _ bin.Encoder = &Boost{} + _ bin.Decoder = &Boost{} + _ bin.BareEncoder = &Boost{} + _ bin.BareDecoder = &Boost{} +) + +func (b *Boost) Zero() bool { + if b == nil { + return true + } + if !(b.Flags.Zero()) { + return false + } + if !(b.Gift == false) { + return false + } + if !(b.Giveaway == false) { + return false + } + if !(b.Unclaimed == false) { + return false + } + if !(b.ID == "") { + return false + } + if !(b.UserID == 0) { + return false + } + if !(b.GiveawayMsgID == 0) { + return false + } + if !(b.Date == 0) { + return false + } + if !(b.Expires == 0) { + return false + } + if !(b.UsedGiftSlug == "") { + return false + } + if !(b.Multiplier == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (b *Boost) String() string { + if b == nil { + return "Boost(nil)" + } + type Alias Boost + return fmt.Sprintf("Boost%+v", Alias(*b)) +} + +// FillFrom fills Boost from given interface. +func (b *Boost) FillFrom(from interface { + GetGift() (value bool) + GetGiveaway() (value bool) + GetUnclaimed() (value bool) + GetID() (value string) + GetUserID() (value int64, ok bool) + GetGiveawayMsgID() (value int, ok bool) + GetDate() (value int) + GetExpires() (value int) + GetUsedGiftSlug() (value string, ok bool) + GetMultiplier() (value int, ok bool) +}) { + b.Gift = from.GetGift() + b.Giveaway = from.GetGiveaway() + b.Unclaimed = from.GetUnclaimed() + b.ID = from.GetID() + if val, ok := from.GetUserID(); ok { + b.UserID = val + } + + if val, ok := from.GetGiveawayMsgID(); ok { + b.GiveawayMsgID = val + } + + b.Date = from.GetDate() + b.Expires = from.GetExpires() + if val, ok := from.GetUsedGiftSlug(); ok { + b.UsedGiftSlug = val + } + + if val, ok := from.GetMultiplier(); ok { + b.Multiplier = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*Boost) TypeID() uint32 { + return BoostTypeID +} + +// TypeName returns name of type in TL schema. +func (*Boost) TypeName() string { + return "boost" +} + +// TypeInfo returns info about TL type. +func (b *Boost) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "boost", + ID: BoostTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Gift", + SchemaName: "gift", + Null: !b.Flags.Has(1), + }, + { + Name: "Giveaway", + SchemaName: "giveaway", + Null: !b.Flags.Has(2), + }, + { + Name: "Unclaimed", + SchemaName: "unclaimed", + Null: !b.Flags.Has(3), + }, + { + Name: "ID", + SchemaName: "id", + }, + { + Name: "UserID", + SchemaName: "user_id", + Null: !b.Flags.Has(0), + }, + { + Name: "GiveawayMsgID", + SchemaName: "giveaway_msg_id", + Null: !b.Flags.Has(2), + }, + { + Name: "Date", + SchemaName: "date", + }, + { + Name: "Expires", + SchemaName: "expires", + }, + { + Name: "UsedGiftSlug", + SchemaName: "used_gift_slug", + Null: !b.Flags.Has(4), + }, + { + Name: "Multiplier", + SchemaName: "multiplier", + Null: !b.Flags.Has(5), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (b *Boost) SetFlags() { + if !(b.Gift == false) { + b.Flags.Set(1) + } + if !(b.Giveaway == false) { + b.Flags.Set(2) + } + if !(b.Unclaimed == false) { + b.Flags.Set(3) + } + if !(b.UserID == 0) { + b.Flags.Set(0) + } + if !(b.GiveawayMsgID == 0) { + b.Flags.Set(2) + } + if !(b.UsedGiftSlug == "") { + b.Flags.Set(4) + } + if !(b.Multiplier == 0) { + b.Flags.Set(5) + } +} + +// Encode implements bin.Encoder. +func (b *Boost) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode boost#2a1c8c71 as nil") + } + buf.PutID(BoostTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *Boost) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode boost#2a1c8c71 as nil") + } + b.SetFlags() + if err := b.Flags.Encode(buf); err != nil { + return fmt.Errorf("unable to encode boost#2a1c8c71: field flags: %w", err) + } + buf.PutString(b.ID) + if b.Flags.Has(0) { + buf.PutLong(b.UserID) + } + if b.Flags.Has(2) { + buf.PutInt(b.GiveawayMsgID) + } + buf.PutInt(b.Date) + buf.PutInt(b.Expires) + if b.Flags.Has(4) { + buf.PutString(b.UsedGiftSlug) + } + if b.Flags.Has(5) { + buf.PutInt(b.Multiplier) + } + return nil +} + +// Decode implements bin.Decoder. +func (b *Boost) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode boost#2a1c8c71 to nil") + } + if err := buf.ConsumeID(BoostTypeID); err != nil { + return fmt.Errorf("unable to decode boost#2a1c8c71: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *Boost) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode boost#2a1c8c71 to nil") + } + { + if err := b.Flags.Decode(buf); err != nil { + return fmt.Errorf("unable to decode boost#2a1c8c71: field flags: %w", err) + } + } + b.Gift = b.Flags.Has(1) + b.Giveaway = b.Flags.Has(2) + b.Unclaimed = b.Flags.Has(3) + { + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode boost#2a1c8c71: field id: %w", err) + } + b.ID = value + } + if b.Flags.Has(0) { + value, err := buf.Long() + if err != nil { + return fmt.Errorf("unable to decode boost#2a1c8c71: field user_id: %w", err) + } + b.UserID = value + } + if b.Flags.Has(2) { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode boost#2a1c8c71: field giveaway_msg_id: %w", err) + } + b.GiveawayMsgID = value + } + { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode boost#2a1c8c71: field date: %w", err) + } + b.Date = value + } + { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode boost#2a1c8c71: field expires: %w", err) + } + b.Expires = value + } + if b.Flags.Has(4) { + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode boost#2a1c8c71: field used_gift_slug: %w", err) + } + b.UsedGiftSlug = value + } + if b.Flags.Has(5) { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode boost#2a1c8c71: field multiplier: %w", err) + } + b.Multiplier = value + } + return nil +} + +// SetGift sets value of Gift conditional field. +func (b *Boost) SetGift(value bool) { + if value { + b.Flags.Set(1) + b.Gift = true + } else { + b.Flags.Unset(1) + b.Gift = false + } +} + +// GetGift returns value of Gift conditional field. +func (b *Boost) GetGift() (value bool) { + if b == nil { + return + } + return b.Flags.Has(1) +} + +// SetGiveaway sets value of Giveaway conditional field. +func (b *Boost) SetGiveaway(value bool) { + if value { + b.Flags.Set(2) + b.Giveaway = true + } else { + b.Flags.Unset(2) + b.Giveaway = false + } +} + +// GetGiveaway returns value of Giveaway conditional field. +func (b *Boost) GetGiveaway() (value bool) { + if b == nil { + return + } + return b.Flags.Has(2) +} + +// SetUnclaimed sets value of Unclaimed conditional field. +func (b *Boost) SetUnclaimed(value bool) { + if value { + b.Flags.Set(3) + b.Unclaimed = true + } else { + b.Flags.Unset(3) + b.Unclaimed = false + } +} + +// GetUnclaimed returns value of Unclaimed conditional field. +func (b *Boost) GetUnclaimed() (value bool) { + if b == nil { + return + } + return b.Flags.Has(3) +} + +// GetID returns value of ID field. +func (b *Boost) GetID() (value string) { + if b == nil { + return + } + return b.ID +} + +// SetUserID sets value of UserID conditional field. +func (b *Boost) SetUserID(value int64) { + b.Flags.Set(0) + b.UserID = value +} + +// GetUserID returns value of UserID conditional field and +// boolean which is true if field was set. +func (b *Boost) GetUserID() (value int64, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(0) { + return value, false + } + return b.UserID, true +} + +// SetGiveawayMsgID sets value of GiveawayMsgID conditional field. +func (b *Boost) SetGiveawayMsgID(value int) { + b.Flags.Set(2) + b.GiveawayMsgID = value +} + +// GetGiveawayMsgID returns value of GiveawayMsgID conditional field and +// boolean which is true if field was set. +func (b *Boost) GetGiveawayMsgID() (value int, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(2) { + return value, false + } + return b.GiveawayMsgID, true +} + +// GetDate returns value of Date field. +func (b *Boost) GetDate() (value int) { + if b == nil { + return + } + return b.Date +} + +// GetExpires returns value of Expires field. +func (b *Boost) GetExpires() (value int) { + if b == nil { + return + } + return b.Expires +} + +// SetUsedGiftSlug sets value of UsedGiftSlug conditional field. +func (b *Boost) SetUsedGiftSlug(value string) { + b.Flags.Set(4) + b.UsedGiftSlug = value +} + +// GetUsedGiftSlug returns value of UsedGiftSlug conditional field and +// boolean which is true if field was set. +func (b *Boost) GetUsedGiftSlug() (value string, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(4) { + return value, false + } + return b.UsedGiftSlug, true +} + +// SetMultiplier sets value of Multiplier conditional field. +func (b *Boost) SetMultiplier(value int) { + b.Flags.Set(5) + b.Multiplier = value +} + +// GetMultiplier returns value of Multiplier conditional field and +// boolean which is true if field was set. +func (b *Boost) GetMultiplier() (value int, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(5) { + return value, false + } + return b.Multiplier, true +} diff --git a/tg/tl_stories_boosters_list_slices_gen.go b/tg/tl_boost_slices_gen.go similarity index 100% rename from tg/tl_stories_boosters_list_slices_gen.go rename to tg/tl_boost_slices_gen.go diff --git a/tg/tl_booster_gen.go b/tg/tl_booster_gen.go deleted file mode 100644 index 86c8484c32..0000000000 --- a/tg/tl_booster_gen.go +++ /dev/null @@ -1,188 +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{} -) - -// Booster represents TL type `booster#e9e6380`. -// -// See https://core.telegram.org/constructor/booster for reference. -type Booster struct { - // UserID field of Booster. - UserID int64 - // Expires field of Booster. - Expires int -} - -// BoosterTypeID is TL type id of Booster. -const BoosterTypeID = 0xe9e6380 - -// Ensuring interfaces in compile-time for Booster. -var ( - _ bin.Encoder = &Booster{} - _ bin.Decoder = &Booster{} - _ bin.BareEncoder = &Booster{} - _ bin.BareDecoder = &Booster{} -) - -func (b *Booster) Zero() bool { - if b == nil { - return true - } - if !(b.UserID == 0) { - return false - } - if !(b.Expires == 0) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (b *Booster) String() string { - if b == nil { - return "Booster(nil)" - } - type Alias Booster - return fmt.Sprintf("Booster%+v", Alias(*b)) -} - -// FillFrom fills Booster from given interface. -func (b *Booster) FillFrom(from interface { - GetUserID() (value int64) - GetExpires() (value int) -}) { - b.UserID = from.GetUserID() - b.Expires = from.GetExpires() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*Booster) TypeID() uint32 { - return BoosterTypeID -} - -// TypeName returns name of type in TL schema. -func (*Booster) TypeName() string { - return "booster" -} - -// TypeInfo returns info about TL type. -func (b *Booster) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "booster", - ID: BoosterTypeID, - } - if b == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "UserID", - SchemaName: "user_id", - }, - { - Name: "Expires", - SchemaName: "expires", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (b *Booster) Encode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't encode booster#e9e6380 as nil") - } - buf.PutID(BoosterTypeID) - return b.EncodeBare(buf) -} - -// EncodeBare implements bin.BareEncoder. -func (b *Booster) EncodeBare(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't encode booster#e9e6380 as nil") - } - buf.PutLong(b.UserID) - buf.PutInt(b.Expires) - return nil -} - -// Decode implements bin.Decoder. -func (b *Booster) Decode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't decode booster#e9e6380 to nil") - } - if err := buf.ConsumeID(BoosterTypeID); err != nil { - return fmt.Errorf("unable to decode booster#e9e6380: %w", err) - } - return b.DecodeBare(buf) -} - -// DecodeBare implements bin.BareDecoder. -func (b *Booster) DecodeBare(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't decode booster#e9e6380 to nil") - } - { - value, err := buf.Long() - if err != nil { - return fmt.Errorf("unable to decode booster#e9e6380: field user_id: %w", err) - } - b.UserID = value - } - { - value, err := buf.Int() - if err != nil { - return fmt.Errorf("unable to decode booster#e9e6380: field expires: %w", err) - } - b.Expires = value - } - return nil -} - -// GetUserID returns value of UserID field. -func (b *Booster) GetUserID() (value int64) { - if b == nil { - return - } - return b.UserID -} - -// GetExpires returns value of Expires field. -func (b *Booster) GetExpires() (value int) { - if b == nil { - return - } - return b.Expires -} diff --git a/tg/tl_bot_inline_message_gen.go b/tg/tl_bot_inline_message_gen.go index 9eca1672c3..7ed88a362e 100644 --- a/tg/tl_bot_inline_message_gen.go +++ b/tg/tl_bot_inline_message_gen.go @@ -44,6 +44,8 @@ type BotInlineMessageMediaAuto struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields + // InvertMedia field of BotInlineMessageMediaAuto. + InvertMedia bool // Caption Message string // Message entities for styled text¹ @@ -82,6 +84,9 @@ func (b *BotInlineMessageMediaAuto) Zero() bool { if !(b.Flags.Zero()) { return false } + if !(b.InvertMedia == false) { + return false + } if !(b.Message == "") { return false } @@ -106,10 +111,12 @@ func (b *BotInlineMessageMediaAuto) String() string { // FillFrom fills BotInlineMessageMediaAuto from given interface. func (b *BotInlineMessageMediaAuto) FillFrom(from interface { + GetInvertMedia() (value bool) GetMessage() (value string) GetEntities() (value []MessageEntityClass, ok bool) GetReplyMarkup() (value ReplyMarkupClass, ok bool) }) { + b.InvertMedia = from.GetInvertMedia() b.Message = from.GetMessage() if val, ok := from.GetEntities(); ok { b.Entities = val @@ -144,6 +151,11 @@ func (b *BotInlineMessageMediaAuto) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !b.Flags.Has(3), + }, { Name: "Message", SchemaName: "message", @@ -164,6 +176,9 @@ func (b *BotInlineMessageMediaAuto) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (b *BotInlineMessageMediaAuto) SetFlags() { + if !(b.InvertMedia == false) { + b.Flags.Set(3) + } if !(b.Entities == nil) { b.Flags.Set(1) } @@ -234,6 +249,7 @@ func (b *BotInlineMessageMediaAuto) DecodeBare(buf *bin.Buffer) error { return fmt.Errorf("unable to decode botInlineMessageMediaAuto#764cf810: field flags: %w", err) } } + b.InvertMedia = b.Flags.Has(3) { value, err := buf.String() if err != nil { @@ -268,6 +284,25 @@ func (b *BotInlineMessageMediaAuto) DecodeBare(buf *bin.Buffer) error { return nil } +// SetInvertMedia sets value of InvertMedia conditional field. +func (b *BotInlineMessageMediaAuto) SetInvertMedia(value bool) { + if value { + b.Flags.Set(3) + b.InvertMedia = true + } else { + b.Flags.Unset(3) + b.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (b *BotInlineMessageMediaAuto) GetInvertMedia() (value bool) { + if b == nil { + return + } + return b.Flags.Has(3) +} + // GetMessage returns value of Message field. func (b *BotInlineMessageMediaAuto) GetMessage() (value string) { if b == nil { @@ -332,6 +367,8 @@ type BotInlineMessageText struct { Flags bin.Fields // Disable webpage preview NoWebpage bool + // InvertMedia field of BotInlineMessageText. + InvertMedia bool // The message Message string // Message entities for styled text¹ @@ -373,6 +410,9 @@ func (b *BotInlineMessageText) Zero() bool { if !(b.NoWebpage == false) { return false } + if !(b.InvertMedia == false) { + return false + } if !(b.Message == "") { return false } @@ -398,11 +438,13 @@ func (b *BotInlineMessageText) String() string { // FillFrom fills BotInlineMessageText from given interface. func (b *BotInlineMessageText) FillFrom(from interface { GetNoWebpage() (value bool) + GetInvertMedia() (value bool) GetMessage() (value string) GetEntities() (value []MessageEntityClass, ok bool) GetReplyMarkup() (value ReplyMarkupClass, ok bool) }) { b.NoWebpage = from.GetNoWebpage() + b.InvertMedia = from.GetInvertMedia() b.Message = from.GetMessage() if val, ok := from.GetEntities(); ok { b.Entities = val @@ -442,6 +484,11 @@ func (b *BotInlineMessageText) TypeInfo() tdp.Type { SchemaName: "no_webpage", Null: !b.Flags.Has(0), }, + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !b.Flags.Has(3), + }, { Name: "Message", SchemaName: "message", @@ -465,6 +512,9 @@ func (b *BotInlineMessageText) SetFlags() { if !(b.NoWebpage == false) { b.Flags.Set(0) } + if !(b.InvertMedia == false) { + b.Flags.Set(3) + } if !(b.Entities == nil) { b.Flags.Set(1) } @@ -536,6 +586,7 @@ func (b *BotInlineMessageText) DecodeBare(buf *bin.Buffer) error { } } b.NoWebpage = b.Flags.Has(0) + b.InvertMedia = b.Flags.Has(3) { value, err := buf.String() if err != nil { @@ -589,6 +640,25 @@ func (b *BotInlineMessageText) GetNoWebpage() (value bool) { return b.Flags.Has(0) } +// SetInvertMedia sets value of InvertMedia conditional field. +func (b *BotInlineMessageText) SetInvertMedia(value bool) { + if value { + b.Flags.Set(3) + b.InvertMedia = true + } else { + b.Flags.Unset(3) + b.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (b *BotInlineMessageText) GetInvertMedia() (value bool) { + if b == nil { + return + } + return b.Flags.Has(3) +} + // GetMessage returns value of Message field. func (b *BotInlineMessageText) GetMessage() (value string) { if b == nil { @@ -2067,6 +2137,487 @@ func (b *BotInlineMessageMediaInvoice) GetReplyMarkup() (value ReplyMarkupClass, return b.ReplyMarkup, true } +// BotInlineMessageMediaWebPage represents TL type `botInlineMessageMediaWebPage#809ad9a6`. +// +// See https://core.telegram.org/constructor/botInlineMessageMediaWebPage for reference. +type BotInlineMessageMediaWebPage struct { + // Flags field of BotInlineMessageMediaWebPage. + Flags bin.Fields + // InvertMedia field of BotInlineMessageMediaWebPage. + InvertMedia bool + // ForceLargeMedia field of BotInlineMessageMediaWebPage. + ForceLargeMedia bool + // ForceSmallMedia field of BotInlineMessageMediaWebPage. + ForceSmallMedia bool + // Manual field of BotInlineMessageMediaWebPage. + Manual bool + // Safe field of BotInlineMessageMediaWebPage. + Safe bool + // Message field of BotInlineMessageMediaWebPage. + Message string + // Entities field of BotInlineMessageMediaWebPage. + // + // Use SetEntities and GetEntities helpers. + Entities []MessageEntityClass + // URL field of BotInlineMessageMediaWebPage. + URL string + // ReplyMarkup field of BotInlineMessageMediaWebPage. + // + // Use SetReplyMarkup and GetReplyMarkup helpers. + ReplyMarkup ReplyMarkupClass +} + +// BotInlineMessageMediaWebPageTypeID is TL type id of BotInlineMessageMediaWebPage. +const BotInlineMessageMediaWebPageTypeID = 0x809ad9a6 + +// construct implements constructor of BotInlineMessageClass. +func (b BotInlineMessageMediaWebPage) construct() BotInlineMessageClass { return &b } + +// Ensuring interfaces in compile-time for BotInlineMessageMediaWebPage. +var ( + _ bin.Encoder = &BotInlineMessageMediaWebPage{} + _ bin.Decoder = &BotInlineMessageMediaWebPage{} + _ bin.BareEncoder = &BotInlineMessageMediaWebPage{} + _ bin.BareDecoder = &BotInlineMessageMediaWebPage{} + + _ BotInlineMessageClass = &BotInlineMessageMediaWebPage{} +) + +func (b *BotInlineMessageMediaWebPage) Zero() bool { + if b == nil { + return true + } + if !(b.Flags.Zero()) { + return false + } + if !(b.InvertMedia == false) { + return false + } + if !(b.ForceLargeMedia == false) { + return false + } + if !(b.ForceSmallMedia == false) { + return false + } + if !(b.Manual == false) { + return false + } + if !(b.Safe == false) { + return false + } + if !(b.Message == "") { + return false + } + if !(b.Entities == nil) { + return false + } + if !(b.URL == "") { + return false + } + if !(b.ReplyMarkup == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (b *BotInlineMessageMediaWebPage) String() string { + if b == nil { + return "BotInlineMessageMediaWebPage(nil)" + } + type Alias BotInlineMessageMediaWebPage + return fmt.Sprintf("BotInlineMessageMediaWebPage%+v", Alias(*b)) +} + +// FillFrom fills BotInlineMessageMediaWebPage from given interface. +func (b *BotInlineMessageMediaWebPage) FillFrom(from interface { + GetInvertMedia() (value bool) + GetForceLargeMedia() (value bool) + GetForceSmallMedia() (value bool) + GetManual() (value bool) + GetSafe() (value bool) + GetMessage() (value string) + GetEntities() (value []MessageEntityClass, ok bool) + GetURL() (value string) + GetReplyMarkup() (value ReplyMarkupClass, ok bool) +}) { + b.InvertMedia = from.GetInvertMedia() + b.ForceLargeMedia = from.GetForceLargeMedia() + b.ForceSmallMedia = from.GetForceSmallMedia() + b.Manual = from.GetManual() + b.Safe = from.GetSafe() + b.Message = from.GetMessage() + if val, ok := from.GetEntities(); ok { + b.Entities = val + } + + b.URL = from.GetURL() + if val, ok := from.GetReplyMarkup(); ok { + b.ReplyMarkup = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotInlineMessageMediaWebPage) TypeID() uint32 { + return BotInlineMessageMediaWebPageTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotInlineMessageMediaWebPage) TypeName() string { + return "botInlineMessageMediaWebPage" +} + +// TypeInfo returns info about TL type. +func (b *BotInlineMessageMediaWebPage) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "botInlineMessageMediaWebPage", + ID: BotInlineMessageMediaWebPageTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !b.Flags.Has(3), + }, + { + Name: "ForceLargeMedia", + SchemaName: "force_large_media", + Null: !b.Flags.Has(4), + }, + { + Name: "ForceSmallMedia", + SchemaName: "force_small_media", + Null: !b.Flags.Has(5), + }, + { + Name: "Manual", + SchemaName: "manual", + Null: !b.Flags.Has(7), + }, + { + Name: "Safe", + SchemaName: "safe", + Null: !b.Flags.Has(8), + }, + { + Name: "Message", + SchemaName: "message", + }, + { + Name: "Entities", + SchemaName: "entities", + Null: !b.Flags.Has(1), + }, + { + Name: "URL", + SchemaName: "url", + }, + { + Name: "ReplyMarkup", + SchemaName: "reply_markup", + Null: !b.Flags.Has(2), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (b *BotInlineMessageMediaWebPage) SetFlags() { + if !(b.InvertMedia == false) { + b.Flags.Set(3) + } + if !(b.ForceLargeMedia == false) { + b.Flags.Set(4) + } + if !(b.ForceSmallMedia == false) { + b.Flags.Set(5) + } + if !(b.Manual == false) { + b.Flags.Set(7) + } + if !(b.Safe == false) { + b.Flags.Set(8) + } + if !(b.Entities == nil) { + b.Flags.Set(1) + } + if !(b.ReplyMarkup == nil) { + b.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (b *BotInlineMessageMediaWebPage) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode botInlineMessageMediaWebPage#809ad9a6 as nil") + } + buf.PutID(BotInlineMessageMediaWebPageTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *BotInlineMessageMediaWebPage) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode botInlineMessageMediaWebPage#809ad9a6 as nil") + } + b.SetFlags() + if err := b.Flags.Encode(buf); err != nil { + return fmt.Errorf("unable to encode botInlineMessageMediaWebPage#809ad9a6: field flags: %w", err) + } + buf.PutString(b.Message) + if b.Flags.Has(1) { + buf.PutVectorHeader(len(b.Entities)) + for idx, v := range b.Entities { + if v == nil { + return fmt.Errorf("unable to encode botInlineMessageMediaWebPage#809ad9a6: field entities element with index %d is nil", idx) + } + if err := v.Encode(buf); err != nil { + return fmt.Errorf("unable to encode botInlineMessageMediaWebPage#809ad9a6: field entities element with index %d: %w", idx, err) + } + } + } + buf.PutString(b.URL) + if b.Flags.Has(2) { + if b.ReplyMarkup == nil { + return fmt.Errorf("unable to encode botInlineMessageMediaWebPage#809ad9a6: field reply_markup is nil") + } + if err := b.ReplyMarkup.Encode(buf); err != nil { + return fmt.Errorf("unable to encode botInlineMessageMediaWebPage#809ad9a6: field reply_markup: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (b *BotInlineMessageMediaWebPage) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode botInlineMessageMediaWebPage#809ad9a6 to nil") + } + if err := buf.ConsumeID(BotInlineMessageMediaWebPageTypeID); err != nil { + return fmt.Errorf("unable to decode botInlineMessageMediaWebPage#809ad9a6: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *BotInlineMessageMediaWebPage) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode botInlineMessageMediaWebPage#809ad9a6 to nil") + } + { + if err := b.Flags.Decode(buf); err != nil { + return fmt.Errorf("unable to decode botInlineMessageMediaWebPage#809ad9a6: field flags: %w", err) + } + } + b.InvertMedia = b.Flags.Has(3) + b.ForceLargeMedia = b.Flags.Has(4) + b.ForceSmallMedia = b.Flags.Has(5) + b.Manual = b.Flags.Has(7) + b.Safe = b.Flags.Has(8) + { + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode botInlineMessageMediaWebPage#809ad9a6: field message: %w", err) + } + b.Message = value + } + if b.Flags.Has(1) { + headerLen, err := buf.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode botInlineMessageMediaWebPage#809ad9a6: field entities: %w", err) + } + + if headerLen > 0 { + b.Entities = make([]MessageEntityClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeMessageEntity(buf) + if err != nil { + return fmt.Errorf("unable to decode botInlineMessageMediaWebPage#809ad9a6: field entities: %w", err) + } + b.Entities = append(b.Entities, value) + } + } + { + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode botInlineMessageMediaWebPage#809ad9a6: field url: %w", err) + } + b.URL = value + } + if b.Flags.Has(2) { + value, err := DecodeReplyMarkup(buf) + if err != nil { + return fmt.Errorf("unable to decode botInlineMessageMediaWebPage#809ad9a6: field reply_markup: %w", err) + } + b.ReplyMarkup = value + } + return nil +} + +// SetInvertMedia sets value of InvertMedia conditional field. +func (b *BotInlineMessageMediaWebPage) SetInvertMedia(value bool) { + if value { + b.Flags.Set(3) + b.InvertMedia = true + } else { + b.Flags.Unset(3) + b.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (b *BotInlineMessageMediaWebPage) GetInvertMedia() (value bool) { + if b == nil { + return + } + return b.Flags.Has(3) +} + +// SetForceLargeMedia sets value of ForceLargeMedia conditional field. +func (b *BotInlineMessageMediaWebPage) SetForceLargeMedia(value bool) { + if value { + b.Flags.Set(4) + b.ForceLargeMedia = true + } else { + b.Flags.Unset(4) + b.ForceLargeMedia = false + } +} + +// GetForceLargeMedia returns value of ForceLargeMedia conditional field. +func (b *BotInlineMessageMediaWebPage) GetForceLargeMedia() (value bool) { + if b == nil { + return + } + return b.Flags.Has(4) +} + +// SetForceSmallMedia sets value of ForceSmallMedia conditional field. +func (b *BotInlineMessageMediaWebPage) SetForceSmallMedia(value bool) { + if value { + b.Flags.Set(5) + b.ForceSmallMedia = true + } else { + b.Flags.Unset(5) + b.ForceSmallMedia = false + } +} + +// GetForceSmallMedia returns value of ForceSmallMedia conditional field. +func (b *BotInlineMessageMediaWebPage) GetForceSmallMedia() (value bool) { + if b == nil { + return + } + return b.Flags.Has(5) +} + +// SetManual sets value of Manual conditional field. +func (b *BotInlineMessageMediaWebPage) SetManual(value bool) { + if value { + b.Flags.Set(7) + b.Manual = true + } else { + b.Flags.Unset(7) + b.Manual = false + } +} + +// GetManual returns value of Manual conditional field. +func (b *BotInlineMessageMediaWebPage) GetManual() (value bool) { + if b == nil { + return + } + return b.Flags.Has(7) +} + +// SetSafe sets value of Safe conditional field. +func (b *BotInlineMessageMediaWebPage) SetSafe(value bool) { + if value { + b.Flags.Set(8) + b.Safe = true + } else { + b.Flags.Unset(8) + b.Safe = false + } +} + +// GetSafe returns value of Safe conditional field. +func (b *BotInlineMessageMediaWebPage) GetSafe() (value bool) { + if b == nil { + return + } + return b.Flags.Has(8) +} + +// GetMessage returns value of Message field. +func (b *BotInlineMessageMediaWebPage) GetMessage() (value string) { + if b == nil { + return + } + return b.Message +} + +// SetEntities sets value of Entities conditional field. +func (b *BotInlineMessageMediaWebPage) SetEntities(value []MessageEntityClass) { + b.Flags.Set(1) + b.Entities = value +} + +// GetEntities returns value of Entities conditional field and +// boolean which is true if field was set. +func (b *BotInlineMessageMediaWebPage) GetEntities() (value []MessageEntityClass, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(1) { + return value, false + } + return b.Entities, true +} + +// GetURL returns value of URL field. +func (b *BotInlineMessageMediaWebPage) GetURL() (value string) { + if b == nil { + return + } + return b.URL +} + +// SetReplyMarkup sets value of ReplyMarkup conditional field. +func (b *BotInlineMessageMediaWebPage) SetReplyMarkup(value ReplyMarkupClass) { + b.Flags.Set(2) + b.ReplyMarkup = value +} + +// GetReplyMarkup returns value of ReplyMarkup conditional field and +// boolean which is true if field was set. +func (b *BotInlineMessageMediaWebPage) GetReplyMarkup() (value ReplyMarkupClass, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(2) { + return value, false + } + return b.ReplyMarkup, true +} + +// MapEntities returns field Entities wrapped in MessageEntityClassArray helper. +func (b *BotInlineMessageMediaWebPage) MapEntities() (value MessageEntityClassArray, ok bool) { + if !b.Flags.Has(1) { + return value, false + } + return MessageEntityClassArray(b.Entities), true +} + // BotInlineMessageClassName is schema name of BotInlineMessageClass. const BotInlineMessageClassName = "BotInlineMessage" @@ -2087,6 +2638,7 @@ const BotInlineMessageClassName = "BotInlineMessage" // case *tg.BotInlineMessageMediaVenue: // botInlineMessageMediaVenue#8a86659c // case *tg.BotInlineMessageMediaContact: // botInlineMessageMediaContact#18d1cdc2 // case *tg.BotInlineMessageMediaInvoice: // botInlineMessageMediaInvoice#354a9b09 +// case *tg.BotInlineMessageMediaWebPage: // botInlineMessageMediaWebPage#809ad9a6 // default: panic(v) // } type BotInlineMessageClass interface { @@ -2160,6 +2712,13 @@ func DecodeBotInlineMessage(buf *bin.Buffer) (BotInlineMessageClass, error) { return nil, fmt.Errorf("unable to decode BotInlineMessageClass: %w", err) } return &v, nil + case BotInlineMessageMediaWebPageTypeID: + // Decoding botInlineMessageMediaWebPage#809ad9a6. + v := BotInlineMessageMediaWebPage{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode BotInlineMessageClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode BotInlineMessageClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_bot_inline_message_slices_gen.go b/tg/tl_bot_inline_message_slices_gen.go index cc317956b1..e97b33021a 100644 --- a/tg/tl_bot_inline_message_slices_gen.go +++ b/tg/tl_bot_inline_message_slices_gen.go @@ -194,6 +194,19 @@ func (s BotInlineMessageClassArray) AsBotInlineMessageMediaInvoice() (to BotInli return to } +// AsBotInlineMessageMediaWebPage returns copy with only BotInlineMessageMediaWebPage constructors. +func (s BotInlineMessageClassArray) AsBotInlineMessageMediaWebPage() (to BotInlineMessageMediaWebPageArray) { + for _, elem := range s { + value, ok := elem.(*BotInlineMessageMediaWebPage) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // BotInlineMessageMediaAutoArray is adapter for slice of BotInlineMessageMediaAuto. type BotInlineMessageMediaAutoArray []BotInlineMessageMediaAuto @@ -685,3 +698,85 @@ func (s *BotInlineMessageMediaInvoiceArray) Pop() (v BotInlineMessageMediaInvoic return v, true } + +// BotInlineMessageMediaWebPageArray is adapter for slice of BotInlineMessageMediaWebPage. +type BotInlineMessageMediaWebPageArray []BotInlineMessageMediaWebPage + +// Sort sorts slice of BotInlineMessageMediaWebPage. +func (s BotInlineMessageMediaWebPageArray) Sort(less func(a, b BotInlineMessageMediaWebPage) bool) BotInlineMessageMediaWebPageArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of BotInlineMessageMediaWebPage. +func (s BotInlineMessageMediaWebPageArray) SortStable(less func(a, b BotInlineMessageMediaWebPage) bool) BotInlineMessageMediaWebPageArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of BotInlineMessageMediaWebPage. +func (s BotInlineMessageMediaWebPageArray) Retain(keep func(x BotInlineMessageMediaWebPage) bool) BotInlineMessageMediaWebPageArray { + 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 BotInlineMessageMediaWebPageArray) First() (v BotInlineMessageMediaWebPage, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s BotInlineMessageMediaWebPageArray) Last() (v BotInlineMessageMediaWebPage, 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 *BotInlineMessageMediaWebPageArray) PopFirst() (v BotInlineMessageMediaWebPage, 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 BotInlineMessageMediaWebPage + 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 *BotInlineMessageMediaWebPageArray) Pop() (v BotInlineMessageMediaWebPage, 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_channel_admin_log_event_action_gen.go b/tg/tl_channel_admin_log_event_action_gen.go index 6cbe2dcd52..b80a19d4e5 100644 --- a/tg/tl_channel_admin_log_event_action_gen.go +++ b/tg/tl_channel_admin_log_event_action_gen.go @@ -6707,6 +6707,330 @@ func (c *ChannelAdminLogEventActionToggleAntiSpam) GetNewValue() (value bool) { return c.NewValue } +// ChannelAdminLogEventActionChangeColor represents TL type `channelAdminLogEventActionChangeColor#3c2b247b`. +// +// See https://core.telegram.org/constructor/channelAdminLogEventActionChangeColor for reference. +type ChannelAdminLogEventActionChangeColor struct { + // PrevValue field of ChannelAdminLogEventActionChangeColor. + PrevValue int + // NewValue field of ChannelAdminLogEventActionChangeColor. + NewValue int +} + +// ChannelAdminLogEventActionChangeColorTypeID is TL type id of ChannelAdminLogEventActionChangeColor. +const ChannelAdminLogEventActionChangeColorTypeID = 0x3c2b247b + +// construct implements constructor of ChannelAdminLogEventActionClass. +func (c ChannelAdminLogEventActionChangeColor) construct() ChannelAdminLogEventActionClass { return &c } + +// Ensuring interfaces in compile-time for ChannelAdminLogEventActionChangeColor. +var ( + _ bin.Encoder = &ChannelAdminLogEventActionChangeColor{} + _ bin.Decoder = &ChannelAdminLogEventActionChangeColor{} + _ bin.BareEncoder = &ChannelAdminLogEventActionChangeColor{} + _ bin.BareDecoder = &ChannelAdminLogEventActionChangeColor{} + + _ ChannelAdminLogEventActionClass = &ChannelAdminLogEventActionChangeColor{} +) + +func (c *ChannelAdminLogEventActionChangeColor) Zero() bool { + if c == nil { + return true + } + if !(c.PrevValue == 0) { + return false + } + if !(c.NewValue == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChannelAdminLogEventActionChangeColor) String() string { + if c == nil { + return "ChannelAdminLogEventActionChangeColor(nil)" + } + type Alias ChannelAdminLogEventActionChangeColor + return fmt.Sprintf("ChannelAdminLogEventActionChangeColor%+v", Alias(*c)) +} + +// FillFrom fills ChannelAdminLogEventActionChangeColor from given interface. +func (c *ChannelAdminLogEventActionChangeColor) FillFrom(from interface { + GetPrevValue() (value int) + GetNewValue() (value int) +}) { + c.PrevValue = from.GetPrevValue() + c.NewValue = from.GetNewValue() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelAdminLogEventActionChangeColor) TypeID() uint32 { + return ChannelAdminLogEventActionChangeColorTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelAdminLogEventActionChangeColor) TypeName() string { + return "channelAdminLogEventActionChangeColor" +} + +// TypeInfo returns info about TL type. +func (c *ChannelAdminLogEventActionChangeColor) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channelAdminLogEventActionChangeColor", + ID: ChannelAdminLogEventActionChangeColorTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "PrevValue", + SchemaName: "prev_value", + }, + { + Name: "NewValue", + SchemaName: "new_value", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *ChannelAdminLogEventActionChangeColor) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionChangeColor#3c2b247b as nil") + } + b.PutID(ChannelAdminLogEventActionChangeColorTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChannelAdminLogEventActionChangeColor) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionChangeColor#3c2b247b as nil") + } + b.PutInt(c.PrevValue) + b.PutInt(c.NewValue) + return nil +} + +// Decode implements bin.Decoder. +func (c *ChannelAdminLogEventActionChangeColor) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionChangeColor#3c2b247b to nil") + } + if err := b.ConsumeID(ChannelAdminLogEventActionChangeColorTypeID); err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeColor#3c2b247b: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChannelAdminLogEventActionChangeColor) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionChangeColor#3c2b247b to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeColor#3c2b247b: field prev_value: %w", err) + } + c.PrevValue = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeColor#3c2b247b: field new_value: %w", err) + } + c.NewValue = value + } + return nil +} + +// GetPrevValue returns value of PrevValue field. +func (c *ChannelAdminLogEventActionChangeColor) GetPrevValue() (value int) { + if c == nil { + return + } + return c.PrevValue +} + +// GetNewValue returns value of NewValue field. +func (c *ChannelAdminLogEventActionChangeColor) GetNewValue() (value int) { + if c == nil { + return + } + return c.NewValue +} + +// ChannelAdminLogEventActionChangeBackgroundEmoji represents TL type `channelAdminLogEventActionChangeBackgroundEmoji#445fc434`. +// +// See https://core.telegram.org/constructor/channelAdminLogEventActionChangeBackgroundEmoji for reference. +type ChannelAdminLogEventActionChangeBackgroundEmoji struct { + // PrevValue field of ChannelAdminLogEventActionChangeBackgroundEmoji. + PrevValue int64 + // NewValue field of ChannelAdminLogEventActionChangeBackgroundEmoji. + NewValue int64 +} + +// ChannelAdminLogEventActionChangeBackgroundEmojiTypeID is TL type id of ChannelAdminLogEventActionChangeBackgroundEmoji. +const ChannelAdminLogEventActionChangeBackgroundEmojiTypeID = 0x445fc434 + +// construct implements constructor of ChannelAdminLogEventActionClass. +func (c ChannelAdminLogEventActionChangeBackgroundEmoji) construct() ChannelAdminLogEventActionClass { + return &c +} + +// Ensuring interfaces in compile-time for ChannelAdminLogEventActionChangeBackgroundEmoji. +var ( + _ bin.Encoder = &ChannelAdminLogEventActionChangeBackgroundEmoji{} + _ bin.Decoder = &ChannelAdminLogEventActionChangeBackgroundEmoji{} + _ bin.BareEncoder = &ChannelAdminLogEventActionChangeBackgroundEmoji{} + _ bin.BareDecoder = &ChannelAdminLogEventActionChangeBackgroundEmoji{} + + _ ChannelAdminLogEventActionClass = &ChannelAdminLogEventActionChangeBackgroundEmoji{} +) + +func (c *ChannelAdminLogEventActionChangeBackgroundEmoji) Zero() bool { + if c == nil { + return true + } + if !(c.PrevValue == 0) { + return false + } + if !(c.NewValue == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChannelAdminLogEventActionChangeBackgroundEmoji) String() string { + if c == nil { + return "ChannelAdminLogEventActionChangeBackgroundEmoji(nil)" + } + type Alias ChannelAdminLogEventActionChangeBackgroundEmoji + return fmt.Sprintf("ChannelAdminLogEventActionChangeBackgroundEmoji%+v", Alias(*c)) +} + +// FillFrom fills ChannelAdminLogEventActionChangeBackgroundEmoji from given interface. +func (c *ChannelAdminLogEventActionChangeBackgroundEmoji) FillFrom(from interface { + GetPrevValue() (value int64) + GetNewValue() (value int64) +}) { + c.PrevValue = from.GetPrevValue() + c.NewValue = from.GetNewValue() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelAdminLogEventActionChangeBackgroundEmoji) TypeID() uint32 { + return ChannelAdminLogEventActionChangeBackgroundEmojiTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelAdminLogEventActionChangeBackgroundEmoji) TypeName() string { + return "channelAdminLogEventActionChangeBackgroundEmoji" +} + +// TypeInfo returns info about TL type. +func (c *ChannelAdminLogEventActionChangeBackgroundEmoji) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channelAdminLogEventActionChangeBackgroundEmoji", + ID: ChannelAdminLogEventActionChangeBackgroundEmojiTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "PrevValue", + SchemaName: "prev_value", + }, + { + Name: "NewValue", + SchemaName: "new_value", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *ChannelAdminLogEventActionChangeBackgroundEmoji) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionChangeBackgroundEmoji#445fc434 as nil") + } + b.PutID(ChannelAdminLogEventActionChangeBackgroundEmojiTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChannelAdminLogEventActionChangeBackgroundEmoji) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionChangeBackgroundEmoji#445fc434 as nil") + } + b.PutLong(c.PrevValue) + b.PutLong(c.NewValue) + return nil +} + +// Decode implements bin.Decoder. +func (c *ChannelAdminLogEventActionChangeBackgroundEmoji) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionChangeBackgroundEmoji#445fc434 to nil") + } + if err := b.ConsumeID(ChannelAdminLogEventActionChangeBackgroundEmojiTypeID); err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeBackgroundEmoji#445fc434: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChannelAdminLogEventActionChangeBackgroundEmoji) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionChangeBackgroundEmoji#445fc434 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeBackgroundEmoji#445fc434: field prev_value: %w", err) + } + c.PrevValue = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeBackgroundEmoji#445fc434: field new_value: %w", err) + } + c.NewValue = value + } + return nil +} + +// GetPrevValue returns value of PrevValue field. +func (c *ChannelAdminLogEventActionChangeBackgroundEmoji) GetPrevValue() (value int64) { + if c == nil { + return + } + return c.PrevValue +} + +// GetNewValue returns value of NewValue field. +func (c *ChannelAdminLogEventActionChangeBackgroundEmoji) GetNewValue() (value int64) { + if c == nil { + return + } + return c.NewValue +} + // ChannelAdminLogEventActionClassName is schema name of ChannelAdminLogEventActionClass. const ChannelAdminLogEventActionClassName = "ChannelAdminLogEventAction" @@ -6764,6 +7088,8 @@ const ChannelAdminLogEventActionClassName = "ChannelAdminLogEventAction" // case *tg.ChannelAdminLogEventActionDeleteTopic: // channelAdminLogEventActionDeleteTopic#ae168909 // case *tg.ChannelAdminLogEventActionPinTopic: // channelAdminLogEventActionPinTopic#5d8d353b // case *tg.ChannelAdminLogEventActionToggleAntiSpam: // channelAdminLogEventActionToggleAntiSpam#64f36dfc +// case *tg.ChannelAdminLogEventActionChangeColor: // channelAdminLogEventActionChangeColor#3c2b247b +// case *tg.ChannelAdminLogEventActionChangeBackgroundEmoji: // channelAdminLogEventActionChangeBackgroundEmoji#445fc434 // default: panic(v) // } type ChannelAdminLogEventActionClass interface { @@ -7093,6 +7419,20 @@ func DecodeChannelAdminLogEventAction(buf *bin.Buffer) (ChannelAdminLogEventActi return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", err) } return &v, nil + case ChannelAdminLogEventActionChangeColorTypeID: + // Decoding channelAdminLogEventActionChangeColor#3c2b247b. + v := ChannelAdminLogEventActionChangeColor{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", err) + } + return &v, nil + case ChannelAdminLogEventActionChangeBackgroundEmojiTypeID: + // Decoding channelAdminLogEventActionChangeBackgroundEmoji#445fc434. + v := ChannelAdminLogEventActionChangeBackgroundEmoji{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_channel_admin_log_event_action_slices_gen.go b/tg/tl_channel_admin_log_event_action_slices_gen.go index 7e2fee5fbb..1d8cffa7cc 100644 --- a/tg/tl_channel_admin_log_event_action_slices_gen.go +++ b/tg/tl_channel_admin_log_event_action_slices_gen.go @@ -649,6 +649,32 @@ func (s ChannelAdminLogEventActionClassArray) AsChannelAdminLogEventActionToggle return to } +// AsChannelAdminLogEventActionChangeColor returns copy with only ChannelAdminLogEventActionChangeColor constructors. +func (s ChannelAdminLogEventActionClassArray) AsChannelAdminLogEventActionChangeColor() (to ChannelAdminLogEventActionChangeColorArray) { + for _, elem := range s { + value, ok := elem.(*ChannelAdminLogEventActionChangeColor) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsChannelAdminLogEventActionChangeBackgroundEmoji returns copy with only ChannelAdminLogEventActionChangeBackgroundEmoji constructors. +func (s ChannelAdminLogEventActionClassArray) AsChannelAdminLogEventActionChangeBackgroundEmoji() (to ChannelAdminLogEventActionChangeBackgroundEmojiArray) { + for _, elem := range s { + value, ok := elem.(*ChannelAdminLogEventActionChangeBackgroundEmoji) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // ChannelAdminLogEventActionChangeTitleArray is adapter for slice of ChannelAdminLogEventActionChangeTitle. type ChannelAdminLogEventActionChangeTitleArray []ChannelAdminLogEventActionChangeTitle @@ -4010,3 +4036,167 @@ func (s *ChannelAdminLogEventActionToggleAntiSpamArray) Pop() (v ChannelAdminLog return v, true } + +// ChannelAdminLogEventActionChangeColorArray is adapter for slice of ChannelAdminLogEventActionChangeColor. +type ChannelAdminLogEventActionChangeColorArray []ChannelAdminLogEventActionChangeColor + +// Sort sorts slice of ChannelAdminLogEventActionChangeColor. +func (s ChannelAdminLogEventActionChangeColorArray) Sort(less func(a, b ChannelAdminLogEventActionChangeColor) bool) ChannelAdminLogEventActionChangeColorArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ChannelAdminLogEventActionChangeColor. +func (s ChannelAdminLogEventActionChangeColorArray) SortStable(less func(a, b ChannelAdminLogEventActionChangeColor) bool) ChannelAdminLogEventActionChangeColorArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ChannelAdminLogEventActionChangeColor. +func (s ChannelAdminLogEventActionChangeColorArray) Retain(keep func(x ChannelAdminLogEventActionChangeColor) bool) ChannelAdminLogEventActionChangeColorArray { + 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 ChannelAdminLogEventActionChangeColorArray) First() (v ChannelAdminLogEventActionChangeColor, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ChannelAdminLogEventActionChangeColorArray) Last() (v ChannelAdminLogEventActionChangeColor, 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 *ChannelAdminLogEventActionChangeColorArray) PopFirst() (v ChannelAdminLogEventActionChangeColor, 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 ChannelAdminLogEventActionChangeColor + 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 *ChannelAdminLogEventActionChangeColorArray) Pop() (v ChannelAdminLogEventActionChangeColor, 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 +} + +// ChannelAdminLogEventActionChangeBackgroundEmojiArray is adapter for slice of ChannelAdminLogEventActionChangeBackgroundEmoji. +type ChannelAdminLogEventActionChangeBackgroundEmojiArray []ChannelAdminLogEventActionChangeBackgroundEmoji + +// Sort sorts slice of ChannelAdminLogEventActionChangeBackgroundEmoji. +func (s ChannelAdminLogEventActionChangeBackgroundEmojiArray) Sort(less func(a, b ChannelAdminLogEventActionChangeBackgroundEmoji) bool) ChannelAdminLogEventActionChangeBackgroundEmojiArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ChannelAdminLogEventActionChangeBackgroundEmoji. +func (s ChannelAdminLogEventActionChangeBackgroundEmojiArray) SortStable(less func(a, b ChannelAdminLogEventActionChangeBackgroundEmoji) bool) ChannelAdminLogEventActionChangeBackgroundEmojiArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ChannelAdminLogEventActionChangeBackgroundEmoji. +func (s ChannelAdminLogEventActionChangeBackgroundEmojiArray) Retain(keep func(x ChannelAdminLogEventActionChangeBackgroundEmoji) bool) ChannelAdminLogEventActionChangeBackgroundEmojiArray { + 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 ChannelAdminLogEventActionChangeBackgroundEmojiArray) First() (v ChannelAdminLogEventActionChangeBackgroundEmoji, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ChannelAdminLogEventActionChangeBackgroundEmojiArray) Last() (v ChannelAdminLogEventActionChangeBackgroundEmoji, 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 *ChannelAdminLogEventActionChangeBackgroundEmojiArray) PopFirst() (v ChannelAdminLogEventActionChangeBackgroundEmoji, 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 ChannelAdminLogEventActionChangeBackgroundEmoji + 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 *ChannelAdminLogEventActionChangeBackgroundEmojiArray) Pop() (v ChannelAdminLogEventActionChangeBackgroundEmoji, 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_channels_update_color_gen.go b/tg/tl_channels_update_color_gen.go new file mode 100644 index 0000000000..21e1c67071 --- /dev/null +++ b/tg/tl_channels_update_color_gen.go @@ -0,0 +1,276 @@ +// 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{} +) + +// ChannelsUpdateColorRequest represents TL type `channels.updateColor#621a201f`. +// +// See https://core.telegram.org/method/channels.updateColor for reference. +type ChannelsUpdateColorRequest struct { + // Flags field of ChannelsUpdateColorRequest. + Flags bin.Fields + // Channel field of ChannelsUpdateColorRequest. + Channel InputChannelClass + // Color field of ChannelsUpdateColorRequest. + Color int + // BackgroundEmojiID field of ChannelsUpdateColorRequest. + // + // Use SetBackgroundEmojiID and GetBackgroundEmojiID helpers. + BackgroundEmojiID int64 +} + +// ChannelsUpdateColorRequestTypeID is TL type id of ChannelsUpdateColorRequest. +const ChannelsUpdateColorRequestTypeID = 0x621a201f + +// Ensuring interfaces in compile-time for ChannelsUpdateColorRequest. +var ( + _ bin.Encoder = &ChannelsUpdateColorRequest{} + _ bin.Decoder = &ChannelsUpdateColorRequest{} + _ bin.BareEncoder = &ChannelsUpdateColorRequest{} + _ bin.BareDecoder = &ChannelsUpdateColorRequest{} +) + +func (u *ChannelsUpdateColorRequest) Zero() bool { + if u == nil { + return true + } + if !(u.Flags.Zero()) { + return false + } + if !(u.Channel == nil) { + return false + } + if !(u.Color == 0) { + return false + } + if !(u.BackgroundEmojiID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *ChannelsUpdateColorRequest) String() string { + if u == nil { + return "ChannelsUpdateColorRequest(nil)" + } + type Alias ChannelsUpdateColorRequest + return fmt.Sprintf("ChannelsUpdateColorRequest%+v", Alias(*u)) +} + +// FillFrom fills ChannelsUpdateColorRequest from given interface. +func (u *ChannelsUpdateColorRequest) FillFrom(from interface { + GetChannel() (value InputChannelClass) + GetColor() (value int) + GetBackgroundEmojiID() (value int64, ok bool) +}) { + u.Channel = from.GetChannel() + u.Color = from.GetColor() + if val, ok := from.GetBackgroundEmojiID(); ok { + u.BackgroundEmojiID = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelsUpdateColorRequest) TypeID() uint32 { + return ChannelsUpdateColorRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelsUpdateColorRequest) TypeName() string { + return "channels.updateColor" +} + +// TypeInfo returns info about TL type. +func (u *ChannelsUpdateColorRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channels.updateColor", + ID: ChannelsUpdateColorRequestTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Channel", + SchemaName: "channel", + }, + { + Name: "Color", + SchemaName: "color", + }, + { + Name: "BackgroundEmojiID", + SchemaName: "background_emoji_id", + Null: !u.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (u *ChannelsUpdateColorRequest) SetFlags() { + if !(u.BackgroundEmojiID == 0) { + u.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (u *ChannelsUpdateColorRequest) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode channels.updateColor#621a201f as nil") + } + b.PutID(ChannelsUpdateColorRequestTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *ChannelsUpdateColorRequest) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode channels.updateColor#621a201f as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.updateColor#621a201f: field flags: %w", err) + } + if u.Channel == nil { + return fmt.Errorf("unable to encode channels.updateColor#621a201f: field channel is nil") + } + if err := u.Channel.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.updateColor#621a201f: field channel: %w", err) + } + b.PutInt(u.Color) + if u.Flags.Has(0) { + b.PutLong(u.BackgroundEmojiID) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *ChannelsUpdateColorRequest) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode channels.updateColor#621a201f to nil") + } + if err := b.ConsumeID(ChannelsUpdateColorRequestTypeID); err != nil { + return fmt.Errorf("unable to decode channels.updateColor#621a201f: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *ChannelsUpdateColorRequest) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode channels.updateColor#621a201f to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode channels.updateColor#621a201f: field flags: %w", err) + } + } + { + value, err := DecodeInputChannel(b) + if err != nil { + return fmt.Errorf("unable to decode channels.updateColor#621a201f: field channel: %w", err) + } + u.Channel = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channels.updateColor#621a201f: field color: %w", err) + } + u.Color = value + } + if u.Flags.Has(0) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode channels.updateColor#621a201f: field background_emoji_id: %w", err) + } + u.BackgroundEmojiID = value + } + return nil +} + +// GetChannel returns value of Channel field. +func (u *ChannelsUpdateColorRequest) GetChannel() (value InputChannelClass) { + if u == nil { + return + } + return u.Channel +} + +// GetColor returns value of Color field. +func (u *ChannelsUpdateColorRequest) GetColor() (value int) { + if u == nil { + return + } + return u.Color +} + +// SetBackgroundEmojiID sets value of BackgroundEmojiID conditional field. +func (u *ChannelsUpdateColorRequest) SetBackgroundEmojiID(value int64) { + u.Flags.Set(0) + u.BackgroundEmojiID = value +} + +// GetBackgroundEmojiID returns value of BackgroundEmojiID conditional field and +// boolean which is true if field was set. +func (u *ChannelsUpdateColorRequest) GetBackgroundEmojiID() (value int64, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.BackgroundEmojiID, true +} + +// GetChannelAsNotEmpty returns mapped value of Channel field. +func (u *ChannelsUpdateColorRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) { + return u.Channel.AsNotEmpty() +} + +// ChannelsUpdateColor invokes method channels.updateColor#621a201f returning error if any. +// +// See https://core.telegram.org/method/channels.updateColor for reference. +func (c *Client) ChannelsUpdateColor(ctx context.Context, request *ChannelsUpdateColorRequest) (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_stories_boosts_status_slices_gen.go b/tg/tl_channels_update_color_slices_gen.go similarity index 100% rename from tg/tl_stories_boosts_status_slices_gen.go rename to tg/tl_channels_update_color_slices_gen.go diff --git a/tg/tl_chat_gen.go b/tg/tl_chat_gen.go index 01ec344d64..e79c74a8d8 100644 --- a/tg/tl_chat_gen.go +++ b/tg/tl_chat_gen.go @@ -999,7 +999,7 @@ func (c *ChatForbidden) GetTitle() (value string) { return c.Title } -// Channel represents TL type `channel#94f592db`. +// Channel represents TL type `channel#1981ea7e`. // Channel/supergroup info // // See https://core.telegram.org/constructor/channel for reference. @@ -1141,10 +1141,18 @@ type Channel struct { // // Use SetStoriesMaxID and GetStoriesMaxID helpers. StoriesMaxID int + // Color field of Channel. + // + // Use SetColor and GetColor helpers. + Color int + // BackgroundEmojiID field of Channel. + // + // Use SetBackgroundEmojiID and GetBackgroundEmojiID helpers. + BackgroundEmojiID int64 } // ChannelTypeID is TL type id of Channel. -const ChannelTypeID = 0x94f592db +const ChannelTypeID = 0x1981ea7e // construct implements constructor of ChatClass. func (c Channel) construct() ChatClass { return &c } @@ -1277,6 +1285,12 @@ func (c *Channel) Zero() bool { if !(c.StoriesMaxID == 0) { return false } + if !(c.Color == 0) { + return false + } + if !(c.BackgroundEmojiID == 0) { + return false + } return true } @@ -1328,6 +1342,8 @@ func (c *Channel) FillFrom(from interface { GetParticipantsCount() (value int, ok bool) GetUsernames() (value []Username, ok bool) GetStoriesMaxID() (value int, ok bool) + GetColor() (value int, ok bool) + GetBackgroundEmojiID() (value int64, ok bool) }) { c.Creator = from.GetCreator() c.Left = from.GetLeft() @@ -1392,6 +1408,14 @@ func (c *Channel) FillFrom(from interface { c.StoriesMaxID = val } + if val, ok := from.GetColor(); ok { + c.Color = val + } + + if val, ok := from.GetBackgroundEmojiID(); ok { + c.BackgroundEmojiID = val + } + } // TypeID returns type id in TL schema. @@ -1593,6 +1617,16 @@ func (c *Channel) TypeInfo() tdp.Type { SchemaName: "stories_max_id", Null: !c.Flags2.Has(4), }, + { + Name: "Color", + SchemaName: "color", + Null: !c.Flags2.Has(6), + }, + { + Name: "BackgroundEmojiID", + SchemaName: "background_emoji_id", + Null: !c.Flags2.Has(5), + }, } return typ } @@ -1695,12 +1729,18 @@ func (c *Channel) SetFlags() { if !(c.StoriesMaxID == 0) { c.Flags2.Set(4) } + if !(c.Color == 0) { + c.Flags2.Set(6) + } + if !(c.BackgroundEmojiID == 0) { + c.Flags2.Set(5) + } } // Encode implements bin.Encoder. func (c *Channel) Encode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channel#94f592db as nil") + return fmt.Errorf("can't encode channel#1981ea7e as nil") } b.PutID(ChannelTypeID) return c.EncodeBare(b) @@ -1709,14 +1749,14 @@ func (c *Channel) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (c *Channel) EncodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channel#94f592db as nil") + return fmt.Errorf("can't encode channel#1981ea7e as nil") } c.SetFlags() if err := c.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#94f592db: field flags: %w", err) + return fmt.Errorf("unable to encode channel#1981ea7e: field flags: %w", err) } if err := c.Flags2.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#94f592db: field flags2: %w", err) + return fmt.Errorf("unable to encode channel#1981ea7e: field flags2: %w", err) } b.PutLong(c.ID) if c.Flags.Has(13) { @@ -1727,33 +1767,33 @@ func (c *Channel) EncodeBare(b *bin.Buffer) error { b.PutString(c.Username) } if c.Photo == nil { - return fmt.Errorf("unable to encode channel#94f592db: field photo is nil") + return fmt.Errorf("unable to encode channel#1981ea7e: field photo is nil") } if err := c.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#94f592db: field photo: %w", err) + return fmt.Errorf("unable to encode channel#1981ea7e: field photo: %w", err) } b.PutInt(c.Date) if c.Flags.Has(9) { b.PutVectorHeader(len(c.RestrictionReason)) for idx, v := range c.RestrictionReason { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#94f592db: field restriction_reason element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode channel#1981ea7e: field restriction_reason element with index %d: %w", idx, err) } } } if c.Flags.Has(14) { if err := c.AdminRights.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#94f592db: field admin_rights: %w", err) + return fmt.Errorf("unable to encode channel#1981ea7e: field admin_rights: %w", err) } } if c.Flags.Has(15) { if err := c.BannedRights.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#94f592db: field banned_rights: %w", err) + return fmt.Errorf("unable to encode channel#1981ea7e: field banned_rights: %w", err) } } if c.Flags.Has(18) { if err := c.DefaultBannedRights.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#94f592db: field default_banned_rights: %w", err) + return fmt.Errorf("unable to encode channel#1981ea7e: field default_banned_rights: %w", err) } } if c.Flags.Has(17) { @@ -1763,23 +1803,29 @@ func (c *Channel) EncodeBare(b *bin.Buffer) error { b.PutVectorHeader(len(c.Usernames)) for idx, v := range c.Usernames { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#94f592db: field usernames element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode channel#1981ea7e: field usernames element with index %d: %w", idx, err) } } } if c.Flags2.Has(4) { b.PutInt(c.StoriesMaxID) } + if c.Flags2.Has(6) { + b.PutInt(c.Color) + } + if c.Flags2.Has(5) { + b.PutLong(c.BackgroundEmojiID) + } return nil } // Decode implements bin.Decoder. func (c *Channel) Decode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channel#94f592db to nil") + return fmt.Errorf("can't decode channel#1981ea7e to nil") } if err := b.ConsumeID(ChannelTypeID); err != nil { - return fmt.Errorf("unable to decode channel#94f592db: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: %w", err) } return c.DecodeBare(b) } @@ -1787,11 +1833,11 @@ func (c *Channel) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (c *Channel) DecodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channel#94f592db to nil") + return fmt.Errorf("can't decode channel#1981ea7e to nil") } { if err := c.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field flags: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field flags: %w", err) } } c.Creator = c.Flags.Has(0) @@ -1816,7 +1862,7 @@ func (c *Channel) DecodeBare(b *bin.Buffer) error { c.Forum = c.Flags.Has(30) { if err := c.Flags2.Decode(b); err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field flags2: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field flags2: %w", err) } } c.StoriesHidden = c.Flags2.Has(1) @@ -1825,49 +1871,49 @@ func (c *Channel) DecodeBare(b *bin.Buffer) error { { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field id: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field id: %w", err) } c.ID = value } if c.Flags.Has(13) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field access_hash: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field access_hash: %w", err) } c.AccessHash = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field title: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field title: %w", err) } c.Title = value } if c.Flags.Has(6) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field username: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field username: %w", err) } c.Username = value } { value, err := DecodeChatPhoto(b) if err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field photo: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field photo: %w", err) } c.Photo = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field date: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field date: %w", err) } c.Date = value } if c.Flags.Has(9) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field restriction_reason: %w", err) } if headerLen > 0 { @@ -1876,37 +1922,37 @@ func (c *Channel) 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 channel#94f592db: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field restriction_reason: %w", err) } c.RestrictionReason = append(c.RestrictionReason, value) } } if c.Flags.Has(14) { if err := c.AdminRights.Decode(b); err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field admin_rights: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field admin_rights: %w", err) } } if c.Flags.Has(15) { if err := c.BannedRights.Decode(b); err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field banned_rights: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field banned_rights: %w", err) } } if c.Flags.Has(18) { if err := c.DefaultBannedRights.Decode(b); err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field default_banned_rights: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field default_banned_rights: %w", err) } } if c.Flags.Has(17) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field participants_count: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field participants_count: %w", err) } c.ParticipantsCount = value } if c.Flags2.Has(0) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field usernames: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field usernames: %w", err) } if headerLen > 0 { @@ -1915,7 +1961,7 @@ func (c *Channel) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value Username if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field usernames: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field usernames: %w", err) } c.Usernames = append(c.Usernames, value) } @@ -1923,10 +1969,24 @@ func (c *Channel) DecodeBare(b *bin.Buffer) error { if c.Flags2.Has(4) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channel#94f592db: field stories_max_id: %w", err) + return fmt.Errorf("unable to decode channel#1981ea7e: field stories_max_id: %w", err) } c.StoriesMaxID = value } + if c.Flags2.Has(6) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channel#1981ea7e: field color: %w", err) + } + c.Color = value + } + if c.Flags2.Has(5) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode channel#1981ea7e: field background_emoji_id: %w", err) + } + c.BackgroundEmojiID = value + } return nil } @@ -2561,6 +2621,42 @@ func (c *Channel) GetStoriesMaxID() (value int, ok bool) { return c.StoriesMaxID, true } +// SetColor sets value of Color conditional field. +func (c *Channel) SetColor(value int) { + c.Flags2.Set(6) + c.Color = value +} + +// GetColor returns value of Color conditional field and +// boolean which is true if field was set. +func (c *Channel) GetColor() (value int, ok bool) { + if c == nil { + return + } + if !c.Flags2.Has(6) { + return value, false + } + return c.Color, true +} + +// SetBackgroundEmojiID sets value of BackgroundEmojiID conditional field. +func (c *Channel) SetBackgroundEmojiID(value int64) { + c.Flags2.Set(5) + c.BackgroundEmojiID = value +} + +// GetBackgroundEmojiID returns value of BackgroundEmojiID conditional field and +// boolean which is true if field was set. +func (c *Channel) GetBackgroundEmojiID() (value int64, ok bool) { + if c == nil { + return + } + if !c.Flags2.Has(5) { + return value, false + } + return c.BackgroundEmojiID, true +} + // ChannelForbidden represents TL type `channelForbidden#17d493d5`. // Indicates a channel/supergroup we can't access because we were banned, or for some // other reason. @@ -2907,7 +3003,7 @@ const ChatClassName = "Chat" // case *tg.ChatEmpty: // chatEmpty#29562865 // case *tg.Chat: // chat#41cbf256 // case *tg.ChatForbidden: // chatForbidden#6592a1a7 -// case *tg.Channel: // channel#94f592db +// case *tg.Channel: // channel#1981ea7e // case *tg.ChannelForbidden: // channelForbidden#17d493d5 // default: panic(v) // } @@ -3200,7 +3296,7 @@ func DecodeChat(buf *bin.Buffer) (ChatClass, error) { } return &v, nil case ChannelTypeID: - // Decoding channel#94f592db. + // Decoding channel#1981ea7e. v := Channel{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ChatClass: %w", err) diff --git a/tg/tl_chat_invite_gen.go b/tg/tl_chat_invite_gen.go index 4409ad3394..a7ea1c2054 100644 --- a/tg/tl_chat_invite_gen.go +++ b/tg/tl_chat_invite_gen.go @@ -171,7 +171,7 @@ func (c *ChatInviteAlready) GetChat() (value ChatClass) { return c.Chat } -// ChatInvite represents TL type `chatInvite#300c44c1`. +// ChatInvite represents TL type `chatInvite#cde0ec40`. // Chat invite info // // See https://core.telegram.org/constructor/chatInvite for reference. @@ -227,10 +227,12 @@ type ChatInvite struct { // // Use SetParticipants and GetParticipants helpers. Participants []UserClass + // Color field of ChatInvite. + Color int } // ChatInviteTypeID is TL type id of ChatInvite. -const ChatInviteTypeID = 0x300c44c1 +const ChatInviteTypeID = 0xcde0ec40 // construct implements constructor of ChatInviteClass. func (c ChatInvite) construct() ChatInviteClass { return &c } @@ -291,6 +293,9 @@ func (c *ChatInvite) Zero() bool { if !(c.Participants == nil) { return false } + if !(c.Color == 0) { + return false + } return true } @@ -319,6 +324,7 @@ func (c *ChatInvite) FillFrom(from interface { GetPhoto() (value PhotoClass) GetParticipantsCount() (value int) GetParticipants() (value []UserClass, ok bool) + GetColor() (value int) }) { c.Channel = from.GetChannel() c.Broadcast = from.GetBroadcast() @@ -339,6 +345,7 @@ func (c *ChatInvite) FillFrom(from interface { c.Participants = val } + c.Color = from.GetColor() } // TypeID returns type id in TL schema. @@ -426,6 +433,10 @@ func (c *ChatInvite) TypeInfo() tdp.Type { SchemaName: "participants", Null: !c.Flags.Has(4), }, + { + Name: "Color", + SchemaName: "color", + }, } return typ } @@ -467,7 +478,7 @@ func (c *ChatInvite) SetFlags() { // Encode implements bin.Encoder. func (c *ChatInvite) Encode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode chatInvite#300c44c1 as nil") + return fmt.Errorf("can't encode chatInvite#cde0ec40 as nil") } b.PutID(ChatInviteTypeID) return c.EncodeBare(b) @@ -476,44 +487,45 @@ func (c *ChatInvite) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (c *ChatInvite) EncodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode chatInvite#300c44c1 as nil") + return fmt.Errorf("can't encode chatInvite#cde0ec40 as nil") } c.SetFlags() if err := c.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatInvite#300c44c1: field flags: %w", err) + return fmt.Errorf("unable to encode chatInvite#cde0ec40: field flags: %w", err) } b.PutString(c.Title) if c.Flags.Has(5) { b.PutString(c.About) } if c.Photo == nil { - return fmt.Errorf("unable to encode chatInvite#300c44c1: field photo is nil") + return fmt.Errorf("unable to encode chatInvite#cde0ec40: field photo is nil") } if err := c.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatInvite#300c44c1: field photo: %w", err) + return fmt.Errorf("unable to encode chatInvite#cde0ec40: field photo: %w", err) } b.PutInt(c.ParticipantsCount) if c.Flags.Has(4) { b.PutVectorHeader(len(c.Participants)) for idx, v := range c.Participants { if v == nil { - return fmt.Errorf("unable to encode chatInvite#300c44c1: field participants element with index %d is nil", idx) + return fmt.Errorf("unable to encode chatInvite#cde0ec40: field participants element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatInvite#300c44c1: field participants element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode chatInvite#cde0ec40: field participants element with index %d: %w", idx, err) } } } + b.PutInt(c.Color) return nil } // Decode implements bin.Decoder. func (c *ChatInvite) Decode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode chatInvite#300c44c1 to nil") + return fmt.Errorf("can't decode chatInvite#cde0ec40 to nil") } if err := b.ConsumeID(ChatInviteTypeID); err != nil { - return fmt.Errorf("unable to decode chatInvite#300c44c1: %w", err) + return fmt.Errorf("unable to decode chatInvite#cde0ec40: %w", err) } return c.DecodeBare(b) } @@ -521,11 +533,11 @@ func (c *ChatInvite) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (c *ChatInvite) DecodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode chatInvite#300c44c1 to nil") + return fmt.Errorf("can't decode chatInvite#cde0ec40 to nil") } { if err := c.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode chatInvite#300c44c1: field flags: %w", err) + return fmt.Errorf("unable to decode chatInvite#cde0ec40: field flags: %w", err) } } c.Channel = c.Flags.Has(0) @@ -539,35 +551,35 @@ func (c *ChatInvite) DecodeBare(b *bin.Buffer) error { { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode chatInvite#300c44c1: field title: %w", err) + return fmt.Errorf("unable to decode chatInvite#cde0ec40: field title: %w", err) } c.Title = value } if c.Flags.Has(5) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode chatInvite#300c44c1: field about: %w", err) + return fmt.Errorf("unable to decode chatInvite#cde0ec40: field about: %w", err) } c.About = value } { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode chatInvite#300c44c1: field photo: %w", err) + return fmt.Errorf("unable to decode chatInvite#cde0ec40: field photo: %w", err) } c.Photo = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode chatInvite#300c44c1: field participants_count: %w", err) + return fmt.Errorf("unable to decode chatInvite#cde0ec40: field participants_count: %w", err) } c.ParticipantsCount = value } if c.Flags.Has(4) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode chatInvite#300c44c1: field participants: %w", err) + return fmt.Errorf("unable to decode chatInvite#cde0ec40: field participants: %w", err) } if headerLen > 0 { @@ -576,11 +588,18 @@ func (c *ChatInvite) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeUser(b) if err != nil { - return fmt.Errorf("unable to decode chatInvite#300c44c1: field participants: %w", err) + return fmt.Errorf("unable to decode chatInvite#cde0ec40: field participants: %w", err) } c.Participants = append(c.Participants, value) } } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode chatInvite#cde0ec40: field color: %w", err) + } + c.Color = value + } return nil } @@ -796,6 +815,14 @@ func (c *ChatInvite) GetParticipants() (value []UserClass, ok bool) { return c.Participants, true } +// GetColor returns value of Color field. +func (c *ChatInvite) GetColor() (value int) { + if c == nil { + return + } + return c.Color +} + // MapParticipants returns field Participants wrapped in UserClassArray helper. func (c *ChatInvite) MapParticipants() (value UserClassArray, ok bool) { if !c.Flags.Has(4) { @@ -987,7 +1014,7 @@ const ChatInviteClassName = "ChatInvite" // } // switch v := g.(type) { // case *tg.ChatInviteAlready: // chatInviteAlready#5a686d7c -// case *tg.ChatInvite: // chatInvite#300c44c1 +// case *tg.ChatInvite: // chatInvite#cde0ec40 // case *tg.ChatInvitePeek: // chatInvitePeek#61695cb0 // default: panic(v) // } @@ -1025,7 +1052,7 @@ func DecodeChatInvite(buf *bin.Buffer) (ChatInviteClass, error) { } return &v, nil case ChatInviteTypeID: - // Decoding chatInvite#300c44c1. + // Decoding chatInvite#cde0ec40. v := ChatInvite{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ChatInviteClass: %w", err) diff --git a/tg/tl_draft_message_gen.go b/tg/tl_draft_message_gen.go index 60ca2cdb06..6cedd85ea0 100644 --- a/tg/tl_draft_message_gen.go +++ b/tg/tl_draft_message_gen.go @@ -208,7 +208,7 @@ func (d *DraftMessageEmpty) GetDate() (value int, ok bool) { return d.Date, true } -// DraftMessage represents TL type `draftMessage#fd8e711f`. +// DraftMessage represents TL type `draftMessage#3fccf7ef`. // Represents a message draft¹. // // Links: @@ -223,10 +223,12 @@ type DraftMessage struct { Flags bin.Fields // Whether no webpage preview will be generated NoWebpage bool - // The message this message will reply to + // InvertMedia field of DraftMessage. + InvertMedia bool + // ReplyTo field of DraftMessage. // - // Use SetReplyToMsgID and GetReplyToMsgID helpers. - ReplyToMsgID int + // Use SetReplyTo and GetReplyTo helpers. + ReplyTo InputReplyToClass // The draft Message string // Message entities¹ for styled text. @@ -236,12 +238,16 @@ type DraftMessage struct { // // Use SetEntities and GetEntities helpers. Entities []MessageEntityClass + // Media field of DraftMessage. + // + // Use SetMedia and GetMedia helpers. + Media InputMediaClass // Date of last update of the draft. Date int } // DraftMessageTypeID is TL type id of DraftMessage. -const DraftMessageTypeID = 0xfd8e711f +const DraftMessageTypeID = 0x3fccf7ef // construct implements constructor of DraftMessageClass. func (d DraftMessage) construct() DraftMessageClass { return &d } @@ -266,7 +272,10 @@ func (d *DraftMessage) Zero() bool { if !(d.NoWebpage == false) { return false } - if !(d.ReplyToMsgID == 0) { + if !(d.InvertMedia == false) { + return false + } + if !(d.ReplyTo == nil) { return false } if !(d.Message == "") { @@ -275,6 +284,9 @@ func (d *DraftMessage) Zero() bool { if !(d.Entities == nil) { return false } + if !(d.Media == nil) { + return false + } if !(d.Date == 0) { return false } @@ -294,14 +306,17 @@ func (d *DraftMessage) String() string { // FillFrom fills DraftMessage from given interface. func (d *DraftMessage) FillFrom(from interface { GetNoWebpage() (value bool) - GetReplyToMsgID() (value int, ok bool) + GetInvertMedia() (value bool) + GetReplyTo() (value InputReplyToClass, ok bool) GetMessage() (value string) GetEntities() (value []MessageEntityClass, ok bool) + GetMedia() (value InputMediaClass, ok bool) GetDate() (value int) }) { d.NoWebpage = from.GetNoWebpage() - if val, ok := from.GetReplyToMsgID(); ok { - d.ReplyToMsgID = val + d.InvertMedia = from.GetInvertMedia() + if val, ok := from.GetReplyTo(); ok { + d.ReplyTo = val } d.Message = from.GetMessage() @@ -309,6 +324,10 @@ func (d *DraftMessage) FillFrom(from interface { d.Entities = val } + if val, ok := from.GetMedia(); ok { + d.Media = val + } + d.Date = from.GetDate() } @@ -341,9 +360,14 @@ func (d *DraftMessage) TypeInfo() tdp.Type { Null: !d.Flags.Has(1), }, { - Name: "ReplyToMsgID", - SchemaName: "reply_to_msg_id", - Null: !d.Flags.Has(0), + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !d.Flags.Has(6), + }, + { + Name: "ReplyTo", + SchemaName: "reply_to", + Null: !d.Flags.Has(4), }, { Name: "Message", @@ -354,6 +378,11 @@ func (d *DraftMessage) TypeInfo() tdp.Type { SchemaName: "entities", Null: !d.Flags.Has(3), }, + { + Name: "Media", + SchemaName: "media", + Null: !d.Flags.Has(5), + }, { Name: "Date", SchemaName: "date", @@ -367,18 +396,24 @@ func (d *DraftMessage) SetFlags() { if !(d.NoWebpage == false) { d.Flags.Set(1) } - if !(d.ReplyToMsgID == 0) { - d.Flags.Set(0) + if !(d.InvertMedia == false) { + d.Flags.Set(6) + } + if !(d.ReplyTo == nil) { + d.Flags.Set(4) } if !(d.Entities == nil) { d.Flags.Set(3) } + if !(d.Media == nil) { + d.Flags.Set(5) + } } // Encode implements bin.Encoder. func (d *DraftMessage) Encode(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't encode draftMessage#fd8e711f as nil") + return fmt.Errorf("can't encode draftMessage#3fccf7ef as nil") } b.PutID(DraftMessageTypeID) return d.EncodeBare(b) @@ -387,27 +422,40 @@ func (d *DraftMessage) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (d *DraftMessage) EncodeBare(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't encode draftMessage#fd8e711f as nil") + return fmt.Errorf("can't encode draftMessage#3fccf7ef as nil") } d.SetFlags() if err := d.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode draftMessage#fd8e711f: field flags: %w", err) + return fmt.Errorf("unable to encode draftMessage#3fccf7ef: field flags: %w", err) } - if d.Flags.Has(0) { - b.PutInt(d.ReplyToMsgID) + if d.Flags.Has(4) { + if d.ReplyTo == nil { + return fmt.Errorf("unable to encode draftMessage#3fccf7ef: field reply_to is nil") + } + if err := d.ReplyTo.Encode(b); err != nil { + return fmt.Errorf("unable to encode draftMessage#3fccf7ef: field reply_to: %w", err) + } } b.PutString(d.Message) if d.Flags.Has(3) { b.PutVectorHeader(len(d.Entities)) for idx, v := range d.Entities { if v == nil { - return fmt.Errorf("unable to encode draftMessage#fd8e711f: field entities element with index %d is nil", idx) + return fmt.Errorf("unable to encode draftMessage#3fccf7ef: field entities element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode draftMessage#fd8e711f: field entities element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode draftMessage#3fccf7ef: field entities element with index %d: %w", idx, err) } } } + if d.Flags.Has(5) { + if d.Media == nil { + return fmt.Errorf("unable to encode draftMessage#3fccf7ef: field media is nil") + } + if err := d.Media.Encode(b); err != nil { + return fmt.Errorf("unable to encode draftMessage#3fccf7ef: field media: %w", err) + } + } b.PutInt(d.Date) return nil } @@ -415,10 +463,10 @@ func (d *DraftMessage) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (d *DraftMessage) Decode(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't decode draftMessage#fd8e711f to nil") + return fmt.Errorf("can't decode draftMessage#3fccf7ef to nil") } if err := b.ConsumeID(DraftMessageTypeID); err != nil { - return fmt.Errorf("unable to decode draftMessage#fd8e711f: %w", err) + return fmt.Errorf("unable to decode draftMessage#3fccf7ef: %w", err) } return d.DecodeBare(b) } @@ -426,32 +474,33 @@ func (d *DraftMessage) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (d *DraftMessage) DecodeBare(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't decode draftMessage#fd8e711f to nil") + return fmt.Errorf("can't decode draftMessage#3fccf7ef to nil") } { if err := d.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode draftMessage#fd8e711f: field flags: %w", err) + return fmt.Errorf("unable to decode draftMessage#3fccf7ef: field flags: %w", err) } } d.NoWebpage = d.Flags.Has(1) - if d.Flags.Has(0) { - value, err := b.Int() + d.InvertMedia = d.Flags.Has(6) + if d.Flags.Has(4) { + value, err := DecodeInputReplyTo(b) if err != nil { - return fmt.Errorf("unable to decode draftMessage#fd8e711f: field reply_to_msg_id: %w", err) + return fmt.Errorf("unable to decode draftMessage#3fccf7ef: field reply_to: %w", err) } - d.ReplyToMsgID = value + d.ReplyTo = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode draftMessage#fd8e711f: field message: %w", err) + return fmt.Errorf("unable to decode draftMessage#3fccf7ef: field message: %w", err) } d.Message = value } if d.Flags.Has(3) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode draftMessage#fd8e711f: field entities: %w", err) + return fmt.Errorf("unable to decode draftMessage#3fccf7ef: field entities: %w", err) } if headerLen > 0 { @@ -460,15 +509,22 @@ func (d *DraftMessage) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageEntity(b) if err != nil { - return fmt.Errorf("unable to decode draftMessage#fd8e711f: field entities: %w", err) + return fmt.Errorf("unable to decode draftMessage#3fccf7ef: field entities: %w", err) } d.Entities = append(d.Entities, value) } } + if d.Flags.Has(5) { + value, err := DecodeInputMedia(b) + if err != nil { + return fmt.Errorf("unable to decode draftMessage#3fccf7ef: field media: %w", err) + } + d.Media = value + } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode draftMessage#fd8e711f: field date: %w", err) + return fmt.Errorf("unable to decode draftMessage#3fccf7ef: field date: %w", err) } d.Date = value } @@ -494,22 +550,41 @@ func (d *DraftMessage) GetNoWebpage() (value bool) { return d.Flags.Has(1) } -// SetReplyToMsgID sets value of ReplyToMsgID conditional field. -func (d *DraftMessage) SetReplyToMsgID(value int) { - d.Flags.Set(0) - d.ReplyToMsgID = value +// SetInvertMedia sets value of InvertMedia conditional field. +func (d *DraftMessage) SetInvertMedia(value bool) { + if value { + d.Flags.Set(6) + d.InvertMedia = true + } else { + d.Flags.Unset(6) + d.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (d *DraftMessage) GetInvertMedia() (value bool) { + if d == nil { + return + } + return d.Flags.Has(6) +} + +// SetReplyTo sets value of ReplyTo conditional field. +func (d *DraftMessage) SetReplyTo(value InputReplyToClass) { + d.Flags.Set(4) + d.ReplyTo = value } -// GetReplyToMsgID returns value of ReplyToMsgID conditional field and +// GetReplyTo returns value of ReplyTo conditional field and // boolean which is true if field was set. -func (d *DraftMessage) GetReplyToMsgID() (value int, ok bool) { +func (d *DraftMessage) GetReplyTo() (value InputReplyToClass, ok bool) { if d == nil { return } - if !d.Flags.Has(0) { + if !d.Flags.Has(4) { return value, false } - return d.ReplyToMsgID, true + return d.ReplyTo, true } // GetMessage returns value of Message field. @@ -538,6 +613,24 @@ func (d *DraftMessage) GetEntities() (value []MessageEntityClass, ok bool) { return d.Entities, true } +// SetMedia sets value of Media conditional field. +func (d *DraftMessage) SetMedia(value InputMediaClass) { + d.Flags.Set(5) + d.Media = value +} + +// GetMedia returns value of Media conditional field and +// boolean which is true if field was set. +func (d *DraftMessage) GetMedia() (value InputMediaClass, ok bool) { + if d == nil { + return + } + if !d.Flags.Has(5) { + return value, false + } + return d.Media, true +} + // GetDate returns value of Date field. func (d *DraftMessage) GetDate() (value int) { if d == nil { @@ -569,7 +662,7 @@ const DraftMessageClassName = "DraftMessage" // } // switch v := g.(type) { // case *tg.DraftMessageEmpty: // draftMessageEmpty#1b0c841a -// case *tg.DraftMessage: // draftMessage#fd8e711f +// case *tg.DraftMessage: // draftMessage#3fccf7ef // default: panic(v) // } type DraftMessageClass interface { @@ -619,7 +712,7 @@ func DecodeDraftMessage(buf *bin.Buffer) (DraftMessageClass, error) { } return &v, nil case DraftMessageTypeID: - // Decoding draftMessage#fd8e711f. + // Decoding draftMessage#3fccf7ef. v := DraftMessage{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode DraftMessageClass: %w", err) diff --git a/tg/tl_input_bot_inline_message_gen.go b/tg/tl_input_bot_inline_message_gen.go index 2571c3d658..06153a61e5 100644 --- a/tg/tl_input_bot_inline_message_gen.go +++ b/tg/tl_input_bot_inline_message_gen.go @@ -41,6 +41,8 @@ type InputBotInlineMessageMediaAuto struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields + // InvertMedia field of InputBotInlineMessageMediaAuto. + InvertMedia bool // Caption Message string // Message entities for styled text¹ @@ -79,6 +81,9 @@ func (i *InputBotInlineMessageMediaAuto) Zero() bool { if !(i.Flags.Zero()) { return false } + if !(i.InvertMedia == false) { + return false + } if !(i.Message == "") { return false } @@ -103,10 +108,12 @@ func (i *InputBotInlineMessageMediaAuto) String() string { // FillFrom fills InputBotInlineMessageMediaAuto from given interface. func (i *InputBotInlineMessageMediaAuto) FillFrom(from interface { + GetInvertMedia() (value bool) GetMessage() (value string) GetEntities() (value []MessageEntityClass, ok bool) GetReplyMarkup() (value ReplyMarkupClass, ok bool) }) { + i.InvertMedia = from.GetInvertMedia() i.Message = from.GetMessage() if val, ok := from.GetEntities(); ok { i.Entities = val @@ -141,6 +148,11 @@ func (i *InputBotInlineMessageMediaAuto) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !i.Flags.Has(3), + }, { Name: "Message", SchemaName: "message", @@ -161,6 +173,9 @@ func (i *InputBotInlineMessageMediaAuto) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (i *InputBotInlineMessageMediaAuto) SetFlags() { + if !(i.InvertMedia == false) { + i.Flags.Set(3) + } if !(i.Entities == nil) { i.Flags.Set(1) } @@ -231,6 +246,7 @@ func (i *InputBotInlineMessageMediaAuto) DecodeBare(b *bin.Buffer) error { return fmt.Errorf("unable to decode inputBotInlineMessageMediaAuto#3380c786: field flags: %w", err) } } + i.InvertMedia = i.Flags.Has(3) { value, err := b.String() if err != nil { @@ -265,6 +281,25 @@ func (i *InputBotInlineMessageMediaAuto) DecodeBare(b *bin.Buffer) error { return nil } +// SetInvertMedia sets value of InvertMedia conditional field. +func (i *InputBotInlineMessageMediaAuto) SetInvertMedia(value bool) { + if value { + i.Flags.Set(3) + i.InvertMedia = true + } else { + i.Flags.Unset(3) + i.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (i *InputBotInlineMessageMediaAuto) GetInvertMedia() (value bool) { + if i == nil { + return + } + return i.Flags.Has(3) +} + // GetMessage returns value of Message field. func (i *InputBotInlineMessageMediaAuto) GetMessage() (value string) { if i == nil { @@ -329,6 +364,8 @@ type InputBotInlineMessageText struct { Flags bin.Fields // Disable webpage preview NoWebpage bool + // InvertMedia field of InputBotInlineMessageText. + InvertMedia bool // Message Message string // Message entities for styled text¹ @@ -370,6 +407,9 @@ func (i *InputBotInlineMessageText) Zero() bool { if !(i.NoWebpage == false) { return false } + if !(i.InvertMedia == false) { + return false + } if !(i.Message == "") { return false } @@ -395,11 +435,13 @@ func (i *InputBotInlineMessageText) String() string { // FillFrom fills InputBotInlineMessageText from given interface. func (i *InputBotInlineMessageText) FillFrom(from interface { GetNoWebpage() (value bool) + GetInvertMedia() (value bool) GetMessage() (value string) GetEntities() (value []MessageEntityClass, ok bool) GetReplyMarkup() (value ReplyMarkupClass, ok bool) }) { i.NoWebpage = from.GetNoWebpage() + i.InvertMedia = from.GetInvertMedia() i.Message = from.GetMessage() if val, ok := from.GetEntities(); ok { i.Entities = val @@ -439,6 +481,11 @@ func (i *InputBotInlineMessageText) TypeInfo() tdp.Type { SchemaName: "no_webpage", Null: !i.Flags.Has(0), }, + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !i.Flags.Has(3), + }, { Name: "Message", SchemaName: "message", @@ -462,6 +509,9 @@ func (i *InputBotInlineMessageText) SetFlags() { if !(i.NoWebpage == false) { i.Flags.Set(0) } + if !(i.InvertMedia == false) { + i.Flags.Set(3) + } if !(i.Entities == nil) { i.Flags.Set(1) } @@ -533,6 +583,7 @@ func (i *InputBotInlineMessageText) DecodeBare(b *bin.Buffer) error { } } i.NoWebpage = i.Flags.Has(0) + i.InvertMedia = i.Flags.Has(3) { value, err := b.String() if err != nil { @@ -586,6 +637,25 @@ func (i *InputBotInlineMessageText) GetNoWebpage() (value bool) { return i.Flags.Has(0) } +// SetInvertMedia sets value of InvertMedia conditional field. +func (i *InputBotInlineMessageText) SetInvertMedia(value bool) { + if value { + i.Flags.Set(3) + i.InvertMedia = true + } else { + i.Flags.Unset(3) + i.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (i *InputBotInlineMessageText) GetInvertMedia() (value bool) { + if i == nil { + return + } + return i.Flags.Has(3) +} + // GetMessage returns value of Message field. func (i *InputBotInlineMessageText) GetMessage() (value string) { if i == nil { @@ -2222,6 +2292,452 @@ func (i *InputBotInlineMessageMediaInvoice) GetReplyMarkup() (value ReplyMarkupC return i.ReplyMarkup, true } +// InputBotInlineMessageMediaWebPage represents TL type `inputBotInlineMessageMediaWebPage#bddcc510`. +// +// See https://core.telegram.org/constructor/inputBotInlineMessageMediaWebPage for reference. +type InputBotInlineMessageMediaWebPage struct { + // Flags field of InputBotInlineMessageMediaWebPage. + Flags bin.Fields + // InvertMedia field of InputBotInlineMessageMediaWebPage. + InvertMedia bool + // ForceLargeMedia field of InputBotInlineMessageMediaWebPage. + ForceLargeMedia bool + // ForceSmallMedia field of InputBotInlineMessageMediaWebPage. + ForceSmallMedia bool + // Optional field of InputBotInlineMessageMediaWebPage. + Optional bool + // Message field of InputBotInlineMessageMediaWebPage. + Message string + // Entities field of InputBotInlineMessageMediaWebPage. + // + // Use SetEntities and GetEntities helpers. + Entities []MessageEntityClass + // URL field of InputBotInlineMessageMediaWebPage. + URL string + // ReplyMarkup field of InputBotInlineMessageMediaWebPage. + // + // Use SetReplyMarkup and GetReplyMarkup helpers. + ReplyMarkup ReplyMarkupClass +} + +// InputBotInlineMessageMediaWebPageTypeID is TL type id of InputBotInlineMessageMediaWebPage. +const InputBotInlineMessageMediaWebPageTypeID = 0xbddcc510 + +// construct implements constructor of InputBotInlineMessageClass. +func (i InputBotInlineMessageMediaWebPage) construct() InputBotInlineMessageClass { return &i } + +// Ensuring interfaces in compile-time for InputBotInlineMessageMediaWebPage. +var ( + _ bin.Encoder = &InputBotInlineMessageMediaWebPage{} + _ bin.Decoder = &InputBotInlineMessageMediaWebPage{} + _ bin.BareEncoder = &InputBotInlineMessageMediaWebPage{} + _ bin.BareDecoder = &InputBotInlineMessageMediaWebPage{} + + _ InputBotInlineMessageClass = &InputBotInlineMessageMediaWebPage{} +) + +func (i *InputBotInlineMessageMediaWebPage) Zero() bool { + if i == nil { + return true + } + if !(i.Flags.Zero()) { + return false + } + if !(i.InvertMedia == false) { + return false + } + if !(i.ForceLargeMedia == false) { + return false + } + if !(i.ForceSmallMedia == false) { + return false + } + if !(i.Optional == false) { + return false + } + if !(i.Message == "") { + return false + } + if !(i.Entities == nil) { + return false + } + if !(i.URL == "") { + return false + } + if !(i.ReplyMarkup == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputBotInlineMessageMediaWebPage) String() string { + if i == nil { + return "InputBotInlineMessageMediaWebPage(nil)" + } + type Alias InputBotInlineMessageMediaWebPage + return fmt.Sprintf("InputBotInlineMessageMediaWebPage%+v", Alias(*i)) +} + +// FillFrom fills InputBotInlineMessageMediaWebPage from given interface. +func (i *InputBotInlineMessageMediaWebPage) FillFrom(from interface { + GetInvertMedia() (value bool) + GetForceLargeMedia() (value bool) + GetForceSmallMedia() (value bool) + GetOptional() (value bool) + GetMessage() (value string) + GetEntities() (value []MessageEntityClass, ok bool) + GetURL() (value string) + GetReplyMarkup() (value ReplyMarkupClass, ok bool) +}) { + i.InvertMedia = from.GetInvertMedia() + i.ForceLargeMedia = from.GetForceLargeMedia() + i.ForceSmallMedia = from.GetForceSmallMedia() + i.Optional = from.GetOptional() + i.Message = from.GetMessage() + if val, ok := from.GetEntities(); ok { + i.Entities = val + } + + i.URL = from.GetURL() + if val, ok := from.GetReplyMarkup(); ok { + i.ReplyMarkup = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputBotInlineMessageMediaWebPage) TypeID() uint32 { + return InputBotInlineMessageMediaWebPageTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputBotInlineMessageMediaWebPage) TypeName() string { + return "inputBotInlineMessageMediaWebPage" +} + +// TypeInfo returns info about TL type. +func (i *InputBotInlineMessageMediaWebPage) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputBotInlineMessageMediaWebPage", + ID: InputBotInlineMessageMediaWebPageTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !i.Flags.Has(3), + }, + { + Name: "ForceLargeMedia", + SchemaName: "force_large_media", + Null: !i.Flags.Has(4), + }, + { + Name: "ForceSmallMedia", + SchemaName: "force_small_media", + Null: !i.Flags.Has(5), + }, + { + Name: "Optional", + SchemaName: "optional", + Null: !i.Flags.Has(6), + }, + { + Name: "Message", + SchemaName: "message", + }, + { + Name: "Entities", + SchemaName: "entities", + Null: !i.Flags.Has(1), + }, + { + Name: "URL", + SchemaName: "url", + }, + { + Name: "ReplyMarkup", + SchemaName: "reply_markup", + Null: !i.Flags.Has(2), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (i *InputBotInlineMessageMediaWebPage) SetFlags() { + if !(i.InvertMedia == false) { + i.Flags.Set(3) + } + if !(i.ForceLargeMedia == false) { + i.Flags.Set(4) + } + if !(i.ForceSmallMedia == false) { + i.Flags.Set(5) + } + if !(i.Optional == false) { + i.Flags.Set(6) + } + if !(i.Entities == nil) { + i.Flags.Set(1) + } + if !(i.ReplyMarkup == nil) { + i.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (i *InputBotInlineMessageMediaWebPage) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputBotInlineMessageMediaWebPage#bddcc510 as nil") + } + b.PutID(InputBotInlineMessageMediaWebPageTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputBotInlineMessageMediaWebPage) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputBotInlineMessageMediaWebPage#bddcc510 as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputBotInlineMessageMediaWebPage#bddcc510: field flags: %w", err) + } + b.PutString(i.Message) + if i.Flags.Has(1) { + b.PutVectorHeader(len(i.Entities)) + for idx, v := range i.Entities { + if v == nil { + return fmt.Errorf("unable to encode inputBotInlineMessageMediaWebPage#bddcc510: field entities element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputBotInlineMessageMediaWebPage#bddcc510: field entities element with index %d: %w", idx, err) + } + } + } + b.PutString(i.URL) + if i.Flags.Has(2) { + if i.ReplyMarkup == nil { + return fmt.Errorf("unable to encode inputBotInlineMessageMediaWebPage#bddcc510: field reply_markup is nil") + } + if err := i.ReplyMarkup.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputBotInlineMessageMediaWebPage#bddcc510: field reply_markup: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InputBotInlineMessageMediaWebPage) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputBotInlineMessageMediaWebPage#bddcc510 to nil") + } + if err := b.ConsumeID(InputBotInlineMessageMediaWebPageTypeID); err != nil { + return fmt.Errorf("unable to decode inputBotInlineMessageMediaWebPage#bddcc510: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputBotInlineMessageMediaWebPage) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputBotInlineMessageMediaWebPage#bddcc510 to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputBotInlineMessageMediaWebPage#bddcc510: field flags: %w", err) + } + } + i.InvertMedia = i.Flags.Has(3) + i.ForceLargeMedia = i.Flags.Has(4) + i.ForceSmallMedia = i.Flags.Has(5) + i.Optional = i.Flags.Has(6) + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inputBotInlineMessageMediaWebPage#bddcc510: field message: %w", err) + } + i.Message = value + } + if i.Flags.Has(1) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode inputBotInlineMessageMediaWebPage#bddcc510: field entities: %w", err) + } + + if headerLen > 0 { + i.Entities = make([]MessageEntityClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeMessageEntity(b) + if err != nil { + return fmt.Errorf("unable to decode inputBotInlineMessageMediaWebPage#bddcc510: field entities: %w", err) + } + i.Entities = append(i.Entities, value) + } + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inputBotInlineMessageMediaWebPage#bddcc510: field url: %w", err) + } + i.URL = value + } + if i.Flags.Has(2) { + value, err := DecodeReplyMarkup(b) + if err != nil { + return fmt.Errorf("unable to decode inputBotInlineMessageMediaWebPage#bddcc510: field reply_markup: %w", err) + } + i.ReplyMarkup = value + } + return nil +} + +// SetInvertMedia sets value of InvertMedia conditional field. +func (i *InputBotInlineMessageMediaWebPage) SetInvertMedia(value bool) { + if value { + i.Flags.Set(3) + i.InvertMedia = true + } else { + i.Flags.Unset(3) + i.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (i *InputBotInlineMessageMediaWebPage) GetInvertMedia() (value bool) { + if i == nil { + return + } + return i.Flags.Has(3) +} + +// SetForceLargeMedia sets value of ForceLargeMedia conditional field. +func (i *InputBotInlineMessageMediaWebPage) SetForceLargeMedia(value bool) { + if value { + i.Flags.Set(4) + i.ForceLargeMedia = true + } else { + i.Flags.Unset(4) + i.ForceLargeMedia = false + } +} + +// GetForceLargeMedia returns value of ForceLargeMedia conditional field. +func (i *InputBotInlineMessageMediaWebPage) GetForceLargeMedia() (value bool) { + if i == nil { + return + } + return i.Flags.Has(4) +} + +// SetForceSmallMedia sets value of ForceSmallMedia conditional field. +func (i *InputBotInlineMessageMediaWebPage) SetForceSmallMedia(value bool) { + if value { + i.Flags.Set(5) + i.ForceSmallMedia = true + } else { + i.Flags.Unset(5) + i.ForceSmallMedia = false + } +} + +// GetForceSmallMedia returns value of ForceSmallMedia conditional field. +func (i *InputBotInlineMessageMediaWebPage) GetForceSmallMedia() (value bool) { + if i == nil { + return + } + return i.Flags.Has(5) +} + +// SetOptional sets value of Optional conditional field. +func (i *InputBotInlineMessageMediaWebPage) SetOptional(value bool) { + if value { + i.Flags.Set(6) + i.Optional = true + } else { + i.Flags.Unset(6) + i.Optional = false + } +} + +// GetOptional returns value of Optional conditional field. +func (i *InputBotInlineMessageMediaWebPage) GetOptional() (value bool) { + if i == nil { + return + } + return i.Flags.Has(6) +} + +// GetMessage returns value of Message field. +func (i *InputBotInlineMessageMediaWebPage) GetMessage() (value string) { + if i == nil { + return + } + return i.Message +} + +// SetEntities sets value of Entities conditional field. +func (i *InputBotInlineMessageMediaWebPage) SetEntities(value []MessageEntityClass) { + i.Flags.Set(1) + i.Entities = value +} + +// GetEntities returns value of Entities conditional field and +// boolean which is true if field was set. +func (i *InputBotInlineMessageMediaWebPage) GetEntities() (value []MessageEntityClass, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(1) { + return value, false + } + return i.Entities, true +} + +// GetURL returns value of URL field. +func (i *InputBotInlineMessageMediaWebPage) GetURL() (value string) { + if i == nil { + return + } + return i.URL +} + +// SetReplyMarkup sets value of ReplyMarkup conditional field. +func (i *InputBotInlineMessageMediaWebPage) SetReplyMarkup(value ReplyMarkupClass) { + i.Flags.Set(2) + i.ReplyMarkup = value +} + +// GetReplyMarkup returns value of ReplyMarkup conditional field and +// boolean which is true if field was set. +func (i *InputBotInlineMessageMediaWebPage) GetReplyMarkup() (value ReplyMarkupClass, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(2) { + return value, false + } + return i.ReplyMarkup, true +} + +// MapEntities returns field Entities wrapped in MessageEntityClassArray helper. +func (i *InputBotInlineMessageMediaWebPage) MapEntities() (value MessageEntityClassArray, ok bool) { + if !i.Flags.Has(1) { + return value, false + } + return MessageEntityClassArray(i.Entities), true +} + // InputBotInlineMessageClassName is schema name of InputBotInlineMessageClass. const InputBotInlineMessageClassName = "InputBotInlineMessage" @@ -2243,6 +2759,7 @@ const InputBotInlineMessageClassName = "InputBotInlineMessage" // case *tg.InputBotInlineMessageMediaContact: // inputBotInlineMessageMediaContact#a6edbffd // case *tg.InputBotInlineMessageGame: // inputBotInlineMessageGame#4b425864 // case *tg.InputBotInlineMessageMediaInvoice: // inputBotInlineMessageMediaInvoice#d7e78225 +// case *tg.InputBotInlineMessageMediaWebPage: // inputBotInlineMessageMediaWebPage#bddcc510 // default: panic(v) // } type InputBotInlineMessageClass interface { @@ -2323,6 +2840,13 @@ func DecodeInputBotInlineMessage(buf *bin.Buffer) (InputBotInlineMessageClass, e return nil, fmt.Errorf("unable to decode InputBotInlineMessageClass: %w", err) } return &v, nil + case InputBotInlineMessageMediaWebPageTypeID: + // Decoding inputBotInlineMessageMediaWebPage#bddcc510. + v := InputBotInlineMessageMediaWebPage{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InputBotInlineMessageClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode InputBotInlineMessageClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_input_bot_inline_message_slices_gen.go b/tg/tl_input_bot_inline_message_slices_gen.go index 64c74a0c9a..d57c6fdea1 100644 --- a/tg/tl_input_bot_inline_message_slices_gen.go +++ b/tg/tl_input_bot_inline_message_slices_gen.go @@ -207,6 +207,19 @@ func (s InputBotInlineMessageClassArray) AsInputBotInlineMessageMediaInvoice() ( return to } +// AsInputBotInlineMessageMediaWebPage returns copy with only InputBotInlineMessageMediaWebPage constructors. +func (s InputBotInlineMessageClassArray) AsInputBotInlineMessageMediaWebPage() (to InputBotInlineMessageMediaWebPageArray) { + for _, elem := range s { + value, ok := elem.(*InputBotInlineMessageMediaWebPage) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // InputBotInlineMessageMediaAutoArray is adapter for slice of InputBotInlineMessageMediaAuto. type InputBotInlineMessageMediaAutoArray []InputBotInlineMessageMediaAuto @@ -780,3 +793,85 @@ func (s *InputBotInlineMessageMediaInvoiceArray) Pop() (v InputBotInlineMessageM return v, true } + +// InputBotInlineMessageMediaWebPageArray is adapter for slice of InputBotInlineMessageMediaWebPage. +type InputBotInlineMessageMediaWebPageArray []InputBotInlineMessageMediaWebPage + +// Sort sorts slice of InputBotInlineMessageMediaWebPage. +func (s InputBotInlineMessageMediaWebPageArray) Sort(less func(a, b InputBotInlineMessageMediaWebPage) bool) InputBotInlineMessageMediaWebPageArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InputBotInlineMessageMediaWebPage. +func (s InputBotInlineMessageMediaWebPageArray) SortStable(less func(a, b InputBotInlineMessageMediaWebPage) bool) InputBotInlineMessageMediaWebPageArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InputBotInlineMessageMediaWebPage. +func (s InputBotInlineMessageMediaWebPageArray) Retain(keep func(x InputBotInlineMessageMediaWebPage) bool) InputBotInlineMessageMediaWebPageArray { + 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 InputBotInlineMessageMediaWebPageArray) First() (v InputBotInlineMessageMediaWebPage, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputBotInlineMessageMediaWebPageArray) Last() (v InputBotInlineMessageMediaWebPage, 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 *InputBotInlineMessageMediaWebPageArray) PopFirst() (v InputBotInlineMessageMediaWebPage, 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 InputBotInlineMessageMediaWebPage + 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 *InputBotInlineMessageMediaWebPageArray) Pop() (v InputBotInlineMessageMediaWebPage, 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_input_invoice_gen.go b/tg/tl_input_invoice_gen.go index 679aa084dd..a1b47fd85b 100644 --- a/tg/tl_input_invoice_gen.go +++ b/tg/tl_input_invoice_gen.go @@ -341,6 +341,172 @@ func (i *InputInvoiceSlug) GetSlug() (value string) { return i.Slug } +// InputInvoicePremiumGiftCode represents TL type `inputInvoicePremiumGiftCode#98986c0d`. +// +// See https://core.telegram.org/constructor/inputInvoicePremiumGiftCode for reference. +type InputInvoicePremiumGiftCode struct { + // Purpose field of InputInvoicePremiumGiftCode. + Purpose InputStorePaymentPurposeClass + // Option field of InputInvoicePremiumGiftCode. + Option PremiumGiftCodeOption +} + +// InputInvoicePremiumGiftCodeTypeID is TL type id of InputInvoicePremiumGiftCode. +const InputInvoicePremiumGiftCodeTypeID = 0x98986c0d + +// construct implements constructor of InputInvoiceClass. +func (i InputInvoicePremiumGiftCode) construct() InputInvoiceClass { return &i } + +// Ensuring interfaces in compile-time for InputInvoicePremiumGiftCode. +var ( + _ bin.Encoder = &InputInvoicePremiumGiftCode{} + _ bin.Decoder = &InputInvoicePremiumGiftCode{} + _ bin.BareEncoder = &InputInvoicePremiumGiftCode{} + _ bin.BareDecoder = &InputInvoicePremiumGiftCode{} + + _ InputInvoiceClass = &InputInvoicePremiumGiftCode{} +) + +func (i *InputInvoicePremiumGiftCode) Zero() bool { + if i == nil { + return true + } + if !(i.Purpose == nil) { + return false + } + if !(i.Option.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputInvoicePremiumGiftCode) String() string { + if i == nil { + return "InputInvoicePremiumGiftCode(nil)" + } + type Alias InputInvoicePremiumGiftCode + return fmt.Sprintf("InputInvoicePremiumGiftCode%+v", Alias(*i)) +} + +// FillFrom fills InputInvoicePremiumGiftCode from given interface. +func (i *InputInvoicePremiumGiftCode) FillFrom(from interface { + GetPurpose() (value InputStorePaymentPurposeClass) + GetOption() (value PremiumGiftCodeOption) +}) { + i.Purpose = from.GetPurpose() + i.Option = from.GetOption() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputInvoicePremiumGiftCode) TypeID() uint32 { + return InputInvoicePremiumGiftCodeTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputInvoicePremiumGiftCode) TypeName() string { + return "inputInvoicePremiumGiftCode" +} + +// TypeInfo returns info about TL type. +func (i *InputInvoicePremiumGiftCode) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputInvoicePremiumGiftCode", + ID: InputInvoicePremiumGiftCodeTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Purpose", + SchemaName: "purpose", + }, + { + Name: "Option", + SchemaName: "option", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *InputInvoicePremiumGiftCode) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputInvoicePremiumGiftCode#98986c0d as nil") + } + b.PutID(InputInvoicePremiumGiftCodeTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputInvoicePremiumGiftCode) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputInvoicePremiumGiftCode#98986c0d as nil") + } + if i.Purpose == nil { + return fmt.Errorf("unable to encode inputInvoicePremiumGiftCode#98986c0d: field purpose is nil") + } + if err := i.Purpose.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputInvoicePremiumGiftCode#98986c0d: field purpose: %w", err) + } + if err := i.Option.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputInvoicePremiumGiftCode#98986c0d: field option: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InputInvoicePremiumGiftCode) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputInvoicePremiumGiftCode#98986c0d to nil") + } + if err := b.ConsumeID(InputInvoicePremiumGiftCodeTypeID); err != nil { + return fmt.Errorf("unable to decode inputInvoicePremiumGiftCode#98986c0d: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputInvoicePremiumGiftCode) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputInvoicePremiumGiftCode#98986c0d to nil") + } + { + value, err := DecodeInputStorePaymentPurpose(b) + if err != nil { + return fmt.Errorf("unable to decode inputInvoicePremiumGiftCode#98986c0d: field purpose: %w", err) + } + i.Purpose = value + } + { + if err := i.Option.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputInvoicePremiumGiftCode#98986c0d: field option: %w", err) + } + } + return nil +} + +// GetPurpose returns value of Purpose field. +func (i *InputInvoicePremiumGiftCode) GetPurpose() (value InputStorePaymentPurposeClass) { + if i == nil { + return + } + return i.Purpose +} + +// GetOption returns value of Option field. +func (i *InputInvoicePremiumGiftCode) GetOption() (value PremiumGiftCodeOption) { + if i == nil { + return + } + return i.Option +} + // InputInvoiceClassName is schema name of InputInvoiceClass. const InputInvoiceClassName = "InputInvoice" @@ -357,6 +523,7 @@ const InputInvoiceClassName = "InputInvoice" // switch v := g.(type) { // case *tg.InputInvoiceMessage: // inputInvoiceMessage#c5b56859 // case *tg.InputInvoiceSlug: // inputInvoiceSlug#c326caef +// case *tg.InputInvoicePremiumGiftCode: // inputInvoicePremiumGiftCode#98986c0d // default: panic(v) // } type InputInvoiceClass interface { @@ -399,6 +566,13 @@ func DecodeInputInvoice(buf *bin.Buffer) (InputInvoiceClass, error) { return nil, fmt.Errorf("unable to decode InputInvoiceClass: %w", err) } return &v, nil + case InputInvoicePremiumGiftCodeTypeID: + // Decoding inputInvoicePremiumGiftCode#98986c0d. + v := InputInvoicePremiumGiftCode{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InputInvoiceClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode InputInvoiceClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_input_invoice_slices_gen.go b/tg/tl_input_invoice_slices_gen.go index 5ab77b59ca..52bf32e495 100644 --- a/tg/tl_input_invoice_slices_gen.go +++ b/tg/tl_input_invoice_slices_gen.go @@ -142,6 +142,19 @@ func (s InputInvoiceClassArray) AsInputInvoiceSlug() (to InputInvoiceSlugArray) return to } +// AsInputInvoicePremiumGiftCode returns copy with only InputInvoicePremiumGiftCode constructors. +func (s InputInvoiceClassArray) AsInputInvoicePremiumGiftCode() (to InputInvoicePremiumGiftCodeArray) { + for _, elem := range s { + value, ok := elem.(*InputInvoicePremiumGiftCode) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // InputInvoiceMessageArray is adapter for slice of InputInvoiceMessage. type InputInvoiceMessageArray []InputInvoiceMessage @@ -305,3 +318,85 @@ func (s *InputInvoiceSlugArray) Pop() (v InputInvoiceSlug, ok bool) { return v, true } + +// InputInvoicePremiumGiftCodeArray is adapter for slice of InputInvoicePremiumGiftCode. +type InputInvoicePremiumGiftCodeArray []InputInvoicePremiumGiftCode + +// Sort sorts slice of InputInvoicePremiumGiftCode. +func (s InputInvoicePremiumGiftCodeArray) Sort(less func(a, b InputInvoicePremiumGiftCode) bool) InputInvoicePremiumGiftCodeArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InputInvoicePremiumGiftCode. +func (s InputInvoicePremiumGiftCodeArray) SortStable(less func(a, b InputInvoicePremiumGiftCode) bool) InputInvoicePremiumGiftCodeArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InputInvoicePremiumGiftCode. +func (s InputInvoicePremiumGiftCodeArray) Retain(keep func(x InputInvoicePremiumGiftCode) bool) InputInvoicePremiumGiftCodeArray { + 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 InputInvoicePremiumGiftCodeArray) First() (v InputInvoicePremiumGiftCode, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputInvoicePremiumGiftCodeArray) Last() (v InputInvoicePremiumGiftCode, 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 *InputInvoicePremiumGiftCodeArray) PopFirst() (v InputInvoicePremiumGiftCode, 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 InputInvoicePremiumGiftCode + 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 *InputInvoicePremiumGiftCodeArray) Pop() (v InputInvoicePremiumGiftCode, 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_input_media_gen.go b/tg/tl_input_media_gen.go index 1d8092e7f4..6ad374aa10 100644 --- a/tg/tl_input_media_gen.go +++ b/tg/tl_input_media_gen.go @@ -4215,6 +4215,263 @@ func (i *InputMediaStory) GetID() (value int) { return i.ID } +// InputMediaWebPage represents TL type `inputMediaWebPage#c21b8849`. +// +// See https://core.telegram.org/constructor/inputMediaWebPage for reference. +type InputMediaWebPage struct { + // Flags field of InputMediaWebPage. + Flags bin.Fields + // ForceLargeMedia field of InputMediaWebPage. + ForceLargeMedia bool + // ForceSmallMedia field of InputMediaWebPage. + ForceSmallMedia bool + // Optional field of InputMediaWebPage. + Optional bool + // URL field of InputMediaWebPage. + URL string +} + +// InputMediaWebPageTypeID is TL type id of InputMediaWebPage. +const InputMediaWebPageTypeID = 0xc21b8849 + +// construct implements constructor of InputMediaClass. +func (i InputMediaWebPage) construct() InputMediaClass { return &i } + +// Ensuring interfaces in compile-time for InputMediaWebPage. +var ( + _ bin.Encoder = &InputMediaWebPage{} + _ bin.Decoder = &InputMediaWebPage{} + _ bin.BareEncoder = &InputMediaWebPage{} + _ bin.BareDecoder = &InputMediaWebPage{} + + _ InputMediaClass = &InputMediaWebPage{} +) + +func (i *InputMediaWebPage) Zero() bool { + if i == nil { + return true + } + if !(i.Flags.Zero()) { + return false + } + if !(i.ForceLargeMedia == false) { + return false + } + if !(i.ForceSmallMedia == false) { + return false + } + if !(i.Optional == false) { + return false + } + if !(i.URL == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputMediaWebPage) String() string { + if i == nil { + return "InputMediaWebPage(nil)" + } + type Alias InputMediaWebPage + return fmt.Sprintf("InputMediaWebPage%+v", Alias(*i)) +} + +// FillFrom fills InputMediaWebPage from given interface. +func (i *InputMediaWebPage) FillFrom(from interface { + GetForceLargeMedia() (value bool) + GetForceSmallMedia() (value bool) + GetOptional() (value bool) + GetURL() (value string) +}) { + i.ForceLargeMedia = from.GetForceLargeMedia() + i.ForceSmallMedia = from.GetForceSmallMedia() + i.Optional = from.GetOptional() + i.URL = from.GetURL() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputMediaWebPage) TypeID() uint32 { + return InputMediaWebPageTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputMediaWebPage) TypeName() string { + return "inputMediaWebPage" +} + +// TypeInfo returns info about TL type. +func (i *InputMediaWebPage) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputMediaWebPage", + ID: InputMediaWebPageTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ForceLargeMedia", + SchemaName: "force_large_media", + Null: !i.Flags.Has(0), + }, + { + Name: "ForceSmallMedia", + SchemaName: "force_small_media", + Null: !i.Flags.Has(1), + }, + { + Name: "Optional", + SchemaName: "optional", + Null: !i.Flags.Has(2), + }, + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (i *InputMediaWebPage) SetFlags() { + if !(i.ForceLargeMedia == false) { + i.Flags.Set(0) + } + if !(i.ForceSmallMedia == false) { + i.Flags.Set(1) + } + if !(i.Optional == false) { + i.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (i *InputMediaWebPage) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputMediaWebPage#c21b8849 as nil") + } + b.PutID(InputMediaWebPageTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputMediaWebPage) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputMediaWebPage#c21b8849 as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputMediaWebPage#c21b8849: field flags: %w", err) + } + b.PutString(i.URL) + return nil +} + +// Decode implements bin.Decoder. +func (i *InputMediaWebPage) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputMediaWebPage#c21b8849 to nil") + } + if err := b.ConsumeID(InputMediaWebPageTypeID); err != nil { + return fmt.Errorf("unable to decode inputMediaWebPage#c21b8849: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputMediaWebPage) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputMediaWebPage#c21b8849 to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputMediaWebPage#c21b8849: field flags: %w", err) + } + } + i.ForceLargeMedia = i.Flags.Has(0) + i.ForceSmallMedia = i.Flags.Has(1) + i.Optional = i.Flags.Has(2) + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inputMediaWebPage#c21b8849: field url: %w", err) + } + i.URL = value + } + return nil +} + +// SetForceLargeMedia sets value of ForceLargeMedia conditional field. +func (i *InputMediaWebPage) SetForceLargeMedia(value bool) { + if value { + i.Flags.Set(0) + i.ForceLargeMedia = true + } else { + i.Flags.Unset(0) + i.ForceLargeMedia = false + } +} + +// GetForceLargeMedia returns value of ForceLargeMedia conditional field. +func (i *InputMediaWebPage) GetForceLargeMedia() (value bool) { + if i == nil { + return + } + return i.Flags.Has(0) +} + +// SetForceSmallMedia sets value of ForceSmallMedia conditional field. +func (i *InputMediaWebPage) SetForceSmallMedia(value bool) { + if value { + i.Flags.Set(1) + i.ForceSmallMedia = true + } else { + i.Flags.Unset(1) + i.ForceSmallMedia = false + } +} + +// GetForceSmallMedia returns value of ForceSmallMedia conditional field. +func (i *InputMediaWebPage) GetForceSmallMedia() (value bool) { + if i == nil { + return + } + return i.Flags.Has(1) +} + +// SetOptional sets value of Optional conditional field. +func (i *InputMediaWebPage) SetOptional(value bool) { + if value { + i.Flags.Set(2) + i.Optional = true + } else { + i.Flags.Unset(2) + i.Optional = false + } +} + +// GetOptional returns value of Optional conditional field. +func (i *InputMediaWebPage) GetOptional() (value bool) { + if i == nil { + return + } + return i.Flags.Has(2) +} + +// GetURL returns value of URL field. +func (i *InputMediaWebPage) GetURL() (value string) { + if i == nil { + return + } + return i.URL +} + // InputMediaClassName is schema name of InputMediaClass. const InputMediaClassName = "InputMedia" @@ -4245,6 +4502,7 @@ const InputMediaClassName = "InputMedia" // case *tg.InputMediaPoll: // inputMediaPoll#f94e5f1 // case *tg.InputMediaDice: // inputMediaDice#e66fbf7b // case *tg.InputMediaStory: // inputMediaStory#89fdd778 +// case *tg.InputMediaWebPage: // inputMediaWebPage#c21b8849 // default: panic(v) // } type InputMediaClass interface { @@ -4385,6 +4643,13 @@ func DecodeInputMedia(buf *bin.Buffer) (InputMediaClass, error) { return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err) } return &v, nil + case InputMediaWebPageTypeID: + // Decoding inputMediaWebPage#c21b8849. + v := InputMediaWebPage{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode InputMediaClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_input_media_slices_gen.go b/tg/tl_input_media_slices_gen.go index 0ebc91bc61..4eaa15e2a8 100644 --- a/tg/tl_input_media_slices_gen.go +++ b/tg/tl_input_media_slices_gen.go @@ -311,6 +311,19 @@ func (s InputMediaClassArray) AsInputMediaStory() (to InputMediaStoryArray) { return to } +// AsInputMediaWebPage returns copy with only InputMediaWebPage constructors. +func (s InputMediaClassArray) AsInputMediaWebPage() (to InputMediaWebPageArray) { + for _, elem := range s { + value, ok := elem.(*InputMediaWebPage) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // InputMediaUploadedPhotoArray is adapter for slice of InputMediaUploadedPhoto. type InputMediaUploadedPhotoArray []InputMediaUploadedPhoto @@ -1568,3 +1581,85 @@ func (s InputMediaStoryArray) ToMap() map[int]InputMediaStory { s.FillMap(r) return r } + +// InputMediaWebPageArray is adapter for slice of InputMediaWebPage. +type InputMediaWebPageArray []InputMediaWebPage + +// Sort sorts slice of InputMediaWebPage. +func (s InputMediaWebPageArray) Sort(less func(a, b InputMediaWebPage) bool) InputMediaWebPageArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InputMediaWebPage. +func (s InputMediaWebPageArray) SortStable(less func(a, b InputMediaWebPage) bool) InputMediaWebPageArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InputMediaWebPage. +func (s InputMediaWebPageArray) Retain(keep func(x InputMediaWebPage) bool) InputMediaWebPageArray { + 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 InputMediaWebPageArray) First() (v InputMediaWebPage, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputMediaWebPageArray) Last() (v InputMediaWebPage, 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 *InputMediaWebPageArray) PopFirst() (v InputMediaWebPage, 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 InputMediaWebPage + 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 *InputMediaWebPageArray) Pop() (v InputMediaWebPage, 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_input_reply_to_gen.go b/tg/tl_input_reply_to_gen.go index c60a78a7d1..8d688b2166 100644 --- a/tg/tl_input_reply_to_gen.go +++ b/tg/tl_input_reply_to_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// InputReplyToMessage represents TL type `inputReplyToMessage#9c5386e4`. +// InputReplyToMessage represents TL type `inputReplyToMessage#73ec805`. // // See https://core.telegram.org/constructor/inputReplyToMessage for reference. type InputReplyToMessage struct { @@ -43,10 +43,22 @@ type InputReplyToMessage struct { // // Use SetTopMsgID and GetTopMsgID helpers. TopMsgID int + // ReplyToPeerID field of InputReplyToMessage. + // + // Use SetReplyToPeerID and GetReplyToPeerID helpers. + ReplyToPeerID InputPeerClass + // QuoteText field of InputReplyToMessage. + // + // Use SetQuoteText and GetQuoteText helpers. + QuoteText string + // QuoteEntities field of InputReplyToMessage. + // + // Use SetQuoteEntities and GetQuoteEntities helpers. + QuoteEntities []MessageEntityClass } // InputReplyToMessageTypeID is TL type id of InputReplyToMessage. -const InputReplyToMessageTypeID = 0x9c5386e4 +const InputReplyToMessageTypeID = 0x73ec805 // construct implements constructor of InputReplyToClass. func (i InputReplyToMessage) construct() InputReplyToClass { return &i } @@ -74,6 +86,15 @@ func (i *InputReplyToMessage) Zero() bool { if !(i.TopMsgID == 0) { return false } + if !(i.ReplyToPeerID == nil) { + return false + } + if !(i.QuoteText == "") { + return false + } + if !(i.QuoteEntities == nil) { + return false + } return true } @@ -91,12 +112,27 @@ func (i *InputReplyToMessage) String() string { func (i *InputReplyToMessage) FillFrom(from interface { GetReplyToMsgID() (value int) GetTopMsgID() (value int, ok bool) + GetReplyToPeerID() (value InputPeerClass, ok bool) + GetQuoteText() (value string, ok bool) + GetQuoteEntities() (value []MessageEntityClass, ok bool) }) { i.ReplyToMsgID = from.GetReplyToMsgID() if val, ok := from.GetTopMsgID(); ok { i.TopMsgID = val } + if val, ok := from.GetReplyToPeerID(); ok { + i.ReplyToPeerID = val + } + + if val, ok := from.GetQuoteText(); ok { + i.QuoteText = val + } + + if val, ok := from.GetQuoteEntities(); ok { + i.QuoteEntities = val + } + } // TypeID returns type id in TL schema. @@ -131,6 +167,21 @@ func (i *InputReplyToMessage) TypeInfo() tdp.Type { SchemaName: "top_msg_id", Null: !i.Flags.Has(0), }, + { + Name: "ReplyToPeerID", + SchemaName: "reply_to_peer_id", + Null: !i.Flags.Has(1), + }, + { + Name: "QuoteText", + SchemaName: "quote_text", + Null: !i.Flags.Has(2), + }, + { + Name: "QuoteEntities", + SchemaName: "quote_entities", + Null: !i.Flags.Has(3), + }, } return typ } @@ -140,12 +191,21 @@ func (i *InputReplyToMessage) SetFlags() { if !(i.TopMsgID == 0) { i.Flags.Set(0) } + if !(i.ReplyToPeerID == nil) { + i.Flags.Set(1) + } + if !(i.QuoteText == "") { + i.Flags.Set(2) + } + if !(i.QuoteEntities == nil) { + i.Flags.Set(3) + } } // Encode implements bin.Encoder. func (i *InputReplyToMessage) Encode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputReplyToMessage#9c5386e4 as nil") + return fmt.Errorf("can't encode inputReplyToMessage#73ec805 as nil") } b.PutID(InputReplyToMessageTypeID) return i.EncodeBare(b) @@ -154,26 +214,48 @@ func (i *InputReplyToMessage) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (i *InputReplyToMessage) EncodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputReplyToMessage#9c5386e4 as nil") + return fmt.Errorf("can't encode inputReplyToMessage#73ec805 as nil") } i.SetFlags() if err := i.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputReplyToMessage#9c5386e4: field flags: %w", err) + return fmt.Errorf("unable to encode inputReplyToMessage#73ec805: field flags: %w", err) } b.PutInt(i.ReplyToMsgID) if i.Flags.Has(0) { b.PutInt(i.TopMsgID) } + if i.Flags.Has(1) { + if i.ReplyToPeerID == nil { + return fmt.Errorf("unable to encode inputReplyToMessage#73ec805: field reply_to_peer_id is nil") + } + if err := i.ReplyToPeerID.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputReplyToMessage#73ec805: field reply_to_peer_id: %w", err) + } + } + if i.Flags.Has(2) { + b.PutString(i.QuoteText) + } + if i.Flags.Has(3) { + b.PutVectorHeader(len(i.QuoteEntities)) + for idx, v := range i.QuoteEntities { + if v == nil { + return fmt.Errorf("unable to encode inputReplyToMessage#73ec805: field quote_entities element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputReplyToMessage#73ec805: field quote_entities element with index %d: %w", idx, err) + } + } + } return nil } // Decode implements bin.Decoder. func (i *InputReplyToMessage) Decode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputReplyToMessage#9c5386e4 to nil") + return fmt.Errorf("can't decode inputReplyToMessage#73ec805 to nil") } if err := b.ConsumeID(InputReplyToMessageTypeID); err != nil { - return fmt.Errorf("unable to decode inputReplyToMessage#9c5386e4: %w", err) + return fmt.Errorf("unable to decode inputReplyToMessage#73ec805: %w", err) } return i.DecodeBare(b) } @@ -181,27 +263,58 @@ func (i *InputReplyToMessage) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (i *InputReplyToMessage) DecodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputReplyToMessage#9c5386e4 to nil") + return fmt.Errorf("can't decode inputReplyToMessage#73ec805 to nil") } { if err := i.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputReplyToMessage#9c5386e4: field flags: %w", err) + return fmt.Errorf("unable to decode inputReplyToMessage#73ec805: field flags: %w", err) } } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode inputReplyToMessage#9c5386e4: field reply_to_msg_id: %w", err) + return fmt.Errorf("unable to decode inputReplyToMessage#73ec805: field reply_to_msg_id: %w", err) } i.ReplyToMsgID = value } if i.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode inputReplyToMessage#9c5386e4: field top_msg_id: %w", err) + return fmt.Errorf("unable to decode inputReplyToMessage#73ec805: field top_msg_id: %w", err) } i.TopMsgID = value } + if i.Flags.Has(1) { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode inputReplyToMessage#73ec805: field reply_to_peer_id: %w", err) + } + i.ReplyToPeerID = value + } + if i.Flags.Has(2) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inputReplyToMessage#73ec805: field quote_text: %w", err) + } + i.QuoteText = value + } + if i.Flags.Has(3) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode inputReplyToMessage#73ec805: field quote_entities: %w", err) + } + + if headerLen > 0 { + i.QuoteEntities = make([]MessageEntityClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeMessageEntity(b) + if err != nil { + return fmt.Errorf("unable to decode inputReplyToMessage#73ec805: field quote_entities: %w", err) + } + i.QuoteEntities = append(i.QuoteEntities, value) + } + } return nil } @@ -231,6 +344,68 @@ func (i *InputReplyToMessage) GetTopMsgID() (value int, ok bool) { return i.TopMsgID, true } +// SetReplyToPeerID sets value of ReplyToPeerID conditional field. +func (i *InputReplyToMessage) SetReplyToPeerID(value InputPeerClass) { + i.Flags.Set(1) + i.ReplyToPeerID = value +} + +// GetReplyToPeerID returns value of ReplyToPeerID conditional field and +// boolean which is true if field was set. +func (i *InputReplyToMessage) GetReplyToPeerID() (value InputPeerClass, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(1) { + return value, false + } + return i.ReplyToPeerID, true +} + +// SetQuoteText sets value of QuoteText conditional field. +func (i *InputReplyToMessage) SetQuoteText(value string) { + i.Flags.Set(2) + i.QuoteText = value +} + +// GetQuoteText returns value of QuoteText conditional field and +// boolean which is true if field was set. +func (i *InputReplyToMessage) GetQuoteText() (value string, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(2) { + return value, false + } + return i.QuoteText, true +} + +// SetQuoteEntities sets value of QuoteEntities conditional field. +func (i *InputReplyToMessage) SetQuoteEntities(value []MessageEntityClass) { + i.Flags.Set(3) + i.QuoteEntities = value +} + +// GetQuoteEntities returns value of QuoteEntities conditional field and +// boolean which is true if field was set. +func (i *InputReplyToMessage) GetQuoteEntities() (value []MessageEntityClass, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(3) { + return value, false + } + return i.QuoteEntities, true +} + +// MapQuoteEntities returns field QuoteEntities wrapped in MessageEntityClassArray helper. +func (i *InputReplyToMessage) MapQuoteEntities() (value MessageEntityClassArray, ok bool) { + if !i.Flags.Has(3) { + return value, false + } + return MessageEntityClassArray(i.QuoteEntities), true +} + // InputReplyToStory represents TL type `inputReplyToStory#15b0f283`. // // See https://core.telegram.org/constructor/inputReplyToStory for reference. @@ -411,7 +586,7 @@ const InputReplyToClassName = "InputReplyTo" // panic(err) // } // switch v := g.(type) { -// case *tg.InputReplyToMessage: // inputReplyToMessage#9c5386e4 +// case *tg.InputReplyToMessage: // inputReplyToMessage#73ec805 // case *tg.InputReplyToStory: // inputReplyToStory#15b0f283 // default: panic(v) // } @@ -442,7 +617,7 @@ func DecodeInputReplyTo(buf *bin.Buffer) (InputReplyToClass, error) { } switch id { case InputReplyToMessageTypeID: - // Decoding inputReplyToMessage#9c5386e4. + // Decoding inputReplyToMessage#73ec805. v := InputReplyToMessage{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode InputReplyToClass: %w", err) diff --git a/tg/tl_input_store_payment_purpose_gen.go b/tg/tl_input_store_payment_purpose_gen.go index cad92519b5..0397733e3d 100644 --- a/tg/tl_input_store_payment_purpose_gen.go +++ b/tg/tl_input_store_payment_purpose_gen.go @@ -434,6 +434,723 @@ func (i *InputStorePaymentGiftPremium) GetAmount() (value int64) { return i.Amount } +// InputStorePaymentPremiumGiftCode represents TL type `inputStorePaymentPremiumGiftCode#a3805f3f`. +// +// See https://core.telegram.org/constructor/inputStorePaymentPremiumGiftCode for reference. +type InputStorePaymentPremiumGiftCode struct { + // Flags field of InputStorePaymentPremiumGiftCode. + Flags bin.Fields + // Users field of InputStorePaymentPremiumGiftCode. + Users []InputUserClass + // BoostPeer field of InputStorePaymentPremiumGiftCode. + // + // Use SetBoostPeer and GetBoostPeer helpers. + BoostPeer InputPeerClass + // Currency field of InputStorePaymentPremiumGiftCode. + Currency string + // Amount field of InputStorePaymentPremiumGiftCode. + Amount int64 +} + +// InputStorePaymentPremiumGiftCodeTypeID is TL type id of InputStorePaymentPremiumGiftCode. +const InputStorePaymentPremiumGiftCodeTypeID = 0xa3805f3f + +// construct implements constructor of InputStorePaymentPurposeClass. +func (i InputStorePaymentPremiumGiftCode) construct() InputStorePaymentPurposeClass { return &i } + +// Ensuring interfaces in compile-time for InputStorePaymentPremiumGiftCode. +var ( + _ bin.Encoder = &InputStorePaymentPremiumGiftCode{} + _ bin.Decoder = &InputStorePaymentPremiumGiftCode{} + _ bin.BareEncoder = &InputStorePaymentPremiumGiftCode{} + _ bin.BareDecoder = &InputStorePaymentPremiumGiftCode{} + + _ InputStorePaymentPurposeClass = &InputStorePaymentPremiumGiftCode{} +) + +func (i *InputStorePaymentPremiumGiftCode) Zero() bool { + if i == nil { + return true + } + if !(i.Flags.Zero()) { + return false + } + if !(i.Users == nil) { + return false + } + if !(i.BoostPeer == nil) { + return false + } + if !(i.Currency == "") { + return false + } + if !(i.Amount == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputStorePaymentPremiumGiftCode) String() string { + if i == nil { + return "InputStorePaymentPremiumGiftCode(nil)" + } + type Alias InputStorePaymentPremiumGiftCode + return fmt.Sprintf("InputStorePaymentPremiumGiftCode%+v", Alias(*i)) +} + +// FillFrom fills InputStorePaymentPremiumGiftCode from given interface. +func (i *InputStorePaymentPremiumGiftCode) FillFrom(from interface { + GetUsers() (value []InputUserClass) + GetBoostPeer() (value InputPeerClass, ok bool) + GetCurrency() (value string) + GetAmount() (value int64) +}) { + i.Users = from.GetUsers() + if val, ok := from.GetBoostPeer(); ok { + i.BoostPeer = val + } + + i.Currency = from.GetCurrency() + i.Amount = from.GetAmount() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputStorePaymentPremiumGiftCode) TypeID() uint32 { + return InputStorePaymentPremiumGiftCodeTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputStorePaymentPremiumGiftCode) TypeName() string { + return "inputStorePaymentPremiumGiftCode" +} + +// TypeInfo returns info about TL type. +func (i *InputStorePaymentPremiumGiftCode) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputStorePaymentPremiumGiftCode", + ID: InputStorePaymentPremiumGiftCodeTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Users", + SchemaName: "users", + }, + { + Name: "BoostPeer", + SchemaName: "boost_peer", + Null: !i.Flags.Has(0), + }, + { + Name: "Currency", + SchemaName: "currency", + }, + { + Name: "Amount", + SchemaName: "amount", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (i *InputStorePaymentPremiumGiftCode) SetFlags() { + if !(i.BoostPeer == nil) { + i.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (i *InputStorePaymentPremiumGiftCode) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStorePaymentPremiumGiftCode#a3805f3f as nil") + } + b.PutID(InputStorePaymentPremiumGiftCodeTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputStorePaymentPremiumGiftCode) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStorePaymentPremiumGiftCode#a3805f3f as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputStorePaymentPremiumGiftCode#a3805f3f: field flags: %w", err) + } + b.PutVectorHeader(len(i.Users)) + for idx, v := range i.Users { + if v == nil { + return fmt.Errorf("unable to encode inputStorePaymentPremiumGiftCode#a3805f3f: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputStorePaymentPremiumGiftCode#a3805f3f: field users element with index %d: %w", idx, err) + } + } + if i.Flags.Has(0) { + if i.BoostPeer == nil { + return fmt.Errorf("unable to encode inputStorePaymentPremiumGiftCode#a3805f3f: field boost_peer is nil") + } + if err := i.BoostPeer.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputStorePaymentPremiumGiftCode#a3805f3f: field boost_peer: %w", err) + } + } + b.PutString(i.Currency) + b.PutLong(i.Amount) + return nil +} + +// Decode implements bin.Decoder. +func (i *InputStorePaymentPremiumGiftCode) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStorePaymentPremiumGiftCode#a3805f3f to nil") + } + if err := b.ConsumeID(InputStorePaymentPremiumGiftCodeTypeID); err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputStorePaymentPremiumGiftCode) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStorePaymentPremiumGiftCode#a3805f3f to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: field flags: %w", err) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: field users: %w", err) + } + + if headerLen > 0 { + i.Users = make([]InputUserClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: field users: %w", err) + } + i.Users = append(i.Users, value) + } + } + if i.Flags.Has(0) { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: field boost_peer: %w", err) + } + i.BoostPeer = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: field currency: %w", err) + } + i.Currency = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: field amount: %w", err) + } + i.Amount = value + } + return nil +} + +// GetUsers returns value of Users field. +func (i *InputStorePaymentPremiumGiftCode) GetUsers() (value []InputUserClass) { + if i == nil { + return + } + return i.Users +} + +// SetBoostPeer sets value of BoostPeer conditional field. +func (i *InputStorePaymentPremiumGiftCode) SetBoostPeer(value InputPeerClass) { + i.Flags.Set(0) + i.BoostPeer = value +} + +// GetBoostPeer returns value of BoostPeer conditional field and +// boolean which is true if field was set. +func (i *InputStorePaymentPremiumGiftCode) GetBoostPeer() (value InputPeerClass, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(0) { + return value, false + } + return i.BoostPeer, true +} + +// GetCurrency returns value of Currency field. +func (i *InputStorePaymentPremiumGiftCode) GetCurrency() (value string) { + if i == nil { + return + } + return i.Currency +} + +// GetAmount returns value of Amount field. +func (i *InputStorePaymentPremiumGiftCode) GetAmount() (value int64) { + if i == nil { + return + } + return i.Amount +} + +// MapUsers returns field Users wrapped in InputUserClassArray helper. +func (i *InputStorePaymentPremiumGiftCode) MapUsers() (value InputUserClassArray) { + return InputUserClassArray(i.Users) +} + +// InputStorePaymentPremiumGiveaway represents TL type `inputStorePaymentPremiumGiveaway#7c9375e6`. +// +// See https://core.telegram.org/constructor/inputStorePaymentPremiumGiveaway for reference. +type InputStorePaymentPremiumGiveaway struct { + // Flags field of InputStorePaymentPremiumGiveaway. + Flags bin.Fields + // OnlyNewSubscribers field of InputStorePaymentPremiumGiveaway. + OnlyNewSubscribers bool + // BoostPeer field of InputStorePaymentPremiumGiveaway. + BoostPeer InputPeerClass + // AdditionalPeers field of InputStorePaymentPremiumGiveaway. + // + // Use SetAdditionalPeers and GetAdditionalPeers helpers. + AdditionalPeers []InputPeerClass + // CountriesISO2 field of InputStorePaymentPremiumGiveaway. + // + // Use SetCountriesISO2 and GetCountriesISO2 helpers. + CountriesISO2 []string + // RandomID field of InputStorePaymentPremiumGiveaway. + RandomID int64 + // UntilDate field of InputStorePaymentPremiumGiveaway. + UntilDate int + // Currency field of InputStorePaymentPremiumGiveaway. + Currency string + // Amount field of InputStorePaymentPremiumGiveaway. + Amount int64 +} + +// InputStorePaymentPremiumGiveawayTypeID is TL type id of InputStorePaymentPremiumGiveaway. +const InputStorePaymentPremiumGiveawayTypeID = 0x7c9375e6 + +// construct implements constructor of InputStorePaymentPurposeClass. +func (i InputStorePaymentPremiumGiveaway) construct() InputStorePaymentPurposeClass { return &i } + +// Ensuring interfaces in compile-time for InputStorePaymentPremiumGiveaway. +var ( + _ bin.Encoder = &InputStorePaymentPremiumGiveaway{} + _ bin.Decoder = &InputStorePaymentPremiumGiveaway{} + _ bin.BareEncoder = &InputStorePaymentPremiumGiveaway{} + _ bin.BareDecoder = &InputStorePaymentPremiumGiveaway{} + + _ InputStorePaymentPurposeClass = &InputStorePaymentPremiumGiveaway{} +) + +func (i *InputStorePaymentPremiumGiveaway) Zero() bool { + if i == nil { + return true + } + if !(i.Flags.Zero()) { + return false + } + if !(i.OnlyNewSubscribers == false) { + return false + } + if !(i.BoostPeer == nil) { + return false + } + if !(i.AdditionalPeers == nil) { + return false + } + if !(i.CountriesISO2 == nil) { + return false + } + if !(i.RandomID == 0) { + return false + } + if !(i.UntilDate == 0) { + return false + } + if !(i.Currency == "") { + return false + } + if !(i.Amount == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputStorePaymentPremiumGiveaway) String() string { + if i == nil { + return "InputStorePaymentPremiumGiveaway(nil)" + } + type Alias InputStorePaymentPremiumGiveaway + return fmt.Sprintf("InputStorePaymentPremiumGiveaway%+v", Alias(*i)) +} + +// FillFrom fills InputStorePaymentPremiumGiveaway from given interface. +func (i *InputStorePaymentPremiumGiveaway) FillFrom(from interface { + GetOnlyNewSubscribers() (value bool) + GetBoostPeer() (value InputPeerClass) + GetAdditionalPeers() (value []InputPeerClass, ok bool) + GetCountriesISO2() (value []string, ok bool) + GetRandomID() (value int64) + GetUntilDate() (value int) + GetCurrency() (value string) + GetAmount() (value int64) +}) { + i.OnlyNewSubscribers = from.GetOnlyNewSubscribers() + i.BoostPeer = from.GetBoostPeer() + if val, ok := from.GetAdditionalPeers(); ok { + i.AdditionalPeers = val + } + + if val, ok := from.GetCountriesISO2(); ok { + i.CountriesISO2 = val + } + + i.RandomID = from.GetRandomID() + i.UntilDate = from.GetUntilDate() + i.Currency = from.GetCurrency() + i.Amount = from.GetAmount() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputStorePaymentPremiumGiveaway) TypeID() uint32 { + return InputStorePaymentPremiumGiveawayTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputStorePaymentPremiumGiveaway) TypeName() string { + return "inputStorePaymentPremiumGiveaway" +} + +// TypeInfo returns info about TL type. +func (i *InputStorePaymentPremiumGiveaway) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputStorePaymentPremiumGiveaway", + ID: InputStorePaymentPremiumGiveawayTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "OnlyNewSubscribers", + SchemaName: "only_new_subscribers", + Null: !i.Flags.Has(0), + }, + { + Name: "BoostPeer", + SchemaName: "boost_peer", + }, + { + Name: "AdditionalPeers", + SchemaName: "additional_peers", + Null: !i.Flags.Has(1), + }, + { + Name: "CountriesISO2", + SchemaName: "countries_iso2", + Null: !i.Flags.Has(2), + }, + { + Name: "RandomID", + SchemaName: "random_id", + }, + { + Name: "UntilDate", + SchemaName: "until_date", + }, + { + Name: "Currency", + SchemaName: "currency", + }, + { + Name: "Amount", + SchemaName: "amount", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (i *InputStorePaymentPremiumGiveaway) SetFlags() { + if !(i.OnlyNewSubscribers == false) { + i.Flags.Set(0) + } + if !(i.AdditionalPeers == nil) { + i.Flags.Set(1) + } + if !(i.CountriesISO2 == nil) { + i.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (i *InputStorePaymentPremiumGiveaway) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStorePaymentPremiumGiveaway#7c9375e6 as nil") + } + b.PutID(InputStorePaymentPremiumGiveawayTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputStorePaymentPremiumGiveaway) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStorePaymentPremiumGiveaway#7c9375e6 as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputStorePaymentPremiumGiveaway#7c9375e6: field flags: %w", err) + } + if i.BoostPeer == nil { + return fmt.Errorf("unable to encode inputStorePaymentPremiumGiveaway#7c9375e6: field boost_peer is nil") + } + if err := i.BoostPeer.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputStorePaymentPremiumGiveaway#7c9375e6: field boost_peer: %w", err) + } + if i.Flags.Has(1) { + b.PutVectorHeader(len(i.AdditionalPeers)) + for idx, v := range i.AdditionalPeers { + if v == nil { + return fmt.Errorf("unable to encode inputStorePaymentPremiumGiveaway#7c9375e6: field additional_peers element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputStorePaymentPremiumGiveaway#7c9375e6: field additional_peers element with index %d: %w", idx, err) + } + } + } + if i.Flags.Has(2) { + b.PutVectorHeader(len(i.CountriesISO2)) + for _, v := range i.CountriesISO2 { + b.PutString(v) + } + } + b.PutLong(i.RandomID) + b.PutInt(i.UntilDate) + b.PutString(i.Currency) + b.PutLong(i.Amount) + return nil +} + +// Decode implements bin.Decoder. +func (i *InputStorePaymentPremiumGiveaway) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStorePaymentPremiumGiveaway#7c9375e6 to nil") + } + if err := b.ConsumeID(InputStorePaymentPremiumGiveawayTypeID); err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#7c9375e6: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputStorePaymentPremiumGiveaway) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStorePaymentPremiumGiveaway#7c9375e6 to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#7c9375e6: field flags: %w", err) + } + } + i.OnlyNewSubscribers = i.Flags.Has(0) + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#7c9375e6: field boost_peer: %w", err) + } + i.BoostPeer = value + } + if i.Flags.Has(1) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#7c9375e6: field additional_peers: %w", err) + } + + if headerLen > 0 { + i.AdditionalPeers = make([]InputPeerClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#7c9375e6: field additional_peers: %w", err) + } + i.AdditionalPeers = append(i.AdditionalPeers, value) + } + } + if i.Flags.Has(2) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#7c9375e6: field countries_iso2: %w", err) + } + + if headerLen > 0 { + i.CountriesISO2 = 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 inputStorePaymentPremiumGiveaway#7c9375e6: field countries_iso2: %w", err) + } + i.CountriesISO2 = append(i.CountriesISO2, value) + } + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#7c9375e6: field random_id: %w", err) + } + i.RandomID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#7c9375e6: field until_date: %w", err) + } + i.UntilDate = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#7c9375e6: field currency: %w", err) + } + i.Currency = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#7c9375e6: field amount: %w", err) + } + i.Amount = value + } + return nil +} + +// SetOnlyNewSubscribers sets value of OnlyNewSubscribers conditional field. +func (i *InputStorePaymentPremiumGiveaway) SetOnlyNewSubscribers(value bool) { + if value { + i.Flags.Set(0) + i.OnlyNewSubscribers = true + } else { + i.Flags.Unset(0) + i.OnlyNewSubscribers = false + } +} + +// GetOnlyNewSubscribers returns value of OnlyNewSubscribers conditional field. +func (i *InputStorePaymentPremiumGiveaway) GetOnlyNewSubscribers() (value bool) { + if i == nil { + return + } + return i.Flags.Has(0) +} + +// GetBoostPeer returns value of BoostPeer field. +func (i *InputStorePaymentPremiumGiveaway) GetBoostPeer() (value InputPeerClass) { + if i == nil { + return + } + return i.BoostPeer +} + +// SetAdditionalPeers sets value of AdditionalPeers conditional field. +func (i *InputStorePaymentPremiumGiveaway) SetAdditionalPeers(value []InputPeerClass) { + i.Flags.Set(1) + i.AdditionalPeers = value +} + +// GetAdditionalPeers returns value of AdditionalPeers conditional field and +// boolean which is true if field was set. +func (i *InputStorePaymentPremiumGiveaway) GetAdditionalPeers() (value []InputPeerClass, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(1) { + return value, false + } + return i.AdditionalPeers, true +} + +// SetCountriesISO2 sets value of CountriesISO2 conditional field. +func (i *InputStorePaymentPremiumGiveaway) SetCountriesISO2(value []string) { + i.Flags.Set(2) + i.CountriesISO2 = value +} + +// GetCountriesISO2 returns value of CountriesISO2 conditional field and +// boolean which is true if field was set. +func (i *InputStorePaymentPremiumGiveaway) GetCountriesISO2() (value []string, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(2) { + return value, false + } + return i.CountriesISO2, true +} + +// GetRandomID returns value of RandomID field. +func (i *InputStorePaymentPremiumGiveaway) GetRandomID() (value int64) { + if i == nil { + return + } + return i.RandomID +} + +// GetUntilDate returns value of UntilDate field. +func (i *InputStorePaymentPremiumGiveaway) GetUntilDate() (value int) { + if i == nil { + return + } + return i.UntilDate +} + +// GetCurrency returns value of Currency field. +func (i *InputStorePaymentPremiumGiveaway) GetCurrency() (value string) { + if i == nil { + return + } + return i.Currency +} + +// GetAmount returns value of Amount field. +func (i *InputStorePaymentPremiumGiveaway) GetAmount() (value int64) { + if i == nil { + return + } + return i.Amount +} + +// MapAdditionalPeers returns field AdditionalPeers wrapped in InputPeerClassArray helper. +func (i *InputStorePaymentPremiumGiveaway) MapAdditionalPeers() (value InputPeerClassArray, ok bool) { + if !i.Flags.Has(1) { + return value, false + } + return InputPeerClassArray(i.AdditionalPeers), true +} + // InputStorePaymentPurposeClassName is schema name of InputStorePaymentPurposeClass. const InputStorePaymentPurposeClassName = "InputStorePaymentPurpose" @@ -450,6 +1167,8 @@ const InputStorePaymentPurposeClassName = "InputStorePaymentPurpose" // switch v := g.(type) { // case *tg.InputStorePaymentPremiumSubscription: // inputStorePaymentPremiumSubscription#a6751e66 // case *tg.InputStorePaymentGiftPremium: // inputStorePaymentGiftPremium#616f7fe8 +// case *tg.InputStorePaymentPremiumGiftCode: // inputStorePaymentPremiumGiftCode#a3805f3f +// case *tg.InputStorePaymentPremiumGiveaway: // inputStorePaymentPremiumGiveaway#7c9375e6 // default: panic(v) // } type InputStorePaymentPurposeClass interface { @@ -492,6 +1211,20 @@ func DecodeInputStorePaymentPurpose(buf *bin.Buffer) (InputStorePaymentPurposeCl return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", err) } return &v, nil + case InputStorePaymentPremiumGiftCodeTypeID: + // Decoding inputStorePaymentPremiumGiftCode#a3805f3f. + v := InputStorePaymentPremiumGiftCode{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", err) + } + return &v, nil + case InputStorePaymentPremiumGiveawayTypeID: + // Decoding inputStorePaymentPremiumGiveaway#7c9375e6. + v := InputStorePaymentPremiumGiveaway{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_input_store_payment_purpose_slices_gen.go b/tg/tl_input_store_payment_purpose_slices_gen.go index 0f7e5ea8ef..6f7feba9d2 100644 --- a/tg/tl_input_store_payment_purpose_slices_gen.go +++ b/tg/tl_input_store_payment_purpose_slices_gen.go @@ -142,6 +142,32 @@ func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentGiftPremium() (to return to } +// AsInputStorePaymentPremiumGiftCode returns copy with only InputStorePaymentPremiumGiftCode constructors. +func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentPremiumGiftCode() (to InputStorePaymentPremiumGiftCodeArray) { + for _, elem := range s { + value, ok := elem.(*InputStorePaymentPremiumGiftCode) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsInputStorePaymentPremiumGiveaway returns copy with only InputStorePaymentPremiumGiveaway constructors. +func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentPremiumGiveaway() (to InputStorePaymentPremiumGiveawayArray) { + for _, elem := range s { + value, ok := elem.(*InputStorePaymentPremiumGiveaway) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // InputStorePaymentPremiumSubscriptionArray is adapter for slice of InputStorePaymentPremiumSubscription. type InputStorePaymentPremiumSubscriptionArray []InputStorePaymentPremiumSubscription @@ -305,3 +331,167 @@ func (s *InputStorePaymentGiftPremiumArray) Pop() (v InputStorePaymentGiftPremiu return v, true } + +// InputStorePaymentPremiumGiftCodeArray is adapter for slice of InputStorePaymentPremiumGiftCode. +type InputStorePaymentPremiumGiftCodeArray []InputStorePaymentPremiumGiftCode + +// Sort sorts slice of InputStorePaymentPremiumGiftCode. +func (s InputStorePaymentPremiumGiftCodeArray) Sort(less func(a, b InputStorePaymentPremiumGiftCode) bool) InputStorePaymentPremiumGiftCodeArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InputStorePaymentPremiumGiftCode. +func (s InputStorePaymentPremiumGiftCodeArray) SortStable(less func(a, b InputStorePaymentPremiumGiftCode) bool) InputStorePaymentPremiumGiftCodeArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InputStorePaymentPremiumGiftCode. +func (s InputStorePaymentPremiumGiftCodeArray) Retain(keep func(x InputStorePaymentPremiumGiftCode) bool) InputStorePaymentPremiumGiftCodeArray { + 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 InputStorePaymentPremiumGiftCodeArray) First() (v InputStorePaymentPremiumGiftCode, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputStorePaymentPremiumGiftCodeArray) Last() (v InputStorePaymentPremiumGiftCode, 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 *InputStorePaymentPremiumGiftCodeArray) PopFirst() (v InputStorePaymentPremiumGiftCode, 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 InputStorePaymentPremiumGiftCode + 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 *InputStorePaymentPremiumGiftCodeArray) Pop() (v InputStorePaymentPremiumGiftCode, 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 +} + +// InputStorePaymentPremiumGiveawayArray is adapter for slice of InputStorePaymentPremiumGiveaway. +type InputStorePaymentPremiumGiveawayArray []InputStorePaymentPremiumGiveaway + +// Sort sorts slice of InputStorePaymentPremiumGiveaway. +func (s InputStorePaymentPremiumGiveawayArray) Sort(less func(a, b InputStorePaymentPremiumGiveaway) bool) InputStorePaymentPremiumGiveawayArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InputStorePaymentPremiumGiveaway. +func (s InputStorePaymentPremiumGiveawayArray) SortStable(less func(a, b InputStorePaymentPremiumGiveaway) bool) InputStorePaymentPremiumGiveawayArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InputStorePaymentPremiumGiveaway. +func (s InputStorePaymentPremiumGiveawayArray) Retain(keep func(x InputStorePaymentPremiumGiveaway) bool) InputStorePaymentPremiumGiveawayArray { + 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 InputStorePaymentPremiumGiveawayArray) First() (v InputStorePaymentPremiumGiveaway, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputStorePaymentPremiumGiveawayArray) Last() (v InputStorePaymentPremiumGiveaway, 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 *InputStorePaymentPremiumGiveawayArray) PopFirst() (v InputStorePaymentPremiumGiveaway, 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 InputStorePaymentPremiumGiveaway + 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 *InputStorePaymentPremiumGiveawayArray) Pop() (v InputStorePaymentPremiumGiveaway, 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_message_action_gen.go b/tg/tl_message_action_gen.go index 49422af075..b05b6e3977 100644 --- a/tg/tl_message_action_gen.go +++ b/tg/tl_message_action_gen.go @@ -6917,6 +6917,409 @@ func (m *MessageActionSetSameChatWallPaper) GetWallpaper() (value WallPaperClass return m.Wallpaper } +// MessageActionGiftCode represents TL type `messageActionGiftCode#d2cfdb0e`. +// +// See https://core.telegram.org/constructor/messageActionGiftCode for reference. +type MessageActionGiftCode struct { + // Flags field of MessageActionGiftCode. + Flags bin.Fields + // ViaGiveaway field of MessageActionGiftCode. + ViaGiveaway bool + // Unclaimed field of MessageActionGiftCode. + Unclaimed bool + // BoostPeer field of MessageActionGiftCode. + // + // Use SetBoostPeer and GetBoostPeer helpers. + BoostPeer PeerClass + // Months field of MessageActionGiftCode. + Months int + // Slug field of MessageActionGiftCode. + Slug string +} + +// MessageActionGiftCodeTypeID is TL type id of MessageActionGiftCode. +const MessageActionGiftCodeTypeID = 0xd2cfdb0e + +// construct implements constructor of MessageActionClass. +func (m MessageActionGiftCode) construct() MessageActionClass { return &m } + +// Ensuring interfaces in compile-time for MessageActionGiftCode. +var ( + _ bin.Encoder = &MessageActionGiftCode{} + _ bin.Decoder = &MessageActionGiftCode{} + _ bin.BareEncoder = &MessageActionGiftCode{} + _ bin.BareDecoder = &MessageActionGiftCode{} + + _ MessageActionClass = &MessageActionGiftCode{} +) + +func (m *MessageActionGiftCode) Zero() bool { + if m == nil { + return true + } + if !(m.Flags.Zero()) { + return false + } + if !(m.ViaGiveaway == false) { + return false + } + if !(m.Unclaimed == false) { + return false + } + if !(m.BoostPeer == nil) { + return false + } + if !(m.Months == 0) { + return false + } + if !(m.Slug == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageActionGiftCode) String() string { + if m == nil { + return "MessageActionGiftCode(nil)" + } + type Alias MessageActionGiftCode + return fmt.Sprintf("MessageActionGiftCode%+v", Alias(*m)) +} + +// FillFrom fills MessageActionGiftCode from given interface. +func (m *MessageActionGiftCode) FillFrom(from interface { + GetViaGiveaway() (value bool) + GetUnclaimed() (value bool) + GetBoostPeer() (value PeerClass, ok bool) + GetMonths() (value int) + GetSlug() (value string) +}) { + m.ViaGiveaway = from.GetViaGiveaway() + m.Unclaimed = from.GetUnclaimed() + if val, ok := from.GetBoostPeer(); ok { + m.BoostPeer = val + } + + m.Months = from.GetMonths() + m.Slug = from.GetSlug() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageActionGiftCode) TypeID() uint32 { + return MessageActionGiftCodeTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageActionGiftCode) TypeName() string { + return "messageActionGiftCode" +} + +// TypeInfo returns info about TL type. +func (m *MessageActionGiftCode) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageActionGiftCode", + ID: MessageActionGiftCodeTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ViaGiveaway", + SchemaName: "via_giveaway", + Null: !m.Flags.Has(0), + }, + { + Name: "Unclaimed", + SchemaName: "unclaimed", + Null: !m.Flags.Has(2), + }, + { + Name: "BoostPeer", + SchemaName: "boost_peer", + Null: !m.Flags.Has(1), + }, + { + Name: "Months", + SchemaName: "months", + }, + { + Name: "Slug", + SchemaName: "slug", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (m *MessageActionGiftCode) SetFlags() { + if !(m.ViaGiveaway == false) { + m.Flags.Set(0) + } + if !(m.Unclaimed == false) { + m.Flags.Set(2) + } + if !(m.BoostPeer == nil) { + m.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (m *MessageActionGiftCode) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionGiftCode#d2cfdb0e as nil") + } + b.PutID(MessageActionGiftCodeTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageActionGiftCode) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionGiftCode#d2cfdb0e as nil") + } + m.SetFlags() + if err := m.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionGiftCode#d2cfdb0e: field flags: %w", err) + } + if m.Flags.Has(1) { + if m.BoostPeer == nil { + return fmt.Errorf("unable to encode messageActionGiftCode#d2cfdb0e: field boost_peer is nil") + } + if err := m.BoostPeer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionGiftCode#d2cfdb0e: field boost_peer: %w", err) + } + } + b.PutInt(m.Months) + b.PutString(m.Slug) + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageActionGiftCode) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionGiftCode#d2cfdb0e to nil") + } + if err := b.ConsumeID(MessageActionGiftCodeTypeID); err != nil { + return fmt.Errorf("unable to decode messageActionGiftCode#d2cfdb0e: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageActionGiftCode) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionGiftCode#d2cfdb0e to nil") + } + { + if err := m.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageActionGiftCode#d2cfdb0e: field flags: %w", err) + } + } + m.ViaGiveaway = m.Flags.Has(0) + m.Unclaimed = m.Flags.Has(2) + if m.Flags.Has(1) { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode messageActionGiftCode#d2cfdb0e: field boost_peer: %w", err) + } + m.BoostPeer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messageActionGiftCode#d2cfdb0e: field months: %w", err) + } + m.Months = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageActionGiftCode#d2cfdb0e: field slug: %w", err) + } + m.Slug = value + } + return nil +} + +// SetViaGiveaway sets value of ViaGiveaway conditional field. +func (m *MessageActionGiftCode) SetViaGiveaway(value bool) { + if value { + m.Flags.Set(0) + m.ViaGiveaway = true + } else { + m.Flags.Unset(0) + m.ViaGiveaway = false + } +} + +// GetViaGiveaway returns value of ViaGiveaway conditional field. +func (m *MessageActionGiftCode) GetViaGiveaway() (value bool) { + if m == nil { + return + } + return m.Flags.Has(0) +} + +// SetUnclaimed sets value of Unclaimed conditional field. +func (m *MessageActionGiftCode) SetUnclaimed(value bool) { + if value { + m.Flags.Set(2) + m.Unclaimed = true + } else { + m.Flags.Unset(2) + m.Unclaimed = false + } +} + +// GetUnclaimed returns value of Unclaimed conditional field. +func (m *MessageActionGiftCode) GetUnclaimed() (value bool) { + if m == nil { + return + } + return m.Flags.Has(2) +} + +// SetBoostPeer sets value of BoostPeer conditional field. +func (m *MessageActionGiftCode) SetBoostPeer(value PeerClass) { + m.Flags.Set(1) + m.BoostPeer = value +} + +// GetBoostPeer returns value of BoostPeer conditional field and +// boolean which is true if field was set. +func (m *MessageActionGiftCode) GetBoostPeer() (value PeerClass, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(1) { + return value, false + } + return m.BoostPeer, true +} + +// GetMonths returns value of Months field. +func (m *MessageActionGiftCode) GetMonths() (value int) { + if m == nil { + return + } + return m.Months +} + +// GetSlug returns value of Slug field. +func (m *MessageActionGiftCode) GetSlug() (value string) { + if m == nil { + return + } + return m.Slug +} + +// MessageActionGiveawayLaunch represents TL type `messageActionGiveawayLaunch#332ba9ed`. +// +// See https://core.telegram.org/constructor/messageActionGiveawayLaunch for reference. +type MessageActionGiveawayLaunch struct { +} + +// MessageActionGiveawayLaunchTypeID is TL type id of MessageActionGiveawayLaunch. +const MessageActionGiveawayLaunchTypeID = 0x332ba9ed + +// construct implements constructor of MessageActionClass. +func (m MessageActionGiveawayLaunch) construct() MessageActionClass { return &m } + +// Ensuring interfaces in compile-time for MessageActionGiveawayLaunch. +var ( + _ bin.Encoder = &MessageActionGiveawayLaunch{} + _ bin.Decoder = &MessageActionGiveawayLaunch{} + _ bin.BareEncoder = &MessageActionGiveawayLaunch{} + _ bin.BareDecoder = &MessageActionGiveawayLaunch{} + + _ MessageActionClass = &MessageActionGiveawayLaunch{} +) + +func (m *MessageActionGiveawayLaunch) Zero() bool { + if m == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageActionGiveawayLaunch) String() string { + if m == nil { + return "MessageActionGiveawayLaunch(nil)" + } + type Alias MessageActionGiveawayLaunch + return fmt.Sprintf("MessageActionGiveawayLaunch%+v", Alias(*m)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageActionGiveawayLaunch) TypeID() uint32 { + return MessageActionGiveawayLaunchTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageActionGiveawayLaunch) TypeName() string { + return "messageActionGiveawayLaunch" +} + +// TypeInfo returns info about TL type. +func (m *MessageActionGiveawayLaunch) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageActionGiveawayLaunch", + ID: MessageActionGiveawayLaunchTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (m *MessageActionGiveawayLaunch) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionGiveawayLaunch#332ba9ed as nil") + } + b.PutID(MessageActionGiveawayLaunchTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageActionGiveawayLaunch) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionGiveawayLaunch#332ba9ed as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageActionGiveawayLaunch) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionGiveawayLaunch#332ba9ed to nil") + } + if err := b.ConsumeID(MessageActionGiveawayLaunchTypeID); err != nil { + return fmt.Errorf("unable to decode messageActionGiveawayLaunch#332ba9ed: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageActionGiveawayLaunch) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionGiveawayLaunch#332ba9ed to nil") + } + return nil +} + // MessageActionClassName is schema name of MessageActionClass. const MessageActionClassName = "MessageAction" @@ -6970,6 +7373,8 @@ const MessageActionClassName = "MessageAction" // case *tg.MessageActionRequestedPeer: // messageActionRequestedPeer#fe77345d // case *tg.MessageActionSetChatWallPaper: // messageActionSetChatWallPaper#bc44a927 // case *tg.MessageActionSetSameChatWallPaper: // messageActionSetSameChatWallPaper#c0787d6d +// case *tg.MessageActionGiftCode: // messageActionGiftCode#d2cfdb0e +// case *tg.MessageActionGiveawayLaunch: // messageActionGiveawayLaunch#332ba9ed // default: panic(v) // } type MessageActionClass interface { @@ -7271,6 +7676,20 @@ func DecodeMessageAction(buf *bin.Buffer) (MessageActionClass, error) { return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) } return &v, nil + case MessageActionGiftCodeTypeID: + // Decoding messageActionGiftCode#d2cfdb0e. + v := MessageActionGiftCode{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) + } + return &v, nil + case MessageActionGiveawayLaunchTypeID: + // Decoding messageActionGiveawayLaunch#332ba9ed. + v := MessageActionGiveawayLaunch{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode MessageActionClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_message_action_slices_gen.go b/tg/tl_message_action_slices_gen.go index 56c83feb02..061198950a 100644 --- a/tg/tl_message_action_slices_gen.go +++ b/tg/tl_message_action_slices_gen.go @@ -532,6 +532,19 @@ func (s MessageActionClassArray) AsMessageActionSetSameChatWallPaper() (to Messa return to } +// AsMessageActionGiftCode returns copy with only MessageActionGiftCode constructors. +func (s MessageActionClassArray) AsMessageActionGiftCode() (to MessageActionGiftCodeArray) { + for _, elem := range s { + value, ok := elem.(*MessageActionGiftCode) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // MessageActionChatCreateArray is adapter for slice of MessageActionChatCreate. type MessageActionChatCreateArray []MessageActionChatCreate @@ -3155,3 +3168,85 @@ func (s *MessageActionSetSameChatWallPaperArray) Pop() (v MessageActionSetSameCh return v, true } + +// MessageActionGiftCodeArray is adapter for slice of MessageActionGiftCode. +type MessageActionGiftCodeArray []MessageActionGiftCode + +// Sort sorts slice of MessageActionGiftCode. +func (s MessageActionGiftCodeArray) Sort(less func(a, b MessageActionGiftCode) bool) MessageActionGiftCodeArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessageActionGiftCode. +func (s MessageActionGiftCodeArray) SortStable(less func(a, b MessageActionGiftCode) bool) MessageActionGiftCodeArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessageActionGiftCode. +func (s MessageActionGiftCodeArray) Retain(keep func(x MessageActionGiftCode) bool) MessageActionGiftCodeArray { + 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 MessageActionGiftCodeArray) First() (v MessageActionGiftCode, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessageActionGiftCodeArray) Last() (v MessageActionGiftCode, 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 *MessageActionGiftCodeArray) PopFirst() (v MessageActionGiftCode, 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 MessageActionGiftCode + 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 *MessageActionGiftCodeArray) Pop() (v MessageActionGiftCode, 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_message_entity_gen.go b/tg/tl_message_entity_gen.go index b99cdcbf56..fc32a77f81 100644 --- a/tg/tl_message_entity_gen.go +++ b/tg/tl_message_entity_gen.go @@ -3035,174 +3035,6 @@ func (m *MessageEntityStrike) GetLength() (value int) { return m.Length } -// MessageEntityBlockquote represents TL type `messageEntityBlockquote#20df5d0`. -// Message entity representing a block quote. -// -// See https://core.telegram.org/constructor/messageEntityBlockquote for reference. -type MessageEntityBlockquote struct { - // Offset of message entity within message (in UTF-16 code units¹) - // - // Links: - // 1) https://core.telegram.org/api/entities#entity-length - Offset int - // Length of message entity within message (in UTF-16 code units¹) - // - // Links: - // 1) https://core.telegram.org/api/entities#entity-length - Length int -} - -// MessageEntityBlockquoteTypeID is TL type id of MessageEntityBlockquote. -const MessageEntityBlockquoteTypeID = 0x20df5d0 - -// construct implements constructor of MessageEntityClass. -func (m MessageEntityBlockquote) construct() MessageEntityClass { return &m } - -// Ensuring interfaces in compile-time for MessageEntityBlockquote. -var ( - _ bin.Encoder = &MessageEntityBlockquote{} - _ bin.Decoder = &MessageEntityBlockquote{} - _ bin.BareEncoder = &MessageEntityBlockquote{} - _ bin.BareDecoder = &MessageEntityBlockquote{} - - _ MessageEntityClass = &MessageEntityBlockquote{} -) - -func (m *MessageEntityBlockquote) Zero() bool { - if m == nil { - return true - } - if !(m.Offset == 0) { - return false - } - if !(m.Length == 0) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (m *MessageEntityBlockquote) String() string { - if m == nil { - return "MessageEntityBlockquote(nil)" - } - type Alias MessageEntityBlockquote - return fmt.Sprintf("MessageEntityBlockquote%+v", Alias(*m)) -} - -// FillFrom fills MessageEntityBlockquote from given interface. -func (m *MessageEntityBlockquote) FillFrom(from interface { - GetOffset() (value int) - GetLength() (value int) -}) { - m.Offset = from.GetOffset() - m.Length = from.GetLength() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*MessageEntityBlockquote) TypeID() uint32 { - return MessageEntityBlockquoteTypeID -} - -// TypeName returns name of type in TL schema. -func (*MessageEntityBlockquote) TypeName() string { - return "messageEntityBlockquote" -} - -// TypeInfo returns info about TL type. -func (m *MessageEntityBlockquote) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "messageEntityBlockquote", - ID: MessageEntityBlockquoteTypeID, - } - if m == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Offset", - SchemaName: "offset", - }, - { - Name: "Length", - SchemaName: "length", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (m *MessageEntityBlockquote) Encode(b *bin.Buffer) error { - if m == nil { - return fmt.Errorf("can't encode messageEntityBlockquote#20df5d0 as nil") - } - b.PutID(MessageEntityBlockquoteTypeID) - return m.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (m *MessageEntityBlockquote) EncodeBare(b *bin.Buffer) error { - if m == nil { - return fmt.Errorf("can't encode messageEntityBlockquote#20df5d0 as nil") - } - b.PutInt(m.Offset) - b.PutInt(m.Length) - return nil -} - -// Decode implements bin.Decoder. -func (m *MessageEntityBlockquote) Decode(b *bin.Buffer) error { - if m == nil { - return fmt.Errorf("can't decode messageEntityBlockquote#20df5d0 to nil") - } - if err := b.ConsumeID(MessageEntityBlockquoteTypeID); err != nil { - return fmt.Errorf("unable to decode messageEntityBlockquote#20df5d0: %w", err) - } - return m.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (m *MessageEntityBlockquote) DecodeBare(b *bin.Buffer) error { - if m == nil { - return fmt.Errorf("can't decode messageEntityBlockquote#20df5d0 to nil") - } - { - value, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode messageEntityBlockquote#20df5d0: field offset: %w", err) - } - m.Offset = value - } - { - value, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode messageEntityBlockquote#20df5d0: field length: %w", err) - } - m.Length = value - } - return nil -} - -// GetOffset returns value of Offset field. -func (m *MessageEntityBlockquote) GetOffset() (value int) { - if m == nil { - return - } - return m.Offset -} - -// GetLength returns value of Length field. -func (m *MessageEntityBlockquote) GetLength() (value int) { - if m == nil { - return - } - return m.Length -} - // MessageEntityBankCard represents TL type `messageEntityBankCard#761e6af4`. // Indicates a credit card number // @@ -3745,6 +3577,174 @@ func (m *MessageEntityCustomEmoji) GetDocumentID() (value int64) { return m.DocumentID } +// MessageEntityBlockquote represents TL type `messageEntityBlockquote#20df5d0`. +// Message entity representing a block quote. +// +// See https://core.telegram.org/constructor/messageEntityBlockquote for reference. +type MessageEntityBlockquote struct { + // Offset of message entity within message (in UTF-16 code units¹) + // + // Links: + // 1) https://core.telegram.org/api/entities#entity-length + Offset int + // Length of message entity within message (in UTF-16 code units¹) + // + // Links: + // 1) https://core.telegram.org/api/entities#entity-length + Length int +} + +// MessageEntityBlockquoteTypeID is TL type id of MessageEntityBlockquote. +const MessageEntityBlockquoteTypeID = 0x20df5d0 + +// construct implements constructor of MessageEntityClass. +func (m MessageEntityBlockquote) construct() MessageEntityClass { return &m } + +// Ensuring interfaces in compile-time for MessageEntityBlockquote. +var ( + _ bin.Encoder = &MessageEntityBlockquote{} + _ bin.Decoder = &MessageEntityBlockquote{} + _ bin.BareEncoder = &MessageEntityBlockquote{} + _ bin.BareDecoder = &MessageEntityBlockquote{} + + _ MessageEntityClass = &MessageEntityBlockquote{} +) + +func (m *MessageEntityBlockquote) Zero() bool { + if m == nil { + return true + } + if !(m.Offset == 0) { + return false + } + if !(m.Length == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageEntityBlockquote) String() string { + if m == nil { + return "MessageEntityBlockquote(nil)" + } + type Alias MessageEntityBlockquote + return fmt.Sprintf("MessageEntityBlockquote%+v", Alias(*m)) +} + +// FillFrom fills MessageEntityBlockquote from given interface. +func (m *MessageEntityBlockquote) FillFrom(from interface { + GetOffset() (value int) + GetLength() (value int) +}) { + m.Offset = from.GetOffset() + m.Length = from.GetLength() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageEntityBlockquote) TypeID() uint32 { + return MessageEntityBlockquoteTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageEntityBlockquote) TypeName() string { + return "messageEntityBlockquote" +} + +// TypeInfo returns info about TL type. +func (m *MessageEntityBlockquote) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageEntityBlockquote", + ID: MessageEntityBlockquoteTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Offset", + SchemaName: "offset", + }, + { + Name: "Length", + SchemaName: "length", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (m *MessageEntityBlockquote) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageEntityBlockquote#20df5d0 as nil") + } + b.PutID(MessageEntityBlockquoteTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageEntityBlockquote) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageEntityBlockquote#20df5d0 as nil") + } + b.PutInt(m.Offset) + b.PutInt(m.Length) + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageEntityBlockquote) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageEntityBlockquote#20df5d0 to nil") + } + if err := b.ConsumeID(MessageEntityBlockquoteTypeID); err != nil { + return fmt.Errorf("unable to decode messageEntityBlockquote#20df5d0: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageEntityBlockquote) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageEntityBlockquote#20df5d0 to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messageEntityBlockquote#20df5d0: field offset: %w", err) + } + m.Offset = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messageEntityBlockquote#20df5d0: field length: %w", err) + } + m.Length = value + } + return nil +} + +// GetOffset returns value of Offset field. +func (m *MessageEntityBlockquote) GetOffset() (value int) { + if m == nil { + return + } + return m.Offset +} + +// GetLength returns value of Length field. +func (m *MessageEntityBlockquote) GetLength() (value int) { + if m == nil { + return + } + return m.Length +} + // MessageEntityClassName is schema name of MessageEntityClass. const MessageEntityClassName = "MessageEntity" @@ -3776,10 +3776,10 @@ const MessageEntityClassName = "MessageEntity" // case *tg.MessageEntityCashtag: // messageEntityCashtag#4c4e743f // case *tg.MessageEntityUnderline: // messageEntityUnderline#9c4e7e8b // case *tg.MessageEntityStrike: // messageEntityStrike#bf0693d4 -// case *tg.MessageEntityBlockquote: // messageEntityBlockquote#20df5d0 // case *tg.MessageEntityBankCard: // messageEntityBankCard#761e6af4 // case *tg.MessageEntitySpoiler: // messageEntitySpoiler#32ca960f // case *tg.MessageEntityCustomEmoji: // messageEntityCustomEmoji#c8cf05f8 +// case *tg.MessageEntityBlockquote: // messageEntityBlockquote#20df5d0 // default: panic(v) // } type MessageEntityClass interface { @@ -3939,13 +3939,6 @@ func DecodeMessageEntity(buf *bin.Buffer) (MessageEntityClass, error) { return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err) } return &v, nil - case MessageEntityBlockquoteTypeID: - // Decoding messageEntityBlockquote#20df5d0. - v := MessageEntityBlockquote{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err) - } - return &v, nil case MessageEntityBankCardTypeID: // Decoding messageEntityBankCard#761e6af4. v := MessageEntityBankCard{} @@ -3967,6 +3960,13 @@ func DecodeMessageEntity(buf *bin.Buffer) (MessageEntityClass, error) { return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err) } return &v, nil + case MessageEntityBlockquoteTypeID: + // Decoding messageEntityBlockquote#20df5d0. + v := MessageEntityBlockquote{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_message_entity_slices_gen.go b/tg/tl_message_entity_slices_gen.go index fc724cb474..e08d3d7e2a 100644 --- a/tg/tl_message_entity_slices_gen.go +++ b/tg/tl_message_entity_slices_gen.go @@ -337,10 +337,10 @@ func (s MessageEntityClassArray) AsMessageEntityStrike() (to MessageEntityStrike return to } -// AsMessageEntityBlockquote returns copy with only MessageEntityBlockquote constructors. -func (s MessageEntityClassArray) AsMessageEntityBlockquote() (to MessageEntityBlockquoteArray) { +// AsMessageEntityBankCard returns copy with only MessageEntityBankCard constructors. +func (s MessageEntityClassArray) AsMessageEntityBankCard() (to MessageEntityBankCardArray) { for _, elem := range s { - value, ok := elem.(*MessageEntityBlockquote) + value, ok := elem.(*MessageEntityBankCard) if !ok { continue } @@ -350,10 +350,10 @@ func (s MessageEntityClassArray) AsMessageEntityBlockquote() (to MessageEntityBl return to } -// AsMessageEntityBankCard returns copy with only MessageEntityBankCard constructors. -func (s MessageEntityClassArray) AsMessageEntityBankCard() (to MessageEntityBankCardArray) { +// AsMessageEntitySpoiler returns copy with only MessageEntitySpoiler constructors. +func (s MessageEntityClassArray) AsMessageEntitySpoiler() (to MessageEntitySpoilerArray) { for _, elem := range s { - value, ok := elem.(*MessageEntityBankCard) + value, ok := elem.(*MessageEntitySpoiler) if !ok { continue } @@ -363,10 +363,10 @@ func (s MessageEntityClassArray) AsMessageEntityBankCard() (to MessageEntityBank return to } -// AsMessageEntitySpoiler returns copy with only MessageEntitySpoiler constructors. -func (s MessageEntityClassArray) AsMessageEntitySpoiler() (to MessageEntitySpoilerArray) { +// AsMessageEntityCustomEmoji returns copy with only MessageEntityCustomEmoji constructors. +func (s MessageEntityClassArray) AsMessageEntityCustomEmoji() (to MessageEntityCustomEmojiArray) { for _, elem := range s { - value, ok := elem.(*MessageEntitySpoiler) + value, ok := elem.(*MessageEntityCustomEmoji) if !ok { continue } @@ -376,10 +376,10 @@ func (s MessageEntityClassArray) AsMessageEntitySpoiler() (to MessageEntitySpoil return to } -// AsMessageEntityCustomEmoji returns copy with only MessageEntityCustomEmoji constructors. -func (s MessageEntityClassArray) AsMessageEntityCustomEmoji() (to MessageEntityCustomEmojiArray) { +// AsMessageEntityBlockquote returns copy with only MessageEntityBlockquote constructors. +func (s MessageEntityClassArray) AsMessageEntityBlockquote() (to MessageEntityBlockquoteArray) { for _, elem := range s { - value, ok := elem.(*MessageEntityCustomEmoji) + value, ok := elem.(*MessageEntityBlockquote) if !ok { continue } @@ -1783,27 +1783,27 @@ func (s *MessageEntityStrikeArray) Pop() (v MessageEntityStrike, ok bool) { return v, true } -// MessageEntityBlockquoteArray is adapter for slice of MessageEntityBlockquote. -type MessageEntityBlockquoteArray []MessageEntityBlockquote +// MessageEntityBankCardArray is adapter for slice of MessageEntityBankCard. +type MessageEntityBankCardArray []MessageEntityBankCard -// Sort sorts slice of MessageEntityBlockquote. -func (s MessageEntityBlockquoteArray) Sort(less func(a, b MessageEntityBlockquote) bool) MessageEntityBlockquoteArray { +// Sort sorts slice of MessageEntityBankCard. +func (s MessageEntityBankCardArray) Sort(less func(a, b MessageEntityBankCard) bool) MessageEntityBankCardArray { sort.Slice(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } -// SortStable sorts slice of MessageEntityBlockquote. -func (s MessageEntityBlockquoteArray) SortStable(less func(a, b MessageEntityBlockquote) bool) MessageEntityBlockquoteArray { +// SortStable sorts slice of MessageEntityBankCard. +func (s MessageEntityBankCardArray) SortStable(less func(a, b MessageEntityBankCard) bool) MessageEntityBankCardArray { sort.SliceStable(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } -// Retain filters in-place slice of MessageEntityBlockquote. -func (s MessageEntityBlockquoteArray) Retain(keep func(x MessageEntityBlockquote) bool) MessageEntityBlockquoteArray { +// Retain filters in-place slice of MessageEntityBankCard. +func (s MessageEntityBankCardArray) Retain(keep func(x MessageEntityBankCard) bool) MessageEntityBankCardArray { n := 0 for _, x := range s { if keep(x) { @@ -1817,7 +1817,7 @@ func (s MessageEntityBlockquoteArray) Retain(keep func(x MessageEntityBlockquote } // First returns first element of slice (if exists). -func (s MessageEntityBlockquoteArray) First() (v MessageEntityBlockquote, ok bool) { +func (s MessageEntityBankCardArray) First() (v MessageEntityBankCard, ok bool) { if len(s) < 1 { return } @@ -1825,7 +1825,7 @@ func (s MessageEntityBlockquoteArray) First() (v MessageEntityBlockquote, ok boo } // Last returns last element of slice (if exists). -func (s MessageEntityBlockquoteArray) Last() (v MessageEntityBlockquote, ok bool) { +func (s MessageEntityBankCardArray) Last() (v MessageEntityBankCard, ok bool) { if len(s) < 1 { return } @@ -1833,7 +1833,7 @@ func (s MessageEntityBlockquoteArray) Last() (v MessageEntityBlockquote, ok bool } // PopFirst returns first element of slice (if exists) and deletes it. -func (s *MessageEntityBlockquoteArray) PopFirst() (v MessageEntityBlockquote, ok bool) { +func (s *MessageEntityBankCardArray) PopFirst() (v MessageEntityBankCard, ok bool) { if s == nil || len(*s) < 1 { return } @@ -1843,7 +1843,7 @@ func (s *MessageEntityBlockquoteArray) PopFirst() (v MessageEntityBlockquote, ok // Delete by index from SliceTricks. copy(a[0:], a[1:]) - var zero MessageEntityBlockquote + var zero MessageEntityBankCard a[len(a)-1] = zero a = a[:len(a)-1] *s = a @@ -1852,7 +1852,7 @@ func (s *MessageEntityBlockquoteArray) PopFirst() (v MessageEntityBlockquote, ok } // Pop returns last element of slice (if exists) and deletes it. -func (s *MessageEntityBlockquoteArray) Pop() (v MessageEntityBlockquote, ok bool) { +func (s *MessageEntityBankCardArray) Pop() (v MessageEntityBankCard, ok bool) { if s == nil || len(*s) < 1 { return } @@ -1865,27 +1865,27 @@ func (s *MessageEntityBlockquoteArray) Pop() (v MessageEntityBlockquote, ok bool return v, true } -// MessageEntityBankCardArray is adapter for slice of MessageEntityBankCard. -type MessageEntityBankCardArray []MessageEntityBankCard +// MessageEntitySpoilerArray is adapter for slice of MessageEntitySpoiler. +type MessageEntitySpoilerArray []MessageEntitySpoiler -// Sort sorts slice of MessageEntityBankCard. -func (s MessageEntityBankCardArray) Sort(less func(a, b MessageEntityBankCard) bool) MessageEntityBankCardArray { +// Sort sorts slice of MessageEntitySpoiler. +func (s MessageEntitySpoilerArray) Sort(less func(a, b MessageEntitySpoiler) bool) MessageEntitySpoilerArray { sort.Slice(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } -// SortStable sorts slice of MessageEntityBankCard. -func (s MessageEntityBankCardArray) SortStable(less func(a, b MessageEntityBankCard) bool) MessageEntityBankCardArray { +// SortStable sorts slice of MessageEntitySpoiler. +func (s MessageEntitySpoilerArray) SortStable(less func(a, b MessageEntitySpoiler) bool) MessageEntitySpoilerArray { sort.SliceStable(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } -// Retain filters in-place slice of MessageEntityBankCard. -func (s MessageEntityBankCardArray) Retain(keep func(x MessageEntityBankCard) bool) MessageEntityBankCardArray { +// Retain filters in-place slice of MessageEntitySpoiler. +func (s MessageEntitySpoilerArray) Retain(keep func(x MessageEntitySpoiler) bool) MessageEntitySpoilerArray { n := 0 for _, x := range s { if keep(x) { @@ -1899,7 +1899,7 @@ func (s MessageEntityBankCardArray) Retain(keep func(x MessageEntityBankCard) bo } // First returns first element of slice (if exists). -func (s MessageEntityBankCardArray) First() (v MessageEntityBankCard, ok bool) { +func (s MessageEntitySpoilerArray) First() (v MessageEntitySpoiler, ok bool) { if len(s) < 1 { return } @@ -1907,7 +1907,7 @@ func (s MessageEntityBankCardArray) First() (v MessageEntityBankCard, ok bool) { } // Last returns last element of slice (if exists). -func (s MessageEntityBankCardArray) Last() (v MessageEntityBankCard, ok bool) { +func (s MessageEntitySpoilerArray) Last() (v MessageEntitySpoiler, ok bool) { if len(s) < 1 { return } @@ -1915,7 +1915,7 @@ func (s MessageEntityBankCardArray) Last() (v MessageEntityBankCard, ok bool) { } // PopFirst returns first element of slice (if exists) and deletes it. -func (s *MessageEntityBankCardArray) PopFirst() (v MessageEntityBankCard, ok bool) { +func (s *MessageEntitySpoilerArray) PopFirst() (v MessageEntitySpoiler, ok bool) { if s == nil || len(*s) < 1 { return } @@ -1925,7 +1925,7 @@ func (s *MessageEntityBankCardArray) PopFirst() (v MessageEntityBankCard, ok boo // Delete by index from SliceTricks. copy(a[0:], a[1:]) - var zero MessageEntityBankCard + var zero MessageEntitySpoiler a[len(a)-1] = zero a = a[:len(a)-1] *s = a @@ -1934,7 +1934,7 @@ func (s *MessageEntityBankCardArray) PopFirst() (v MessageEntityBankCard, ok boo } // Pop returns last element of slice (if exists) and deletes it. -func (s *MessageEntityBankCardArray) Pop() (v MessageEntityBankCard, ok bool) { +func (s *MessageEntitySpoilerArray) Pop() (v MessageEntitySpoiler, ok bool) { if s == nil || len(*s) < 1 { return } @@ -1947,27 +1947,27 @@ func (s *MessageEntityBankCardArray) Pop() (v MessageEntityBankCard, ok bool) { return v, true } -// MessageEntitySpoilerArray is adapter for slice of MessageEntitySpoiler. -type MessageEntitySpoilerArray []MessageEntitySpoiler +// MessageEntityCustomEmojiArray is adapter for slice of MessageEntityCustomEmoji. +type MessageEntityCustomEmojiArray []MessageEntityCustomEmoji -// Sort sorts slice of MessageEntitySpoiler. -func (s MessageEntitySpoilerArray) Sort(less func(a, b MessageEntitySpoiler) bool) MessageEntitySpoilerArray { +// Sort sorts slice of MessageEntityCustomEmoji. +func (s MessageEntityCustomEmojiArray) Sort(less func(a, b MessageEntityCustomEmoji) bool) MessageEntityCustomEmojiArray { sort.Slice(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } -// SortStable sorts slice of MessageEntitySpoiler. -func (s MessageEntitySpoilerArray) SortStable(less func(a, b MessageEntitySpoiler) bool) MessageEntitySpoilerArray { +// SortStable sorts slice of MessageEntityCustomEmoji. +func (s MessageEntityCustomEmojiArray) SortStable(less func(a, b MessageEntityCustomEmoji) bool) MessageEntityCustomEmojiArray { sort.SliceStable(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } -// Retain filters in-place slice of MessageEntitySpoiler. -func (s MessageEntitySpoilerArray) Retain(keep func(x MessageEntitySpoiler) bool) MessageEntitySpoilerArray { +// Retain filters in-place slice of MessageEntityCustomEmoji. +func (s MessageEntityCustomEmojiArray) Retain(keep func(x MessageEntityCustomEmoji) bool) MessageEntityCustomEmojiArray { n := 0 for _, x := range s { if keep(x) { @@ -1981,7 +1981,7 @@ func (s MessageEntitySpoilerArray) Retain(keep func(x MessageEntitySpoiler) bool } // First returns first element of slice (if exists). -func (s MessageEntitySpoilerArray) First() (v MessageEntitySpoiler, ok bool) { +func (s MessageEntityCustomEmojiArray) First() (v MessageEntityCustomEmoji, ok bool) { if len(s) < 1 { return } @@ -1989,7 +1989,7 @@ func (s MessageEntitySpoilerArray) First() (v MessageEntitySpoiler, ok bool) { } // Last returns last element of slice (if exists). -func (s MessageEntitySpoilerArray) Last() (v MessageEntitySpoiler, ok bool) { +func (s MessageEntityCustomEmojiArray) Last() (v MessageEntityCustomEmoji, ok bool) { if len(s) < 1 { return } @@ -1997,7 +1997,7 @@ func (s MessageEntitySpoilerArray) Last() (v MessageEntitySpoiler, ok bool) { } // PopFirst returns first element of slice (if exists) and deletes it. -func (s *MessageEntitySpoilerArray) PopFirst() (v MessageEntitySpoiler, ok bool) { +func (s *MessageEntityCustomEmojiArray) PopFirst() (v MessageEntityCustomEmoji, ok bool) { if s == nil || len(*s) < 1 { return } @@ -2007,7 +2007,7 @@ func (s *MessageEntitySpoilerArray) PopFirst() (v MessageEntitySpoiler, ok bool) // Delete by index from SliceTricks. copy(a[0:], a[1:]) - var zero MessageEntitySpoiler + var zero MessageEntityCustomEmoji a[len(a)-1] = zero a = a[:len(a)-1] *s = a @@ -2016,7 +2016,7 @@ func (s *MessageEntitySpoilerArray) PopFirst() (v MessageEntitySpoiler, ok bool) } // Pop returns last element of slice (if exists) and deletes it. -func (s *MessageEntitySpoilerArray) Pop() (v MessageEntitySpoiler, ok bool) { +func (s *MessageEntityCustomEmojiArray) Pop() (v MessageEntityCustomEmoji, ok bool) { if s == nil || len(*s) < 1 { return } @@ -2029,27 +2029,27 @@ func (s *MessageEntitySpoilerArray) Pop() (v MessageEntitySpoiler, ok bool) { return v, true } -// MessageEntityCustomEmojiArray is adapter for slice of MessageEntityCustomEmoji. -type MessageEntityCustomEmojiArray []MessageEntityCustomEmoji +// MessageEntityBlockquoteArray is adapter for slice of MessageEntityBlockquote. +type MessageEntityBlockquoteArray []MessageEntityBlockquote -// Sort sorts slice of MessageEntityCustomEmoji. -func (s MessageEntityCustomEmojiArray) Sort(less func(a, b MessageEntityCustomEmoji) bool) MessageEntityCustomEmojiArray { +// Sort sorts slice of MessageEntityBlockquote. +func (s MessageEntityBlockquoteArray) Sort(less func(a, b MessageEntityBlockquote) bool) MessageEntityBlockquoteArray { sort.Slice(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } -// SortStable sorts slice of MessageEntityCustomEmoji. -func (s MessageEntityCustomEmojiArray) SortStable(less func(a, b MessageEntityCustomEmoji) bool) MessageEntityCustomEmojiArray { +// SortStable sorts slice of MessageEntityBlockquote. +func (s MessageEntityBlockquoteArray) SortStable(less func(a, b MessageEntityBlockquote) bool) MessageEntityBlockquoteArray { sort.SliceStable(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } -// Retain filters in-place slice of MessageEntityCustomEmoji. -func (s MessageEntityCustomEmojiArray) Retain(keep func(x MessageEntityCustomEmoji) bool) MessageEntityCustomEmojiArray { +// Retain filters in-place slice of MessageEntityBlockquote. +func (s MessageEntityBlockquoteArray) Retain(keep func(x MessageEntityBlockquote) bool) MessageEntityBlockquoteArray { n := 0 for _, x := range s { if keep(x) { @@ -2063,7 +2063,7 @@ func (s MessageEntityCustomEmojiArray) Retain(keep func(x MessageEntityCustomEmo } // First returns first element of slice (if exists). -func (s MessageEntityCustomEmojiArray) First() (v MessageEntityCustomEmoji, ok bool) { +func (s MessageEntityBlockquoteArray) First() (v MessageEntityBlockquote, ok bool) { if len(s) < 1 { return } @@ -2071,7 +2071,7 @@ func (s MessageEntityCustomEmojiArray) First() (v MessageEntityCustomEmoji, ok b } // Last returns last element of slice (if exists). -func (s MessageEntityCustomEmojiArray) Last() (v MessageEntityCustomEmoji, ok bool) { +func (s MessageEntityBlockquoteArray) Last() (v MessageEntityBlockquote, ok bool) { if len(s) < 1 { return } @@ -2079,7 +2079,7 @@ func (s MessageEntityCustomEmojiArray) Last() (v MessageEntityCustomEmoji, ok bo } // PopFirst returns first element of slice (if exists) and deletes it. -func (s *MessageEntityCustomEmojiArray) PopFirst() (v MessageEntityCustomEmoji, ok bool) { +func (s *MessageEntityBlockquoteArray) PopFirst() (v MessageEntityBlockquote, ok bool) { if s == nil || len(*s) < 1 { return } @@ -2089,7 +2089,7 @@ func (s *MessageEntityCustomEmojiArray) PopFirst() (v MessageEntityCustomEmoji, // Delete by index from SliceTricks. copy(a[0:], a[1:]) - var zero MessageEntityCustomEmoji + var zero MessageEntityBlockquote a[len(a)-1] = zero a = a[:len(a)-1] *s = a @@ -2098,7 +2098,7 @@ func (s *MessageEntityCustomEmojiArray) PopFirst() (v MessageEntityCustomEmoji, } // Pop returns last element of slice (if exists) and deletes it. -func (s *MessageEntityCustomEmojiArray) Pop() (v MessageEntityCustomEmoji, ok bool) { +func (s *MessageEntityBlockquoteArray) Pop() (v MessageEntityBlockquote, ok bool) { if s == nil || len(*s) < 1 { return } diff --git a/tg/tl_message_gen.go b/tg/tl_message_gen.go index 6939a8c635..b990ec66d7 100644 --- a/tg/tl_message_gen.go +++ b/tg/tl_message_gen.go @@ -283,6 +283,8 @@ type Message struct { // Links: // 1) https://telegram.org/blog/protected-content-delete-by-date-and-more Noforwards bool + // InvertMedia field of Message. + InvertMedia bool // ID of the message ID int // ID of the sender of the message @@ -422,6 +424,9 @@ func (m *Message) Zero() bool { if !(m.Noforwards == false) { return false } + if !(m.InvertMedia == false) { + return false + } if !(m.ID == 0) { return false } @@ -507,6 +512,7 @@ func (m *Message) FillFrom(from interface { GetEditHide() (value bool) GetPinned() (value bool) GetNoforwards() (value bool) + GetInvertMedia() (value bool) GetID() (value int) GetFromID() (value PeerClass, ok bool) GetPeerID() (value PeerClass) @@ -538,6 +544,7 @@ func (m *Message) FillFrom(from interface { m.EditHide = from.GetEditHide() m.Pinned = from.GetPinned() m.Noforwards = from.GetNoforwards() + m.InvertMedia = from.GetInvertMedia() m.ID = from.GetID() if val, ok := from.GetFromID(); ok { m.FromID = val @@ -681,6 +688,11 @@ func (m *Message) TypeInfo() tdp.Type { SchemaName: "noforwards", Null: !m.Flags.Has(26), }, + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !m.Flags.Has(27), + }, { Name: "ID", SchemaName: "id", @@ -813,6 +825,9 @@ func (m *Message) SetFlags() { if !(m.Noforwards == false) { m.Flags.Set(26) } + if !(m.InvertMedia == false) { + m.Flags.Set(27) + } if !(m.FromID == nil) { m.Flags.Set(8) } @@ -1011,6 +1026,7 @@ func (m *Message) DecodeBare(b *bin.Buffer) error { m.EditHide = m.Flags.Has(21) m.Pinned = m.Flags.Has(24) m.Noforwards = m.Flags.Has(26) + m.InvertMedia = m.Flags.Has(27) { value, err := b.Int() if err != nil { @@ -1358,6 +1374,25 @@ func (m *Message) GetNoforwards() (value bool) { return m.Flags.Has(26) } +// SetInvertMedia sets value of InvertMedia conditional field. +func (m *Message) SetInvertMedia(value bool) { + if value { + m.Flags.Set(27) + m.InvertMedia = true + } else { + m.Flags.Unset(27) + m.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (m *Message) GetInvertMedia() (value bool) { + if m == nil { + return + } + return m.Flags.Has(27) +} + // GetID returns value of ID field. func (m *Message) GetID() (value int) { if m == nil { diff --git a/tg/tl_message_media_gen.go b/tg/tl_message_media_gen.go index 306af06188..32baab8e98 100644 --- a/tg/tl_message_media_gen.go +++ b/tg/tl_message_media_gen.go @@ -1237,17 +1237,27 @@ func (m *MessageMediaDocument) GetTTLSeconds() (value int, ok bool) { return m.TTLSeconds, true } -// MessageMediaWebPage represents TL type `messageMediaWebPage#a32dd600`. +// MessageMediaWebPage represents TL type `messageMediaWebPage#ddf10c3b`. // Preview of webpage // // See https://core.telegram.org/constructor/messageMediaWebPage for reference. type MessageMediaWebPage struct { + // Flags field of MessageMediaWebPage. + Flags bin.Fields + // ForceLargeMedia field of MessageMediaWebPage. + ForceLargeMedia bool + // ForceSmallMedia field of MessageMediaWebPage. + ForceSmallMedia bool + // Manual field of MessageMediaWebPage. + Manual bool + // Safe field of MessageMediaWebPage. + Safe bool // Webpage preview Webpage WebPageClass } // MessageMediaWebPageTypeID is TL type id of MessageMediaWebPage. -const MessageMediaWebPageTypeID = 0xa32dd600 +const MessageMediaWebPageTypeID = 0xddf10c3b // construct implements constructor of MessageMediaClass. func (m MessageMediaWebPage) construct() MessageMediaClass { return &m } @@ -1266,6 +1276,21 @@ func (m *MessageMediaWebPage) Zero() bool { if m == nil { return true } + if !(m.Flags.Zero()) { + return false + } + if !(m.ForceLargeMedia == false) { + return false + } + if !(m.ForceSmallMedia == false) { + return false + } + if !(m.Manual == false) { + return false + } + if !(m.Safe == false) { + return false + } if !(m.Webpage == nil) { return false } @@ -1284,8 +1309,16 @@ func (m *MessageMediaWebPage) String() string { // FillFrom fills MessageMediaWebPage from given interface. func (m *MessageMediaWebPage) FillFrom(from interface { + GetForceLargeMedia() (value bool) + GetForceSmallMedia() (value bool) + GetManual() (value bool) + GetSafe() (value bool) GetWebpage() (value WebPageClass) }) { + m.ForceLargeMedia = from.GetForceLargeMedia() + m.ForceSmallMedia = from.GetForceSmallMedia() + m.Manual = from.GetManual() + m.Safe = from.GetSafe() m.Webpage = from.GetWebpage() } @@ -1312,6 +1345,26 @@ func (m *MessageMediaWebPage) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "ForceLargeMedia", + SchemaName: "force_large_media", + Null: !m.Flags.Has(0), + }, + { + Name: "ForceSmallMedia", + SchemaName: "force_small_media", + Null: !m.Flags.Has(1), + }, + { + Name: "Manual", + SchemaName: "manual", + Null: !m.Flags.Has(3), + }, + { + Name: "Safe", + SchemaName: "safe", + Null: !m.Flags.Has(4), + }, { Name: "Webpage", SchemaName: "webpage", @@ -1320,10 +1373,26 @@ func (m *MessageMediaWebPage) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (m *MessageMediaWebPage) SetFlags() { + if !(m.ForceLargeMedia == false) { + m.Flags.Set(0) + } + if !(m.ForceSmallMedia == false) { + m.Flags.Set(1) + } + if !(m.Manual == false) { + m.Flags.Set(3) + } + if !(m.Safe == false) { + m.Flags.Set(4) + } +} + // Encode implements bin.Encoder. func (m *MessageMediaWebPage) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageMediaWebPage#a32dd600 as nil") + return fmt.Errorf("can't encode messageMediaWebPage#ddf10c3b as nil") } b.PutID(MessageMediaWebPageTypeID) return m.EncodeBare(b) @@ -1332,13 +1401,17 @@ func (m *MessageMediaWebPage) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *MessageMediaWebPage) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageMediaWebPage#a32dd600 as nil") + return fmt.Errorf("can't encode messageMediaWebPage#ddf10c3b as nil") + } + m.SetFlags() + if err := m.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageMediaWebPage#ddf10c3b: field flags: %w", err) } if m.Webpage == nil { - return fmt.Errorf("unable to encode messageMediaWebPage#a32dd600: field webpage is nil") + return fmt.Errorf("unable to encode messageMediaWebPage#ddf10c3b: field webpage is nil") } if err := m.Webpage.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageMediaWebPage#a32dd600: field webpage: %w", err) + return fmt.Errorf("unable to encode messageMediaWebPage#ddf10c3b: field webpage: %w", err) } return nil } @@ -1346,10 +1419,10 @@ func (m *MessageMediaWebPage) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (m *MessageMediaWebPage) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageMediaWebPage#a32dd600 to nil") + return fmt.Errorf("can't decode messageMediaWebPage#ddf10c3b to nil") } if err := b.ConsumeID(MessageMediaWebPageTypeID); err != nil { - return fmt.Errorf("unable to decode messageMediaWebPage#a32dd600: %w", err) + return fmt.Errorf("unable to decode messageMediaWebPage#ddf10c3b: %w", err) } return m.DecodeBare(b) } @@ -1357,18 +1430,103 @@ func (m *MessageMediaWebPage) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *MessageMediaWebPage) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageMediaWebPage#a32dd600 to nil") + return fmt.Errorf("can't decode messageMediaWebPage#ddf10c3b to nil") + } + { + if err := m.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageMediaWebPage#ddf10c3b: field flags: %w", err) + } } + m.ForceLargeMedia = m.Flags.Has(0) + m.ForceSmallMedia = m.Flags.Has(1) + m.Manual = m.Flags.Has(3) + m.Safe = m.Flags.Has(4) { value, err := DecodeWebPage(b) if err != nil { - return fmt.Errorf("unable to decode messageMediaWebPage#a32dd600: field webpage: %w", err) + return fmt.Errorf("unable to decode messageMediaWebPage#ddf10c3b: field webpage: %w", err) } m.Webpage = value } return nil } +// SetForceLargeMedia sets value of ForceLargeMedia conditional field. +func (m *MessageMediaWebPage) SetForceLargeMedia(value bool) { + if value { + m.Flags.Set(0) + m.ForceLargeMedia = true + } else { + m.Flags.Unset(0) + m.ForceLargeMedia = false + } +} + +// GetForceLargeMedia returns value of ForceLargeMedia conditional field. +func (m *MessageMediaWebPage) GetForceLargeMedia() (value bool) { + if m == nil { + return + } + return m.Flags.Has(0) +} + +// SetForceSmallMedia sets value of ForceSmallMedia conditional field. +func (m *MessageMediaWebPage) SetForceSmallMedia(value bool) { + if value { + m.Flags.Set(1) + m.ForceSmallMedia = true + } else { + m.Flags.Unset(1) + m.ForceSmallMedia = false + } +} + +// GetForceSmallMedia returns value of ForceSmallMedia conditional field. +func (m *MessageMediaWebPage) GetForceSmallMedia() (value bool) { + if m == nil { + return + } + return m.Flags.Has(1) +} + +// SetManual sets value of Manual conditional field. +func (m *MessageMediaWebPage) SetManual(value bool) { + if value { + m.Flags.Set(3) + m.Manual = true + } else { + m.Flags.Unset(3) + m.Manual = false + } +} + +// GetManual returns value of Manual conditional field. +func (m *MessageMediaWebPage) GetManual() (value bool) { + if m == nil { + return + } + return m.Flags.Has(3) +} + +// SetSafe sets value of Safe conditional field. +func (m *MessageMediaWebPage) SetSafe(value bool) { + if value { + m.Flags.Set(4) + m.Safe = true + } else { + m.Flags.Unset(4) + m.Safe = false + } +} + +// GetSafe returns value of Safe conditional field. +func (m *MessageMediaWebPage) GetSafe() (value bool) { + if m == nil { + return + } + return m.Flags.Has(4) +} + // GetWebpage returns value of Webpage field. func (m *MessageMediaWebPage) GetWebpage() (value WebPageClass) { if m == nil { @@ -3187,6 +3345,348 @@ func (m *MessageMediaStory) GetStory() (value StoryItemClass, ok bool) { return m.Story, true } +// MessageMediaGiveaway represents TL type `messageMediaGiveaway#58260664`. +// +// See https://core.telegram.org/constructor/messageMediaGiveaway for reference. +type MessageMediaGiveaway struct { + // Flags field of MessageMediaGiveaway. + Flags bin.Fields + // OnlyNewSubscribers field of MessageMediaGiveaway. + OnlyNewSubscribers bool + // Channels field of MessageMediaGiveaway. + Channels []int64 + // CountriesISO2 field of MessageMediaGiveaway. + // + // Use SetCountriesISO2 and GetCountriesISO2 helpers. + CountriesISO2 []string + // Quantity field of MessageMediaGiveaway. + Quantity int + // Months field of MessageMediaGiveaway. + Months int + // UntilDate field of MessageMediaGiveaway. + UntilDate int +} + +// MessageMediaGiveawayTypeID is TL type id of MessageMediaGiveaway. +const MessageMediaGiveawayTypeID = 0x58260664 + +// construct implements constructor of MessageMediaClass. +func (m MessageMediaGiveaway) construct() MessageMediaClass { return &m } + +// Ensuring interfaces in compile-time for MessageMediaGiveaway. +var ( + _ bin.Encoder = &MessageMediaGiveaway{} + _ bin.Decoder = &MessageMediaGiveaway{} + _ bin.BareEncoder = &MessageMediaGiveaway{} + _ bin.BareDecoder = &MessageMediaGiveaway{} + + _ MessageMediaClass = &MessageMediaGiveaway{} +) + +func (m *MessageMediaGiveaway) Zero() bool { + if m == nil { + return true + } + if !(m.Flags.Zero()) { + return false + } + if !(m.OnlyNewSubscribers == false) { + return false + } + if !(m.Channels == nil) { + return false + } + if !(m.CountriesISO2 == nil) { + return false + } + if !(m.Quantity == 0) { + return false + } + if !(m.Months == 0) { + return false + } + if !(m.UntilDate == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageMediaGiveaway) String() string { + if m == nil { + return "MessageMediaGiveaway(nil)" + } + type Alias MessageMediaGiveaway + return fmt.Sprintf("MessageMediaGiveaway%+v", Alias(*m)) +} + +// FillFrom fills MessageMediaGiveaway from given interface. +func (m *MessageMediaGiveaway) FillFrom(from interface { + GetOnlyNewSubscribers() (value bool) + GetChannels() (value []int64) + GetCountriesISO2() (value []string, ok bool) + GetQuantity() (value int) + GetMonths() (value int) + GetUntilDate() (value int) +}) { + m.OnlyNewSubscribers = from.GetOnlyNewSubscribers() + m.Channels = from.GetChannels() + if val, ok := from.GetCountriesISO2(); ok { + m.CountriesISO2 = val + } + + m.Quantity = from.GetQuantity() + m.Months = from.GetMonths() + m.UntilDate = from.GetUntilDate() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageMediaGiveaway) TypeID() uint32 { + return MessageMediaGiveawayTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageMediaGiveaway) TypeName() string { + return "messageMediaGiveaway" +} + +// TypeInfo returns info about TL type. +func (m *MessageMediaGiveaway) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageMediaGiveaway", + ID: MessageMediaGiveawayTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "OnlyNewSubscribers", + SchemaName: "only_new_subscribers", + Null: !m.Flags.Has(0), + }, + { + Name: "Channels", + SchemaName: "channels", + }, + { + Name: "CountriesISO2", + SchemaName: "countries_iso2", + Null: !m.Flags.Has(1), + }, + { + Name: "Quantity", + SchemaName: "quantity", + }, + { + Name: "Months", + SchemaName: "months", + }, + { + Name: "UntilDate", + SchemaName: "until_date", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (m *MessageMediaGiveaway) SetFlags() { + if !(m.OnlyNewSubscribers == false) { + m.Flags.Set(0) + } + if !(m.CountriesISO2 == nil) { + m.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (m *MessageMediaGiveaway) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageMediaGiveaway#58260664 as nil") + } + b.PutID(MessageMediaGiveawayTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageMediaGiveaway) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageMediaGiveaway#58260664 as nil") + } + m.SetFlags() + if err := m.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageMediaGiveaway#58260664: field flags: %w", err) + } + b.PutVectorHeader(len(m.Channels)) + for _, v := range m.Channels { + b.PutLong(v) + } + if m.Flags.Has(1) { + b.PutVectorHeader(len(m.CountriesISO2)) + for _, v := range m.CountriesISO2 { + b.PutString(v) + } + } + b.PutInt(m.Quantity) + b.PutInt(m.Months) + b.PutInt(m.UntilDate) + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageMediaGiveaway) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageMediaGiveaway#58260664 to nil") + } + if err := b.ConsumeID(MessageMediaGiveawayTypeID); err != nil { + return fmt.Errorf("unable to decode messageMediaGiveaway#58260664: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageMediaGiveaway) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageMediaGiveaway#58260664 to nil") + } + { + if err := m.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageMediaGiveaway#58260664: field flags: %w", err) + } + } + m.OnlyNewSubscribers = m.Flags.Has(0) + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messageMediaGiveaway#58260664: field channels: %w", err) + } + + if headerLen > 0 { + m.Channels = make([]int64, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messageMediaGiveaway#58260664: field channels: %w", err) + } + m.Channels = append(m.Channels, value) + } + } + if m.Flags.Has(1) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messageMediaGiveaway#58260664: field countries_iso2: %w", err) + } + + if headerLen > 0 { + m.CountriesISO2 = 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 messageMediaGiveaway#58260664: field countries_iso2: %w", err) + } + m.CountriesISO2 = append(m.CountriesISO2, value) + } + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messageMediaGiveaway#58260664: field quantity: %w", err) + } + m.Quantity = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messageMediaGiveaway#58260664: field months: %w", err) + } + m.Months = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messageMediaGiveaway#58260664: field until_date: %w", err) + } + m.UntilDate = value + } + return nil +} + +// SetOnlyNewSubscribers sets value of OnlyNewSubscribers conditional field. +func (m *MessageMediaGiveaway) SetOnlyNewSubscribers(value bool) { + if value { + m.Flags.Set(0) + m.OnlyNewSubscribers = true + } else { + m.Flags.Unset(0) + m.OnlyNewSubscribers = false + } +} + +// GetOnlyNewSubscribers returns value of OnlyNewSubscribers conditional field. +func (m *MessageMediaGiveaway) GetOnlyNewSubscribers() (value bool) { + if m == nil { + return + } + return m.Flags.Has(0) +} + +// GetChannels returns value of Channels field. +func (m *MessageMediaGiveaway) GetChannels() (value []int64) { + if m == nil { + return + } + return m.Channels +} + +// SetCountriesISO2 sets value of CountriesISO2 conditional field. +func (m *MessageMediaGiveaway) SetCountriesISO2(value []string) { + m.Flags.Set(1) + m.CountriesISO2 = value +} + +// GetCountriesISO2 returns value of CountriesISO2 conditional field and +// boolean which is true if field was set. +func (m *MessageMediaGiveaway) GetCountriesISO2() (value []string, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(1) { + return value, false + } + return m.CountriesISO2, true +} + +// GetQuantity returns value of Quantity field. +func (m *MessageMediaGiveaway) GetQuantity() (value int) { + if m == nil { + return + } + return m.Quantity +} + +// GetMonths returns value of Months field. +func (m *MessageMediaGiveaway) GetMonths() (value int) { + if m == nil { + return + } + return m.Months +} + +// GetUntilDate returns value of UntilDate field. +func (m *MessageMediaGiveaway) GetUntilDate() (value int) { + if m == nil { + return + } + return m.UntilDate +} + // MessageMediaClassName is schema name of MessageMediaClass. const MessageMediaClassName = "MessageMedia" @@ -3207,7 +3707,7 @@ const MessageMediaClassName = "MessageMedia" // case *tg.MessageMediaContact: // messageMediaContact#70322949 // case *tg.MessageMediaUnsupported: // messageMediaUnsupported#9f84f49e // case *tg.MessageMediaDocument: // messageMediaDocument#4cf4d72d -// case *tg.MessageMediaWebPage: // messageMediaWebPage#a32dd600 +// case *tg.MessageMediaWebPage: // messageMediaWebPage#ddf10c3b // case *tg.MessageMediaVenue: // messageMediaVenue#2ec0533f // case *tg.MessageMediaGame: // messageMediaGame#fdb19008 // case *tg.MessageMediaInvoice: // messageMediaInvoice#f6a548d3 @@ -3215,6 +3715,7 @@ const MessageMediaClassName = "MessageMedia" // case *tg.MessageMediaPoll: // messageMediaPoll#4bd6e798 // case *tg.MessageMediaDice: // messageMediaDice#3f7ee58b // case *tg.MessageMediaStory: // messageMediaStory#68cb6283 +// case *tg.MessageMediaGiveaway: // messageMediaGiveaway#58260664 // default: panic(v) // } type MessageMediaClass interface { @@ -3286,7 +3787,7 @@ func DecodeMessageMedia(buf *bin.Buffer) (MessageMediaClass, error) { } return &v, nil case MessageMediaWebPageTypeID: - // Decoding messageMediaWebPage#a32dd600. + // Decoding messageMediaWebPage#ddf10c3b. v := MessageMediaWebPage{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageMediaClass: %w", err) @@ -3341,6 +3842,13 @@ func DecodeMessageMedia(buf *bin.Buffer) (MessageMediaClass, error) { return nil, fmt.Errorf("unable to decode MessageMediaClass: %w", err) } return &v, nil + case MessageMediaGiveawayTypeID: + // Decoding messageMediaGiveaway#58260664. + v := MessageMediaGiveaway{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageMediaClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode MessageMediaClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_message_media_slices_gen.go b/tg/tl_message_media_slices_gen.go index 362e3794fd..6f03b5f03b 100644 --- a/tg/tl_message_media_slices_gen.go +++ b/tg/tl_message_media_slices_gen.go @@ -272,6 +272,19 @@ func (s MessageMediaClassArray) AsMessageMediaStory() (to MessageMediaStoryArray return to } +// AsMessageMediaGiveaway returns copy with only MessageMediaGiveaway constructors. +func (s MessageMediaClassArray) AsMessageMediaGiveaway() (to MessageMediaGiveawayArray) { + for _, elem := range s { + value, ok := elem.(*MessageMediaGiveaway) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // MessageMediaPhotoArray is adapter for slice of MessageMediaPhoto. type MessageMediaPhotoArray []MessageMediaPhoto @@ -1283,3 +1296,85 @@ func (s MessageMediaStoryArray) ToMap() map[int]MessageMediaStory { s.FillMap(r) return r } + +// MessageMediaGiveawayArray is adapter for slice of MessageMediaGiveaway. +type MessageMediaGiveawayArray []MessageMediaGiveaway + +// Sort sorts slice of MessageMediaGiveaway. +func (s MessageMediaGiveawayArray) Sort(less func(a, b MessageMediaGiveaway) bool) MessageMediaGiveawayArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessageMediaGiveaway. +func (s MessageMediaGiveawayArray) SortStable(less func(a, b MessageMediaGiveaway) bool) MessageMediaGiveawayArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessageMediaGiveaway. +func (s MessageMediaGiveawayArray) Retain(keep func(x MessageMediaGiveaway) bool) MessageMediaGiveawayArray { + 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 MessageMediaGiveawayArray) First() (v MessageMediaGiveaway, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessageMediaGiveawayArray) Last() (v MessageMediaGiveaway, 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 *MessageMediaGiveawayArray) PopFirst() (v MessageMediaGiveaway, 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 MessageMediaGiveaway + 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 *MessageMediaGiveawayArray) Pop() (v MessageMediaGiveaway, 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_message_reply_header_gen.go b/tg/tl_message_reply_header_gen.go index d843bbbc6e..3d8cd4471c 100644 --- a/tg/tl_message_reply_header_gen.go +++ b/tg/tl_message_reply_header_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessageReplyHeader represents TL type `messageReplyHeader#a6d57763`. +// MessageReplyHeader represents TL type `messageReplyHeader#6eebcabd`. // Message replies and thread¹ information // // Links: @@ -51,7 +51,11 @@ type MessageReplyHeader struct { // Links: // 1) https://core.telegram.org/api/forum#forum-topics ForumTopic bool + // Quote field of MessageReplyHeader. + Quote bool // ID of message to which this message is replying + // + // Use SetReplyToMsgID and GetReplyToMsgID helpers. ReplyToMsgID int // For replies sent in channel discussion threads¹ of which the current user is not a // member, the discussion group ID @@ -61,6 +65,14 @@ type MessageReplyHeader struct { // // Use SetReplyToPeerID and GetReplyToPeerID helpers. ReplyToPeerID PeerClass + // ReplyFrom field of MessageReplyHeader. + // + // Use SetReplyFrom and GetReplyFrom helpers. + ReplyFrom MessageFwdHeader + // ReplyMedia field of MessageReplyHeader. + // + // Use SetReplyMedia and GetReplyMedia helpers. + ReplyMedia MessageMediaClass // ID of the message that started this message thread¹ // // Links: @@ -68,10 +80,18 @@ type MessageReplyHeader struct { // // Use SetReplyToTopID and GetReplyToTopID helpers. ReplyToTopID int + // QuoteText field of MessageReplyHeader. + // + // Use SetQuoteText and GetQuoteText helpers. + QuoteText string + // QuoteEntities field of MessageReplyHeader. + // + // Use SetQuoteEntities and GetQuoteEntities helpers. + QuoteEntities []MessageEntityClass } // MessageReplyHeaderTypeID is TL type id of MessageReplyHeader. -const MessageReplyHeaderTypeID = 0xa6d57763 +const MessageReplyHeaderTypeID = 0x6eebcabd // construct implements constructor of MessageReplyHeaderClass. func (m MessageReplyHeader) construct() MessageReplyHeaderClass { return &m } @@ -99,15 +119,30 @@ func (m *MessageReplyHeader) Zero() bool { if !(m.ForumTopic == false) { return false } + if !(m.Quote == false) { + return false + } if !(m.ReplyToMsgID == 0) { return false } if !(m.ReplyToPeerID == nil) { return false } + if !(m.ReplyFrom.Zero()) { + return false + } + if !(m.ReplyMedia == nil) { + return false + } if !(m.ReplyToTopID == 0) { return false } + if !(m.QuoteText == "") { + return false + } + if !(m.QuoteEntities == nil) { + return false + } return true } @@ -125,21 +160,46 @@ func (m *MessageReplyHeader) String() string { func (m *MessageReplyHeader) FillFrom(from interface { GetReplyToScheduled() (value bool) GetForumTopic() (value bool) - GetReplyToMsgID() (value int) + GetQuote() (value bool) + GetReplyToMsgID() (value int, ok bool) GetReplyToPeerID() (value PeerClass, ok bool) + GetReplyFrom() (value MessageFwdHeader, ok bool) + GetReplyMedia() (value MessageMediaClass, ok bool) GetReplyToTopID() (value int, ok bool) + GetQuoteText() (value string, ok bool) + GetQuoteEntities() (value []MessageEntityClass, ok bool) }) { m.ReplyToScheduled = from.GetReplyToScheduled() m.ForumTopic = from.GetForumTopic() - m.ReplyToMsgID = from.GetReplyToMsgID() + m.Quote = from.GetQuote() + if val, ok := from.GetReplyToMsgID(); ok { + m.ReplyToMsgID = val + } + if val, ok := from.GetReplyToPeerID(); ok { m.ReplyToPeerID = val } + if val, ok := from.GetReplyFrom(); ok { + m.ReplyFrom = val + } + + if val, ok := from.GetReplyMedia(); ok { + m.ReplyMedia = val + } + if val, ok := from.GetReplyToTopID(); ok { m.ReplyToTopID = val } + if val, ok := from.GetQuoteText(); ok { + m.QuoteText = val + } + + if val, ok := from.GetQuoteEntities(); ok { + m.QuoteEntities = val + } + } // TypeID returns type id in TL schema. @@ -175,20 +235,46 @@ func (m *MessageReplyHeader) TypeInfo() tdp.Type { SchemaName: "forum_topic", Null: !m.Flags.Has(3), }, + { + Name: "Quote", + SchemaName: "quote", + Null: !m.Flags.Has(9), + }, { Name: "ReplyToMsgID", SchemaName: "reply_to_msg_id", + Null: !m.Flags.Has(4), }, { Name: "ReplyToPeerID", SchemaName: "reply_to_peer_id", Null: !m.Flags.Has(0), }, + { + Name: "ReplyFrom", + SchemaName: "reply_from", + Null: !m.Flags.Has(5), + }, + { + Name: "ReplyMedia", + SchemaName: "reply_media", + Null: !m.Flags.Has(8), + }, { Name: "ReplyToTopID", SchemaName: "reply_to_top_id", Null: !m.Flags.Has(1), }, + { + Name: "QuoteText", + SchemaName: "quote_text", + Null: !m.Flags.Has(6), + }, + { + Name: "QuoteEntities", + SchemaName: "quote_entities", + Null: !m.Flags.Has(7), + }, } return typ } @@ -201,18 +287,36 @@ func (m *MessageReplyHeader) SetFlags() { if !(m.ForumTopic == false) { m.Flags.Set(3) } + if !(m.Quote == false) { + m.Flags.Set(9) + } + if !(m.ReplyToMsgID == 0) { + m.Flags.Set(4) + } if !(m.ReplyToPeerID == nil) { m.Flags.Set(0) } + if !(m.ReplyFrom.Zero()) { + m.Flags.Set(5) + } + if !(m.ReplyMedia == nil) { + m.Flags.Set(8) + } if !(m.ReplyToTopID == 0) { m.Flags.Set(1) } + if !(m.QuoteText == "") { + m.Flags.Set(6) + } + if !(m.QuoteEntities == nil) { + m.Flags.Set(7) + } } // Encode implements bin.Encoder. func (m *MessageReplyHeader) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageReplyHeader#a6d57763 as nil") + return fmt.Errorf("can't encode messageReplyHeader#6eebcabd as nil") } b.PutID(MessageReplyHeaderTypeID) return m.EncodeBare(b) @@ -221,34 +325,63 @@ func (m *MessageReplyHeader) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *MessageReplyHeader) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageReplyHeader#a6d57763 as nil") + return fmt.Errorf("can't encode messageReplyHeader#6eebcabd as nil") } m.SetFlags() if err := m.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageReplyHeader#a6d57763: field flags: %w", err) + return fmt.Errorf("unable to encode messageReplyHeader#6eebcabd: field flags: %w", err) + } + if m.Flags.Has(4) { + b.PutInt(m.ReplyToMsgID) } - b.PutInt(m.ReplyToMsgID) if m.Flags.Has(0) { if m.ReplyToPeerID == nil { - return fmt.Errorf("unable to encode messageReplyHeader#a6d57763: field reply_to_peer_id is nil") + return fmt.Errorf("unable to encode messageReplyHeader#6eebcabd: field reply_to_peer_id is nil") } if err := m.ReplyToPeerID.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageReplyHeader#a6d57763: field reply_to_peer_id: %w", err) + return fmt.Errorf("unable to encode messageReplyHeader#6eebcabd: field reply_to_peer_id: %w", err) + } + } + if m.Flags.Has(5) { + if err := m.ReplyFrom.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageReplyHeader#6eebcabd: field reply_from: %w", err) + } + } + if m.Flags.Has(8) { + if m.ReplyMedia == nil { + return fmt.Errorf("unable to encode messageReplyHeader#6eebcabd: field reply_media is nil") + } + if err := m.ReplyMedia.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageReplyHeader#6eebcabd: field reply_media: %w", err) } } if m.Flags.Has(1) { b.PutInt(m.ReplyToTopID) } + if m.Flags.Has(6) { + b.PutString(m.QuoteText) + } + if m.Flags.Has(7) { + b.PutVectorHeader(len(m.QuoteEntities)) + for idx, v := range m.QuoteEntities { + if v == nil { + return fmt.Errorf("unable to encode messageReplyHeader#6eebcabd: field quote_entities element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageReplyHeader#6eebcabd: field quote_entities element with index %d: %w", idx, err) + } + } + } return nil } // Decode implements bin.Decoder. func (m *MessageReplyHeader) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageReplyHeader#a6d57763 to nil") + return fmt.Errorf("can't decode messageReplyHeader#6eebcabd to nil") } if err := b.ConsumeID(MessageReplyHeaderTypeID); err != nil { - return fmt.Errorf("unable to decode messageReplyHeader#a6d57763: %w", err) + return fmt.Errorf("unable to decode messageReplyHeader#6eebcabd: %w", err) } return m.DecodeBare(b) } @@ -256,36 +389,73 @@ func (m *MessageReplyHeader) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *MessageReplyHeader) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageReplyHeader#a6d57763 to nil") + return fmt.Errorf("can't decode messageReplyHeader#6eebcabd to nil") } { if err := m.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messageReplyHeader#a6d57763: field flags: %w", err) + return fmt.Errorf("unable to decode messageReplyHeader#6eebcabd: field flags: %w", err) } } m.ReplyToScheduled = m.Flags.Has(2) m.ForumTopic = m.Flags.Has(3) - { + m.Quote = m.Flags.Has(9) + if m.Flags.Has(4) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageReplyHeader#a6d57763: field reply_to_msg_id: %w", err) + return fmt.Errorf("unable to decode messageReplyHeader#6eebcabd: field reply_to_msg_id: %w", err) } m.ReplyToMsgID = value } if m.Flags.Has(0) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode messageReplyHeader#a6d57763: field reply_to_peer_id: %w", err) + return fmt.Errorf("unable to decode messageReplyHeader#6eebcabd: field reply_to_peer_id: %w", err) } m.ReplyToPeerID = value } + if m.Flags.Has(5) { + if err := m.ReplyFrom.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageReplyHeader#6eebcabd: field reply_from: %w", err) + } + } + if m.Flags.Has(8) { + value, err := DecodeMessageMedia(b) + if err != nil { + return fmt.Errorf("unable to decode messageReplyHeader#6eebcabd: field reply_media: %w", err) + } + m.ReplyMedia = value + } if m.Flags.Has(1) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageReplyHeader#a6d57763: field reply_to_top_id: %w", err) + return fmt.Errorf("unable to decode messageReplyHeader#6eebcabd: field reply_to_top_id: %w", err) } m.ReplyToTopID = value } + if m.Flags.Has(6) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageReplyHeader#6eebcabd: field quote_text: %w", err) + } + m.QuoteText = value + } + if m.Flags.Has(7) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messageReplyHeader#6eebcabd: field quote_entities: %w", err) + } + + if headerLen > 0 { + m.QuoteEntities = make([]MessageEntityClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeMessageEntity(b) + if err != nil { + return fmt.Errorf("unable to decode messageReplyHeader#6eebcabd: field quote_entities: %w", err) + } + m.QuoteEntities = append(m.QuoteEntities, value) + } + } return nil } @@ -327,12 +497,41 @@ func (m *MessageReplyHeader) GetForumTopic() (value bool) { return m.Flags.Has(3) } -// GetReplyToMsgID returns value of ReplyToMsgID field. -func (m *MessageReplyHeader) GetReplyToMsgID() (value int) { +// SetQuote sets value of Quote conditional field. +func (m *MessageReplyHeader) SetQuote(value bool) { + if value { + m.Flags.Set(9) + m.Quote = true + } else { + m.Flags.Unset(9) + m.Quote = false + } +} + +// GetQuote returns value of Quote conditional field. +func (m *MessageReplyHeader) GetQuote() (value bool) { if m == nil { return } - return m.ReplyToMsgID + return m.Flags.Has(9) +} + +// SetReplyToMsgID sets value of ReplyToMsgID conditional field. +func (m *MessageReplyHeader) SetReplyToMsgID(value int) { + m.Flags.Set(4) + m.ReplyToMsgID = value +} + +// GetReplyToMsgID returns value of ReplyToMsgID conditional field and +// boolean which is true if field was set. +func (m *MessageReplyHeader) GetReplyToMsgID() (value int, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(4) { + return value, false + } + return m.ReplyToMsgID, true } // SetReplyToPeerID sets value of ReplyToPeerID conditional field. @@ -353,6 +552,42 @@ func (m *MessageReplyHeader) GetReplyToPeerID() (value PeerClass, ok bool) { return m.ReplyToPeerID, true } +// SetReplyFrom sets value of ReplyFrom conditional field. +func (m *MessageReplyHeader) SetReplyFrom(value MessageFwdHeader) { + m.Flags.Set(5) + m.ReplyFrom = value +} + +// GetReplyFrom returns value of ReplyFrom conditional field and +// boolean which is true if field was set. +func (m *MessageReplyHeader) GetReplyFrom() (value MessageFwdHeader, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(5) { + return value, false + } + return m.ReplyFrom, true +} + +// SetReplyMedia sets value of ReplyMedia conditional field. +func (m *MessageReplyHeader) SetReplyMedia(value MessageMediaClass) { + m.Flags.Set(8) + m.ReplyMedia = value +} + +// GetReplyMedia returns value of ReplyMedia conditional field and +// boolean which is true if field was set. +func (m *MessageReplyHeader) GetReplyMedia() (value MessageMediaClass, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(8) { + return value, false + } + return m.ReplyMedia, true +} + // SetReplyToTopID sets value of ReplyToTopID conditional field. func (m *MessageReplyHeader) SetReplyToTopID(value int) { m.Flags.Set(1) @@ -371,6 +606,50 @@ func (m *MessageReplyHeader) GetReplyToTopID() (value int, ok bool) { return m.ReplyToTopID, true } +// SetQuoteText sets value of QuoteText conditional field. +func (m *MessageReplyHeader) SetQuoteText(value string) { + m.Flags.Set(6) + m.QuoteText = value +} + +// GetQuoteText returns value of QuoteText conditional field and +// boolean which is true if field was set. +func (m *MessageReplyHeader) GetQuoteText() (value string, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(6) { + return value, false + } + return m.QuoteText, true +} + +// SetQuoteEntities sets value of QuoteEntities conditional field. +func (m *MessageReplyHeader) SetQuoteEntities(value []MessageEntityClass) { + m.Flags.Set(7) + m.QuoteEntities = value +} + +// GetQuoteEntities returns value of QuoteEntities conditional field and +// boolean which is true if field was set. +func (m *MessageReplyHeader) GetQuoteEntities() (value []MessageEntityClass, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(7) { + return value, false + } + return m.QuoteEntities, true +} + +// MapQuoteEntities returns field QuoteEntities wrapped in MessageEntityClassArray helper. +func (m *MessageReplyHeader) MapQuoteEntities() (value MessageEntityClassArray, ok bool) { + if !m.Flags.Has(7) { + return value, false + } + return MessageEntityClassArray(m.QuoteEntities), true +} + // MessageReplyStoryHeader represents TL type `messageReplyStoryHeader#9c98bfc1`. // // See https://core.telegram.org/constructor/messageReplyStoryHeader for reference. @@ -546,7 +825,7 @@ const MessageReplyHeaderClassName = "MessageReplyHeader" // panic(err) // } // switch v := g.(type) { -// case *tg.MessageReplyHeader: // messageReplyHeader#a6d57763 +// case *tg.MessageReplyHeader: // messageReplyHeader#6eebcabd // case *tg.MessageReplyStoryHeader: // messageReplyStoryHeader#9c98bfc1 // default: panic(v) // } @@ -577,7 +856,7 @@ func DecodeMessageReplyHeader(buf *bin.Buffer) (MessageReplyHeaderClass, error) } switch id { case MessageReplyHeaderTypeID: - // Decoding messageReplyHeader#a6d57763. + // Decoding messageReplyHeader#6eebcabd. v := MessageReplyHeader{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageReplyHeaderClass: %w", err) diff --git a/tg/tl_messages_edit_inline_bot_message_gen.go b/tg/tl_messages_edit_inline_bot_message_gen.go index ac6940a066..f5f6f623d9 100644 --- a/tg/tl_messages_edit_inline_bot_message_gen.go +++ b/tg/tl_messages_edit_inline_bot_message_gen.go @@ -43,6 +43,8 @@ type MessagesEditInlineBotMessageRequest struct { Flags bin.Fields // Disable webpage preview NoWebpage bool + // InvertMedia field of MessagesEditInlineBotMessageRequest. + InvertMedia bool // Sent inline message ID ID InputBotInlineMessageIDClass // Message @@ -87,6 +89,9 @@ func (e *MessagesEditInlineBotMessageRequest) Zero() bool { if !(e.NoWebpage == false) { return false } + if !(e.InvertMedia == false) { + return false + } if !(e.ID == nil) { return false } @@ -118,6 +123,7 @@ func (e *MessagesEditInlineBotMessageRequest) String() string { // FillFrom fills MessagesEditInlineBotMessageRequest from given interface. func (e *MessagesEditInlineBotMessageRequest) FillFrom(from interface { GetNoWebpage() (value bool) + GetInvertMedia() (value bool) GetID() (value InputBotInlineMessageIDClass) GetMessage() (value string, ok bool) GetMedia() (value InputMediaClass, ok bool) @@ -125,6 +131,7 @@ func (e *MessagesEditInlineBotMessageRequest) FillFrom(from interface { GetEntities() (value []MessageEntityClass, ok bool) }) { e.NoWebpage = from.GetNoWebpage() + e.InvertMedia = from.GetInvertMedia() e.ID = from.GetID() if val, ok := from.GetMessage(); ok { e.Message = val @@ -172,6 +179,11 @@ func (e *MessagesEditInlineBotMessageRequest) TypeInfo() tdp.Type { SchemaName: "no_webpage", Null: !e.Flags.Has(1), }, + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !e.Flags.Has(16), + }, { Name: "ID", SchemaName: "id", @@ -205,6 +217,9 @@ func (e *MessagesEditInlineBotMessageRequest) SetFlags() { if !(e.NoWebpage == false) { e.Flags.Set(1) } + if !(e.InvertMedia == false) { + e.Flags.Set(16) + } if !(e.Message == "") { e.Flags.Set(11) } @@ -298,6 +313,7 @@ func (e *MessagesEditInlineBotMessageRequest) DecodeBare(b *bin.Buffer) error { } } e.NoWebpage = e.Flags.Has(1) + e.InvertMedia = e.Flags.Has(16) { value, err := DecodeInputBotInlineMessageID(b) if err != nil { @@ -365,6 +381,25 @@ func (e *MessagesEditInlineBotMessageRequest) GetNoWebpage() (value bool) { return e.Flags.Has(1) } +// SetInvertMedia sets value of InvertMedia conditional field. +func (e *MessagesEditInlineBotMessageRequest) SetInvertMedia(value bool) { + if value { + e.Flags.Set(16) + e.InvertMedia = true + } else { + e.Flags.Unset(16) + e.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (e *MessagesEditInlineBotMessageRequest) GetInvertMedia() (value bool) { + if e == nil { + return + } + return e.Flags.Has(16) +} + // GetID returns value of ID field. func (e *MessagesEditInlineBotMessageRequest) GetID() (value InputBotInlineMessageIDClass) { if e == nil { diff --git a/tg/tl_messages_edit_message_gen.go b/tg/tl_messages_edit_message_gen.go index 5017e2ceee..16509864e5 100644 --- a/tg/tl_messages_edit_message_gen.go +++ b/tg/tl_messages_edit_message_gen.go @@ -43,6 +43,8 @@ type MessagesEditMessageRequest struct { Flags bin.Fields // Disable webpage preview NoWebpage bool + // InvertMedia field of MessagesEditMessageRequest. + InvertMedia bool // Where was the message sent Peer InputPeerClass // ID of the message to edit @@ -96,6 +98,9 @@ func (e *MessagesEditMessageRequest) Zero() bool { if !(e.NoWebpage == false) { return false } + if !(e.InvertMedia == false) { + return false + } if !(e.Peer == nil) { return false } @@ -133,6 +138,7 @@ func (e *MessagesEditMessageRequest) String() string { // FillFrom fills MessagesEditMessageRequest from given interface. func (e *MessagesEditMessageRequest) FillFrom(from interface { GetNoWebpage() (value bool) + GetInvertMedia() (value bool) GetPeer() (value InputPeerClass) GetID() (value int) GetMessage() (value string, ok bool) @@ -142,6 +148,7 @@ func (e *MessagesEditMessageRequest) FillFrom(from interface { GetScheduleDate() (value int, ok bool) }) { e.NoWebpage = from.GetNoWebpage() + e.InvertMedia = from.GetInvertMedia() e.Peer = from.GetPeer() e.ID = from.GetID() if val, ok := from.GetMessage(); ok { @@ -194,6 +201,11 @@ func (e *MessagesEditMessageRequest) TypeInfo() tdp.Type { SchemaName: "no_webpage", Null: !e.Flags.Has(1), }, + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !e.Flags.Has(16), + }, { Name: "Peer", SchemaName: "peer", @@ -236,6 +248,9 @@ func (e *MessagesEditMessageRequest) SetFlags() { if !(e.NoWebpage == false) { e.Flags.Set(1) } + if !(e.InvertMedia == false) { + e.Flags.Set(16) + } if !(e.Message == "") { e.Flags.Set(11) } @@ -336,6 +351,7 @@ func (e *MessagesEditMessageRequest) DecodeBare(b *bin.Buffer) error { } } e.NoWebpage = e.Flags.Has(1) + e.InvertMedia = e.Flags.Has(16) { value, err := DecodeInputPeer(b) if err != nil { @@ -417,6 +433,25 @@ func (e *MessagesEditMessageRequest) GetNoWebpage() (value bool) { return e.Flags.Has(1) } +// SetInvertMedia sets value of InvertMedia conditional field. +func (e *MessagesEditMessageRequest) SetInvertMedia(value bool) { + if value { + e.Flags.Set(16) + e.InvertMedia = true + } else { + e.Flags.Unset(16) + e.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (e *MessagesEditMessageRequest) GetInvertMedia() (value bool) { + if e == nil { + return + } + return e.Flags.Has(16) +} + // GetPeer returns value of Peer field. func (e *MessagesEditMessageRequest) GetPeer() (value InputPeerClass) { if e == nil { diff --git a/tg/tl_messages_save_draft_gen.go b/tg/tl_messages_save_draft_gen.go index 25772a8394..86f965cf4b 100644 --- a/tg/tl_messages_save_draft_gen.go +++ b/tg/tl_messages_save_draft_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSaveDraftRequest represents TL type `messages.saveDraft#b4331e3f`. +// MessagesSaveDraftRequest represents TL type `messages.saveDraft#7ff3b806`. // Save a message draft¹ associated to a chat. // // Links: @@ -46,17 +46,12 @@ type MessagesSaveDraftRequest struct { Flags bin.Fields // Disable generation of the webpage preview NoWebpage bool - // Message ID the message should reply to + // InvertMedia field of MessagesSaveDraftRequest. + InvertMedia bool + // ReplyTo field of MessagesSaveDraftRequest. // - // Use SetReplyToMsgID and GetReplyToMsgID helpers. - ReplyToMsgID int - // Forum topic¹ where the message will be sent - // - // Links: - // 1) https://core.telegram.org/api/forum#forum-topics - // - // Use SetTopMsgID and GetTopMsgID helpers. - TopMsgID int + // Use SetReplyTo and GetReplyTo helpers. + ReplyTo InputReplyToClass // Destination of the message that should be sent Peer InputPeerClass // The draft @@ -68,10 +63,14 @@ type MessagesSaveDraftRequest struct { // // Use SetEntities and GetEntities helpers. Entities []MessageEntityClass + // Media field of MessagesSaveDraftRequest. + // + // Use SetMedia and GetMedia helpers. + Media InputMediaClass } // MessagesSaveDraftRequestTypeID is TL type id of MessagesSaveDraftRequest. -const MessagesSaveDraftRequestTypeID = 0xb4331e3f +const MessagesSaveDraftRequestTypeID = 0x7ff3b806 // Ensuring interfaces in compile-time for MessagesSaveDraftRequest. var ( @@ -91,10 +90,10 @@ func (s *MessagesSaveDraftRequest) Zero() bool { if !(s.NoWebpage == false) { return false } - if !(s.ReplyToMsgID == 0) { + if !(s.InvertMedia == false) { return false } - if !(s.TopMsgID == 0) { + if !(s.ReplyTo == nil) { return false } if !(s.Peer == nil) { @@ -106,6 +105,9 @@ func (s *MessagesSaveDraftRequest) Zero() bool { if !(s.Entities == nil) { return false } + if !(s.Media == nil) { + return false + } return true } @@ -122,19 +124,17 @@ func (s *MessagesSaveDraftRequest) String() string { // FillFrom fills MessagesSaveDraftRequest from given interface. func (s *MessagesSaveDraftRequest) FillFrom(from interface { GetNoWebpage() (value bool) - GetReplyToMsgID() (value int, ok bool) - GetTopMsgID() (value int, ok bool) + GetInvertMedia() (value bool) + GetReplyTo() (value InputReplyToClass, ok bool) GetPeer() (value InputPeerClass) GetMessage() (value string) GetEntities() (value []MessageEntityClass, ok bool) + GetMedia() (value InputMediaClass, ok bool) }) { s.NoWebpage = from.GetNoWebpage() - if val, ok := from.GetReplyToMsgID(); ok { - s.ReplyToMsgID = val - } - - if val, ok := from.GetTopMsgID(); ok { - s.TopMsgID = val + s.InvertMedia = from.GetInvertMedia() + if val, ok := from.GetReplyTo(); ok { + s.ReplyTo = val } s.Peer = from.GetPeer() @@ -143,6 +143,10 @@ func (s *MessagesSaveDraftRequest) FillFrom(from interface { s.Entities = val } + if val, ok := from.GetMedia(); ok { + s.Media = val + } + } // TypeID returns type id in TL schema. @@ -174,14 +178,14 @@ func (s *MessagesSaveDraftRequest) TypeInfo() tdp.Type { Null: !s.Flags.Has(1), }, { - Name: "ReplyToMsgID", - SchemaName: "reply_to_msg_id", - Null: !s.Flags.Has(0), + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !s.Flags.Has(6), }, { - Name: "TopMsgID", - SchemaName: "top_msg_id", - Null: !s.Flags.Has(2), + Name: "ReplyTo", + SchemaName: "reply_to", + Null: !s.Flags.Has(4), }, { Name: "Peer", @@ -196,6 +200,11 @@ func (s *MessagesSaveDraftRequest) TypeInfo() tdp.Type { SchemaName: "entities", Null: !s.Flags.Has(3), }, + { + Name: "Media", + SchemaName: "media", + Null: !s.Flags.Has(5), + }, } return typ } @@ -205,21 +214,24 @@ func (s *MessagesSaveDraftRequest) SetFlags() { if !(s.NoWebpage == false) { s.Flags.Set(1) } - if !(s.ReplyToMsgID == 0) { - s.Flags.Set(0) + if !(s.InvertMedia == false) { + s.Flags.Set(6) } - if !(s.TopMsgID == 0) { - s.Flags.Set(2) + if !(s.ReplyTo == nil) { + s.Flags.Set(4) } if !(s.Entities == nil) { s.Flags.Set(3) } + if !(s.Media == nil) { + s.Flags.Set(5) + } } // Encode implements bin.Encoder. func (s *MessagesSaveDraftRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.saveDraft#b4331e3f as nil") + return fmt.Errorf("can't encode messages.saveDraft#7ff3b806 as nil") } b.PutID(MessagesSaveDraftRequestTypeID) return s.EncodeBare(b) @@ -228,46 +240,56 @@ func (s *MessagesSaveDraftRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSaveDraftRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.saveDraft#b4331e3f as nil") + return fmt.Errorf("can't encode messages.saveDraft#7ff3b806 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.saveDraft#b4331e3f: field flags: %w", err) - } - if s.Flags.Has(0) { - b.PutInt(s.ReplyToMsgID) + return fmt.Errorf("unable to encode messages.saveDraft#7ff3b806: field flags: %w", err) } - if s.Flags.Has(2) { - b.PutInt(s.TopMsgID) + if s.Flags.Has(4) { + if s.ReplyTo == nil { + return fmt.Errorf("unable to encode messages.saveDraft#7ff3b806: field reply_to is nil") + } + if err := s.ReplyTo.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.saveDraft#7ff3b806: field reply_to: %w", err) + } } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.saveDraft#b4331e3f: field peer is nil") + return fmt.Errorf("unable to encode messages.saveDraft#7ff3b806: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.saveDraft#b4331e3f: field peer: %w", err) + return fmt.Errorf("unable to encode messages.saveDraft#7ff3b806: field peer: %w", err) } b.PutString(s.Message) if s.Flags.Has(3) { b.PutVectorHeader(len(s.Entities)) for idx, v := range s.Entities { if v == nil { - return fmt.Errorf("unable to encode messages.saveDraft#b4331e3f: field entities element with index %d is nil", idx) + return fmt.Errorf("unable to encode messages.saveDraft#7ff3b806: field entities element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.saveDraft#b4331e3f: field entities element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.saveDraft#7ff3b806: field entities element with index %d: %w", idx, err) } } } + if s.Flags.Has(5) { + if s.Media == nil { + return fmt.Errorf("unable to encode messages.saveDraft#7ff3b806: field media is nil") + } + if err := s.Media.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.saveDraft#7ff3b806: field media: %w", err) + } + } return nil } // Decode implements bin.Decoder. func (s *MessagesSaveDraftRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.saveDraft#b4331e3f to nil") + return fmt.Errorf("can't decode messages.saveDraft#7ff3b806 to nil") } if err := b.ConsumeID(MessagesSaveDraftRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#7ff3b806: %w", err) } return s.DecodeBare(b) } @@ -275,46 +297,40 @@ func (s *MessagesSaveDraftRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSaveDraftRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.saveDraft#b4331e3f to nil") + return fmt.Errorf("can't decode messages.saveDraft#7ff3b806 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field flags: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#7ff3b806: field flags: %w", err) } } s.NoWebpage = s.Flags.Has(1) - if s.Flags.Has(0) { - value, err := b.Int() + s.InvertMedia = s.Flags.Has(6) + if s.Flags.Has(4) { + value, err := DecodeInputReplyTo(b) if err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field reply_to_msg_id: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#7ff3b806: field reply_to: %w", err) } - s.ReplyToMsgID = value - } - if s.Flags.Has(2) { - value, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field top_msg_id: %w", err) - } - s.TopMsgID = value + s.ReplyTo = value } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field peer: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#7ff3b806: field peer: %w", err) } s.Peer = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field message: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#7ff3b806: field message: %w", err) } s.Message = value } if s.Flags.Has(3) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field entities: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#7ff3b806: field entities: %w", err) } if headerLen > 0 { @@ -323,11 +339,18 @@ func (s *MessagesSaveDraftRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageEntity(b) if err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field entities: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#7ff3b806: field entities: %w", err) } s.Entities = append(s.Entities, value) } } + if s.Flags.Has(5) { + value, err := DecodeInputMedia(b) + if err != nil { + return fmt.Errorf("unable to decode messages.saveDraft#7ff3b806: field media: %w", err) + } + s.Media = value + } return nil } @@ -350,40 +373,41 @@ func (s *MessagesSaveDraftRequest) GetNoWebpage() (value bool) { return s.Flags.Has(1) } -// SetReplyToMsgID sets value of ReplyToMsgID conditional field. -func (s *MessagesSaveDraftRequest) SetReplyToMsgID(value int) { - s.Flags.Set(0) - s.ReplyToMsgID = value +// SetInvertMedia sets value of InvertMedia conditional field. +func (s *MessagesSaveDraftRequest) SetInvertMedia(value bool) { + if value { + s.Flags.Set(6) + s.InvertMedia = true + } else { + s.Flags.Unset(6) + s.InvertMedia = false + } } -// GetReplyToMsgID returns value of ReplyToMsgID conditional field and -// boolean which is true if field was set. -func (s *MessagesSaveDraftRequest) GetReplyToMsgID() (value int, ok bool) { +// GetInvertMedia returns value of InvertMedia conditional field. +func (s *MessagesSaveDraftRequest) GetInvertMedia() (value bool) { if s == nil { return } - if !s.Flags.Has(0) { - return value, false - } - return s.ReplyToMsgID, true + return s.Flags.Has(6) } -// SetTopMsgID sets value of TopMsgID conditional field. -func (s *MessagesSaveDraftRequest) SetTopMsgID(value int) { - s.Flags.Set(2) - s.TopMsgID = value +// SetReplyTo sets value of ReplyTo conditional field. +func (s *MessagesSaveDraftRequest) SetReplyTo(value InputReplyToClass) { + s.Flags.Set(4) + s.ReplyTo = value } -// GetTopMsgID returns value of TopMsgID conditional field and +// GetReplyTo returns value of ReplyTo conditional field and // boolean which is true if field was set. -func (s *MessagesSaveDraftRequest) GetTopMsgID() (value int, ok bool) { +func (s *MessagesSaveDraftRequest) GetReplyTo() (value InputReplyToClass, ok bool) { if s == nil { return } - if !s.Flags.Has(2) { + if !s.Flags.Has(4) { return value, false } - return s.TopMsgID, true + return s.ReplyTo, true } // GetPeer returns value of Peer field. @@ -420,6 +444,24 @@ func (s *MessagesSaveDraftRequest) GetEntities() (value []MessageEntityClass, ok return s.Entities, true } +// SetMedia sets value of Media conditional field. +func (s *MessagesSaveDraftRequest) SetMedia(value InputMediaClass) { + s.Flags.Set(5) + s.Media = value +} + +// GetMedia returns value of Media conditional field and +// boolean which is true if field was set. +func (s *MessagesSaveDraftRequest) GetMedia() (value InputMediaClass, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(5) { + return value, false + } + return s.Media, true +} + // MapEntities returns field Entities wrapped in MessageEntityClassArray helper. func (s *MessagesSaveDraftRequest) MapEntities() (value MessageEntityClassArray, ok bool) { if !s.Flags.Has(3) { @@ -428,7 +470,7 @@ func (s *MessagesSaveDraftRequest) MapEntities() (value MessageEntityClassArray, return MessageEntityClassArray(s.Entities), true } -// MessagesSaveDraft invokes method messages.saveDraft#b4331e3f returning error if any. +// MessagesSaveDraft invokes method messages.saveDraft#7ff3b806 returning error if any. // Save a message draft¹ associated to a chat. // // Links: diff --git a/tg/tl_messages_send_media_gen.go b/tg/tl_messages_send_media_gen.go index b753912e9f..ecf6a31953 100644 --- a/tg/tl_messages_send_media_gen.go +++ b/tg/tl_messages_send_media_gen.go @@ -58,6 +58,8 @@ type MessagesSendMediaRequest struct { // Links: // 1) https://core.telegram.org/api/stickers#recent-stickersets UpdateStickersetsOrder bool + // InvertMedia field of MessagesSendMediaRequest. + InvertMedia bool // Destination Peer InputPeerClass // ReplyTo field of MessagesSendMediaRequest. @@ -127,6 +129,9 @@ func (s *MessagesSendMediaRequest) Zero() bool { if !(s.UpdateStickersetsOrder == false) { return false } + if !(s.InvertMedia == false) { + return false + } if !(s.Peer == nil) { return false } @@ -174,6 +179,7 @@ func (s *MessagesSendMediaRequest) FillFrom(from interface { GetClearDraft() (value bool) GetNoforwards() (value bool) GetUpdateStickersetsOrder() (value bool) + GetInvertMedia() (value bool) GetPeer() (value InputPeerClass) GetReplyTo() (value InputReplyToClass, ok bool) GetMedia() (value InputMediaClass) @@ -189,6 +195,7 @@ func (s *MessagesSendMediaRequest) FillFrom(from interface { s.ClearDraft = from.GetClearDraft() s.Noforwards = from.GetNoforwards() s.UpdateStickersetsOrder = from.GetUpdateStickersetsOrder() + s.InvertMedia = from.GetInvertMedia() s.Peer = from.GetPeer() if val, ok := from.GetReplyTo(); ok { s.ReplyTo = val @@ -263,6 +270,11 @@ func (s *MessagesSendMediaRequest) TypeInfo() tdp.Type { SchemaName: "update_stickersets_order", Null: !s.Flags.Has(15), }, + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !s.Flags.Has(16), + }, { Name: "Peer", SchemaName: "peer", @@ -325,6 +337,9 @@ func (s *MessagesSendMediaRequest) SetFlags() { if !(s.UpdateStickersetsOrder == false) { s.Flags.Set(15) } + if !(s.InvertMedia == false) { + s.Flags.Set(16) + } if !(s.ReplyTo == nil) { s.Flags.Set(0) } @@ -441,6 +456,7 @@ func (s *MessagesSendMediaRequest) DecodeBare(b *bin.Buffer) error { s.ClearDraft = s.Flags.Has(7) s.Noforwards = s.Flags.Has(14) s.UpdateStickersetsOrder = s.Flags.Has(15) + s.InvertMedia = s.Flags.Has(16) { value, err := DecodeInputPeer(b) if err != nil { @@ -612,6 +628,25 @@ func (s *MessagesSendMediaRequest) GetUpdateStickersetsOrder() (value bool) { return s.Flags.Has(15) } +// SetInvertMedia sets value of InvertMedia conditional field. +func (s *MessagesSendMediaRequest) SetInvertMedia(value bool) { + if value { + s.Flags.Set(16) + s.InvertMedia = true + } else { + s.Flags.Unset(16) + s.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (s *MessagesSendMediaRequest) GetInvertMedia() (value bool) { + if s == nil { + return + } + return s.Flags.Has(16) +} + // 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 93768e8b5c..64e4283f64 100644 --- a/tg/tl_messages_send_message_gen.go +++ b/tg/tl_messages_send_message_gen.go @@ -60,6 +60,8 @@ type MessagesSendMessageRequest struct { // Links: // 1) https://core.telegram.org/api/stickers#recent-stickersets UpdateStickersetsOrder bool + // InvertMedia field of MessagesSendMessageRequest. + InvertMedia bool // The destination where the message will be sent Peer InputPeerClass // ReplyTo field of MessagesSendMessageRequest. @@ -130,6 +132,9 @@ func (s *MessagesSendMessageRequest) Zero() bool { if !(s.UpdateStickersetsOrder == false) { return false } + if !(s.InvertMedia == false) { + return false + } if !(s.Peer == nil) { return false } @@ -175,6 +180,7 @@ func (s *MessagesSendMessageRequest) FillFrom(from interface { GetClearDraft() (value bool) GetNoforwards() (value bool) GetUpdateStickersetsOrder() (value bool) + GetInvertMedia() (value bool) GetPeer() (value InputPeerClass) GetReplyTo() (value InputReplyToClass, ok bool) GetMessage() (value string) @@ -190,6 +196,7 @@ func (s *MessagesSendMessageRequest) FillFrom(from interface { s.ClearDraft = from.GetClearDraft() s.Noforwards = from.GetNoforwards() s.UpdateStickersetsOrder = from.GetUpdateStickersetsOrder() + s.InvertMedia = from.GetInvertMedia() s.Peer = from.GetPeer() if val, ok := from.GetReplyTo(); ok { s.ReplyTo = val @@ -268,6 +275,11 @@ func (s *MessagesSendMessageRequest) TypeInfo() tdp.Type { SchemaName: "update_stickersets_order", Null: !s.Flags.Has(15), }, + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !s.Flags.Has(16), + }, { Name: "Peer", SchemaName: "peer", @@ -329,6 +341,9 @@ func (s *MessagesSendMessageRequest) SetFlags() { if !(s.UpdateStickersetsOrder == false) { s.Flags.Set(15) } + if !(s.InvertMedia == false) { + s.Flags.Set(16) + } if !(s.ReplyTo == nil) { s.Flags.Set(0) } @@ -440,6 +455,7 @@ func (s *MessagesSendMessageRequest) DecodeBare(b *bin.Buffer) error { s.ClearDraft = s.Flags.Has(7) s.Noforwards = s.Flags.Has(14) s.UpdateStickersetsOrder = s.Flags.Has(15) + s.InvertMedia = s.Flags.Has(16) { value, err := DecodeInputPeer(b) if err != nil { @@ -623,6 +639,25 @@ func (s *MessagesSendMessageRequest) GetUpdateStickersetsOrder() (value bool) { return s.Flags.Has(15) } +// SetInvertMedia sets value of InvertMedia conditional field. +func (s *MessagesSendMessageRequest) SetInvertMedia(value bool) { + if value { + s.Flags.Set(16) + s.InvertMedia = true + } else { + s.Flags.Unset(16) + s.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (s *MessagesSendMessageRequest) GetInvertMedia() (value bool) { + if s == nil { + return + } + return s.Flags.Has(16) +} + // 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 21bea04f78..f041ec59c1 100644 --- a/tg/tl_messages_send_multi_media_gen.go +++ b/tg/tl_messages_send_multi_media_gen.go @@ -64,6 +64,8 @@ type MessagesSendMultiMediaRequest struct { // Links: // 1) https://core.telegram.org/api/stickers#recent-stickersets UpdateStickersetsOrder bool + // InvertMedia field of MessagesSendMultiMediaRequest. + InvertMedia bool // The destination chat Peer InputPeerClass // ReplyTo field of MessagesSendMultiMediaRequest. @@ -119,6 +121,9 @@ func (s *MessagesSendMultiMediaRequest) Zero() bool { if !(s.UpdateStickersetsOrder == false) { return false } + if !(s.InvertMedia == false) { + return false + } if !(s.Peer == nil) { return false } @@ -154,6 +159,7 @@ func (s *MessagesSendMultiMediaRequest) FillFrom(from interface { GetClearDraft() (value bool) GetNoforwards() (value bool) GetUpdateStickersetsOrder() (value bool) + GetInvertMedia() (value bool) GetPeer() (value InputPeerClass) GetReplyTo() (value InputReplyToClass, ok bool) GetMultiMedia() (value []InputSingleMedia) @@ -165,6 +171,7 @@ func (s *MessagesSendMultiMediaRequest) FillFrom(from interface { s.ClearDraft = from.GetClearDraft() s.Noforwards = from.GetNoforwards() s.UpdateStickersetsOrder = from.GetUpdateStickersetsOrder() + s.InvertMedia = from.GetInvertMedia() s.Peer = from.GetPeer() if val, ok := from.GetReplyTo(); ok { s.ReplyTo = val @@ -229,6 +236,11 @@ func (s *MessagesSendMultiMediaRequest) TypeInfo() tdp.Type { SchemaName: "update_stickersets_order", Null: !s.Flags.Has(15), }, + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !s.Flags.Has(16), + }, { Name: "Peer", SchemaName: "peer", @@ -273,6 +285,9 @@ func (s *MessagesSendMultiMediaRequest) SetFlags() { if !(s.UpdateStickersetsOrder == false) { s.Flags.Set(15) } + if !(s.InvertMedia == false) { + s.Flags.Set(16) + } if !(s.ReplyTo == nil) { s.Flags.Set(0) } @@ -362,6 +377,7 @@ func (s *MessagesSendMultiMediaRequest) DecodeBare(b *bin.Buffer) error { s.ClearDraft = s.Flags.Has(7) s.Noforwards = s.Flags.Has(14) s.UpdateStickersetsOrder = s.Flags.Has(15) + s.InvertMedia = s.Flags.Has(16) { value, err := DecodeInputPeer(b) if err != nil { @@ -505,6 +521,25 @@ func (s *MessagesSendMultiMediaRequest) GetUpdateStickersetsOrder() (value bool) return s.Flags.Has(15) } +// SetInvertMedia sets value of InvertMedia conditional field. +func (s *MessagesSendMultiMediaRequest) SetInvertMedia(value bool) { + if value { + s.Flags.Set(16) + s.InvertMedia = true + } else { + s.Flags.Unset(16) + s.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (s *MessagesSendMultiMediaRequest) GetInvertMedia() (value bool) { + if s == nil { + return + } + return s.Flags.Has(16) +} + // GetPeer returns value of Peer field. func (s *MessagesSendMultiMediaRequest) GetPeer() (value InputPeerClass) { if s == nil { diff --git a/tg/tl_my_boost_gen.go b/tg/tl_my_boost_gen.go new file mode 100644 index 0000000000..623e3973d5 --- /dev/null +++ b/tg/tl_my_boost_gen.go @@ -0,0 +1,334 @@ +// 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{} +) + +// MyBoost represents TL type `myBoost#c448415c`. +// +// See https://core.telegram.org/constructor/myBoost for reference. +type MyBoost struct { + // Flags field of MyBoost. + Flags bin.Fields + // Slot field of MyBoost. + Slot int + // Peer field of MyBoost. + // + // Use SetPeer and GetPeer helpers. + Peer PeerClass + // Date field of MyBoost. + Date int + // Expires field of MyBoost. + Expires int + // CooldownUntilDate field of MyBoost. + // + // Use SetCooldownUntilDate and GetCooldownUntilDate helpers. + CooldownUntilDate int +} + +// MyBoostTypeID is TL type id of MyBoost. +const MyBoostTypeID = 0xc448415c + +// Ensuring interfaces in compile-time for MyBoost. +var ( + _ bin.Encoder = &MyBoost{} + _ bin.Decoder = &MyBoost{} + _ bin.BareEncoder = &MyBoost{} + _ bin.BareDecoder = &MyBoost{} +) + +func (m *MyBoost) Zero() bool { + if m == nil { + return true + } + if !(m.Flags.Zero()) { + return false + } + if !(m.Slot == 0) { + return false + } + if !(m.Peer == nil) { + return false + } + if !(m.Date == 0) { + return false + } + if !(m.Expires == 0) { + return false + } + if !(m.CooldownUntilDate == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MyBoost) String() string { + if m == nil { + return "MyBoost(nil)" + } + type Alias MyBoost + return fmt.Sprintf("MyBoost%+v", Alias(*m)) +} + +// FillFrom fills MyBoost from given interface. +func (m *MyBoost) FillFrom(from interface { + GetSlot() (value int) + GetPeer() (value PeerClass, ok bool) + GetDate() (value int) + GetExpires() (value int) + GetCooldownUntilDate() (value int, ok bool) +}) { + m.Slot = from.GetSlot() + if val, ok := from.GetPeer(); ok { + m.Peer = val + } + + m.Date = from.GetDate() + m.Expires = from.GetExpires() + if val, ok := from.GetCooldownUntilDate(); ok { + m.CooldownUntilDate = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MyBoost) TypeID() uint32 { + return MyBoostTypeID +} + +// TypeName returns name of type in TL schema. +func (*MyBoost) TypeName() string { + return "myBoost" +} + +// TypeInfo returns info about TL type. +func (m *MyBoost) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "myBoost", + ID: MyBoostTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Slot", + SchemaName: "slot", + }, + { + Name: "Peer", + SchemaName: "peer", + Null: !m.Flags.Has(0), + }, + { + Name: "Date", + SchemaName: "date", + }, + { + Name: "Expires", + SchemaName: "expires", + }, + { + Name: "CooldownUntilDate", + SchemaName: "cooldown_until_date", + Null: !m.Flags.Has(1), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (m *MyBoost) SetFlags() { + if !(m.Peer == nil) { + m.Flags.Set(0) + } + if !(m.CooldownUntilDate == 0) { + m.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (m *MyBoost) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode myBoost#c448415c as nil") + } + b.PutID(MyBoostTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MyBoost) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode myBoost#c448415c as nil") + } + m.SetFlags() + if err := m.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode myBoost#c448415c: field flags: %w", err) + } + b.PutInt(m.Slot) + if m.Flags.Has(0) { + if m.Peer == nil { + return fmt.Errorf("unable to encode myBoost#c448415c: field peer is nil") + } + if err := m.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode myBoost#c448415c: field peer: %w", err) + } + } + b.PutInt(m.Date) + b.PutInt(m.Expires) + if m.Flags.Has(1) { + b.PutInt(m.CooldownUntilDate) + } + return nil +} + +// Decode implements bin.Decoder. +func (m *MyBoost) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode myBoost#c448415c to nil") + } + if err := b.ConsumeID(MyBoostTypeID); err != nil { + return fmt.Errorf("unable to decode myBoost#c448415c: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MyBoost) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode myBoost#c448415c to nil") + } + { + if err := m.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode myBoost#c448415c: field flags: %w", err) + } + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode myBoost#c448415c: field slot: %w", err) + } + m.Slot = value + } + if m.Flags.Has(0) { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode myBoost#c448415c: field peer: %w", err) + } + m.Peer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode myBoost#c448415c: field date: %w", err) + } + m.Date = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode myBoost#c448415c: field expires: %w", err) + } + m.Expires = value + } + if m.Flags.Has(1) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode myBoost#c448415c: field cooldown_until_date: %w", err) + } + m.CooldownUntilDate = value + } + return nil +} + +// GetSlot returns value of Slot field. +func (m *MyBoost) GetSlot() (value int) { + if m == nil { + return + } + return m.Slot +} + +// SetPeer sets value of Peer conditional field. +func (m *MyBoost) SetPeer(value PeerClass) { + m.Flags.Set(0) + m.Peer = value +} + +// GetPeer returns value of Peer conditional field and +// boolean which is true if field was set. +func (m *MyBoost) GetPeer() (value PeerClass, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(0) { + return value, false + } + return m.Peer, true +} + +// GetDate returns value of Date field. +func (m *MyBoost) GetDate() (value int) { + if m == nil { + return + } + return m.Date +} + +// GetExpires returns value of Expires field. +func (m *MyBoost) GetExpires() (value int) { + if m == nil { + return + } + return m.Expires +} + +// SetCooldownUntilDate sets value of CooldownUntilDate conditional field. +func (m *MyBoost) SetCooldownUntilDate(value int) { + m.Flags.Set(1) + m.CooldownUntilDate = value +} + +// GetCooldownUntilDate returns value of CooldownUntilDate conditional field and +// boolean which is true if field was set. +func (m *MyBoost) GetCooldownUntilDate() (value int, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(1) { + return value, false + } + return m.CooldownUntilDate, true +} diff --git a/tg/tl_stories_can_apply_boost_slices_gen.go b/tg/tl_my_boost_slices_gen.go similarity index 100% rename from tg/tl_stories_can_apply_boost_slices_gen.go rename to tg/tl_my_boost_slices_gen.go diff --git a/tg/tl_payments_apply_gift_code_gen.go b/tg/tl_payments_apply_gift_code_gen.go new file mode 100644 index 0000000000..1b35a1cef1 --- /dev/null +++ b/tg/tl_payments_apply_gift_code_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{} +) + +// PaymentsApplyGiftCodeRequest represents TL type `payments.applyGiftCode#f6e26854`. +// +// See https://core.telegram.org/method/payments.applyGiftCode for reference. +type PaymentsApplyGiftCodeRequest struct { + // Slug field of PaymentsApplyGiftCodeRequest. + Slug string +} + +// PaymentsApplyGiftCodeRequestTypeID is TL type id of PaymentsApplyGiftCodeRequest. +const PaymentsApplyGiftCodeRequestTypeID = 0xf6e26854 + +// Ensuring interfaces in compile-time for PaymentsApplyGiftCodeRequest. +var ( + _ bin.Encoder = &PaymentsApplyGiftCodeRequest{} + _ bin.Decoder = &PaymentsApplyGiftCodeRequest{} + _ bin.BareEncoder = &PaymentsApplyGiftCodeRequest{} + _ bin.BareDecoder = &PaymentsApplyGiftCodeRequest{} +) + +func (a *PaymentsApplyGiftCodeRequest) Zero() bool { + if a == nil { + return true + } + if !(a.Slug == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *PaymentsApplyGiftCodeRequest) String() string { + if a == nil { + return "PaymentsApplyGiftCodeRequest(nil)" + } + type Alias PaymentsApplyGiftCodeRequest + return fmt.Sprintf("PaymentsApplyGiftCodeRequest%+v", Alias(*a)) +} + +// FillFrom fills PaymentsApplyGiftCodeRequest from given interface. +func (a *PaymentsApplyGiftCodeRequest) FillFrom(from interface { + GetSlug() (value string) +}) { + a.Slug = from.GetSlug() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsApplyGiftCodeRequest) TypeID() uint32 { + return PaymentsApplyGiftCodeRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsApplyGiftCodeRequest) TypeName() string { + return "payments.applyGiftCode" +} + +// TypeInfo returns info about TL type. +func (a *PaymentsApplyGiftCodeRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.applyGiftCode", + ID: PaymentsApplyGiftCodeRequestTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Slug", + SchemaName: "slug", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (a *PaymentsApplyGiftCodeRequest) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode payments.applyGiftCode#f6e26854 as nil") + } + b.PutID(PaymentsApplyGiftCodeRequestTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *PaymentsApplyGiftCodeRequest) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode payments.applyGiftCode#f6e26854 as nil") + } + b.PutString(a.Slug) + return nil +} + +// Decode implements bin.Decoder. +func (a *PaymentsApplyGiftCodeRequest) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode payments.applyGiftCode#f6e26854 to nil") + } + if err := b.ConsumeID(PaymentsApplyGiftCodeRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.applyGiftCode#f6e26854: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *PaymentsApplyGiftCodeRequest) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode payments.applyGiftCode#f6e26854 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.applyGiftCode#f6e26854: field slug: %w", err) + } + a.Slug = value + } + return nil +} + +// GetSlug returns value of Slug field. +func (a *PaymentsApplyGiftCodeRequest) GetSlug() (value string) { + if a == nil { + return + } + return a.Slug +} + +// PaymentsApplyGiftCode invokes method payments.applyGiftCode#f6e26854 returning error if any. +// +// See https://core.telegram.org/method/payments.applyGiftCode for reference. +func (c *Client) PaymentsApplyGiftCode(ctx context.Context, slug string) (UpdatesClass, error) { + var result UpdatesBox + + request := &PaymentsApplyGiftCodeRequest{ + Slug: slug, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Updates, nil +} diff --git a/tg/tl_stories_get_boosters_list_slices_gen.go b/tg/tl_payments_apply_gift_code_slices_gen.go similarity index 100% rename from tg/tl_stories_get_boosters_list_slices_gen.go rename to tg/tl_payments_apply_gift_code_slices_gen.go diff --git a/tg/tl_payments_check_gift_code_gen.go b/tg/tl_payments_check_gift_code_gen.go new file mode 100644 index 0000000000..a35f02d0e2 --- /dev/null +++ b/tg/tl_payments_check_gift_code_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{} +) + +// PaymentsCheckGiftCodeRequest represents TL type `payments.checkGiftCode#8e51b4c1`. +// +// See https://core.telegram.org/method/payments.checkGiftCode for reference. +type PaymentsCheckGiftCodeRequest struct { + // Slug field of PaymentsCheckGiftCodeRequest. + Slug string +} + +// PaymentsCheckGiftCodeRequestTypeID is TL type id of PaymentsCheckGiftCodeRequest. +const PaymentsCheckGiftCodeRequestTypeID = 0x8e51b4c1 + +// Ensuring interfaces in compile-time for PaymentsCheckGiftCodeRequest. +var ( + _ bin.Encoder = &PaymentsCheckGiftCodeRequest{} + _ bin.Decoder = &PaymentsCheckGiftCodeRequest{} + _ bin.BareEncoder = &PaymentsCheckGiftCodeRequest{} + _ bin.BareDecoder = &PaymentsCheckGiftCodeRequest{} +) + +func (c *PaymentsCheckGiftCodeRequest) Zero() bool { + if c == nil { + return true + } + if !(c.Slug == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *PaymentsCheckGiftCodeRequest) String() string { + if c == nil { + return "PaymentsCheckGiftCodeRequest(nil)" + } + type Alias PaymentsCheckGiftCodeRequest + return fmt.Sprintf("PaymentsCheckGiftCodeRequest%+v", Alias(*c)) +} + +// FillFrom fills PaymentsCheckGiftCodeRequest from given interface. +func (c *PaymentsCheckGiftCodeRequest) FillFrom(from interface { + GetSlug() (value string) +}) { + c.Slug = from.GetSlug() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsCheckGiftCodeRequest) TypeID() uint32 { + return PaymentsCheckGiftCodeRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsCheckGiftCodeRequest) TypeName() string { + return "payments.checkGiftCode" +} + +// TypeInfo returns info about TL type. +func (c *PaymentsCheckGiftCodeRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.checkGiftCode", + ID: PaymentsCheckGiftCodeRequestTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Slug", + SchemaName: "slug", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *PaymentsCheckGiftCodeRequest) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode payments.checkGiftCode#8e51b4c1 as nil") + } + b.PutID(PaymentsCheckGiftCodeRequestTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *PaymentsCheckGiftCodeRequest) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode payments.checkGiftCode#8e51b4c1 as nil") + } + b.PutString(c.Slug) + return nil +} + +// Decode implements bin.Decoder. +func (c *PaymentsCheckGiftCodeRequest) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode payments.checkGiftCode#8e51b4c1 to nil") + } + if err := b.ConsumeID(PaymentsCheckGiftCodeRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.checkGiftCode#8e51b4c1: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *PaymentsCheckGiftCodeRequest) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode payments.checkGiftCode#8e51b4c1 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.checkGiftCode#8e51b4c1: field slug: %w", err) + } + c.Slug = value + } + return nil +} + +// GetSlug returns value of Slug field. +func (c *PaymentsCheckGiftCodeRequest) GetSlug() (value string) { + if c == nil { + return + } + return c.Slug +} + +// PaymentsCheckGiftCode invokes method payments.checkGiftCode#8e51b4c1 returning error if any. +// +// See https://core.telegram.org/method/payments.checkGiftCode for reference. +func (c *Client) PaymentsCheckGiftCode(ctx context.Context, slug string) (*PaymentsCheckedGiftCode, error) { + var result PaymentsCheckedGiftCode + + request := &PaymentsCheckGiftCodeRequest{ + Slug: slug, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_stories_get_boosts_status_slices_gen.go b/tg/tl_payments_check_gift_code_slices_gen.go similarity index 100% rename from tg/tl_stories_get_boosts_status_slices_gen.go rename to tg/tl_payments_check_gift_code_slices_gen.go diff --git a/tg/tl_payments_checked_gift_code_gen.go b/tg/tl_payments_checked_gift_code_gen.go new file mode 100644 index 0000000000..a75c3d563c --- /dev/null +++ b/tg/tl_payments_checked_gift_code_gen.go @@ -0,0 +1,517 @@ +// 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{} +) + +// PaymentsCheckedGiftCode represents TL type `payments.checkedGiftCode#b722f158`. +// +// See https://core.telegram.org/constructor/payments.checkedGiftCode for reference. +type PaymentsCheckedGiftCode struct { + // Flags field of PaymentsCheckedGiftCode. + Flags bin.Fields + // ViaGiveaway field of PaymentsCheckedGiftCode. + ViaGiveaway bool + // FromID field of PaymentsCheckedGiftCode. + FromID PeerClass + // GiveawayMsgID field of PaymentsCheckedGiftCode. + // + // Use SetGiveawayMsgID and GetGiveawayMsgID helpers. + GiveawayMsgID int + // ToID field of PaymentsCheckedGiftCode. + // + // Use SetToID and GetToID helpers. + ToID int64 + // Date field of PaymentsCheckedGiftCode. + Date int + // Months field of PaymentsCheckedGiftCode. + Months int + // UsedDate field of PaymentsCheckedGiftCode. + // + // Use SetUsedDate and GetUsedDate helpers. + UsedDate int + // Chats field of PaymentsCheckedGiftCode. + Chats []ChatClass + // Users field of PaymentsCheckedGiftCode. + Users []UserClass +} + +// PaymentsCheckedGiftCodeTypeID is TL type id of PaymentsCheckedGiftCode. +const PaymentsCheckedGiftCodeTypeID = 0xb722f158 + +// Ensuring interfaces in compile-time for PaymentsCheckedGiftCode. +var ( + _ bin.Encoder = &PaymentsCheckedGiftCode{} + _ bin.Decoder = &PaymentsCheckedGiftCode{} + _ bin.BareEncoder = &PaymentsCheckedGiftCode{} + _ bin.BareDecoder = &PaymentsCheckedGiftCode{} +) + +func (c *PaymentsCheckedGiftCode) Zero() bool { + if c == nil { + return true + } + if !(c.Flags.Zero()) { + return false + } + if !(c.ViaGiveaway == false) { + return false + } + if !(c.FromID == nil) { + return false + } + if !(c.GiveawayMsgID == 0) { + return false + } + if !(c.ToID == 0) { + return false + } + if !(c.Date == 0) { + return false + } + if !(c.Months == 0) { + return false + } + if !(c.UsedDate == 0) { + return false + } + if !(c.Chats == nil) { + return false + } + if !(c.Users == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *PaymentsCheckedGiftCode) String() string { + if c == nil { + return "PaymentsCheckedGiftCode(nil)" + } + type Alias PaymentsCheckedGiftCode + return fmt.Sprintf("PaymentsCheckedGiftCode%+v", Alias(*c)) +} + +// FillFrom fills PaymentsCheckedGiftCode from given interface. +func (c *PaymentsCheckedGiftCode) FillFrom(from interface { + GetViaGiveaway() (value bool) + GetFromID() (value PeerClass) + GetGiveawayMsgID() (value int, ok bool) + GetToID() (value int64, ok bool) + GetDate() (value int) + GetMonths() (value int) + GetUsedDate() (value int, ok bool) + GetChats() (value []ChatClass) + GetUsers() (value []UserClass) +}) { + c.ViaGiveaway = from.GetViaGiveaway() + c.FromID = from.GetFromID() + if val, ok := from.GetGiveawayMsgID(); ok { + c.GiveawayMsgID = val + } + + if val, ok := from.GetToID(); ok { + c.ToID = val + } + + c.Date = from.GetDate() + c.Months = from.GetMonths() + if val, ok := from.GetUsedDate(); ok { + c.UsedDate = val + } + + c.Chats = from.GetChats() + c.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsCheckedGiftCode) TypeID() uint32 { + return PaymentsCheckedGiftCodeTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsCheckedGiftCode) TypeName() string { + return "payments.checkedGiftCode" +} + +// TypeInfo returns info about TL type. +func (c *PaymentsCheckedGiftCode) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.checkedGiftCode", + ID: PaymentsCheckedGiftCodeTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ViaGiveaway", + SchemaName: "via_giveaway", + Null: !c.Flags.Has(2), + }, + { + Name: "FromID", + SchemaName: "from_id", + }, + { + Name: "GiveawayMsgID", + SchemaName: "giveaway_msg_id", + Null: !c.Flags.Has(3), + }, + { + Name: "ToID", + SchemaName: "to_id", + Null: !c.Flags.Has(0), + }, + { + Name: "Date", + SchemaName: "date", + }, + { + Name: "Months", + SchemaName: "months", + }, + { + Name: "UsedDate", + SchemaName: "used_date", + Null: !c.Flags.Has(1), + }, + { + Name: "Chats", + SchemaName: "chats", + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (c *PaymentsCheckedGiftCode) SetFlags() { + if !(c.ViaGiveaway == false) { + c.Flags.Set(2) + } + if !(c.GiveawayMsgID == 0) { + c.Flags.Set(3) + } + if !(c.ToID == 0) { + c.Flags.Set(0) + } + if !(c.UsedDate == 0) { + c.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (c *PaymentsCheckedGiftCode) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode payments.checkedGiftCode#b722f158 as nil") + } + b.PutID(PaymentsCheckedGiftCodeTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *PaymentsCheckedGiftCode) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode payments.checkedGiftCode#b722f158 as nil") + } + c.SetFlags() + if err := c.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.checkedGiftCode#b722f158: field flags: %w", err) + } + if c.FromID == nil { + return fmt.Errorf("unable to encode payments.checkedGiftCode#b722f158: field from_id is nil") + } + if err := c.FromID.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.checkedGiftCode#b722f158: field from_id: %w", err) + } + if c.Flags.Has(3) { + b.PutInt(c.GiveawayMsgID) + } + if c.Flags.Has(0) { + b.PutLong(c.ToID) + } + b.PutInt(c.Date) + b.PutInt(c.Months) + if c.Flags.Has(1) { + b.PutInt(c.UsedDate) + } + b.PutVectorHeader(len(c.Chats)) + for idx, v := range c.Chats { + if v == nil { + return fmt.Errorf("unable to encode payments.checkedGiftCode#b722f158: field chats element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.checkedGiftCode#b722f158: field chats element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(c.Users)) + for idx, v := range c.Users { + if v == nil { + return fmt.Errorf("unable to encode payments.checkedGiftCode#b722f158: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.checkedGiftCode#b722f158: field users element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (c *PaymentsCheckedGiftCode) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode payments.checkedGiftCode#b722f158 to nil") + } + if err := b.ConsumeID(PaymentsCheckedGiftCodeTypeID); err != nil { + return fmt.Errorf("unable to decode payments.checkedGiftCode#b722f158: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *PaymentsCheckedGiftCode) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode payments.checkedGiftCode#b722f158 to nil") + } + { + if err := c.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.checkedGiftCode#b722f158: field flags: %w", err) + } + } + c.ViaGiveaway = c.Flags.Has(2) + { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode payments.checkedGiftCode#b722f158: field from_id: %w", err) + } + c.FromID = value + } + if c.Flags.Has(3) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.checkedGiftCode#b722f158: field giveaway_msg_id: %w", err) + } + c.GiveawayMsgID = value + } + if c.Flags.Has(0) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode payments.checkedGiftCode#b722f158: field to_id: %w", err) + } + c.ToID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.checkedGiftCode#b722f158: field date: %w", err) + } + c.Date = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.checkedGiftCode#b722f158: field months: %w", err) + } + c.Months = value + } + if c.Flags.Has(1) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.checkedGiftCode#b722f158: field used_date: %w", err) + } + c.UsedDate = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.checkedGiftCode#b722f158: field chats: %w", err) + } + + if headerLen > 0 { + c.Chats = make([]ChatClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeChat(b) + if err != nil { + return fmt.Errorf("unable to decode payments.checkedGiftCode#b722f158: field chats: %w", err) + } + c.Chats = append(c.Chats, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.checkedGiftCode#b722f158: field users: %w", err) + } + + if headerLen > 0 { + c.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeUser(b) + if err != nil { + return fmt.Errorf("unable to decode payments.checkedGiftCode#b722f158: field users: %w", err) + } + c.Users = append(c.Users, value) + } + } + return nil +} + +// SetViaGiveaway sets value of ViaGiveaway conditional field. +func (c *PaymentsCheckedGiftCode) SetViaGiveaway(value bool) { + if value { + c.Flags.Set(2) + c.ViaGiveaway = true + } else { + c.Flags.Unset(2) + c.ViaGiveaway = false + } +} + +// GetViaGiveaway returns value of ViaGiveaway conditional field. +func (c *PaymentsCheckedGiftCode) GetViaGiveaway() (value bool) { + if c == nil { + return + } + return c.Flags.Has(2) +} + +// GetFromID returns value of FromID field. +func (c *PaymentsCheckedGiftCode) GetFromID() (value PeerClass) { + if c == nil { + return + } + return c.FromID +} + +// SetGiveawayMsgID sets value of GiveawayMsgID conditional field. +func (c *PaymentsCheckedGiftCode) SetGiveawayMsgID(value int) { + c.Flags.Set(3) + c.GiveawayMsgID = value +} + +// GetGiveawayMsgID returns value of GiveawayMsgID conditional field and +// boolean which is true if field was set. +func (c *PaymentsCheckedGiftCode) GetGiveawayMsgID() (value int, ok bool) { + if c == nil { + return + } + if !c.Flags.Has(3) { + return value, false + } + return c.GiveawayMsgID, true +} + +// SetToID sets value of ToID conditional field. +func (c *PaymentsCheckedGiftCode) SetToID(value int64) { + c.Flags.Set(0) + c.ToID = value +} + +// GetToID returns value of ToID conditional field and +// boolean which is true if field was set. +func (c *PaymentsCheckedGiftCode) GetToID() (value int64, ok bool) { + if c == nil { + return + } + if !c.Flags.Has(0) { + return value, false + } + return c.ToID, true +} + +// GetDate returns value of Date field. +func (c *PaymentsCheckedGiftCode) GetDate() (value int) { + if c == nil { + return + } + return c.Date +} + +// GetMonths returns value of Months field. +func (c *PaymentsCheckedGiftCode) GetMonths() (value int) { + if c == nil { + return + } + return c.Months +} + +// SetUsedDate sets value of UsedDate conditional field. +func (c *PaymentsCheckedGiftCode) SetUsedDate(value int) { + c.Flags.Set(1) + c.UsedDate = value +} + +// GetUsedDate returns value of UsedDate conditional field and +// boolean which is true if field was set. +func (c *PaymentsCheckedGiftCode) GetUsedDate() (value int, ok bool) { + if c == nil { + return + } + if !c.Flags.Has(1) { + return value, false + } + return c.UsedDate, true +} + +// GetChats returns value of Chats field. +func (c *PaymentsCheckedGiftCode) GetChats() (value []ChatClass) { + if c == nil { + return + } + return c.Chats +} + +// GetUsers returns value of Users field. +func (c *PaymentsCheckedGiftCode) GetUsers() (value []UserClass) { + if c == nil { + return + } + return c.Users +} + +// MapChats returns field Chats wrapped in ChatClassArray helper. +func (c *PaymentsCheckedGiftCode) MapChats() (value ChatClassArray) { + return ChatClassArray(c.Chats) +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (c *PaymentsCheckedGiftCode) MapUsers() (value UserClassArray) { + return UserClassArray(c.Users) +} diff --git a/tg/tl_payments_checked_gift_code_slices_gen.go b/tg/tl_payments_checked_gift_code_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_checked_gift_code_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_payments_get_giveaway_info_gen.go b/tg/tl_payments_get_giveaway_info_gen.go new file mode 100644 index 0000000000..34f65a6130 --- /dev/null +++ b/tg/tl_payments_get_giveaway_info_gen.go @@ -0,0 +1,205 @@ +// 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{} +) + +// PaymentsGetGiveawayInfoRequest represents TL type `payments.getGiveawayInfo#f4239425`. +// +// See https://core.telegram.org/method/payments.getGiveawayInfo for reference. +type PaymentsGetGiveawayInfoRequest struct { + // Peer field of PaymentsGetGiveawayInfoRequest. + Peer InputPeerClass + // MsgID field of PaymentsGetGiveawayInfoRequest. + MsgID int +} + +// PaymentsGetGiveawayInfoRequestTypeID is TL type id of PaymentsGetGiveawayInfoRequest. +const PaymentsGetGiveawayInfoRequestTypeID = 0xf4239425 + +// Ensuring interfaces in compile-time for PaymentsGetGiveawayInfoRequest. +var ( + _ bin.Encoder = &PaymentsGetGiveawayInfoRequest{} + _ bin.Decoder = &PaymentsGetGiveawayInfoRequest{} + _ bin.BareEncoder = &PaymentsGetGiveawayInfoRequest{} + _ bin.BareDecoder = &PaymentsGetGiveawayInfoRequest{} +) + +func (g *PaymentsGetGiveawayInfoRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Peer == nil) { + return false + } + if !(g.MsgID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGetGiveawayInfoRequest) String() string { + if g == nil { + return "PaymentsGetGiveawayInfoRequest(nil)" + } + type Alias PaymentsGetGiveawayInfoRequest + return fmt.Sprintf("PaymentsGetGiveawayInfoRequest%+v", Alias(*g)) +} + +// FillFrom fills PaymentsGetGiveawayInfoRequest from given interface. +func (g *PaymentsGetGiveawayInfoRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetMsgID() (value int) +}) { + g.Peer = from.GetPeer() + g.MsgID = from.GetMsgID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsGetGiveawayInfoRequest) TypeID() uint32 { + return PaymentsGetGiveawayInfoRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGetGiveawayInfoRequest) TypeName() string { + return "payments.getGiveawayInfo" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGetGiveawayInfoRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.getGiveawayInfo", + ID: PaymentsGetGiveawayInfoRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "MsgID", + SchemaName: "msg_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *PaymentsGetGiveawayInfoRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getGiveawayInfo#f4239425 as nil") + } + b.PutID(PaymentsGetGiveawayInfoRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGetGiveawayInfoRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getGiveawayInfo#f4239425 as nil") + } + if g.Peer == nil { + return fmt.Errorf("unable to encode payments.getGiveawayInfo#f4239425: field peer is nil") + } + if err := g.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getGiveawayInfo#f4239425: field peer: %w", err) + } + b.PutInt(g.MsgID) + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGetGiveawayInfoRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getGiveawayInfo#f4239425 to nil") + } + if err := b.ConsumeID(PaymentsGetGiveawayInfoRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.getGiveawayInfo#f4239425: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGetGiveawayInfoRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getGiveawayInfo#f4239425 to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode payments.getGiveawayInfo#f4239425: field peer: %w", err) + } + g.Peer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.getGiveawayInfo#f4239425: field msg_id: %w", err) + } + g.MsgID = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (g *PaymentsGetGiveawayInfoRequest) GetPeer() (value InputPeerClass) { + if g == nil { + return + } + return g.Peer +} + +// GetMsgID returns value of MsgID field. +func (g *PaymentsGetGiveawayInfoRequest) GetMsgID() (value int) { + if g == nil { + return + } + return g.MsgID +} + +// PaymentsGetGiveawayInfo invokes method payments.getGiveawayInfo#f4239425 returning error if any. +// +// See https://core.telegram.org/method/payments.getGiveawayInfo for reference. +func (c *Client) PaymentsGetGiveawayInfo(ctx context.Context, request *PaymentsGetGiveawayInfoRequest) (PaymentsGiveawayInfoClass, error) { + var result PaymentsGiveawayInfoBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.GiveawayInfo, nil +} diff --git a/tg/tl_payments_get_giveaway_info_slices_gen.go b/tg/tl_payments_get_giveaway_info_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_get_giveaway_info_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_payments_get_premium_gift_code_options_gen.go b/tg/tl_payments_get_premium_gift_code_options_gen.go new file mode 100644 index 0000000000..ec3a3cc812 --- /dev/null +++ b/tg/tl_payments_get_premium_gift_code_options_gen.go @@ -0,0 +1,217 @@ +// 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{} +) + +// PaymentsGetPremiumGiftCodeOptionsRequest represents TL type `payments.getPremiumGiftCodeOptions#2757ba54`. +// +// See https://core.telegram.org/method/payments.getPremiumGiftCodeOptions for reference. +type PaymentsGetPremiumGiftCodeOptionsRequest struct { + // Flags field of PaymentsGetPremiumGiftCodeOptionsRequest. + Flags bin.Fields + // BoostPeer field of PaymentsGetPremiumGiftCodeOptionsRequest. + // + // Use SetBoostPeer and GetBoostPeer helpers. + BoostPeer InputPeerClass +} + +// PaymentsGetPremiumGiftCodeOptionsRequestTypeID is TL type id of PaymentsGetPremiumGiftCodeOptionsRequest. +const PaymentsGetPremiumGiftCodeOptionsRequestTypeID = 0x2757ba54 + +// Ensuring interfaces in compile-time for PaymentsGetPremiumGiftCodeOptionsRequest. +var ( + _ bin.Encoder = &PaymentsGetPremiumGiftCodeOptionsRequest{} + _ bin.Decoder = &PaymentsGetPremiumGiftCodeOptionsRequest{} + _ bin.BareEncoder = &PaymentsGetPremiumGiftCodeOptionsRequest{} + _ bin.BareDecoder = &PaymentsGetPremiumGiftCodeOptionsRequest{} +) + +func (g *PaymentsGetPremiumGiftCodeOptionsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Flags.Zero()) { + return false + } + if !(g.BoostPeer == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGetPremiumGiftCodeOptionsRequest) String() string { + if g == nil { + return "PaymentsGetPremiumGiftCodeOptionsRequest(nil)" + } + type Alias PaymentsGetPremiumGiftCodeOptionsRequest + return fmt.Sprintf("PaymentsGetPremiumGiftCodeOptionsRequest%+v", Alias(*g)) +} + +// FillFrom fills PaymentsGetPremiumGiftCodeOptionsRequest from given interface. +func (g *PaymentsGetPremiumGiftCodeOptionsRequest) FillFrom(from interface { + GetBoostPeer() (value InputPeerClass, ok bool) +}) { + if val, ok := from.GetBoostPeer(); ok { + g.BoostPeer = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsGetPremiumGiftCodeOptionsRequest) TypeID() uint32 { + return PaymentsGetPremiumGiftCodeOptionsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGetPremiumGiftCodeOptionsRequest) TypeName() string { + return "payments.getPremiumGiftCodeOptions" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGetPremiumGiftCodeOptionsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.getPremiumGiftCodeOptions", + ID: PaymentsGetPremiumGiftCodeOptionsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "BoostPeer", + SchemaName: "boost_peer", + Null: !g.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (g *PaymentsGetPremiumGiftCodeOptionsRequest) SetFlags() { + if !(g.BoostPeer == nil) { + g.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (g *PaymentsGetPremiumGiftCodeOptionsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getPremiumGiftCodeOptions#2757ba54 as nil") + } + b.PutID(PaymentsGetPremiumGiftCodeOptionsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGetPremiumGiftCodeOptionsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getPremiumGiftCodeOptions#2757ba54 as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getPremiumGiftCodeOptions#2757ba54: field flags: %w", err) + } + if g.Flags.Has(0) { + if g.BoostPeer == nil { + return fmt.Errorf("unable to encode payments.getPremiumGiftCodeOptions#2757ba54: field boost_peer is nil") + } + if err := g.BoostPeer.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getPremiumGiftCodeOptions#2757ba54: field boost_peer: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGetPremiumGiftCodeOptionsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getPremiumGiftCodeOptions#2757ba54 to nil") + } + if err := b.ConsumeID(PaymentsGetPremiumGiftCodeOptionsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.getPremiumGiftCodeOptions#2757ba54: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGetPremiumGiftCodeOptionsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getPremiumGiftCodeOptions#2757ba54 to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.getPremiumGiftCodeOptions#2757ba54: field flags: %w", err) + } + } + if g.Flags.Has(0) { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode payments.getPremiumGiftCodeOptions#2757ba54: field boost_peer: %w", err) + } + g.BoostPeer = value + } + return nil +} + +// SetBoostPeer sets value of BoostPeer conditional field. +func (g *PaymentsGetPremiumGiftCodeOptionsRequest) SetBoostPeer(value InputPeerClass) { + g.Flags.Set(0) + g.BoostPeer = value +} + +// GetBoostPeer returns value of BoostPeer conditional field and +// boolean which is true if field was set. +func (g *PaymentsGetPremiumGiftCodeOptionsRequest) GetBoostPeer() (value InputPeerClass, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(0) { + return value, false + } + return g.BoostPeer, true +} + +// PaymentsGetPremiumGiftCodeOptions invokes method payments.getPremiumGiftCodeOptions#2757ba54 returning error if any. +// +// See https://core.telegram.org/method/payments.getPremiumGiftCodeOptions for reference. +func (c *Client) PaymentsGetPremiumGiftCodeOptions(ctx context.Context, request *PaymentsGetPremiumGiftCodeOptionsRequest) ([]PremiumGiftCodeOption, error) { + var result PremiumGiftCodeOptionVector + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return []PremiumGiftCodeOption(result.Elems), nil +} diff --git a/tg/tl_payments_get_premium_gift_code_options_slices_gen.go b/tg/tl_payments_get_premium_gift_code_options_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_get_premium_gift_code_options_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_payments_giveaway_info_gen.go b/tg/tl_payments_giveaway_info_gen.go new file mode 100644 index 0000000000..697e60412f --- /dev/null +++ b/tg/tl_payments_giveaway_info_gen.go @@ -0,0 +1,841 @@ +// 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{} +) + +// PaymentsGiveawayInfo represents TL type `payments.giveawayInfo#4367daa0`. +// +// See https://core.telegram.org/constructor/payments.giveawayInfo for reference. +type PaymentsGiveawayInfo struct { + // Flags field of PaymentsGiveawayInfo. + Flags bin.Fields + // Participating field of PaymentsGiveawayInfo. + Participating bool + // PreparingResults field of PaymentsGiveawayInfo. + PreparingResults bool + // StartDate field of PaymentsGiveawayInfo. + StartDate int + // JoinedTooEarlyDate field of PaymentsGiveawayInfo. + // + // Use SetJoinedTooEarlyDate and GetJoinedTooEarlyDate helpers. + JoinedTooEarlyDate int + // AdminDisallowedChatID field of PaymentsGiveawayInfo. + // + // Use SetAdminDisallowedChatID and GetAdminDisallowedChatID helpers. + AdminDisallowedChatID int64 + // DisallowedCountry field of PaymentsGiveawayInfo. + // + // Use SetDisallowedCountry and GetDisallowedCountry helpers. + DisallowedCountry string +} + +// PaymentsGiveawayInfoTypeID is TL type id of PaymentsGiveawayInfo. +const PaymentsGiveawayInfoTypeID = 0x4367daa0 + +// construct implements constructor of PaymentsGiveawayInfoClass. +func (g PaymentsGiveawayInfo) construct() PaymentsGiveawayInfoClass { return &g } + +// Ensuring interfaces in compile-time for PaymentsGiveawayInfo. +var ( + _ bin.Encoder = &PaymentsGiveawayInfo{} + _ bin.Decoder = &PaymentsGiveawayInfo{} + _ bin.BareEncoder = &PaymentsGiveawayInfo{} + _ bin.BareDecoder = &PaymentsGiveawayInfo{} + + _ PaymentsGiveawayInfoClass = &PaymentsGiveawayInfo{} +) + +func (g *PaymentsGiveawayInfo) Zero() bool { + if g == nil { + return true + } + if !(g.Flags.Zero()) { + return false + } + if !(g.Participating == false) { + return false + } + if !(g.PreparingResults == false) { + return false + } + if !(g.StartDate == 0) { + return false + } + if !(g.JoinedTooEarlyDate == 0) { + return false + } + if !(g.AdminDisallowedChatID == 0) { + return false + } + if !(g.DisallowedCountry == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGiveawayInfo) String() string { + if g == nil { + return "PaymentsGiveawayInfo(nil)" + } + type Alias PaymentsGiveawayInfo + return fmt.Sprintf("PaymentsGiveawayInfo%+v", Alias(*g)) +} + +// FillFrom fills PaymentsGiveawayInfo from given interface. +func (g *PaymentsGiveawayInfo) FillFrom(from interface { + GetParticipating() (value bool) + GetPreparingResults() (value bool) + GetStartDate() (value int) + GetJoinedTooEarlyDate() (value int, ok bool) + GetAdminDisallowedChatID() (value int64, ok bool) + GetDisallowedCountry() (value string, ok bool) +}) { + g.Participating = from.GetParticipating() + g.PreparingResults = from.GetPreparingResults() + g.StartDate = from.GetStartDate() + if val, ok := from.GetJoinedTooEarlyDate(); ok { + g.JoinedTooEarlyDate = val + } + + if val, ok := from.GetAdminDisallowedChatID(); ok { + g.AdminDisallowedChatID = val + } + + if val, ok := from.GetDisallowedCountry(); ok { + g.DisallowedCountry = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsGiveawayInfo) TypeID() uint32 { + return PaymentsGiveawayInfoTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGiveawayInfo) TypeName() string { + return "payments.giveawayInfo" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGiveawayInfo) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.giveawayInfo", + ID: PaymentsGiveawayInfoTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Participating", + SchemaName: "participating", + Null: !g.Flags.Has(0), + }, + { + Name: "PreparingResults", + SchemaName: "preparing_results", + Null: !g.Flags.Has(3), + }, + { + Name: "StartDate", + SchemaName: "start_date", + }, + { + Name: "JoinedTooEarlyDate", + SchemaName: "joined_too_early_date", + Null: !g.Flags.Has(1), + }, + { + Name: "AdminDisallowedChatID", + SchemaName: "admin_disallowed_chat_id", + Null: !g.Flags.Has(2), + }, + { + Name: "DisallowedCountry", + SchemaName: "disallowed_country", + Null: !g.Flags.Has(4), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (g *PaymentsGiveawayInfo) SetFlags() { + if !(g.Participating == false) { + g.Flags.Set(0) + } + if !(g.PreparingResults == false) { + g.Flags.Set(3) + } + if !(g.JoinedTooEarlyDate == 0) { + g.Flags.Set(1) + } + if !(g.AdminDisallowedChatID == 0) { + g.Flags.Set(2) + } + if !(g.DisallowedCountry == "") { + g.Flags.Set(4) + } +} + +// Encode implements bin.Encoder. +func (g *PaymentsGiveawayInfo) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.giveawayInfo#4367daa0 as nil") + } + b.PutID(PaymentsGiveawayInfoTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGiveawayInfo) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.giveawayInfo#4367daa0 as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.giveawayInfo#4367daa0: field flags: %w", err) + } + b.PutInt(g.StartDate) + if g.Flags.Has(1) { + b.PutInt(g.JoinedTooEarlyDate) + } + if g.Flags.Has(2) { + b.PutLong(g.AdminDisallowedChatID) + } + if g.Flags.Has(4) { + b.PutString(g.DisallowedCountry) + } + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGiveawayInfo) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.giveawayInfo#4367daa0 to nil") + } + if err := b.ConsumeID(PaymentsGiveawayInfoTypeID); err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfo#4367daa0: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGiveawayInfo) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.giveawayInfo#4367daa0 to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfo#4367daa0: field flags: %w", err) + } + } + g.Participating = g.Flags.Has(0) + g.PreparingResults = g.Flags.Has(3) + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfo#4367daa0: field start_date: %w", err) + } + g.StartDate = value + } + if g.Flags.Has(1) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfo#4367daa0: field joined_too_early_date: %w", err) + } + g.JoinedTooEarlyDate = value + } + if g.Flags.Has(2) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfo#4367daa0: field admin_disallowed_chat_id: %w", err) + } + g.AdminDisallowedChatID = value + } + if g.Flags.Has(4) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfo#4367daa0: field disallowed_country: %w", err) + } + g.DisallowedCountry = value + } + return nil +} + +// SetParticipating sets value of Participating conditional field. +func (g *PaymentsGiveawayInfo) SetParticipating(value bool) { + if value { + g.Flags.Set(0) + g.Participating = true + } else { + g.Flags.Unset(0) + g.Participating = false + } +} + +// GetParticipating returns value of Participating conditional field. +func (g *PaymentsGiveawayInfo) GetParticipating() (value bool) { + if g == nil { + return + } + return g.Flags.Has(0) +} + +// SetPreparingResults sets value of PreparingResults conditional field. +func (g *PaymentsGiveawayInfo) SetPreparingResults(value bool) { + if value { + g.Flags.Set(3) + g.PreparingResults = true + } else { + g.Flags.Unset(3) + g.PreparingResults = false + } +} + +// GetPreparingResults returns value of PreparingResults conditional field. +func (g *PaymentsGiveawayInfo) GetPreparingResults() (value bool) { + if g == nil { + return + } + return g.Flags.Has(3) +} + +// GetStartDate returns value of StartDate field. +func (g *PaymentsGiveawayInfo) GetStartDate() (value int) { + if g == nil { + return + } + return g.StartDate +} + +// SetJoinedTooEarlyDate sets value of JoinedTooEarlyDate conditional field. +func (g *PaymentsGiveawayInfo) SetJoinedTooEarlyDate(value int) { + g.Flags.Set(1) + g.JoinedTooEarlyDate = value +} + +// GetJoinedTooEarlyDate returns value of JoinedTooEarlyDate conditional field and +// boolean which is true if field was set. +func (g *PaymentsGiveawayInfo) GetJoinedTooEarlyDate() (value int, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(1) { + return value, false + } + return g.JoinedTooEarlyDate, true +} + +// SetAdminDisallowedChatID sets value of AdminDisallowedChatID conditional field. +func (g *PaymentsGiveawayInfo) SetAdminDisallowedChatID(value int64) { + g.Flags.Set(2) + g.AdminDisallowedChatID = value +} + +// GetAdminDisallowedChatID returns value of AdminDisallowedChatID conditional field and +// boolean which is true if field was set. +func (g *PaymentsGiveawayInfo) GetAdminDisallowedChatID() (value int64, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(2) { + return value, false + } + return g.AdminDisallowedChatID, true +} + +// SetDisallowedCountry sets value of DisallowedCountry conditional field. +func (g *PaymentsGiveawayInfo) SetDisallowedCountry(value string) { + g.Flags.Set(4) + g.DisallowedCountry = value +} + +// GetDisallowedCountry returns value of DisallowedCountry conditional field and +// boolean which is true if field was set. +func (g *PaymentsGiveawayInfo) GetDisallowedCountry() (value string, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(4) { + return value, false + } + return g.DisallowedCountry, true +} + +// PaymentsGiveawayInfoResults represents TL type `payments.giveawayInfoResults#cd5570`. +// +// See https://core.telegram.org/constructor/payments.giveawayInfoResults for reference. +type PaymentsGiveawayInfoResults struct { + // Flags field of PaymentsGiveawayInfoResults. + Flags bin.Fields + // Winner field of PaymentsGiveawayInfoResults. + Winner bool + // Refunded field of PaymentsGiveawayInfoResults. + Refunded bool + // StartDate field of PaymentsGiveawayInfoResults. + StartDate int + // GiftCodeSlug field of PaymentsGiveawayInfoResults. + // + // Use SetGiftCodeSlug and GetGiftCodeSlug helpers. + GiftCodeSlug string + // FinishDate field of PaymentsGiveawayInfoResults. + FinishDate int + // WinnersCount field of PaymentsGiveawayInfoResults. + WinnersCount int + // ActivatedCount field of PaymentsGiveawayInfoResults. + ActivatedCount int +} + +// PaymentsGiveawayInfoResultsTypeID is TL type id of PaymentsGiveawayInfoResults. +const PaymentsGiveawayInfoResultsTypeID = 0xcd5570 + +// construct implements constructor of PaymentsGiveawayInfoClass. +func (g PaymentsGiveawayInfoResults) construct() PaymentsGiveawayInfoClass { return &g } + +// Ensuring interfaces in compile-time for PaymentsGiveawayInfoResults. +var ( + _ bin.Encoder = &PaymentsGiveawayInfoResults{} + _ bin.Decoder = &PaymentsGiveawayInfoResults{} + _ bin.BareEncoder = &PaymentsGiveawayInfoResults{} + _ bin.BareDecoder = &PaymentsGiveawayInfoResults{} + + _ PaymentsGiveawayInfoClass = &PaymentsGiveawayInfoResults{} +) + +func (g *PaymentsGiveawayInfoResults) Zero() bool { + if g == nil { + return true + } + if !(g.Flags.Zero()) { + return false + } + if !(g.Winner == false) { + return false + } + if !(g.Refunded == false) { + return false + } + if !(g.StartDate == 0) { + return false + } + if !(g.GiftCodeSlug == "") { + return false + } + if !(g.FinishDate == 0) { + return false + } + if !(g.WinnersCount == 0) { + return false + } + if !(g.ActivatedCount == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGiveawayInfoResults) String() string { + if g == nil { + return "PaymentsGiveawayInfoResults(nil)" + } + type Alias PaymentsGiveawayInfoResults + return fmt.Sprintf("PaymentsGiveawayInfoResults%+v", Alias(*g)) +} + +// FillFrom fills PaymentsGiveawayInfoResults from given interface. +func (g *PaymentsGiveawayInfoResults) FillFrom(from interface { + GetWinner() (value bool) + GetRefunded() (value bool) + GetStartDate() (value int) + GetGiftCodeSlug() (value string, ok bool) + GetFinishDate() (value int) + GetWinnersCount() (value int) + GetActivatedCount() (value int) +}) { + g.Winner = from.GetWinner() + g.Refunded = from.GetRefunded() + g.StartDate = from.GetStartDate() + if val, ok := from.GetGiftCodeSlug(); ok { + g.GiftCodeSlug = val + } + + g.FinishDate = from.GetFinishDate() + g.WinnersCount = from.GetWinnersCount() + g.ActivatedCount = from.GetActivatedCount() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsGiveawayInfoResults) TypeID() uint32 { + return PaymentsGiveawayInfoResultsTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGiveawayInfoResults) TypeName() string { + return "payments.giveawayInfoResults" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGiveawayInfoResults) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.giveawayInfoResults", + ID: PaymentsGiveawayInfoResultsTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Winner", + SchemaName: "winner", + Null: !g.Flags.Has(0), + }, + { + Name: "Refunded", + SchemaName: "refunded", + Null: !g.Flags.Has(1), + }, + { + Name: "StartDate", + SchemaName: "start_date", + }, + { + Name: "GiftCodeSlug", + SchemaName: "gift_code_slug", + Null: !g.Flags.Has(0), + }, + { + Name: "FinishDate", + SchemaName: "finish_date", + }, + { + Name: "WinnersCount", + SchemaName: "winners_count", + }, + { + Name: "ActivatedCount", + SchemaName: "activated_count", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (g *PaymentsGiveawayInfoResults) SetFlags() { + if !(g.Winner == false) { + g.Flags.Set(0) + } + if !(g.Refunded == false) { + g.Flags.Set(1) + } + if !(g.GiftCodeSlug == "") { + g.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (g *PaymentsGiveawayInfoResults) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.giveawayInfoResults#cd5570 as nil") + } + b.PutID(PaymentsGiveawayInfoResultsTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGiveawayInfoResults) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.giveawayInfoResults#cd5570 as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.giveawayInfoResults#cd5570: field flags: %w", err) + } + b.PutInt(g.StartDate) + if g.Flags.Has(0) { + b.PutString(g.GiftCodeSlug) + } + b.PutInt(g.FinishDate) + b.PutInt(g.WinnersCount) + b.PutInt(g.ActivatedCount) + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGiveawayInfoResults) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.giveawayInfoResults#cd5570 to nil") + } + if err := b.ConsumeID(PaymentsGiveawayInfoResultsTypeID); err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGiveawayInfoResults) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.giveawayInfoResults#cd5570 to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: field flags: %w", err) + } + } + g.Winner = g.Flags.Has(0) + g.Refunded = g.Flags.Has(1) + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: field start_date: %w", err) + } + g.StartDate = value + } + if g.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: field gift_code_slug: %w", err) + } + g.GiftCodeSlug = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: field finish_date: %w", err) + } + g.FinishDate = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: field winners_count: %w", err) + } + g.WinnersCount = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: field activated_count: %w", err) + } + g.ActivatedCount = value + } + return nil +} + +// SetWinner sets value of Winner conditional field. +func (g *PaymentsGiveawayInfoResults) SetWinner(value bool) { + if value { + g.Flags.Set(0) + g.Winner = true + } else { + g.Flags.Unset(0) + g.Winner = false + } +} + +// GetWinner returns value of Winner conditional field. +func (g *PaymentsGiveawayInfoResults) GetWinner() (value bool) { + if g == nil { + return + } + return g.Flags.Has(0) +} + +// SetRefunded sets value of Refunded conditional field. +func (g *PaymentsGiveawayInfoResults) SetRefunded(value bool) { + if value { + g.Flags.Set(1) + g.Refunded = true + } else { + g.Flags.Unset(1) + g.Refunded = false + } +} + +// GetRefunded returns value of Refunded conditional field. +func (g *PaymentsGiveawayInfoResults) GetRefunded() (value bool) { + if g == nil { + return + } + return g.Flags.Has(1) +} + +// GetStartDate returns value of StartDate field. +func (g *PaymentsGiveawayInfoResults) GetStartDate() (value int) { + if g == nil { + return + } + return g.StartDate +} + +// SetGiftCodeSlug sets value of GiftCodeSlug conditional field. +func (g *PaymentsGiveawayInfoResults) SetGiftCodeSlug(value string) { + g.Flags.Set(0) + g.GiftCodeSlug = value +} + +// GetGiftCodeSlug returns value of GiftCodeSlug conditional field and +// boolean which is true if field was set. +func (g *PaymentsGiveawayInfoResults) GetGiftCodeSlug() (value string, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(0) { + return value, false + } + return g.GiftCodeSlug, true +} + +// GetFinishDate returns value of FinishDate field. +func (g *PaymentsGiveawayInfoResults) GetFinishDate() (value int) { + if g == nil { + return + } + return g.FinishDate +} + +// GetWinnersCount returns value of WinnersCount field. +func (g *PaymentsGiveawayInfoResults) GetWinnersCount() (value int) { + if g == nil { + return + } + return g.WinnersCount +} + +// GetActivatedCount returns value of ActivatedCount field. +func (g *PaymentsGiveawayInfoResults) GetActivatedCount() (value int) { + if g == nil { + return + } + return g.ActivatedCount +} + +// PaymentsGiveawayInfoClassName is schema name of PaymentsGiveawayInfoClass. +const PaymentsGiveawayInfoClassName = "payments.GiveawayInfo" + +// PaymentsGiveawayInfoClass represents payments.GiveawayInfo generic type. +// +// See https://core.telegram.org/type/payments.GiveawayInfo for reference. +// +// Example: +// +// g, err := tg.DecodePaymentsGiveawayInfo(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.PaymentsGiveawayInfo: // payments.giveawayInfo#4367daa0 +// case *tg.PaymentsGiveawayInfoResults: // payments.giveawayInfoResults#cd5570 +// default: panic(v) +// } +type PaymentsGiveawayInfoClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() PaymentsGiveawayInfoClass + + // 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 + + // StartDate field of PaymentsGiveawayInfo. + GetStartDate() (value int) +} + +// DecodePaymentsGiveawayInfo implements binary de-serialization for PaymentsGiveawayInfoClass. +func DecodePaymentsGiveawayInfo(buf *bin.Buffer) (PaymentsGiveawayInfoClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case PaymentsGiveawayInfoTypeID: + // Decoding payments.giveawayInfo#4367daa0. + v := PaymentsGiveawayInfo{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode PaymentsGiveawayInfoClass: %w", err) + } + return &v, nil + case PaymentsGiveawayInfoResultsTypeID: + // Decoding payments.giveawayInfoResults#cd5570. + v := PaymentsGiveawayInfoResults{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode PaymentsGiveawayInfoClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode PaymentsGiveawayInfoClass: %w", bin.NewUnexpectedID(id)) + } +} + +// PaymentsGiveawayInfo boxes the PaymentsGiveawayInfoClass providing a helper. +type PaymentsGiveawayInfoBox struct { + GiveawayInfo PaymentsGiveawayInfoClass +} + +// Decode implements bin.Decoder for PaymentsGiveawayInfoBox. +func (b *PaymentsGiveawayInfoBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode PaymentsGiveawayInfoBox to nil") + } + v, err := DecodePaymentsGiveawayInfo(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.GiveawayInfo = v + return nil +} + +// Encode implements bin.Encode for PaymentsGiveawayInfoBox. +func (b *PaymentsGiveawayInfoBox) Encode(buf *bin.Buffer) error { + if b == nil || b.GiveawayInfo == nil { + return fmt.Errorf("unable to encode PaymentsGiveawayInfoClass as nil") + } + return b.GiveawayInfo.Encode(buf) +} diff --git a/tg/tl_payments_giveaway_info_slices_gen.go b/tg/tl_payments_giveaway_info_slices_gen.go new file mode 100644 index 0000000000..552b446bb4 --- /dev/null +++ b/tg/tl_payments_giveaway_info_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{} +) + +// PaymentsGiveawayInfoClassArray is adapter for slice of PaymentsGiveawayInfoClass. +type PaymentsGiveawayInfoClassArray []PaymentsGiveawayInfoClass + +// Sort sorts slice of PaymentsGiveawayInfoClass. +func (s PaymentsGiveawayInfoClassArray) Sort(less func(a, b PaymentsGiveawayInfoClass) bool) PaymentsGiveawayInfoClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PaymentsGiveawayInfoClass. +func (s PaymentsGiveawayInfoClassArray) SortStable(less func(a, b PaymentsGiveawayInfoClass) bool) PaymentsGiveawayInfoClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PaymentsGiveawayInfoClass. +func (s PaymentsGiveawayInfoClassArray) Retain(keep func(x PaymentsGiveawayInfoClass) bool) PaymentsGiveawayInfoClassArray { + 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 PaymentsGiveawayInfoClassArray) First() (v PaymentsGiveawayInfoClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PaymentsGiveawayInfoClassArray) Last() (v PaymentsGiveawayInfoClass, 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 *PaymentsGiveawayInfoClassArray) PopFirst() (v PaymentsGiveawayInfoClass, 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 PaymentsGiveawayInfoClass + 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 *PaymentsGiveawayInfoClassArray) Pop() (v PaymentsGiveawayInfoClass, 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 +} + +// AsPaymentsGiveawayInfo returns copy with only PaymentsGiveawayInfo constructors. +func (s PaymentsGiveawayInfoClassArray) AsPaymentsGiveawayInfo() (to PaymentsGiveawayInfoArray) { + for _, elem := range s { + value, ok := elem.(*PaymentsGiveawayInfo) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsPaymentsGiveawayInfoResults returns copy with only PaymentsGiveawayInfoResults constructors. +func (s PaymentsGiveawayInfoClassArray) AsPaymentsGiveawayInfoResults() (to PaymentsGiveawayInfoResultsArray) { + for _, elem := range s { + value, ok := elem.(*PaymentsGiveawayInfoResults) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// PaymentsGiveawayInfoArray is adapter for slice of PaymentsGiveawayInfo. +type PaymentsGiveawayInfoArray []PaymentsGiveawayInfo + +// Sort sorts slice of PaymentsGiveawayInfo. +func (s PaymentsGiveawayInfoArray) Sort(less func(a, b PaymentsGiveawayInfo) bool) PaymentsGiveawayInfoArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PaymentsGiveawayInfo. +func (s PaymentsGiveawayInfoArray) SortStable(less func(a, b PaymentsGiveawayInfo) bool) PaymentsGiveawayInfoArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PaymentsGiveawayInfo. +func (s PaymentsGiveawayInfoArray) Retain(keep func(x PaymentsGiveawayInfo) bool) PaymentsGiveawayInfoArray { + 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 PaymentsGiveawayInfoArray) First() (v PaymentsGiveawayInfo, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PaymentsGiveawayInfoArray) Last() (v PaymentsGiveawayInfo, 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 *PaymentsGiveawayInfoArray) PopFirst() (v PaymentsGiveawayInfo, 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 PaymentsGiveawayInfo + 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 *PaymentsGiveawayInfoArray) Pop() (v PaymentsGiveawayInfo, 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 +} + +// PaymentsGiveawayInfoResultsArray is adapter for slice of PaymentsGiveawayInfoResults. +type PaymentsGiveawayInfoResultsArray []PaymentsGiveawayInfoResults + +// Sort sorts slice of PaymentsGiveawayInfoResults. +func (s PaymentsGiveawayInfoResultsArray) Sort(less func(a, b PaymentsGiveawayInfoResults) bool) PaymentsGiveawayInfoResultsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PaymentsGiveawayInfoResults. +func (s PaymentsGiveawayInfoResultsArray) SortStable(less func(a, b PaymentsGiveawayInfoResults) bool) PaymentsGiveawayInfoResultsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PaymentsGiveawayInfoResults. +func (s PaymentsGiveawayInfoResultsArray) Retain(keep func(x PaymentsGiveawayInfoResults) bool) PaymentsGiveawayInfoResultsArray { + 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 PaymentsGiveawayInfoResultsArray) First() (v PaymentsGiveawayInfoResults, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PaymentsGiveawayInfoResultsArray) Last() (v PaymentsGiveawayInfoResults, 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 *PaymentsGiveawayInfoResultsArray) PopFirst() (v PaymentsGiveawayInfoResults, 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 PaymentsGiveawayInfoResults + 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 *PaymentsGiveawayInfoResultsArray) Pop() (v PaymentsGiveawayInfoResults, 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_payments_launch_prepaid_giveaway_gen.go b/tg/tl_payments_launch_prepaid_giveaway_gen.go new file mode 100644 index 0000000000..fe97ba60f1 --- /dev/null +++ b/tg/tl_payments_launch_prepaid_giveaway_gen.go @@ -0,0 +1,237 @@ +// 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{} +) + +// PaymentsLaunchPrepaidGiveawayRequest represents TL type `payments.launchPrepaidGiveaway#5ff58f20`. +// +// See https://core.telegram.org/method/payments.launchPrepaidGiveaway for reference. +type PaymentsLaunchPrepaidGiveawayRequest struct { + // Peer field of PaymentsLaunchPrepaidGiveawayRequest. + Peer InputPeerClass + // GiveawayID field of PaymentsLaunchPrepaidGiveawayRequest. + GiveawayID int64 + // Purpose field of PaymentsLaunchPrepaidGiveawayRequest. + Purpose InputStorePaymentPurposeClass +} + +// PaymentsLaunchPrepaidGiveawayRequestTypeID is TL type id of PaymentsLaunchPrepaidGiveawayRequest. +const PaymentsLaunchPrepaidGiveawayRequestTypeID = 0x5ff58f20 + +// Ensuring interfaces in compile-time for PaymentsLaunchPrepaidGiveawayRequest. +var ( + _ bin.Encoder = &PaymentsLaunchPrepaidGiveawayRequest{} + _ bin.Decoder = &PaymentsLaunchPrepaidGiveawayRequest{} + _ bin.BareEncoder = &PaymentsLaunchPrepaidGiveawayRequest{} + _ bin.BareDecoder = &PaymentsLaunchPrepaidGiveawayRequest{} +) + +func (l *PaymentsLaunchPrepaidGiveawayRequest) Zero() bool { + if l == nil { + return true + } + if !(l.Peer == nil) { + return false + } + if !(l.GiveawayID == 0) { + return false + } + if !(l.Purpose == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (l *PaymentsLaunchPrepaidGiveawayRequest) String() string { + if l == nil { + return "PaymentsLaunchPrepaidGiveawayRequest(nil)" + } + type Alias PaymentsLaunchPrepaidGiveawayRequest + return fmt.Sprintf("PaymentsLaunchPrepaidGiveawayRequest%+v", Alias(*l)) +} + +// FillFrom fills PaymentsLaunchPrepaidGiveawayRequest from given interface. +func (l *PaymentsLaunchPrepaidGiveawayRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetGiveawayID() (value int64) + GetPurpose() (value InputStorePaymentPurposeClass) +}) { + l.Peer = from.GetPeer() + l.GiveawayID = from.GetGiveawayID() + l.Purpose = from.GetPurpose() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsLaunchPrepaidGiveawayRequest) TypeID() uint32 { + return PaymentsLaunchPrepaidGiveawayRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsLaunchPrepaidGiveawayRequest) TypeName() string { + return "payments.launchPrepaidGiveaway" +} + +// TypeInfo returns info about TL type. +func (l *PaymentsLaunchPrepaidGiveawayRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.launchPrepaidGiveaway", + ID: PaymentsLaunchPrepaidGiveawayRequestTypeID, + } + if l == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "GiveawayID", + SchemaName: "giveaway_id", + }, + { + Name: "Purpose", + SchemaName: "purpose", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (l *PaymentsLaunchPrepaidGiveawayRequest) Encode(b *bin.Buffer) error { + if l == nil { + return fmt.Errorf("can't encode payments.launchPrepaidGiveaway#5ff58f20 as nil") + } + b.PutID(PaymentsLaunchPrepaidGiveawayRequestTypeID) + return l.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (l *PaymentsLaunchPrepaidGiveawayRequest) EncodeBare(b *bin.Buffer) error { + if l == nil { + return fmt.Errorf("can't encode payments.launchPrepaidGiveaway#5ff58f20 as nil") + } + if l.Peer == nil { + return fmt.Errorf("unable to encode payments.launchPrepaidGiveaway#5ff58f20: field peer is nil") + } + if err := l.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.launchPrepaidGiveaway#5ff58f20: field peer: %w", err) + } + b.PutLong(l.GiveawayID) + if l.Purpose == nil { + return fmt.Errorf("unable to encode payments.launchPrepaidGiveaway#5ff58f20: field purpose is nil") + } + if err := l.Purpose.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.launchPrepaidGiveaway#5ff58f20: field purpose: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (l *PaymentsLaunchPrepaidGiveawayRequest) Decode(b *bin.Buffer) error { + if l == nil { + return fmt.Errorf("can't decode payments.launchPrepaidGiveaway#5ff58f20 to nil") + } + if err := b.ConsumeID(PaymentsLaunchPrepaidGiveawayRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.launchPrepaidGiveaway#5ff58f20: %w", err) + } + return l.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (l *PaymentsLaunchPrepaidGiveawayRequest) DecodeBare(b *bin.Buffer) error { + if l == nil { + return fmt.Errorf("can't decode payments.launchPrepaidGiveaway#5ff58f20 to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode payments.launchPrepaidGiveaway#5ff58f20: field peer: %w", err) + } + l.Peer = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode payments.launchPrepaidGiveaway#5ff58f20: field giveaway_id: %w", err) + } + l.GiveawayID = value + } + { + value, err := DecodeInputStorePaymentPurpose(b) + if err != nil { + return fmt.Errorf("unable to decode payments.launchPrepaidGiveaway#5ff58f20: field purpose: %w", err) + } + l.Purpose = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (l *PaymentsLaunchPrepaidGiveawayRequest) GetPeer() (value InputPeerClass) { + if l == nil { + return + } + return l.Peer +} + +// GetGiveawayID returns value of GiveawayID field. +func (l *PaymentsLaunchPrepaidGiveawayRequest) GetGiveawayID() (value int64) { + if l == nil { + return + } + return l.GiveawayID +} + +// GetPurpose returns value of Purpose field. +func (l *PaymentsLaunchPrepaidGiveawayRequest) GetPurpose() (value InputStorePaymentPurposeClass) { + if l == nil { + return + } + return l.Purpose +} + +// PaymentsLaunchPrepaidGiveaway invokes method payments.launchPrepaidGiveaway#5ff58f20 returning error if any. +// +// See https://core.telegram.org/method/payments.launchPrepaidGiveaway for reference. +func (c *Client) PaymentsLaunchPrepaidGiveaway(ctx context.Context, request *PaymentsLaunchPrepaidGiveawayRequest) (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_payments_launch_prepaid_giveaway_slices_gen.go b/tg/tl_payments_launch_prepaid_giveaway_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_launch_prepaid_giveaway_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_premium_apply_boost_gen.go b/tg/tl_premium_apply_boost_gen.go new file mode 100644 index 0000000000..fb948c65f6 --- /dev/null +++ b/tg/tl_premium_apply_boost_gen.go @@ -0,0 +1,257 @@ +// 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{} +) + +// PremiumApplyBoostRequest represents TL type `premium.applyBoost#6b7da746`. +// +// See https://core.telegram.org/method/premium.applyBoost for reference. +type PremiumApplyBoostRequest struct { + // Flags field of PremiumApplyBoostRequest. + Flags bin.Fields + // Slots field of PremiumApplyBoostRequest. + // + // Use SetSlots and GetSlots helpers. + Slots []int + // Peer field of PremiumApplyBoostRequest. + Peer InputPeerClass +} + +// PremiumApplyBoostRequestTypeID is TL type id of PremiumApplyBoostRequest. +const PremiumApplyBoostRequestTypeID = 0x6b7da746 + +// Ensuring interfaces in compile-time for PremiumApplyBoostRequest. +var ( + _ bin.Encoder = &PremiumApplyBoostRequest{} + _ bin.Decoder = &PremiumApplyBoostRequest{} + _ bin.BareEncoder = &PremiumApplyBoostRequest{} + _ bin.BareDecoder = &PremiumApplyBoostRequest{} +) + +func (a *PremiumApplyBoostRequest) Zero() bool { + if a == nil { + return true + } + if !(a.Flags.Zero()) { + return false + } + if !(a.Slots == nil) { + return false + } + if !(a.Peer == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *PremiumApplyBoostRequest) String() string { + if a == nil { + return "PremiumApplyBoostRequest(nil)" + } + type Alias PremiumApplyBoostRequest + return fmt.Sprintf("PremiumApplyBoostRequest%+v", Alias(*a)) +} + +// FillFrom fills PremiumApplyBoostRequest from given interface. +func (a *PremiumApplyBoostRequest) FillFrom(from interface { + GetSlots() (value []int, ok bool) + GetPeer() (value InputPeerClass) +}) { + if val, ok := from.GetSlots(); ok { + a.Slots = val + } + + a.Peer = from.GetPeer() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PremiumApplyBoostRequest) TypeID() uint32 { + return PremiumApplyBoostRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PremiumApplyBoostRequest) TypeName() string { + return "premium.applyBoost" +} + +// TypeInfo returns info about TL type. +func (a *PremiumApplyBoostRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "premium.applyBoost", + ID: PremiumApplyBoostRequestTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Slots", + SchemaName: "slots", + Null: !a.Flags.Has(0), + }, + { + Name: "Peer", + SchemaName: "peer", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (a *PremiumApplyBoostRequest) SetFlags() { + if !(a.Slots == nil) { + a.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (a *PremiumApplyBoostRequest) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode premium.applyBoost#6b7da746 as nil") + } + b.PutID(PremiumApplyBoostRequestTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *PremiumApplyBoostRequest) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode premium.applyBoost#6b7da746 as nil") + } + a.SetFlags() + if err := a.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode premium.applyBoost#6b7da746: field flags: %w", err) + } + if a.Flags.Has(0) { + b.PutVectorHeader(len(a.Slots)) + for _, v := range a.Slots { + b.PutInt(v) + } + } + if a.Peer == nil { + return fmt.Errorf("unable to encode premium.applyBoost#6b7da746: field peer is nil") + } + if err := a.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode premium.applyBoost#6b7da746: field peer: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (a *PremiumApplyBoostRequest) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode premium.applyBoost#6b7da746 to nil") + } + if err := b.ConsumeID(PremiumApplyBoostRequestTypeID); err != nil { + return fmt.Errorf("unable to decode premium.applyBoost#6b7da746: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *PremiumApplyBoostRequest) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode premium.applyBoost#6b7da746 to nil") + } + { + if err := a.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode premium.applyBoost#6b7da746: field flags: %w", err) + } + } + if a.Flags.Has(0) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode premium.applyBoost#6b7da746: field slots: %w", err) + } + + if headerLen > 0 { + a.Slots = make([]int, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode premium.applyBoost#6b7da746: field slots: %w", err) + } + a.Slots = append(a.Slots, value) + } + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode premium.applyBoost#6b7da746: field peer: %w", err) + } + a.Peer = value + } + return nil +} + +// SetSlots sets value of Slots conditional field. +func (a *PremiumApplyBoostRequest) SetSlots(value []int) { + a.Flags.Set(0) + a.Slots = value +} + +// GetSlots returns value of Slots conditional field and +// boolean which is true if field was set. +func (a *PremiumApplyBoostRequest) GetSlots() (value []int, ok bool) { + if a == nil { + return + } + if !a.Flags.Has(0) { + return value, false + } + return a.Slots, true +} + +// GetPeer returns value of Peer field. +func (a *PremiumApplyBoostRequest) GetPeer() (value InputPeerClass) { + if a == nil { + return + } + return a.Peer +} + +// PremiumApplyBoost invokes method premium.applyBoost#6b7da746 returning error if any. +// +// See https://core.telegram.org/method/premium.applyBoost for reference. +func (c *Client) PremiumApplyBoost(ctx context.Context, request *PremiumApplyBoostRequest) (*PremiumMyBoosts, error) { + var result PremiumMyBoosts + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_premium_apply_boost_slices_gen.go b/tg/tl_premium_apply_boost_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_premium_apply_boost_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_premium_boosts_list_gen.go b/tg/tl_premium_boosts_list_gen.go new file mode 100644 index 0000000000..75e2df60f5 --- /dev/null +++ b/tg/tl_premium_boosts_list_gen.go @@ -0,0 +1,319 @@ +// 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{} +) + +// PremiumBoostsList represents TL type `premium.boostsList#86f8613c`. +// +// See https://core.telegram.org/constructor/premium.boostsList for reference. +type PremiumBoostsList struct { + // Flags field of PremiumBoostsList. + Flags bin.Fields + // Count field of PremiumBoostsList. + Count int + // Boosts field of PremiumBoostsList. + Boosts []Boost + // NextOffset field of PremiumBoostsList. + // + // Use SetNextOffset and GetNextOffset helpers. + NextOffset string + // Users field of PremiumBoostsList. + Users []UserClass +} + +// PremiumBoostsListTypeID is TL type id of PremiumBoostsList. +const PremiumBoostsListTypeID = 0x86f8613c + +// Ensuring interfaces in compile-time for PremiumBoostsList. +var ( + _ bin.Encoder = &PremiumBoostsList{} + _ bin.Decoder = &PremiumBoostsList{} + _ bin.BareEncoder = &PremiumBoostsList{} + _ bin.BareDecoder = &PremiumBoostsList{} +) + +func (b *PremiumBoostsList) Zero() bool { + if b == nil { + return true + } + if !(b.Flags.Zero()) { + return false + } + if !(b.Count == 0) { + return false + } + if !(b.Boosts == nil) { + return false + } + if !(b.NextOffset == "") { + return false + } + if !(b.Users == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (b *PremiumBoostsList) String() string { + if b == nil { + return "PremiumBoostsList(nil)" + } + type Alias PremiumBoostsList + return fmt.Sprintf("PremiumBoostsList%+v", Alias(*b)) +} + +// FillFrom fills PremiumBoostsList from given interface. +func (b *PremiumBoostsList) FillFrom(from interface { + GetCount() (value int) + GetBoosts() (value []Boost) + GetNextOffset() (value string, ok bool) + GetUsers() (value []UserClass) +}) { + b.Count = from.GetCount() + b.Boosts = from.GetBoosts() + if val, ok := from.GetNextOffset(); ok { + b.NextOffset = val + } + + b.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PremiumBoostsList) TypeID() uint32 { + return PremiumBoostsListTypeID +} + +// TypeName returns name of type in TL schema. +func (*PremiumBoostsList) TypeName() string { + return "premium.boostsList" +} + +// TypeInfo returns info about TL type. +func (b *PremiumBoostsList) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "premium.boostsList", + ID: PremiumBoostsListTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Count", + SchemaName: "count", + }, + { + Name: "Boosts", + SchemaName: "boosts", + }, + { + Name: "NextOffset", + SchemaName: "next_offset", + Null: !b.Flags.Has(0), + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (b *PremiumBoostsList) SetFlags() { + if !(b.NextOffset == "") { + b.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (b *PremiumBoostsList) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode premium.boostsList#86f8613c as nil") + } + buf.PutID(PremiumBoostsListTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *PremiumBoostsList) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode premium.boostsList#86f8613c as nil") + } + b.SetFlags() + if err := b.Flags.Encode(buf); err != nil { + return fmt.Errorf("unable to encode premium.boostsList#86f8613c: field flags: %w", err) + } + buf.PutInt(b.Count) + buf.PutVectorHeader(len(b.Boosts)) + for idx, v := range b.Boosts { + if err := v.Encode(buf); err != nil { + return fmt.Errorf("unable to encode premium.boostsList#86f8613c: field boosts element with index %d: %w", idx, err) + } + } + if b.Flags.Has(0) { + buf.PutString(b.NextOffset) + } + buf.PutVectorHeader(len(b.Users)) + for idx, v := range b.Users { + if v == nil { + return fmt.Errorf("unable to encode premium.boostsList#86f8613c: field users element with index %d is nil", idx) + } + if err := v.Encode(buf); err != nil { + return fmt.Errorf("unable to encode premium.boostsList#86f8613c: field users element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (b *PremiumBoostsList) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode premium.boostsList#86f8613c to nil") + } + if err := buf.ConsumeID(PremiumBoostsListTypeID); err != nil { + return fmt.Errorf("unable to decode premium.boostsList#86f8613c: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *PremiumBoostsList) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode premium.boostsList#86f8613c to nil") + } + { + if err := b.Flags.Decode(buf); err != nil { + return fmt.Errorf("unable to decode premium.boostsList#86f8613c: field flags: %w", err) + } + } + { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode premium.boostsList#86f8613c: field count: %w", err) + } + b.Count = value + } + { + headerLen, err := buf.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode premium.boostsList#86f8613c: field boosts: %w", err) + } + + if headerLen > 0 { + b.Boosts = make([]Boost, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value Boost + if err := value.Decode(buf); err != nil { + return fmt.Errorf("unable to decode premium.boostsList#86f8613c: field boosts: %w", err) + } + b.Boosts = append(b.Boosts, value) + } + } + if b.Flags.Has(0) { + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode premium.boostsList#86f8613c: field next_offset: %w", err) + } + b.NextOffset = value + } + { + headerLen, err := buf.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode premium.boostsList#86f8613c: field users: %w", err) + } + + if headerLen > 0 { + b.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeUser(buf) + if err != nil { + return fmt.Errorf("unable to decode premium.boostsList#86f8613c: field users: %w", err) + } + b.Users = append(b.Users, value) + } + } + return nil +} + +// GetCount returns value of Count field. +func (b *PremiumBoostsList) GetCount() (value int) { + if b == nil { + return + } + return b.Count +} + +// GetBoosts returns value of Boosts field. +func (b *PremiumBoostsList) GetBoosts() (value []Boost) { + if b == nil { + return + } + return b.Boosts +} + +// SetNextOffset sets value of NextOffset conditional field. +func (b *PremiumBoostsList) SetNextOffset(value string) { + b.Flags.Set(0) + b.NextOffset = value +} + +// GetNextOffset returns value of NextOffset conditional field and +// boolean which is true if field was set. +func (b *PremiumBoostsList) GetNextOffset() (value string, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(0) { + return value, false + } + return b.NextOffset, true +} + +// GetUsers returns value of Users field. +func (b *PremiumBoostsList) GetUsers() (value []UserClass) { + if b == nil { + return + } + return b.Users +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (b *PremiumBoostsList) MapUsers() (value UserClassArray) { + return UserClassArray(b.Users) +} diff --git a/tg/tl_premium_boosts_list_slices_gen.go b/tg/tl_premium_boosts_list_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_premium_boosts_list_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_premium_boosts_status_gen.go b/tg/tl_premium_boosts_status_gen.go new file mode 100644 index 0000000000..1d3ad1f1bc --- /dev/null +++ b/tg/tl_premium_boosts_status_gen.go @@ -0,0 +1,563 @@ +// 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{} +) + +// PremiumBoostsStatus represents TL type `premium.boostsStatus#4959427a`. +// +// See https://core.telegram.org/constructor/premium.boostsStatus for reference. +type PremiumBoostsStatus struct { + // Flags field of PremiumBoostsStatus. + Flags bin.Fields + // MyBoost field of PremiumBoostsStatus. + MyBoost bool + // Level field of PremiumBoostsStatus. + Level int + // CurrentLevelBoosts field of PremiumBoostsStatus. + CurrentLevelBoosts int + // Boosts field of PremiumBoostsStatus. + Boosts int + // GiftBoosts field of PremiumBoostsStatus. + // + // Use SetGiftBoosts and GetGiftBoosts helpers. + GiftBoosts int + // NextLevelBoosts field of PremiumBoostsStatus. + // + // Use SetNextLevelBoosts and GetNextLevelBoosts helpers. + NextLevelBoosts int + // PremiumAudience field of PremiumBoostsStatus. + // + // Use SetPremiumAudience and GetPremiumAudience helpers. + PremiumAudience StatsPercentValue + // BoostURL field of PremiumBoostsStatus. + BoostURL string + // PrepaidGiveaways field of PremiumBoostsStatus. + // + // Use SetPrepaidGiveaways and GetPrepaidGiveaways helpers. + PrepaidGiveaways []PrepaidGiveaway + // MyBoostSlots field of PremiumBoostsStatus. + // + // Use SetMyBoostSlots and GetMyBoostSlots helpers. + MyBoostSlots []int +} + +// PremiumBoostsStatusTypeID is TL type id of PremiumBoostsStatus. +const PremiumBoostsStatusTypeID = 0x4959427a + +// Ensuring interfaces in compile-time for PremiumBoostsStatus. +var ( + _ bin.Encoder = &PremiumBoostsStatus{} + _ bin.Decoder = &PremiumBoostsStatus{} + _ bin.BareEncoder = &PremiumBoostsStatus{} + _ bin.BareDecoder = &PremiumBoostsStatus{} +) + +func (b *PremiumBoostsStatus) Zero() bool { + if b == nil { + return true + } + if !(b.Flags.Zero()) { + return false + } + if !(b.MyBoost == false) { + return false + } + if !(b.Level == 0) { + return false + } + if !(b.CurrentLevelBoosts == 0) { + return false + } + if !(b.Boosts == 0) { + return false + } + if !(b.GiftBoosts == 0) { + return false + } + if !(b.NextLevelBoosts == 0) { + return false + } + if !(b.PremiumAudience.Zero()) { + return false + } + if !(b.BoostURL == "") { + return false + } + if !(b.PrepaidGiveaways == nil) { + return false + } + if !(b.MyBoostSlots == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (b *PremiumBoostsStatus) String() string { + if b == nil { + return "PremiumBoostsStatus(nil)" + } + type Alias PremiumBoostsStatus + return fmt.Sprintf("PremiumBoostsStatus%+v", Alias(*b)) +} + +// FillFrom fills PremiumBoostsStatus from given interface. +func (b *PremiumBoostsStatus) FillFrom(from interface { + GetMyBoost() (value bool) + GetLevel() (value int) + GetCurrentLevelBoosts() (value int) + GetBoosts() (value int) + GetGiftBoosts() (value int, ok bool) + GetNextLevelBoosts() (value int, ok bool) + GetPremiumAudience() (value StatsPercentValue, ok bool) + GetBoostURL() (value string) + GetPrepaidGiveaways() (value []PrepaidGiveaway, ok bool) + GetMyBoostSlots() (value []int, ok bool) +}) { + b.MyBoost = from.GetMyBoost() + b.Level = from.GetLevel() + b.CurrentLevelBoosts = from.GetCurrentLevelBoosts() + b.Boosts = from.GetBoosts() + if val, ok := from.GetGiftBoosts(); ok { + b.GiftBoosts = val + } + + if val, ok := from.GetNextLevelBoosts(); ok { + b.NextLevelBoosts = val + } + + if val, ok := from.GetPremiumAudience(); ok { + b.PremiumAudience = val + } + + b.BoostURL = from.GetBoostURL() + if val, ok := from.GetPrepaidGiveaways(); ok { + b.PrepaidGiveaways = val + } + + if val, ok := from.GetMyBoostSlots(); ok { + b.MyBoostSlots = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PremiumBoostsStatus) TypeID() uint32 { + return PremiumBoostsStatusTypeID +} + +// TypeName returns name of type in TL schema. +func (*PremiumBoostsStatus) TypeName() string { + return "premium.boostsStatus" +} + +// TypeInfo returns info about TL type. +func (b *PremiumBoostsStatus) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "premium.boostsStatus", + ID: PremiumBoostsStatusTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "MyBoost", + SchemaName: "my_boost", + Null: !b.Flags.Has(2), + }, + { + Name: "Level", + SchemaName: "level", + }, + { + Name: "CurrentLevelBoosts", + SchemaName: "current_level_boosts", + }, + { + Name: "Boosts", + SchemaName: "boosts", + }, + { + Name: "GiftBoosts", + SchemaName: "gift_boosts", + Null: !b.Flags.Has(4), + }, + { + Name: "NextLevelBoosts", + SchemaName: "next_level_boosts", + Null: !b.Flags.Has(0), + }, + { + Name: "PremiumAudience", + SchemaName: "premium_audience", + Null: !b.Flags.Has(1), + }, + { + Name: "BoostURL", + SchemaName: "boost_url", + }, + { + Name: "PrepaidGiveaways", + SchemaName: "prepaid_giveaways", + Null: !b.Flags.Has(3), + }, + { + Name: "MyBoostSlots", + SchemaName: "my_boost_slots", + Null: !b.Flags.Has(2), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (b *PremiumBoostsStatus) SetFlags() { + if !(b.MyBoost == false) { + b.Flags.Set(2) + } + if !(b.GiftBoosts == 0) { + b.Flags.Set(4) + } + if !(b.NextLevelBoosts == 0) { + b.Flags.Set(0) + } + if !(b.PremiumAudience.Zero()) { + b.Flags.Set(1) + } + if !(b.PrepaidGiveaways == nil) { + b.Flags.Set(3) + } + if !(b.MyBoostSlots == nil) { + b.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (b *PremiumBoostsStatus) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode premium.boostsStatus#4959427a as nil") + } + buf.PutID(PremiumBoostsStatusTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *PremiumBoostsStatus) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode premium.boostsStatus#4959427a as nil") + } + b.SetFlags() + if err := b.Flags.Encode(buf); err != nil { + return fmt.Errorf("unable to encode premium.boostsStatus#4959427a: field flags: %w", err) + } + buf.PutInt(b.Level) + buf.PutInt(b.CurrentLevelBoosts) + buf.PutInt(b.Boosts) + if b.Flags.Has(4) { + buf.PutInt(b.GiftBoosts) + } + if b.Flags.Has(0) { + buf.PutInt(b.NextLevelBoosts) + } + if b.Flags.Has(1) { + if err := b.PremiumAudience.Encode(buf); err != nil { + return fmt.Errorf("unable to encode premium.boostsStatus#4959427a: field premium_audience: %w", err) + } + } + buf.PutString(b.BoostURL) + if b.Flags.Has(3) { + buf.PutVectorHeader(len(b.PrepaidGiveaways)) + for idx, v := range b.PrepaidGiveaways { + if err := v.Encode(buf); err != nil { + return fmt.Errorf("unable to encode premium.boostsStatus#4959427a: field prepaid_giveaways element with index %d: %w", idx, err) + } + } + } + if b.Flags.Has(2) { + buf.PutVectorHeader(len(b.MyBoostSlots)) + for _, v := range b.MyBoostSlots { + buf.PutInt(v) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (b *PremiumBoostsStatus) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode premium.boostsStatus#4959427a to nil") + } + if err := buf.ConsumeID(PremiumBoostsStatusTypeID); err != nil { + return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *PremiumBoostsStatus) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode premium.boostsStatus#4959427a to nil") + } + { + if err := b.Flags.Decode(buf); err != nil { + return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field flags: %w", err) + } + } + b.MyBoost = b.Flags.Has(2) + { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field level: %w", err) + } + b.Level = value + } + { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field current_level_boosts: %w", err) + } + b.CurrentLevelBoosts = value + } + { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field boosts: %w", err) + } + b.Boosts = value + } + if b.Flags.Has(4) { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field gift_boosts: %w", err) + } + b.GiftBoosts = value + } + if b.Flags.Has(0) { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field next_level_boosts: %w", err) + } + b.NextLevelBoosts = value + } + if b.Flags.Has(1) { + if err := b.PremiumAudience.Decode(buf); err != nil { + return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field premium_audience: %w", err) + } + } + { + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field boost_url: %w", err) + } + b.BoostURL = value + } + if b.Flags.Has(3) { + headerLen, err := buf.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field prepaid_giveaways: %w", err) + } + + if headerLen > 0 { + b.PrepaidGiveaways = make([]PrepaidGiveaway, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value PrepaidGiveaway + if err := value.Decode(buf); err != nil { + return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field prepaid_giveaways: %w", err) + } + b.PrepaidGiveaways = append(b.PrepaidGiveaways, value) + } + } + if b.Flags.Has(2) { + headerLen, err := buf.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field my_boost_slots: %w", err) + } + + if headerLen > 0 { + b.MyBoostSlots = make([]int, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field my_boost_slots: %w", err) + } + b.MyBoostSlots = append(b.MyBoostSlots, value) + } + } + return nil +} + +// SetMyBoost sets value of MyBoost conditional field. +func (b *PremiumBoostsStatus) SetMyBoost(value bool) { + if value { + b.Flags.Set(2) + b.MyBoost = true + } else { + b.Flags.Unset(2) + b.MyBoost = false + } +} + +// GetMyBoost returns value of MyBoost conditional field. +func (b *PremiumBoostsStatus) GetMyBoost() (value bool) { + if b == nil { + return + } + return b.Flags.Has(2) +} + +// GetLevel returns value of Level field. +func (b *PremiumBoostsStatus) GetLevel() (value int) { + if b == nil { + return + } + return b.Level +} + +// GetCurrentLevelBoosts returns value of CurrentLevelBoosts field. +func (b *PremiumBoostsStatus) GetCurrentLevelBoosts() (value int) { + if b == nil { + return + } + return b.CurrentLevelBoosts +} + +// GetBoosts returns value of Boosts field. +func (b *PremiumBoostsStatus) GetBoosts() (value int) { + if b == nil { + return + } + return b.Boosts +} + +// SetGiftBoosts sets value of GiftBoosts conditional field. +func (b *PremiumBoostsStatus) SetGiftBoosts(value int) { + b.Flags.Set(4) + b.GiftBoosts = value +} + +// GetGiftBoosts returns value of GiftBoosts conditional field and +// boolean which is true if field was set. +func (b *PremiumBoostsStatus) GetGiftBoosts() (value int, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(4) { + return value, false + } + return b.GiftBoosts, true +} + +// SetNextLevelBoosts sets value of NextLevelBoosts conditional field. +func (b *PremiumBoostsStatus) SetNextLevelBoosts(value int) { + b.Flags.Set(0) + b.NextLevelBoosts = value +} + +// GetNextLevelBoosts returns value of NextLevelBoosts conditional field and +// boolean which is true if field was set. +func (b *PremiumBoostsStatus) GetNextLevelBoosts() (value int, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(0) { + return value, false + } + return b.NextLevelBoosts, true +} + +// SetPremiumAudience sets value of PremiumAudience conditional field. +func (b *PremiumBoostsStatus) SetPremiumAudience(value StatsPercentValue) { + b.Flags.Set(1) + b.PremiumAudience = value +} + +// GetPremiumAudience returns value of PremiumAudience conditional field and +// boolean which is true if field was set. +func (b *PremiumBoostsStatus) GetPremiumAudience() (value StatsPercentValue, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(1) { + return value, false + } + return b.PremiumAudience, true +} + +// GetBoostURL returns value of BoostURL field. +func (b *PremiumBoostsStatus) GetBoostURL() (value string) { + if b == nil { + return + } + return b.BoostURL +} + +// SetPrepaidGiveaways sets value of PrepaidGiveaways conditional field. +func (b *PremiumBoostsStatus) SetPrepaidGiveaways(value []PrepaidGiveaway) { + b.Flags.Set(3) + b.PrepaidGiveaways = value +} + +// GetPrepaidGiveaways returns value of PrepaidGiveaways conditional field and +// boolean which is true if field was set. +func (b *PremiumBoostsStatus) GetPrepaidGiveaways() (value []PrepaidGiveaway, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(3) { + return value, false + } + return b.PrepaidGiveaways, true +} + +// SetMyBoostSlots sets value of MyBoostSlots conditional field. +func (b *PremiumBoostsStatus) SetMyBoostSlots(value []int) { + b.Flags.Set(2) + b.MyBoostSlots = value +} + +// GetMyBoostSlots returns value of MyBoostSlots conditional field and +// boolean which is true if field was set. +func (b *PremiumBoostsStatus) GetMyBoostSlots() (value []int, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(2) { + return value, false + } + return b.MyBoostSlots, true +} diff --git a/tg/tl_premium_boosts_status_slices_gen.go b/tg/tl_premium_boosts_status_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_premium_boosts_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_premium_get_boosts_list_gen.go b/tg/tl_premium_get_boosts_list_gen.go new file mode 100644 index 0000000000..a758789f49 --- /dev/null +++ b/tg/tl_premium_get_boosts_list_gen.go @@ -0,0 +1,285 @@ +// 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{} +) + +// PremiumGetBoostsListRequest represents TL type `premium.getBoostsList#60f67660`. +// +// See https://core.telegram.org/method/premium.getBoostsList for reference. +type PremiumGetBoostsListRequest struct { + // Flags field of PremiumGetBoostsListRequest. + Flags bin.Fields + // Gifts field of PremiumGetBoostsListRequest. + Gifts bool + // Peer field of PremiumGetBoostsListRequest. + Peer InputPeerClass + // Offset field of PremiumGetBoostsListRequest. + Offset string + // Limit field of PremiumGetBoostsListRequest. + Limit int +} + +// PremiumGetBoostsListRequestTypeID is TL type id of PremiumGetBoostsListRequest. +const PremiumGetBoostsListRequestTypeID = 0x60f67660 + +// Ensuring interfaces in compile-time for PremiumGetBoostsListRequest. +var ( + _ bin.Encoder = &PremiumGetBoostsListRequest{} + _ bin.Decoder = &PremiumGetBoostsListRequest{} + _ bin.BareEncoder = &PremiumGetBoostsListRequest{} + _ bin.BareDecoder = &PremiumGetBoostsListRequest{} +) + +func (g *PremiumGetBoostsListRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Flags.Zero()) { + return false + } + if !(g.Gifts == false) { + return false + } + if !(g.Peer == nil) { + return false + } + if !(g.Offset == "") { + return false + } + if !(g.Limit == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PremiumGetBoostsListRequest) String() string { + if g == nil { + return "PremiumGetBoostsListRequest(nil)" + } + type Alias PremiumGetBoostsListRequest + return fmt.Sprintf("PremiumGetBoostsListRequest%+v", Alias(*g)) +} + +// FillFrom fills PremiumGetBoostsListRequest from given interface. +func (g *PremiumGetBoostsListRequest) FillFrom(from interface { + GetGifts() (value bool) + GetPeer() (value InputPeerClass) + GetOffset() (value string) + GetLimit() (value int) +}) { + g.Gifts = from.GetGifts() + g.Peer = from.GetPeer() + g.Offset = from.GetOffset() + g.Limit = from.GetLimit() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PremiumGetBoostsListRequest) TypeID() uint32 { + return PremiumGetBoostsListRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PremiumGetBoostsListRequest) TypeName() string { + return "premium.getBoostsList" +} + +// TypeInfo returns info about TL type. +func (g *PremiumGetBoostsListRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "premium.getBoostsList", + ID: PremiumGetBoostsListRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Gifts", + SchemaName: "gifts", + Null: !g.Flags.Has(0), + }, + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "Offset", + SchemaName: "offset", + }, + { + Name: "Limit", + SchemaName: "limit", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (g *PremiumGetBoostsListRequest) SetFlags() { + if !(g.Gifts == false) { + g.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (g *PremiumGetBoostsListRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode premium.getBoostsList#60f67660 as nil") + } + b.PutID(PremiumGetBoostsListRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PremiumGetBoostsListRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode premium.getBoostsList#60f67660 as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode premium.getBoostsList#60f67660: field flags: %w", err) + } + if g.Peer == nil { + return fmt.Errorf("unable to encode premium.getBoostsList#60f67660: field peer is nil") + } + if err := g.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode premium.getBoostsList#60f67660: field peer: %w", err) + } + b.PutString(g.Offset) + b.PutInt(g.Limit) + return nil +} + +// Decode implements bin.Decoder. +func (g *PremiumGetBoostsListRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode premium.getBoostsList#60f67660 to nil") + } + if err := b.ConsumeID(PremiumGetBoostsListRequestTypeID); err != nil { + return fmt.Errorf("unable to decode premium.getBoostsList#60f67660: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PremiumGetBoostsListRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode premium.getBoostsList#60f67660 to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode premium.getBoostsList#60f67660: field flags: %w", err) + } + } + g.Gifts = g.Flags.Has(0) + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode premium.getBoostsList#60f67660: field peer: %w", err) + } + g.Peer = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode premium.getBoostsList#60f67660: field offset: %w", err) + } + g.Offset = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode premium.getBoostsList#60f67660: field limit: %w", err) + } + g.Limit = value + } + return nil +} + +// SetGifts sets value of Gifts conditional field. +func (g *PremiumGetBoostsListRequest) SetGifts(value bool) { + if value { + g.Flags.Set(0) + g.Gifts = true + } else { + g.Flags.Unset(0) + g.Gifts = false + } +} + +// GetGifts returns value of Gifts conditional field. +func (g *PremiumGetBoostsListRequest) GetGifts() (value bool) { + if g == nil { + return + } + return g.Flags.Has(0) +} + +// GetPeer returns value of Peer field. +func (g *PremiumGetBoostsListRequest) GetPeer() (value InputPeerClass) { + if g == nil { + return + } + return g.Peer +} + +// GetOffset returns value of Offset field. +func (g *PremiumGetBoostsListRequest) GetOffset() (value string) { + if g == nil { + return + } + return g.Offset +} + +// GetLimit returns value of Limit field. +func (g *PremiumGetBoostsListRequest) GetLimit() (value int) { + if g == nil { + return + } + return g.Limit +} + +// PremiumGetBoostsList invokes method premium.getBoostsList#60f67660 returning error if any. +// +// See https://core.telegram.org/method/premium.getBoostsList for reference. +func (c *Client) PremiumGetBoostsList(ctx context.Context, request *PremiumGetBoostsListRequest) (*PremiumBoostsList, error) { + var result PremiumBoostsList + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_premium_get_boosts_list_slices_gen.go b/tg/tl_premium_get_boosts_list_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_premium_get_boosts_list_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_premium_get_boosts_status_gen.go b/tg/tl_premium_get_boosts_status_gen.go new file mode 100644 index 0000000000..29331f21a2 --- /dev/null +++ b/tg/tl_premium_get_boosts_status_gen.go @@ -0,0 +1,181 @@ +// 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{} +) + +// PremiumGetBoostsStatusRequest represents TL type `premium.getBoostsStatus#42f1f61`. +// +// See https://core.telegram.org/method/premium.getBoostsStatus for reference. +type PremiumGetBoostsStatusRequest struct { + // Peer field of PremiumGetBoostsStatusRequest. + Peer InputPeerClass +} + +// PremiumGetBoostsStatusRequestTypeID is TL type id of PremiumGetBoostsStatusRequest. +const PremiumGetBoostsStatusRequestTypeID = 0x42f1f61 + +// Ensuring interfaces in compile-time for PremiumGetBoostsStatusRequest. +var ( + _ bin.Encoder = &PremiumGetBoostsStatusRequest{} + _ bin.Decoder = &PremiumGetBoostsStatusRequest{} + _ bin.BareEncoder = &PremiumGetBoostsStatusRequest{} + _ bin.BareDecoder = &PremiumGetBoostsStatusRequest{} +) + +func (g *PremiumGetBoostsStatusRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Peer == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PremiumGetBoostsStatusRequest) String() string { + if g == nil { + return "PremiumGetBoostsStatusRequest(nil)" + } + type Alias PremiumGetBoostsStatusRequest + return fmt.Sprintf("PremiumGetBoostsStatusRequest%+v", Alias(*g)) +} + +// FillFrom fills PremiumGetBoostsStatusRequest from given interface. +func (g *PremiumGetBoostsStatusRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) +}) { + g.Peer = from.GetPeer() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PremiumGetBoostsStatusRequest) TypeID() uint32 { + return PremiumGetBoostsStatusRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PremiumGetBoostsStatusRequest) TypeName() string { + return "premium.getBoostsStatus" +} + +// TypeInfo returns info about TL type. +func (g *PremiumGetBoostsStatusRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "premium.getBoostsStatus", + ID: PremiumGetBoostsStatusRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *PremiumGetBoostsStatusRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode premium.getBoostsStatus#42f1f61 as nil") + } + b.PutID(PremiumGetBoostsStatusRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PremiumGetBoostsStatusRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode premium.getBoostsStatus#42f1f61 as nil") + } + if g.Peer == nil { + return fmt.Errorf("unable to encode premium.getBoostsStatus#42f1f61: field peer is nil") + } + if err := g.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode premium.getBoostsStatus#42f1f61: field peer: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (g *PremiumGetBoostsStatusRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode premium.getBoostsStatus#42f1f61 to nil") + } + if err := b.ConsumeID(PremiumGetBoostsStatusRequestTypeID); err != nil { + return fmt.Errorf("unable to decode premium.getBoostsStatus#42f1f61: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PremiumGetBoostsStatusRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode premium.getBoostsStatus#42f1f61 to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode premium.getBoostsStatus#42f1f61: field peer: %w", err) + } + g.Peer = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (g *PremiumGetBoostsStatusRequest) GetPeer() (value InputPeerClass) { + if g == nil { + return + } + return g.Peer +} + +// PremiumGetBoostsStatus invokes method premium.getBoostsStatus#42f1f61 returning error if any. +// +// See https://core.telegram.org/method/premium.getBoostsStatus for reference. +func (c *Client) PremiumGetBoostsStatus(ctx context.Context, peer InputPeerClass) (*PremiumBoostsStatus, error) { + var result PremiumBoostsStatus + + request := &PremiumGetBoostsStatusRequest{ + Peer: peer, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_premium_get_boosts_status_slices_gen.go b/tg/tl_premium_get_boosts_status_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_premium_get_boosts_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_premium_get_my_boosts_gen.go b/tg/tl_premium_get_my_boosts_gen.go new file mode 100644 index 0000000000..d13cc44e6c --- /dev/null +++ b/tg/tl_premium_get_my_boosts_gen.go @@ -0,0 +1,141 @@ +// 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{} +) + +// PremiumGetMyBoostsRequest represents TL type `premium.getMyBoosts#be77b4a`. +// +// See https://core.telegram.org/method/premium.getMyBoosts for reference. +type PremiumGetMyBoostsRequest struct { +} + +// PremiumGetMyBoostsRequestTypeID is TL type id of PremiumGetMyBoostsRequest. +const PremiumGetMyBoostsRequestTypeID = 0xbe77b4a + +// Ensuring interfaces in compile-time for PremiumGetMyBoostsRequest. +var ( + _ bin.Encoder = &PremiumGetMyBoostsRequest{} + _ bin.Decoder = &PremiumGetMyBoostsRequest{} + _ bin.BareEncoder = &PremiumGetMyBoostsRequest{} + _ bin.BareDecoder = &PremiumGetMyBoostsRequest{} +) + +func (g *PremiumGetMyBoostsRequest) Zero() bool { + if g == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (g *PremiumGetMyBoostsRequest) String() string { + if g == nil { + return "PremiumGetMyBoostsRequest(nil)" + } + type Alias PremiumGetMyBoostsRequest + return fmt.Sprintf("PremiumGetMyBoostsRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PremiumGetMyBoostsRequest) TypeID() uint32 { + return PremiumGetMyBoostsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PremiumGetMyBoostsRequest) TypeName() string { + return "premium.getMyBoosts" +} + +// TypeInfo returns info about TL type. +func (g *PremiumGetMyBoostsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "premium.getMyBoosts", + ID: PremiumGetMyBoostsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (g *PremiumGetMyBoostsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode premium.getMyBoosts#be77b4a as nil") + } + b.PutID(PremiumGetMyBoostsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PremiumGetMyBoostsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode premium.getMyBoosts#be77b4a as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (g *PremiumGetMyBoostsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode premium.getMyBoosts#be77b4a to nil") + } + if err := b.ConsumeID(PremiumGetMyBoostsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode premium.getMyBoosts#be77b4a: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PremiumGetMyBoostsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode premium.getMyBoosts#be77b4a to nil") + } + return nil +} + +// PremiumGetMyBoosts invokes method premium.getMyBoosts#be77b4a returning error if any. +// +// See https://core.telegram.org/method/premium.getMyBoosts for reference. +func (c *Client) PremiumGetMyBoosts(ctx context.Context) (*PremiumMyBoosts, error) { + var result PremiumMyBoosts + + request := &PremiumGetMyBoostsRequest{} + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_premium_get_my_boosts_slices_gen.go b/tg/tl_premium_get_my_boosts_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_premium_get_my_boosts_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_premium_gift_code_option_gen.go b/tg/tl_premium_gift_code_option_gen.go new file mode 100644 index 0000000000..d19ad8991a --- /dev/null +++ b/tg/tl_premium_gift_code_option_gen.go @@ -0,0 +1,356 @@ +// 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{} +) + +// PremiumGiftCodeOption represents TL type `premiumGiftCodeOption#257e962b`. +// +// See https://core.telegram.org/constructor/premiumGiftCodeOption for reference. +type PremiumGiftCodeOption struct { + // Flags field of PremiumGiftCodeOption. + Flags bin.Fields + // Users field of PremiumGiftCodeOption. + Users int + // Months field of PremiumGiftCodeOption. + Months int + // StoreProduct field of PremiumGiftCodeOption. + // + // Use SetStoreProduct and GetStoreProduct helpers. + StoreProduct string + // StoreQuantity field of PremiumGiftCodeOption. + // + // Use SetStoreQuantity and GetStoreQuantity helpers. + StoreQuantity int + // Currency field of PremiumGiftCodeOption. + Currency string + // Amount field of PremiumGiftCodeOption. + Amount int64 +} + +// PremiumGiftCodeOptionTypeID is TL type id of PremiumGiftCodeOption. +const PremiumGiftCodeOptionTypeID = 0x257e962b + +// Ensuring interfaces in compile-time for PremiumGiftCodeOption. +var ( + _ bin.Encoder = &PremiumGiftCodeOption{} + _ bin.Decoder = &PremiumGiftCodeOption{} + _ bin.BareEncoder = &PremiumGiftCodeOption{} + _ bin.BareDecoder = &PremiumGiftCodeOption{} +) + +func (p *PremiumGiftCodeOption) Zero() bool { + if p == nil { + return true + } + if !(p.Flags.Zero()) { + return false + } + if !(p.Users == 0) { + return false + } + if !(p.Months == 0) { + return false + } + if !(p.StoreProduct == "") { + return false + } + if !(p.StoreQuantity == 0) { + return false + } + if !(p.Currency == "") { + return false + } + if !(p.Amount == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (p *PremiumGiftCodeOption) String() string { + if p == nil { + return "PremiumGiftCodeOption(nil)" + } + type Alias PremiumGiftCodeOption + return fmt.Sprintf("PremiumGiftCodeOption%+v", Alias(*p)) +} + +// FillFrom fills PremiumGiftCodeOption from given interface. +func (p *PremiumGiftCodeOption) FillFrom(from interface { + GetUsers() (value int) + GetMonths() (value int) + GetStoreProduct() (value string, ok bool) + GetStoreQuantity() (value int, ok bool) + GetCurrency() (value string) + GetAmount() (value int64) +}) { + p.Users = from.GetUsers() + p.Months = from.GetMonths() + if val, ok := from.GetStoreProduct(); ok { + p.StoreProduct = val + } + + if val, ok := from.GetStoreQuantity(); ok { + p.StoreQuantity = val + } + + p.Currency = from.GetCurrency() + p.Amount = from.GetAmount() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PremiumGiftCodeOption) TypeID() uint32 { + return PremiumGiftCodeOptionTypeID +} + +// TypeName returns name of type in TL schema. +func (*PremiumGiftCodeOption) TypeName() string { + return "premiumGiftCodeOption" +} + +// TypeInfo returns info about TL type. +func (p *PremiumGiftCodeOption) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "premiumGiftCodeOption", + ID: PremiumGiftCodeOptionTypeID, + } + if p == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Users", + SchemaName: "users", + }, + { + Name: "Months", + SchemaName: "months", + }, + { + Name: "StoreProduct", + SchemaName: "store_product", + Null: !p.Flags.Has(0), + }, + { + Name: "StoreQuantity", + SchemaName: "store_quantity", + Null: !p.Flags.Has(1), + }, + { + Name: "Currency", + SchemaName: "currency", + }, + { + Name: "Amount", + SchemaName: "amount", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (p *PremiumGiftCodeOption) SetFlags() { + if !(p.StoreProduct == "") { + p.Flags.Set(0) + } + if !(p.StoreQuantity == 0) { + p.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (p *PremiumGiftCodeOption) Encode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode premiumGiftCodeOption#257e962b as nil") + } + b.PutID(PremiumGiftCodeOptionTypeID) + return p.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (p *PremiumGiftCodeOption) EncodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode premiumGiftCodeOption#257e962b as nil") + } + p.SetFlags() + if err := p.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode premiumGiftCodeOption#257e962b: field flags: %w", err) + } + b.PutInt(p.Users) + b.PutInt(p.Months) + if p.Flags.Has(0) { + b.PutString(p.StoreProduct) + } + if p.Flags.Has(1) { + b.PutInt(p.StoreQuantity) + } + b.PutString(p.Currency) + b.PutLong(p.Amount) + return nil +} + +// Decode implements bin.Decoder. +func (p *PremiumGiftCodeOption) Decode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode premiumGiftCodeOption#257e962b to nil") + } + if err := b.ConsumeID(PremiumGiftCodeOptionTypeID); err != nil { + return fmt.Errorf("unable to decode premiumGiftCodeOption#257e962b: %w", err) + } + return p.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (p *PremiumGiftCodeOption) DecodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode premiumGiftCodeOption#257e962b to nil") + } + { + if err := p.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode premiumGiftCodeOption#257e962b: field flags: %w", err) + } + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode premiumGiftCodeOption#257e962b: field users: %w", err) + } + p.Users = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode premiumGiftCodeOption#257e962b: field months: %w", err) + } + p.Months = value + } + if p.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode premiumGiftCodeOption#257e962b: field store_product: %w", err) + } + p.StoreProduct = value + } + if p.Flags.Has(1) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode premiumGiftCodeOption#257e962b: field store_quantity: %w", err) + } + p.StoreQuantity = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode premiumGiftCodeOption#257e962b: field currency: %w", err) + } + p.Currency = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode premiumGiftCodeOption#257e962b: field amount: %w", err) + } + p.Amount = value + } + return nil +} + +// GetUsers returns value of Users field. +func (p *PremiumGiftCodeOption) GetUsers() (value int) { + if p == nil { + return + } + return p.Users +} + +// GetMonths returns value of Months field. +func (p *PremiumGiftCodeOption) GetMonths() (value int) { + if p == nil { + return + } + return p.Months +} + +// SetStoreProduct sets value of StoreProduct conditional field. +func (p *PremiumGiftCodeOption) 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 *PremiumGiftCodeOption) GetStoreProduct() (value string, ok bool) { + if p == nil { + return + } + if !p.Flags.Has(0) { + return value, false + } + return p.StoreProduct, true +} + +// SetStoreQuantity sets value of StoreQuantity conditional field. +func (p *PremiumGiftCodeOption) SetStoreQuantity(value int) { + p.Flags.Set(1) + p.StoreQuantity = value +} + +// GetStoreQuantity returns value of StoreQuantity conditional field and +// boolean which is true if field was set. +func (p *PremiumGiftCodeOption) GetStoreQuantity() (value int, ok bool) { + if p == nil { + return + } + if !p.Flags.Has(1) { + return value, false + } + return p.StoreQuantity, true +} + +// GetCurrency returns value of Currency field. +func (p *PremiumGiftCodeOption) GetCurrency() (value string) { + if p == nil { + return + } + return p.Currency +} + +// GetAmount returns value of Amount field. +func (p *PremiumGiftCodeOption) GetAmount() (value int64) { + if p == nil { + return + } + return p.Amount +} diff --git a/tg/tl_premium_gift_code_option_slices_gen.go b/tg/tl_premium_gift_code_option_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_premium_gift_code_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_premium_gift_code_option_vector_gen.go b/tg/tl_premium_gift_code_option_vector_gen.go new file mode 100644 index 0000000000..6c678b4dec --- /dev/null +++ b/tg/tl_premium_gift_code_option_vector_gen.go @@ -0,0 +1,172 @@ +// 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{} +) + +// PremiumGiftCodeOptionVector is a box for Vector +type PremiumGiftCodeOptionVector struct { + // Elements of Vector + Elems []PremiumGiftCodeOption +} + +// PremiumGiftCodeOptionVectorTypeID is TL type id of PremiumGiftCodeOptionVector. +const PremiumGiftCodeOptionVectorTypeID = bin.TypeVector + +// Ensuring interfaces in compile-time for PremiumGiftCodeOptionVector. +var ( + _ bin.Encoder = &PremiumGiftCodeOptionVector{} + _ bin.Decoder = &PremiumGiftCodeOptionVector{} + _ bin.BareEncoder = &PremiumGiftCodeOptionVector{} + _ bin.BareDecoder = &PremiumGiftCodeOptionVector{} +) + +func (vec *PremiumGiftCodeOptionVector) Zero() bool { + if vec == nil { + return true + } + if !(vec.Elems == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (vec *PremiumGiftCodeOptionVector) String() string { + if vec == nil { + return "PremiumGiftCodeOptionVector(nil)" + } + type Alias PremiumGiftCodeOptionVector + return fmt.Sprintf("PremiumGiftCodeOptionVector%+v", Alias(*vec)) +} + +// FillFrom fills PremiumGiftCodeOptionVector from given interface. +func (vec *PremiumGiftCodeOptionVector) FillFrom(from interface { + GetElems() (value []PremiumGiftCodeOption) +}) { + vec.Elems = from.GetElems() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PremiumGiftCodeOptionVector) TypeID() uint32 { + return PremiumGiftCodeOptionVectorTypeID +} + +// TypeName returns name of type in TL schema. +func (*PremiumGiftCodeOptionVector) TypeName() string { + return "" +} + +// TypeInfo returns info about TL type. +func (vec *PremiumGiftCodeOptionVector) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "", + ID: PremiumGiftCodeOptionVectorTypeID, + } + if vec == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Elems", + SchemaName: "Elems", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (vec *PremiumGiftCodeOptionVector) Encode(b *bin.Buffer) error { + if vec == nil { + return fmt.Errorf("can't encode Vector as nil") + } + + return vec.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (vec *PremiumGiftCodeOptionVector) EncodeBare(b *bin.Buffer) error { + if vec == nil { + return fmt.Errorf("can't encode Vector as nil") + } + b.PutVectorHeader(len(vec.Elems)) + for idx, v := range vec.Elems { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode Vector: field Elems element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (vec *PremiumGiftCodeOptionVector) Decode(b *bin.Buffer) error { + if vec == nil { + return fmt.Errorf("can't decode Vector to nil") + } + + return vec.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (vec *PremiumGiftCodeOptionVector) DecodeBare(b *bin.Buffer) error { + if vec == nil { + return fmt.Errorf("can't decode Vector to nil") + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode Vector: field Elems: %w", err) + } + + if headerLen > 0 { + vec.Elems = make([]PremiumGiftCodeOption, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value PremiumGiftCodeOption + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode Vector: field Elems: %w", err) + } + vec.Elems = append(vec.Elems, value) + } + } + return nil +} + +// GetElems returns value of Elems field. +func (vec *PremiumGiftCodeOptionVector) GetElems() (value []PremiumGiftCodeOption) { + if vec == nil { + return + } + return vec.Elems +} diff --git a/tg/tl_premium_gift_code_option_vector_slices_gen.go b/tg/tl_premium_gift_code_option_vector_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_premium_gift_code_option_vector_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_premium_my_boosts_gen.go b/tg/tl_premium_my_boosts_gen.go new file mode 100644 index 0000000000..ac54cbd9f0 --- /dev/null +++ b/tg/tl_premium_my_boosts_gen.go @@ -0,0 +1,276 @@ +// 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{} +) + +// PremiumMyBoosts represents TL type `premium.myBoosts#9ae228e2`. +// +// See https://core.telegram.org/constructor/premium.myBoosts for reference. +type PremiumMyBoosts struct { + // MyBoosts field of PremiumMyBoosts. + MyBoosts []MyBoost + // Chats field of PremiumMyBoosts. + Chats []ChatClass + // Users field of PremiumMyBoosts. + Users []UserClass +} + +// PremiumMyBoostsTypeID is TL type id of PremiumMyBoosts. +const PremiumMyBoostsTypeID = 0x9ae228e2 + +// Ensuring interfaces in compile-time for PremiumMyBoosts. +var ( + _ bin.Encoder = &PremiumMyBoosts{} + _ bin.Decoder = &PremiumMyBoosts{} + _ bin.BareEncoder = &PremiumMyBoosts{} + _ bin.BareDecoder = &PremiumMyBoosts{} +) + +func (m *PremiumMyBoosts) Zero() bool { + if m == nil { + return true + } + if !(m.MyBoosts == nil) { + return false + } + if !(m.Chats == nil) { + return false + } + if !(m.Users == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *PremiumMyBoosts) String() string { + if m == nil { + return "PremiumMyBoosts(nil)" + } + type Alias PremiumMyBoosts + return fmt.Sprintf("PremiumMyBoosts%+v", Alias(*m)) +} + +// FillFrom fills PremiumMyBoosts from given interface. +func (m *PremiumMyBoosts) FillFrom(from interface { + GetMyBoosts() (value []MyBoost) + GetChats() (value []ChatClass) + GetUsers() (value []UserClass) +}) { + m.MyBoosts = from.GetMyBoosts() + m.Chats = from.GetChats() + m.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PremiumMyBoosts) TypeID() uint32 { + return PremiumMyBoostsTypeID +} + +// TypeName returns name of type in TL schema. +func (*PremiumMyBoosts) TypeName() string { + return "premium.myBoosts" +} + +// TypeInfo returns info about TL type. +func (m *PremiumMyBoosts) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "premium.myBoosts", + ID: PremiumMyBoostsTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "MyBoosts", + SchemaName: "my_boosts", + }, + { + Name: "Chats", + SchemaName: "chats", + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (m *PremiumMyBoosts) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode premium.myBoosts#9ae228e2 as nil") + } + b.PutID(PremiumMyBoostsTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *PremiumMyBoosts) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode premium.myBoosts#9ae228e2 as nil") + } + b.PutVectorHeader(len(m.MyBoosts)) + for idx, v := range m.MyBoosts { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode premium.myBoosts#9ae228e2: field my_boosts element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(m.Chats)) + for idx, v := range m.Chats { + if v == nil { + return fmt.Errorf("unable to encode premium.myBoosts#9ae228e2: field chats element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode premium.myBoosts#9ae228e2: field chats element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(m.Users)) + for idx, v := range m.Users { + if v == nil { + return fmt.Errorf("unable to encode premium.myBoosts#9ae228e2: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode premium.myBoosts#9ae228e2: field users element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (m *PremiumMyBoosts) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode premium.myBoosts#9ae228e2 to nil") + } + if err := b.ConsumeID(PremiumMyBoostsTypeID); err != nil { + return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *PremiumMyBoosts) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode premium.myBoosts#9ae228e2 to nil") + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: field my_boosts: %w", err) + } + + if headerLen > 0 { + m.MyBoosts = make([]MyBoost, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value MyBoost + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: field my_boosts: %w", err) + } + m.MyBoosts = append(m.MyBoosts, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: field chats: %w", err) + } + + if headerLen > 0 { + m.Chats = make([]ChatClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeChat(b) + if err != nil { + return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: field chats: %w", err) + } + m.Chats = append(m.Chats, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: field users: %w", err) + } + + if headerLen > 0 { + m.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeUser(b) + if err != nil { + return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: field users: %w", err) + } + m.Users = append(m.Users, value) + } + } + return nil +} + +// GetMyBoosts returns value of MyBoosts field. +func (m *PremiumMyBoosts) GetMyBoosts() (value []MyBoost) { + if m == nil { + return + } + return m.MyBoosts +} + +// GetChats returns value of Chats field. +func (m *PremiumMyBoosts) GetChats() (value []ChatClass) { + if m == nil { + return + } + return m.Chats +} + +// GetUsers returns value of Users field. +func (m *PremiumMyBoosts) GetUsers() (value []UserClass) { + if m == nil { + return + } + return m.Users +} + +// MapChats returns field Chats wrapped in ChatClassArray helper. +func (m *PremiumMyBoosts) MapChats() (value ChatClassArray) { + return ChatClassArray(m.Chats) +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (m *PremiumMyBoosts) MapUsers() (value UserClassArray) { + return UserClassArray(m.Users) +} diff --git a/tg/tl_premium_my_boosts_slices_gen.go b/tg/tl_premium_my_boosts_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_premium_my_boosts_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_prepaid_giveaway_gen.go b/tg/tl_prepaid_giveaway_gen.go new file mode 100644 index 0000000000..55aa8eab93 --- /dev/null +++ b/tg/tl_prepaid_giveaway_gen.go @@ -0,0 +1,242 @@ +// 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{} +) + +// PrepaidGiveaway represents TL type `prepaidGiveaway#b2539d54`. +// +// See https://core.telegram.org/constructor/prepaidGiveaway for reference. +type PrepaidGiveaway struct { + // ID field of PrepaidGiveaway. + ID int64 + // Months field of PrepaidGiveaway. + Months int + // Quantity field of PrepaidGiveaway. + Quantity int + // Date field of PrepaidGiveaway. + Date int +} + +// PrepaidGiveawayTypeID is TL type id of PrepaidGiveaway. +const PrepaidGiveawayTypeID = 0xb2539d54 + +// Ensuring interfaces in compile-time for PrepaidGiveaway. +var ( + _ bin.Encoder = &PrepaidGiveaway{} + _ bin.Decoder = &PrepaidGiveaway{} + _ bin.BareEncoder = &PrepaidGiveaway{} + _ bin.BareDecoder = &PrepaidGiveaway{} +) + +func (p *PrepaidGiveaway) Zero() bool { + if p == nil { + return true + } + if !(p.ID == 0) { + return false + } + if !(p.Months == 0) { + return false + } + if !(p.Quantity == 0) { + return false + } + if !(p.Date == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (p *PrepaidGiveaway) String() string { + if p == nil { + return "PrepaidGiveaway(nil)" + } + type Alias PrepaidGiveaway + return fmt.Sprintf("PrepaidGiveaway%+v", Alias(*p)) +} + +// FillFrom fills PrepaidGiveaway from given interface. +func (p *PrepaidGiveaway) FillFrom(from interface { + GetID() (value int64) + GetMonths() (value int) + GetQuantity() (value int) + GetDate() (value int) +}) { + p.ID = from.GetID() + p.Months = from.GetMonths() + p.Quantity = from.GetQuantity() + p.Date = from.GetDate() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PrepaidGiveaway) TypeID() uint32 { + return PrepaidGiveawayTypeID +} + +// TypeName returns name of type in TL schema. +func (*PrepaidGiveaway) TypeName() string { + return "prepaidGiveaway" +} + +// TypeInfo returns info about TL type. +func (p *PrepaidGiveaway) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "prepaidGiveaway", + ID: PrepaidGiveawayTypeID, + } + if p == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ID", + SchemaName: "id", + }, + { + Name: "Months", + SchemaName: "months", + }, + { + Name: "Quantity", + SchemaName: "quantity", + }, + { + Name: "Date", + SchemaName: "date", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (p *PrepaidGiveaway) Encode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode prepaidGiveaway#b2539d54 as nil") + } + b.PutID(PrepaidGiveawayTypeID) + return p.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (p *PrepaidGiveaway) EncodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode prepaidGiveaway#b2539d54 as nil") + } + b.PutLong(p.ID) + b.PutInt(p.Months) + b.PutInt(p.Quantity) + b.PutInt(p.Date) + return nil +} + +// Decode implements bin.Decoder. +func (p *PrepaidGiveaway) Decode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode prepaidGiveaway#b2539d54 to nil") + } + if err := b.ConsumeID(PrepaidGiveawayTypeID); err != nil { + return fmt.Errorf("unable to decode prepaidGiveaway#b2539d54: %w", err) + } + return p.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (p *PrepaidGiveaway) DecodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode prepaidGiveaway#b2539d54 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode prepaidGiveaway#b2539d54: field id: %w", err) + } + p.ID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode prepaidGiveaway#b2539d54: field months: %w", err) + } + p.Months = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode prepaidGiveaway#b2539d54: field quantity: %w", err) + } + p.Quantity = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode prepaidGiveaway#b2539d54: field date: %w", err) + } + p.Date = value + } + return nil +} + +// GetID returns value of ID field. +func (p *PrepaidGiveaway) GetID() (value int64) { + if p == nil { + return + } + return p.ID +} + +// GetMonths returns value of Months field. +func (p *PrepaidGiveaway) GetMonths() (value int) { + if p == nil { + return + } + return p.Months +} + +// GetQuantity returns value of Quantity field. +func (p *PrepaidGiveaway) GetQuantity() (value int) { + if p == nil { + return + } + return p.Quantity +} + +// GetDate returns value of Date field. +func (p *PrepaidGiveaway) GetDate() (value int) { + if p == nil { + return + } + return p.Date +} diff --git a/tg/tl_prepaid_giveaway_slices_gen.go b/tg/tl_prepaid_giveaway_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_prepaid_giveaway_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_registry_gen.go b/tg/tl_registry_gen.go index a0feb02472..0c4ca40555 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 165 +const Layer = 166 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -72,6 +72,7 @@ func TypesMap() map[uint32]string { InputMediaPollTypeID: "inputMediaPoll#f94e5f1", InputMediaDiceTypeID: "inputMediaDice#e66fbf7b", InputMediaStoryTypeID: "inputMediaStory#89fdd778", + InputMediaWebPageTypeID: "inputMediaWebPage#c21b8849", InputChatPhotoEmptyTypeID: "inputChatPhotoEmpty#1ca48f57", InputChatUploadedPhotoTypeID: "inputChatUploadedPhoto#bdcdaec0", InputChatPhotoTypeID: "inputChatPhoto#8953ad37", @@ -103,7 +104,7 @@ func TypesMap() map[uint32]string { StorageFileMp4TypeID: "storage.fileMp4#b3cea0e4", StorageFileWebpTypeID: "storage.fileWebp#1081464c", UserEmptyTypeID: "userEmpty#d3bc4b7a", - UserTypeID: "user#abb5f120", + UserTypeID: "user#eb602f25", UserProfilePhotoEmptyTypeID: "userProfilePhotoEmpty#4f11bae1", UserProfilePhotoTypeID: "userProfilePhoto#82d1f706", UserStatusEmptyTypeID: "userStatusEmpty#9d05049", @@ -115,7 +116,7 @@ func TypesMap() map[uint32]string { ChatEmptyTypeID: "chatEmpty#29562865", ChatTypeID: "chat#41cbf256", ChatForbiddenTypeID: "chatForbidden#6592a1a7", - ChannelTypeID: "channel#94f592db", + ChannelTypeID: "channel#1981ea7e", ChannelForbiddenTypeID: "channelForbidden#17d493d5", ChatFullTypeID: "chatFull#c9d31138", ChannelFullTypeID: "channelFull#723027bd", @@ -135,7 +136,7 @@ func TypesMap() map[uint32]string { MessageMediaContactTypeID: "messageMediaContact#70322949", MessageMediaUnsupportedTypeID: "messageMediaUnsupported#9f84f49e", MessageMediaDocumentTypeID: "messageMediaDocument#4cf4d72d", - MessageMediaWebPageTypeID: "messageMediaWebPage#a32dd600", + MessageMediaWebPageTypeID: "messageMediaWebPage#ddf10c3b", MessageMediaVenueTypeID: "messageMediaVenue#2ec0533f", MessageMediaGameTypeID: "messageMediaGame#fdb19008", MessageMediaInvoiceTypeID: "messageMediaInvoice#f6a548d3", @@ -143,6 +144,7 @@ func TypesMap() map[uint32]string { MessageMediaPollTypeID: "messageMediaPoll#4bd6e798", MessageMediaDiceTypeID: "messageMediaDice#3f7ee58b", MessageMediaStoryTypeID: "messageMediaStory#68cb6283", + MessageMediaGiveawayTypeID: "messageMediaGiveaway#58260664", MessageActionEmptyTypeID: "messageActionEmpty#b6aef7b0", MessageActionChatCreateTypeID: "messageActionChatCreate#bd47cbad", MessageActionChatEditTitleTypeID: "messageActionChatEditTitle#b5a1ce5a", @@ -182,6 +184,8 @@ func TypesMap() map[uint32]string { MessageActionRequestedPeerTypeID: "messageActionRequestedPeer#fe77345d", MessageActionSetChatWallPaperTypeID: "messageActionSetChatWallPaper#bc44a927", MessageActionSetSameChatWallPaperTypeID: "messageActionSetSameChatWallPaper#c0787d6d", + MessageActionGiftCodeTypeID: "messageActionGiftCode#d2cfdb0e", + MessageActionGiveawayLaunchTypeID: "messageActionGiveawayLaunch#332ba9ed", DialogTypeID: "dialog#d58a08c6", DialogFolderTypeID: "dialogFolder#71bd134c", PhotoEmptyTypeID: "photoEmpty#2331b22d", @@ -497,8 +501,8 @@ func TypesMap() map[uint32]string { MessagesAllStickersNotModifiedTypeID: "messages.allStickersNotModified#e86602c3", MessagesAllStickersTypeID: "messages.allStickers#cdbbcebb", MessagesAffectedMessagesTypeID: "messages.affectedMessages#84d19185", - WebPageEmptyTypeID: "webPageEmpty#eb1477e8", - WebPagePendingTypeID: "webPagePending#c586da1c", + WebPageEmptyTypeID: "webPageEmpty#211a1788", + WebPagePendingTypeID: "webPagePending#b0d13e47", WebPageTypeID: "webPage#e89c45b2", WebPageNotModifiedTypeID: "webPageNotModified#7311ca11", AuthorizationTypeID: "authorization#ad01d61d", @@ -511,7 +515,7 @@ func TypesMap() map[uint32]string { ChatInviteExportedTypeID: "chatInviteExported#ab4a819", ChatInvitePublicJoinRequestsTypeID: "chatInvitePublicJoinRequests#ed107ab7", ChatInviteAlreadyTypeID: "chatInviteAlready#5a686d7c", - ChatInviteTypeID: "chatInvite#300c44c1", + ChatInviteTypeID: "chatInvite#cde0ec40", ChatInvitePeekTypeID: "chatInvitePeek#61695cb0", InputStickerSetEmptyTypeID: "inputStickerSetEmpty#ffb62b95", InputStickerSetIDTypeID: "inputStickerSetID#9de7a269", @@ -566,10 +570,10 @@ func TypesMap() map[uint32]string { MessageEntityCashtagTypeID: "messageEntityCashtag#4c4e743f", MessageEntityUnderlineTypeID: "messageEntityUnderline#9c4e7e8b", MessageEntityStrikeTypeID: "messageEntityStrike#bf0693d4", - MessageEntityBlockquoteTypeID: "messageEntityBlockquote#20df5d0", MessageEntityBankCardTypeID: "messageEntityBankCard#761e6af4", MessageEntitySpoilerTypeID: "messageEntitySpoiler#32ca960f", MessageEntityCustomEmojiTypeID: "messageEntityCustomEmoji#c8cf05f8", + MessageEntityBlockquoteTypeID: "messageEntityBlockquote#20df5d0", InputChannelEmptyTypeID: "inputChannelEmpty#ee8c1e86", InputChannelTypeID: "inputChannel#f35aec28", InputChannelFromMessageTypeID: "inputChannelFromMessage#5b934f9d", @@ -607,6 +611,7 @@ func TypesMap() map[uint32]string { InputBotInlineMessageMediaContactTypeID: "inputBotInlineMessageMediaContact#a6edbffd", InputBotInlineMessageGameTypeID: "inputBotInlineMessageGame#4b425864", InputBotInlineMessageMediaInvoiceTypeID: "inputBotInlineMessageMediaInvoice#d7e78225", + InputBotInlineMessageMediaWebPageTypeID: "inputBotInlineMessageMediaWebPage#bddcc510", InputBotInlineResultTypeID: "inputBotInlineResult#88bf9319", InputBotInlineResultPhotoTypeID: "inputBotInlineResultPhoto#a8d864a7", InputBotInlineResultDocumentTypeID: "inputBotInlineResultDocument#fff8fdc4", @@ -617,6 +622,7 @@ func TypesMap() map[uint32]string { BotInlineMessageMediaVenueTypeID: "botInlineMessageMediaVenue#8a86659c", BotInlineMessageMediaContactTypeID: "botInlineMessageMediaContact#18d1cdc2", BotInlineMessageMediaInvoiceTypeID: "botInlineMessageMediaInvoice#354a9b09", + BotInlineMessageMediaWebPageTypeID: "botInlineMessageMediaWebPage#809ad9a6", BotInlineResultTypeID: "botInlineResult#11965f3a", BotInlineMediaResultTypeID: "botInlineMediaResult#17db940b", MessagesBotResultsTypeID: "messages.botResults#e021f2f6", @@ -656,7 +662,7 @@ func TypesMap() map[uint32]string { ContactsTopPeersTypeID: "contacts.topPeers#70b772a8", ContactsTopPeersDisabledTypeID: "contacts.topPeersDisabled#b52c939d", DraftMessageEmptyTypeID: "draftMessageEmpty#1b0c841a", - DraftMessageTypeID: "draftMessage#fd8e711f", + DraftMessageTypeID: "draftMessage#3fccf7ef", MessagesFeaturedStickersNotModifiedTypeID: "messages.featuredStickersNotModified#c6dc0c66", MessagesFeaturedStickersTypeID: "messages.featuredStickers#be382906", MessagesRecentStickersNotModifiedTypeID: "messages.recentStickersNotModified#b17f890", @@ -815,6 +821,8 @@ func TypesMap() map[uint32]string { ChannelAdminLogEventActionDeleteTopicTypeID: "channelAdminLogEventActionDeleteTopic#ae168909", ChannelAdminLogEventActionPinTopicTypeID: "channelAdminLogEventActionPinTopic#5d8d353b", ChannelAdminLogEventActionToggleAntiSpamTypeID: "channelAdminLogEventActionToggleAntiSpam#64f36dfc", + ChannelAdminLogEventActionChangeColorTypeID: "channelAdminLogEventActionChangeColor#3c2b247b", + ChannelAdminLogEventActionChangeBackgroundEmojiTypeID: "channelAdminLogEventActionChangeBackgroundEmoji#445fc434", ChannelAdminLogEventTypeID: "channelAdminLogEvent#1fad68cd", ChannelsAdminLogResultsTypeID: "channels.adminLogResults#ed8af74d", ChannelAdminLogEventsFilterTypeID: "channelAdminLogEventsFilter#ea107ae4", @@ -1000,7 +1008,7 @@ func TypesMap() map[uint32]string { MessageViewsTypeID: "messageViews#455b853d", MessagesMessageViewsTypeID: "messages.messageViews#b6c4f543", MessagesDiscussionMessageTypeID: "messages.discussionMessage#a6341782", - MessageReplyHeaderTypeID: "messageReplyHeader#a6d57763", + MessageReplyHeaderTypeID: "messageReplyHeader#6eebcabd", MessageReplyStoryHeaderTypeID: "messageReplyStoryHeader#9c98bfc1", MessageRepliesTypeID: "messageReplies#83d60fc2", PeerBlockedTypeID: "peerBlocked#e8fd8014", @@ -1091,11 +1099,14 @@ func TypesMap() map[uint32]string { AttachMenuPeerTypeBroadcastTypeID: "attachMenuPeerTypeBroadcast#7bfbdefc", InputInvoiceMessageTypeID: "inputInvoiceMessage#c5b56859", InputInvoiceSlugTypeID: "inputInvoiceSlug#c326caef", + InputInvoicePremiumGiftCodeTypeID: "inputInvoicePremiumGiftCode#98986c0d", PaymentsExportedInvoiceTypeID: "payments.exportedInvoice#aed0cbd9", MessagesTranscribedAudioTypeID: "messages.transcribedAudio#93752c52", HelpPremiumPromoTypeID: "help.premiumPromo#5334759c", InputStorePaymentPremiumSubscriptionTypeID: "inputStorePaymentPremiumSubscription#a6751e66", InputStorePaymentGiftPremiumTypeID: "inputStorePaymentGiftPremium#616f7fe8", + InputStorePaymentPremiumGiftCodeTypeID: "inputStorePaymentPremiumGiftCode#a3805f3f", + InputStorePaymentPremiumGiveawayTypeID: "inputStorePaymentPremiumGiveaway#7c9375e6", PremiumGiftOptionTypeID: "premiumGiftOption#74c34319", PaymentFormMethodTypeID: "paymentFormMethod#88f8f21b", EmojiStatusEmptyTypeID: "emojiStatusEmpty#2de11aae", @@ -1175,7 +1186,7 @@ func TypesMap() map[uint32]string { StoryViewTypeID: "storyView#b0bdeac5", StoriesStoryViewsListTypeID: "stories.storyViewsList#46e9b9ec", StoriesStoryViewsTypeID: "stories.storyViews#de9eed1d", - InputReplyToMessageTypeID: "inputReplyToMessage#9c5386e4", + InputReplyToMessageTypeID: "inputReplyToMessage#73ec805", InputReplyToStoryTypeID: "inputReplyToStory#15b0f283", ExportedStoryLinkTypeID: "exportedStoryLink#3fc9053b", StoriesStealthModeTypeID: "storiesStealthMode#712e27fd", @@ -1186,12 +1197,17 @@ func TypesMap() map[uint32]string { MediaAreaSuggestedReactionTypeID: "mediaAreaSuggestedReaction#14455871", PeerStoriesTypeID: "peerStories#9a35e999", StoriesPeerStoriesTypeID: "stories.peerStories#cae68768", - StoriesBoostsStatusTypeID: "stories.boostsStatus#e5c1aa5c", - StoriesCanApplyBoostOkTypeID: "stories.canApplyBoostOk#c3173587", - StoriesCanApplyBoostReplaceTypeID: "stories.canApplyBoostReplace#712c4655", - BoosterTypeID: "booster#e9e6380", - StoriesBoostersListTypeID: "stories.boostersList#f3dd3d1d", MessagesWebPageTypeID: "messages.webPage#fd5e12bd", + PremiumGiftCodeOptionTypeID: "premiumGiftCodeOption#257e962b", + PaymentsCheckedGiftCodeTypeID: "payments.checkedGiftCode#b722f158", + PaymentsGiveawayInfoTypeID: "payments.giveawayInfo#4367daa0", + PaymentsGiveawayInfoResultsTypeID: "payments.giveawayInfoResults#cd5570", + PrepaidGiveawayTypeID: "prepaidGiveaway#b2539d54", + BoostTypeID: "boost#2a1c8c71", + PremiumBoostsListTypeID: "premium.boostsList#86f8613c", + MyBoostTypeID: "myBoost#c448415c", + PremiumMyBoostsTypeID: "premium.myBoosts#9ae228e2", + PremiumBoostsStatusTypeID: "premium.boostsStatus#4959427a", InvokeAfterMsgRequestTypeID: "invokeAfterMsg#cb9f372d", InvokeAfterMsgsRequestTypeID: "invokeAfterMsgs#3dc4b4f0", InitConnectionRequestTypeID: "initConnection#c1cd5ea9", @@ -1309,6 +1325,8 @@ func TypesMap() map[uint32]string { AccountSaveAutoSaveSettingsRequestTypeID: "account.saveAutoSaveSettings#d69b8361", AccountDeleteAutoSaveExceptionsRequestTypeID: "account.deleteAutoSaveExceptions#53bc0020", AccountInvalidateSignInCodesRequestTypeID: "account.invalidateSignInCodes#ca8ae8ba", + AccountUpdateColorRequestTypeID: "account.updateColor#a001cc43", + AccountGetDefaultBackgroundEmojisRequestTypeID: "account.getDefaultBackgroundEmojis#a60ab9ce", UsersGetUsersRequestTypeID: "users.getUsers#d91a548", UsersGetFullUserRequestTypeID: "users.getFullUser#b60f5918", UsersSetSecureValueErrorsRequestTypeID: "users.setSecureValueErrors#90c894b5", @@ -1398,7 +1416,7 @@ func TypesMap() map[uint32]string { MessagesGetBotCallbackAnswerRequestTypeID: "messages.getBotCallbackAnswer#9342ca07", MessagesSetBotCallbackAnswerRequestTypeID: "messages.setBotCallbackAnswer#d58f130a", MessagesGetPeerDialogsRequestTypeID: "messages.getPeerDialogs#e470bcfd", - MessagesSaveDraftRequestTypeID: "messages.saveDraft#b4331e3f", + MessagesSaveDraftRequestTypeID: "messages.saveDraft#7ff3b806", MessagesGetAllDraftsRequestTypeID: "messages.getAllDrafts#6a3f8d65", MessagesGetFeaturedStickersRequestTypeID: "messages.getFeaturedStickers#64780b14", MessagesReadFeaturedStickersRequestTypeID: "messages.readFeaturedStickers#5b118126", @@ -1619,6 +1637,7 @@ func TypesMap() map[uint32]string { ChannelsReportAntiSpamFalsePositiveRequestTypeID: "channels.reportAntiSpamFalsePositive#a850a693", ChannelsToggleParticipantsHiddenRequestTypeID: "channels.toggleParticipantsHidden#6a6e7854", ChannelsClickSponsoredMessageRequestTypeID: "channels.clickSponsoredMessage#18afbc93", + ChannelsUpdateColorRequestTypeID: "channels.updateColor#621a201f", BotsSendCustomRequestRequestTypeID: "bots.sendCustomRequest#aa2769ed", BotsAnswerWebhookJSONQueryRequestTypeID: "bots.answerWebhookJSONQuery#e6213f4d", BotsSetBotCommandsRequestTypeID: "bots.setBotCommands#517165a", @@ -1646,6 +1665,11 @@ func TypesMap() map[uint32]string { PaymentsAssignAppStoreTransactionRequestTypeID: "payments.assignAppStoreTransaction#80ed747d", PaymentsAssignPlayMarketTransactionRequestTypeID: "payments.assignPlayMarketTransaction#dffd50d3", PaymentsCanPurchasePremiumRequestTypeID: "payments.canPurchasePremium#9fc19eb6", + PaymentsGetPremiumGiftCodeOptionsRequestTypeID: "payments.getPremiumGiftCodeOptions#2757ba54", + PaymentsCheckGiftCodeRequestTypeID: "payments.checkGiftCode#8e51b4c1", + PaymentsApplyGiftCodeRequestTypeID: "payments.applyGiftCode#f6e26854", + PaymentsGetGiveawayInfoRequestTypeID: "payments.getGiveawayInfo#f4239425", + PaymentsLaunchPrepaidGiveawayRequestTypeID: "payments.launchPrepaidGiveaway#5ff58f20", StickersCreateStickerSetRequestTypeID: "stickers.createStickerSet#9021ab67", StickersRemoveStickerFromSetRequestTypeID: "stickers.removeStickerFromSet#f7760f51", StickersChangeStickerPositionRequestTypeID: "stickers.changeStickerPosition#ffb6d4ca", @@ -1732,10 +1756,10 @@ func TypesMap() map[uint32]string { StoriesGetPeerMaxIDsRequestTypeID: "stories.getPeerMaxIDs#535983c3", StoriesGetChatsToSendRequestTypeID: "stories.getChatsToSend#a56a8b60", StoriesTogglePeerStoriesHiddenRequestTypeID: "stories.togglePeerStoriesHidden#bd0415c4", - StoriesGetBoostsStatusRequestTypeID: "stories.getBoostsStatus#4c449472", - StoriesGetBoostersListRequestTypeID: "stories.getBoostersList#337ef980", - StoriesCanApplyBoostRequestTypeID: "stories.canApplyBoost#db05c1bd", - StoriesApplyBoostRequestTypeID: "stories.applyBoost#f29d7c2b", + PremiumGetBoostsListRequestTypeID: "premium.getBoostsList#60f67660", + PremiumGetMyBoostsRequestTypeID: "premium.getMyBoosts#be77b4a", + PremiumApplyBoostRequestTypeID: "premium.applyBoost#6b7da746", + PremiumGetBoostsStatusRequestTypeID: "premium.getBoostsStatus#42f1f61", IntTypeID: "int#a8509bda", LongTypeID: "long#22076cba", DoubleTypeID: "double#2210c154", @@ -1790,6 +1814,7 @@ func NamesMap() map[string]uint32 { "inputMediaPoll": InputMediaPollTypeID, "inputMediaDice": InputMediaDiceTypeID, "inputMediaStory": InputMediaStoryTypeID, + "inputMediaWebPage": InputMediaWebPageTypeID, "inputChatPhotoEmpty": InputChatPhotoEmptyTypeID, "inputChatUploadedPhoto": InputChatUploadedPhotoTypeID, "inputChatPhoto": InputChatPhotoTypeID, @@ -1861,6 +1886,7 @@ func NamesMap() map[string]uint32 { "messageMediaPoll": MessageMediaPollTypeID, "messageMediaDice": MessageMediaDiceTypeID, "messageMediaStory": MessageMediaStoryTypeID, + "messageMediaGiveaway": MessageMediaGiveawayTypeID, "messageActionEmpty": MessageActionEmptyTypeID, "messageActionChatCreate": MessageActionChatCreateTypeID, "messageActionChatEditTitle": MessageActionChatEditTitleTypeID, @@ -1900,6 +1926,8 @@ func NamesMap() map[string]uint32 { "messageActionRequestedPeer": MessageActionRequestedPeerTypeID, "messageActionSetChatWallPaper": MessageActionSetChatWallPaperTypeID, "messageActionSetSameChatWallPaper": MessageActionSetSameChatWallPaperTypeID, + "messageActionGiftCode": MessageActionGiftCodeTypeID, + "messageActionGiveawayLaunch": MessageActionGiveawayLaunchTypeID, "dialog": DialogTypeID, "dialogFolder": DialogFolderTypeID, "photoEmpty": PhotoEmptyTypeID, @@ -2284,10 +2312,10 @@ func NamesMap() map[string]uint32 { "messageEntityCashtag": MessageEntityCashtagTypeID, "messageEntityUnderline": MessageEntityUnderlineTypeID, "messageEntityStrike": MessageEntityStrikeTypeID, - "messageEntityBlockquote": MessageEntityBlockquoteTypeID, "messageEntityBankCard": MessageEntityBankCardTypeID, "messageEntitySpoiler": MessageEntitySpoilerTypeID, "messageEntityCustomEmoji": MessageEntityCustomEmojiTypeID, + "messageEntityBlockquote": MessageEntityBlockquoteTypeID, "inputChannelEmpty": InputChannelEmptyTypeID, "inputChannel": InputChannelTypeID, "inputChannelFromMessage": InputChannelFromMessageTypeID, @@ -2325,6 +2353,7 @@ func NamesMap() map[string]uint32 { "inputBotInlineMessageMediaContact": InputBotInlineMessageMediaContactTypeID, "inputBotInlineMessageGame": InputBotInlineMessageGameTypeID, "inputBotInlineMessageMediaInvoice": InputBotInlineMessageMediaInvoiceTypeID, + "inputBotInlineMessageMediaWebPage": InputBotInlineMessageMediaWebPageTypeID, "inputBotInlineResult": InputBotInlineResultTypeID, "inputBotInlineResultPhoto": InputBotInlineResultPhotoTypeID, "inputBotInlineResultDocument": InputBotInlineResultDocumentTypeID, @@ -2335,6 +2364,7 @@ func NamesMap() map[string]uint32 { "botInlineMessageMediaVenue": BotInlineMessageMediaVenueTypeID, "botInlineMessageMediaContact": BotInlineMessageMediaContactTypeID, "botInlineMessageMediaInvoice": BotInlineMessageMediaInvoiceTypeID, + "botInlineMessageMediaWebPage": BotInlineMessageMediaWebPageTypeID, "botInlineResult": BotInlineResultTypeID, "botInlineMediaResult": BotInlineMediaResultTypeID, "messages.botResults": MessagesBotResultsTypeID, @@ -2533,6 +2563,8 @@ func NamesMap() map[string]uint32 { "channelAdminLogEventActionDeleteTopic": ChannelAdminLogEventActionDeleteTopicTypeID, "channelAdminLogEventActionPinTopic": ChannelAdminLogEventActionPinTopicTypeID, "channelAdminLogEventActionToggleAntiSpam": ChannelAdminLogEventActionToggleAntiSpamTypeID, + "channelAdminLogEventActionChangeColor": ChannelAdminLogEventActionChangeColorTypeID, + "channelAdminLogEventActionChangeBackgroundEmoji": ChannelAdminLogEventActionChangeBackgroundEmojiTypeID, "channelAdminLogEvent": ChannelAdminLogEventTypeID, "channels.adminLogResults": ChannelsAdminLogResultsTypeID, "channelAdminLogEventsFilter": ChannelAdminLogEventsFilterTypeID, @@ -2809,11 +2841,14 @@ func NamesMap() map[string]uint32 { "attachMenuPeerTypeBroadcast": AttachMenuPeerTypeBroadcastTypeID, "inputInvoiceMessage": InputInvoiceMessageTypeID, "inputInvoiceSlug": InputInvoiceSlugTypeID, + "inputInvoicePremiumGiftCode": InputInvoicePremiumGiftCodeTypeID, "payments.exportedInvoice": PaymentsExportedInvoiceTypeID, "messages.transcribedAudio": MessagesTranscribedAudioTypeID, "help.premiumPromo": HelpPremiumPromoTypeID, "inputStorePaymentPremiumSubscription": InputStorePaymentPremiumSubscriptionTypeID, "inputStorePaymentGiftPremium": InputStorePaymentGiftPremiumTypeID, + "inputStorePaymentPremiumGiftCode": InputStorePaymentPremiumGiftCodeTypeID, + "inputStorePaymentPremiumGiveaway": InputStorePaymentPremiumGiveawayTypeID, "premiumGiftOption": PremiumGiftOptionTypeID, "paymentFormMethod": PaymentFormMethodTypeID, "emojiStatusEmpty": EmojiStatusEmptyTypeID, @@ -2904,12 +2939,17 @@ func NamesMap() map[string]uint32 { "mediaAreaSuggestedReaction": MediaAreaSuggestedReactionTypeID, "peerStories": PeerStoriesTypeID, "stories.peerStories": StoriesPeerStoriesTypeID, - "stories.boostsStatus": StoriesBoostsStatusTypeID, - "stories.canApplyBoostOk": StoriesCanApplyBoostOkTypeID, - "stories.canApplyBoostReplace": StoriesCanApplyBoostReplaceTypeID, - "booster": BoosterTypeID, - "stories.boostersList": StoriesBoostersListTypeID, "messages.webPage": MessagesWebPageTypeID, + "premiumGiftCodeOption": PremiumGiftCodeOptionTypeID, + "payments.checkedGiftCode": PaymentsCheckedGiftCodeTypeID, + "payments.giveawayInfo": PaymentsGiveawayInfoTypeID, + "payments.giveawayInfoResults": PaymentsGiveawayInfoResultsTypeID, + "prepaidGiveaway": PrepaidGiveawayTypeID, + "boost": BoostTypeID, + "premium.boostsList": PremiumBoostsListTypeID, + "myBoost": MyBoostTypeID, + "premium.myBoosts": PremiumMyBoostsTypeID, + "premium.boostsStatus": PremiumBoostsStatusTypeID, "invokeAfterMsg": InvokeAfterMsgRequestTypeID, "invokeAfterMsgs": InvokeAfterMsgsRequestTypeID, "initConnection": InitConnectionRequestTypeID, @@ -3027,6 +3067,8 @@ func NamesMap() map[string]uint32 { "account.saveAutoSaveSettings": AccountSaveAutoSaveSettingsRequestTypeID, "account.deleteAutoSaveExceptions": AccountDeleteAutoSaveExceptionsRequestTypeID, "account.invalidateSignInCodes": AccountInvalidateSignInCodesRequestTypeID, + "account.updateColor": AccountUpdateColorRequestTypeID, + "account.getDefaultBackgroundEmojis": AccountGetDefaultBackgroundEmojisRequestTypeID, "users.getUsers": UsersGetUsersRequestTypeID, "users.getFullUser": UsersGetFullUserRequestTypeID, "users.setSecureValueErrors": UsersSetSecureValueErrorsRequestTypeID, @@ -3337,6 +3379,7 @@ func NamesMap() map[string]uint32 { "channels.reportAntiSpamFalsePositive": ChannelsReportAntiSpamFalsePositiveRequestTypeID, "channels.toggleParticipantsHidden": ChannelsToggleParticipantsHiddenRequestTypeID, "channels.clickSponsoredMessage": ChannelsClickSponsoredMessageRequestTypeID, + "channels.updateColor": ChannelsUpdateColorRequestTypeID, "bots.sendCustomRequest": BotsSendCustomRequestRequestTypeID, "bots.answerWebhookJSONQuery": BotsAnswerWebhookJSONQueryRequestTypeID, "bots.setBotCommands": BotsSetBotCommandsRequestTypeID, @@ -3364,6 +3407,11 @@ func NamesMap() map[string]uint32 { "payments.assignAppStoreTransaction": PaymentsAssignAppStoreTransactionRequestTypeID, "payments.assignPlayMarketTransaction": PaymentsAssignPlayMarketTransactionRequestTypeID, "payments.canPurchasePremium": PaymentsCanPurchasePremiumRequestTypeID, + "payments.getPremiumGiftCodeOptions": PaymentsGetPremiumGiftCodeOptionsRequestTypeID, + "payments.checkGiftCode": PaymentsCheckGiftCodeRequestTypeID, + "payments.applyGiftCode": PaymentsApplyGiftCodeRequestTypeID, + "payments.getGiveawayInfo": PaymentsGetGiveawayInfoRequestTypeID, + "payments.launchPrepaidGiveaway": PaymentsLaunchPrepaidGiveawayRequestTypeID, "stickers.createStickerSet": StickersCreateStickerSetRequestTypeID, "stickers.removeStickerFromSet": StickersRemoveStickerFromSetRequestTypeID, "stickers.changeStickerPosition": StickersChangeStickerPositionRequestTypeID, @@ -3450,10 +3498,10 @@ func NamesMap() map[string]uint32 { "stories.getPeerMaxIDs": StoriesGetPeerMaxIDsRequestTypeID, "stories.getChatsToSend": StoriesGetChatsToSendRequestTypeID, "stories.togglePeerStoriesHidden": StoriesTogglePeerStoriesHiddenRequestTypeID, - "stories.getBoostsStatus": StoriesGetBoostsStatusRequestTypeID, - "stories.getBoostersList": StoriesGetBoostersListRequestTypeID, - "stories.canApplyBoost": StoriesCanApplyBoostRequestTypeID, - "stories.applyBoost": StoriesApplyBoostRequestTypeID, + "premium.getBoostsList": PremiumGetBoostsListRequestTypeID, + "premium.getMyBoosts": PremiumGetMyBoostsRequestTypeID, + "premium.applyBoost": PremiumApplyBoostRequestTypeID, + "premium.getBoostsStatus": PremiumGetBoostsStatusRequestTypeID, "int": IntTypeID, "long": LongTypeID, "double": DoubleTypeID, @@ -3508,6 +3556,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputMediaPollTypeID: func() bin.Object { return &InputMediaPoll{} }, InputMediaDiceTypeID: func() bin.Object { return &InputMediaDice{} }, InputMediaStoryTypeID: func() bin.Object { return &InputMediaStory{} }, + InputMediaWebPageTypeID: func() bin.Object { return &InputMediaWebPage{} }, InputChatPhotoEmptyTypeID: func() bin.Object { return &InputChatPhotoEmpty{} }, InputChatUploadedPhotoTypeID: func() bin.Object { return &InputChatUploadedPhoto{} }, InputChatPhotoTypeID: func() bin.Object { return &InputChatPhoto{} }, @@ -3579,6 +3628,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessageMediaPollTypeID: func() bin.Object { return &MessageMediaPoll{} }, MessageMediaDiceTypeID: func() bin.Object { return &MessageMediaDice{} }, MessageMediaStoryTypeID: func() bin.Object { return &MessageMediaStory{} }, + MessageMediaGiveawayTypeID: func() bin.Object { return &MessageMediaGiveaway{} }, MessageActionEmptyTypeID: func() bin.Object { return &MessageActionEmpty{} }, MessageActionChatCreateTypeID: func() bin.Object { return &MessageActionChatCreate{} }, MessageActionChatEditTitleTypeID: func() bin.Object { return &MessageActionChatEditTitle{} }, @@ -3618,6 +3668,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessageActionRequestedPeerTypeID: func() bin.Object { return &MessageActionRequestedPeer{} }, MessageActionSetChatWallPaperTypeID: func() bin.Object { return &MessageActionSetChatWallPaper{} }, MessageActionSetSameChatWallPaperTypeID: func() bin.Object { return &MessageActionSetSameChatWallPaper{} }, + MessageActionGiftCodeTypeID: func() bin.Object { return &MessageActionGiftCode{} }, + MessageActionGiveawayLaunchTypeID: func() bin.Object { return &MessageActionGiveawayLaunch{} }, DialogTypeID: func() bin.Object { return &Dialog{} }, DialogFolderTypeID: func() bin.Object { return &DialogFolder{} }, PhotoEmptyTypeID: func() bin.Object { return &PhotoEmpty{} }, @@ -4002,10 +4054,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessageEntityCashtagTypeID: func() bin.Object { return &MessageEntityCashtag{} }, MessageEntityUnderlineTypeID: func() bin.Object { return &MessageEntityUnderline{} }, MessageEntityStrikeTypeID: func() bin.Object { return &MessageEntityStrike{} }, - MessageEntityBlockquoteTypeID: func() bin.Object { return &MessageEntityBlockquote{} }, MessageEntityBankCardTypeID: func() bin.Object { return &MessageEntityBankCard{} }, MessageEntitySpoilerTypeID: func() bin.Object { return &MessageEntitySpoiler{} }, MessageEntityCustomEmojiTypeID: func() bin.Object { return &MessageEntityCustomEmoji{} }, + MessageEntityBlockquoteTypeID: func() bin.Object { return &MessageEntityBlockquote{} }, InputChannelEmptyTypeID: func() bin.Object { return &InputChannelEmpty{} }, InputChannelTypeID: func() bin.Object { return &InputChannel{} }, InputChannelFromMessageTypeID: func() bin.Object { return &InputChannelFromMessage{} }, @@ -4043,6 +4095,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputBotInlineMessageMediaContactTypeID: func() bin.Object { return &InputBotInlineMessageMediaContact{} }, InputBotInlineMessageGameTypeID: func() bin.Object { return &InputBotInlineMessageGame{} }, InputBotInlineMessageMediaInvoiceTypeID: func() bin.Object { return &InputBotInlineMessageMediaInvoice{} }, + InputBotInlineMessageMediaWebPageTypeID: func() bin.Object { return &InputBotInlineMessageMediaWebPage{} }, InputBotInlineResultTypeID: func() bin.Object { return &InputBotInlineResult{} }, InputBotInlineResultPhotoTypeID: func() bin.Object { return &InputBotInlineResultPhoto{} }, InputBotInlineResultDocumentTypeID: func() bin.Object { return &InputBotInlineResultDocument{} }, @@ -4053,6 +4106,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { BotInlineMessageMediaVenueTypeID: func() bin.Object { return &BotInlineMessageMediaVenue{} }, BotInlineMessageMediaContactTypeID: func() bin.Object { return &BotInlineMessageMediaContact{} }, BotInlineMessageMediaInvoiceTypeID: func() bin.Object { return &BotInlineMessageMediaInvoice{} }, + BotInlineMessageMediaWebPageTypeID: func() bin.Object { return &BotInlineMessageMediaWebPage{} }, BotInlineResultTypeID: func() bin.Object { return &BotInlineResult{} }, BotInlineMediaResultTypeID: func() bin.Object { return &BotInlineMediaResult{} }, MessagesBotResultsTypeID: func() bin.Object { return &MessagesBotResults{} }, @@ -4251,6 +4305,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { ChannelAdminLogEventActionDeleteTopicTypeID: func() bin.Object { return &ChannelAdminLogEventActionDeleteTopic{} }, ChannelAdminLogEventActionPinTopicTypeID: func() bin.Object { return &ChannelAdminLogEventActionPinTopic{} }, ChannelAdminLogEventActionToggleAntiSpamTypeID: func() bin.Object { return &ChannelAdminLogEventActionToggleAntiSpam{} }, + ChannelAdminLogEventActionChangeColorTypeID: func() bin.Object { return &ChannelAdminLogEventActionChangeColor{} }, + ChannelAdminLogEventActionChangeBackgroundEmojiTypeID: func() bin.Object { return &ChannelAdminLogEventActionChangeBackgroundEmoji{} }, ChannelAdminLogEventTypeID: func() bin.Object { return &ChannelAdminLogEvent{} }, ChannelsAdminLogResultsTypeID: func() bin.Object { return &ChannelsAdminLogResults{} }, ChannelAdminLogEventsFilterTypeID: func() bin.Object { return &ChannelAdminLogEventsFilter{} }, @@ -4527,11 +4583,14 @@ func TypesConstructorMap() map[uint32]func() bin.Object { AttachMenuPeerTypeBroadcastTypeID: func() bin.Object { return &AttachMenuPeerTypeBroadcast{} }, InputInvoiceMessageTypeID: func() bin.Object { return &InputInvoiceMessage{} }, InputInvoiceSlugTypeID: func() bin.Object { return &InputInvoiceSlug{} }, + InputInvoicePremiumGiftCodeTypeID: func() bin.Object { return &InputInvoicePremiumGiftCode{} }, PaymentsExportedInvoiceTypeID: func() bin.Object { return &PaymentsExportedInvoice{} }, MessagesTranscribedAudioTypeID: func() bin.Object { return &MessagesTranscribedAudio{} }, HelpPremiumPromoTypeID: func() bin.Object { return &HelpPremiumPromo{} }, InputStorePaymentPremiumSubscriptionTypeID: func() bin.Object { return &InputStorePaymentPremiumSubscription{} }, InputStorePaymentGiftPremiumTypeID: func() bin.Object { return &InputStorePaymentGiftPremium{} }, + InputStorePaymentPremiumGiftCodeTypeID: func() bin.Object { return &InputStorePaymentPremiumGiftCode{} }, + InputStorePaymentPremiumGiveawayTypeID: func() bin.Object { return &InputStorePaymentPremiumGiveaway{} }, PremiumGiftOptionTypeID: func() bin.Object { return &PremiumGiftOption{} }, PaymentFormMethodTypeID: func() bin.Object { return &PaymentFormMethod{} }, EmojiStatusEmptyTypeID: func() bin.Object { return &EmojiStatusEmpty{} }, @@ -4622,12 +4681,17 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MediaAreaSuggestedReactionTypeID: func() bin.Object { return &MediaAreaSuggestedReaction{} }, PeerStoriesTypeID: func() bin.Object { return &PeerStories{} }, StoriesPeerStoriesTypeID: func() bin.Object { return &StoriesPeerStories{} }, - StoriesBoostsStatusTypeID: func() bin.Object { return &StoriesBoostsStatus{} }, - StoriesCanApplyBoostOkTypeID: func() bin.Object { return &StoriesCanApplyBoostOk{} }, - StoriesCanApplyBoostReplaceTypeID: func() bin.Object { return &StoriesCanApplyBoostReplace{} }, - BoosterTypeID: func() bin.Object { return &Booster{} }, - StoriesBoostersListTypeID: func() bin.Object { return &StoriesBoostersList{} }, MessagesWebPageTypeID: func() bin.Object { return &MessagesWebPage{} }, + PremiumGiftCodeOptionTypeID: func() bin.Object { return &PremiumGiftCodeOption{} }, + PaymentsCheckedGiftCodeTypeID: func() bin.Object { return &PaymentsCheckedGiftCode{} }, + PaymentsGiveawayInfoTypeID: func() bin.Object { return &PaymentsGiveawayInfo{} }, + PaymentsGiveawayInfoResultsTypeID: func() bin.Object { return &PaymentsGiveawayInfoResults{} }, + PrepaidGiveawayTypeID: func() bin.Object { return &PrepaidGiveaway{} }, + BoostTypeID: func() bin.Object { return &Boost{} }, + PremiumBoostsListTypeID: func() bin.Object { return &PremiumBoostsList{} }, + MyBoostTypeID: func() bin.Object { return &MyBoost{} }, + PremiumMyBoostsTypeID: func() bin.Object { return &PremiumMyBoosts{} }, + PremiumBoostsStatusTypeID: func() bin.Object { return &PremiumBoostsStatus{} }, InvokeAfterMsgRequestTypeID: func() bin.Object { return &InvokeAfterMsgRequest{} }, InvokeAfterMsgsRequestTypeID: func() bin.Object { return &InvokeAfterMsgsRequest{} }, InitConnectionRequestTypeID: func() bin.Object { return &InitConnectionRequest{} }, @@ -4745,6 +4809,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { AccountSaveAutoSaveSettingsRequestTypeID: func() bin.Object { return &AccountSaveAutoSaveSettingsRequest{} }, AccountDeleteAutoSaveExceptionsRequestTypeID: func() bin.Object { return &AccountDeleteAutoSaveExceptionsRequest{} }, AccountInvalidateSignInCodesRequestTypeID: func() bin.Object { return &AccountInvalidateSignInCodesRequest{} }, + AccountUpdateColorRequestTypeID: func() bin.Object { return &AccountUpdateColorRequest{} }, + AccountGetDefaultBackgroundEmojisRequestTypeID: func() bin.Object { return &AccountGetDefaultBackgroundEmojisRequest{} }, UsersGetUsersRequestTypeID: func() bin.Object { return &UsersGetUsersRequest{} }, UsersGetFullUserRequestTypeID: func() bin.Object { return &UsersGetFullUserRequest{} }, UsersSetSecureValueErrorsRequestTypeID: func() bin.Object { return &UsersSetSecureValueErrorsRequest{} }, @@ -5055,6 +5121,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { ChannelsReportAntiSpamFalsePositiveRequestTypeID: func() bin.Object { return &ChannelsReportAntiSpamFalsePositiveRequest{} }, ChannelsToggleParticipantsHiddenRequestTypeID: func() bin.Object { return &ChannelsToggleParticipantsHiddenRequest{} }, ChannelsClickSponsoredMessageRequestTypeID: func() bin.Object { return &ChannelsClickSponsoredMessageRequest{} }, + ChannelsUpdateColorRequestTypeID: func() bin.Object { return &ChannelsUpdateColorRequest{} }, BotsSendCustomRequestRequestTypeID: func() bin.Object { return &BotsSendCustomRequestRequest{} }, BotsAnswerWebhookJSONQueryRequestTypeID: func() bin.Object { return &BotsAnswerWebhookJSONQueryRequest{} }, BotsSetBotCommandsRequestTypeID: func() bin.Object { return &BotsSetBotCommandsRequest{} }, @@ -5082,6 +5149,11 @@ 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{} }, + PaymentsGetPremiumGiftCodeOptionsRequestTypeID: func() bin.Object { return &PaymentsGetPremiumGiftCodeOptionsRequest{} }, + PaymentsCheckGiftCodeRequestTypeID: func() bin.Object { return &PaymentsCheckGiftCodeRequest{} }, + PaymentsApplyGiftCodeRequestTypeID: func() bin.Object { return &PaymentsApplyGiftCodeRequest{} }, + PaymentsGetGiveawayInfoRequestTypeID: func() bin.Object { return &PaymentsGetGiveawayInfoRequest{} }, + PaymentsLaunchPrepaidGiveawayRequestTypeID: func() bin.Object { return &PaymentsLaunchPrepaidGiveawayRequest{} }, StickersCreateStickerSetRequestTypeID: func() bin.Object { return &StickersCreateStickerSetRequest{} }, StickersRemoveStickerFromSetRequestTypeID: func() bin.Object { return &StickersRemoveStickerFromSetRequest{} }, StickersChangeStickerPositionRequestTypeID: func() bin.Object { return &StickersChangeStickerPositionRequest{} }, @@ -5168,10 +5240,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { StoriesGetPeerMaxIDsRequestTypeID: func() bin.Object { return &StoriesGetPeerMaxIDsRequest{} }, StoriesGetChatsToSendRequestTypeID: func() bin.Object { return &StoriesGetChatsToSendRequest{} }, StoriesTogglePeerStoriesHiddenRequestTypeID: func() bin.Object { return &StoriesTogglePeerStoriesHiddenRequest{} }, - StoriesGetBoostsStatusRequestTypeID: func() bin.Object { return &StoriesGetBoostsStatusRequest{} }, - StoriesGetBoostersListRequestTypeID: func() bin.Object { return &StoriesGetBoostersListRequest{} }, - StoriesCanApplyBoostRequestTypeID: func() bin.Object { return &StoriesCanApplyBoostRequest{} }, - StoriesApplyBoostRequestTypeID: func() bin.Object { return &StoriesApplyBoostRequest{} }, + PremiumGetBoostsListRequestTypeID: func() bin.Object { return &PremiumGetBoostsListRequest{} }, + PremiumGetMyBoostsRequestTypeID: func() bin.Object { return &PremiumGetMyBoostsRequest{} }, + PremiumApplyBoostRequestTypeID: func() bin.Object { return &PremiumApplyBoostRequest{} }, + PremiumGetBoostsStatusRequestTypeID: func() bin.Object { return &PremiumGetBoostsStatusRequest{} }, IntTypeID: func() bin.Object { return &Int{} }, LongTypeID: func() bin.Object { return &Long{} }, DoubleTypeID: func() bin.Object { return &Double{} }, @@ -5293,6 +5365,7 @@ func ClassConstructorsMap() map[string][]uint32 { BotInlineMessageMediaVenueTypeID, BotInlineMessageMediaContactTypeID, BotInlineMessageMediaInvoiceTypeID, + BotInlineMessageMediaWebPageTypeID, }, BotInlineResultClassName: { BotInlineResultTypeID, @@ -5347,6 +5420,8 @@ func ClassConstructorsMap() map[string][]uint32 { ChannelAdminLogEventActionDeleteTopicTypeID, ChannelAdminLogEventActionPinTopicTypeID, ChannelAdminLogEventActionToggleAntiSpamTypeID, + ChannelAdminLogEventActionChangeColorTypeID, + ChannelAdminLogEventActionChangeBackgroundEmojiTypeID, }, ChannelLocationClassName: { ChannelLocationEmptyTypeID, @@ -5570,6 +5645,7 @@ func ClassConstructorsMap() map[string][]uint32 { InputBotInlineMessageMediaContactTypeID, InputBotInlineMessageGameTypeID, InputBotInlineMessageMediaInvoiceTypeID, + InputBotInlineMessageMediaWebPageTypeID, }, InputBotInlineMessageIDClassName: { InputBotInlineMessageIDTypeID, @@ -5638,6 +5714,7 @@ func ClassConstructorsMap() map[string][]uint32 { InputInvoiceClassName: { InputInvoiceMessageTypeID, InputInvoiceSlugTypeID, + InputInvoicePremiumGiftCodeTypeID, }, InputMediaClassName: { InputMediaEmptyTypeID, @@ -5656,6 +5733,7 @@ func ClassConstructorsMap() map[string][]uint32 { InputMediaPollTypeID, InputMediaDiceTypeID, InputMediaStoryTypeID, + InputMediaWebPageTypeID, }, InputMessageClassName: { InputMessageIDTypeID, @@ -5739,6 +5817,8 @@ func ClassConstructorsMap() map[string][]uint32 { InputStorePaymentPurposeClassName: { InputStorePaymentPremiumSubscriptionTypeID, InputStorePaymentGiftPremiumTypeID, + InputStorePaymentPremiumGiftCodeTypeID, + InputStorePaymentPremiumGiveawayTypeID, }, InputThemeClassName: { InputThemeTypeID, @@ -5837,6 +5917,8 @@ func ClassConstructorsMap() map[string][]uint32 { MessageActionRequestedPeerTypeID, MessageActionSetChatWallPaperTypeID, MessageActionSetSameChatWallPaperTypeID, + MessageActionGiftCodeTypeID, + MessageActionGiveawayLaunchTypeID, }, MessageClassName: { MessageEmptyTypeID, @@ -5861,10 +5943,10 @@ func ClassConstructorsMap() map[string][]uint32 { MessageEntityCashtagTypeID, MessageEntityUnderlineTypeID, MessageEntityStrikeTypeID, - MessageEntityBlockquoteTypeID, MessageEntityBankCardTypeID, MessageEntitySpoilerTypeID, MessageEntityCustomEmojiTypeID, + MessageEntityBlockquoteTypeID, }, MessageExtendedMediaClassName: { MessageExtendedMediaPreviewTypeID, @@ -5885,6 +5967,7 @@ func ClassConstructorsMap() map[string][]uint32 { MessageMediaPollTypeID, MessageMediaDiceTypeID, MessageMediaStoryTypeID, + MessageMediaGiveawayTypeID, }, MessagePeerVoteClassName: { MessagePeerVoteTypeID, @@ -6049,6 +6132,10 @@ func ClassConstructorsMap() map[string][]uint32 { PasswordKdfAlgoUnknownTypeID, PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID, }, + PaymentsGiveawayInfoClassName: { + PaymentsGiveawayInfoTypeID, + PaymentsGiveawayInfoResultsTypeID, + }, PaymentsPaymentResultClassName: { PaymentsPaymentResultTypeID, PaymentsPaymentVerificationNeededTypeID, @@ -6262,10 +6349,6 @@ func ClassConstructorsMap() map[string][]uint32 { StoriesAllStoriesNotModifiedTypeID, StoriesAllStoriesTypeID, }, - StoriesCanApplyBoostResultClassName: { - StoriesCanApplyBoostOkTypeID, - StoriesCanApplyBoostReplaceTypeID, - }, StoryItemClassName: { StoryItemDeletedTypeID, StoryItemSkippedTypeID, diff --git a/tg/tl_server_gen.go b/tg/tl_server_gen.go index 48b816845a..8e58181b1f 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -2119,6 +2119,44 @@ func (s *ServerDispatcher) OnAccountInvalidateSignInCodes(f func(ctx context.Con s.handlers[AccountInvalidateSignInCodesRequestTypeID] = handler } +func (s *ServerDispatcher) OnAccountUpdateColor(f func(ctx context.Context, request *AccountUpdateColorRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountUpdateColorRequest + 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[AccountUpdateColorRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnAccountGetDefaultBackgroundEmojis(f func(ctx context.Context, hash int64) (EmojiListClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountGetDefaultBackgroundEmojisRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Hash) + if err != nil { + return nil, err + } + return &EmojiListBox{EmojiList: response}, nil + } + + s.handlers[AccountGetDefaultBackgroundEmojisRequestTypeID] = 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 @@ -7689,6 +7727,23 @@ func (s *ServerDispatcher) OnChannelsClickSponsoredMessage(f func(ctx context.Co s.handlers[ChannelsClickSponsoredMessageRequestTypeID] = handler } +func (s *ServerDispatcher) OnChannelsUpdateColor(f func(ctx context.Context, request *ChannelsUpdateColorRequest) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request ChannelsUpdateColorRequest + 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[ChannelsUpdateColorRequestTypeID] = handler +} + func (s *ServerDispatcher) OnBotsSendCustomRequest(f func(ctx context.Context, request *BotsSendCustomRequestRequest) (*DataJSON, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request BotsSendCustomRequestRequest @@ -8196,6 +8251,91 @@ func (s *ServerDispatcher) OnPaymentsCanPurchasePremium(f func(ctx context.Conte s.handlers[PaymentsCanPurchasePremiumRequestTypeID] = handler } +func (s *ServerDispatcher) OnPaymentsGetPremiumGiftCodeOptions(f func(ctx context.Context, request *PaymentsGetPremiumGiftCodeOptionsRequest) ([]PremiumGiftCodeOption, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsGetPremiumGiftCodeOptionsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &PremiumGiftCodeOptionVector{Elems: response}, nil + } + + s.handlers[PaymentsGetPremiumGiftCodeOptionsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsCheckGiftCode(f func(ctx context.Context, slug string) (*PaymentsCheckedGiftCode, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsCheckGiftCodeRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Slug) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[PaymentsCheckGiftCodeRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsApplyGiftCode(f func(ctx context.Context, slug string) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsApplyGiftCodeRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Slug) + if err != nil { + return nil, err + } + return &UpdatesBox{Updates: response}, nil + } + + s.handlers[PaymentsApplyGiftCodeRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsGetGiveawayInfo(f func(ctx context.Context, request *PaymentsGetGiveawayInfoRequest) (PaymentsGiveawayInfoClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsGetGiveawayInfoRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &PaymentsGiveawayInfoBox{GiveawayInfo: response}, nil + } + + s.handlers[PaymentsGetGiveawayInfoRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsLaunchPrepaidGiveaway(f func(ctx context.Context, request *PaymentsLaunchPrepaidGiveawayRequest) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsLaunchPrepaidGiveawayRequest + 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[PaymentsLaunchPrepaidGiveawayRequestTypeID] = 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 @@ -9714,60 +9854,60 @@ func (s *ServerDispatcher) OnStoriesTogglePeerStoriesHidden(f func(ctx context.C s.handlers[StoriesTogglePeerStoriesHiddenRequestTypeID] = handler } -func (s *ServerDispatcher) OnStoriesGetBoostsStatus(f func(ctx context.Context, peer InputPeerClass) (*StoriesBoostsStatus, error)) { +func (s *ServerDispatcher) OnPremiumGetBoostsList(f func(ctx context.Context, request *PremiumGetBoostsListRequest) (*PremiumBoostsList, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { - var request StoriesGetBoostsStatusRequest + var request PremiumGetBoostsListRequest if err := request.Decode(b); err != nil { return nil, err } - response, err := f(ctx, request.Peer) + response, err := f(ctx, &request) if err != nil { return nil, err } return response, nil } - s.handlers[StoriesGetBoostsStatusRequestTypeID] = handler + s.handlers[PremiumGetBoostsListRequestTypeID] = handler } -func (s *ServerDispatcher) OnStoriesGetBoostersList(f func(ctx context.Context, request *StoriesGetBoostersListRequest) (*StoriesBoostersList, error)) { +func (s *ServerDispatcher) OnPremiumGetMyBoosts(f func(ctx context.Context) (*PremiumMyBoosts, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { - var request StoriesGetBoostersListRequest + var request PremiumGetMyBoostsRequest if err := request.Decode(b); err != nil { return nil, err } - response, err := f(ctx, &request) + response, err := f(ctx) if err != nil { return nil, err } return response, nil } - s.handlers[StoriesGetBoostersListRequestTypeID] = handler + s.handlers[PremiumGetMyBoostsRequestTypeID] = handler } -func (s *ServerDispatcher) OnStoriesCanApplyBoost(f func(ctx context.Context, peer InputPeerClass) (StoriesCanApplyBoostResultClass, error)) { +func (s *ServerDispatcher) OnPremiumApplyBoost(f func(ctx context.Context, request *PremiumApplyBoostRequest) (*PremiumMyBoosts, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { - var request StoriesCanApplyBoostRequest + var request PremiumApplyBoostRequest if err := request.Decode(b); err != nil { return nil, err } - response, err := f(ctx, request.Peer) + response, err := f(ctx, &request) if err != nil { return nil, err } - return &StoriesCanApplyBoostResultBox{CanApplyBoostResult: response}, nil + return response, nil } - s.handlers[StoriesCanApplyBoostRequestTypeID] = handler + s.handlers[PremiumApplyBoostRequestTypeID] = handler } -func (s *ServerDispatcher) OnStoriesApplyBoost(f func(ctx context.Context, peer InputPeerClass) (bool, error)) { +func (s *ServerDispatcher) OnPremiumGetBoostsStatus(f func(ctx context.Context, peer InputPeerClass) (*PremiumBoostsStatus, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { - var request StoriesApplyBoostRequest + var request PremiumGetBoostsStatusRequest if err := request.Decode(b); err != nil { return nil, err } @@ -9776,14 +9916,10 @@ func (s *ServerDispatcher) OnStoriesApplyBoost(f func(ctx context.Context, peer if err != nil { return nil, err } - if response { - return &BoolBox{Bool: &BoolTrue{}}, nil - } - - return &BoolBox{Bool: &BoolFalse{}}, nil + return response, nil } - s.handlers[StoriesApplyBoostRequestTypeID] = handler + s.handlers[PremiumGetBoostsStatusRequestTypeID] = handler } func (s *ServerDispatcher) OnTestUseError(f func(ctx context.Context) (*Error, error)) { diff --git a/tg/tl_sticker_set_gen.go b/tg/tl_sticker_set_gen.go index 9c4df53638..440908b6d0 100644 --- a/tg/tl_sticker_set_gen.go +++ b/tg/tl_sticker_set_gen.go @@ -54,6 +54,8 @@ type StickerSet struct { Videos bool // This is a custom emoji stickerset Emojis bool + // TextColor field of StickerSet. + TextColor bool // When was this stickerset installed // // Use SetInstalledDate and GetInstalledDate helpers. @@ -131,6 +133,9 @@ func (s *StickerSet) Zero() bool { if !(s.Emojis == false) { return false } + if !(s.TextColor == false) { + return false + } if !(s.InstalledDate == 0) { return false } @@ -185,6 +190,7 @@ func (s *StickerSet) FillFrom(from interface { GetAnimated() (value bool) GetVideos() (value bool) GetEmojis() (value bool) + GetTextColor() (value bool) GetInstalledDate() (value int, ok bool) GetID() (value int64) GetAccessHash() (value int64) @@ -203,6 +209,7 @@ func (s *StickerSet) FillFrom(from interface { s.Animated = from.GetAnimated() s.Videos = from.GetVideos() s.Emojis = from.GetEmojis() + s.TextColor = from.GetTextColor() if val, ok := from.GetInstalledDate(); ok { s.InstalledDate = val } @@ -284,6 +291,11 @@ func (s *StickerSet) TypeInfo() tdp.Type { SchemaName: "emojis", Null: !s.Flags.Has(7), }, + { + Name: "TextColor", + SchemaName: "text_color", + Null: !s.Flags.Has(9), + }, { Name: "InstalledDate", SchemaName: "installed_date", @@ -357,6 +369,9 @@ func (s *StickerSet) SetFlags() { if !(s.Emojis == false) { s.Flags.Set(7) } + if !(s.TextColor == false) { + s.Flags.Set(9) + } if !(s.InstalledDate == 0) { s.Flags.Set(0) } @@ -451,6 +466,7 @@ func (s *StickerSet) DecodeBare(b *bin.Buffer) error { s.Animated = s.Flags.Has(5) s.Videos = s.Flags.Has(6) s.Emojis = s.Flags.Has(7) + s.TextColor = s.Flags.Has(9) if s.Flags.Has(0) { value, err := b.Int() if err != nil { @@ -655,6 +671,25 @@ func (s *StickerSet) GetEmojis() (value bool) { return s.Flags.Has(7) } +// SetTextColor sets value of TextColor conditional field. +func (s *StickerSet) SetTextColor(value bool) { + if value { + s.Flags.Set(9) + s.TextColor = true + } else { + s.Flags.Unset(9) + s.TextColor = false + } +} + +// GetTextColor returns value of TextColor conditional field. +func (s *StickerSet) GetTextColor() (value bool) { + if s == nil { + return + } + return s.Flags.Has(9) +} + // SetInstalledDate sets value of InstalledDate conditional field. func (s *StickerSet) SetInstalledDate(value int) { s.Flags.Set(0) diff --git a/tg/tl_stories_apply_boost_gen.go b/tg/tl_stories_apply_boost_gen.go deleted file mode 100644 index d9819c06e5..0000000000 --- a/tg/tl_stories_apply_boost_gen.go +++ /dev/null @@ -1,182 +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{} -) - -// StoriesApplyBoostRequest represents TL type `stories.applyBoost#f29d7c2b`. -// -// See https://core.telegram.org/method/stories.applyBoost for reference. -type StoriesApplyBoostRequest struct { - // Peer field of StoriesApplyBoostRequest. - Peer InputPeerClass -} - -// StoriesApplyBoostRequestTypeID is TL type id of StoriesApplyBoostRequest. -const StoriesApplyBoostRequestTypeID = 0xf29d7c2b - -// Ensuring interfaces in compile-time for StoriesApplyBoostRequest. -var ( - _ bin.Encoder = &StoriesApplyBoostRequest{} - _ bin.Decoder = &StoriesApplyBoostRequest{} - _ bin.BareEncoder = &StoriesApplyBoostRequest{} - _ bin.BareDecoder = &StoriesApplyBoostRequest{} -) - -func (a *StoriesApplyBoostRequest) Zero() bool { - if a == nil { - return true - } - if !(a.Peer == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (a *StoriesApplyBoostRequest) String() string { - if a == nil { - return "StoriesApplyBoostRequest(nil)" - } - type Alias StoriesApplyBoostRequest - return fmt.Sprintf("StoriesApplyBoostRequest%+v", Alias(*a)) -} - -// FillFrom fills StoriesApplyBoostRequest from given interface. -func (a *StoriesApplyBoostRequest) FillFrom(from interface { - GetPeer() (value InputPeerClass) -}) { - a.Peer = from.GetPeer() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StoriesApplyBoostRequest) TypeID() uint32 { - return StoriesApplyBoostRequestTypeID -} - -// TypeName returns name of type in TL schema. -func (*StoriesApplyBoostRequest) TypeName() string { - return "stories.applyBoost" -} - -// TypeInfo returns info about TL type. -func (a *StoriesApplyBoostRequest) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "stories.applyBoost", - ID: StoriesApplyBoostRequestTypeID, - } - if a == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Peer", - SchemaName: "peer", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (a *StoriesApplyBoostRequest) Encode(b *bin.Buffer) error { - if a == nil { - return fmt.Errorf("can't encode stories.applyBoost#f29d7c2b as nil") - } - b.PutID(StoriesApplyBoostRequestTypeID) - return a.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (a *StoriesApplyBoostRequest) EncodeBare(b *bin.Buffer) error { - if a == nil { - return fmt.Errorf("can't encode stories.applyBoost#f29d7c2b as nil") - } - if a.Peer == nil { - return fmt.Errorf("unable to encode stories.applyBoost#f29d7c2b: field peer is nil") - } - if err := a.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode stories.applyBoost#f29d7c2b: field peer: %w", err) - } - return nil -} - -// Decode implements bin.Decoder. -func (a *StoriesApplyBoostRequest) Decode(b *bin.Buffer) error { - if a == nil { - return fmt.Errorf("can't decode stories.applyBoost#f29d7c2b to nil") - } - if err := b.ConsumeID(StoriesApplyBoostRequestTypeID); err != nil { - return fmt.Errorf("unable to decode stories.applyBoost#f29d7c2b: %w", err) - } - return a.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (a *StoriesApplyBoostRequest) DecodeBare(b *bin.Buffer) error { - if a == nil { - return fmt.Errorf("can't decode stories.applyBoost#f29d7c2b to nil") - } - { - value, err := DecodeInputPeer(b) - if err != nil { - return fmt.Errorf("unable to decode stories.applyBoost#f29d7c2b: field peer: %w", err) - } - a.Peer = value - } - return nil -} - -// GetPeer returns value of Peer field. -func (a *StoriesApplyBoostRequest) GetPeer() (value InputPeerClass) { - if a == nil { - return - } - return a.Peer -} - -// StoriesApplyBoost invokes method stories.applyBoost#f29d7c2b returning error if any. -// -// See https://core.telegram.org/method/stories.applyBoost for reference. -func (c *Client) StoriesApplyBoost(ctx context.Context, peer InputPeerClass) (bool, error) { - var result BoolBox - - request := &StoriesApplyBoostRequest{ - Peer: peer, - } - 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_stories_boosters_list_gen.go b/tg/tl_stories_boosters_list_gen.go deleted file mode 100644 index 52c6103da3..0000000000 --- a/tg/tl_stories_boosters_list_gen.go +++ /dev/null @@ -1,319 +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{} -) - -// StoriesBoostersList represents TL type `stories.boostersList#f3dd3d1d`. -// -// See https://core.telegram.org/constructor/stories.boostersList for reference. -type StoriesBoostersList struct { - // Flags field of StoriesBoostersList. - Flags bin.Fields - // Count field of StoriesBoostersList. - Count int - // Boosters field of StoriesBoostersList. - Boosters []Booster - // NextOffset field of StoriesBoostersList. - // - // Use SetNextOffset and GetNextOffset helpers. - NextOffset string - // Users field of StoriesBoostersList. - Users []UserClass -} - -// StoriesBoostersListTypeID is TL type id of StoriesBoostersList. -const StoriesBoostersListTypeID = 0xf3dd3d1d - -// Ensuring interfaces in compile-time for StoriesBoostersList. -var ( - _ bin.Encoder = &StoriesBoostersList{} - _ bin.Decoder = &StoriesBoostersList{} - _ bin.BareEncoder = &StoriesBoostersList{} - _ bin.BareDecoder = &StoriesBoostersList{} -) - -func (b *StoriesBoostersList) Zero() bool { - if b == nil { - return true - } - if !(b.Flags.Zero()) { - return false - } - if !(b.Count == 0) { - return false - } - if !(b.Boosters == nil) { - return false - } - if !(b.NextOffset == "") { - return false - } - if !(b.Users == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (b *StoriesBoostersList) String() string { - if b == nil { - return "StoriesBoostersList(nil)" - } - type Alias StoriesBoostersList - return fmt.Sprintf("StoriesBoostersList%+v", Alias(*b)) -} - -// FillFrom fills StoriesBoostersList from given interface. -func (b *StoriesBoostersList) FillFrom(from interface { - GetCount() (value int) - GetBoosters() (value []Booster) - GetNextOffset() (value string, ok bool) - GetUsers() (value []UserClass) -}) { - b.Count = from.GetCount() - b.Boosters = from.GetBoosters() - if val, ok := from.GetNextOffset(); ok { - b.NextOffset = val - } - - b.Users = from.GetUsers() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StoriesBoostersList) TypeID() uint32 { - return StoriesBoostersListTypeID -} - -// TypeName returns name of type in TL schema. -func (*StoriesBoostersList) TypeName() string { - return "stories.boostersList" -} - -// TypeInfo returns info about TL type. -func (b *StoriesBoostersList) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "stories.boostersList", - ID: StoriesBoostersListTypeID, - } - if b == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Count", - SchemaName: "count", - }, - { - Name: "Boosters", - SchemaName: "boosters", - }, - { - Name: "NextOffset", - SchemaName: "next_offset", - Null: !b.Flags.Has(0), - }, - { - Name: "Users", - SchemaName: "users", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (b *StoriesBoostersList) SetFlags() { - if !(b.NextOffset == "") { - b.Flags.Set(0) - } -} - -// Encode implements bin.Encoder. -func (b *StoriesBoostersList) Encode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't encode stories.boostersList#f3dd3d1d as nil") - } - buf.PutID(StoriesBoostersListTypeID) - return b.EncodeBare(buf) -} - -// EncodeBare implements bin.BareEncoder. -func (b *StoriesBoostersList) EncodeBare(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't encode stories.boostersList#f3dd3d1d as nil") - } - b.SetFlags() - if err := b.Flags.Encode(buf); err != nil { - return fmt.Errorf("unable to encode stories.boostersList#f3dd3d1d: field flags: %w", err) - } - buf.PutInt(b.Count) - buf.PutVectorHeader(len(b.Boosters)) - for idx, v := range b.Boosters { - if err := v.Encode(buf); err != nil { - return fmt.Errorf("unable to encode stories.boostersList#f3dd3d1d: field boosters element with index %d: %w", idx, err) - } - } - if b.Flags.Has(0) { - buf.PutString(b.NextOffset) - } - buf.PutVectorHeader(len(b.Users)) - for idx, v := range b.Users { - if v == nil { - return fmt.Errorf("unable to encode stories.boostersList#f3dd3d1d: field users element with index %d is nil", idx) - } - if err := v.Encode(buf); err != nil { - return fmt.Errorf("unable to encode stories.boostersList#f3dd3d1d: field users element with index %d: %w", idx, err) - } - } - return nil -} - -// Decode implements bin.Decoder. -func (b *StoriesBoostersList) Decode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't decode stories.boostersList#f3dd3d1d to nil") - } - if err := buf.ConsumeID(StoriesBoostersListTypeID); err != nil { - return fmt.Errorf("unable to decode stories.boostersList#f3dd3d1d: %w", err) - } - return b.DecodeBare(buf) -} - -// DecodeBare implements bin.BareDecoder. -func (b *StoriesBoostersList) DecodeBare(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't decode stories.boostersList#f3dd3d1d to nil") - } - { - if err := b.Flags.Decode(buf); err != nil { - return fmt.Errorf("unable to decode stories.boostersList#f3dd3d1d: field flags: %w", err) - } - } - { - value, err := buf.Int() - if err != nil { - return fmt.Errorf("unable to decode stories.boostersList#f3dd3d1d: field count: %w", err) - } - b.Count = value - } - { - headerLen, err := buf.VectorHeader() - if err != nil { - return fmt.Errorf("unable to decode stories.boostersList#f3dd3d1d: field boosters: %w", err) - } - - if headerLen > 0 { - b.Boosters = make([]Booster, 0, headerLen%bin.PreallocateLimit) - } - for idx := 0; idx < headerLen; idx++ { - var value Booster - if err := value.Decode(buf); err != nil { - return fmt.Errorf("unable to decode stories.boostersList#f3dd3d1d: field boosters: %w", err) - } - b.Boosters = append(b.Boosters, value) - } - } - if b.Flags.Has(0) { - value, err := buf.String() - if err != nil { - return fmt.Errorf("unable to decode stories.boostersList#f3dd3d1d: field next_offset: %w", err) - } - b.NextOffset = value - } - { - headerLen, err := buf.VectorHeader() - if err != nil { - return fmt.Errorf("unable to decode stories.boostersList#f3dd3d1d: field users: %w", err) - } - - if headerLen > 0 { - b.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit) - } - for idx := 0; idx < headerLen; idx++ { - value, err := DecodeUser(buf) - if err != nil { - return fmt.Errorf("unable to decode stories.boostersList#f3dd3d1d: field users: %w", err) - } - b.Users = append(b.Users, value) - } - } - return nil -} - -// GetCount returns value of Count field. -func (b *StoriesBoostersList) GetCount() (value int) { - if b == nil { - return - } - return b.Count -} - -// GetBoosters returns value of Boosters field. -func (b *StoriesBoostersList) GetBoosters() (value []Booster) { - if b == nil { - return - } - return b.Boosters -} - -// SetNextOffset sets value of NextOffset conditional field. -func (b *StoriesBoostersList) SetNextOffset(value string) { - b.Flags.Set(0) - b.NextOffset = value -} - -// GetNextOffset returns value of NextOffset conditional field and -// boolean which is true if field was set. -func (b *StoriesBoostersList) GetNextOffset() (value string, ok bool) { - if b == nil { - return - } - if !b.Flags.Has(0) { - return value, false - } - return b.NextOffset, true -} - -// GetUsers returns value of Users field. -func (b *StoriesBoostersList) GetUsers() (value []UserClass) { - if b == nil { - return - } - return b.Users -} - -// MapUsers returns field Users wrapped in UserClassArray helper. -func (b *StoriesBoostersList) MapUsers() (value UserClassArray) { - return UserClassArray(b.Users) -} diff --git a/tg/tl_stories_boosts_status_gen.go b/tg/tl_stories_boosts_status_gen.go deleted file mode 100644 index 0f884e8d57..0000000000 --- a/tg/tl_stories_boosts_status_gen.go +++ /dev/null @@ -1,391 +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{} -) - -// StoriesBoostsStatus represents TL type `stories.boostsStatus#e5c1aa5c`. -// -// See https://core.telegram.org/constructor/stories.boostsStatus for reference. -type StoriesBoostsStatus struct { - // Flags field of StoriesBoostsStatus. - Flags bin.Fields - // MyBoost field of StoriesBoostsStatus. - MyBoost bool - // Level field of StoriesBoostsStatus. - Level int - // CurrentLevelBoosts field of StoriesBoostsStatus. - CurrentLevelBoosts int - // Boosts field of StoriesBoostsStatus. - Boosts int - // NextLevelBoosts field of StoriesBoostsStatus. - // - // Use SetNextLevelBoosts and GetNextLevelBoosts helpers. - NextLevelBoosts int - // PremiumAudience field of StoriesBoostsStatus. - // - // Use SetPremiumAudience and GetPremiumAudience helpers. - PremiumAudience StatsPercentValue - // BoostURL field of StoriesBoostsStatus. - BoostURL string -} - -// StoriesBoostsStatusTypeID is TL type id of StoriesBoostsStatus. -const StoriesBoostsStatusTypeID = 0xe5c1aa5c - -// Ensuring interfaces in compile-time for StoriesBoostsStatus. -var ( - _ bin.Encoder = &StoriesBoostsStatus{} - _ bin.Decoder = &StoriesBoostsStatus{} - _ bin.BareEncoder = &StoriesBoostsStatus{} - _ bin.BareDecoder = &StoriesBoostsStatus{} -) - -func (b *StoriesBoostsStatus) Zero() bool { - if b == nil { - return true - } - if !(b.Flags.Zero()) { - return false - } - if !(b.MyBoost == false) { - return false - } - if !(b.Level == 0) { - return false - } - if !(b.CurrentLevelBoosts == 0) { - return false - } - if !(b.Boosts == 0) { - return false - } - if !(b.NextLevelBoosts == 0) { - return false - } - if !(b.PremiumAudience.Zero()) { - return false - } - if !(b.BoostURL == "") { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (b *StoriesBoostsStatus) String() string { - if b == nil { - return "StoriesBoostsStatus(nil)" - } - type Alias StoriesBoostsStatus - return fmt.Sprintf("StoriesBoostsStatus%+v", Alias(*b)) -} - -// FillFrom fills StoriesBoostsStatus from given interface. -func (b *StoriesBoostsStatus) FillFrom(from interface { - GetMyBoost() (value bool) - GetLevel() (value int) - GetCurrentLevelBoosts() (value int) - GetBoosts() (value int) - GetNextLevelBoosts() (value int, ok bool) - GetPremiumAudience() (value StatsPercentValue, ok bool) - GetBoostURL() (value string) -}) { - b.MyBoost = from.GetMyBoost() - b.Level = from.GetLevel() - b.CurrentLevelBoosts = from.GetCurrentLevelBoosts() - b.Boosts = from.GetBoosts() - if val, ok := from.GetNextLevelBoosts(); ok { - b.NextLevelBoosts = val - } - - if val, ok := from.GetPremiumAudience(); ok { - b.PremiumAudience = val - } - - b.BoostURL = from.GetBoostURL() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StoriesBoostsStatus) TypeID() uint32 { - return StoriesBoostsStatusTypeID -} - -// TypeName returns name of type in TL schema. -func (*StoriesBoostsStatus) TypeName() string { - return "stories.boostsStatus" -} - -// TypeInfo returns info about TL type. -func (b *StoriesBoostsStatus) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "stories.boostsStatus", - ID: StoriesBoostsStatusTypeID, - } - if b == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "MyBoost", - SchemaName: "my_boost", - Null: !b.Flags.Has(2), - }, - { - Name: "Level", - SchemaName: "level", - }, - { - Name: "CurrentLevelBoosts", - SchemaName: "current_level_boosts", - }, - { - Name: "Boosts", - SchemaName: "boosts", - }, - { - Name: "NextLevelBoosts", - SchemaName: "next_level_boosts", - Null: !b.Flags.Has(0), - }, - { - Name: "PremiumAudience", - SchemaName: "premium_audience", - Null: !b.Flags.Has(1), - }, - { - Name: "BoostURL", - SchemaName: "boost_url", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (b *StoriesBoostsStatus) SetFlags() { - if !(b.MyBoost == false) { - b.Flags.Set(2) - } - if !(b.NextLevelBoosts == 0) { - b.Flags.Set(0) - } - if !(b.PremiumAudience.Zero()) { - b.Flags.Set(1) - } -} - -// Encode implements bin.Encoder. -func (b *StoriesBoostsStatus) Encode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't encode stories.boostsStatus#e5c1aa5c as nil") - } - buf.PutID(StoriesBoostsStatusTypeID) - return b.EncodeBare(buf) -} - -// EncodeBare implements bin.BareEncoder. -func (b *StoriesBoostsStatus) EncodeBare(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't encode stories.boostsStatus#e5c1aa5c as nil") - } - b.SetFlags() - if err := b.Flags.Encode(buf); err != nil { - return fmt.Errorf("unable to encode stories.boostsStatus#e5c1aa5c: field flags: %w", err) - } - buf.PutInt(b.Level) - buf.PutInt(b.CurrentLevelBoosts) - buf.PutInt(b.Boosts) - if b.Flags.Has(0) { - buf.PutInt(b.NextLevelBoosts) - } - if b.Flags.Has(1) { - if err := b.PremiumAudience.Encode(buf); err != nil { - return fmt.Errorf("unable to encode stories.boostsStatus#e5c1aa5c: field premium_audience: %w", err) - } - } - buf.PutString(b.BoostURL) - return nil -} - -// Decode implements bin.Decoder. -func (b *StoriesBoostsStatus) Decode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't decode stories.boostsStatus#e5c1aa5c to nil") - } - if err := buf.ConsumeID(StoriesBoostsStatusTypeID); err != nil { - return fmt.Errorf("unable to decode stories.boostsStatus#e5c1aa5c: %w", err) - } - return b.DecodeBare(buf) -} - -// DecodeBare implements bin.BareDecoder. -func (b *StoriesBoostsStatus) DecodeBare(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't decode stories.boostsStatus#e5c1aa5c to nil") - } - { - if err := b.Flags.Decode(buf); err != nil { - return fmt.Errorf("unable to decode stories.boostsStatus#e5c1aa5c: field flags: %w", err) - } - } - b.MyBoost = b.Flags.Has(2) - { - value, err := buf.Int() - if err != nil { - return fmt.Errorf("unable to decode stories.boostsStatus#e5c1aa5c: field level: %w", err) - } - b.Level = value - } - { - value, err := buf.Int() - if err != nil { - return fmt.Errorf("unable to decode stories.boostsStatus#e5c1aa5c: field current_level_boosts: %w", err) - } - b.CurrentLevelBoosts = value - } - { - value, err := buf.Int() - if err != nil { - return fmt.Errorf("unable to decode stories.boostsStatus#e5c1aa5c: field boosts: %w", err) - } - b.Boosts = value - } - if b.Flags.Has(0) { - value, err := buf.Int() - if err != nil { - return fmt.Errorf("unable to decode stories.boostsStatus#e5c1aa5c: field next_level_boosts: %w", err) - } - b.NextLevelBoosts = value - } - if b.Flags.Has(1) { - if err := b.PremiumAudience.Decode(buf); err != nil { - return fmt.Errorf("unable to decode stories.boostsStatus#e5c1aa5c: field premium_audience: %w", err) - } - } - { - value, err := buf.String() - if err != nil { - return fmt.Errorf("unable to decode stories.boostsStatus#e5c1aa5c: field boost_url: %w", err) - } - b.BoostURL = value - } - return nil -} - -// SetMyBoost sets value of MyBoost conditional field. -func (b *StoriesBoostsStatus) SetMyBoost(value bool) { - if value { - b.Flags.Set(2) - b.MyBoost = true - } else { - b.Flags.Unset(2) - b.MyBoost = false - } -} - -// GetMyBoost returns value of MyBoost conditional field. -func (b *StoriesBoostsStatus) GetMyBoost() (value bool) { - if b == nil { - return - } - return b.Flags.Has(2) -} - -// GetLevel returns value of Level field. -func (b *StoriesBoostsStatus) GetLevel() (value int) { - if b == nil { - return - } - return b.Level -} - -// GetCurrentLevelBoosts returns value of CurrentLevelBoosts field. -func (b *StoriesBoostsStatus) GetCurrentLevelBoosts() (value int) { - if b == nil { - return - } - return b.CurrentLevelBoosts -} - -// GetBoosts returns value of Boosts field. -func (b *StoriesBoostsStatus) GetBoosts() (value int) { - if b == nil { - return - } - return b.Boosts -} - -// SetNextLevelBoosts sets value of NextLevelBoosts conditional field. -func (b *StoriesBoostsStatus) SetNextLevelBoosts(value int) { - b.Flags.Set(0) - b.NextLevelBoosts = value -} - -// GetNextLevelBoosts returns value of NextLevelBoosts conditional field and -// boolean which is true if field was set. -func (b *StoriesBoostsStatus) GetNextLevelBoosts() (value int, ok bool) { - if b == nil { - return - } - if !b.Flags.Has(0) { - return value, false - } - return b.NextLevelBoosts, true -} - -// SetPremiumAudience sets value of PremiumAudience conditional field. -func (b *StoriesBoostsStatus) SetPremiumAudience(value StatsPercentValue) { - b.Flags.Set(1) - b.PremiumAudience = value -} - -// GetPremiumAudience returns value of PremiumAudience conditional field and -// boolean which is true if field was set. -func (b *StoriesBoostsStatus) GetPremiumAudience() (value StatsPercentValue, ok bool) { - if b == nil { - return - } - if !b.Flags.Has(1) { - return value, false - } - return b.PremiumAudience, true -} - -// GetBoostURL returns value of BoostURL field. -func (b *StoriesBoostsStatus) GetBoostURL() (value string) { - if b == nil { - return - } - return b.BoostURL -} diff --git a/tg/tl_stories_can_apply_boost_gen.go b/tg/tl_stories_can_apply_boost_gen.go deleted file mode 100644 index 0a96059a7b..0000000000 --- a/tg/tl_stories_can_apply_boost_gen.go +++ /dev/null @@ -1,181 +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{} -) - -// StoriesCanApplyBoostRequest represents TL type `stories.canApplyBoost#db05c1bd`. -// -// See https://core.telegram.org/method/stories.canApplyBoost for reference. -type StoriesCanApplyBoostRequest struct { - // Peer field of StoriesCanApplyBoostRequest. - Peer InputPeerClass -} - -// StoriesCanApplyBoostRequestTypeID is TL type id of StoriesCanApplyBoostRequest. -const StoriesCanApplyBoostRequestTypeID = 0xdb05c1bd - -// Ensuring interfaces in compile-time for StoriesCanApplyBoostRequest. -var ( - _ bin.Encoder = &StoriesCanApplyBoostRequest{} - _ bin.Decoder = &StoriesCanApplyBoostRequest{} - _ bin.BareEncoder = &StoriesCanApplyBoostRequest{} - _ bin.BareDecoder = &StoriesCanApplyBoostRequest{} -) - -func (c *StoriesCanApplyBoostRequest) Zero() bool { - if c == nil { - return true - } - if !(c.Peer == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (c *StoriesCanApplyBoostRequest) String() string { - if c == nil { - return "StoriesCanApplyBoostRequest(nil)" - } - type Alias StoriesCanApplyBoostRequest - return fmt.Sprintf("StoriesCanApplyBoostRequest%+v", Alias(*c)) -} - -// FillFrom fills StoriesCanApplyBoostRequest from given interface. -func (c *StoriesCanApplyBoostRequest) FillFrom(from interface { - GetPeer() (value InputPeerClass) -}) { - c.Peer = from.GetPeer() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StoriesCanApplyBoostRequest) TypeID() uint32 { - return StoriesCanApplyBoostRequestTypeID -} - -// TypeName returns name of type in TL schema. -func (*StoriesCanApplyBoostRequest) TypeName() string { - return "stories.canApplyBoost" -} - -// TypeInfo returns info about TL type. -func (c *StoriesCanApplyBoostRequest) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "stories.canApplyBoost", - ID: StoriesCanApplyBoostRequestTypeID, - } - if c == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Peer", - SchemaName: "peer", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (c *StoriesCanApplyBoostRequest) Encode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode stories.canApplyBoost#db05c1bd as nil") - } - b.PutID(StoriesCanApplyBoostRequestTypeID) - return c.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (c *StoriesCanApplyBoostRequest) EncodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode stories.canApplyBoost#db05c1bd as nil") - } - if c.Peer == nil { - return fmt.Errorf("unable to encode stories.canApplyBoost#db05c1bd: field peer is nil") - } - if err := c.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode stories.canApplyBoost#db05c1bd: field peer: %w", err) - } - return nil -} - -// Decode implements bin.Decoder. -func (c *StoriesCanApplyBoostRequest) Decode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode stories.canApplyBoost#db05c1bd to nil") - } - if err := b.ConsumeID(StoriesCanApplyBoostRequestTypeID); err != nil { - return fmt.Errorf("unable to decode stories.canApplyBoost#db05c1bd: %w", err) - } - return c.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (c *StoriesCanApplyBoostRequest) DecodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode stories.canApplyBoost#db05c1bd to nil") - } - { - value, err := DecodeInputPeer(b) - if err != nil { - return fmt.Errorf("unable to decode stories.canApplyBoost#db05c1bd: field peer: %w", err) - } - c.Peer = value - } - return nil -} - -// GetPeer returns value of Peer field. -func (c *StoriesCanApplyBoostRequest) GetPeer() (value InputPeerClass) { - if c == nil { - return - } - return c.Peer -} - -// StoriesCanApplyBoost invokes method stories.canApplyBoost#db05c1bd returning error if any. -// -// See https://core.telegram.org/method/stories.canApplyBoost for reference. -func (c *Client) StoriesCanApplyBoost(ctx context.Context, peer InputPeerClass) (StoriesCanApplyBoostResultClass, error) { - var result StoriesCanApplyBoostResultBox - - request := &StoriesCanApplyBoostRequest{ - Peer: peer, - } - if err := c.rpc.Invoke(ctx, request, &result); err != nil { - return nil, err - } - return result.CanApplyBoostResult, nil -} diff --git a/tg/tl_stories_can_apply_boost_result_gen.go b/tg/tl_stories_can_apply_boost_result_gen.go deleted file mode 100644 index ee020c6bb4..0000000000 --- a/tg/tl_stories_can_apply_boost_result_gen.go +++ /dev/null @@ -1,411 +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{} -) - -// StoriesCanApplyBoostOk represents TL type `stories.canApplyBoostOk#c3173587`. -// -// See https://core.telegram.org/constructor/stories.canApplyBoostOk for reference. -type StoriesCanApplyBoostOk struct { -} - -// StoriesCanApplyBoostOkTypeID is TL type id of StoriesCanApplyBoostOk. -const StoriesCanApplyBoostOkTypeID = 0xc3173587 - -// construct implements constructor of StoriesCanApplyBoostResultClass. -func (c StoriesCanApplyBoostOk) construct() StoriesCanApplyBoostResultClass { return &c } - -// Ensuring interfaces in compile-time for StoriesCanApplyBoostOk. -var ( - _ bin.Encoder = &StoriesCanApplyBoostOk{} - _ bin.Decoder = &StoriesCanApplyBoostOk{} - _ bin.BareEncoder = &StoriesCanApplyBoostOk{} - _ bin.BareDecoder = &StoriesCanApplyBoostOk{} - - _ StoriesCanApplyBoostResultClass = &StoriesCanApplyBoostOk{} -) - -func (c *StoriesCanApplyBoostOk) Zero() bool { - if c == nil { - return true - } - - return true -} - -// String implements fmt.Stringer. -func (c *StoriesCanApplyBoostOk) String() string { - if c == nil { - return "StoriesCanApplyBoostOk(nil)" - } - type Alias StoriesCanApplyBoostOk - return fmt.Sprintf("StoriesCanApplyBoostOk%+v", Alias(*c)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StoriesCanApplyBoostOk) TypeID() uint32 { - return StoriesCanApplyBoostOkTypeID -} - -// TypeName returns name of type in TL schema. -func (*StoriesCanApplyBoostOk) TypeName() string { - return "stories.canApplyBoostOk" -} - -// TypeInfo returns info about TL type. -func (c *StoriesCanApplyBoostOk) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "stories.canApplyBoostOk", - ID: StoriesCanApplyBoostOkTypeID, - } - if c == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{} - return typ -} - -// Encode implements bin.Encoder. -func (c *StoriesCanApplyBoostOk) Encode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode stories.canApplyBoostOk#c3173587 as nil") - } - b.PutID(StoriesCanApplyBoostOkTypeID) - return c.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (c *StoriesCanApplyBoostOk) EncodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode stories.canApplyBoostOk#c3173587 as nil") - } - return nil -} - -// Decode implements bin.Decoder. -func (c *StoriesCanApplyBoostOk) Decode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode stories.canApplyBoostOk#c3173587 to nil") - } - if err := b.ConsumeID(StoriesCanApplyBoostOkTypeID); err != nil { - return fmt.Errorf("unable to decode stories.canApplyBoostOk#c3173587: %w", err) - } - return c.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (c *StoriesCanApplyBoostOk) DecodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode stories.canApplyBoostOk#c3173587 to nil") - } - return nil -} - -// StoriesCanApplyBoostReplace represents TL type `stories.canApplyBoostReplace#712c4655`. -// -// See https://core.telegram.org/constructor/stories.canApplyBoostReplace for reference. -type StoriesCanApplyBoostReplace struct { - // CurrentBoost field of StoriesCanApplyBoostReplace. - CurrentBoost PeerClass - // Chats field of StoriesCanApplyBoostReplace. - Chats []ChatClass -} - -// StoriesCanApplyBoostReplaceTypeID is TL type id of StoriesCanApplyBoostReplace. -const StoriesCanApplyBoostReplaceTypeID = 0x712c4655 - -// construct implements constructor of StoriesCanApplyBoostResultClass. -func (c StoriesCanApplyBoostReplace) construct() StoriesCanApplyBoostResultClass { return &c } - -// Ensuring interfaces in compile-time for StoriesCanApplyBoostReplace. -var ( - _ bin.Encoder = &StoriesCanApplyBoostReplace{} - _ bin.Decoder = &StoriesCanApplyBoostReplace{} - _ bin.BareEncoder = &StoriesCanApplyBoostReplace{} - _ bin.BareDecoder = &StoriesCanApplyBoostReplace{} - - _ StoriesCanApplyBoostResultClass = &StoriesCanApplyBoostReplace{} -) - -func (c *StoriesCanApplyBoostReplace) Zero() bool { - if c == nil { - return true - } - if !(c.CurrentBoost == nil) { - return false - } - if !(c.Chats == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (c *StoriesCanApplyBoostReplace) String() string { - if c == nil { - return "StoriesCanApplyBoostReplace(nil)" - } - type Alias StoriesCanApplyBoostReplace - return fmt.Sprintf("StoriesCanApplyBoostReplace%+v", Alias(*c)) -} - -// FillFrom fills StoriesCanApplyBoostReplace from given interface. -func (c *StoriesCanApplyBoostReplace) FillFrom(from interface { - GetCurrentBoost() (value PeerClass) - GetChats() (value []ChatClass) -}) { - c.CurrentBoost = from.GetCurrentBoost() - c.Chats = from.GetChats() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StoriesCanApplyBoostReplace) TypeID() uint32 { - return StoriesCanApplyBoostReplaceTypeID -} - -// TypeName returns name of type in TL schema. -func (*StoriesCanApplyBoostReplace) TypeName() string { - return "stories.canApplyBoostReplace" -} - -// TypeInfo returns info about TL type. -func (c *StoriesCanApplyBoostReplace) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "stories.canApplyBoostReplace", - ID: StoriesCanApplyBoostReplaceTypeID, - } - if c == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "CurrentBoost", - SchemaName: "current_boost", - }, - { - Name: "Chats", - SchemaName: "chats", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (c *StoriesCanApplyBoostReplace) Encode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode stories.canApplyBoostReplace#712c4655 as nil") - } - b.PutID(StoriesCanApplyBoostReplaceTypeID) - return c.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (c *StoriesCanApplyBoostReplace) EncodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode stories.canApplyBoostReplace#712c4655 as nil") - } - if c.CurrentBoost == nil { - return fmt.Errorf("unable to encode stories.canApplyBoostReplace#712c4655: field current_boost is nil") - } - if err := c.CurrentBoost.Encode(b); err != nil { - return fmt.Errorf("unable to encode stories.canApplyBoostReplace#712c4655: field current_boost: %w", err) - } - b.PutVectorHeader(len(c.Chats)) - for idx, v := range c.Chats { - if v == nil { - return fmt.Errorf("unable to encode stories.canApplyBoostReplace#712c4655: field chats element with index %d is nil", idx) - } - if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode stories.canApplyBoostReplace#712c4655: field chats element with index %d: %w", idx, err) - } - } - return nil -} - -// Decode implements bin.Decoder. -func (c *StoriesCanApplyBoostReplace) Decode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode stories.canApplyBoostReplace#712c4655 to nil") - } - if err := b.ConsumeID(StoriesCanApplyBoostReplaceTypeID); err != nil { - return fmt.Errorf("unable to decode stories.canApplyBoostReplace#712c4655: %w", err) - } - return c.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (c *StoriesCanApplyBoostReplace) DecodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode stories.canApplyBoostReplace#712c4655 to nil") - } - { - value, err := DecodePeer(b) - if err != nil { - return fmt.Errorf("unable to decode stories.canApplyBoostReplace#712c4655: field current_boost: %w", err) - } - c.CurrentBoost = value - } - { - headerLen, err := b.VectorHeader() - if err != nil { - return fmt.Errorf("unable to decode stories.canApplyBoostReplace#712c4655: field chats: %w", err) - } - - if headerLen > 0 { - c.Chats = make([]ChatClass, 0, headerLen%bin.PreallocateLimit) - } - for idx := 0; idx < headerLen; idx++ { - value, err := DecodeChat(b) - if err != nil { - return fmt.Errorf("unable to decode stories.canApplyBoostReplace#712c4655: field chats: %w", err) - } - c.Chats = append(c.Chats, value) - } - } - return nil -} - -// GetCurrentBoost returns value of CurrentBoost field. -func (c *StoriesCanApplyBoostReplace) GetCurrentBoost() (value PeerClass) { - if c == nil { - return - } - return c.CurrentBoost -} - -// GetChats returns value of Chats field. -func (c *StoriesCanApplyBoostReplace) GetChats() (value []ChatClass) { - if c == nil { - return - } - return c.Chats -} - -// MapChats returns field Chats wrapped in ChatClassArray helper. -func (c *StoriesCanApplyBoostReplace) MapChats() (value ChatClassArray) { - return ChatClassArray(c.Chats) -} - -// StoriesCanApplyBoostResultClassName is schema name of StoriesCanApplyBoostResultClass. -const StoriesCanApplyBoostResultClassName = "stories.CanApplyBoostResult" - -// StoriesCanApplyBoostResultClass represents stories.CanApplyBoostResult generic type. -// -// See https://core.telegram.org/type/stories.CanApplyBoostResult for reference. -// -// Example: -// -// g, err := tg.DecodeStoriesCanApplyBoostResult(buf) -// if err != nil { -// panic(err) -// } -// switch v := g.(type) { -// case *tg.StoriesCanApplyBoostOk: // stories.canApplyBoostOk#c3173587 -// case *tg.StoriesCanApplyBoostReplace: // stories.canApplyBoostReplace#712c4655 -// default: panic(v) -// } -type StoriesCanApplyBoostResultClass interface { - bin.Encoder - bin.Decoder - bin.BareEncoder - bin.BareDecoder - construct() StoriesCanApplyBoostResultClass - - // 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 -} - -// DecodeStoriesCanApplyBoostResult implements binary de-serialization for StoriesCanApplyBoostResultClass. -func DecodeStoriesCanApplyBoostResult(buf *bin.Buffer) (StoriesCanApplyBoostResultClass, error) { - id, err := buf.PeekID() - if err != nil { - return nil, err - } - switch id { - case StoriesCanApplyBoostOkTypeID: - // Decoding stories.canApplyBoostOk#c3173587. - v := StoriesCanApplyBoostOk{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode StoriesCanApplyBoostResultClass: %w", err) - } - return &v, nil - case StoriesCanApplyBoostReplaceTypeID: - // Decoding stories.canApplyBoostReplace#712c4655. - v := StoriesCanApplyBoostReplace{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode StoriesCanApplyBoostResultClass: %w", err) - } - return &v, nil - default: - return nil, fmt.Errorf("unable to decode StoriesCanApplyBoostResultClass: %w", bin.NewUnexpectedID(id)) - } -} - -// StoriesCanApplyBoostResult boxes the StoriesCanApplyBoostResultClass providing a helper. -type StoriesCanApplyBoostResultBox struct { - CanApplyBoostResult StoriesCanApplyBoostResultClass -} - -// Decode implements bin.Decoder for StoriesCanApplyBoostResultBox. -func (b *StoriesCanApplyBoostResultBox) Decode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("unable to decode StoriesCanApplyBoostResultBox to nil") - } - v, err := DecodeStoriesCanApplyBoostResult(buf) - if err != nil { - return fmt.Errorf("unable to decode boxed value: %w", err) - } - b.CanApplyBoostResult = v - return nil -} - -// Encode implements bin.Encode for StoriesCanApplyBoostResultBox. -func (b *StoriesCanApplyBoostResultBox) Encode(buf *bin.Buffer) error { - if b == nil || b.CanApplyBoostResult == nil { - return fmt.Errorf("unable to encode StoriesCanApplyBoostResultClass as nil") - } - return b.CanApplyBoostResult.Encode(buf) -} diff --git a/tg/tl_stories_can_apply_boost_result_slices_gen.go b/tg/tl_stories_can_apply_boost_result_slices_gen.go deleted file mode 100644 index 44f8f4c7d2..0000000000 --- a/tg/tl_stories_can_apply_boost_result_slices_gen.go +++ /dev/null @@ -1,212 +0,0 @@ -//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{} -) - -// StoriesCanApplyBoostResultClassArray is adapter for slice of StoriesCanApplyBoostResultClass. -type StoriesCanApplyBoostResultClassArray []StoriesCanApplyBoostResultClass - -// Sort sorts slice of StoriesCanApplyBoostResultClass. -func (s StoriesCanApplyBoostResultClassArray) Sort(less func(a, b StoriesCanApplyBoostResultClass) bool) StoriesCanApplyBoostResultClassArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of StoriesCanApplyBoostResultClass. -func (s StoriesCanApplyBoostResultClassArray) SortStable(less func(a, b StoriesCanApplyBoostResultClass) bool) StoriesCanApplyBoostResultClassArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of StoriesCanApplyBoostResultClass. -func (s StoriesCanApplyBoostResultClassArray) Retain(keep func(x StoriesCanApplyBoostResultClass) bool) StoriesCanApplyBoostResultClassArray { - 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 StoriesCanApplyBoostResultClassArray) First() (v StoriesCanApplyBoostResultClass, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s StoriesCanApplyBoostResultClassArray) Last() (v StoriesCanApplyBoostResultClass, 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 *StoriesCanApplyBoostResultClassArray) PopFirst() (v StoriesCanApplyBoostResultClass, 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 StoriesCanApplyBoostResultClass - 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 *StoriesCanApplyBoostResultClassArray) Pop() (v StoriesCanApplyBoostResultClass, 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 -} - -// AsStoriesCanApplyBoostReplace returns copy with only StoriesCanApplyBoostReplace constructors. -func (s StoriesCanApplyBoostResultClassArray) AsStoriesCanApplyBoostReplace() (to StoriesCanApplyBoostReplaceArray) { - for _, elem := range s { - value, ok := elem.(*StoriesCanApplyBoostReplace) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// StoriesCanApplyBoostReplaceArray is adapter for slice of StoriesCanApplyBoostReplace. -type StoriesCanApplyBoostReplaceArray []StoriesCanApplyBoostReplace - -// Sort sorts slice of StoriesCanApplyBoostReplace. -func (s StoriesCanApplyBoostReplaceArray) Sort(less func(a, b StoriesCanApplyBoostReplace) bool) StoriesCanApplyBoostReplaceArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of StoriesCanApplyBoostReplace. -func (s StoriesCanApplyBoostReplaceArray) SortStable(less func(a, b StoriesCanApplyBoostReplace) bool) StoriesCanApplyBoostReplaceArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of StoriesCanApplyBoostReplace. -func (s StoriesCanApplyBoostReplaceArray) Retain(keep func(x StoriesCanApplyBoostReplace) bool) StoriesCanApplyBoostReplaceArray { - 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 StoriesCanApplyBoostReplaceArray) First() (v StoriesCanApplyBoostReplace, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s StoriesCanApplyBoostReplaceArray) Last() (v StoriesCanApplyBoostReplace, 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 *StoriesCanApplyBoostReplaceArray) PopFirst() (v StoriesCanApplyBoostReplace, 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 StoriesCanApplyBoostReplace - 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 *StoriesCanApplyBoostReplaceArray) Pop() (v StoriesCanApplyBoostReplace, 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_stories_get_boosters_list_gen.go b/tg/tl_stories_get_boosters_list_gen.go deleted file mode 100644 index 179af64da4..0000000000 --- a/tg/tl_stories_get_boosters_list_gen.go +++ /dev/null @@ -1,232 +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{} -) - -// StoriesGetBoostersListRequest represents TL type `stories.getBoostersList#337ef980`. -// -// See https://core.telegram.org/method/stories.getBoostersList for reference. -type StoriesGetBoostersListRequest struct { - // Peer field of StoriesGetBoostersListRequest. - Peer InputPeerClass - // Offset field of StoriesGetBoostersListRequest. - Offset string - // Limit field of StoriesGetBoostersListRequest. - Limit int -} - -// StoriesGetBoostersListRequestTypeID is TL type id of StoriesGetBoostersListRequest. -const StoriesGetBoostersListRequestTypeID = 0x337ef980 - -// Ensuring interfaces in compile-time for StoriesGetBoostersListRequest. -var ( - _ bin.Encoder = &StoriesGetBoostersListRequest{} - _ bin.Decoder = &StoriesGetBoostersListRequest{} - _ bin.BareEncoder = &StoriesGetBoostersListRequest{} - _ bin.BareDecoder = &StoriesGetBoostersListRequest{} -) - -func (g *StoriesGetBoostersListRequest) Zero() bool { - if g == nil { - return true - } - if !(g.Peer == nil) { - return false - } - if !(g.Offset == "") { - return false - } - if !(g.Limit == 0) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (g *StoriesGetBoostersListRequest) String() string { - if g == nil { - return "StoriesGetBoostersListRequest(nil)" - } - type Alias StoriesGetBoostersListRequest - return fmt.Sprintf("StoriesGetBoostersListRequest%+v", Alias(*g)) -} - -// FillFrom fills StoriesGetBoostersListRequest from given interface. -func (g *StoriesGetBoostersListRequest) FillFrom(from interface { - GetPeer() (value InputPeerClass) - GetOffset() (value string) - GetLimit() (value int) -}) { - g.Peer = from.GetPeer() - g.Offset = from.GetOffset() - g.Limit = from.GetLimit() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StoriesGetBoostersListRequest) TypeID() uint32 { - return StoriesGetBoostersListRequestTypeID -} - -// TypeName returns name of type in TL schema. -func (*StoriesGetBoostersListRequest) TypeName() string { - return "stories.getBoostersList" -} - -// TypeInfo returns info about TL type. -func (g *StoriesGetBoostersListRequest) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "stories.getBoostersList", - ID: StoriesGetBoostersListRequestTypeID, - } - if g == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Peer", - SchemaName: "peer", - }, - { - Name: "Offset", - SchemaName: "offset", - }, - { - Name: "Limit", - SchemaName: "limit", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (g *StoriesGetBoostersListRequest) Encode(b *bin.Buffer) error { - if g == nil { - return fmt.Errorf("can't encode stories.getBoostersList#337ef980 as nil") - } - b.PutID(StoriesGetBoostersListRequestTypeID) - return g.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (g *StoriesGetBoostersListRequest) EncodeBare(b *bin.Buffer) error { - if g == nil { - return fmt.Errorf("can't encode stories.getBoostersList#337ef980 as nil") - } - if g.Peer == nil { - return fmt.Errorf("unable to encode stories.getBoostersList#337ef980: field peer is nil") - } - if err := g.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode stories.getBoostersList#337ef980: field peer: %w", err) - } - b.PutString(g.Offset) - b.PutInt(g.Limit) - return nil -} - -// Decode implements bin.Decoder. -func (g *StoriesGetBoostersListRequest) Decode(b *bin.Buffer) error { - if g == nil { - return fmt.Errorf("can't decode stories.getBoostersList#337ef980 to nil") - } - if err := b.ConsumeID(StoriesGetBoostersListRequestTypeID); err != nil { - return fmt.Errorf("unable to decode stories.getBoostersList#337ef980: %w", err) - } - return g.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (g *StoriesGetBoostersListRequest) DecodeBare(b *bin.Buffer) error { - if g == nil { - return fmt.Errorf("can't decode stories.getBoostersList#337ef980 to nil") - } - { - value, err := DecodeInputPeer(b) - if err != nil { - return fmt.Errorf("unable to decode stories.getBoostersList#337ef980: field peer: %w", err) - } - g.Peer = value - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode stories.getBoostersList#337ef980: field offset: %w", err) - } - g.Offset = value - } - { - value, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode stories.getBoostersList#337ef980: field limit: %w", err) - } - g.Limit = value - } - return nil -} - -// GetPeer returns value of Peer field. -func (g *StoriesGetBoostersListRequest) GetPeer() (value InputPeerClass) { - if g == nil { - return - } - return g.Peer -} - -// GetOffset returns value of Offset field. -func (g *StoriesGetBoostersListRequest) GetOffset() (value string) { - if g == nil { - return - } - return g.Offset -} - -// GetLimit returns value of Limit field. -func (g *StoriesGetBoostersListRequest) GetLimit() (value int) { - if g == nil { - return - } - return g.Limit -} - -// StoriesGetBoostersList invokes method stories.getBoostersList#337ef980 returning error if any. -// -// See https://core.telegram.org/method/stories.getBoostersList for reference. -func (c *Client) StoriesGetBoostersList(ctx context.Context, request *StoriesGetBoostersListRequest) (*StoriesBoostersList, error) { - var result StoriesBoostersList - - if err := c.rpc.Invoke(ctx, request, &result); err != nil { - return nil, err - } - return &result, nil -} diff --git a/tg/tl_stories_get_boosts_status_gen.go b/tg/tl_stories_get_boosts_status_gen.go deleted file mode 100644 index 539684af31..0000000000 --- a/tg/tl_stories_get_boosts_status_gen.go +++ /dev/null @@ -1,181 +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{} -) - -// StoriesGetBoostsStatusRequest represents TL type `stories.getBoostsStatus#4c449472`. -// -// See https://core.telegram.org/method/stories.getBoostsStatus for reference. -type StoriesGetBoostsStatusRequest struct { - // Peer field of StoriesGetBoostsStatusRequest. - Peer InputPeerClass -} - -// StoriesGetBoostsStatusRequestTypeID is TL type id of StoriesGetBoostsStatusRequest. -const StoriesGetBoostsStatusRequestTypeID = 0x4c449472 - -// Ensuring interfaces in compile-time for StoriesGetBoostsStatusRequest. -var ( - _ bin.Encoder = &StoriesGetBoostsStatusRequest{} - _ bin.Decoder = &StoriesGetBoostsStatusRequest{} - _ bin.BareEncoder = &StoriesGetBoostsStatusRequest{} - _ bin.BareDecoder = &StoriesGetBoostsStatusRequest{} -) - -func (g *StoriesGetBoostsStatusRequest) Zero() bool { - if g == nil { - return true - } - if !(g.Peer == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (g *StoriesGetBoostsStatusRequest) String() string { - if g == nil { - return "StoriesGetBoostsStatusRequest(nil)" - } - type Alias StoriesGetBoostsStatusRequest - return fmt.Sprintf("StoriesGetBoostsStatusRequest%+v", Alias(*g)) -} - -// FillFrom fills StoriesGetBoostsStatusRequest from given interface. -func (g *StoriesGetBoostsStatusRequest) FillFrom(from interface { - GetPeer() (value InputPeerClass) -}) { - g.Peer = from.GetPeer() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StoriesGetBoostsStatusRequest) TypeID() uint32 { - return StoriesGetBoostsStatusRequestTypeID -} - -// TypeName returns name of type in TL schema. -func (*StoriesGetBoostsStatusRequest) TypeName() string { - return "stories.getBoostsStatus" -} - -// TypeInfo returns info about TL type. -func (g *StoriesGetBoostsStatusRequest) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "stories.getBoostsStatus", - ID: StoriesGetBoostsStatusRequestTypeID, - } - if g == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Peer", - SchemaName: "peer", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (g *StoriesGetBoostsStatusRequest) Encode(b *bin.Buffer) error { - if g == nil { - return fmt.Errorf("can't encode stories.getBoostsStatus#4c449472 as nil") - } - b.PutID(StoriesGetBoostsStatusRequestTypeID) - return g.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (g *StoriesGetBoostsStatusRequest) EncodeBare(b *bin.Buffer) error { - if g == nil { - return fmt.Errorf("can't encode stories.getBoostsStatus#4c449472 as nil") - } - if g.Peer == nil { - return fmt.Errorf("unable to encode stories.getBoostsStatus#4c449472: field peer is nil") - } - if err := g.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode stories.getBoostsStatus#4c449472: field peer: %w", err) - } - return nil -} - -// Decode implements bin.Decoder. -func (g *StoriesGetBoostsStatusRequest) Decode(b *bin.Buffer) error { - if g == nil { - return fmt.Errorf("can't decode stories.getBoostsStatus#4c449472 to nil") - } - if err := b.ConsumeID(StoriesGetBoostsStatusRequestTypeID); err != nil { - return fmt.Errorf("unable to decode stories.getBoostsStatus#4c449472: %w", err) - } - return g.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (g *StoriesGetBoostsStatusRequest) DecodeBare(b *bin.Buffer) error { - if g == nil { - return fmt.Errorf("can't decode stories.getBoostsStatus#4c449472 to nil") - } - { - value, err := DecodeInputPeer(b) - if err != nil { - return fmt.Errorf("unable to decode stories.getBoostsStatus#4c449472: field peer: %w", err) - } - g.Peer = value - } - return nil -} - -// GetPeer returns value of Peer field. -func (g *StoriesGetBoostsStatusRequest) GetPeer() (value InputPeerClass) { - if g == nil { - return - } - return g.Peer -} - -// StoriesGetBoostsStatus invokes method stories.getBoostsStatus#4c449472 returning error if any. -// -// See https://core.telegram.org/method/stories.getBoostsStatus for reference. -func (c *Client) StoriesGetBoostsStatus(ctx context.Context, peer InputPeerClass) (*StoriesBoostsStatus, error) { - var result StoriesBoostsStatus - - request := &StoriesGetBoostsStatusRequest{ - Peer: peer, - } - if err := c.rpc.Invoke(ctx, request, &result); err != nil { - return nil, err - } - return &result, nil -} diff --git a/tg/tl_update_gen.go b/tg/tl_update_gen.go index 5666292176..f0107464ed 100644 --- a/tg/tl_update_gen.go +++ b/tg/tl_update_gen.go @@ -3275,6 +3275,8 @@ type UpdateServiceNotification struct { Flags bin.Fields // If set, the message must be displayed in a popup. Popup bool + // InvertMedia field of UpdateServiceNotification. + InvertMedia bool // When was the notification receivedThe message must also be stored locally as part of // the message history with the user id 777000 (Telegram Notifications). // @@ -3324,6 +3326,9 @@ func (u *UpdateServiceNotification) Zero() bool { if !(u.Popup == false) { return false } + if !(u.InvertMedia == false) { + return false + } if !(u.InboxDate == 0) { return false } @@ -3355,6 +3360,7 @@ func (u *UpdateServiceNotification) String() string { // FillFrom fills UpdateServiceNotification from given interface. func (u *UpdateServiceNotification) FillFrom(from interface { GetPopup() (value bool) + GetInvertMedia() (value bool) GetInboxDate() (value int, ok bool) GetType() (value string) GetMessage() (value string) @@ -3362,6 +3368,7 @@ func (u *UpdateServiceNotification) FillFrom(from interface { GetEntities() (value []MessageEntityClass) }) { u.Popup = from.GetPopup() + u.InvertMedia = from.GetInvertMedia() if val, ok := from.GetInboxDate(); ok { u.InboxDate = val } @@ -3400,6 +3407,11 @@ func (u *UpdateServiceNotification) TypeInfo() tdp.Type { SchemaName: "popup", Null: !u.Flags.Has(0), }, + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !u.Flags.Has(2), + }, { Name: "InboxDate", SchemaName: "inbox_date", @@ -3430,6 +3442,9 @@ func (u *UpdateServiceNotification) SetFlags() { if !(u.Popup == false) { u.Flags.Set(0) } + if !(u.InvertMedia == false) { + u.Flags.Set(2) + } if !(u.InboxDate == 0) { u.Flags.Set(1) } @@ -3498,6 +3513,7 @@ func (u *UpdateServiceNotification) DecodeBare(b *bin.Buffer) error { } } u.Popup = u.Flags.Has(0) + u.InvertMedia = u.Flags.Has(2) if u.Flags.Has(1) { value, err := b.Int() if err != nil { @@ -3565,6 +3581,25 @@ func (u *UpdateServiceNotification) GetPopup() (value bool) { return u.Flags.Has(0) } +// SetInvertMedia sets value of InvertMedia conditional field. +func (u *UpdateServiceNotification) SetInvertMedia(value bool) { + if value { + u.Flags.Set(2) + u.InvertMedia = true + } else { + u.Flags.Unset(2) + u.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (u *UpdateServiceNotification) GetInvertMedia() (value bool) { + if u == nil { + return + } + return u.Flags.Has(2) +} + // SetInboxDate sets value of InboxDate conditional field. func (u *UpdateServiceNotification) SetInboxDate(value int) { u.Flags.Set(1) diff --git a/tg/tl_user_gen.go b/tg/tl_user_gen.go index ceb9ac22f5..2e5795d611 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#abb5f120`. +// User represents TL type `user#eb602f25`. // Indicates info about a certain user // // See https://core.telegram.org/constructor/user for reference. @@ -300,10 +300,18 @@ type User struct { // // Use SetStoriesMaxID and GetStoriesMaxID helpers. StoriesMaxID int + // Color field of User. + // + // Use SetColor and GetColor helpers. + Color int + // BackgroundEmojiID field of User. + // + // Use SetBackgroundEmojiID and GetBackgroundEmojiID helpers. + BackgroundEmojiID int64 } // UserTypeID is TL type id of User. -const UserTypeID = 0xabb5f120 +const UserTypeID = 0xeb602f25 // construct implements constructor of UserClass. func (u User) construct() UserClass { return &u } @@ -439,6 +447,12 @@ func (u *User) Zero() bool { if !(u.StoriesMaxID == 0) { return false } + if !(u.Color == 0) { + return false + } + if !(u.BackgroundEmojiID == 0) { + return false + } return true } @@ -491,6 +505,8 @@ func (u *User) FillFrom(from interface { GetEmojiStatus() (value EmojiStatusClass, ok bool) GetUsernames() (value []Username, ok bool) GetStoriesMaxID() (value int, ok bool) + GetColor() (value int, ok bool) + GetBackgroundEmojiID() (value int64, ok bool) }) { u.Self = from.GetSelf() u.Contact = from.GetContact() @@ -571,6 +587,14 @@ func (u *User) FillFrom(from interface { u.StoriesMaxID = val } + if val, ok := from.GetColor(); ok { + u.Color = val + } + + if val, ok := from.GetBackgroundEmojiID(); ok { + u.BackgroundEmojiID = val + } + } // TypeID returns type id in TL schema. @@ -780,6 +804,16 @@ func (u *User) TypeInfo() tdp.Type { SchemaName: "stories_max_id", Null: !u.Flags2.Has(5), }, + { + Name: "Color", + SchemaName: "color", + Null: !u.Flags2.Has(7), + }, + { + Name: "BackgroundEmojiID", + SchemaName: "background_emoji_id", + Null: !u.Flags2.Has(6), + }, } return typ } @@ -894,12 +928,18 @@ func (u *User) SetFlags() { if !(u.StoriesMaxID == 0) { u.Flags2.Set(5) } + if !(u.Color == 0) { + u.Flags2.Set(7) + } + if !(u.BackgroundEmojiID == 0) { + u.Flags2.Set(6) + } } // Encode implements bin.Encoder. func (u *User) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode user#abb5f120 as nil") + return fmt.Errorf("can't encode user#eb602f25 as nil") } b.PutID(UserTypeID) return u.EncodeBare(b) @@ -908,14 +948,14 @@ 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#abb5f120 as nil") + return fmt.Errorf("can't encode user#eb602f25 as nil") } u.SetFlags() if err := u.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#abb5f120: field flags: %w", err) + return fmt.Errorf("unable to encode user#eb602f25: field flags: %w", err) } if err := u.Flags2.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#abb5f120: field flags2: %w", err) + return fmt.Errorf("unable to encode user#eb602f25: field flags2: %w", err) } b.PutLong(u.ID) if u.Flags.Has(0) { @@ -935,18 +975,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#abb5f120: field photo is nil") + return fmt.Errorf("unable to encode user#eb602f25: field photo is nil") } if err := u.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#abb5f120: field photo: %w", err) + return fmt.Errorf("unable to encode user#eb602f25: field photo: %w", err) } } if u.Flags.Has(6) { if u.Status == nil { - return fmt.Errorf("unable to encode user#abb5f120: field status is nil") + return fmt.Errorf("unable to encode user#eb602f25: field status is nil") } if err := u.Status.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#abb5f120: field status: %w", err) + return fmt.Errorf("unable to encode user#eb602f25: field status: %w", err) } } if u.Flags.Has(14) { @@ -956,7 +996,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#abb5f120: field restriction_reason element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode user#eb602f25: field restriction_reason element with index %d: %w", idx, err) } } } @@ -968,33 +1008,39 @@ func (u *User) EncodeBare(b *bin.Buffer) error { } if u.Flags.Has(30) { if u.EmojiStatus == nil { - return fmt.Errorf("unable to encode user#abb5f120: field emoji_status is nil") + return fmt.Errorf("unable to encode user#eb602f25: field emoji_status is nil") } if err := u.EmojiStatus.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#abb5f120: field emoji_status: %w", err) + return fmt.Errorf("unable to encode user#eb602f25: field emoji_status: %w", err) } } if u.Flags2.Has(0) { b.PutVectorHeader(len(u.Usernames)) for idx, v := range u.Usernames { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#abb5f120: field usernames element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode user#eb602f25: field usernames element with index %d: %w", idx, err) } } } if u.Flags2.Has(5) { b.PutInt(u.StoriesMaxID) } + if u.Flags2.Has(7) { + b.PutInt(u.Color) + } + if u.Flags2.Has(6) { + b.PutLong(u.BackgroundEmojiID) + } return nil } // Decode implements bin.Decoder. func (u *User) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode user#abb5f120 to nil") + return fmt.Errorf("can't decode user#eb602f25 to nil") } if err := b.ConsumeID(UserTypeID); err != nil { - return fmt.Errorf("unable to decode user#abb5f120: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: %w", err) } return u.DecodeBare(b) } @@ -1002,11 +1048,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#abb5f120 to nil") + return fmt.Errorf("can't decode user#eb602f25 to nil") } { if err := u.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode user#abb5f120: field flags: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: field flags: %w", err) } } u.Self = u.Flags.Has(10) @@ -1029,7 +1075,7 @@ func (u *User) DecodeBare(b *bin.Buffer) error { u.AttachMenuEnabled = u.Flags.Has(29) { if err := u.Flags2.Decode(b); err != nil { - return fmt.Errorf("unable to decode user#abb5f120: field flags2: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: field flags2: %w", err) } } u.BotCanEdit = u.Flags2.Has(1) @@ -1039,70 +1085,70 @@ func (u *User) DecodeBare(b *bin.Buffer) error { { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode user#abb5f120: field id: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: 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#abb5f120: field access_hash: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: 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#abb5f120: field first_name: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: 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#abb5f120: field last_name: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: 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#abb5f120: field username: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: 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#abb5f120: field phone: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: 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#abb5f120: field photo: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: 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#abb5f120: field status: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: 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#abb5f120: field bot_info_version: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: 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#abb5f120: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: field restriction_reason: %w", err) } if headerLen > 0 { @@ -1111,7 +1157,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#abb5f120: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: field restriction_reason: %w", err) } u.RestrictionReason = append(u.RestrictionReason, value) } @@ -1119,28 +1165,28 @@ 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#abb5f120: field bot_inline_placeholder: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: 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#abb5f120: field lang_code: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: 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#abb5f120: field emoji_status: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: field emoji_status: %w", err) } u.EmojiStatus = value } if u.Flags2.Has(0) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode user#abb5f120: field usernames: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: field usernames: %w", err) } if headerLen > 0 { @@ -1149,7 +1195,7 @@ func (u *User) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value Username if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode user#abb5f120: field usernames: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: field usernames: %w", err) } u.Usernames = append(u.Usernames, value) } @@ -1157,10 +1203,24 @@ func (u *User) DecodeBare(b *bin.Buffer) error { if u.Flags2.Has(5) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode user#abb5f120: field stories_max_id: %w", err) + return fmt.Errorf("unable to decode user#eb602f25: field stories_max_id: %w", err) } u.StoriesMaxID = value } + if u.Flags2.Has(7) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode user#eb602f25: field color: %w", err) + } + u.Color = value + } + if u.Flags2.Has(6) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode user#eb602f25: field background_emoji_id: %w", err) + } + u.BackgroundEmojiID = value + } return nil } @@ -1842,6 +1902,42 @@ func (u *User) GetStoriesMaxID() (value int, ok bool) { return u.StoriesMaxID, true } +// SetColor sets value of Color conditional field. +func (u *User) SetColor(value int) { + u.Flags2.Set(7) + u.Color = value +} + +// GetColor returns value of Color conditional field and +// boolean which is true if field was set. +func (u *User) GetColor() (value int, ok bool) { + if u == nil { + return + } + if !u.Flags2.Has(7) { + return value, false + } + return u.Color, true +} + +// SetBackgroundEmojiID sets value of BackgroundEmojiID conditional field. +func (u *User) SetBackgroundEmojiID(value int64) { + u.Flags2.Set(6) + u.BackgroundEmojiID = value +} + +// GetBackgroundEmojiID returns value of BackgroundEmojiID conditional field and +// boolean which is true if field was set. +func (u *User) GetBackgroundEmojiID() (value int64, ok bool) { + if u == nil { + return + } + if !u.Flags2.Has(6) { + return value, false + } + return u.BackgroundEmojiID, true +} + // UserClassName is schema name of UserClass. const UserClassName = "User" @@ -1857,7 +1953,7 @@ const UserClassName = "User" // } // switch v := g.(type) { // case *tg.UserEmpty: // userEmpty#d3bc4b7a -// case *tg.User: // user#abb5f120 +// case *tg.User: // user#eb602f25 // default: panic(v) // } type UserClass interface { @@ -1932,7 +2028,7 @@ func DecodeUser(buf *bin.Buffer) (UserClass, error) { } return &v, nil case UserTypeID: - // Decoding user#abb5f120. + // Decoding user#eb602f25. v := User{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UserClass: %w", err) diff --git a/tg/tl_web_page_gen.go b/tg/tl_web_page_gen.go index 7ee5b1f7cd..4e9ff15b8d 100644 --- a/tg/tl_web_page_gen.go +++ b/tg/tl_web_page_gen.go @@ -31,17 +31,23 @@ var ( _ = tdjson.Encoder{} ) -// WebPageEmpty represents TL type `webPageEmpty#eb1477e8`. +// WebPageEmpty represents TL type `webPageEmpty#211a1788`. // No preview is available for the webpage // // See https://core.telegram.org/constructor/webPageEmpty for reference. type WebPageEmpty struct { + // Flags field of WebPageEmpty. + Flags bin.Fields // Preview ID ID int64 + // URL field of WebPageEmpty. + // + // Use SetURL and GetURL helpers. + URL string } // WebPageEmptyTypeID is TL type id of WebPageEmpty. -const WebPageEmptyTypeID = 0xeb1477e8 +const WebPageEmptyTypeID = 0x211a1788 // construct implements constructor of WebPageClass. func (w WebPageEmpty) construct() WebPageClass { return &w } @@ -60,9 +66,15 @@ func (w *WebPageEmpty) Zero() bool { if w == nil { return true } + if !(w.Flags.Zero()) { + return false + } if !(w.ID == 0) { return false } + if !(w.URL == "") { + return false + } return true } @@ -79,8 +91,13 @@ func (w *WebPageEmpty) String() string { // FillFrom fills WebPageEmpty from given interface. func (w *WebPageEmpty) FillFrom(from interface { GetID() (value int64) + GetURL() (value string, ok bool) }) { w.ID = from.GetID() + if val, ok := from.GetURL(); ok { + w.URL = val + } + } // TypeID returns type id in TL schema. @@ -110,14 +127,26 @@ func (w *WebPageEmpty) TypeInfo() tdp.Type { Name: "ID", SchemaName: "id", }, + { + Name: "URL", + SchemaName: "url", + Null: !w.Flags.Has(0), + }, } return typ } +// SetFlags sets flags for non-zero fields. +func (w *WebPageEmpty) SetFlags() { + if !(w.URL == "") { + w.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (w *WebPageEmpty) Encode(b *bin.Buffer) error { if w == nil { - return fmt.Errorf("can't encode webPageEmpty#eb1477e8 as nil") + return fmt.Errorf("can't encode webPageEmpty#211a1788 as nil") } b.PutID(WebPageEmptyTypeID) return w.EncodeBare(b) @@ -126,19 +155,26 @@ func (w *WebPageEmpty) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (w *WebPageEmpty) EncodeBare(b *bin.Buffer) error { if w == nil { - return fmt.Errorf("can't encode webPageEmpty#eb1477e8 as nil") + return fmt.Errorf("can't encode webPageEmpty#211a1788 as nil") + } + w.SetFlags() + if err := w.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode webPageEmpty#211a1788: field flags: %w", err) } b.PutLong(w.ID) + if w.Flags.Has(0) { + b.PutString(w.URL) + } return nil } // Decode implements bin.Decoder. func (w *WebPageEmpty) Decode(b *bin.Buffer) error { if w == nil { - return fmt.Errorf("can't decode webPageEmpty#eb1477e8 to nil") + return fmt.Errorf("can't decode webPageEmpty#211a1788 to nil") } if err := b.ConsumeID(WebPageEmptyTypeID); err != nil { - return fmt.Errorf("unable to decode webPageEmpty#eb1477e8: %w", err) + return fmt.Errorf("unable to decode webPageEmpty#211a1788: %w", err) } return w.DecodeBare(b) } @@ -146,15 +182,27 @@ func (w *WebPageEmpty) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (w *WebPageEmpty) DecodeBare(b *bin.Buffer) error { if w == nil { - return fmt.Errorf("can't decode webPageEmpty#eb1477e8 to nil") + return fmt.Errorf("can't decode webPageEmpty#211a1788 to nil") + } + { + if err := w.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode webPageEmpty#211a1788: field flags: %w", err) + } } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode webPageEmpty#eb1477e8: field id: %w", err) + return fmt.Errorf("unable to decode webPageEmpty#211a1788: field id: %w", err) } w.ID = value } + if w.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode webPageEmpty#211a1788: field url: %w", err) + } + w.URL = value + } return nil } @@ -166,19 +214,43 @@ func (w *WebPageEmpty) GetID() (value int64) { return w.ID } -// WebPagePending represents TL type `webPagePending#c586da1c`. +// SetURL sets value of URL conditional field. +func (w *WebPageEmpty) SetURL(value string) { + w.Flags.Set(0) + w.URL = value +} + +// GetURL returns value of URL conditional field and +// boolean which is true if field was set. +func (w *WebPageEmpty) GetURL() (value string, ok bool) { + if w == nil { + return + } + if !w.Flags.Has(0) { + return value, false + } + return w.URL, true +} + +// WebPagePending represents TL type `webPagePending#b0d13e47`. // A preview of the webpage is currently being generated // // See https://core.telegram.org/constructor/webPagePending for reference. type WebPagePending struct { + // Flags field of WebPagePending. + Flags bin.Fields // ID of preview ID int64 + // URL field of WebPagePending. + // + // Use SetURL and GetURL helpers. + URL string // When was the processing started Date int } // WebPagePendingTypeID is TL type id of WebPagePending. -const WebPagePendingTypeID = 0xc586da1c +const WebPagePendingTypeID = 0xb0d13e47 // construct implements constructor of WebPageClass. func (w WebPagePending) construct() WebPageClass { return &w } @@ -197,9 +269,15 @@ func (w *WebPagePending) Zero() bool { if w == nil { return true } + if !(w.Flags.Zero()) { + return false + } if !(w.ID == 0) { return false } + if !(w.URL == "") { + return false + } if !(w.Date == 0) { return false } @@ -219,9 +297,14 @@ func (w *WebPagePending) String() string { // FillFrom fills WebPagePending from given interface. func (w *WebPagePending) FillFrom(from interface { GetID() (value int64) + GetURL() (value string, ok bool) GetDate() (value int) }) { w.ID = from.GetID() + if val, ok := from.GetURL(); ok { + w.URL = val + } + w.Date = from.GetDate() } @@ -252,6 +335,11 @@ func (w *WebPagePending) TypeInfo() tdp.Type { Name: "ID", SchemaName: "id", }, + { + Name: "URL", + SchemaName: "url", + Null: !w.Flags.Has(0), + }, { Name: "Date", SchemaName: "date", @@ -260,10 +348,17 @@ func (w *WebPagePending) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (w *WebPagePending) SetFlags() { + if !(w.URL == "") { + w.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (w *WebPagePending) Encode(b *bin.Buffer) error { if w == nil { - return fmt.Errorf("can't encode webPagePending#c586da1c as nil") + return fmt.Errorf("can't encode webPagePending#b0d13e47 as nil") } b.PutID(WebPagePendingTypeID) return w.EncodeBare(b) @@ -272,9 +367,16 @@ func (w *WebPagePending) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (w *WebPagePending) EncodeBare(b *bin.Buffer) error { if w == nil { - return fmt.Errorf("can't encode webPagePending#c586da1c as nil") + return fmt.Errorf("can't encode webPagePending#b0d13e47 as nil") + } + w.SetFlags() + if err := w.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode webPagePending#b0d13e47: field flags: %w", err) } b.PutLong(w.ID) + if w.Flags.Has(0) { + b.PutString(w.URL) + } b.PutInt(w.Date) return nil } @@ -282,10 +384,10 @@ func (w *WebPagePending) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (w *WebPagePending) Decode(b *bin.Buffer) error { if w == nil { - return fmt.Errorf("can't decode webPagePending#c586da1c to nil") + return fmt.Errorf("can't decode webPagePending#b0d13e47 to nil") } if err := b.ConsumeID(WebPagePendingTypeID); err != nil { - return fmt.Errorf("unable to decode webPagePending#c586da1c: %w", err) + return fmt.Errorf("unable to decode webPagePending#b0d13e47: %w", err) } return w.DecodeBare(b) } @@ -293,19 +395,31 @@ func (w *WebPagePending) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (w *WebPagePending) DecodeBare(b *bin.Buffer) error { if w == nil { - return fmt.Errorf("can't decode webPagePending#c586da1c to nil") + return fmt.Errorf("can't decode webPagePending#b0d13e47 to nil") + } + { + if err := w.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode webPagePending#b0d13e47: field flags: %w", err) + } } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode webPagePending#c586da1c: field id: %w", err) + return fmt.Errorf("unable to decode webPagePending#b0d13e47: field id: %w", err) } w.ID = value } + if w.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode webPagePending#b0d13e47: field url: %w", err) + } + w.URL = value + } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode webPagePending#c586da1c: field date: %w", err) + return fmt.Errorf("unable to decode webPagePending#b0d13e47: field date: %w", err) } w.Date = value } @@ -320,6 +434,24 @@ func (w *WebPagePending) GetID() (value int64) { return w.ID } +// SetURL sets value of URL conditional field. +func (w *WebPagePending) SetURL(value string) { + w.Flags.Set(0) + w.URL = value +} + +// GetURL returns value of URL conditional field and +// boolean which is true if field was set. +func (w *WebPagePending) GetURL() (value string, ok bool) { + if w == nil { + return + } + if !w.Flags.Has(0) { + return value, false + } + return w.URL, true +} + // GetDate returns value of Date field. func (w *WebPagePending) GetDate() (value int) { if w == nil { @@ -338,6 +470,8 @@ type WebPage struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields + // HasLargeMedia field of WebPage. + HasLargeMedia bool // Preview ID ID int64 // URL of previewed webpage @@ -434,6 +568,9 @@ func (w *WebPage) Zero() bool { if !(w.Flags.Zero()) { return false } + if !(w.HasLargeMedia == false) { + return false + } if !(w.ID == 0) { return false } @@ -503,6 +640,7 @@ func (w *WebPage) String() string { // FillFrom fills WebPage from given interface. func (w *WebPage) FillFrom(from interface { + GetHasLargeMedia() (value bool) GetID() (value int64) GetURL() (value string) GetDisplayURL() (value string) @@ -522,6 +660,7 @@ func (w *WebPage) FillFrom(from interface { GetCachedPage() (value Page, ok bool) GetAttributes() (value []WebPageAttributeClass, ok bool) }) { + w.HasLargeMedia = from.GetHasLargeMedia() w.ID = from.GetID() w.URL = from.GetURL() w.DisplayURL = from.GetDisplayURL() @@ -607,6 +746,11 @@ func (w *WebPage) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "HasLargeMedia", + SchemaName: "has_large_media", + Null: !w.Flags.Has(13), + }, { Name: "ID", SchemaName: "id", @@ -699,6 +843,9 @@ func (w *WebPage) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (w *WebPage) SetFlags() { + if !(w.HasLargeMedia == false) { + w.Flags.Set(13) + } if !(w.Type == "") { w.Flags.Set(0) } @@ -851,6 +998,7 @@ func (w *WebPage) DecodeBare(b *bin.Buffer) error { return fmt.Errorf("unable to decode webPage#e89c45b2: field flags: %w", err) } } + w.HasLargeMedia = w.Flags.Has(13) { value, err := b.Long() if err != nil { @@ -988,6 +1136,25 @@ func (w *WebPage) DecodeBare(b *bin.Buffer) error { return nil } +// SetHasLargeMedia sets value of HasLargeMedia conditional field. +func (w *WebPage) SetHasLargeMedia(value bool) { + if value { + w.Flags.Set(13) + w.HasLargeMedia = true + } else { + w.Flags.Unset(13) + w.HasLargeMedia = false + } +} + +// GetHasLargeMedia returns value of HasLargeMedia conditional field. +func (w *WebPage) GetHasLargeMedia() (value bool) { + if w == nil { + return + } + return w.Flags.Has(13) +} + // GetID returns value of ID field. func (w *WebPage) GetID() (value int64) { if w == nil { @@ -1471,8 +1638,8 @@ const WebPageClassName = "WebPage" // panic(err) // } // switch v := g.(type) { -// case *tg.WebPageEmpty: // webPageEmpty#eb1477e8 -// case *tg.WebPagePending: // webPagePending#c586da1c +// case *tg.WebPageEmpty: // webPageEmpty#211a1788 +// case *tg.WebPagePending: // webPagePending#b0d13e47 // case *tg.WebPage: // webPage#e89c45b2 // case *tg.WebPageNotModified: // webPageNotModified#7311ca11 // default: panic(v) @@ -1554,14 +1721,14 @@ func DecodeWebPage(buf *bin.Buffer) (WebPageClass, error) { } switch id { case WebPageEmptyTypeID: - // Decoding webPageEmpty#eb1477e8. + // Decoding webPageEmpty#211a1788. v := WebPageEmpty{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode WebPageClass: %w", err) } return &v, nil case WebPagePendingTypeID: - // Decoding webPagePending#c586da1c. + // Decoding webPagePending#b0d13e47. v := WebPagePending{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode WebPageClass: %w", err) From 04fed8f8b183eb19221e5e3228b286b9109f6346 Mon Sep 17 00:00:00 2001 From: Aleksandr Razumov Date: Mon, 30 Oct 2023 10:47:42 +0300 Subject: [PATCH 2/4] fix: refactor after schema update --- examples/go.mod | 4 ++-- examples/go.sum | 2 ++ telegram/message/builder.go | 8 +++++--- telegram/message/builder_test.go | 2 +- telegram/message/draft.go | 10 +++++----- telegram/message/inline.go | 2 +- telegram/message/media.go | 4 ++-- telegram/message/text.go | 2 +- 8 files changed, 19 insertions(+), 15 deletions(-) diff --git a/examples/go.mod b/examples/go.mod index 466c117966..2ff626509d 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -31,7 +31,7 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/gotd/ige v0.2.2 // indirect github.com/gotd/neo v0.1.5 // indirect - github.com/klauspost/compress v1.17.0 // indirect + github.com/klauspost/compress v1.17.2 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect @@ -44,7 +44,7 @@ require ( golang.org/x/exp v0.0.0-20230116083435-1de6713980de // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.13.0 // indirect - nhooyr.io/websocket v1.8.7 // indirect + nhooyr.io/websocket v1.8.10 // indirect rsc.io/qr v0.2.0 // indirect ) diff --git a/examples/go.sum b/examples/go.sum index fd4de8e29f..41fa1b76fe 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -164,6 +164,7 @@ github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -404,5 +405,6 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= +nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY= rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs= diff --git a/telegram/message/builder.go b/telegram/message/builder.go index 783e69a19a..edff4a7f81 100644 --- a/telegram/message/builder.go +++ b/telegram/message/builder.go @@ -33,8 +33,8 @@ type Builder struct { // noForwards whether that sent message cannot be forwarded. noForwards bool - // The message ID to which this message will reply to. - replyToMsgID int + // The reply target. + replyTo tg.InputReplyToClass // Reply markup for sending bot buttons. replyMarkup tg.ReplyMarkupClass // Scheduled message date for scheduled messages. @@ -73,7 +73,9 @@ func (b *Builder) Clear() *Builder { // Reply sets message ID to reply. func (b *Builder) Reply(id int) *Builder { - b.replyToMsgID = id + b.replyTo = &tg.InputReplyToMessage{ + ReplyToMsgID: id, + } return b } diff --git a/telegram/message/builder_test.go b/telegram/message/builder_test.go index 73a78dc49c..07f1cc0e6c 100644 --- a/telegram/message/builder_test.go +++ b/telegram/message/builder_test.go @@ -26,7 +26,7 @@ func TestBuilder(t *testing.T) { a.True(b.noWebpage) b = b.ReplyMsg(&tg.Message{ID: 10}) - a.Equal(10, b.replyToMsgID) + a.Equal(10, b.replyTo.(*tg.InputReplyToMessage).ReplyToMsgID) date := time.Now() b = b.Schedule(date) diff --git a/telegram/message/draft.go b/telegram/message/draft.go index 8d25f4dcbc..d493899442 100644 --- a/telegram/message/draft.go +++ b/telegram/message/draft.go @@ -16,11 +16,11 @@ func (b *Builder) saveDraftRequest( entities []tg.MessageEntityClass, ) *tg.MessagesSaveDraftRequest { return &tg.MessagesSaveDraftRequest{ - NoWebpage: b.noWebpage, - Peer: peer, - ReplyToMsgID: b.replyToMsgID, - Message: msg, - Entities: entities, + NoWebpage: b.noWebpage, + Peer: peer, + ReplyTo: b.replyTo, + Message: msg, + Entities: entities, } } diff --git a/telegram/message/inline.go b/telegram/message/inline.go index 8cc6b4b482..b0448b809f 100644 --- a/telegram/message/inline.go +++ b/telegram/message/inline.go @@ -22,7 +22,7 @@ func (b *Builder) InlineResult(ctx context.Context, id string, queryID int64, hi ClearDraft: b.clearDraft, HideVia: hideVia, Peer: p, - ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: b.replyToMsgID}, + ReplyTo: b.replyTo, QueryID: queryID, ID: id, ScheduleDate: b.scheduleDate, diff --git a/telegram/message/media.go b/telegram/message/media.go index f47a71b5d5..a7243ded80 100644 --- a/telegram/message/media.go +++ b/telegram/message/media.go @@ -58,7 +58,7 @@ func (b *Builder) Album(ctx context.Context, media MultiMediaOption, album ...Mu Background: b.background, ClearDraft: b.clearDraft, Peer: p, - ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: b.replyToMsgID}, + ReplyTo: b.replyTo, MultiMedia: mb, ScheduleDate: b.scheduleDate, }) @@ -112,7 +112,7 @@ func (b *Builder) Media(ctx context.Context, media MediaOption) (tg.UpdatesClass Background: b.background, ClearDraft: b.clearDraft, Peer: p, - ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: b.replyToMsgID}, + ReplyTo: b.replyTo, Media: attachment.Media, Message: attachment.Message, ReplyMarkup: b.replyMarkup, diff --git a/telegram/message/text.go b/telegram/message/text.go index 7f8f9ca0bb..3f8b105626 100644 --- a/telegram/message/text.go +++ b/telegram/message/text.go @@ -22,7 +22,7 @@ func (b *Builder) sendRequest( ClearDraft: b.clearDraft, Noforwards: b.noForwards, Peer: p, - ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: b.replyToMsgID}, + ReplyTo: b.replyTo, Message: msg, RandomID: 0, ReplyMarkup: b.replyMarkup, From 74433497f05f0f5509ac0b3e8ddf51b1d150de60 Mon Sep 17 00:00:00 2001 From: Aleksandr Razumov Date: Mon, 30 Oct 2023 10:50:36 +0300 Subject: [PATCH 3/4] chore(deps): update getdoc --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e23b043277..4f2c7beb5b 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/go-faster/jx v1.1.0 github.com/go-faster/xor v1.0.0 github.com/go-openapi/inflect v0.19.0 - github.com/gotd/getdoc v0.33.0 + github.com/gotd/getdoc v0.34.0 github.com/gotd/ige v0.2.2 github.com/gotd/neo v0.1.5 github.com/gotd/tl v0.4.0 diff --git a/go.sum b/go.sum index 64759947cd..61131a5b34 100644 --- a/go.sum +++ b/go.sum @@ -21,6 +21,8 @@ github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12f github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/gotd/getdoc v0.33.0 h1:SuhzZGPkKmc1UujqMK9I2sZhZ0CVmopC/b+9uG5+7r4= github.com/gotd/getdoc v0.33.0/go.mod h1:qzfE27A4jhjLh1jTtwryuS0J3x2sRvQyzVYPfuZ17Yk= +github.com/gotd/getdoc v0.34.0 h1:Zx+SW9LYgksInerjl2Tr+i8XdrNAky/VOn3EF54gcOI= +github.com/gotd/getdoc v0.34.0/go.mod h1:qzfE27A4jhjLh1jTtwryuS0J3x2sRvQyzVYPfuZ17Yk= github.com/gotd/ige v0.2.2 h1:XQ9dJZwBfDnOGSTxKXBGP4gMud3Qku2ekScRjDWWfEk= github.com/gotd/ige v0.2.2/go.mod h1:tuCRb+Y5Y3eNTo3ypIfNpQ4MFjrnONiL2jN2AKZXmb0= github.com/gotd/neo v0.1.5 h1:oj0iQfMbGClP8xI59x7fE/uHoTJD7NZH9oV1WNuPukQ= From 58b60f86e3965875e78f19aa490b464eac2a6028 Mon Sep 17 00:00:00 2001 From: Aleksandr Razumov Date: Mon, 30 Oct 2023 11:16:13 +0300 Subject: [PATCH 4/4] ci: disable x386 --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a80d29fa5..87f448b1f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,10 +22,6 @@ jobs: - ubuntu-latest - macos-latest include: - - arch: 386 - go: "1.21" - runner: ubuntu-latest - - arch: amd64 runner: windows-latest go: "1.21"