diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index 4356ec6eb..6053c49d2 100644 --- a/_schema/tdesktop.tl +++ b/_schema/tdesktop.tl @@ -1,8 +1,8 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl -// Layer: 184 -// SHA256: a37868b9861499415a8c27ae47e42b3cd96eb175bd49a91f272e43dd57261c51 +// Layer: 185 +// SHA256: c488cd16de64bea5e744d4a0954cfdec14947c71bcf21084f281bf062b23a173 boolFalse#bc799737 = Bool; @@ -140,7 +140,7 @@ storage.fileWebp#1081464c = storage.FileType; userEmpty#d3bc4b7a id:long = User; -user#215c4438 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 contact_require_premium:flags2.10?true bot_business:flags2.11?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.8?PeerColor profile_color:flags2.9?PeerColor = User; +user#83314fca 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 contact_require_premium:flags2.10?true bot_business:flags2.11?true bot_has_main_app:flags2.13?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.8?PeerColor profile_color:flags2.9?PeerColor bot_active_users:flags2.12?int = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; @@ -314,6 +314,8 @@ messageActionRequestedPeerSentMe#93b31848 button_id:int peers:Vector menu_button:flags.3?BotMenuButton = BotInfo; +botInfo#8f300b57 flags:# has_preview_medias:flags.6?true user_id:flags.0?long description:flags.1?string description_photo:flags.4?Photo description_document:flags.5?Document commands:flags.2?Vector menu_button:flags.3?BotMenuButton = BotInfo; keyboardButton#a2fa4880 text:string = KeyboardButton; @@ -1316,6 +1318,8 @@ topPeerCategoryForwardUsers#a8406ca9 = TopPeerCategory; topPeerCategoryForwardChats#fbeec0f0 = TopPeerCategory; +topPeerCategoryBotsApp#fd9e7bec = TopPeerCategory; + topPeerCategoryPeers#fb834291 category:TopPeerCategory count:int peers:Vector = TopPeerCategoryPeers; contacts.topPeersNotModified#de266ef5 = contacts.TopPeers; @@ -2210,7 +2214,7 @@ inputInvoiceSlug#c326caef slug:string = InputInvoice; inputInvoicePremiumGiftCode#98986c0d purpose:InputStorePaymentPurpose option:PremiumGiftCodeOption = InputInvoice; -inputInvoiceStars#1da33ad8 option:StarsTopupOption = InputInvoice; +inputInvoiceStars#65f00ce3 purpose:InputStorePaymentPurpose = InputInvoice; payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice; @@ -2226,7 +2230,9 @@ inputStorePaymentPremiumGiftCode#a3805f3f flags:# users:Vector boost_ inputStorePaymentPremiumGiveaway#160544ca flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.3?true boost_peer:InputPeer additional_peers:flags.1?Vector countries_iso2:flags.2?Vector prize_description:flags.4?string random_id:long until_date:int currency:string amount:long = InputStorePaymentPurpose; -inputStorePaymentStars#4f0ee8df flags:# stars:long currency:string amount:long = InputStorePaymentPurpose; +inputStorePaymentStarsTopup#dddd0f56 stars:long currency:string amount:long = InputStorePaymentPurpose; + +inputStorePaymentStarsGift#1d741ef7 user_id:InputUser stars:long currency:string amount:long = InputStorePaymentPurpose; premiumGiftOption#74c34319 flags:# months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumGiftOption; @@ -2414,6 +2420,8 @@ inputMediaAreaChannelPost#2271f2bf coordinates:MediaAreaCoordinates channel:Inpu mediaAreaUrl#37381085 coordinates:MediaAreaCoordinates url:string = MediaArea; +mediaAreaWeather#49a6549c coordinates:MediaAreaCoordinates emoji:string temperature_c:double color:int = MediaArea; + peerStories#9a35e999 flags:# peer:Peer max_read_id:flags.0?int stories:Vector = PeerStories; stories.peerStories#cae68768 stories:PeerStories chats:Vector users:Vector = stories.PeerStories; @@ -2636,7 +2644,7 @@ starsTransactionPeerAds#60682812 = StarsTransactionPeer; starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; -starsTransaction#2db5418f flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector = StarsTransaction; +starsTransaction#2db5418f flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector = StarsTransaction; payments.starsStatus#8cf4ee60 flags:# balance:long history:Vector next_offset:flags.0?string chats:Vector users:Vector = payments.StarsStatus; @@ -2656,6 +2664,14 @@ payments.starsRevenueAdsAccountUrl#394e7f21 url:string = payments.StarsRevenueAd inputStarsTransaction#206ae6d1 flags:# refund:flags.0?true id:string = InputStarsTransaction; +starsGiftOption#5e0589f1 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsGiftOption; + +bots.popularAppBots#1991b13b flags:# next_offset:flags.0?string users:Vector = bots.PopularAppBots; + +botPreviewMedia#23e91ba3 date:int media:MessageMedia = BotPreviewMedia; + +bots.previewInfo#ca71d64 media:Vector lang_codes:Vector = bots.PreviewInfo; + ---functions--- @@ -2979,7 +2995,7 @@ contacts.search#11f812d8 q:string limit:int = contacts.Found; contacts.resolveUsername#f93ccba3 username:string = contacts.ResolvedPeer; -contacts.getTopPeers#973478b6 flags:# correspondents:flags.0?true bots_pm:flags.1?true bots_inline:flags.2?true phone_calls:flags.3?true forward_users:flags.4?true forward_chats:flags.5?true groups:flags.10?true channels:flags.15?true offset:int limit:int hash:long = contacts.TopPeers; +contacts.getTopPeers#973478b6 flags:# correspondents:flags.0?true bots_pm:flags.1?true bots_inline:flags.2?true phone_calls:flags.3?true forward_users:flags.4?true forward_chats:flags.5?true groups:flags.10?true channels:flags.15?true bots_app:flags.16?true offset:int limit:int hash:long = contacts.TopPeers; contacts.resetTopPeerRating#1ae373ac category:TopPeerCategory peer:InputPeer = Bool; @@ -3435,6 +3451,8 @@ messages.deleteFactCheck#d1da940c peer:InputPeer msg_id:int = Updates; messages.getFactCheck#b9cdc5ee peer:InputPeer msg_id:Vector = Vector; +messages.requestMainWebView#c9e01e7b flags:# compact:flags.7?true peer:InputPeer bot:InputUser start_param:flags.1?string theme_params:flags.0?DataJSON platform:string = WebViewResult; + updates.getState#edd4882a = updates.State; updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference; @@ -3679,6 +3697,20 @@ bots.allowSendMessage#f132e3ef bot:InputUser = Updates; bots.invokeWebViewCustomMethod#87fc5e7 bot:InputUser custom_method:string params:DataJSON = DataJSON; +bots.getPopularAppBots#c2510192 offset:string limit:int = bots.PopularAppBots; + +bots.addPreviewMedia#17aeb75a bot:InputUser lang_code:string media:InputMedia = BotPreviewMedia; + +bots.editPreviewMedia#8525606f bot:InputUser lang_code:string media:InputMedia new_media:InputMedia = BotPreviewMedia; + +bots.deletePreviewMedia#2d0135b3 bot:InputUser lang_code:string media:Vector = Bool; + +bots.reorderPreviewMedias#b627f3aa bot:InputUser lang_code:string order:Vector = Bool; + +bots.getPreviewInfo#423ab3ad bot:InputUser lang_code:string = bots.PreviewInfo; + +bots.getPreviewMedias#a2a5594d bot:InputUser = Vector; + payments.getPaymentForm#37148dbb flags:# invoice:InputInvoice theme_params:flags.0?DataJSON = payments.PaymentForm; payments.getPaymentReceipt#2478d1cc peer:InputPeer msg_id:int = payments.PaymentReceipt; @@ -3729,6 +3761,8 @@ payments.getStarsRevenueAdsAccountUrl#d1d7efc5 peer:InputPeer = payments.StarsRe payments.getStarsTransactionsByID#27842d2e peer:InputPeer id:Vector = payments.StarsStatus; +payments.getStarsGiftOptions#d3c96bc8 flags:# user_id:flags.0?InputUser = Vector; + stickers.createStickerSet#9021ab67 flags:# masks:flags.0?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; @@ -3945,4 +3979,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 184 +// LAYER 185 diff --git a/_schema/tdlib.tl b/_schema/tdlib.tl index ba31e17de..25d4d6923 100644 --- a/_schema/tdlib.tl +++ b/_schema/tdlib.tl @@ -1,8 +1,8 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/tdlib/td/master/td/generate/scheme/telegram_api.tl -// Layer: 184 -// SHA256: 27b8cea98891e644164d7d74ae7338e948a53e4b8134088363ee4c7fa416c492 +// Layer: 185 +// SHA256: 5c7629bbffdcdc1814e1d0c9630a55a16127237bb97282f5799bcd4566416207 int#a8509bda ? = Int; @@ -78,6 +78,8 @@ inputFile#f52ff27f id:long parts:int name:string md5_checksum:string = InputFile inputFileBig#fa4f0bb5 id:long parts:int name:string = InputFile; +inputFileStoryDocument#62dc8b48 id:InputDocument = InputFile; + inputMediaEmpty#9664f57f = InputMedia; inputMediaUploadedPhoto#1e287d04 flags:# spoiler:flags.2?true file:InputFile stickers:flags.0?Vector ttl_seconds:flags.1?int = InputMedia; @@ -176,7 +178,7 @@ storage.fileWebp#1081464c = storage.FileType; userEmpty#d3bc4b7a id:long = User; -user#215c4438 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 contact_require_premium:flags2.10?true bot_business:flags2.11?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.8?PeerColor profile_color:flags2.9?PeerColor = User; +user#83314fca 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 contact_require_premium:flags2.10?true bot_business:flags2.11?true bot_has_main_app:flags2.13?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.8?PeerColor profile_color:flags2.9?PeerColor bot_active_users:flags2.12?int = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; @@ -350,6 +352,8 @@ messageActionRequestedPeerSentMe#93b31848 button_id:int peers:Vector menu_button:flags.3?BotMenuButton = BotInfo; +botInfo#8f300b57 flags:# has_preview_medias:flags.6?true user_id:flags.0?long description:flags.1?string description_photo:flags.4?Photo description_document:flags.5?Document commands:flags.2?Vector menu_button:flags.3?BotMenuButton = BotInfo; keyboardButton#a2fa4880 text:string = KeyboardButton; @@ -1352,6 +1356,8 @@ topPeerCategoryForwardUsers#a8406ca9 = TopPeerCategory; topPeerCategoryForwardChats#fbeec0f0 = TopPeerCategory; +topPeerCategoryBotsApp#fd9e7bec = TopPeerCategory; + topPeerCategoryPeers#fb834291 category:TopPeerCategory count:int peers:Vector = TopPeerCategoryPeers; contacts.topPeersNotModified#de266ef5 = contacts.TopPeers; @@ -2246,7 +2252,7 @@ inputInvoiceSlug#c326caef slug:string = InputInvoice; inputInvoicePremiumGiftCode#98986c0d purpose:InputStorePaymentPurpose option:PremiumGiftCodeOption = InputInvoice; -inputInvoiceStars#1da33ad8 option:StarsTopupOption = InputInvoice; +inputInvoiceStars#65f00ce3 purpose:InputStorePaymentPurpose = InputInvoice; payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice; @@ -2262,7 +2268,9 @@ inputStorePaymentPremiumGiftCode#a3805f3f flags:# users:Vector boost_ inputStorePaymentPremiumGiveaway#160544ca flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.3?true boost_peer:InputPeer additional_peers:flags.1?Vector countries_iso2:flags.2?Vector prize_description:flags.4?string random_id:long until_date:int currency:string amount:long = InputStorePaymentPurpose; -inputStorePaymentStars#4f0ee8df flags:# stars:long currency:string amount:long = InputStorePaymentPurpose; +inputStorePaymentStarsTopup#dddd0f56 stars:long currency:string amount:long = InputStorePaymentPurpose; + +inputStorePaymentStarsGift#1d741ef7 user_id:InputUser stars:long currency:string amount:long = InputStorePaymentPurpose; premiumGiftOption#74c34319 flags:# months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumGiftOption; @@ -2450,6 +2458,8 @@ inputMediaAreaChannelPost#2271f2bf coordinates:MediaAreaCoordinates channel:Inpu mediaAreaUrl#37381085 coordinates:MediaAreaCoordinates url:string = MediaArea; +mediaAreaWeather#49a6549c coordinates:MediaAreaCoordinates emoji:string temperature_c:double color:int = MediaArea; + peerStories#9a35e999 flags:# peer:Peer max_read_id:flags.0?int stories:Vector = PeerStories; stories.peerStories#cae68768 stories:PeerStories chats:Vector users:Vector = stories.PeerStories; @@ -2672,7 +2682,7 @@ starsTransactionPeerAds#60682812 = StarsTransactionPeer; starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; -starsTransaction#2db5418f flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector = StarsTransaction; +starsTransaction#2db5418f flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector = StarsTransaction; payments.starsStatus#8cf4ee60 flags:# balance:long history:Vector next_offset:flags.0?string chats:Vector users:Vector = payments.StarsStatus; @@ -2692,6 +2702,14 @@ payments.starsRevenueAdsAccountUrl#394e7f21 url:string = payments.StarsRevenueAd inputStarsTransaction#206ae6d1 flags:# refund:flags.0?true id:string = InputStarsTransaction; +starsGiftOption#5e0589f1 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsGiftOption; + +bots.popularAppBots#1991b13b flags:# next_offset:flags.0?string users:Vector = bots.PopularAppBots; + +botPreviewMedia#23e91ba3 date:int media:MessageMedia = BotPreviewMedia; + +bots.previewInfo#ca71d64 media:Vector lang_codes:Vector = bots.PreviewInfo; + ---functions--- @@ -3015,7 +3033,7 @@ contacts.search#11f812d8 q:string limit:int = contacts.Found; contacts.resolveUsername#f93ccba3 username:string = contacts.ResolvedPeer; -contacts.getTopPeers#973478b6 flags:# correspondents:flags.0?true bots_pm:flags.1?true bots_inline:flags.2?true phone_calls:flags.3?true forward_users:flags.4?true forward_chats:flags.5?true groups:flags.10?true channels:flags.15?true offset:int limit:int hash:long = contacts.TopPeers; +contacts.getTopPeers#973478b6 flags:# correspondents:flags.0?true bots_pm:flags.1?true bots_inline:flags.2?true phone_calls:flags.3?true forward_users:flags.4?true forward_chats:flags.5?true groups:flags.10?true channels:flags.15?true bots_app:flags.16?true offset:int limit:int hash:long = contacts.TopPeers; contacts.resetTopPeerRating#1ae373ac category:TopPeerCategory peer:InputPeer = Bool; @@ -3471,6 +3489,8 @@ messages.deleteFactCheck#d1da940c peer:InputPeer msg_id:int = Updates; messages.getFactCheck#b9cdc5ee peer:InputPeer msg_id:Vector = Vector; +messages.requestMainWebView#c9e01e7b flags:# compact:flags.7?true peer:InputPeer bot:InputUser start_param:flags.1?string theme_params:flags.0?DataJSON platform:string = WebViewResult; + updates.getState#edd4882a = updates.State; updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference; @@ -3715,6 +3735,20 @@ bots.allowSendMessage#f132e3ef bot:InputUser = Updates; bots.invokeWebViewCustomMethod#87fc5e7 bot:InputUser custom_method:string params:DataJSON = DataJSON; +bots.getPopularAppBots#c2510192 offset:string limit:int = bots.PopularAppBots; + +bots.addPreviewMedia#17aeb75a bot:InputUser lang_code:string media:InputMedia = BotPreviewMedia; + +bots.editPreviewMedia#8525606f bot:InputUser lang_code:string media:InputMedia new_media:InputMedia = BotPreviewMedia; + +bots.deletePreviewMedia#2d0135b3 bot:InputUser lang_code:string media:Vector = Bool; + +bots.reorderPreviewMedias#b627f3aa bot:InputUser lang_code:string order:Vector = Bool; + +bots.getPreviewInfo#423ab3ad bot:InputUser lang_code:string = bots.PreviewInfo; + +bots.getPreviewMedias#a2a5594d bot:InputUser = Vector; + payments.getPaymentForm#37148dbb flags:# invoice:InputInvoice theme_params:flags.0?DataJSON = payments.PaymentForm; payments.getPaymentReceipt#2478d1cc peer:InputPeer msg_id:int = payments.PaymentReceipt; @@ -3765,6 +3799,8 @@ payments.getStarsRevenueAdsAccountUrl#d1d7efc5 peer:InputPeer = payments.StarsRe payments.getStarsTransactionsByID#27842d2e peer:InputPeer id:Vector = payments.StarsStatus; +payments.getStarsGiftOptions#d3c96bc8 flags:# user_id:flags.0?InputUser = Vector; + stickers.createStickerSet#9021ab67 flags:# masks:flags.0?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; @@ -3981,4 +4017,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 184 +// LAYER 185 diff --git a/_schema/telegram.tl b/_schema/telegram.tl index 18dc73ea4..615ab871e 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 -// Layer: 184 -// SHA256: a37868b9861499415a8c27ae47e42b3cd96eb175bd49a91f272e43dd57261c51 +// Layer: 185 +// SHA256: c488cd16de64bea5e744d4a0954cfdec14947c71bcf21084f281bf062b23a173 boolFalse#bc799737 = Bool; @@ -141,7 +141,7 @@ storage.fileWebp#1081464c = storage.FileType; userEmpty#d3bc4b7a id:long = User; -user#215c4438 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 contact_require_premium:flags2.10?true bot_business:flags2.11?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.8?PeerColor profile_color:flags2.9?PeerColor = User; +user#83314fca 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 contact_require_premium:flags2.10?true bot_business:flags2.11?true bot_has_main_app:flags2.13?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.8?PeerColor profile_color:flags2.9?PeerColor bot_active_users:flags2.12?int = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; @@ -315,6 +315,8 @@ messageActionRequestedPeerSentMe#93b31848 button_id:int peers:Vector menu_button:flags.3?BotMenuButton = BotInfo; +botInfo#8f300b57 flags:# has_preview_medias:flags.6?true user_id:flags.0?long description:flags.1?string description_photo:flags.4?Photo description_document:flags.5?Document commands:flags.2?Vector menu_button:flags.3?BotMenuButton = BotInfo; keyboardButton#a2fa4880 text:string = KeyboardButton; @@ -1317,6 +1319,8 @@ topPeerCategoryForwardUsers#a8406ca9 = TopPeerCategory; topPeerCategoryForwardChats#fbeec0f0 = TopPeerCategory; +topPeerCategoryBotsApp#fd9e7bec = TopPeerCategory; + topPeerCategoryPeers#fb834291 category:TopPeerCategory count:int peers:Vector = TopPeerCategoryPeers; contacts.topPeersNotModified#de266ef5 = contacts.TopPeers; @@ -2211,7 +2215,7 @@ inputInvoiceSlug#c326caef slug:string = InputInvoice; inputInvoicePremiumGiftCode#98986c0d purpose:InputStorePaymentPurpose option:PremiumGiftCodeOption = InputInvoice; -inputInvoiceStars#1da33ad8 option:StarsTopupOption = InputInvoice; +inputInvoiceStars#65f00ce3 purpose:InputStorePaymentPurpose = InputInvoice; payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice; @@ -2227,7 +2231,9 @@ inputStorePaymentPremiumGiftCode#a3805f3f flags:# users:Vector boost_ inputStorePaymentPremiumGiveaway#160544ca flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.3?true boost_peer:InputPeer additional_peers:flags.1?Vector countries_iso2:flags.2?Vector prize_description:flags.4?string random_id:long until_date:int currency:string amount:long = InputStorePaymentPurpose; -inputStorePaymentStars#4f0ee8df flags:# stars:long currency:string amount:long = InputStorePaymentPurpose; +inputStorePaymentStarsTopup#dddd0f56 stars:long currency:string amount:long = InputStorePaymentPurpose; + +inputStorePaymentStarsGift#1d741ef7 user_id:InputUser stars:long currency:string amount:long = InputStorePaymentPurpose; premiumGiftOption#74c34319 flags:# months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumGiftOption; @@ -2415,6 +2421,8 @@ inputMediaAreaChannelPost#2271f2bf coordinates:MediaAreaCoordinates channel:Inpu mediaAreaUrl#37381085 coordinates:MediaAreaCoordinates url:string = MediaArea; +mediaAreaWeather#49a6549c coordinates:MediaAreaCoordinates emoji:string temperature_c:double color:int = MediaArea; + peerStories#9a35e999 flags:# peer:Peer max_read_id:flags.0?int stories:Vector = PeerStories; stories.peerStories#cae68768 stories:PeerStories chats:Vector users:Vector = stories.PeerStories; @@ -2637,7 +2645,7 @@ starsTransactionPeerAds#60682812 = StarsTransactionPeer; starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; -starsTransaction#2db5418f flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector = StarsTransaction; +starsTransaction#2db5418f flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector = StarsTransaction; payments.starsStatus#8cf4ee60 flags:# balance:long history:Vector next_offset:flags.0?string chats:Vector users:Vector = payments.StarsStatus; @@ -2657,6 +2665,14 @@ payments.starsRevenueAdsAccountUrl#394e7f21 url:string = payments.StarsRevenueAd inputStarsTransaction#206ae6d1 flags:# refund:flags.0?true id:string = InputStarsTransaction; +starsGiftOption#5e0589f1 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsGiftOption; + +bots.popularAppBots#1991b13b flags:# next_offset:flags.0?string users:Vector = bots.PopularAppBots; + +botPreviewMedia#23e91ba3 date:int media:MessageMedia = BotPreviewMedia; + +bots.previewInfo#ca71d64 media:Vector lang_codes:Vector = bots.PreviewInfo; + ---functions--- @@ -2980,7 +2996,7 @@ contacts.search#11f812d8 q:string limit:int = contacts.Found; contacts.resolveUsername#f93ccba3 username:string = contacts.ResolvedPeer; -contacts.getTopPeers#973478b6 flags:# correspondents:flags.0?true bots_pm:flags.1?true bots_inline:flags.2?true phone_calls:flags.3?true forward_users:flags.4?true forward_chats:flags.5?true groups:flags.10?true channels:flags.15?true offset:int limit:int hash:long = contacts.TopPeers; +contacts.getTopPeers#973478b6 flags:# correspondents:flags.0?true bots_pm:flags.1?true bots_inline:flags.2?true phone_calls:flags.3?true forward_users:flags.4?true forward_chats:flags.5?true groups:flags.10?true channels:flags.15?true bots_app:flags.16?true offset:int limit:int hash:long = contacts.TopPeers; contacts.resetTopPeerRating#1ae373ac category:TopPeerCategory peer:InputPeer = Bool; @@ -3436,6 +3452,8 @@ messages.deleteFactCheck#d1da940c peer:InputPeer msg_id:int = Updates; messages.getFactCheck#b9cdc5ee peer:InputPeer msg_id:Vector = Vector; +messages.requestMainWebView#c9e01e7b flags:# compact:flags.7?true peer:InputPeer bot:InputUser start_param:flags.1?string theme_params:flags.0?DataJSON platform:string = WebViewResult; + updates.getState#edd4882a = updates.State; updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference; @@ -3680,6 +3698,20 @@ bots.allowSendMessage#f132e3ef bot:InputUser = Updates; bots.invokeWebViewCustomMethod#87fc5e7 bot:InputUser custom_method:string params:DataJSON = DataJSON; +bots.getPopularAppBots#c2510192 offset:string limit:int = bots.PopularAppBots; + +bots.addPreviewMedia#17aeb75a bot:InputUser lang_code:string media:InputMedia = BotPreviewMedia; + +bots.editPreviewMedia#8525606f bot:InputUser lang_code:string media:InputMedia new_media:InputMedia = BotPreviewMedia; + +bots.deletePreviewMedia#2d0135b3 bot:InputUser lang_code:string media:Vector = Bool; + +bots.reorderPreviewMedias#b627f3aa bot:InputUser lang_code:string order:Vector = Bool; + +bots.getPreviewInfo#423ab3ad bot:InputUser lang_code:string = bots.PreviewInfo; + +bots.getPreviewMedias#a2a5594d bot:InputUser = Vector; + payments.getPaymentForm#37148dbb flags:# invoice:InputInvoice theme_params:flags.0?DataJSON = payments.PaymentForm; payments.getPaymentReceipt#2478d1cc peer:InputPeer msg_id:int = payments.PaymentReceipt; @@ -3730,6 +3762,8 @@ payments.getStarsRevenueAdsAccountUrl#d1d7efc5 peer:InputPeer = payments.StarsRe payments.getStarsTransactionsByID#27842d2e peer:InputPeer id:Vector = payments.StarsStatus; +payments.getStarsGiftOptions#d3c96bc8 flags:# user_id:flags.0?InputUser = Vector; + stickers.createStickerSet#9021ab67 flags:# masks:flags.0?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; @@ -3978,4 +4012,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 184 +// LAYER 185 diff --git a/tg/tl_bot_info_gen.go b/tg/tl_bot_info_gen.go index bbccb9f7f..4d8666ea9 100644 --- a/tg/tl_bot_info_gen.go +++ b/tg/tl_bot_info_gen.go @@ -41,6 +41,8 @@ type BotInfo struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields + // HasPreviewMedias field of BotInfo. + HasPreviewMedias bool // ID of the bot // // Use SetUserID and GetUserID helpers. @@ -85,6 +87,9 @@ func (b *BotInfo) Zero() bool { if !(b.Flags.Zero()) { return false } + if !(b.HasPreviewMedias == false) { + return false + } if !(b.UserID == 0) { return false } @@ -118,6 +123,7 @@ func (b *BotInfo) String() string { // FillFrom fills BotInfo from given interface. func (b *BotInfo) FillFrom(from interface { + GetHasPreviewMedias() (value bool) GetUserID() (value int64, ok bool) GetDescription() (value string, ok bool) GetDescriptionPhoto() (value PhotoClass, ok bool) @@ -125,6 +131,7 @@ func (b *BotInfo) FillFrom(from interface { GetCommands() (value []BotCommand, ok bool) GetMenuButton() (value BotMenuButtonClass, ok bool) }) { + b.HasPreviewMedias = from.GetHasPreviewMedias() if val, ok := from.GetUserID(); ok { b.UserID = val } @@ -174,6 +181,11 @@ func (b *BotInfo) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "HasPreviewMedias", + SchemaName: "has_preview_medias", + Null: !b.Flags.Has(6), + }, { Name: "UserID", SchemaName: "user_id", @@ -210,6 +222,9 @@ func (b *BotInfo) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (b *BotInfo) SetFlags() { + if !(b.HasPreviewMedias == false) { + b.Flags.Set(6) + } if !(b.UserID == 0) { b.Flags.Set(0) } @@ -310,6 +325,7 @@ func (b *BotInfo) DecodeBare(buf *bin.Buffer) error { return fmt.Errorf("unable to decode botInfo#8f300b57: field flags: %w", err) } } + b.HasPreviewMedias = b.Flags.Has(6) if b.Flags.Has(0) { value, err := buf.Long() if err != nil { @@ -365,6 +381,25 @@ func (b *BotInfo) DecodeBare(buf *bin.Buffer) error { return nil } +// SetHasPreviewMedias sets value of HasPreviewMedias conditional field. +func (b *BotInfo) SetHasPreviewMedias(value bool) { + if value { + b.Flags.Set(6) + b.HasPreviewMedias = true + } else { + b.Flags.Unset(6) + b.HasPreviewMedias = false + } +} + +// GetHasPreviewMedias returns value of HasPreviewMedias conditional field. +func (b *BotInfo) GetHasPreviewMedias() (value bool) { + if b == nil { + return + } + return b.Flags.Has(6) +} + // SetUserID sets value of UserID conditional field. func (b *BotInfo) SetUserID(value int64) { b.Flags.Set(0) diff --git a/tg/tl_bot_preview_media_gen.go b/tg/tl_bot_preview_media_gen.go new file mode 100644 index 000000000..83ffc9bf8 --- /dev/null +++ b/tg/tl_bot_preview_media_gen.go @@ -0,0 +1,193 @@ +// 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{} +) + +// BotPreviewMedia represents TL type `botPreviewMedia#23e91ba3`. +// +// See https://core.telegram.org/constructor/botPreviewMedia for reference. +type BotPreviewMedia struct { + // Date field of BotPreviewMedia. + Date int + // Media field of BotPreviewMedia. + Media MessageMediaClass +} + +// BotPreviewMediaTypeID is TL type id of BotPreviewMedia. +const BotPreviewMediaTypeID = 0x23e91ba3 + +// Ensuring interfaces in compile-time for BotPreviewMedia. +var ( + _ bin.Encoder = &BotPreviewMedia{} + _ bin.Decoder = &BotPreviewMedia{} + _ bin.BareEncoder = &BotPreviewMedia{} + _ bin.BareDecoder = &BotPreviewMedia{} +) + +func (b *BotPreviewMedia) Zero() bool { + if b == nil { + return true + } + if !(b.Date == 0) { + return false + } + if !(b.Media == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (b *BotPreviewMedia) String() string { + if b == nil { + return "BotPreviewMedia(nil)" + } + type Alias BotPreviewMedia + return fmt.Sprintf("BotPreviewMedia%+v", Alias(*b)) +} + +// FillFrom fills BotPreviewMedia from given interface. +func (b *BotPreviewMedia) FillFrom(from interface { + GetDate() (value int) + GetMedia() (value MessageMediaClass) +}) { + b.Date = from.GetDate() + b.Media = from.GetMedia() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotPreviewMedia) TypeID() uint32 { + return BotPreviewMediaTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotPreviewMedia) TypeName() string { + return "botPreviewMedia" +} + +// TypeInfo returns info about TL type. +func (b *BotPreviewMedia) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "botPreviewMedia", + ID: BotPreviewMediaTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Date", + SchemaName: "date", + }, + { + Name: "Media", + SchemaName: "media", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (b *BotPreviewMedia) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode botPreviewMedia#23e91ba3 as nil") + } + buf.PutID(BotPreviewMediaTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *BotPreviewMedia) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode botPreviewMedia#23e91ba3 as nil") + } + buf.PutInt(b.Date) + if b.Media == nil { + return fmt.Errorf("unable to encode botPreviewMedia#23e91ba3: field media is nil") + } + if err := b.Media.Encode(buf); err != nil { + return fmt.Errorf("unable to encode botPreviewMedia#23e91ba3: field media: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (b *BotPreviewMedia) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode botPreviewMedia#23e91ba3 to nil") + } + if err := buf.ConsumeID(BotPreviewMediaTypeID); err != nil { + return fmt.Errorf("unable to decode botPreviewMedia#23e91ba3: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *BotPreviewMedia) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode botPreviewMedia#23e91ba3 to nil") + } + { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode botPreviewMedia#23e91ba3: field date: %w", err) + } + b.Date = value + } + { + value, err := DecodeMessageMedia(buf) + if err != nil { + return fmt.Errorf("unable to decode botPreviewMedia#23e91ba3: field media: %w", err) + } + b.Media = value + } + return nil +} + +// GetDate returns value of Date field. +func (b *BotPreviewMedia) GetDate() (value int) { + if b == nil { + return + } + return b.Date +} + +// GetMedia returns value of Media field. +func (b *BotPreviewMedia) GetMedia() (value MessageMediaClass) { + if b == nil { + return + } + return b.Media +} diff --git a/tg/tl_bot_preview_media_slices_gen.go b/tg/tl_bot_preview_media_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_bot_preview_media_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_bot_preview_media_vector_gen.go b/tg/tl_bot_preview_media_vector_gen.go new file mode 100644 index 000000000..884d28cca --- /dev/null +++ b/tg/tl_bot_preview_media_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{} +) + +// BotPreviewMediaVector is a box for Vector +type BotPreviewMediaVector struct { + // Elements of Vector + Elems []BotPreviewMedia +} + +// BotPreviewMediaVectorTypeID is TL type id of BotPreviewMediaVector. +const BotPreviewMediaVectorTypeID = bin.TypeVector + +// Ensuring interfaces in compile-time for BotPreviewMediaVector. +var ( + _ bin.Encoder = &BotPreviewMediaVector{} + _ bin.Decoder = &BotPreviewMediaVector{} + _ bin.BareEncoder = &BotPreviewMediaVector{} + _ bin.BareDecoder = &BotPreviewMediaVector{} +) + +func (vec *BotPreviewMediaVector) Zero() bool { + if vec == nil { + return true + } + if !(vec.Elems == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (vec *BotPreviewMediaVector) String() string { + if vec == nil { + return "BotPreviewMediaVector(nil)" + } + type Alias BotPreviewMediaVector + return fmt.Sprintf("BotPreviewMediaVector%+v", Alias(*vec)) +} + +// FillFrom fills BotPreviewMediaVector from given interface. +func (vec *BotPreviewMediaVector) FillFrom(from interface { + GetElems() (value []BotPreviewMedia) +}) { + vec.Elems = from.GetElems() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotPreviewMediaVector) TypeID() uint32 { + return BotPreviewMediaVectorTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotPreviewMediaVector) TypeName() string { + return "" +} + +// TypeInfo returns info about TL type. +func (vec *BotPreviewMediaVector) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "", + ID: BotPreviewMediaVectorTypeID, + } + if vec == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Elems", + SchemaName: "Elems", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (vec *BotPreviewMediaVector) 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 *BotPreviewMediaVector) 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 *BotPreviewMediaVector) 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 *BotPreviewMediaVector) 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([]BotPreviewMedia, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value BotPreviewMedia + 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 *BotPreviewMediaVector) GetElems() (value []BotPreviewMedia) { + if vec == nil { + return + } + return vec.Elems +} diff --git a/tg/tl_bot_preview_media_vector_slices_gen.go b/tg/tl_bot_preview_media_vector_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_bot_preview_media_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_bots_add_preview_media_gen.go b/tg/tl_bots_add_preview_media_gen.go new file mode 100644 index 000000000..c4b75f56d --- /dev/null +++ b/tg/tl_bots_add_preview_media_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{} +) + +// BotsAddPreviewMediaRequest represents TL type `bots.addPreviewMedia#17aeb75a`. +// +// See https://core.telegram.org/method/bots.addPreviewMedia for reference. +type BotsAddPreviewMediaRequest struct { + // Bot field of BotsAddPreviewMediaRequest. + Bot InputUserClass + // LangCode field of BotsAddPreviewMediaRequest. + LangCode string + // Media field of BotsAddPreviewMediaRequest. + Media InputMediaClass +} + +// BotsAddPreviewMediaRequestTypeID is TL type id of BotsAddPreviewMediaRequest. +const BotsAddPreviewMediaRequestTypeID = 0x17aeb75a + +// Ensuring interfaces in compile-time for BotsAddPreviewMediaRequest. +var ( + _ bin.Encoder = &BotsAddPreviewMediaRequest{} + _ bin.Decoder = &BotsAddPreviewMediaRequest{} + _ bin.BareEncoder = &BotsAddPreviewMediaRequest{} + _ bin.BareDecoder = &BotsAddPreviewMediaRequest{} +) + +func (a *BotsAddPreviewMediaRequest) Zero() bool { + if a == nil { + return true + } + if !(a.Bot == nil) { + return false + } + if !(a.LangCode == "") { + return false + } + if !(a.Media == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *BotsAddPreviewMediaRequest) String() string { + if a == nil { + return "BotsAddPreviewMediaRequest(nil)" + } + type Alias BotsAddPreviewMediaRequest + return fmt.Sprintf("BotsAddPreviewMediaRequest%+v", Alias(*a)) +} + +// FillFrom fills BotsAddPreviewMediaRequest from given interface. +func (a *BotsAddPreviewMediaRequest) FillFrom(from interface { + GetBot() (value InputUserClass) + GetLangCode() (value string) + GetMedia() (value InputMediaClass) +}) { + a.Bot = from.GetBot() + a.LangCode = from.GetLangCode() + a.Media = from.GetMedia() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsAddPreviewMediaRequest) TypeID() uint32 { + return BotsAddPreviewMediaRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsAddPreviewMediaRequest) TypeName() string { + return "bots.addPreviewMedia" +} + +// TypeInfo returns info about TL type. +func (a *BotsAddPreviewMediaRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.addPreviewMedia", + ID: BotsAddPreviewMediaRequestTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Bot", + SchemaName: "bot", + }, + { + Name: "LangCode", + SchemaName: "lang_code", + }, + { + Name: "Media", + SchemaName: "media", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (a *BotsAddPreviewMediaRequest) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode bots.addPreviewMedia#17aeb75a as nil") + } + b.PutID(BotsAddPreviewMediaRequestTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *BotsAddPreviewMediaRequest) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode bots.addPreviewMedia#17aeb75a as nil") + } + if a.Bot == nil { + return fmt.Errorf("unable to encode bots.addPreviewMedia#17aeb75a: field bot is nil") + } + if err := a.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.addPreviewMedia#17aeb75a: field bot: %w", err) + } + b.PutString(a.LangCode) + if a.Media == nil { + return fmt.Errorf("unable to encode bots.addPreviewMedia#17aeb75a: field media is nil") + } + if err := a.Media.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.addPreviewMedia#17aeb75a: field media: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (a *BotsAddPreviewMediaRequest) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode bots.addPreviewMedia#17aeb75a to nil") + } + if err := b.ConsumeID(BotsAddPreviewMediaRequestTypeID); err != nil { + return fmt.Errorf("unable to decode bots.addPreviewMedia#17aeb75a: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *BotsAddPreviewMediaRequest) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode bots.addPreviewMedia#17aeb75a to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode bots.addPreviewMedia#17aeb75a: field bot: %w", err) + } + a.Bot = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode bots.addPreviewMedia#17aeb75a: field lang_code: %w", err) + } + a.LangCode = value + } + { + value, err := DecodeInputMedia(b) + if err != nil { + return fmt.Errorf("unable to decode bots.addPreviewMedia#17aeb75a: field media: %w", err) + } + a.Media = value + } + return nil +} + +// GetBot returns value of Bot field. +func (a *BotsAddPreviewMediaRequest) GetBot() (value InputUserClass) { + if a == nil { + return + } + return a.Bot +} + +// GetLangCode returns value of LangCode field. +func (a *BotsAddPreviewMediaRequest) GetLangCode() (value string) { + if a == nil { + return + } + return a.LangCode +} + +// GetMedia returns value of Media field. +func (a *BotsAddPreviewMediaRequest) GetMedia() (value InputMediaClass) { + if a == nil { + return + } + return a.Media +} + +// BotsAddPreviewMedia invokes method bots.addPreviewMedia#17aeb75a returning error if any. +// +// See https://core.telegram.org/method/bots.addPreviewMedia for reference. +func (c *Client) BotsAddPreviewMedia(ctx context.Context, request *BotsAddPreviewMediaRequest) (*BotPreviewMedia, error) { + var result BotPreviewMedia + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_bots_add_preview_media_slices_gen.go b/tg/tl_bots_add_preview_media_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_bots_add_preview_media_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_bots_delete_preview_media_gen.go b/tg/tl_bots_delete_preview_media_gen.go new file mode 100644 index 000000000..7a453d3d0 --- /dev/null +++ b/tg/tl_bots_delete_preview_media_gen.go @@ -0,0 +1,256 @@ +// 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{} +) + +// BotsDeletePreviewMediaRequest represents TL type `bots.deletePreviewMedia#2d0135b3`. +// +// See https://core.telegram.org/method/bots.deletePreviewMedia for reference. +type BotsDeletePreviewMediaRequest struct { + // Bot field of BotsDeletePreviewMediaRequest. + Bot InputUserClass + // LangCode field of BotsDeletePreviewMediaRequest. + LangCode string + // Media field of BotsDeletePreviewMediaRequest. + Media []InputMediaClass +} + +// BotsDeletePreviewMediaRequestTypeID is TL type id of BotsDeletePreviewMediaRequest. +const BotsDeletePreviewMediaRequestTypeID = 0x2d0135b3 + +// Ensuring interfaces in compile-time for BotsDeletePreviewMediaRequest. +var ( + _ bin.Encoder = &BotsDeletePreviewMediaRequest{} + _ bin.Decoder = &BotsDeletePreviewMediaRequest{} + _ bin.BareEncoder = &BotsDeletePreviewMediaRequest{} + _ bin.BareDecoder = &BotsDeletePreviewMediaRequest{} +) + +func (d *BotsDeletePreviewMediaRequest) Zero() bool { + if d == nil { + return true + } + if !(d.Bot == nil) { + return false + } + if !(d.LangCode == "") { + return false + } + if !(d.Media == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (d *BotsDeletePreviewMediaRequest) String() string { + if d == nil { + return "BotsDeletePreviewMediaRequest(nil)" + } + type Alias BotsDeletePreviewMediaRequest + return fmt.Sprintf("BotsDeletePreviewMediaRequest%+v", Alias(*d)) +} + +// FillFrom fills BotsDeletePreviewMediaRequest from given interface. +func (d *BotsDeletePreviewMediaRequest) FillFrom(from interface { + GetBot() (value InputUserClass) + GetLangCode() (value string) + GetMedia() (value []InputMediaClass) +}) { + d.Bot = from.GetBot() + d.LangCode = from.GetLangCode() + d.Media = from.GetMedia() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsDeletePreviewMediaRequest) TypeID() uint32 { + return BotsDeletePreviewMediaRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsDeletePreviewMediaRequest) TypeName() string { + return "bots.deletePreviewMedia" +} + +// TypeInfo returns info about TL type. +func (d *BotsDeletePreviewMediaRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.deletePreviewMedia", + ID: BotsDeletePreviewMediaRequestTypeID, + } + if d == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Bot", + SchemaName: "bot", + }, + { + Name: "LangCode", + SchemaName: "lang_code", + }, + { + Name: "Media", + SchemaName: "media", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (d *BotsDeletePreviewMediaRequest) Encode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode bots.deletePreviewMedia#2d0135b3 as nil") + } + b.PutID(BotsDeletePreviewMediaRequestTypeID) + return d.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (d *BotsDeletePreviewMediaRequest) EncodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode bots.deletePreviewMedia#2d0135b3 as nil") + } + if d.Bot == nil { + return fmt.Errorf("unable to encode bots.deletePreviewMedia#2d0135b3: field bot is nil") + } + if err := d.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.deletePreviewMedia#2d0135b3: field bot: %w", err) + } + b.PutString(d.LangCode) + b.PutVectorHeader(len(d.Media)) + for idx, v := range d.Media { + if v == nil { + return fmt.Errorf("unable to encode bots.deletePreviewMedia#2d0135b3: field media element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.deletePreviewMedia#2d0135b3: field media element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (d *BotsDeletePreviewMediaRequest) Decode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode bots.deletePreviewMedia#2d0135b3 to nil") + } + if err := b.ConsumeID(BotsDeletePreviewMediaRequestTypeID); err != nil { + return fmt.Errorf("unable to decode bots.deletePreviewMedia#2d0135b3: %w", err) + } + return d.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (d *BotsDeletePreviewMediaRequest) DecodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode bots.deletePreviewMedia#2d0135b3 to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode bots.deletePreviewMedia#2d0135b3: field bot: %w", err) + } + d.Bot = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode bots.deletePreviewMedia#2d0135b3: field lang_code: %w", err) + } + d.LangCode = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode bots.deletePreviewMedia#2d0135b3: field media: %w", err) + } + + if headerLen > 0 { + d.Media = make([]InputMediaClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeInputMedia(b) + if err != nil { + return fmt.Errorf("unable to decode bots.deletePreviewMedia#2d0135b3: field media: %w", err) + } + d.Media = append(d.Media, value) + } + } + return nil +} + +// GetBot returns value of Bot field. +func (d *BotsDeletePreviewMediaRequest) GetBot() (value InputUserClass) { + if d == nil { + return + } + return d.Bot +} + +// GetLangCode returns value of LangCode field. +func (d *BotsDeletePreviewMediaRequest) GetLangCode() (value string) { + if d == nil { + return + } + return d.LangCode +} + +// GetMedia returns value of Media field. +func (d *BotsDeletePreviewMediaRequest) GetMedia() (value []InputMediaClass) { + if d == nil { + return + } + return d.Media +} + +// MapMedia returns field Media wrapped in InputMediaClassArray helper. +func (d *BotsDeletePreviewMediaRequest) MapMedia() (value InputMediaClassArray) { + return InputMediaClassArray(d.Media) +} + +// BotsDeletePreviewMedia invokes method bots.deletePreviewMedia#2d0135b3 returning error if any. +// +// See https://core.telegram.org/method/bots.deletePreviewMedia for reference. +func (c *Client) BotsDeletePreviewMedia(ctx context.Context, request *BotsDeletePreviewMediaRequest) (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_bots_delete_preview_media_slices_gen.go b/tg/tl_bots_delete_preview_media_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_bots_delete_preview_media_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_bots_edit_preview_media_gen.go b/tg/tl_bots_edit_preview_media_gen.go new file mode 100644 index 000000000..21c00cb77 --- /dev/null +++ b/tg/tl_bots_edit_preview_media_gen.go @@ -0,0 +1,269 @@ +// 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{} +) + +// BotsEditPreviewMediaRequest represents TL type `bots.editPreviewMedia#8525606f`. +// +// See https://core.telegram.org/method/bots.editPreviewMedia for reference. +type BotsEditPreviewMediaRequest struct { + // Bot field of BotsEditPreviewMediaRequest. + Bot InputUserClass + // LangCode field of BotsEditPreviewMediaRequest. + LangCode string + // Media field of BotsEditPreviewMediaRequest. + Media InputMediaClass + // NewMedia field of BotsEditPreviewMediaRequest. + NewMedia InputMediaClass +} + +// BotsEditPreviewMediaRequestTypeID is TL type id of BotsEditPreviewMediaRequest. +const BotsEditPreviewMediaRequestTypeID = 0x8525606f + +// Ensuring interfaces in compile-time for BotsEditPreviewMediaRequest. +var ( + _ bin.Encoder = &BotsEditPreviewMediaRequest{} + _ bin.Decoder = &BotsEditPreviewMediaRequest{} + _ bin.BareEncoder = &BotsEditPreviewMediaRequest{} + _ bin.BareDecoder = &BotsEditPreviewMediaRequest{} +) + +func (e *BotsEditPreviewMediaRequest) Zero() bool { + if e == nil { + return true + } + if !(e.Bot == nil) { + return false + } + if !(e.LangCode == "") { + return false + } + if !(e.Media == nil) { + return false + } + if !(e.NewMedia == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *BotsEditPreviewMediaRequest) String() string { + if e == nil { + return "BotsEditPreviewMediaRequest(nil)" + } + type Alias BotsEditPreviewMediaRequest + return fmt.Sprintf("BotsEditPreviewMediaRequest%+v", Alias(*e)) +} + +// FillFrom fills BotsEditPreviewMediaRequest from given interface. +func (e *BotsEditPreviewMediaRequest) FillFrom(from interface { + GetBot() (value InputUserClass) + GetLangCode() (value string) + GetMedia() (value InputMediaClass) + GetNewMedia() (value InputMediaClass) +}) { + e.Bot = from.GetBot() + e.LangCode = from.GetLangCode() + e.Media = from.GetMedia() + e.NewMedia = from.GetNewMedia() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsEditPreviewMediaRequest) TypeID() uint32 { + return BotsEditPreviewMediaRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsEditPreviewMediaRequest) TypeName() string { + return "bots.editPreviewMedia" +} + +// TypeInfo returns info about TL type. +func (e *BotsEditPreviewMediaRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.editPreviewMedia", + ID: BotsEditPreviewMediaRequestTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Bot", + SchemaName: "bot", + }, + { + Name: "LangCode", + SchemaName: "lang_code", + }, + { + Name: "Media", + SchemaName: "media", + }, + { + Name: "NewMedia", + SchemaName: "new_media", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (e *BotsEditPreviewMediaRequest) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode bots.editPreviewMedia#8525606f as nil") + } + b.PutID(BotsEditPreviewMediaRequestTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *BotsEditPreviewMediaRequest) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode bots.editPreviewMedia#8525606f as nil") + } + if e.Bot == nil { + return fmt.Errorf("unable to encode bots.editPreviewMedia#8525606f: field bot is nil") + } + if err := e.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.editPreviewMedia#8525606f: field bot: %w", err) + } + b.PutString(e.LangCode) + if e.Media == nil { + return fmt.Errorf("unable to encode bots.editPreviewMedia#8525606f: field media is nil") + } + if err := e.Media.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.editPreviewMedia#8525606f: field media: %w", err) + } + if e.NewMedia == nil { + return fmt.Errorf("unable to encode bots.editPreviewMedia#8525606f: field new_media is nil") + } + if err := e.NewMedia.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.editPreviewMedia#8525606f: field new_media: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (e *BotsEditPreviewMediaRequest) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode bots.editPreviewMedia#8525606f to nil") + } + if err := b.ConsumeID(BotsEditPreviewMediaRequestTypeID); err != nil { + return fmt.Errorf("unable to decode bots.editPreviewMedia#8525606f: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *BotsEditPreviewMediaRequest) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode bots.editPreviewMedia#8525606f to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode bots.editPreviewMedia#8525606f: field bot: %w", err) + } + e.Bot = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode bots.editPreviewMedia#8525606f: field lang_code: %w", err) + } + e.LangCode = value + } + { + value, err := DecodeInputMedia(b) + if err != nil { + return fmt.Errorf("unable to decode bots.editPreviewMedia#8525606f: field media: %w", err) + } + e.Media = value + } + { + value, err := DecodeInputMedia(b) + if err != nil { + return fmt.Errorf("unable to decode bots.editPreviewMedia#8525606f: field new_media: %w", err) + } + e.NewMedia = value + } + return nil +} + +// GetBot returns value of Bot field. +func (e *BotsEditPreviewMediaRequest) GetBot() (value InputUserClass) { + if e == nil { + return + } + return e.Bot +} + +// GetLangCode returns value of LangCode field. +func (e *BotsEditPreviewMediaRequest) GetLangCode() (value string) { + if e == nil { + return + } + return e.LangCode +} + +// GetMedia returns value of Media field. +func (e *BotsEditPreviewMediaRequest) GetMedia() (value InputMediaClass) { + if e == nil { + return + } + return e.Media +} + +// GetNewMedia returns value of NewMedia field. +func (e *BotsEditPreviewMediaRequest) GetNewMedia() (value InputMediaClass) { + if e == nil { + return + } + return e.NewMedia +} + +// BotsEditPreviewMedia invokes method bots.editPreviewMedia#8525606f returning error if any. +// +// See https://core.telegram.org/method/bots.editPreviewMedia for reference. +func (c *Client) BotsEditPreviewMedia(ctx context.Context, request *BotsEditPreviewMediaRequest) (*BotPreviewMedia, error) { + var result BotPreviewMedia + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_bots_edit_preview_media_slices_gen.go b/tg/tl_bots_edit_preview_media_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_bots_edit_preview_media_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_bots_get_popular_app_bots_gen.go b/tg/tl_bots_get_popular_app_bots_gen.go new file mode 100644 index 000000000..9a00a5d1d --- /dev/null +++ b/tg/tl_bots_get_popular_app_bots_gen.go @@ -0,0 +1,200 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// BotsGetPopularAppBotsRequest represents TL type `bots.getPopularAppBots#c2510192`. +// +// See https://core.telegram.org/method/bots.getPopularAppBots for reference. +type BotsGetPopularAppBotsRequest struct { + // Offset field of BotsGetPopularAppBotsRequest. + Offset string + // Limit field of BotsGetPopularAppBotsRequest. + Limit int +} + +// BotsGetPopularAppBotsRequestTypeID is TL type id of BotsGetPopularAppBotsRequest. +const BotsGetPopularAppBotsRequestTypeID = 0xc2510192 + +// Ensuring interfaces in compile-time for BotsGetPopularAppBotsRequest. +var ( + _ bin.Encoder = &BotsGetPopularAppBotsRequest{} + _ bin.Decoder = &BotsGetPopularAppBotsRequest{} + _ bin.BareEncoder = &BotsGetPopularAppBotsRequest{} + _ bin.BareDecoder = &BotsGetPopularAppBotsRequest{} +) + +func (g *BotsGetPopularAppBotsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Offset == "") { + return false + } + if !(g.Limit == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *BotsGetPopularAppBotsRequest) String() string { + if g == nil { + return "BotsGetPopularAppBotsRequest(nil)" + } + type Alias BotsGetPopularAppBotsRequest + return fmt.Sprintf("BotsGetPopularAppBotsRequest%+v", Alias(*g)) +} + +// FillFrom fills BotsGetPopularAppBotsRequest from given interface. +func (g *BotsGetPopularAppBotsRequest) FillFrom(from interface { + GetOffset() (value string) + GetLimit() (value int) +}) { + 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 (*BotsGetPopularAppBotsRequest) TypeID() uint32 { + return BotsGetPopularAppBotsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsGetPopularAppBotsRequest) TypeName() string { + return "bots.getPopularAppBots" +} + +// TypeInfo returns info about TL type. +func (g *BotsGetPopularAppBotsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.getPopularAppBots", + ID: BotsGetPopularAppBotsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Offset", + SchemaName: "offset", + }, + { + Name: "Limit", + SchemaName: "limit", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *BotsGetPopularAppBotsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode bots.getPopularAppBots#c2510192 as nil") + } + b.PutID(BotsGetPopularAppBotsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *BotsGetPopularAppBotsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode bots.getPopularAppBots#c2510192 as nil") + } + b.PutString(g.Offset) + b.PutInt(g.Limit) + return nil +} + +// Decode implements bin.Decoder. +func (g *BotsGetPopularAppBotsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode bots.getPopularAppBots#c2510192 to nil") + } + if err := b.ConsumeID(BotsGetPopularAppBotsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode bots.getPopularAppBots#c2510192: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *BotsGetPopularAppBotsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode bots.getPopularAppBots#c2510192 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode bots.getPopularAppBots#c2510192: field offset: %w", err) + } + g.Offset = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode bots.getPopularAppBots#c2510192: field limit: %w", err) + } + g.Limit = value + } + return nil +} + +// GetOffset returns value of Offset field. +func (g *BotsGetPopularAppBotsRequest) GetOffset() (value string) { + if g == nil { + return + } + return g.Offset +} + +// GetLimit returns value of Limit field. +func (g *BotsGetPopularAppBotsRequest) GetLimit() (value int) { + if g == nil { + return + } + return g.Limit +} + +// BotsGetPopularAppBots invokes method bots.getPopularAppBots#c2510192 returning error if any. +// +// See https://core.telegram.org/method/bots.getPopularAppBots for reference. +func (c *Client) BotsGetPopularAppBots(ctx context.Context, request *BotsGetPopularAppBotsRequest) (*BotsPopularAppBots, error) { + var result BotsPopularAppBots + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_bots_get_popular_app_bots_slices_gen.go b/tg/tl_bots_get_popular_app_bots_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_bots_get_popular_app_bots_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_bots_get_preview_info_gen.go b/tg/tl_bots_get_preview_info_gen.go new file mode 100644 index 000000000..4408ce3bb --- /dev/null +++ b/tg/tl_bots_get_preview_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{} +) + +// BotsGetPreviewInfoRequest represents TL type `bots.getPreviewInfo#423ab3ad`. +// +// See https://core.telegram.org/method/bots.getPreviewInfo for reference. +type BotsGetPreviewInfoRequest struct { + // Bot field of BotsGetPreviewInfoRequest. + Bot InputUserClass + // LangCode field of BotsGetPreviewInfoRequest. + LangCode string +} + +// BotsGetPreviewInfoRequestTypeID is TL type id of BotsGetPreviewInfoRequest. +const BotsGetPreviewInfoRequestTypeID = 0x423ab3ad + +// Ensuring interfaces in compile-time for BotsGetPreviewInfoRequest. +var ( + _ bin.Encoder = &BotsGetPreviewInfoRequest{} + _ bin.Decoder = &BotsGetPreviewInfoRequest{} + _ bin.BareEncoder = &BotsGetPreviewInfoRequest{} + _ bin.BareDecoder = &BotsGetPreviewInfoRequest{} +) + +func (g *BotsGetPreviewInfoRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Bot == nil) { + return false + } + if !(g.LangCode == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *BotsGetPreviewInfoRequest) String() string { + if g == nil { + return "BotsGetPreviewInfoRequest(nil)" + } + type Alias BotsGetPreviewInfoRequest + return fmt.Sprintf("BotsGetPreviewInfoRequest%+v", Alias(*g)) +} + +// FillFrom fills BotsGetPreviewInfoRequest from given interface. +func (g *BotsGetPreviewInfoRequest) FillFrom(from interface { + GetBot() (value InputUserClass) + GetLangCode() (value string) +}) { + g.Bot = from.GetBot() + g.LangCode = from.GetLangCode() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsGetPreviewInfoRequest) TypeID() uint32 { + return BotsGetPreviewInfoRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsGetPreviewInfoRequest) TypeName() string { + return "bots.getPreviewInfo" +} + +// TypeInfo returns info about TL type. +func (g *BotsGetPreviewInfoRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.getPreviewInfo", + ID: BotsGetPreviewInfoRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Bot", + SchemaName: "bot", + }, + { + Name: "LangCode", + SchemaName: "lang_code", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *BotsGetPreviewInfoRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode bots.getPreviewInfo#423ab3ad as nil") + } + b.PutID(BotsGetPreviewInfoRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *BotsGetPreviewInfoRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode bots.getPreviewInfo#423ab3ad as nil") + } + if g.Bot == nil { + return fmt.Errorf("unable to encode bots.getPreviewInfo#423ab3ad: field bot is nil") + } + if err := g.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.getPreviewInfo#423ab3ad: field bot: %w", err) + } + b.PutString(g.LangCode) + return nil +} + +// Decode implements bin.Decoder. +func (g *BotsGetPreviewInfoRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode bots.getPreviewInfo#423ab3ad to nil") + } + if err := b.ConsumeID(BotsGetPreviewInfoRequestTypeID); err != nil { + return fmt.Errorf("unable to decode bots.getPreviewInfo#423ab3ad: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *BotsGetPreviewInfoRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode bots.getPreviewInfo#423ab3ad to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode bots.getPreviewInfo#423ab3ad: field bot: %w", err) + } + g.Bot = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode bots.getPreviewInfo#423ab3ad: field lang_code: %w", err) + } + g.LangCode = value + } + return nil +} + +// GetBot returns value of Bot field. +func (g *BotsGetPreviewInfoRequest) GetBot() (value InputUserClass) { + if g == nil { + return + } + return g.Bot +} + +// GetLangCode returns value of LangCode field. +func (g *BotsGetPreviewInfoRequest) GetLangCode() (value string) { + if g == nil { + return + } + return g.LangCode +} + +// BotsGetPreviewInfo invokes method bots.getPreviewInfo#423ab3ad returning error if any. +// +// See https://core.telegram.org/method/bots.getPreviewInfo for reference. +func (c *Client) BotsGetPreviewInfo(ctx context.Context, request *BotsGetPreviewInfoRequest) (*BotsPreviewInfo, error) { + var result BotsPreviewInfo + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_bots_get_preview_info_slices_gen.go b/tg/tl_bots_get_preview_info_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_bots_get_preview_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_bots_get_preview_medias_gen.go b/tg/tl_bots_get_preview_medias_gen.go new file mode 100644 index 000000000..312eaf6fc --- /dev/null +++ b/tg/tl_bots_get_preview_medias_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{} +) + +// BotsGetPreviewMediasRequest represents TL type `bots.getPreviewMedias#a2a5594d`. +// +// See https://core.telegram.org/method/bots.getPreviewMedias for reference. +type BotsGetPreviewMediasRequest struct { + // Bot field of BotsGetPreviewMediasRequest. + Bot InputUserClass +} + +// BotsGetPreviewMediasRequestTypeID is TL type id of BotsGetPreviewMediasRequest. +const BotsGetPreviewMediasRequestTypeID = 0xa2a5594d + +// Ensuring interfaces in compile-time for BotsGetPreviewMediasRequest. +var ( + _ bin.Encoder = &BotsGetPreviewMediasRequest{} + _ bin.Decoder = &BotsGetPreviewMediasRequest{} + _ bin.BareEncoder = &BotsGetPreviewMediasRequest{} + _ bin.BareDecoder = &BotsGetPreviewMediasRequest{} +) + +func (g *BotsGetPreviewMediasRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Bot == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *BotsGetPreviewMediasRequest) String() string { + if g == nil { + return "BotsGetPreviewMediasRequest(nil)" + } + type Alias BotsGetPreviewMediasRequest + return fmt.Sprintf("BotsGetPreviewMediasRequest%+v", Alias(*g)) +} + +// FillFrom fills BotsGetPreviewMediasRequest from given interface. +func (g *BotsGetPreviewMediasRequest) FillFrom(from interface { + GetBot() (value InputUserClass) +}) { + g.Bot = from.GetBot() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsGetPreviewMediasRequest) TypeID() uint32 { + return BotsGetPreviewMediasRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsGetPreviewMediasRequest) TypeName() string { + return "bots.getPreviewMedias" +} + +// TypeInfo returns info about TL type. +func (g *BotsGetPreviewMediasRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.getPreviewMedias", + ID: BotsGetPreviewMediasRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Bot", + SchemaName: "bot", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *BotsGetPreviewMediasRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode bots.getPreviewMedias#a2a5594d as nil") + } + b.PutID(BotsGetPreviewMediasRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *BotsGetPreviewMediasRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode bots.getPreviewMedias#a2a5594d as nil") + } + if g.Bot == nil { + return fmt.Errorf("unable to encode bots.getPreviewMedias#a2a5594d: field bot is nil") + } + if err := g.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.getPreviewMedias#a2a5594d: field bot: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (g *BotsGetPreviewMediasRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode bots.getPreviewMedias#a2a5594d to nil") + } + if err := b.ConsumeID(BotsGetPreviewMediasRequestTypeID); err != nil { + return fmt.Errorf("unable to decode bots.getPreviewMedias#a2a5594d: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *BotsGetPreviewMediasRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode bots.getPreviewMedias#a2a5594d to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode bots.getPreviewMedias#a2a5594d: field bot: %w", err) + } + g.Bot = value + } + return nil +} + +// GetBot returns value of Bot field. +func (g *BotsGetPreviewMediasRequest) GetBot() (value InputUserClass) { + if g == nil { + return + } + return g.Bot +} + +// BotsGetPreviewMedias invokes method bots.getPreviewMedias#a2a5594d returning error if any. +// +// See https://core.telegram.org/method/bots.getPreviewMedias for reference. +func (c *Client) BotsGetPreviewMedias(ctx context.Context, bot InputUserClass) ([]BotPreviewMedia, error) { + var result BotPreviewMediaVector + + request := &BotsGetPreviewMediasRequest{ + Bot: bot, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return []BotPreviewMedia(result.Elems), nil +} diff --git a/tg/tl_bots_get_preview_medias_slices_gen.go b/tg/tl_bots_get_preview_medias_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_bots_get_preview_medias_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_bots_popular_app_bots_gen.go b/tg/tl_bots_popular_app_bots_gen.go new file mode 100644 index 000000000..be7ebb097 --- /dev/null +++ b/tg/tl_bots_popular_app_bots_gen.go @@ -0,0 +1,250 @@ +// 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{} +) + +// BotsPopularAppBots represents TL type `bots.popularAppBots#1991b13b`. +// +// See https://core.telegram.org/constructor/bots.popularAppBots for reference. +type BotsPopularAppBots struct { + // Flags field of BotsPopularAppBots. + Flags bin.Fields + // NextOffset field of BotsPopularAppBots. + // + // Use SetNextOffset and GetNextOffset helpers. + NextOffset string + // Users field of BotsPopularAppBots. + Users []UserClass +} + +// BotsPopularAppBotsTypeID is TL type id of BotsPopularAppBots. +const BotsPopularAppBotsTypeID = 0x1991b13b + +// Ensuring interfaces in compile-time for BotsPopularAppBots. +var ( + _ bin.Encoder = &BotsPopularAppBots{} + _ bin.Decoder = &BotsPopularAppBots{} + _ bin.BareEncoder = &BotsPopularAppBots{} + _ bin.BareDecoder = &BotsPopularAppBots{} +) + +func (p *BotsPopularAppBots) Zero() bool { + if p == nil { + return true + } + if !(p.Flags.Zero()) { + return false + } + if !(p.NextOffset == "") { + return false + } + if !(p.Users == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (p *BotsPopularAppBots) String() string { + if p == nil { + return "BotsPopularAppBots(nil)" + } + type Alias BotsPopularAppBots + return fmt.Sprintf("BotsPopularAppBots%+v", Alias(*p)) +} + +// FillFrom fills BotsPopularAppBots from given interface. +func (p *BotsPopularAppBots) FillFrom(from interface { + GetNextOffset() (value string, ok bool) + GetUsers() (value []UserClass) +}) { + if val, ok := from.GetNextOffset(); ok { + p.NextOffset = val + } + + p.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsPopularAppBots) TypeID() uint32 { + return BotsPopularAppBotsTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsPopularAppBots) TypeName() string { + return "bots.popularAppBots" +} + +// TypeInfo returns info about TL type. +func (p *BotsPopularAppBots) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.popularAppBots", + ID: BotsPopularAppBotsTypeID, + } + if p == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "NextOffset", + SchemaName: "next_offset", + Null: !p.Flags.Has(0), + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (p *BotsPopularAppBots) SetFlags() { + if !(p.NextOffset == "") { + p.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (p *BotsPopularAppBots) Encode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode bots.popularAppBots#1991b13b as nil") + } + b.PutID(BotsPopularAppBotsTypeID) + return p.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (p *BotsPopularAppBots) EncodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode bots.popularAppBots#1991b13b as nil") + } + p.SetFlags() + if err := p.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.popularAppBots#1991b13b: field flags: %w", err) + } + if p.Flags.Has(0) { + b.PutString(p.NextOffset) + } + b.PutVectorHeader(len(p.Users)) + for idx, v := range p.Users { + if v == nil { + return fmt.Errorf("unable to encode bots.popularAppBots#1991b13b: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.popularAppBots#1991b13b: field users element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (p *BotsPopularAppBots) Decode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode bots.popularAppBots#1991b13b to nil") + } + if err := b.ConsumeID(BotsPopularAppBotsTypeID); err != nil { + return fmt.Errorf("unable to decode bots.popularAppBots#1991b13b: %w", err) + } + return p.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (p *BotsPopularAppBots) DecodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode bots.popularAppBots#1991b13b to nil") + } + { + if err := p.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode bots.popularAppBots#1991b13b: field flags: %w", err) + } + } + if p.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode bots.popularAppBots#1991b13b: field next_offset: %w", err) + } + p.NextOffset = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode bots.popularAppBots#1991b13b: field users: %w", err) + } + + if headerLen > 0 { + p.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 bots.popularAppBots#1991b13b: field users: %w", err) + } + p.Users = append(p.Users, value) + } + } + return nil +} + +// SetNextOffset sets value of NextOffset conditional field. +func (p *BotsPopularAppBots) SetNextOffset(value string) { + p.Flags.Set(0) + p.NextOffset = value +} + +// GetNextOffset returns value of NextOffset conditional field and +// boolean which is true if field was set. +func (p *BotsPopularAppBots) GetNextOffset() (value string, ok bool) { + if p == nil { + return + } + if !p.Flags.Has(0) { + return value, false + } + return p.NextOffset, true +} + +// GetUsers returns value of Users field. +func (p *BotsPopularAppBots) GetUsers() (value []UserClass) { + if p == nil { + return + } + return p.Users +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (p *BotsPopularAppBots) MapUsers() (value UserClassArray) { + return UserClassArray(p.Users) +} diff --git a/tg/tl_bots_popular_app_bots_slices_gen.go b/tg/tl_bots_popular_app_bots_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_bots_popular_app_bots_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_bots_preview_info_gen.go b/tg/tl_bots_preview_info_gen.go new file mode 100644 index 000000000..0ca01842c --- /dev/null +++ b/tg/tl_bots_preview_info_gen.go @@ -0,0 +1,216 @@ +// 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{} +) + +// BotsPreviewInfo represents TL type `bots.previewInfo#ca71d64`. +// +// See https://core.telegram.org/constructor/bots.previewInfo for reference. +type BotsPreviewInfo struct { + // Media field of BotsPreviewInfo. + Media []BotPreviewMedia + // LangCodes field of BotsPreviewInfo. + LangCodes []string +} + +// BotsPreviewInfoTypeID is TL type id of BotsPreviewInfo. +const BotsPreviewInfoTypeID = 0xca71d64 + +// Ensuring interfaces in compile-time for BotsPreviewInfo. +var ( + _ bin.Encoder = &BotsPreviewInfo{} + _ bin.Decoder = &BotsPreviewInfo{} + _ bin.BareEncoder = &BotsPreviewInfo{} + _ bin.BareDecoder = &BotsPreviewInfo{} +) + +func (p *BotsPreviewInfo) Zero() bool { + if p == nil { + return true + } + if !(p.Media == nil) { + return false + } + if !(p.LangCodes == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (p *BotsPreviewInfo) String() string { + if p == nil { + return "BotsPreviewInfo(nil)" + } + type Alias BotsPreviewInfo + return fmt.Sprintf("BotsPreviewInfo%+v", Alias(*p)) +} + +// FillFrom fills BotsPreviewInfo from given interface. +func (p *BotsPreviewInfo) FillFrom(from interface { + GetMedia() (value []BotPreviewMedia) + GetLangCodes() (value []string) +}) { + p.Media = from.GetMedia() + p.LangCodes = from.GetLangCodes() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsPreviewInfo) TypeID() uint32 { + return BotsPreviewInfoTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsPreviewInfo) TypeName() string { + return "bots.previewInfo" +} + +// TypeInfo returns info about TL type. +func (p *BotsPreviewInfo) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.previewInfo", + ID: BotsPreviewInfoTypeID, + } + if p == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Media", + SchemaName: "media", + }, + { + Name: "LangCodes", + SchemaName: "lang_codes", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (p *BotsPreviewInfo) Encode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode bots.previewInfo#ca71d64 as nil") + } + b.PutID(BotsPreviewInfoTypeID) + return p.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (p *BotsPreviewInfo) EncodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode bots.previewInfo#ca71d64 as nil") + } + b.PutVectorHeader(len(p.Media)) + for idx, v := range p.Media { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.previewInfo#ca71d64: field media element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(p.LangCodes)) + for _, v := range p.LangCodes { + b.PutString(v) + } + return nil +} + +// Decode implements bin.Decoder. +func (p *BotsPreviewInfo) Decode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode bots.previewInfo#ca71d64 to nil") + } + if err := b.ConsumeID(BotsPreviewInfoTypeID); err != nil { + return fmt.Errorf("unable to decode bots.previewInfo#ca71d64: %w", err) + } + return p.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (p *BotsPreviewInfo) DecodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode bots.previewInfo#ca71d64 to nil") + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode bots.previewInfo#ca71d64: field media: %w", err) + } + + if headerLen > 0 { + p.Media = make([]BotPreviewMedia, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value BotPreviewMedia + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode bots.previewInfo#ca71d64: field media: %w", err) + } + p.Media = append(p.Media, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode bots.previewInfo#ca71d64: field lang_codes: %w", err) + } + + if headerLen > 0 { + p.LangCodes = 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 bots.previewInfo#ca71d64: field lang_codes: %w", err) + } + p.LangCodes = append(p.LangCodes, value) + } + } + return nil +} + +// GetMedia returns value of Media field. +func (p *BotsPreviewInfo) GetMedia() (value []BotPreviewMedia) { + if p == nil { + return + } + return p.Media +} + +// GetLangCodes returns value of LangCodes field. +func (p *BotsPreviewInfo) GetLangCodes() (value []string) { + if p == nil { + return + } + return p.LangCodes +} diff --git a/tg/tl_bots_preview_info_slices_gen.go b/tg/tl_bots_preview_info_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_bots_preview_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_bots_reorder_preview_medias_gen.go b/tg/tl_bots_reorder_preview_medias_gen.go new file mode 100644 index 000000000..b921e527b --- /dev/null +++ b/tg/tl_bots_reorder_preview_medias_gen.go @@ -0,0 +1,256 @@ +// 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{} +) + +// BotsReorderPreviewMediasRequest represents TL type `bots.reorderPreviewMedias#b627f3aa`. +// +// See https://core.telegram.org/method/bots.reorderPreviewMedias for reference. +type BotsReorderPreviewMediasRequest struct { + // Bot field of BotsReorderPreviewMediasRequest. + Bot InputUserClass + // LangCode field of BotsReorderPreviewMediasRequest. + LangCode string + // Order field of BotsReorderPreviewMediasRequest. + Order []InputMediaClass +} + +// BotsReorderPreviewMediasRequestTypeID is TL type id of BotsReorderPreviewMediasRequest. +const BotsReorderPreviewMediasRequestTypeID = 0xb627f3aa + +// Ensuring interfaces in compile-time for BotsReorderPreviewMediasRequest. +var ( + _ bin.Encoder = &BotsReorderPreviewMediasRequest{} + _ bin.Decoder = &BotsReorderPreviewMediasRequest{} + _ bin.BareEncoder = &BotsReorderPreviewMediasRequest{} + _ bin.BareDecoder = &BotsReorderPreviewMediasRequest{} +) + +func (r *BotsReorderPreviewMediasRequest) Zero() bool { + if r == nil { + return true + } + if !(r.Bot == nil) { + return false + } + if !(r.LangCode == "") { + return false + } + if !(r.Order == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *BotsReorderPreviewMediasRequest) String() string { + if r == nil { + return "BotsReorderPreviewMediasRequest(nil)" + } + type Alias BotsReorderPreviewMediasRequest + return fmt.Sprintf("BotsReorderPreviewMediasRequest%+v", Alias(*r)) +} + +// FillFrom fills BotsReorderPreviewMediasRequest from given interface. +func (r *BotsReorderPreviewMediasRequest) FillFrom(from interface { + GetBot() (value InputUserClass) + GetLangCode() (value string) + GetOrder() (value []InputMediaClass) +}) { + r.Bot = from.GetBot() + r.LangCode = from.GetLangCode() + r.Order = from.GetOrder() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsReorderPreviewMediasRequest) TypeID() uint32 { + return BotsReorderPreviewMediasRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsReorderPreviewMediasRequest) TypeName() string { + return "bots.reorderPreviewMedias" +} + +// TypeInfo returns info about TL type. +func (r *BotsReorderPreviewMediasRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.reorderPreviewMedias", + ID: BotsReorderPreviewMediasRequestTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Bot", + SchemaName: "bot", + }, + { + Name: "LangCode", + SchemaName: "lang_code", + }, + { + Name: "Order", + SchemaName: "order", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (r *BotsReorderPreviewMediasRequest) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode bots.reorderPreviewMedias#b627f3aa as nil") + } + b.PutID(BotsReorderPreviewMediasRequestTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *BotsReorderPreviewMediasRequest) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode bots.reorderPreviewMedias#b627f3aa as nil") + } + if r.Bot == nil { + return fmt.Errorf("unable to encode bots.reorderPreviewMedias#b627f3aa: field bot is nil") + } + if err := r.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.reorderPreviewMedias#b627f3aa: field bot: %w", err) + } + b.PutString(r.LangCode) + b.PutVectorHeader(len(r.Order)) + for idx, v := range r.Order { + if v == nil { + return fmt.Errorf("unable to encode bots.reorderPreviewMedias#b627f3aa: field order element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.reorderPreviewMedias#b627f3aa: field order element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (r *BotsReorderPreviewMediasRequest) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode bots.reorderPreviewMedias#b627f3aa to nil") + } + if err := b.ConsumeID(BotsReorderPreviewMediasRequestTypeID); err != nil { + return fmt.Errorf("unable to decode bots.reorderPreviewMedias#b627f3aa: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *BotsReorderPreviewMediasRequest) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode bots.reorderPreviewMedias#b627f3aa to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode bots.reorderPreviewMedias#b627f3aa: field bot: %w", err) + } + r.Bot = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode bots.reorderPreviewMedias#b627f3aa: field lang_code: %w", err) + } + r.LangCode = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode bots.reorderPreviewMedias#b627f3aa: field order: %w", err) + } + + if headerLen > 0 { + r.Order = make([]InputMediaClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeInputMedia(b) + if err != nil { + return fmt.Errorf("unable to decode bots.reorderPreviewMedias#b627f3aa: field order: %w", err) + } + r.Order = append(r.Order, value) + } + } + return nil +} + +// GetBot returns value of Bot field. +func (r *BotsReorderPreviewMediasRequest) GetBot() (value InputUserClass) { + if r == nil { + return + } + return r.Bot +} + +// GetLangCode returns value of LangCode field. +func (r *BotsReorderPreviewMediasRequest) GetLangCode() (value string) { + if r == nil { + return + } + return r.LangCode +} + +// GetOrder returns value of Order field. +func (r *BotsReorderPreviewMediasRequest) GetOrder() (value []InputMediaClass) { + if r == nil { + return + } + return r.Order +} + +// MapOrder returns field Order wrapped in InputMediaClassArray helper. +func (r *BotsReorderPreviewMediasRequest) MapOrder() (value InputMediaClassArray) { + return InputMediaClassArray(r.Order) +} + +// BotsReorderPreviewMedias invokes method bots.reorderPreviewMedias#b627f3aa returning error if any. +// +// See https://core.telegram.org/method/bots.reorderPreviewMedias for reference. +func (c *Client) BotsReorderPreviewMedias(ctx context.Context, request *BotsReorderPreviewMediasRequest) (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_bots_reorder_preview_medias_slices_gen.go b/tg/tl_bots_reorder_preview_medias_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_bots_reorder_preview_medias_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_contacts_get_top_peers_gen.go b/tg/tl_contacts_get_top_peers_gen.go index 36476403b..4ce5bbaef 100644 --- a/tg/tl_contacts_get_top_peers_gen.go +++ b/tg/tl_contacts_get_top_peers_gen.go @@ -57,6 +57,8 @@ type ContactsGetTopPeersRequest struct { Groups bool // Most frequently visited channels Channels bool + // BotsApp field of ContactsGetTopPeersRequest. + BotsApp bool // Offset for pagination¹ // // Links: @@ -116,6 +118,9 @@ func (g *ContactsGetTopPeersRequest) Zero() bool { if !(g.Channels == false) { return false } + if !(g.BotsApp == false) { + return false + } if !(g.Offset == 0) { return false } @@ -148,6 +153,7 @@ func (g *ContactsGetTopPeersRequest) FillFrom(from interface { GetForwardChats() (value bool) GetGroups() (value bool) GetChannels() (value bool) + GetBotsApp() (value bool) GetOffset() (value int) GetLimit() (value int) GetHash() (value int64) @@ -160,6 +166,7 @@ func (g *ContactsGetTopPeersRequest) FillFrom(from interface { g.ForwardChats = from.GetForwardChats() g.Groups = from.GetGroups() g.Channels = from.GetChannels() + g.BotsApp = from.GetBotsApp() g.Offset = from.GetOffset() g.Limit = from.GetLimit() g.Hash = from.GetHash() @@ -228,6 +235,11 @@ func (g *ContactsGetTopPeersRequest) TypeInfo() tdp.Type { SchemaName: "channels", Null: !g.Flags.Has(15), }, + { + Name: "BotsApp", + SchemaName: "bots_app", + Null: !g.Flags.Has(16), + }, { Name: "Offset", SchemaName: "offset", @@ -270,6 +282,9 @@ func (g *ContactsGetTopPeersRequest) SetFlags() { if !(g.Channels == false) { g.Flags.Set(15) } + if !(g.BotsApp == false) { + g.Flags.Set(16) + } } // Encode implements bin.Encoder. @@ -325,6 +340,7 @@ func (g *ContactsGetTopPeersRequest) DecodeBare(b *bin.Buffer) error { g.ForwardChats = g.Flags.Has(5) g.Groups = g.Flags.Has(10) g.Channels = g.Flags.Has(15) + g.BotsApp = g.Flags.Has(16) { value, err := b.Int() if err != nil { @@ -501,6 +517,25 @@ func (g *ContactsGetTopPeersRequest) GetChannels() (value bool) { return g.Flags.Has(15) } +// SetBotsApp sets value of BotsApp conditional field. +func (g *ContactsGetTopPeersRequest) SetBotsApp(value bool) { + if value { + g.Flags.Set(16) + g.BotsApp = true + } else { + g.Flags.Unset(16) + g.BotsApp = false + } +} + +// GetBotsApp returns value of BotsApp conditional field. +func (g *ContactsGetTopPeersRequest) GetBotsApp() (value bool) { + if g == nil { + return + } + return g.Flags.Has(16) +} + // GetOffset returns value of Offset field. func (g *ContactsGetTopPeersRequest) GetOffset() (value int) { if g == nil { diff --git a/tg/tl_document_attribute_gen.go b/tg/tl_document_attribute_gen.go index 7b213cad0..0c8040eac 100644 --- a/tg/tl_document_attribute_gen.go +++ b/tg/tl_document_attribute_gen.go @@ -566,7 +566,7 @@ func (d *DocumentAttributeSticker) GetMaskCoords() (value MaskCoords, ok bool) { return d.MaskCoords, true } -// DocumentAttributeVideo represents TL type `documentAttributeVideo#d38ff1c2`. +// DocumentAttributeVideo represents TL type `documentAttributeVideo#17399fad`. // Defines a video // // See https://core.telegram.org/constructor/documentAttributeVideo for reference. @@ -596,10 +596,14 @@ type DocumentAttributeVideo struct { // // Use SetPreloadPrefixSize and GetPreloadPrefixSize helpers. PreloadPrefixSize int + // VideoStartTs field of DocumentAttributeVideo. + // + // Use SetVideoStartTs and GetVideoStartTs helpers. + VideoStartTs float64 } // DocumentAttributeVideoTypeID is TL type id of DocumentAttributeVideo. -const DocumentAttributeVideoTypeID = 0xd38ff1c2 +const DocumentAttributeVideoTypeID = 0x17399fad // construct implements constructor of DocumentAttributeClass. func (d DocumentAttributeVideo) construct() DocumentAttributeClass { return &d } @@ -642,6 +646,9 @@ func (d *DocumentAttributeVideo) Zero() bool { if !(d.PreloadPrefixSize == 0) { return false } + if !(d.VideoStartTs == 0) { + return false + } return true } @@ -664,6 +671,7 @@ func (d *DocumentAttributeVideo) FillFrom(from interface { GetW() (value int) GetH() (value int) GetPreloadPrefixSize() (value int, ok bool) + GetVideoStartTs() (value float64, ok bool) }) { d.RoundMessage = from.GetRoundMessage() d.SupportsStreaming = from.GetSupportsStreaming() @@ -675,6 +683,10 @@ func (d *DocumentAttributeVideo) FillFrom(from interface { d.PreloadPrefixSize = val } + if val, ok := from.GetVideoStartTs(); ok { + d.VideoStartTs = val + } + } // TypeID returns type id in TL schema. @@ -732,6 +744,11 @@ func (d *DocumentAttributeVideo) TypeInfo() tdp.Type { SchemaName: "preload_prefix_size", Null: !d.Flags.Has(2), }, + { + Name: "VideoStartTs", + SchemaName: "video_start_ts", + Null: !d.Flags.Has(4), + }, } return typ } @@ -750,12 +767,15 @@ func (d *DocumentAttributeVideo) SetFlags() { if !(d.PreloadPrefixSize == 0) { d.Flags.Set(2) } + if !(d.VideoStartTs == 0) { + d.Flags.Set(4) + } } // Encode implements bin.Encoder. func (d *DocumentAttributeVideo) Encode(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't encode documentAttributeVideo#d38ff1c2 as nil") + return fmt.Errorf("can't encode documentAttributeVideo#17399fad as nil") } b.PutID(DocumentAttributeVideoTypeID) return d.EncodeBare(b) @@ -764,11 +784,11 @@ func (d *DocumentAttributeVideo) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (d *DocumentAttributeVideo) EncodeBare(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't encode documentAttributeVideo#d38ff1c2 as nil") + return fmt.Errorf("can't encode documentAttributeVideo#17399fad as nil") } d.SetFlags() if err := d.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode documentAttributeVideo#d38ff1c2: field flags: %w", err) + return fmt.Errorf("unable to encode documentAttributeVideo#17399fad: field flags: %w", err) } b.PutDouble(d.Duration) b.PutInt(d.W) @@ -776,16 +796,19 @@ func (d *DocumentAttributeVideo) EncodeBare(b *bin.Buffer) error { if d.Flags.Has(2) { b.PutInt(d.PreloadPrefixSize) } + if d.Flags.Has(4) { + b.PutDouble(d.VideoStartTs) + } return nil } // Decode implements bin.Decoder. func (d *DocumentAttributeVideo) Decode(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't decode documentAttributeVideo#d38ff1c2 to nil") + return fmt.Errorf("can't decode documentAttributeVideo#17399fad to nil") } if err := b.ConsumeID(DocumentAttributeVideoTypeID); err != nil { - return fmt.Errorf("unable to decode documentAttributeVideo#d38ff1c2: %w", err) + return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: %w", err) } return d.DecodeBare(b) } @@ -793,11 +816,11 @@ func (d *DocumentAttributeVideo) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (d *DocumentAttributeVideo) DecodeBare(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't decode documentAttributeVideo#d38ff1c2 to nil") + return fmt.Errorf("can't decode documentAttributeVideo#17399fad to nil") } { if err := d.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode documentAttributeVideo#d38ff1c2: field flags: %w", err) + return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: field flags: %w", err) } } d.RoundMessage = d.Flags.Has(0) @@ -806,31 +829,38 @@ func (d *DocumentAttributeVideo) DecodeBare(b *bin.Buffer) error { { value, err := b.Double() if err != nil { - return fmt.Errorf("unable to decode documentAttributeVideo#d38ff1c2: field duration: %w", err) + return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: field duration: %w", err) } d.Duration = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode documentAttributeVideo#d38ff1c2: field w: %w", err) + return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: field w: %w", err) } d.W = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode documentAttributeVideo#d38ff1c2: field h: %w", err) + return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: field h: %w", err) } d.H = value } if d.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode documentAttributeVideo#d38ff1c2: field preload_prefix_size: %w", err) + return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: field preload_prefix_size: %w", err) } d.PreloadPrefixSize = value } + if d.Flags.Has(4) { + value, err := b.Double() + if err != nil { + return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: field video_start_ts: %w", err) + } + d.VideoStartTs = value + } return nil } @@ -933,6 +963,24 @@ func (d *DocumentAttributeVideo) GetPreloadPrefixSize() (value int, ok bool) { return d.PreloadPrefixSize, true } +// SetVideoStartTs sets value of VideoStartTs conditional field. +func (d *DocumentAttributeVideo) SetVideoStartTs(value float64) { + d.Flags.Set(4) + d.VideoStartTs = value +} + +// GetVideoStartTs returns value of VideoStartTs conditional field and +// boolean which is true if field was set. +func (d *DocumentAttributeVideo) GetVideoStartTs() (value float64, ok bool) { + if d == nil { + return + } + if !d.Flags.Has(4) { + return value, false + } + return d.VideoStartTs, true +} + // DocumentAttributeAudio represents TL type `documentAttributeAudio#9852f9c6`. // Represents an audio file // @@ -1786,7 +1834,7 @@ const DocumentAttributeClassName = "DocumentAttribute" // case *tg.DocumentAttributeImageSize: // documentAttributeImageSize#6c37c15c // case *tg.DocumentAttributeAnimated: // documentAttributeAnimated#11b58939 // case *tg.DocumentAttributeSticker: // documentAttributeSticker#6319d612 -// case *tg.DocumentAttributeVideo: // documentAttributeVideo#d38ff1c2 +// case *tg.DocumentAttributeVideo: // documentAttributeVideo#17399fad // case *tg.DocumentAttributeAudio: // documentAttributeAudio#9852f9c6 // case *tg.DocumentAttributeFilename: // documentAttributeFilename#15590068 // case *tg.DocumentAttributeHasStickers: // documentAttributeHasStickers#9801d2f7 @@ -1841,7 +1889,7 @@ func DecodeDocumentAttribute(buf *bin.Buffer) (DocumentAttributeClass, error) { } return &v, nil case DocumentAttributeVideoTypeID: - // Decoding documentAttributeVideo#d38ff1c2. + // Decoding documentAttributeVideo#17399fad. v := DocumentAttributeVideo{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode DocumentAttributeClass: %w", err) diff --git a/tg/tl_input_invoice_gen.go b/tg/tl_input_invoice_gen.go index bc0a8564b..eabaf0b47 100644 --- a/tg/tl_input_invoice_gen.go +++ b/tg/tl_input_invoice_gen.go @@ -526,16 +526,16 @@ func (i *InputInvoicePremiumGiftCode) GetOption() (value PremiumGiftCodeOption) return i.Option } -// InputInvoiceStars represents TL type `inputInvoiceStars#1da33ad8`. +// InputInvoiceStars represents TL type `inputInvoiceStars#65f00ce3`. // // See https://core.telegram.org/constructor/inputInvoiceStars for reference. type InputInvoiceStars struct { - // Option field of InputInvoiceStars. - Option StarsTopupOption + // Purpose field of InputInvoiceStars. + Purpose InputStorePaymentPurposeClass } // InputInvoiceStarsTypeID is TL type id of InputInvoiceStars. -const InputInvoiceStarsTypeID = 0x1da33ad8 +const InputInvoiceStarsTypeID = 0x65f00ce3 // construct implements constructor of InputInvoiceClass. func (i InputInvoiceStars) construct() InputInvoiceClass { return &i } @@ -554,7 +554,7 @@ func (i *InputInvoiceStars) Zero() bool { if i == nil { return true } - if !(i.Option.Zero()) { + if !(i.Purpose == nil) { return false } @@ -572,9 +572,9 @@ func (i *InputInvoiceStars) String() string { // FillFrom fills InputInvoiceStars from given interface. func (i *InputInvoiceStars) FillFrom(from interface { - GetOption() (value StarsTopupOption) + GetPurpose() (value InputStorePaymentPurposeClass) }) { - i.Option = from.GetOption() + i.Purpose = from.GetPurpose() } // TypeID returns type id in TL schema. @@ -601,8 +601,8 @@ func (i *InputInvoiceStars) TypeInfo() tdp.Type { } typ.Fields = []tdp.Field{ { - Name: "Option", - SchemaName: "option", + Name: "Purpose", + SchemaName: "purpose", }, } return typ @@ -611,7 +611,7 @@ func (i *InputInvoiceStars) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (i *InputInvoiceStars) Encode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputInvoiceStars#1da33ad8 as nil") + return fmt.Errorf("can't encode inputInvoiceStars#65f00ce3 as nil") } b.PutID(InputInvoiceStarsTypeID) return i.EncodeBare(b) @@ -620,10 +620,13 @@ func (i *InputInvoiceStars) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (i *InputInvoiceStars) EncodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputInvoiceStars#1da33ad8 as nil") + return fmt.Errorf("can't encode inputInvoiceStars#65f00ce3 as nil") } - if err := i.Option.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputInvoiceStars#1da33ad8: field option: %w", err) + if i.Purpose == nil { + return fmt.Errorf("unable to encode inputInvoiceStars#65f00ce3: field purpose is nil") + } + if err := i.Purpose.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputInvoiceStars#65f00ce3: field purpose: %w", err) } return nil } @@ -631,10 +634,10 @@ func (i *InputInvoiceStars) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (i *InputInvoiceStars) Decode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputInvoiceStars#1da33ad8 to nil") + return fmt.Errorf("can't decode inputInvoiceStars#65f00ce3 to nil") } if err := b.ConsumeID(InputInvoiceStarsTypeID); err != nil { - return fmt.Errorf("unable to decode inputInvoiceStars#1da33ad8: %w", err) + return fmt.Errorf("unable to decode inputInvoiceStars#65f00ce3: %w", err) } return i.DecodeBare(b) } @@ -642,22 +645,24 @@ func (i *InputInvoiceStars) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (i *InputInvoiceStars) DecodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputInvoiceStars#1da33ad8 to nil") + return fmt.Errorf("can't decode inputInvoiceStars#65f00ce3 to nil") } { - if err := i.Option.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputInvoiceStars#1da33ad8: field option: %w", err) + value, err := DecodeInputStorePaymentPurpose(b) + if err != nil { + return fmt.Errorf("unable to decode inputInvoiceStars#65f00ce3: field purpose: %w", err) } + i.Purpose = value } return nil } -// GetOption returns value of Option field. -func (i *InputInvoiceStars) GetOption() (value StarsTopupOption) { +// GetPurpose returns value of Purpose field. +func (i *InputInvoiceStars) GetPurpose() (value InputStorePaymentPurposeClass) { if i == nil { return } - return i.Option + return i.Purpose } // InputInvoiceClassName is schema name of InputInvoiceClass. @@ -677,7 +682,7 @@ const InputInvoiceClassName = "InputInvoice" // case *tg.InputInvoiceMessage: // inputInvoiceMessage#c5b56859 // case *tg.InputInvoiceSlug: // inputInvoiceSlug#c326caef // case *tg.InputInvoicePremiumGiftCode: // inputInvoicePremiumGiftCode#98986c0d -// case *tg.InputInvoiceStars: // inputInvoiceStars#1da33ad8 +// case *tg.InputInvoiceStars: // inputInvoiceStars#65f00ce3 // default: panic(v) // } type InputInvoiceClass interface { @@ -728,7 +733,7 @@ func DecodeInputInvoice(buf *bin.Buffer) (InputInvoiceClass, error) { } return &v, nil case InputInvoiceStarsTypeID: - // Decoding inputInvoiceStars#1da33ad8. + // Decoding inputInvoiceStars#65f00ce3. v := InputInvoiceStars{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode InputInvoiceClass: %w", err) diff --git a/tg/tl_input_store_payment_purpose_gen.go b/tg/tl_input_store_payment_purpose_gen.go index f698ea377..35128a6d0 100644 --- a/tg/tl_input_store_payment_purpose_gen.go +++ b/tg/tl_input_store_payment_purpose_gen.go @@ -1301,43 +1301,38 @@ func (i *InputStorePaymentPremiumGiveaway) MapAdditionalPeers() (value InputPeer return InputPeerClassArray(i.AdditionalPeers), true } -// InputStorePaymentStars represents TL type `inputStorePaymentStars#4f0ee8df`. +// InputStorePaymentStarsTopup represents TL type `inputStorePaymentStarsTopup#dddd0f56`. // -// See https://core.telegram.org/constructor/inputStorePaymentStars for reference. -type InputStorePaymentStars struct { - // Flags field of InputStorePaymentStars. - Flags bin.Fields - // Stars field of InputStorePaymentStars. +// See https://core.telegram.org/constructor/inputStorePaymentStarsTopup for reference. +type InputStorePaymentStarsTopup struct { + // Stars field of InputStorePaymentStarsTopup. Stars int64 - // Currency field of InputStorePaymentStars. + // Currency field of InputStorePaymentStarsTopup. Currency string - // Amount field of InputStorePaymentStars. + // Amount field of InputStorePaymentStarsTopup. Amount int64 } -// InputStorePaymentStarsTypeID is TL type id of InputStorePaymentStars. -const InputStorePaymentStarsTypeID = 0x4f0ee8df +// InputStorePaymentStarsTopupTypeID is TL type id of InputStorePaymentStarsTopup. +const InputStorePaymentStarsTopupTypeID = 0xdddd0f56 // construct implements constructor of InputStorePaymentPurposeClass. -func (i InputStorePaymentStars) construct() InputStorePaymentPurposeClass { return &i } +func (i InputStorePaymentStarsTopup) construct() InputStorePaymentPurposeClass { return &i } -// Ensuring interfaces in compile-time for InputStorePaymentStars. +// Ensuring interfaces in compile-time for InputStorePaymentStarsTopup. var ( - _ bin.Encoder = &InputStorePaymentStars{} - _ bin.Decoder = &InputStorePaymentStars{} - _ bin.BareEncoder = &InputStorePaymentStars{} - _ bin.BareDecoder = &InputStorePaymentStars{} + _ bin.Encoder = &InputStorePaymentStarsTopup{} + _ bin.Decoder = &InputStorePaymentStarsTopup{} + _ bin.BareEncoder = &InputStorePaymentStarsTopup{} + _ bin.BareDecoder = &InputStorePaymentStarsTopup{} - _ InputStorePaymentPurposeClass = &InputStorePaymentStars{} + _ InputStorePaymentPurposeClass = &InputStorePaymentStarsTopup{} ) -func (i *InputStorePaymentStars) Zero() bool { +func (i *InputStorePaymentStarsTopup) Zero() bool { if i == nil { return true } - if !(i.Flags.Zero()) { - return false - } if !(i.Stars == 0) { return false } @@ -1352,16 +1347,16 @@ func (i *InputStorePaymentStars) Zero() bool { } // String implements fmt.Stringer. -func (i *InputStorePaymentStars) String() string { +func (i *InputStorePaymentStarsTopup) String() string { if i == nil { - return "InputStorePaymentStars(nil)" + return "InputStorePaymentStarsTopup(nil)" } - type Alias InputStorePaymentStars - return fmt.Sprintf("InputStorePaymentStars%+v", Alias(*i)) + type Alias InputStorePaymentStarsTopup + return fmt.Sprintf("InputStorePaymentStarsTopup%+v", Alias(*i)) } -// FillFrom fills InputStorePaymentStars from given interface. -func (i *InputStorePaymentStars) FillFrom(from interface { +// FillFrom fills InputStorePaymentStarsTopup from given interface. +func (i *InputStorePaymentStarsTopup) FillFrom(from interface { GetStars() (value int64) GetCurrency() (value string) GetAmount() (value int64) @@ -1374,20 +1369,20 @@ func (i *InputStorePaymentStars) FillFrom(from interface { // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*InputStorePaymentStars) TypeID() uint32 { - return InputStorePaymentStarsTypeID +func (*InputStorePaymentStarsTopup) TypeID() uint32 { + return InputStorePaymentStarsTopupTypeID } // TypeName returns name of type in TL schema. -func (*InputStorePaymentStars) TypeName() string { - return "inputStorePaymentStars" +func (*InputStorePaymentStarsTopup) TypeName() string { + return "inputStorePaymentStarsTopup" } // TypeInfo returns info about TL type. -func (i *InputStorePaymentStars) TypeInfo() tdp.Type { +func (i *InputStorePaymentStarsTopup) TypeInfo() tdp.Type { typ := tdp.Type{ - Name: "inputStorePaymentStars", - ID: InputStorePaymentStarsTypeID, + Name: "inputStorePaymentStarsTopup", + ID: InputStorePaymentStarsTopupTypeID, } if i == nil { typ.Null = true @@ -1410,27 +1405,224 @@ func (i *InputStorePaymentStars) TypeInfo() tdp.Type { return typ } -// SetFlags sets flags for non-zero fields. -func (i *InputStorePaymentStars) SetFlags() { +// Encode implements bin.Encoder. +func (i *InputStorePaymentStarsTopup) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStorePaymentStarsTopup#dddd0f56 as nil") + } + b.PutID(InputStorePaymentStarsTopupTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputStorePaymentStarsTopup) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStorePaymentStarsTopup#dddd0f56 as nil") + } + b.PutLong(i.Stars) + b.PutString(i.Currency) + b.PutLong(i.Amount) + return nil +} + +// Decode implements bin.Decoder. +func (i *InputStorePaymentStarsTopup) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStorePaymentStarsTopup#dddd0f56 to nil") + } + if err := b.ConsumeID(InputStorePaymentStarsTopupTypeID); err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsTopup#dddd0f56: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputStorePaymentStarsTopup) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStorePaymentStarsTopup#dddd0f56 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsTopup#dddd0f56: field stars: %w", err) + } + i.Stars = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsTopup#dddd0f56: field currency: %w", err) + } + i.Currency = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsTopup#dddd0f56: field amount: %w", err) + } + i.Amount = value + } + return nil +} + +// GetStars returns value of Stars field. +func (i *InputStorePaymentStarsTopup) GetStars() (value int64) { + if i == nil { + return + } + return i.Stars +} + +// GetCurrency returns value of Currency field. +func (i *InputStorePaymentStarsTopup) GetCurrency() (value string) { + if i == nil { + return + } + return i.Currency +} + +// GetAmount returns value of Amount field. +func (i *InputStorePaymentStarsTopup) GetAmount() (value int64) { + if i == nil { + return + } + return i.Amount +} + +// InputStorePaymentStarsGift represents TL type `inputStorePaymentStarsGift#1d741ef7`. +// +// See https://core.telegram.org/constructor/inputStorePaymentStarsGift for reference. +type InputStorePaymentStarsGift struct { + // UserID field of InputStorePaymentStarsGift. + UserID InputUserClass + // Stars field of InputStorePaymentStarsGift. + Stars int64 + // Currency field of InputStorePaymentStarsGift. + Currency string + // Amount field of InputStorePaymentStarsGift. + Amount int64 +} + +// InputStorePaymentStarsGiftTypeID is TL type id of InputStorePaymentStarsGift. +const InputStorePaymentStarsGiftTypeID = 0x1d741ef7 + +// construct implements constructor of InputStorePaymentPurposeClass. +func (i InputStorePaymentStarsGift) construct() InputStorePaymentPurposeClass { return &i } + +// Ensuring interfaces in compile-time for InputStorePaymentStarsGift. +var ( + _ bin.Encoder = &InputStorePaymentStarsGift{} + _ bin.Decoder = &InputStorePaymentStarsGift{} + _ bin.BareEncoder = &InputStorePaymentStarsGift{} + _ bin.BareDecoder = &InputStorePaymentStarsGift{} + + _ InputStorePaymentPurposeClass = &InputStorePaymentStarsGift{} +) + +func (i *InputStorePaymentStarsGift) Zero() bool { + if i == nil { + return true + } + if !(i.UserID == nil) { + return false + } + if !(i.Stars == 0) { + return false + } + if !(i.Currency == "") { + return false + } + if !(i.Amount == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputStorePaymentStarsGift) String() string { + if i == nil { + return "InputStorePaymentStarsGift(nil)" + } + type Alias InputStorePaymentStarsGift + return fmt.Sprintf("InputStorePaymentStarsGift%+v", Alias(*i)) +} + +// FillFrom fills InputStorePaymentStarsGift from given interface. +func (i *InputStorePaymentStarsGift) FillFrom(from interface { + GetUserID() (value InputUserClass) + GetStars() (value int64) + GetCurrency() (value string) + GetAmount() (value int64) +}) { + i.UserID = from.GetUserID() + i.Stars = from.GetStars() + 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 (*InputStorePaymentStarsGift) TypeID() uint32 { + return InputStorePaymentStarsGiftTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputStorePaymentStarsGift) TypeName() string { + return "inputStorePaymentStarsGift" +} + +// TypeInfo returns info about TL type. +func (i *InputStorePaymentStarsGift) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputStorePaymentStarsGift", + ID: InputStorePaymentStarsGiftTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "Stars", + SchemaName: "stars", + }, + { + Name: "Currency", + SchemaName: "currency", + }, + { + Name: "Amount", + SchemaName: "amount", + }, + } + return typ } // Encode implements bin.Encoder. -func (i *InputStorePaymentStars) Encode(b *bin.Buffer) error { +func (i *InputStorePaymentStarsGift) Encode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputStorePaymentStars#4f0ee8df as nil") + return fmt.Errorf("can't encode inputStorePaymentStarsGift#1d741ef7 as nil") } - b.PutID(InputStorePaymentStarsTypeID) + b.PutID(InputStorePaymentStarsGiftTypeID) return i.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. -func (i *InputStorePaymentStars) EncodeBare(b *bin.Buffer) error { +func (i *InputStorePaymentStarsGift) EncodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputStorePaymentStars#4f0ee8df as nil") + return fmt.Errorf("can't encode inputStorePaymentStarsGift#1d741ef7 as nil") } - i.SetFlags() - if err := i.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputStorePaymentStars#4f0ee8df: field flags: %w", err) + if i.UserID == nil { + return fmt.Errorf("unable to encode inputStorePaymentStarsGift#1d741ef7: field user_id is nil") + } + if err := i.UserID.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputStorePaymentStarsGift#1d741ef7: field user_id: %w", err) } b.PutLong(i.Stars) b.PutString(i.Currency) @@ -1439,52 +1631,62 @@ func (i *InputStorePaymentStars) EncodeBare(b *bin.Buffer) error { } // Decode implements bin.Decoder. -func (i *InputStorePaymentStars) Decode(b *bin.Buffer) error { +func (i *InputStorePaymentStarsGift) Decode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputStorePaymentStars#4f0ee8df to nil") + return fmt.Errorf("can't decode inputStorePaymentStarsGift#1d741ef7 to nil") } - if err := b.ConsumeID(InputStorePaymentStarsTypeID); err != nil { - return fmt.Errorf("unable to decode inputStorePaymentStars#4f0ee8df: %w", err) + if err := b.ConsumeID(InputStorePaymentStarsGiftTypeID); err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGift#1d741ef7: %w", err) } return i.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. -func (i *InputStorePaymentStars) DecodeBare(b *bin.Buffer) error { +func (i *InputStorePaymentStarsGift) DecodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputStorePaymentStars#4f0ee8df to nil") + return fmt.Errorf("can't decode inputStorePaymentStarsGift#1d741ef7 to nil") } { - if err := i.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputStorePaymentStars#4f0ee8df: field flags: %w", err) + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGift#1d741ef7: field user_id: %w", err) } + i.UserID = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode inputStorePaymentStars#4f0ee8df: field stars: %w", err) + return fmt.Errorf("unable to decode inputStorePaymentStarsGift#1d741ef7: field stars: %w", err) } i.Stars = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode inputStorePaymentStars#4f0ee8df: field currency: %w", err) + return fmt.Errorf("unable to decode inputStorePaymentStarsGift#1d741ef7: field currency: %w", err) } i.Currency = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode inputStorePaymentStars#4f0ee8df: field amount: %w", err) + return fmt.Errorf("unable to decode inputStorePaymentStarsGift#1d741ef7: field amount: %w", err) } i.Amount = value } return nil } +// GetUserID returns value of UserID field. +func (i *InputStorePaymentStarsGift) GetUserID() (value InputUserClass) { + if i == nil { + return + } + return i.UserID +} + // GetStars returns value of Stars field. -func (i *InputStorePaymentStars) GetStars() (value int64) { +func (i *InputStorePaymentStarsGift) GetStars() (value int64) { if i == nil { return } @@ -1492,7 +1694,7 @@ func (i *InputStorePaymentStars) GetStars() (value int64) { } // GetCurrency returns value of Currency field. -func (i *InputStorePaymentStars) GetCurrency() (value string) { +func (i *InputStorePaymentStarsGift) GetCurrency() (value string) { if i == nil { return } @@ -1500,7 +1702,7 @@ func (i *InputStorePaymentStars) GetCurrency() (value string) { } // GetAmount returns value of Amount field. -func (i *InputStorePaymentStars) GetAmount() (value int64) { +func (i *InputStorePaymentStarsGift) GetAmount() (value int64) { if i == nil { return } @@ -1525,7 +1727,8 @@ const InputStorePaymentPurposeClassName = "InputStorePaymentPurpose" // case *tg.InputStorePaymentGiftPremium: // inputStorePaymentGiftPremium#616f7fe8 // case *tg.InputStorePaymentPremiumGiftCode: // inputStorePaymentPremiumGiftCode#a3805f3f // case *tg.InputStorePaymentPremiumGiveaway: // inputStorePaymentPremiumGiveaway#160544ca -// case *tg.InputStorePaymentStars: // inputStorePaymentStars#4f0ee8df +// case *tg.InputStorePaymentStarsTopup: // inputStorePaymentStarsTopup#dddd0f56 +// case *tg.InputStorePaymentStarsGift: // inputStorePaymentStarsGift#1d741ef7 // default: panic(v) // } type InputStorePaymentPurposeClass interface { @@ -1582,9 +1785,16 @@ func DecodeInputStorePaymentPurpose(buf *bin.Buffer) (InputStorePaymentPurposeCl return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", err) } return &v, nil - case InputStorePaymentStarsTypeID: - // Decoding inputStorePaymentStars#4f0ee8df. - v := InputStorePaymentStars{} + case InputStorePaymentStarsTopupTypeID: + // Decoding inputStorePaymentStarsTopup#dddd0f56. + v := InputStorePaymentStarsTopup{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", err) + } + return &v, nil + case InputStorePaymentStarsGiftTypeID: + // Decoding inputStorePaymentStarsGift#1d741ef7. + v := InputStorePaymentStarsGift{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", err) } diff --git a/tg/tl_input_store_payment_purpose_slices_gen.go b/tg/tl_input_store_payment_purpose_slices_gen.go index ce16f7789..07269a90b 100644 --- a/tg/tl_input_store_payment_purpose_slices_gen.go +++ b/tg/tl_input_store_payment_purpose_slices_gen.go @@ -168,10 +168,23 @@ func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentPremiumGiveaway() return to } -// AsInputStorePaymentStars returns copy with only InputStorePaymentStars constructors. -func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentStars() (to InputStorePaymentStarsArray) { +// AsInputStorePaymentStarsTopup returns copy with only InputStorePaymentStarsTopup constructors. +func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentStarsTopup() (to InputStorePaymentStarsTopupArray) { for _, elem := range s { - value, ok := elem.(*InputStorePaymentStars) + value, ok := elem.(*InputStorePaymentStarsTopup) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsInputStorePaymentStarsGift returns copy with only InputStorePaymentStarsGift constructors. +func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentStarsGift() (to InputStorePaymentStarsGiftArray) { + for _, elem := range s { + value, ok := elem.(*InputStorePaymentStarsGift) if !ok { continue } @@ -509,27 +522,109 @@ func (s *InputStorePaymentPremiumGiveawayArray) Pop() (v InputStorePaymentPremiu return v, true } -// InputStorePaymentStarsArray is adapter for slice of InputStorePaymentStars. -type InputStorePaymentStarsArray []InputStorePaymentStars +// InputStorePaymentStarsTopupArray is adapter for slice of InputStorePaymentStarsTopup. +type InputStorePaymentStarsTopupArray []InputStorePaymentStarsTopup + +// Sort sorts slice of InputStorePaymentStarsTopup. +func (s InputStorePaymentStarsTopupArray) Sort(less func(a, b InputStorePaymentStarsTopup) bool) InputStorePaymentStarsTopupArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InputStorePaymentStarsTopup. +func (s InputStorePaymentStarsTopupArray) SortStable(less func(a, b InputStorePaymentStarsTopup) bool) InputStorePaymentStarsTopupArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InputStorePaymentStarsTopup. +func (s InputStorePaymentStarsTopupArray) Retain(keep func(x InputStorePaymentStarsTopup) bool) InputStorePaymentStarsTopupArray { + 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 InputStorePaymentStarsTopupArray) First() (v InputStorePaymentStarsTopup, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputStorePaymentStarsTopupArray) Last() (v InputStorePaymentStarsTopup, 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 *InputStorePaymentStarsTopupArray) PopFirst() (v InputStorePaymentStarsTopup, 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 InputStorePaymentStarsTopup + 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 *InputStorePaymentStarsTopupArray) Pop() (v InputStorePaymentStarsTopup, 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 +} + +// InputStorePaymentStarsGiftArray is adapter for slice of InputStorePaymentStarsGift. +type InputStorePaymentStarsGiftArray []InputStorePaymentStarsGift -// Sort sorts slice of InputStorePaymentStars. -func (s InputStorePaymentStarsArray) Sort(less func(a, b InputStorePaymentStars) bool) InputStorePaymentStarsArray { +// Sort sorts slice of InputStorePaymentStarsGift. +func (s InputStorePaymentStarsGiftArray) Sort(less func(a, b InputStorePaymentStarsGift) bool) InputStorePaymentStarsGiftArray { sort.Slice(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } -// SortStable sorts slice of InputStorePaymentStars. -func (s InputStorePaymentStarsArray) SortStable(less func(a, b InputStorePaymentStars) bool) InputStorePaymentStarsArray { +// SortStable sorts slice of InputStorePaymentStarsGift. +func (s InputStorePaymentStarsGiftArray) SortStable(less func(a, b InputStorePaymentStarsGift) bool) InputStorePaymentStarsGiftArray { sort.SliceStable(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } -// Retain filters in-place slice of InputStorePaymentStars. -func (s InputStorePaymentStarsArray) Retain(keep func(x InputStorePaymentStars) bool) InputStorePaymentStarsArray { +// Retain filters in-place slice of InputStorePaymentStarsGift. +func (s InputStorePaymentStarsGiftArray) Retain(keep func(x InputStorePaymentStarsGift) bool) InputStorePaymentStarsGiftArray { n := 0 for _, x := range s { if keep(x) { @@ -543,7 +638,7 @@ func (s InputStorePaymentStarsArray) Retain(keep func(x InputStorePaymentStars) } // First returns first element of slice (if exists). -func (s InputStorePaymentStarsArray) First() (v InputStorePaymentStars, ok bool) { +func (s InputStorePaymentStarsGiftArray) First() (v InputStorePaymentStarsGift, ok bool) { if len(s) < 1 { return } @@ -551,7 +646,7 @@ func (s InputStorePaymentStarsArray) First() (v InputStorePaymentStars, ok bool) } // Last returns last element of slice (if exists). -func (s InputStorePaymentStarsArray) Last() (v InputStorePaymentStars, ok bool) { +func (s InputStorePaymentStarsGiftArray) Last() (v InputStorePaymentStarsGift, ok bool) { if len(s) < 1 { return } @@ -559,7 +654,7 @@ func (s InputStorePaymentStarsArray) Last() (v InputStorePaymentStars, ok bool) } // PopFirst returns first element of slice (if exists) and deletes it. -func (s *InputStorePaymentStarsArray) PopFirst() (v InputStorePaymentStars, ok bool) { +func (s *InputStorePaymentStarsGiftArray) PopFirst() (v InputStorePaymentStarsGift, ok bool) { if s == nil || len(*s) < 1 { return } @@ -569,7 +664,7 @@ func (s *InputStorePaymentStarsArray) PopFirst() (v InputStorePaymentStars, ok b // Delete by index from SliceTricks. copy(a[0:], a[1:]) - var zero InputStorePaymentStars + var zero InputStorePaymentStarsGift a[len(a)-1] = zero a = a[:len(a)-1] *s = a @@ -578,7 +673,7 @@ func (s *InputStorePaymentStarsArray) PopFirst() (v InputStorePaymentStars, ok b } // Pop returns last element of slice (if exists) and deletes it. -func (s *InputStorePaymentStarsArray) Pop() (v InputStorePaymentStars, ok bool) { +func (s *InputStorePaymentStarsGiftArray) Pop() (v InputStorePaymentStarsGift, ok bool) { if s == nil || len(*s) < 1 { return } diff --git a/tg/tl_media_area_gen.go b/tg/tl_media_area_gen.go index 185d77289..82b0685c5 100644 --- a/tg/tl_media_area_gen.go +++ b/tg/tl_media_area_gen.go @@ -1582,6 +1582,221 @@ func (m *MediaAreaURL) GetURL() (value string) { return m.URL } +// MediaAreaWeather represents TL type `mediaAreaWeather#49a6549c`. +// +// See https://core.telegram.org/constructor/mediaAreaWeather for reference. +type MediaAreaWeather struct { + // Coordinates field of MediaAreaWeather. + Coordinates MediaAreaCoordinates + // Emoji field of MediaAreaWeather. + Emoji string + // TemperatureC field of MediaAreaWeather. + TemperatureC float64 + // Color field of MediaAreaWeather. + Color int +} + +// MediaAreaWeatherTypeID is TL type id of MediaAreaWeather. +const MediaAreaWeatherTypeID = 0x49a6549c + +// construct implements constructor of MediaAreaClass. +func (m MediaAreaWeather) construct() MediaAreaClass { return &m } + +// Ensuring interfaces in compile-time for MediaAreaWeather. +var ( + _ bin.Encoder = &MediaAreaWeather{} + _ bin.Decoder = &MediaAreaWeather{} + _ bin.BareEncoder = &MediaAreaWeather{} + _ bin.BareDecoder = &MediaAreaWeather{} + + _ MediaAreaClass = &MediaAreaWeather{} +) + +func (m *MediaAreaWeather) Zero() bool { + if m == nil { + return true + } + if !(m.Coordinates.Zero()) { + return false + } + if !(m.Emoji == "") { + return false + } + if !(m.TemperatureC == 0) { + return false + } + if !(m.Color == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MediaAreaWeather) String() string { + if m == nil { + return "MediaAreaWeather(nil)" + } + type Alias MediaAreaWeather + return fmt.Sprintf("MediaAreaWeather%+v", Alias(*m)) +} + +// FillFrom fills MediaAreaWeather from given interface. +func (m *MediaAreaWeather) FillFrom(from interface { + GetCoordinates() (value MediaAreaCoordinates) + GetEmoji() (value string) + GetTemperatureC() (value float64) + GetColor() (value int) +}) { + m.Coordinates = from.GetCoordinates() + m.Emoji = from.GetEmoji() + m.TemperatureC = from.GetTemperatureC() + m.Color = from.GetColor() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MediaAreaWeather) TypeID() uint32 { + return MediaAreaWeatherTypeID +} + +// TypeName returns name of type in TL schema. +func (*MediaAreaWeather) TypeName() string { + return "mediaAreaWeather" +} + +// TypeInfo returns info about TL type. +func (m *MediaAreaWeather) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "mediaAreaWeather", + ID: MediaAreaWeatherTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Coordinates", + SchemaName: "coordinates", + }, + { + Name: "Emoji", + SchemaName: "emoji", + }, + { + Name: "TemperatureC", + SchemaName: "temperature_c", + }, + { + Name: "Color", + SchemaName: "color", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (m *MediaAreaWeather) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode mediaAreaWeather#49a6549c as nil") + } + b.PutID(MediaAreaWeatherTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MediaAreaWeather) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode mediaAreaWeather#49a6549c as nil") + } + if err := m.Coordinates.Encode(b); err != nil { + return fmt.Errorf("unable to encode mediaAreaWeather#49a6549c: field coordinates: %w", err) + } + b.PutString(m.Emoji) + b.PutDouble(m.TemperatureC) + b.PutInt(m.Color) + return nil +} + +// Decode implements bin.Decoder. +func (m *MediaAreaWeather) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode mediaAreaWeather#49a6549c to nil") + } + if err := b.ConsumeID(MediaAreaWeatherTypeID); err != nil { + return fmt.Errorf("unable to decode mediaAreaWeather#49a6549c: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MediaAreaWeather) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode mediaAreaWeather#49a6549c to nil") + } + { + if err := m.Coordinates.Decode(b); err != nil { + return fmt.Errorf("unable to decode mediaAreaWeather#49a6549c: field coordinates: %w", err) + } + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode mediaAreaWeather#49a6549c: field emoji: %w", err) + } + m.Emoji = value + } + { + value, err := b.Double() + if err != nil { + return fmt.Errorf("unable to decode mediaAreaWeather#49a6549c: field temperature_c: %w", err) + } + m.TemperatureC = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode mediaAreaWeather#49a6549c: field color: %w", err) + } + m.Color = value + } + return nil +} + +// GetCoordinates returns value of Coordinates field. +func (m *MediaAreaWeather) GetCoordinates() (value MediaAreaCoordinates) { + if m == nil { + return + } + return m.Coordinates +} + +// GetEmoji returns value of Emoji field. +func (m *MediaAreaWeather) GetEmoji() (value string) { + if m == nil { + return + } + return m.Emoji +} + +// GetTemperatureC returns value of TemperatureC field. +func (m *MediaAreaWeather) GetTemperatureC() (value float64) { + if m == nil { + return + } + return m.TemperatureC +} + +// GetColor returns value of Color field. +func (m *MediaAreaWeather) GetColor() (value int) { + if m == nil { + return + } + return m.Color +} + // MediaAreaClassName is schema name of MediaAreaClass. const MediaAreaClassName = "MediaArea" @@ -1603,6 +1818,7 @@ const MediaAreaClassName = "MediaArea" // case *tg.MediaAreaChannelPost: // mediaAreaChannelPost#770416af // case *tg.InputMediaAreaChannelPost: // inputMediaAreaChannelPost#2271f2bf // case *tg.MediaAreaURL: // mediaAreaUrl#37381085 +// case *tg.MediaAreaWeather: // mediaAreaWeather#49a6549c // default: panic(v) // } type MediaAreaClass interface { @@ -1684,6 +1900,13 @@ func DecodeMediaArea(buf *bin.Buffer) (MediaAreaClass, error) { return nil, fmt.Errorf("unable to decode MediaAreaClass: %w", err) } return &v, nil + case MediaAreaWeatherTypeID: + // Decoding mediaAreaWeather#49a6549c. + v := MediaAreaWeather{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MediaAreaClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode MediaAreaClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_media_area_slices_gen.go b/tg/tl_media_area_slices_gen.go index eec89564c..13dfa06f7 100644 --- a/tg/tl_media_area_slices_gen.go +++ b/tg/tl_media_area_slices_gen.go @@ -207,6 +207,19 @@ func (s MediaAreaClassArray) AsMediaAreaURL() (to MediaAreaURLArray) { return to } +// AsMediaAreaWeather returns copy with only MediaAreaWeather constructors. +func (s MediaAreaClassArray) AsMediaAreaWeather() (to MediaAreaWeatherArray) { + for _, elem := range s { + value, ok := elem.(*MediaAreaWeather) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // MediaAreaVenueArray is adapter for slice of MediaAreaVenue. type MediaAreaVenueArray []MediaAreaVenue @@ -780,3 +793,85 @@ func (s *MediaAreaURLArray) Pop() (v MediaAreaURL, ok bool) { return v, true } + +// MediaAreaWeatherArray is adapter for slice of MediaAreaWeather. +type MediaAreaWeatherArray []MediaAreaWeather + +// Sort sorts slice of MediaAreaWeather. +func (s MediaAreaWeatherArray) Sort(less func(a, b MediaAreaWeather) bool) MediaAreaWeatherArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MediaAreaWeather. +func (s MediaAreaWeatherArray) SortStable(less func(a, b MediaAreaWeather) bool) MediaAreaWeatherArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MediaAreaWeather. +func (s MediaAreaWeatherArray) Retain(keep func(x MediaAreaWeather) bool) MediaAreaWeatherArray { + 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 MediaAreaWeatherArray) First() (v MediaAreaWeather, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MediaAreaWeatherArray) Last() (v MediaAreaWeather, 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 *MediaAreaWeatherArray) PopFirst() (v MediaAreaWeather, 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 MediaAreaWeather + 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 *MediaAreaWeatherArray) Pop() (v MediaAreaWeather, 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 f20ec15c6..d9ffc4bee 100644 --- a/tg/tl_message_action_gen.go +++ b/tg/tl_message_action_gen.go @@ -8297,6 +8297,356 @@ func (m *MessageActionPaymentRefunded) GetCharge() (value PaymentCharge) { return m.Charge } +// MessageActionGiftStars represents TL type `messageActionGiftStars#45d5b021`. +// +// See https://core.telegram.org/constructor/messageActionGiftStars for reference. +type MessageActionGiftStars struct { + // Flags field of MessageActionGiftStars. + Flags bin.Fields + // Currency field of MessageActionGiftStars. + Currency string + // Amount field of MessageActionGiftStars. + Amount int64 + // Stars field of MessageActionGiftStars. + Stars int64 + // CryptoCurrency field of MessageActionGiftStars. + // + // Use SetCryptoCurrency and GetCryptoCurrency helpers. + CryptoCurrency string + // CryptoAmount field of MessageActionGiftStars. + // + // Use SetCryptoAmount and GetCryptoAmount helpers. + CryptoAmount int64 + // TransactionID field of MessageActionGiftStars. + // + // Use SetTransactionID and GetTransactionID helpers. + TransactionID string +} + +// MessageActionGiftStarsTypeID is TL type id of MessageActionGiftStars. +const MessageActionGiftStarsTypeID = 0x45d5b021 + +// construct implements constructor of MessageActionClass. +func (m MessageActionGiftStars) construct() MessageActionClass { return &m } + +// Ensuring interfaces in compile-time for MessageActionGiftStars. +var ( + _ bin.Encoder = &MessageActionGiftStars{} + _ bin.Decoder = &MessageActionGiftStars{} + _ bin.BareEncoder = &MessageActionGiftStars{} + _ bin.BareDecoder = &MessageActionGiftStars{} + + _ MessageActionClass = &MessageActionGiftStars{} +) + +func (m *MessageActionGiftStars) Zero() bool { + if m == nil { + return true + } + if !(m.Flags.Zero()) { + return false + } + if !(m.Currency == "") { + return false + } + if !(m.Amount == 0) { + return false + } + if !(m.Stars == 0) { + return false + } + if !(m.CryptoCurrency == "") { + return false + } + if !(m.CryptoAmount == 0) { + return false + } + if !(m.TransactionID == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageActionGiftStars) String() string { + if m == nil { + return "MessageActionGiftStars(nil)" + } + type Alias MessageActionGiftStars + return fmt.Sprintf("MessageActionGiftStars%+v", Alias(*m)) +} + +// FillFrom fills MessageActionGiftStars from given interface. +func (m *MessageActionGiftStars) FillFrom(from interface { + GetCurrency() (value string) + GetAmount() (value int64) + GetStars() (value int64) + GetCryptoCurrency() (value string, ok bool) + GetCryptoAmount() (value int64, ok bool) + GetTransactionID() (value string, ok bool) +}) { + m.Currency = from.GetCurrency() + m.Amount = from.GetAmount() + m.Stars = from.GetStars() + if val, ok := from.GetCryptoCurrency(); ok { + m.CryptoCurrency = val + } + + if val, ok := from.GetCryptoAmount(); ok { + m.CryptoAmount = val + } + + if val, ok := from.GetTransactionID(); ok { + m.TransactionID = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageActionGiftStars) TypeID() uint32 { + return MessageActionGiftStarsTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageActionGiftStars) TypeName() string { + return "messageActionGiftStars" +} + +// TypeInfo returns info about TL type. +func (m *MessageActionGiftStars) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageActionGiftStars", + ID: MessageActionGiftStarsTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Currency", + SchemaName: "currency", + }, + { + Name: "Amount", + SchemaName: "amount", + }, + { + Name: "Stars", + SchemaName: "stars", + }, + { + Name: "CryptoCurrency", + SchemaName: "crypto_currency", + Null: !m.Flags.Has(0), + }, + { + Name: "CryptoAmount", + SchemaName: "crypto_amount", + Null: !m.Flags.Has(0), + }, + { + Name: "TransactionID", + SchemaName: "transaction_id", + Null: !m.Flags.Has(1), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (m *MessageActionGiftStars) SetFlags() { + if !(m.CryptoCurrency == "") { + m.Flags.Set(0) + } + if !(m.CryptoAmount == 0) { + m.Flags.Set(0) + } + if !(m.TransactionID == "") { + m.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (m *MessageActionGiftStars) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionGiftStars#45d5b021 as nil") + } + b.PutID(MessageActionGiftStarsTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageActionGiftStars) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionGiftStars#45d5b021 as nil") + } + m.SetFlags() + if err := m.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionGiftStars#45d5b021: field flags: %w", err) + } + b.PutString(m.Currency) + b.PutLong(m.Amount) + b.PutLong(m.Stars) + if m.Flags.Has(0) { + b.PutString(m.CryptoCurrency) + } + if m.Flags.Has(0) { + b.PutLong(m.CryptoAmount) + } + if m.Flags.Has(1) { + b.PutString(m.TransactionID) + } + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageActionGiftStars) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionGiftStars#45d5b021 to nil") + } + if err := b.ConsumeID(MessageActionGiftStarsTypeID); err != nil { + return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageActionGiftStars) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionGiftStars#45d5b021 to nil") + } + { + if err := m.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field flags: %w", err) + } + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field currency: %w", err) + } + m.Currency = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field amount: %w", err) + } + m.Amount = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field stars: %w", err) + } + m.Stars = value + } + if m.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field crypto_currency: %w", err) + } + m.CryptoCurrency = value + } + if m.Flags.Has(0) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field crypto_amount: %w", err) + } + m.CryptoAmount = value + } + if m.Flags.Has(1) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field transaction_id: %w", err) + } + m.TransactionID = value + } + return nil +} + +// GetCurrency returns value of Currency field. +func (m *MessageActionGiftStars) GetCurrency() (value string) { + if m == nil { + return + } + return m.Currency +} + +// GetAmount returns value of Amount field. +func (m *MessageActionGiftStars) GetAmount() (value int64) { + if m == nil { + return + } + return m.Amount +} + +// GetStars returns value of Stars field. +func (m *MessageActionGiftStars) GetStars() (value int64) { + if m == nil { + return + } + return m.Stars +} + +// SetCryptoCurrency sets value of CryptoCurrency conditional field. +func (m *MessageActionGiftStars) SetCryptoCurrency(value string) { + m.Flags.Set(0) + m.CryptoCurrency = value +} + +// GetCryptoCurrency returns value of CryptoCurrency conditional field and +// boolean which is true if field was set. +func (m *MessageActionGiftStars) GetCryptoCurrency() (value string, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(0) { + return value, false + } + return m.CryptoCurrency, true +} + +// SetCryptoAmount sets value of CryptoAmount conditional field. +func (m *MessageActionGiftStars) SetCryptoAmount(value int64) { + m.Flags.Set(0) + m.CryptoAmount = value +} + +// GetCryptoAmount returns value of CryptoAmount conditional field and +// boolean which is true if field was set. +func (m *MessageActionGiftStars) GetCryptoAmount() (value int64, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(0) { + return value, false + } + return m.CryptoAmount, true +} + +// SetTransactionID sets value of TransactionID conditional field. +func (m *MessageActionGiftStars) SetTransactionID(value string) { + m.Flags.Set(1) + m.TransactionID = value +} + +// GetTransactionID returns value of TransactionID conditional field and +// boolean which is true if field was set. +func (m *MessageActionGiftStars) GetTransactionID() (value string, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(1) { + return value, false + } + return m.TransactionID, true +} + // MessageActionClassName is schema name of MessageActionClass. const MessageActionClassName = "MessageAction" @@ -8355,6 +8705,7 @@ const MessageActionClassName = "MessageAction" // case *tg.MessageActionBoostApply: // messageActionBoostApply#cc02aa6d // case *tg.MessageActionRequestedPeerSentMe: // messageActionRequestedPeerSentMe#93b31848 // case *tg.MessageActionPaymentRefunded: // messageActionPaymentRefunded#41b3e202 +// case *tg.MessageActionGiftStars: // messageActionGiftStars#45d5b021 // default: panic(v) // } type MessageActionClass interface { @@ -8691,6 +9042,13 @@ func DecodeMessageAction(buf *bin.Buffer) (MessageActionClass, error) { return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) } return &v, nil + case MessageActionGiftStarsTypeID: + // Decoding messageActionGiftStars#45d5b021. + v := MessageActionGiftStars{} + 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 19107d527..5b6b4b752 100644 --- a/tg/tl_message_action_slices_gen.go +++ b/tg/tl_message_action_slices_gen.go @@ -584,6 +584,19 @@ func (s MessageActionClassArray) AsMessageActionPaymentRefunded() (to MessageAct return to } +// AsMessageActionGiftStars returns copy with only MessageActionGiftStars constructors. +func (s MessageActionClassArray) AsMessageActionGiftStars() (to MessageActionGiftStarsArray) { + for _, elem := range s { + value, ok := elem.(*MessageActionGiftStars) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // MessageActionChatCreateArray is adapter for slice of MessageActionChatCreate. type MessageActionChatCreateArray []MessageActionChatCreate @@ -3535,3 +3548,85 @@ func (s *MessageActionPaymentRefundedArray) Pop() (v MessageActionPaymentRefunde return v, true } + +// MessageActionGiftStarsArray is adapter for slice of MessageActionGiftStars. +type MessageActionGiftStarsArray []MessageActionGiftStars + +// Sort sorts slice of MessageActionGiftStars. +func (s MessageActionGiftStarsArray) Sort(less func(a, b MessageActionGiftStars) bool) MessageActionGiftStarsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessageActionGiftStars. +func (s MessageActionGiftStarsArray) SortStable(less func(a, b MessageActionGiftStars) bool) MessageActionGiftStarsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessageActionGiftStars. +func (s MessageActionGiftStarsArray) Retain(keep func(x MessageActionGiftStars) bool) MessageActionGiftStarsArray { + 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 MessageActionGiftStarsArray) First() (v MessageActionGiftStars, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessageActionGiftStarsArray) Last() (v MessageActionGiftStars, 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 *MessageActionGiftStarsArray) PopFirst() (v MessageActionGiftStars, 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 MessageActionGiftStars + 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 *MessageActionGiftStarsArray) Pop() (v MessageActionGiftStars, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_messages_request_main_web_view_gen.go b/tg/tl_messages_request_main_web_view_gen.go new file mode 100644 index 000000000..ad95d3b86 --- /dev/null +++ b/tg/tl_messages_request_main_web_view_gen.go @@ -0,0 +1,386 @@ +// 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{} +) + +// MessagesRequestMainWebViewRequest represents TL type `messages.requestMainWebView#c9e01e7b`. +// +// See https://core.telegram.org/method/messages.requestMainWebView for reference. +type MessagesRequestMainWebViewRequest struct { + // Flags field of MessagesRequestMainWebViewRequest. + Flags bin.Fields + // Compact field of MessagesRequestMainWebViewRequest. + Compact bool + // Peer field of MessagesRequestMainWebViewRequest. + Peer InputPeerClass + // Bot field of MessagesRequestMainWebViewRequest. + Bot InputUserClass + // StartParam field of MessagesRequestMainWebViewRequest. + // + // Use SetStartParam and GetStartParam helpers. + StartParam string + // ThemeParams field of MessagesRequestMainWebViewRequest. + // + // Use SetThemeParams and GetThemeParams helpers. + ThemeParams DataJSON + // Platform field of MessagesRequestMainWebViewRequest. + Platform string +} + +// MessagesRequestMainWebViewRequestTypeID is TL type id of MessagesRequestMainWebViewRequest. +const MessagesRequestMainWebViewRequestTypeID = 0xc9e01e7b + +// Ensuring interfaces in compile-time for MessagesRequestMainWebViewRequest. +var ( + _ bin.Encoder = &MessagesRequestMainWebViewRequest{} + _ bin.Decoder = &MessagesRequestMainWebViewRequest{} + _ bin.BareEncoder = &MessagesRequestMainWebViewRequest{} + _ bin.BareDecoder = &MessagesRequestMainWebViewRequest{} +) + +func (r *MessagesRequestMainWebViewRequest) Zero() bool { + if r == nil { + return true + } + if !(r.Flags.Zero()) { + return false + } + if !(r.Compact == false) { + return false + } + if !(r.Peer == nil) { + return false + } + if !(r.Bot == nil) { + return false + } + if !(r.StartParam == "") { + return false + } + if !(r.ThemeParams.Zero()) { + return false + } + if !(r.Platform == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *MessagesRequestMainWebViewRequest) String() string { + if r == nil { + return "MessagesRequestMainWebViewRequest(nil)" + } + type Alias MessagesRequestMainWebViewRequest + return fmt.Sprintf("MessagesRequestMainWebViewRequest%+v", Alias(*r)) +} + +// FillFrom fills MessagesRequestMainWebViewRequest from given interface. +func (r *MessagesRequestMainWebViewRequest) FillFrom(from interface { + GetCompact() (value bool) + GetPeer() (value InputPeerClass) + GetBot() (value InputUserClass) + GetStartParam() (value string, ok bool) + GetThemeParams() (value DataJSON, ok bool) + GetPlatform() (value string) +}) { + r.Compact = from.GetCompact() + r.Peer = from.GetPeer() + r.Bot = from.GetBot() + if val, ok := from.GetStartParam(); ok { + r.StartParam = val + } + + if val, ok := from.GetThemeParams(); ok { + r.ThemeParams = val + } + + r.Platform = from.GetPlatform() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesRequestMainWebViewRequest) TypeID() uint32 { + return MessagesRequestMainWebViewRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesRequestMainWebViewRequest) TypeName() string { + return "messages.requestMainWebView" +} + +// TypeInfo returns info about TL type. +func (r *MessagesRequestMainWebViewRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.requestMainWebView", + ID: MessagesRequestMainWebViewRequestTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Compact", + SchemaName: "compact", + Null: !r.Flags.Has(7), + }, + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "Bot", + SchemaName: "bot", + }, + { + Name: "StartParam", + SchemaName: "start_param", + Null: !r.Flags.Has(1), + }, + { + Name: "ThemeParams", + SchemaName: "theme_params", + Null: !r.Flags.Has(0), + }, + { + Name: "Platform", + SchemaName: "platform", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (r *MessagesRequestMainWebViewRequest) SetFlags() { + if !(r.Compact == false) { + r.Flags.Set(7) + } + if !(r.StartParam == "") { + r.Flags.Set(1) + } + if !(r.ThemeParams.Zero()) { + r.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (r *MessagesRequestMainWebViewRequest) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.requestMainWebView#c9e01e7b as nil") + } + b.PutID(MessagesRequestMainWebViewRequestTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *MessagesRequestMainWebViewRequest) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.requestMainWebView#c9e01e7b as nil") + } + r.SetFlags() + if err := r.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.requestMainWebView#c9e01e7b: field flags: %w", err) + } + if r.Peer == nil { + return fmt.Errorf("unable to encode messages.requestMainWebView#c9e01e7b: field peer is nil") + } + if err := r.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.requestMainWebView#c9e01e7b: field peer: %w", err) + } + if r.Bot == nil { + return fmt.Errorf("unable to encode messages.requestMainWebView#c9e01e7b: field bot is nil") + } + if err := r.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.requestMainWebView#c9e01e7b: field bot: %w", err) + } + if r.Flags.Has(1) { + b.PutString(r.StartParam) + } + if r.Flags.Has(0) { + if err := r.ThemeParams.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.requestMainWebView#c9e01e7b: field theme_params: %w", err) + } + } + b.PutString(r.Platform) + return nil +} + +// Decode implements bin.Decoder. +func (r *MessagesRequestMainWebViewRequest) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.requestMainWebView#c9e01e7b to nil") + } + if err := b.ConsumeID(MessagesRequestMainWebViewRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.requestMainWebView#c9e01e7b: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *MessagesRequestMainWebViewRequest) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.requestMainWebView#c9e01e7b to nil") + } + { + if err := r.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.requestMainWebView#c9e01e7b: field flags: %w", err) + } + } + r.Compact = r.Flags.Has(7) + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.requestMainWebView#c9e01e7b: field peer: %w", err) + } + r.Peer = value + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode messages.requestMainWebView#c9e01e7b: field bot: %w", err) + } + r.Bot = value + } + if r.Flags.Has(1) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messages.requestMainWebView#c9e01e7b: field start_param: %w", err) + } + r.StartParam = value + } + if r.Flags.Has(0) { + if err := r.ThemeParams.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.requestMainWebView#c9e01e7b: field theme_params: %w", err) + } + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messages.requestMainWebView#c9e01e7b: field platform: %w", err) + } + r.Platform = value + } + return nil +} + +// SetCompact sets value of Compact conditional field. +func (r *MessagesRequestMainWebViewRequest) SetCompact(value bool) { + if value { + r.Flags.Set(7) + r.Compact = true + } else { + r.Flags.Unset(7) + r.Compact = false + } +} + +// GetCompact returns value of Compact conditional field. +func (r *MessagesRequestMainWebViewRequest) GetCompact() (value bool) { + if r == nil { + return + } + return r.Flags.Has(7) +} + +// GetPeer returns value of Peer field. +func (r *MessagesRequestMainWebViewRequest) GetPeer() (value InputPeerClass) { + if r == nil { + return + } + return r.Peer +} + +// GetBot returns value of Bot field. +func (r *MessagesRequestMainWebViewRequest) GetBot() (value InputUserClass) { + if r == nil { + return + } + return r.Bot +} + +// SetStartParam sets value of StartParam conditional field. +func (r *MessagesRequestMainWebViewRequest) SetStartParam(value string) { + r.Flags.Set(1) + r.StartParam = value +} + +// GetStartParam returns value of StartParam conditional field and +// boolean which is true if field was set. +func (r *MessagesRequestMainWebViewRequest) GetStartParam() (value string, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(1) { + return value, false + } + return r.StartParam, true +} + +// SetThemeParams sets value of ThemeParams conditional field. +func (r *MessagesRequestMainWebViewRequest) SetThemeParams(value DataJSON) { + r.Flags.Set(0) + r.ThemeParams = value +} + +// GetThemeParams returns value of ThemeParams conditional field and +// boolean which is true if field was set. +func (r *MessagesRequestMainWebViewRequest) GetThemeParams() (value DataJSON, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(0) { + return value, false + } + return r.ThemeParams, true +} + +// GetPlatform returns value of Platform field. +func (r *MessagesRequestMainWebViewRequest) GetPlatform() (value string) { + if r == nil { + return + } + return r.Platform +} + +// MessagesRequestMainWebView invokes method messages.requestMainWebView#c9e01e7b returning error if any. +// +// See https://core.telegram.org/method/messages.requestMainWebView for reference. +func (c *Client) MessagesRequestMainWebView(ctx context.Context, request *MessagesRequestMainWebViewRequest) (*WebViewResultURL, error) { + var result WebViewResultURL + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_messages_request_main_web_view_slices_gen.go b/tg/tl_messages_request_main_web_view_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_messages_request_main_web_view_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_stars_gift_options_gen.go b/tg/tl_payments_get_stars_gift_options_gen.go new file mode 100644 index 000000000..99c031fd2 --- /dev/null +++ b/tg/tl_payments_get_stars_gift_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{} +) + +// PaymentsGetStarsGiftOptionsRequest represents TL type `payments.getStarsGiftOptions#d3c96bc8`. +// +// See https://core.telegram.org/method/payments.getStarsGiftOptions for reference. +type PaymentsGetStarsGiftOptionsRequest struct { + // Flags field of PaymentsGetStarsGiftOptionsRequest. + Flags bin.Fields + // UserID field of PaymentsGetStarsGiftOptionsRequest. + // + // Use SetUserID and GetUserID helpers. + UserID InputUserClass +} + +// PaymentsGetStarsGiftOptionsRequestTypeID is TL type id of PaymentsGetStarsGiftOptionsRequest. +const PaymentsGetStarsGiftOptionsRequestTypeID = 0xd3c96bc8 + +// Ensuring interfaces in compile-time for PaymentsGetStarsGiftOptionsRequest. +var ( + _ bin.Encoder = &PaymentsGetStarsGiftOptionsRequest{} + _ bin.Decoder = &PaymentsGetStarsGiftOptionsRequest{} + _ bin.BareEncoder = &PaymentsGetStarsGiftOptionsRequest{} + _ bin.BareDecoder = &PaymentsGetStarsGiftOptionsRequest{} +) + +func (g *PaymentsGetStarsGiftOptionsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Flags.Zero()) { + return false + } + if !(g.UserID == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGetStarsGiftOptionsRequest) String() string { + if g == nil { + return "PaymentsGetStarsGiftOptionsRequest(nil)" + } + type Alias PaymentsGetStarsGiftOptionsRequest + return fmt.Sprintf("PaymentsGetStarsGiftOptionsRequest%+v", Alias(*g)) +} + +// FillFrom fills PaymentsGetStarsGiftOptionsRequest from given interface. +func (g *PaymentsGetStarsGiftOptionsRequest) FillFrom(from interface { + GetUserID() (value InputUserClass, ok bool) +}) { + if val, ok := from.GetUserID(); ok { + g.UserID = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsGetStarsGiftOptionsRequest) TypeID() uint32 { + return PaymentsGetStarsGiftOptionsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGetStarsGiftOptionsRequest) TypeName() string { + return "payments.getStarsGiftOptions" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGetStarsGiftOptionsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.getStarsGiftOptions", + ID: PaymentsGetStarsGiftOptionsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + Null: !g.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (g *PaymentsGetStarsGiftOptionsRequest) SetFlags() { + if !(g.UserID == nil) { + g.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (g *PaymentsGetStarsGiftOptionsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getStarsGiftOptions#d3c96bc8 as nil") + } + b.PutID(PaymentsGetStarsGiftOptionsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGetStarsGiftOptionsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getStarsGiftOptions#d3c96bc8 as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getStarsGiftOptions#d3c96bc8: field flags: %w", err) + } + if g.Flags.Has(0) { + if g.UserID == nil { + return fmt.Errorf("unable to encode payments.getStarsGiftOptions#d3c96bc8: field user_id is nil") + } + if err := g.UserID.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getStarsGiftOptions#d3c96bc8: field user_id: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGetStarsGiftOptionsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getStarsGiftOptions#d3c96bc8 to nil") + } + if err := b.ConsumeID(PaymentsGetStarsGiftOptionsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.getStarsGiftOptions#d3c96bc8: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGetStarsGiftOptionsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getStarsGiftOptions#d3c96bc8 to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.getStarsGiftOptions#d3c96bc8: field flags: %w", err) + } + } + if g.Flags.Has(0) { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode payments.getStarsGiftOptions#d3c96bc8: field user_id: %w", err) + } + g.UserID = value + } + return nil +} + +// SetUserID sets value of UserID conditional field. +func (g *PaymentsGetStarsGiftOptionsRequest) SetUserID(value InputUserClass) { + g.Flags.Set(0) + g.UserID = value +} + +// GetUserID returns value of UserID conditional field and +// boolean which is true if field was set. +func (g *PaymentsGetStarsGiftOptionsRequest) GetUserID() (value InputUserClass, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(0) { + return value, false + } + return g.UserID, true +} + +// PaymentsGetStarsGiftOptions invokes method payments.getStarsGiftOptions#d3c96bc8 returning error if any. +// +// See https://core.telegram.org/method/payments.getStarsGiftOptions for reference. +func (c *Client) PaymentsGetStarsGiftOptions(ctx context.Context, request *PaymentsGetStarsGiftOptionsRequest) ([]StarsGiftOption, error) { + var result StarsGiftOptionVector + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return []StarsGiftOption(result.Elems), nil +} diff --git a/tg/tl_payments_get_stars_gift_options_slices_gen.go b/tg/tl_payments_get_stars_gift_options_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_payments_get_stars_gift_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_registry_gen.go b/tg/tl_registry_gen.go index c1c78c3f9..e18121e8d 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 184 +const Layer = 185 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -105,7 +105,7 @@ func TypesMap() map[uint32]string { StorageFileMp4TypeID: "storage.fileMp4#b3cea0e4", StorageFileWebpTypeID: "storage.fileWebp#1081464c", UserEmptyTypeID: "userEmpty#d3bc4b7a", - UserTypeID: "user#215c4438", + UserTypeID: "user#83314fca", UserProfilePhotoEmptyTypeID: "userProfilePhotoEmpty#4f11bae1", UserProfilePhotoTypeID: "userProfilePhoto#82d1f706", UserStatusEmptyTypeID: "userStatusEmpty#9d05049", @@ -192,6 +192,7 @@ func TypesMap() map[uint32]string { MessageActionBoostApplyTypeID: "messageActionBoostApply#cc02aa6d", MessageActionRequestedPeerSentMeTypeID: "messageActionRequestedPeerSentMe#93b31848", MessageActionPaymentRefundedTypeID: "messageActionPaymentRefunded#41b3e202", + MessageActionGiftStarsTypeID: "messageActionGiftStars#45d5b021", DialogTypeID: "dialog#d58a08c6", DialogFolderTypeID: "dialogFolder#71bd134c", PhotoEmptyTypeID: "photoEmpty#2331b22d", @@ -522,7 +523,7 @@ func TypesMap() map[uint32]string { DocumentAttributeImageSizeTypeID: "documentAttributeImageSize#6c37c15c", DocumentAttributeAnimatedTypeID: "documentAttributeAnimated#11b58939", DocumentAttributeStickerTypeID: "documentAttributeSticker#6319d612", - DocumentAttributeVideoTypeID: "documentAttributeVideo#d38ff1c2", + DocumentAttributeVideoTypeID: "documentAttributeVideo#17399fad", DocumentAttributeAudioTypeID: "documentAttributeAudio#9852f9c6", DocumentAttributeFilenameTypeID: "documentAttributeFilename#15590068", DocumentAttributeHasStickersTypeID: "documentAttributeHasStickers#9801d2f7", @@ -693,6 +694,7 @@ func TypesMap() map[uint32]string { TopPeerCategoryPhoneCallsTypeID: "topPeerCategoryPhoneCalls#1e76a78c", TopPeerCategoryForwardUsersTypeID: "topPeerCategoryForwardUsers#a8406ca9", TopPeerCategoryForwardChatsTypeID: "topPeerCategoryForwardChats#fbeec0f0", + TopPeerCategoryBotsAppTypeID: "topPeerCategoryBotsApp#fd9e7bec", TopPeerCategoryPeersTypeID: "topPeerCategoryPeers#fb834291", ContactsTopPeersNotModifiedTypeID: "contacts.topPeersNotModified#de266ef5", ContactsTopPeersTypeID: "contacts.topPeers#70b772a8", @@ -1140,7 +1142,7 @@ func TypesMap() map[uint32]string { InputInvoiceMessageTypeID: "inputInvoiceMessage#c5b56859", InputInvoiceSlugTypeID: "inputInvoiceSlug#c326caef", InputInvoicePremiumGiftCodeTypeID: "inputInvoicePremiumGiftCode#98986c0d", - InputInvoiceStarsTypeID: "inputInvoiceStars#1da33ad8", + InputInvoiceStarsTypeID: "inputInvoiceStars#65f00ce3", PaymentsExportedInvoiceTypeID: "payments.exportedInvoice#aed0cbd9", MessagesTranscribedAudioTypeID: "messages.transcribedAudio#cfb9d957", HelpPremiumPromoTypeID: "help.premiumPromo#5334759c", @@ -1148,7 +1150,8 @@ func TypesMap() map[uint32]string { InputStorePaymentGiftPremiumTypeID: "inputStorePaymentGiftPremium#616f7fe8", InputStorePaymentPremiumGiftCodeTypeID: "inputStorePaymentPremiumGiftCode#a3805f3f", InputStorePaymentPremiumGiveawayTypeID: "inputStorePaymentPremiumGiveaway#160544ca", - InputStorePaymentStarsTypeID: "inputStorePaymentStars#4f0ee8df", + InputStorePaymentStarsTopupTypeID: "inputStorePaymentStarsTopup#dddd0f56", + InputStorePaymentStarsGiftTypeID: "inputStorePaymentStarsGift#1d741ef7", PremiumGiftOptionTypeID: "premiumGiftOption#74c34319", PaymentFormMethodTypeID: "paymentFormMethod#88f8f21b", EmojiStatusEmptyTypeID: "emojiStatusEmpty#2de11aae", @@ -1242,6 +1245,7 @@ func TypesMap() map[uint32]string { MediaAreaChannelPostTypeID: "mediaAreaChannelPost#770416af", InputMediaAreaChannelPostTypeID: "inputMediaAreaChannelPost#2271f2bf", MediaAreaURLTypeID: "mediaAreaUrl#37381085", + MediaAreaWeatherTypeID: "mediaAreaWeather#49a6549c", PeerStoriesTypeID: "peerStories#9a35e999", StoriesPeerStoriesTypeID: "stories.peerStories#cae68768", MessagesWebPageTypeID: "messages.webPage#fd5e12bd", @@ -1363,6 +1367,10 @@ func TypesMap() map[uint32]string { PaymentsStarsRevenueWithdrawalURLTypeID: "payments.starsRevenueWithdrawalUrl#1dab80b7", PaymentsStarsRevenueAdsAccountURLTypeID: "payments.starsRevenueAdsAccountUrl#394e7f21", InputStarsTransactionTypeID: "inputStarsTransaction#206ae6d1", + StarsGiftOptionTypeID: "starsGiftOption#5e0589f1", + BotsPopularAppBotsTypeID: "bots.popularAppBots#1991b13b", + BotPreviewMediaTypeID: "botPreviewMedia#23e91ba3", + BotsPreviewInfoTypeID: "bots.previewInfo#ca71d64", InvokeAfterMsgRequestTypeID: "invokeAfterMsg#cb9f372d", InvokeAfterMsgsRequestTypeID: "invokeAfterMsgs#3dc4b4f0", InitConnectionRequestTypeID: "initConnection#c1cd5ea9", @@ -1751,6 +1759,7 @@ func TypesMap() map[uint32]string { MessagesEditFactCheckRequestTypeID: "messages.editFactCheck#589ee75", MessagesDeleteFactCheckRequestTypeID: "messages.deleteFactCheck#d1da940c", MessagesGetFactCheckRequestTypeID: "messages.getFactCheck#b9cdc5ee", + MessagesRequestMainWebViewRequestTypeID: "messages.requestMainWebView#c9e01e7b", UpdatesGetStateRequestTypeID: "updates.getState#edd4882a", UpdatesGetDifferenceRequestTypeID: "updates.getDifference#19c2f763", UpdatesGetChannelDifferenceRequestTypeID: "updates.getChannelDifference#3173d78", @@ -1873,6 +1882,13 @@ func TypesMap() map[uint32]string { BotsCanSendMessageRequestTypeID: "bots.canSendMessage#1359f4e6", BotsAllowSendMessageRequestTypeID: "bots.allowSendMessage#f132e3ef", BotsInvokeWebViewCustomMethodRequestTypeID: "bots.invokeWebViewCustomMethod#87fc5e7", + BotsGetPopularAppBotsRequestTypeID: "bots.getPopularAppBots#c2510192", + BotsAddPreviewMediaRequestTypeID: "bots.addPreviewMedia#17aeb75a", + BotsEditPreviewMediaRequestTypeID: "bots.editPreviewMedia#8525606f", + BotsDeletePreviewMediaRequestTypeID: "bots.deletePreviewMedia#2d0135b3", + BotsReorderPreviewMediasRequestTypeID: "bots.reorderPreviewMedias#b627f3aa", + BotsGetPreviewInfoRequestTypeID: "bots.getPreviewInfo#423ab3ad", + BotsGetPreviewMediasRequestTypeID: "bots.getPreviewMedias#a2a5594d", PaymentsGetPaymentFormRequestTypeID: "payments.getPaymentForm#37148dbb", PaymentsGetPaymentReceiptRequestTypeID: "payments.getPaymentReceipt#2478d1cc", PaymentsValidateRequestedInfoRequestTypeID: "payments.validateRequestedInfo#b6c8f12b", @@ -1898,6 +1914,7 @@ func TypesMap() map[uint32]string { PaymentsGetStarsRevenueWithdrawalURLRequestTypeID: "payments.getStarsRevenueWithdrawalUrl#13bbe8b3", PaymentsGetStarsRevenueAdsAccountURLRequestTypeID: "payments.getStarsRevenueAdsAccountUrl#d1d7efc5", PaymentsGetStarsTransactionsByIDRequestTypeID: "payments.getStarsTransactionsByID#27842d2e", + PaymentsGetStarsGiftOptionsRequestTypeID: "payments.getStarsGiftOptions#d3c96bc8", StickersCreateStickerSetRequestTypeID: "stickers.createStickerSet#9021ab67", StickersRemoveStickerFromSetRequestTypeID: "stickers.removeStickerFromSet#f7760f51", StickersChangeStickerPositionRequestTypeID: "stickers.changeStickerPosition#ffb6d4ca", @@ -2180,6 +2197,7 @@ func NamesMap() map[string]uint32 { "messageActionBoostApply": MessageActionBoostApplyTypeID, "messageActionRequestedPeerSentMe": MessageActionRequestedPeerSentMeTypeID, "messageActionPaymentRefunded": MessageActionPaymentRefundedTypeID, + "messageActionGiftStars": MessageActionGiftStarsTypeID, "dialog": DialogTypeID, "dialogFolder": DialogFolderTypeID, "photoEmpty": PhotoEmptyTypeID, @@ -2681,6 +2699,7 @@ func NamesMap() map[string]uint32 { "topPeerCategoryPhoneCalls": TopPeerCategoryPhoneCallsTypeID, "topPeerCategoryForwardUsers": TopPeerCategoryForwardUsersTypeID, "topPeerCategoryForwardChats": TopPeerCategoryForwardChatsTypeID, + "topPeerCategoryBotsApp": TopPeerCategoryBotsAppTypeID, "topPeerCategoryPeers": TopPeerCategoryPeersTypeID, "contacts.topPeersNotModified": ContactsTopPeersNotModifiedTypeID, "contacts.topPeers": ContactsTopPeersTypeID, @@ -3136,7 +3155,8 @@ func NamesMap() map[string]uint32 { "inputStorePaymentGiftPremium": InputStorePaymentGiftPremiumTypeID, "inputStorePaymentPremiumGiftCode": InputStorePaymentPremiumGiftCodeTypeID, "inputStorePaymentPremiumGiveaway": InputStorePaymentPremiumGiveawayTypeID, - "inputStorePaymentStars": InputStorePaymentStarsTypeID, + "inputStorePaymentStarsTopup": InputStorePaymentStarsTopupTypeID, + "inputStorePaymentStarsGift": InputStorePaymentStarsGiftTypeID, "premiumGiftOption": PremiumGiftOptionTypeID, "paymentFormMethod": PaymentFormMethodTypeID, "emojiStatusEmpty": EmojiStatusEmptyTypeID, @@ -3230,6 +3250,7 @@ func NamesMap() map[string]uint32 { "mediaAreaChannelPost": MediaAreaChannelPostTypeID, "inputMediaAreaChannelPost": InputMediaAreaChannelPostTypeID, "mediaAreaUrl": MediaAreaURLTypeID, + "mediaAreaWeather": MediaAreaWeatherTypeID, "peerStories": PeerStoriesTypeID, "stories.peerStories": StoriesPeerStoriesTypeID, "messages.webPage": MessagesWebPageTypeID, @@ -3351,6 +3372,10 @@ func NamesMap() map[string]uint32 { "payments.starsRevenueWithdrawalUrl": PaymentsStarsRevenueWithdrawalURLTypeID, "payments.starsRevenueAdsAccountUrl": PaymentsStarsRevenueAdsAccountURLTypeID, "inputStarsTransaction": InputStarsTransactionTypeID, + "starsGiftOption": StarsGiftOptionTypeID, + "bots.popularAppBots": BotsPopularAppBotsTypeID, + "botPreviewMedia": BotPreviewMediaTypeID, + "bots.previewInfo": BotsPreviewInfoTypeID, "invokeAfterMsg": InvokeAfterMsgRequestTypeID, "invokeAfterMsgs": InvokeAfterMsgsRequestTypeID, "initConnection": InitConnectionRequestTypeID, @@ -3739,6 +3764,7 @@ func NamesMap() map[string]uint32 { "messages.editFactCheck": MessagesEditFactCheckRequestTypeID, "messages.deleteFactCheck": MessagesDeleteFactCheckRequestTypeID, "messages.getFactCheck": MessagesGetFactCheckRequestTypeID, + "messages.requestMainWebView": MessagesRequestMainWebViewRequestTypeID, "updates.getState": UpdatesGetStateRequestTypeID, "updates.getDifference": UpdatesGetDifferenceRequestTypeID, "updates.getChannelDifference": UpdatesGetChannelDifferenceRequestTypeID, @@ -3861,6 +3887,13 @@ func NamesMap() map[string]uint32 { "bots.canSendMessage": BotsCanSendMessageRequestTypeID, "bots.allowSendMessage": BotsAllowSendMessageRequestTypeID, "bots.invokeWebViewCustomMethod": BotsInvokeWebViewCustomMethodRequestTypeID, + "bots.getPopularAppBots": BotsGetPopularAppBotsRequestTypeID, + "bots.addPreviewMedia": BotsAddPreviewMediaRequestTypeID, + "bots.editPreviewMedia": BotsEditPreviewMediaRequestTypeID, + "bots.deletePreviewMedia": BotsDeletePreviewMediaRequestTypeID, + "bots.reorderPreviewMedias": BotsReorderPreviewMediasRequestTypeID, + "bots.getPreviewInfo": BotsGetPreviewInfoRequestTypeID, + "bots.getPreviewMedias": BotsGetPreviewMediasRequestTypeID, "payments.getPaymentForm": PaymentsGetPaymentFormRequestTypeID, "payments.getPaymentReceipt": PaymentsGetPaymentReceiptRequestTypeID, "payments.validateRequestedInfo": PaymentsValidateRequestedInfoRequestTypeID, @@ -3886,6 +3919,7 @@ func NamesMap() map[string]uint32 { "payments.getStarsRevenueWithdrawalUrl": PaymentsGetStarsRevenueWithdrawalURLRequestTypeID, "payments.getStarsRevenueAdsAccountUrl": PaymentsGetStarsRevenueAdsAccountURLRequestTypeID, "payments.getStarsTransactionsByID": PaymentsGetStarsTransactionsByIDRequestTypeID, + "payments.getStarsGiftOptions": PaymentsGetStarsGiftOptionsRequestTypeID, "stickers.createStickerSet": StickersCreateStickerSetRequestTypeID, "stickers.removeStickerFromSet": StickersRemoveStickerFromSetRequestTypeID, "stickers.changeStickerPosition": StickersChangeStickerPositionRequestTypeID, @@ -4168,6 +4202,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessageActionBoostApplyTypeID: func() bin.Object { return &MessageActionBoostApply{} }, MessageActionRequestedPeerSentMeTypeID: func() bin.Object { return &MessageActionRequestedPeerSentMe{} }, MessageActionPaymentRefundedTypeID: func() bin.Object { return &MessageActionPaymentRefunded{} }, + MessageActionGiftStarsTypeID: func() bin.Object { return &MessageActionGiftStars{} }, DialogTypeID: func() bin.Object { return &Dialog{} }, DialogFolderTypeID: func() bin.Object { return &DialogFolder{} }, PhotoEmptyTypeID: func() bin.Object { return &PhotoEmpty{} }, @@ -4669,6 +4704,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { TopPeerCategoryPhoneCallsTypeID: func() bin.Object { return &TopPeerCategoryPhoneCalls{} }, TopPeerCategoryForwardUsersTypeID: func() bin.Object { return &TopPeerCategoryForwardUsers{} }, TopPeerCategoryForwardChatsTypeID: func() bin.Object { return &TopPeerCategoryForwardChats{} }, + TopPeerCategoryBotsAppTypeID: func() bin.Object { return &TopPeerCategoryBotsApp{} }, TopPeerCategoryPeersTypeID: func() bin.Object { return &TopPeerCategoryPeers{} }, ContactsTopPeersNotModifiedTypeID: func() bin.Object { return &ContactsTopPeersNotModified{} }, ContactsTopPeersTypeID: func() bin.Object { return &ContactsTopPeers{} }, @@ -5124,7 +5160,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputStorePaymentGiftPremiumTypeID: func() bin.Object { return &InputStorePaymentGiftPremium{} }, InputStorePaymentPremiumGiftCodeTypeID: func() bin.Object { return &InputStorePaymentPremiumGiftCode{} }, InputStorePaymentPremiumGiveawayTypeID: func() bin.Object { return &InputStorePaymentPremiumGiveaway{} }, - InputStorePaymentStarsTypeID: func() bin.Object { return &InputStorePaymentStars{} }, + InputStorePaymentStarsTopupTypeID: func() bin.Object { return &InputStorePaymentStarsTopup{} }, + InputStorePaymentStarsGiftTypeID: func() bin.Object { return &InputStorePaymentStarsGift{} }, PremiumGiftOptionTypeID: func() bin.Object { return &PremiumGiftOption{} }, PaymentFormMethodTypeID: func() bin.Object { return &PaymentFormMethod{} }, EmojiStatusEmptyTypeID: func() bin.Object { return &EmojiStatusEmpty{} }, @@ -5218,6 +5255,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MediaAreaChannelPostTypeID: func() bin.Object { return &MediaAreaChannelPost{} }, InputMediaAreaChannelPostTypeID: func() bin.Object { return &InputMediaAreaChannelPost{} }, MediaAreaURLTypeID: func() bin.Object { return &MediaAreaURL{} }, + MediaAreaWeatherTypeID: func() bin.Object { return &MediaAreaWeather{} }, PeerStoriesTypeID: func() bin.Object { return &PeerStories{} }, StoriesPeerStoriesTypeID: func() bin.Object { return &StoriesPeerStories{} }, MessagesWebPageTypeID: func() bin.Object { return &MessagesWebPage{} }, @@ -5339,6 +5377,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { PaymentsStarsRevenueWithdrawalURLTypeID: func() bin.Object { return &PaymentsStarsRevenueWithdrawalURL{} }, PaymentsStarsRevenueAdsAccountURLTypeID: func() bin.Object { return &PaymentsStarsRevenueAdsAccountURL{} }, InputStarsTransactionTypeID: func() bin.Object { return &InputStarsTransaction{} }, + StarsGiftOptionTypeID: func() bin.Object { return &StarsGiftOption{} }, + BotsPopularAppBotsTypeID: func() bin.Object { return &BotsPopularAppBots{} }, + BotPreviewMediaTypeID: func() bin.Object { return &BotPreviewMedia{} }, + BotsPreviewInfoTypeID: func() bin.Object { return &BotsPreviewInfo{} }, InvokeAfterMsgRequestTypeID: func() bin.Object { return &InvokeAfterMsgRequest{} }, InvokeAfterMsgsRequestTypeID: func() bin.Object { return &InvokeAfterMsgsRequest{} }, InitConnectionRequestTypeID: func() bin.Object { return &InitConnectionRequest{} }, @@ -5727,6 +5769,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessagesEditFactCheckRequestTypeID: func() bin.Object { return &MessagesEditFactCheckRequest{} }, MessagesDeleteFactCheckRequestTypeID: func() bin.Object { return &MessagesDeleteFactCheckRequest{} }, MessagesGetFactCheckRequestTypeID: func() bin.Object { return &MessagesGetFactCheckRequest{} }, + MessagesRequestMainWebViewRequestTypeID: func() bin.Object { return &MessagesRequestMainWebViewRequest{} }, UpdatesGetStateRequestTypeID: func() bin.Object { return &UpdatesGetStateRequest{} }, UpdatesGetDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetDifferenceRequest{} }, UpdatesGetChannelDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetChannelDifferenceRequest{} }, @@ -5849,6 +5892,13 @@ func TypesConstructorMap() map[uint32]func() bin.Object { BotsCanSendMessageRequestTypeID: func() bin.Object { return &BotsCanSendMessageRequest{} }, BotsAllowSendMessageRequestTypeID: func() bin.Object { return &BotsAllowSendMessageRequest{} }, BotsInvokeWebViewCustomMethodRequestTypeID: func() bin.Object { return &BotsInvokeWebViewCustomMethodRequest{} }, + BotsGetPopularAppBotsRequestTypeID: func() bin.Object { return &BotsGetPopularAppBotsRequest{} }, + BotsAddPreviewMediaRequestTypeID: func() bin.Object { return &BotsAddPreviewMediaRequest{} }, + BotsEditPreviewMediaRequestTypeID: func() bin.Object { return &BotsEditPreviewMediaRequest{} }, + BotsDeletePreviewMediaRequestTypeID: func() bin.Object { return &BotsDeletePreviewMediaRequest{} }, + BotsReorderPreviewMediasRequestTypeID: func() bin.Object { return &BotsReorderPreviewMediasRequest{} }, + BotsGetPreviewInfoRequestTypeID: func() bin.Object { return &BotsGetPreviewInfoRequest{} }, + BotsGetPreviewMediasRequestTypeID: func() bin.Object { return &BotsGetPreviewMediasRequest{} }, PaymentsGetPaymentFormRequestTypeID: func() bin.Object { return &PaymentsGetPaymentFormRequest{} }, PaymentsGetPaymentReceiptRequestTypeID: func() bin.Object { return &PaymentsGetPaymentReceiptRequest{} }, PaymentsValidateRequestedInfoRequestTypeID: func() bin.Object { return &PaymentsValidateRequestedInfoRequest{} }, @@ -5874,6 +5924,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { PaymentsGetStarsRevenueWithdrawalURLRequestTypeID: func() bin.Object { return &PaymentsGetStarsRevenueWithdrawalURLRequest{} }, PaymentsGetStarsRevenueAdsAccountURLRequestTypeID: func() bin.Object { return &PaymentsGetStarsRevenueAdsAccountURLRequest{} }, PaymentsGetStarsTransactionsByIDRequestTypeID: func() bin.Object { return &PaymentsGetStarsTransactionsByIDRequest{} }, + PaymentsGetStarsGiftOptionsRequestTypeID: func() bin.Object { return &PaymentsGetStarsGiftOptionsRequest{} }, StickersCreateStickerSetRequestTypeID: func() bin.Object { return &StickersCreateStickerSetRequest{} }, StickersRemoveStickerFromSetRequestTypeID: func() bin.Object { return &StickersRemoveStickerFromSetRequest{} }, StickersChangeStickerPositionRequestTypeID: func() bin.Object { return &StickersChangeStickerPositionRequest{} }, @@ -6607,7 +6658,8 @@ func ClassConstructorsMap() map[string][]uint32 { InputStorePaymentGiftPremiumTypeID, InputStorePaymentPremiumGiftCodeTypeID, InputStorePaymentPremiumGiveawayTypeID, - InputStorePaymentStarsTypeID, + InputStorePaymentStarsTopupTypeID, + InputStorePaymentStarsGiftTypeID, }, InputThemeClassName: { InputThemeTypeID, @@ -6669,6 +6721,7 @@ func ClassConstructorsMap() map[string][]uint32 { MediaAreaChannelPostTypeID, InputMediaAreaChannelPostTypeID, MediaAreaURLTypeID, + MediaAreaWeatherTypeID, }, MessageActionClassName: { MessageActionEmptyTypeID, @@ -6715,6 +6768,7 @@ func ClassConstructorsMap() map[string][]uint32 { MessageActionBoostApplyTypeID, MessageActionRequestedPeerSentMeTypeID, MessageActionPaymentRefundedTypeID, + MessageActionGiftStarsTypeID, }, MessageClassName: { MessageEmptyTypeID, @@ -7224,6 +7278,7 @@ func ClassConstructorsMap() map[string][]uint32 { TopPeerCategoryPhoneCallsTypeID, TopPeerCategoryForwardUsersTypeID, TopPeerCategoryForwardChatsTypeID, + TopPeerCategoryBotsAppTypeID, }, URLAuthResultClassName: { URLAuthResultRequestTypeID, diff --git a/tg/tl_server_gen.go b/tg/tl_server_gen.go index 56ce5ad97..8704228d1 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -6975,6 +6975,23 @@ func (s *ServerDispatcher) OnMessagesGetFactCheck(f func(ctx context.Context, re s.handlers[MessagesGetFactCheckRequestTypeID] = handler } +func (s *ServerDispatcher) OnMessagesRequestMainWebView(f func(ctx context.Context, request *MessagesRequestMainWebViewRequest) (*WebViewResultURL, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesRequestMainWebViewRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[MessagesRequestMainWebViewRequestTypeID] = handler +} + func (s *ServerDispatcher) OnUpdatesGetState(f func(ctx context.Context) (*UpdatesState, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request UpdatesGetStateRequest @@ -9177,6 +9194,133 @@ func (s *ServerDispatcher) OnBotsInvokeWebViewCustomMethod(f func(ctx context.Co s.handlers[BotsInvokeWebViewCustomMethodRequestTypeID] = handler } +func (s *ServerDispatcher) OnBotsGetPopularAppBots(f func(ctx context.Context, request *BotsGetPopularAppBotsRequest) (*BotsPopularAppBots, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request BotsGetPopularAppBotsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[BotsGetPopularAppBotsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnBotsAddPreviewMedia(f func(ctx context.Context, request *BotsAddPreviewMediaRequest) (*BotPreviewMedia, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request BotsAddPreviewMediaRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[BotsAddPreviewMediaRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnBotsEditPreviewMedia(f func(ctx context.Context, request *BotsEditPreviewMediaRequest) (*BotPreviewMedia, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request BotsEditPreviewMediaRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[BotsEditPreviewMediaRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnBotsDeletePreviewMedia(f func(ctx context.Context, request *BotsDeletePreviewMediaRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request BotsDeletePreviewMediaRequest + 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[BotsDeletePreviewMediaRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnBotsReorderPreviewMedias(f func(ctx context.Context, request *BotsReorderPreviewMediasRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request BotsReorderPreviewMediasRequest + 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[BotsReorderPreviewMediasRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnBotsGetPreviewInfo(f func(ctx context.Context, request *BotsGetPreviewInfoRequest) (*BotsPreviewInfo, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request BotsGetPreviewInfoRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[BotsGetPreviewInfoRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnBotsGetPreviewMedias(f func(ctx context.Context, bot InputUserClass) ([]BotPreviewMedia, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request BotsGetPreviewMediasRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Bot) + if err != nil { + return nil, err + } + return &BotPreviewMediaVector{Elems: response}, nil + } + + s.handlers[BotsGetPreviewMediasRequestTypeID] = handler +} + func (s *ServerDispatcher) OnPaymentsGetPaymentForm(f func(ctx context.Context, request *PaymentsGetPaymentFormRequest) (PaymentsPaymentFormClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request PaymentsGetPaymentFormRequest @@ -9610,6 +9754,23 @@ func (s *ServerDispatcher) OnPaymentsGetStarsTransactionsByID(f func(ctx context s.handlers[PaymentsGetStarsTransactionsByIDRequestTypeID] = handler } +func (s *ServerDispatcher) OnPaymentsGetStarsGiftOptions(f func(ctx context.Context, request *PaymentsGetStarsGiftOptionsRequest) ([]StarsGiftOption, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsGetStarsGiftOptionsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &StarsGiftOptionVector{Elems: response}, nil + } + + s.handlers[PaymentsGetStarsGiftOptionsRequestTypeID] = handler +} + func (s *ServerDispatcher) OnStickersCreateStickerSet(f func(ctx context.Context, request *StickersCreateStickerSetRequest) (MessagesStickerSetClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request StickersCreateStickerSetRequest diff --git a/tg/tl_stars_gift_option_gen.go b/tg/tl_stars_gift_option_gen.go new file mode 100644 index 000000000..d01542e89 --- /dev/null +++ b/tg/tl_stars_gift_option_gen.go @@ -0,0 +1,316 @@ +// 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{} +) + +// StarsGiftOption represents TL type `starsGiftOption#5e0589f1`. +// +// See https://core.telegram.org/constructor/starsGiftOption for reference. +type StarsGiftOption struct { + // Flags field of StarsGiftOption. + Flags bin.Fields + // Extended field of StarsGiftOption. + Extended bool + // Stars field of StarsGiftOption. + Stars int64 + // StoreProduct field of StarsGiftOption. + // + // Use SetStoreProduct and GetStoreProduct helpers. + StoreProduct string + // Currency field of StarsGiftOption. + Currency string + // Amount field of StarsGiftOption. + Amount int64 +} + +// StarsGiftOptionTypeID is TL type id of StarsGiftOption. +const StarsGiftOptionTypeID = 0x5e0589f1 + +// Ensuring interfaces in compile-time for StarsGiftOption. +var ( + _ bin.Encoder = &StarsGiftOption{} + _ bin.Decoder = &StarsGiftOption{} + _ bin.BareEncoder = &StarsGiftOption{} + _ bin.BareDecoder = &StarsGiftOption{} +) + +func (s *StarsGiftOption) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.Extended == false) { + return false + } + if !(s.Stars == 0) { + return false + } + if !(s.StoreProduct == "") { + return false + } + if !(s.Currency == "") { + return false + } + if !(s.Amount == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarsGiftOption) String() string { + if s == nil { + return "StarsGiftOption(nil)" + } + type Alias StarsGiftOption + return fmt.Sprintf("StarsGiftOption%+v", Alias(*s)) +} + +// FillFrom fills StarsGiftOption from given interface. +func (s *StarsGiftOption) FillFrom(from interface { + GetExtended() (value bool) + GetStars() (value int64) + GetStoreProduct() (value string, ok bool) + GetCurrency() (value string) + GetAmount() (value int64) +}) { + s.Extended = from.GetExtended() + s.Stars = from.GetStars() + if val, ok := from.GetStoreProduct(); ok { + s.StoreProduct = val + } + + s.Currency = from.GetCurrency() + s.Amount = from.GetAmount() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsGiftOption) TypeID() uint32 { + return StarsGiftOptionTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsGiftOption) TypeName() string { + return "starsGiftOption" +} + +// TypeInfo returns info about TL type. +func (s *StarsGiftOption) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starsGiftOption", + ID: StarsGiftOptionTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Extended", + SchemaName: "extended", + Null: !s.Flags.Has(1), + }, + { + Name: "Stars", + SchemaName: "stars", + }, + { + Name: "StoreProduct", + SchemaName: "store_product", + Null: !s.Flags.Has(0), + }, + { + Name: "Currency", + SchemaName: "currency", + }, + { + Name: "Amount", + SchemaName: "amount", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *StarsGiftOption) SetFlags() { + if !(s.Extended == false) { + s.Flags.Set(1) + } + if !(s.StoreProduct == "") { + s.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (s *StarsGiftOption) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsGiftOption#5e0589f1 as nil") + } + b.PutID(StarsGiftOptionTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarsGiftOption) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsGiftOption#5e0589f1 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsGiftOption#5e0589f1: field flags: %w", err) + } + b.PutLong(s.Stars) + if s.Flags.Has(0) { + b.PutString(s.StoreProduct) + } + b.PutString(s.Currency) + b.PutLong(s.Amount) + return nil +} + +// Decode implements bin.Decoder. +func (s *StarsGiftOption) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsGiftOption#5e0589f1 to nil") + } + if err := b.ConsumeID(StarsGiftOptionTypeID); err != nil { + return fmt.Errorf("unable to decode starsGiftOption#5e0589f1: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarsGiftOption) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsGiftOption#5e0589f1 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode starsGiftOption#5e0589f1: field flags: %w", err) + } + } + s.Extended = s.Flags.Has(1) + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode starsGiftOption#5e0589f1: field stars: %w", err) + } + s.Stars = value + } + if s.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode starsGiftOption#5e0589f1: field store_product: %w", err) + } + s.StoreProduct = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode starsGiftOption#5e0589f1: field currency: %w", err) + } + s.Currency = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode starsGiftOption#5e0589f1: field amount: %w", err) + } + s.Amount = value + } + return nil +} + +// SetExtended sets value of Extended conditional field. +func (s *StarsGiftOption) SetExtended(value bool) { + if value { + s.Flags.Set(1) + s.Extended = true + } else { + s.Flags.Unset(1) + s.Extended = false + } +} + +// GetExtended returns value of Extended conditional field. +func (s *StarsGiftOption) GetExtended() (value bool) { + if s == nil { + return + } + return s.Flags.Has(1) +} + +// GetStars returns value of Stars field. +func (s *StarsGiftOption) GetStars() (value int64) { + if s == nil { + return + } + return s.Stars +} + +// SetStoreProduct sets value of StoreProduct conditional field. +func (s *StarsGiftOption) SetStoreProduct(value string) { + s.Flags.Set(0) + s.StoreProduct = value +} + +// GetStoreProduct returns value of StoreProduct conditional field and +// boolean which is true if field was set. +func (s *StarsGiftOption) GetStoreProduct() (value string, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.StoreProduct, true +} + +// GetCurrency returns value of Currency field. +func (s *StarsGiftOption) GetCurrency() (value string) { + if s == nil { + return + } + return s.Currency +} + +// GetAmount returns value of Amount field. +func (s *StarsGiftOption) GetAmount() (value int64) { + if s == nil { + return + } + return s.Amount +} diff --git a/tg/tl_stars_gift_option_slices_gen.go b/tg/tl_stars_gift_option_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_stars_gift_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_stars_gift_option_vector_gen.go b/tg/tl_stars_gift_option_vector_gen.go new file mode 100644 index 000000000..80a59ccd9 --- /dev/null +++ b/tg/tl_stars_gift_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{} +) + +// StarsGiftOptionVector is a box for Vector +type StarsGiftOptionVector struct { + // Elements of Vector + Elems []StarsGiftOption +} + +// StarsGiftOptionVectorTypeID is TL type id of StarsGiftOptionVector. +const StarsGiftOptionVectorTypeID = bin.TypeVector + +// Ensuring interfaces in compile-time for StarsGiftOptionVector. +var ( + _ bin.Encoder = &StarsGiftOptionVector{} + _ bin.Decoder = &StarsGiftOptionVector{} + _ bin.BareEncoder = &StarsGiftOptionVector{} + _ bin.BareDecoder = &StarsGiftOptionVector{} +) + +func (vec *StarsGiftOptionVector) Zero() bool { + if vec == nil { + return true + } + if !(vec.Elems == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (vec *StarsGiftOptionVector) String() string { + if vec == nil { + return "StarsGiftOptionVector(nil)" + } + type Alias StarsGiftOptionVector + return fmt.Sprintf("StarsGiftOptionVector%+v", Alias(*vec)) +} + +// FillFrom fills StarsGiftOptionVector from given interface. +func (vec *StarsGiftOptionVector) FillFrom(from interface { + GetElems() (value []StarsGiftOption) +}) { + vec.Elems = from.GetElems() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsGiftOptionVector) TypeID() uint32 { + return StarsGiftOptionVectorTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsGiftOptionVector) TypeName() string { + return "" +} + +// TypeInfo returns info about TL type. +func (vec *StarsGiftOptionVector) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "", + ID: StarsGiftOptionVectorTypeID, + } + if vec == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Elems", + SchemaName: "Elems", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (vec *StarsGiftOptionVector) 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 *StarsGiftOptionVector) 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 *StarsGiftOptionVector) 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 *StarsGiftOptionVector) 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([]StarsGiftOption, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value StarsGiftOption + 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 *StarsGiftOptionVector) GetElems() (value []StarsGiftOption) { + if vec == nil { + return + } + return vec.Elems +} diff --git a/tg/tl_stars_gift_option_vector_slices_gen.go b/tg/tl_stars_gift_option_vector_slices_gen.go new file mode 100644 index 000000000..fe21471a4 --- /dev/null +++ b/tg/tl_stars_gift_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_stars_transaction_gen.go b/tg/tl_stars_transaction_gen.go index f3a8691de..f14276d93 100644 --- a/tg/tl_stars_transaction_gen.go +++ b/tg/tl_stars_transaction_gen.go @@ -43,6 +43,8 @@ type StarsTransaction struct { Pending bool // Failed field of StarsTransaction. Failed bool + // Gift field of StarsTransaction. + Gift bool // ID field of StarsTransaction. ID string // Stars field of StarsTransaction. @@ -112,6 +114,9 @@ func (s *StarsTransaction) Zero() bool { if !(s.Failed == false) { return false } + if !(s.Gift == false) { + return false + } if !(s.ID == "") { return false } @@ -166,6 +171,7 @@ func (s *StarsTransaction) FillFrom(from interface { GetRefund() (value bool) GetPending() (value bool) GetFailed() (value bool) + GetGift() (value bool) GetID() (value string) GetStars() (value int64) GetDate() (value int) @@ -182,6 +188,7 @@ func (s *StarsTransaction) FillFrom(from interface { s.Refund = from.GetRefund() s.Pending = from.GetPending() s.Failed = from.GetFailed() + s.Gift = from.GetGift() s.ID = from.GetID() s.Stars = from.GetStars() s.Date = from.GetDate() @@ -258,6 +265,11 @@ func (s *StarsTransaction) TypeInfo() tdp.Type { SchemaName: "failed", Null: !s.Flags.Has(6), }, + { + Name: "Gift", + SchemaName: "gift", + Null: !s.Flags.Has(10), + }, { Name: "ID", SchemaName: "id", @@ -329,6 +341,9 @@ func (s *StarsTransaction) SetFlags() { if !(s.Failed == false) { s.Flags.Set(6) } + if !(s.Gift == false) { + s.Flags.Set(10) + } if !(s.Title == "") { s.Flags.Set(0) } @@ -446,6 +461,7 @@ func (s *StarsTransaction) DecodeBare(b *bin.Buffer) error { s.Refund = s.Flags.Has(3) s.Pending = s.Flags.Has(4) s.Failed = s.Flags.Has(6) + s.Gift = s.Flags.Has(10) { value, err := b.String() if err != nil { @@ -600,6 +616,25 @@ func (s *StarsTransaction) GetFailed() (value bool) { return s.Flags.Has(6) } +// SetGift sets value of Gift conditional field. +func (s *StarsTransaction) SetGift(value bool) { + if value { + s.Flags.Set(10) + s.Gift = true + } else { + s.Flags.Unset(10) + s.Gift = false + } +} + +// GetGift returns value of Gift conditional field. +func (s *StarsTransaction) GetGift() (value bool) { + if s == nil { + return + } + return s.Flags.Has(10) +} + // GetID returns value of ID field. func (s *StarsTransaction) GetID() (value string) { if s == nil { diff --git a/tg/tl_top_peer_category_gen.go b/tg/tl_top_peer_category_gen.go index 5ea027141..9f4d43cac 100644 --- a/tg/tl_top_peer_category_gen.go +++ b/tg/tl_top_peer_category_gen.go @@ -847,6 +847,107 @@ func (t *TopPeerCategoryForwardChats) DecodeBare(b *bin.Buffer) error { return nil } +// TopPeerCategoryBotsApp represents TL type `topPeerCategoryBotsApp#fd9e7bec`. +// +// See https://core.telegram.org/constructor/topPeerCategoryBotsApp for reference. +type TopPeerCategoryBotsApp struct { +} + +// TopPeerCategoryBotsAppTypeID is TL type id of TopPeerCategoryBotsApp. +const TopPeerCategoryBotsAppTypeID = 0xfd9e7bec + +// construct implements constructor of TopPeerCategoryClass. +func (t TopPeerCategoryBotsApp) construct() TopPeerCategoryClass { return &t } + +// Ensuring interfaces in compile-time for TopPeerCategoryBotsApp. +var ( + _ bin.Encoder = &TopPeerCategoryBotsApp{} + _ bin.Decoder = &TopPeerCategoryBotsApp{} + _ bin.BareEncoder = &TopPeerCategoryBotsApp{} + _ bin.BareDecoder = &TopPeerCategoryBotsApp{} + + _ TopPeerCategoryClass = &TopPeerCategoryBotsApp{} +) + +func (t *TopPeerCategoryBotsApp) Zero() bool { + if t == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (t *TopPeerCategoryBotsApp) String() string { + if t == nil { + return "TopPeerCategoryBotsApp(nil)" + } + type Alias TopPeerCategoryBotsApp + return fmt.Sprintf("TopPeerCategoryBotsApp%+v", Alias(*t)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*TopPeerCategoryBotsApp) TypeID() uint32 { + return TopPeerCategoryBotsAppTypeID +} + +// TypeName returns name of type in TL schema. +func (*TopPeerCategoryBotsApp) TypeName() string { + return "topPeerCategoryBotsApp" +} + +// TypeInfo returns info about TL type. +func (t *TopPeerCategoryBotsApp) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "topPeerCategoryBotsApp", + ID: TopPeerCategoryBotsAppTypeID, + } + if t == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (t *TopPeerCategoryBotsApp) Encode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode topPeerCategoryBotsApp#fd9e7bec as nil") + } + b.PutID(TopPeerCategoryBotsAppTypeID) + return t.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (t *TopPeerCategoryBotsApp) EncodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode topPeerCategoryBotsApp#fd9e7bec as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (t *TopPeerCategoryBotsApp) Decode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode topPeerCategoryBotsApp#fd9e7bec to nil") + } + if err := b.ConsumeID(TopPeerCategoryBotsAppTypeID); err != nil { + return fmt.Errorf("unable to decode topPeerCategoryBotsApp#fd9e7bec: %w", err) + } + return t.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (t *TopPeerCategoryBotsApp) DecodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode topPeerCategoryBotsApp#fd9e7bec to nil") + } + return nil +} + // TopPeerCategoryClassName is schema name of TopPeerCategoryClass. const TopPeerCategoryClassName = "TopPeerCategory" @@ -869,6 +970,7 @@ const TopPeerCategoryClassName = "TopPeerCategory" // case *tg.TopPeerCategoryPhoneCalls: // topPeerCategoryPhoneCalls#1e76a78c // case *tg.TopPeerCategoryForwardUsers: // topPeerCategoryForwardUsers#a8406ca9 // case *tg.TopPeerCategoryForwardChats: // topPeerCategoryForwardChats#fbeec0f0 +// case *tg.TopPeerCategoryBotsApp: // topPeerCategoryBotsApp#fd9e7bec // default: panic(v) // } type TopPeerCategoryClass interface { @@ -953,6 +1055,13 @@ func DecodeTopPeerCategory(buf *bin.Buffer) (TopPeerCategoryClass, error) { return nil, fmt.Errorf("unable to decode TopPeerCategoryClass: %w", err) } return &v, nil + case TopPeerCategoryBotsAppTypeID: + // Decoding topPeerCategoryBotsApp#fd9e7bec. + v := TopPeerCategoryBotsApp{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode TopPeerCategoryClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode TopPeerCategoryClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_user_gen.go b/tg/tl_user_gen.go index eb260c3c7..7dead706d 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#215c4438`. +// User represents TL type `user#83314fca`. // Indicates info about a certain user // // See https://core.telegram.org/constructor/user for reference. @@ -246,6 +246,8 @@ type User struct { ContactRequirePremium bool // BotBusiness field of User. BotBusiness bool + // BotHasMainApp field of User. + BotHasMainApp bool // ID of the user ID int64 // Access hash of the user @@ -327,10 +329,14 @@ type User struct { // // Use SetProfileColor and GetProfileColor helpers. ProfileColor PeerColor + // BotActiveUsers field of User. + // + // Use SetBotActiveUsers and GetBotActiveUsers helpers. + BotActiveUsers int } // UserTypeID is TL type id of User. -const UserTypeID = 0x215c4438 +const UserTypeID = 0x83314fca // construct implements constructor of UserClass. func (u User) construct() UserClass { return &u } @@ -427,6 +433,9 @@ func (u *User) Zero() bool { if !(u.BotBusiness == false) { return false } + if !(u.BotHasMainApp == false) { + return false + } if !(u.ID == 0) { return false } @@ -478,6 +487,9 @@ func (u *User) Zero() bool { if !(u.ProfileColor.Zero()) { return false } + if !(u.BotActiveUsers == 0) { + return false + } return true } @@ -517,6 +529,7 @@ func (u *User) FillFrom(from interface { GetStoriesUnavailable() (value bool) GetContactRequirePremium() (value bool) GetBotBusiness() (value bool) + GetBotHasMainApp() (value bool) GetID() (value int64) GetAccessHash() (value int64, ok bool) GetFirstName() (value string, ok bool) @@ -534,6 +547,7 @@ func (u *User) FillFrom(from interface { GetStoriesMaxID() (value int, ok bool) GetColor() (value PeerColor, ok bool) GetProfileColor() (value PeerColor, ok bool) + GetBotActiveUsers() (value int, ok bool) }) { u.Self = from.GetSelf() u.Contact = from.GetContact() @@ -559,6 +573,7 @@ func (u *User) FillFrom(from interface { u.StoriesUnavailable = from.GetStoriesUnavailable() u.ContactRequirePremium = from.GetContactRequirePremium() u.BotBusiness = from.GetBotBusiness() + u.BotHasMainApp = from.GetBotHasMainApp() u.ID = from.GetID() if val, ok := from.GetAccessHash(); ok { u.AccessHash = val @@ -624,6 +639,10 @@ func (u *User) FillFrom(from interface { u.ProfileColor = val } + if val, ok := from.GetBotActiveUsers(); ok { + u.BotActiveUsers = val + } + } // TypeID returns type id in TL schema. @@ -769,6 +788,11 @@ func (u *User) TypeInfo() tdp.Type { SchemaName: "bot_business", Null: !u.Flags2.Has(11), }, + { + Name: "BotHasMainApp", + SchemaName: "bot_has_main_app", + Null: !u.Flags2.Has(13), + }, { Name: "ID", SchemaName: "id", @@ -853,6 +877,11 @@ func (u *User) TypeInfo() tdp.Type { SchemaName: "profile_color", Null: !u.Flags2.Has(9), }, + { + Name: "BotActiveUsers", + SchemaName: "bot_active_users", + Null: !u.Flags2.Has(12), + }, } return typ } @@ -931,6 +960,9 @@ func (u *User) SetFlags() { if !(u.BotBusiness == false) { u.Flags2.Set(11) } + if !(u.BotHasMainApp == false) { + u.Flags2.Set(13) + } if !(u.AccessHash == 0) { u.Flags.Set(0) } @@ -979,12 +1011,15 @@ func (u *User) SetFlags() { if !(u.ProfileColor.Zero()) { u.Flags2.Set(9) } + if !(u.BotActiveUsers == 0) { + u.Flags2.Set(12) + } } // Encode implements bin.Encoder. func (u *User) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode user#215c4438 as nil") + return fmt.Errorf("can't encode user#83314fca as nil") } b.PutID(UserTypeID) return u.EncodeBare(b) @@ -993,14 +1028,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#215c4438 as nil") + return fmt.Errorf("can't encode user#83314fca as nil") } u.SetFlags() if err := u.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#215c4438: field flags: %w", err) + return fmt.Errorf("unable to encode user#83314fca: field flags: %w", err) } if err := u.Flags2.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#215c4438: field flags2: %w", err) + return fmt.Errorf("unable to encode user#83314fca: field flags2: %w", err) } b.PutLong(u.ID) if u.Flags.Has(0) { @@ -1020,18 +1055,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#215c4438: field photo is nil") + return fmt.Errorf("unable to encode user#83314fca: field photo is nil") } if err := u.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#215c4438: field photo: %w", err) + return fmt.Errorf("unable to encode user#83314fca: field photo: %w", err) } } if u.Flags.Has(6) { if u.Status == nil { - return fmt.Errorf("unable to encode user#215c4438: field status is nil") + return fmt.Errorf("unable to encode user#83314fca: field status is nil") } if err := u.Status.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#215c4438: field status: %w", err) + return fmt.Errorf("unable to encode user#83314fca: field status: %w", err) } } if u.Flags.Has(14) { @@ -1041,7 +1076,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#215c4438: field restriction_reason element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode user#83314fca: field restriction_reason element with index %d: %w", idx, err) } } } @@ -1053,17 +1088,17 @@ func (u *User) EncodeBare(b *bin.Buffer) error { } if u.Flags.Has(30) { if u.EmojiStatus == nil { - return fmt.Errorf("unable to encode user#215c4438: field emoji_status is nil") + return fmt.Errorf("unable to encode user#83314fca: field emoji_status is nil") } if err := u.EmojiStatus.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#215c4438: field emoji_status: %w", err) + return fmt.Errorf("unable to encode user#83314fca: 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#215c4438: field usernames element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode user#83314fca: field usernames element with index %d: %w", idx, err) } } } @@ -1072,24 +1107,27 @@ func (u *User) EncodeBare(b *bin.Buffer) error { } if u.Flags2.Has(8) { if err := u.Color.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#215c4438: field color: %w", err) + return fmt.Errorf("unable to encode user#83314fca: field color: %w", err) } } if u.Flags2.Has(9) { if err := u.ProfileColor.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#215c4438: field profile_color: %w", err) + return fmt.Errorf("unable to encode user#83314fca: field profile_color: %w", err) } } + if u.Flags2.Has(12) { + b.PutInt(u.BotActiveUsers) + } return nil } // Decode implements bin.Decoder. func (u *User) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode user#215c4438 to nil") + return fmt.Errorf("can't decode user#83314fca to nil") } if err := b.ConsumeID(UserTypeID); err != nil { - return fmt.Errorf("unable to decode user#215c4438: %w", err) + return fmt.Errorf("unable to decode user#83314fca: %w", err) } return u.DecodeBare(b) } @@ -1097,11 +1135,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#215c4438 to nil") + return fmt.Errorf("can't decode user#83314fca to nil") } { if err := u.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode user#215c4438: field flags: %w", err) + return fmt.Errorf("unable to decode user#83314fca: field flags: %w", err) } } u.Self = u.Flags.Has(10) @@ -1124,7 +1162,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#215c4438: field flags2: %w", err) + return fmt.Errorf("unable to decode user#83314fca: field flags2: %w", err) } } u.BotCanEdit = u.Flags2.Has(1) @@ -1133,73 +1171,74 @@ func (u *User) DecodeBare(b *bin.Buffer) error { u.StoriesUnavailable = u.Flags2.Has(4) u.ContactRequirePremium = u.Flags2.Has(10) u.BotBusiness = u.Flags2.Has(11) + u.BotHasMainApp = u.Flags2.Has(13) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode user#215c4438: field id: %w", err) + return fmt.Errorf("unable to decode user#83314fca: 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#215c4438: field access_hash: %w", err) + return fmt.Errorf("unable to decode user#83314fca: 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#215c4438: field first_name: %w", err) + return fmt.Errorf("unable to decode user#83314fca: 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#215c4438: field last_name: %w", err) + return fmt.Errorf("unable to decode user#83314fca: 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#215c4438: field username: %w", err) + return fmt.Errorf("unable to decode user#83314fca: 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#215c4438: field phone: %w", err) + return fmt.Errorf("unable to decode user#83314fca: 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#215c4438: field photo: %w", err) + return fmt.Errorf("unable to decode user#83314fca: 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#215c4438: field status: %w", err) + return fmt.Errorf("unable to decode user#83314fca: 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#215c4438: field bot_info_version: %w", err) + return fmt.Errorf("unable to decode user#83314fca: 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#215c4438: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode user#83314fca: field restriction_reason: %w", err) } if headerLen > 0 { @@ -1208,7 +1247,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#215c4438: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode user#83314fca: field restriction_reason: %w", err) } u.RestrictionReason = append(u.RestrictionReason, value) } @@ -1216,28 +1255,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#215c4438: field bot_inline_placeholder: %w", err) + return fmt.Errorf("unable to decode user#83314fca: 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#215c4438: field lang_code: %w", err) + return fmt.Errorf("unable to decode user#83314fca: 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#215c4438: field emoji_status: %w", err) + return fmt.Errorf("unable to decode user#83314fca: 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#215c4438: field usernames: %w", err) + return fmt.Errorf("unable to decode user#83314fca: field usernames: %w", err) } if headerLen > 0 { @@ -1246,7 +1285,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#215c4438: field usernames: %w", err) + return fmt.Errorf("unable to decode user#83314fca: field usernames: %w", err) } u.Usernames = append(u.Usernames, value) } @@ -1254,20 +1293,27 @@ 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#215c4438: field stories_max_id: %w", err) + return fmt.Errorf("unable to decode user#83314fca: field stories_max_id: %w", err) } u.StoriesMaxID = value } if u.Flags2.Has(8) { if err := u.Color.Decode(b); err != nil { - return fmt.Errorf("unable to decode user#215c4438: field color: %w", err) + return fmt.Errorf("unable to decode user#83314fca: field color: %w", err) } } if u.Flags2.Has(9) { if err := u.ProfileColor.Decode(b); err != nil { - return fmt.Errorf("unable to decode user#215c4438: field profile_color: %w", err) + return fmt.Errorf("unable to decode user#83314fca: field profile_color: %w", err) } } + if u.Flags2.Has(12) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode user#83314fca: field bot_active_users: %w", err) + } + u.BotActiveUsers = value + } return nil } @@ -1727,6 +1773,25 @@ func (u *User) GetBotBusiness() (value bool) { return u.Flags2.Has(11) } +// SetBotHasMainApp sets value of BotHasMainApp conditional field. +func (u *User) SetBotHasMainApp(value bool) { + if value { + u.Flags2.Set(13) + u.BotHasMainApp = true + } else { + u.Flags2.Unset(13) + u.BotHasMainApp = false + } +} + +// GetBotHasMainApp returns value of BotHasMainApp conditional field. +func (u *User) GetBotHasMainApp() (value bool) { + if u == nil { + return + } + return u.Flags2.Has(13) +} + // GetID returns value of ID field. func (u *User) GetID() (value int64) { if u == nil { @@ -2023,6 +2088,24 @@ func (u *User) GetProfileColor() (value PeerColor, ok bool) { return u.ProfileColor, true } +// SetBotActiveUsers sets value of BotActiveUsers conditional field. +func (u *User) SetBotActiveUsers(value int) { + u.Flags2.Set(12) + u.BotActiveUsers = value +} + +// GetBotActiveUsers returns value of BotActiveUsers conditional field and +// boolean which is true if field was set. +func (u *User) GetBotActiveUsers() (value int, ok bool) { + if u == nil { + return + } + if !u.Flags2.Has(12) { + return value, false + } + return u.BotActiveUsers, true +} + // UserClassName is schema name of UserClass. const UserClassName = "User" @@ -2038,7 +2121,7 @@ const UserClassName = "User" // } // switch v := g.(type) { // case *tg.UserEmpty: // userEmpty#d3bc4b7a -// case *tg.User: // user#215c4438 +// case *tg.User: // user#83314fca // default: panic(v) // } type UserClass interface { @@ -2123,7 +2206,7 @@ func DecodeUser(buf *bin.Buffer) (UserClass, error) { } return &v, nil case UserTypeID: - // Decoding user#215c4438. + // Decoding user#83314fca. v := User{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UserClass: %w", err)