diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index cf62a015d9..c54b0908f3 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: 179 -// SHA256: 9eb6aa1c5c25c900796809ce40385160142eaebc0ab5b68af4b8a4567fec6f05 +// Layer: 181 +// SHA256: 681a5cff504a6851c9671e750ddd78d022d24b9d22c6411b415582dff0a2b944 boolFalse#bc799737 = Bool; @@ -64,7 +64,7 @@ inputMediaDocumentExternal#fb52dc99 flags:# spoiler:flags.1?true url:string ttl_ inputMediaGame#d33f43f3 id:InputGame = InputMedia; -inputMediaInvoice#8eb5a6d5 flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:string provider_data:DataJSON start_param:flags.1?string extended_media:flags.2?InputMedia = InputMedia; +inputMediaInvoice#405fef0d flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:flags.3?string provider_data:DataJSON start_param:flags.1?string extended_media:flags.2?InputMedia = InputMedia; inputMediaGeoLive#971fa843 flags:# stopped:flags.0?true geo_point:InputGeoPoint heading:flags.2?int period:flags.1?int proximity_notification_radius:flags.3?int = InputMedia; @@ -186,7 +186,7 @@ chatPhoto#1c6e1c11 flags:# has_video:flags.0?true photo_id:long stripped_thumb:f messageEmpty#90a6ca84 flags:# id:int peer_id:flags.0?Peer = Message; -message#2357bf25 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true flags2:# offline:flags2.1?true id:int from_id:flags.8?Peer from_boosts_applied:flags.29?int peer_id:Peer saved_peer_id:flags.28?Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long via_business_bot_id:flags2.0?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int quick_reply_shortcut_id:flags.30?int = Message; +message#94345242 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true flags2:# offline:flags2.1?true id:int from_id:flags.8?Peer from_boosts_applied:flags.29?int peer_id:Peer saved_peer_id:flags.28?Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long via_business_bot_id:flags2.0?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int quick_reply_shortcut_id:flags.30?int effect:flags2.2?long factcheck:flags2.3?FactCheck = Message; messageService#2b085862 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?Peer peer_id:Peer reply_to:flags.3?MessageReplyHeader date:int action:MessageAction ttl_period:flags.25?int = Message; @@ -726,6 +726,10 @@ updateBotDeleteBusinessMessage#a02a982e connection_id:string peer:Peer messages: updateNewStoryReaction#1824e40b story_id:int peer:Peer reaction:Reaction = Update; +updateBroadcastRevenueTransactions#dfd961f5 peer:Peer balances:BroadcastRevenueBalances = Update; + +updateStarsBalance#fb85198 balance:long = Update; + updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.differenceEmpty#5d75a138 date:int seq:int = updates.Difference; @@ -1130,7 +1134,7 @@ messageEntitySpoiler#32ca960f offset:int length:int = MessageEntity; messageEntityCustomEmoji#c8cf05f8 offset:int length:int document_id:long = MessageEntity; -messageEntityBlockquote#20df5d0 offset:int length:int = MessageEntity; +messageEntityBlockquote#f1ccaaac flags:# collapsed:flags.0?true offset:int length:int = MessageEntity; inputChannelEmpty#ee8c1e86 = InputChannel; @@ -1266,7 +1270,7 @@ auth.sentCodeTypeSetUpEmailRequired#a5491dea flags:# apple_signin_allowed:flags. auth.sentCodeTypeFragmentSms#d9565c39 url:string length:int = auth.SentCodeType; -auth.sentCodeTypeFirebaseSms#e57b1432 flags:# nonce:flags.0?bytes receipt:flags.1?string push_timeout:flags.1?int length:int = auth.SentCodeType; +auth.sentCodeTypeFirebaseSms#13c90f17 flags:# nonce:flags.0?bytes play_integrity_nonce:flags.2?bytes receipt:flags.1?string push_timeout:flags.1?int length:int = auth.SentCodeType; auth.sentCodeTypeSmsWord#a416ac81 flags:# beginning:flags.0?string = auth.SentCodeType; @@ -1480,6 +1484,8 @@ upload.webFile#21e753bc size:int mime_type:string file_type:storage.FileType mti payments.paymentForm#a0058751 flags:# can_save_credentials:flags.2?true password_missing:flags.3?true form_id:long bot_id:long title:string description:string photo:flags.5?WebDocument invoice:Invoice provider_id:long url:string native_provider:flags.4?string native_params:flags.4?DataJSON additional_methods:flags.6?Vector saved_info:flags.0?PaymentRequestedInfo saved_credentials:flags.1?Vector users:Vector = payments.PaymentForm; +payments.paymentFormStars#7bf6b15c flags:# form_id:long bot_id:long title:string description:string photo:flags.5?WebDocument invoice:Invoice users:Vector = payments.PaymentForm; + payments.validatedRequestedInfo#d1451883 flags:# id:flags.0?string shipping_options:flags.1?Vector = payments.ValidatedRequestedInfo; payments.paymentResult#4e5f810d updates:Updates = payments.PaymentResult; @@ -1488,6 +1494,8 @@ payments.paymentVerificationNeeded#d8411139 url:string = payments.PaymentResult; payments.paymentReceipt#70c4fe03 flags:# date:int bot_id:long provider_id:long title:string description:string photo:flags.2?WebDocument invoice:Invoice info:flags.0?PaymentRequestedInfo shipping:flags.1?ShippingOption tip_amount:flags.3?long currency:string total_amount:long credentials_title:string users:Vector = payments.PaymentReceipt; +payments.paymentReceiptStars#dabbf83a flags:# date:int bot_id:long title:string description:string photo:flags.2?WebDocument invoice:Invoice currency:string total_amount:long transaction_id:string users:Vector = payments.PaymentReceipt; + payments.savedInfo#fb8fe43c flags:# has_saved_credentials:flags.1?true saved_info:flags.0?PaymentRequestedInfo = payments.SavedInfo; inputPaymentCredentialsSaved#c10eb2cf id:string tmp_password:bytes = InputPaymentCredentials; @@ -2194,6 +2202,8 @@ inputInvoiceSlug#c326caef slug:string = InputInvoice; inputInvoicePremiumGiftCode#98986c0d purpose:InputStorePaymentPurpose option:PremiumGiftCodeOption = InputInvoice; +inputInvoiceStars#1da33ad8 option:StarsTopupOption = InputInvoice; + payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice; messages.transcribedAudio#cfb9d957 flags:# pending:flags.0?true transcription_id:long text:string trial_remains_num:flags.1?int trial_remains_until_date:flags.1?int = messages.TranscribedAudio; @@ -2208,6 +2218,8 @@ 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; + premiumGiftOption#74c34319 flags:# months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumGiftOption; paymentFormMethod#88f8f21b url:string title:string = PaymentFormMethod; @@ -2592,6 +2604,32 @@ reactionsNotifySettings#56e34970 flags:# messages_notify_from:flags.0?ReactionNo broadcastRevenueBalances#8438f1c6 current_balance:long available_balance:long overall_revenue:long = BroadcastRevenueBalances; +availableEffect#93c3e27e flags:# premium_required:flags.2?true id:long emoticon:string static_icon_id:flags.0?long effect_sticker_id:long effect_animation_id:flags.1?long = AvailableEffect; + +messages.availableEffectsNotModified#d1ed9a5b = messages.AvailableEffects; + +messages.availableEffects#bddb616e hash:int effects:Vector documents:Vector = messages.AvailableEffects; + +factCheck#b89bfccf flags:# need_check:flags.0?true country:flags.1?string text:flags.1?TextWithEntities hash:long = FactCheck; + +starsTransactionPeerUnsupported#95f2bfe4 = StarsTransactionPeer; + +starsTransactionPeerAppStore#b457b375 = StarsTransactionPeer; + +starsTransactionPeerPlayMarket#7b560a0b = StarsTransactionPeer; + +starsTransactionPeerPremiumBot#250dbaf8 = StarsTransactionPeer; + +starsTransactionPeerFragment#e92fd902 = StarsTransactionPeer; + +starsTransactionPeer#d80da15d peer:Peer = StarsTransactionPeer; + +starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; + +starsTransaction#cc7079b2 flags:# refund:flags.3?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument = StarsTransaction; + +payments.starsStatus#8cf4ee60 flags:# balance:long history:Vector next_offset:flags.0?string chats:Vector users:Vector = payments.StarsStatus; + ---functions--- @@ -2611,6 +2649,10 @@ invokeWithTakeout#aca9fd2e {X:Type} takeout_id:long query:!X = X; invokeWithBusinessConnection#dd289f8e {X:Type} connection_id:string query:!X = X; +invokeWithGooglePlayIntegrity#1df92984 {X:Type} nonce:string token:string query:!X = X; + +invokeWithApnsSecret#dae54f8 {X:Type} nonce:string secret:string query:!X = X; + auth.sendCode#a677244f phone_number:string api_id:int api_hash:string settings:CodeSettings = auth.SentCode; auth.signUp#aac7b717 flags:# no_joined_notifications:flags.0?true phone_number:string phone_code_hash:string first_name:string last_name:string = auth.Authorization; @@ -2635,7 +2677,7 @@ auth.requestPasswordRecovery#d897bc66 = auth.PasswordRecovery; auth.recoverPassword#37096c70 flags:# code:string new_settings:flags.0?account.PasswordInputSettings = auth.Authorization; -auth.resendCode#3ef1a9bf phone_number:string phone_code_hash:string = auth.SentCode; +auth.resendCode#cae47523 flags:# phone_number:string phone_code_hash:string reason:flags.0?string = auth.SentCode; auth.cancelCode#1f040578 phone_number:string phone_code_hash:string = Bool; @@ -2651,7 +2693,7 @@ auth.checkRecoveryPassword#d36bf79 code:string = Bool; auth.importWebTokenAuthorization#2db873a9 api_id:int api_hash:string web_auth_token:string = auth.Authorization; -auth.requestFirebaseSms#89464b50 flags:# phone_number:string phone_code_hash:string safety_net_token:flags.0?string ios_push_secret:flags.1?string = Bool; +auth.requestFirebaseSms#8e39261e flags:# phone_number:string phone_code_hash:string safety_net_token:flags.0?string play_integrity_token:flags.2?string ios_push_secret:flags.1?string = Bool; auth.resetLoginEmail#7e960193 phone_number:string phone_code_hash:string = auth.SentCode; @@ -2959,9 +3001,9 @@ messages.receivedMessages#5a954c0 max_id:int = Vector; messages.setTyping#58943ee2 flags:# peer:InputPeer top_msg_id:flags.0?int action:SendMessageAction = Bool; -messages.sendMessage#dff8042c flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut = Updates; +messages.sendMessage#983f9745 flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long = Updates; -messages.sendMedia#7bd66041 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut = Updates; +messages.sendMedia#7852834e flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long = Updates; messages.forwardMessages#d5039208 flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer top_msg_id:flags.9?int schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut = Updates; @@ -3119,7 +3161,7 @@ messages.readMentions#36e5bf4d flags:# peer:InputPeer top_msg_id:flags.0?int = m messages.getRecentLocations#702a40e0 peer:InputPeer limit:int hash:long = messages.Messages; -messages.sendMultiMedia#c964709 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut = Updates; +messages.sendMultiMedia#37b74355 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long = Updates; messages.uploadEncryptedFile#5057c497 peer:InputEncryptedChat file:InputEncryptedFile = EncryptedFile; @@ -3359,6 +3401,14 @@ messages.getMyStickers#d0b5e1fc offset_id:long limit:int = messages.MyStickers; messages.getEmojiStickerGroups#1dd840f5 hash:int = messages.EmojiGroups; +messages.getAvailableEffects#dea20a39 hash:int = messages.AvailableEffects; + +messages.editFactCheck#589ee75 peer:InputPeer msg_id:int text:TextWithEntities = Updates; + +messages.deleteFactCheck#d1da940c peer:InputPeer msg_id:int = Updates; + +messages.getFactCheck#b9cdc5ee peer:InputPeer msg_id:Vector = Vector; + 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; @@ -3569,6 +3619,8 @@ channels.reportSponsoredMessage#af8ff6b9 channel:InputChannel random_id:bytes op channels.restrictSponsoredMessages#9ae91519 channel:InputChannel restricted:Bool = Updates; +channels.searchPosts#d19f987b hashtag:string offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; + bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; @@ -3633,6 +3685,16 @@ payments.getGiveawayInfo#f4239425 peer:InputPeer msg_id:int = payments.GiveawayI payments.launchPrepaidGiveaway#5ff58f20 peer:InputPeer giveaway_id:long purpose:InputStorePaymentPurpose = Updates; +payments.getStarsTopupOptions#c00ec7d3 = Vector; + +payments.getStarsStatus#104fcfa7 peer:InputPeer = payments.StarsStatus; + +payments.getStarsTransactions#673ac2f9 flags:# inbound:flags.0?true outbound:flags.1?true peer:InputPeer offset:string = payments.StarsStatus; + +payments.sendStarsForm#2bb731d flags:# form_id:long invoice:InputInvoice = payments.PaymentResult; + +payments.refundStarsCharge#25ae8f4a user_id:InputUser charge_id:string = Updates; + 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; @@ -3847,4 +3909,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 179 +// LAYER 181 diff --git a/_schema/tdlib.tl b/_schema/tdlib.tl index 6555971370..1e7d07699e 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: 179 -// SHA256: 9959d8e9447fbb87f7624fa9912116ccbf2f57af2a99c61df725a8839be8745b +// Layer: 181 +// SHA256: 23c76e54567eb8f4951bb21916061eb1773730027db23a0a68317d23a61d50df int#a8509bda ? = Int; @@ -43,6 +43,10 @@ test.parseInputAppEvent#bb0d87f1 = InputAppEvent; invokeWithBusinessConnectionPrefix#dd289f8e connection_id:string = Error; +invokeWithGooglePlayIntegrityPrefix#1df92984 nonce:string token:string = Error; + +invokeWithApnsSecretPrefix#dae54f8 nonce:string secret:string = Error; + ---types--- @@ -96,7 +100,7 @@ inputMediaDocumentExternal#fb52dc99 flags:# spoiler:flags.1?true url:string ttl_ inputMediaGame#d33f43f3 id:InputGame = InputMedia; -inputMediaInvoice#8eb5a6d5 flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:string provider_data:DataJSON start_param:flags.1?string extended_media:flags.2?InputMedia = InputMedia; +inputMediaInvoice#405fef0d flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:flags.3?string provider_data:DataJSON start_param:flags.1?string extended_media:flags.2?InputMedia = InputMedia; inputMediaGeoLive#971fa843 flags:# stopped:flags.0?true geo_point:InputGeoPoint heading:flags.2?int period:flags.1?int proximity_notification_radius:flags.3?int = InputMedia; @@ -218,7 +222,7 @@ chatPhoto#1c6e1c11 flags:# has_video:flags.0?true photo_id:long stripped_thumb:f messageEmpty#90a6ca84 flags:# id:int peer_id:flags.0?Peer = Message; -message#2357bf25 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true flags2:# offline:flags2.1?true id:int from_id:flags.8?Peer from_boosts_applied:flags.29?int peer_id:Peer saved_peer_id:flags.28?Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long via_business_bot_id:flags2.0?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int quick_reply_shortcut_id:flags.30?int = Message; +message#94345242 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true flags2:# offline:flags2.1?true id:int from_id:flags.8?Peer from_boosts_applied:flags.29?int peer_id:Peer saved_peer_id:flags.28?Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long via_business_bot_id:flags2.0?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int quick_reply_shortcut_id:flags.30?int effect:flags2.2?long factcheck:flags2.3?FactCheck = Message; messageService#2b085862 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?Peer peer_id:Peer reply_to:flags.3?MessageReplyHeader date:int action:MessageAction ttl_period:flags.25?int = Message; @@ -758,7 +762,9 @@ updateBotDeleteBusinessMessage#a02a982e connection_id:string peer:Peer messages: updateNewStoryReaction#1824e40b story_id:int peer:Peer reaction:Reaction = Update; -updateBroadcastRevenueTransactions#5c65d358 balances:BroadcastRevenueBalances = Update; +updateBroadcastRevenueTransactions#dfd961f5 peer:Peer balances:BroadcastRevenueBalances = Update; + +updateStarsBalance#fb85198 balance:long = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -1164,7 +1170,7 @@ messageEntitySpoiler#32ca960f offset:int length:int = MessageEntity; messageEntityCustomEmoji#c8cf05f8 offset:int length:int document_id:long = MessageEntity; -messageEntityBlockquote#20df5d0 offset:int length:int = MessageEntity; +messageEntityBlockquote#f1ccaaac flags:# collapsed:flags.0?true offset:int length:int = MessageEntity; inputChannelEmpty#ee8c1e86 = InputChannel; @@ -1300,7 +1306,7 @@ auth.sentCodeTypeSetUpEmailRequired#a5491dea flags:# apple_signin_allowed:flags. auth.sentCodeTypeFragmentSms#d9565c39 url:string length:int = auth.SentCodeType; -auth.sentCodeTypeFirebaseSms#e57b1432 flags:# nonce:flags.0?bytes receipt:flags.1?string push_timeout:flags.1?int length:int = auth.SentCodeType; +auth.sentCodeTypeFirebaseSms#13c90f17 flags:# nonce:flags.0?bytes play_integrity_nonce:flags.2?bytes receipt:flags.1?string push_timeout:flags.1?int length:int = auth.SentCodeType; auth.sentCodeTypeSmsWord#a416ac81 flags:# beginning:flags.0?string = auth.SentCodeType; @@ -1514,6 +1520,8 @@ upload.webFile#21e753bc size:int mime_type:string file_type:storage.FileType mti payments.paymentForm#a0058751 flags:# can_save_credentials:flags.2?true password_missing:flags.3?true form_id:long bot_id:long title:string description:string photo:flags.5?WebDocument invoice:Invoice provider_id:long url:string native_provider:flags.4?string native_params:flags.4?DataJSON additional_methods:flags.6?Vector saved_info:flags.0?PaymentRequestedInfo saved_credentials:flags.1?Vector users:Vector = payments.PaymentForm; +payments.paymentFormStars#7bf6b15c flags:# form_id:long bot_id:long title:string description:string photo:flags.5?WebDocument invoice:Invoice users:Vector = payments.PaymentForm; + payments.validatedRequestedInfo#d1451883 flags:# id:flags.0?string shipping_options:flags.1?Vector = payments.ValidatedRequestedInfo; payments.paymentResult#4e5f810d updates:Updates = payments.PaymentResult; @@ -1522,6 +1530,8 @@ payments.paymentVerificationNeeded#d8411139 url:string = payments.PaymentResult; payments.paymentReceipt#70c4fe03 flags:# date:int bot_id:long provider_id:long title:string description:string photo:flags.2?WebDocument invoice:Invoice info:flags.0?PaymentRequestedInfo shipping:flags.1?ShippingOption tip_amount:flags.3?long currency:string total_amount:long credentials_title:string users:Vector = payments.PaymentReceipt; +payments.paymentReceiptStars#dabbf83a flags:# date:int bot_id:long title:string description:string photo:flags.2?WebDocument invoice:Invoice currency:string total_amount:long transaction_id:string users:Vector = payments.PaymentReceipt; + payments.savedInfo#fb8fe43c flags:# has_saved_credentials:flags.1?true saved_info:flags.0?PaymentRequestedInfo = payments.SavedInfo; inputPaymentCredentialsSaved#c10eb2cf id:string tmp_password:bytes = InputPaymentCredentials; @@ -2228,6 +2238,8 @@ inputInvoiceSlug#c326caef slug:string = InputInvoice; inputInvoicePremiumGiftCode#98986c0d purpose:InputStorePaymentPurpose option:PremiumGiftCodeOption = InputInvoice; +inputInvoiceStars#1da33ad8 option:StarsTopupOption = InputInvoice; + payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice; messages.transcribedAudio#cfb9d957 flags:# pending:flags.0?true transcription_id:long text:string trial_remains_num:flags.1?int trial_remains_until_date:flags.1?int = messages.TranscribedAudio; @@ -2242,6 +2254,8 @@ 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; + premiumGiftOption#74c34319 flags:# months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumGiftOption; paymentFormMethod#88f8f21b url:string title:string = PaymentFormMethod; @@ -2626,6 +2640,32 @@ reactionsNotifySettings#56e34970 flags:# messages_notify_from:flags.0?ReactionNo broadcastRevenueBalances#8438f1c6 current_balance:long available_balance:long overall_revenue:long = BroadcastRevenueBalances; +availableEffect#93c3e27e flags:# premium_required:flags.2?true id:long emoticon:string static_icon_id:flags.0?long effect_sticker_id:long effect_animation_id:flags.1?long = AvailableEffect; + +messages.availableEffectsNotModified#d1ed9a5b = messages.AvailableEffects; + +messages.availableEffects#bddb616e hash:int effects:Vector documents:Vector = messages.AvailableEffects; + +factCheck#b89bfccf flags:# need_check:flags.0?true country:flags.1?string text:flags.1?TextWithEntities hash:long = FactCheck; + +starsTransactionPeerUnsupported#95f2bfe4 = StarsTransactionPeer; + +starsTransactionPeerAppStore#b457b375 = StarsTransactionPeer; + +starsTransactionPeerPlayMarket#7b560a0b = StarsTransactionPeer; + +starsTransactionPeerPremiumBot#250dbaf8 = StarsTransactionPeer; + +starsTransactionPeerFragment#e92fd902 = StarsTransactionPeer; + +starsTransactionPeer#d80da15d peer:Peer = StarsTransactionPeer; + +starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; + +starsTransaction#cc7079b2 flags:# refund:flags.3?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument = StarsTransaction; + +payments.starsStatus#8cf4ee60 flags:# balance:long history:Vector next_offset:flags.0?string chats:Vector users:Vector = payments.StarsStatus; + ---functions--- @@ -2645,6 +2685,10 @@ invokeWithTakeout#aca9fd2e {X:Type} takeout_id:long query:!X = X; invokeWithBusinessConnection#dd289f8e {X:Type} connection_id:string query:!X = X; +invokeWithGooglePlayIntegrity#1df92984 {X:Type} nonce:string token:string query:!X = X; + +invokeWithApnsSecret#dae54f8 {X:Type} nonce:string secret:string query:!X = X; + auth.sendCode#a677244f phone_number:string api_id:int api_hash:string settings:CodeSettings = auth.SentCode; auth.signUp#aac7b717 flags:# no_joined_notifications:flags.0?true phone_number:string phone_code_hash:string first_name:string last_name:string = auth.Authorization; @@ -2669,7 +2713,7 @@ auth.requestPasswordRecovery#d897bc66 = auth.PasswordRecovery; auth.recoverPassword#37096c70 flags:# code:string new_settings:flags.0?account.PasswordInputSettings = auth.Authorization; -auth.resendCode#3ef1a9bf phone_number:string phone_code_hash:string = auth.SentCode; +auth.resendCode#cae47523 flags:# phone_number:string phone_code_hash:string reason:flags.0?string = auth.SentCode; auth.cancelCode#1f040578 phone_number:string phone_code_hash:string = Bool; @@ -2685,7 +2729,7 @@ auth.checkRecoveryPassword#d36bf79 code:string = Bool; auth.importWebTokenAuthorization#2db873a9 api_id:int api_hash:string web_auth_token:string = auth.Authorization; -auth.requestFirebaseSms#89464b50 flags:# phone_number:string phone_code_hash:string safety_net_token:flags.0?string ios_push_secret:flags.1?string = Bool; +auth.requestFirebaseSms#8e39261e flags:# phone_number:string phone_code_hash:string safety_net_token:flags.0?string play_integrity_token:flags.2?string ios_push_secret:flags.1?string = Bool; auth.resetLoginEmail#7e960193 phone_number:string phone_code_hash:string = auth.SentCode; @@ -2993,9 +3037,9 @@ messages.receivedMessages#5a954c0 max_id:int = Vector; messages.setTyping#58943ee2 flags:# peer:InputPeer top_msg_id:flags.0?int action:SendMessageAction = Bool; -messages.sendMessage#dff8042c flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut = Updates; +messages.sendMessage#983f9745 flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long = Updates; -messages.sendMedia#7bd66041 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut = Updates; +messages.sendMedia#7852834e flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long = Updates; messages.forwardMessages#d5039208 flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer top_msg_id:flags.9?int schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut = Updates; @@ -3153,7 +3197,7 @@ messages.readMentions#36e5bf4d flags:# peer:InputPeer top_msg_id:flags.0?int = m messages.getRecentLocations#702a40e0 peer:InputPeer limit:int hash:long = messages.Messages; -messages.sendMultiMedia#c964709 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut = Updates; +messages.sendMultiMedia#37b74355 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long = Updates; messages.uploadEncryptedFile#5057c497 peer:InputEncryptedChat file:InputEncryptedFile = EncryptedFile; @@ -3393,6 +3437,14 @@ messages.getMyStickers#d0b5e1fc offset_id:long limit:int = messages.MyStickers; messages.getEmojiStickerGroups#1dd840f5 hash:int = messages.EmojiGroups; +messages.getAvailableEffects#dea20a39 hash:int = messages.AvailableEffects; + +messages.editFactCheck#589ee75 peer:InputPeer msg_id:int text:TextWithEntities = Updates; + +messages.deleteFactCheck#d1da940c peer:InputPeer msg_id:int = Updates; + +messages.getFactCheck#b9cdc5ee peer:InputPeer msg_id:Vector = Vector; + 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; @@ -3603,6 +3655,8 @@ channels.reportSponsoredMessage#af8ff6b9 channel:InputChannel random_id:bytes op channels.restrictSponsoredMessages#9ae91519 channel:InputChannel restricted:Bool = Updates; +channels.searchPosts#d19f987b hashtag:string offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; + bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; @@ -3667,6 +3721,16 @@ payments.getGiveawayInfo#f4239425 peer:InputPeer msg_id:int = payments.GiveawayI payments.launchPrepaidGiveaway#5ff58f20 peer:InputPeer giveaway_id:long purpose:InputStorePaymentPurpose = Updates; +payments.getStarsTopupOptions#c00ec7d3 = Vector; + +payments.getStarsStatus#104fcfa7 peer:InputPeer = payments.StarsStatus; + +payments.getStarsTransactions#673ac2f9 flags:# inbound:flags.0?true outbound:flags.1?true peer:InputPeer offset:string = payments.StarsStatus; + +payments.sendStarsForm#2bb731d flags:# form_id:long invoice:InputInvoice = payments.PaymentResult; + +payments.refundStarsCharge#25ae8f4a user_id:InputUser charge_id:string = Updates; + 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; @@ -3881,4 +3945,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 179 +// LAYER 181 diff --git a/_schema/telegram.tl b/_schema/telegram.tl index 3069813663..4576cd2594 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: 179 -// SHA256: 9eb6aa1c5c25c900796809ce40385160142eaebc0ab5b68af4b8a4567fec6f05 +// Layer: 181 +// SHA256: 681a5cff504a6851c9671e750ddd78d022d24b9d22c6411b415582dff0a2b944 boolFalse#bc799737 = Bool; @@ -65,7 +65,7 @@ inputMediaDocumentExternal#fb52dc99 flags:# spoiler:flags.1?true url:string ttl_ inputMediaGame#d33f43f3 id:InputGame = InputMedia; -inputMediaInvoice#8eb5a6d5 flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:string provider_data:DataJSON start_param:flags.1?string extended_media:flags.2?InputMedia = InputMedia; +inputMediaInvoice#405fef0d flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:flags.3?string provider_data:DataJSON start_param:flags.1?string extended_media:flags.2?InputMedia = InputMedia; inputMediaGeoLive#971fa843 flags:# stopped:flags.0?true geo_point:InputGeoPoint heading:flags.2?int period:flags.1?int proximity_notification_radius:flags.3?int = InputMedia; @@ -187,7 +187,7 @@ chatPhoto#1c6e1c11 flags:# has_video:flags.0?true photo_id:long stripped_thumb:f messageEmpty#90a6ca84 flags:# id:int peer_id:flags.0?Peer = Message; -message#2357bf25 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true flags2:# offline:flags2.1?true id:int from_id:flags.8?Peer from_boosts_applied:flags.29?int peer_id:Peer saved_peer_id:flags.28?Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long via_business_bot_id:flags2.0?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int quick_reply_shortcut_id:flags.30?int = Message; +message#94345242 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true flags2:# offline:flags2.1?true id:int from_id:flags.8?Peer from_boosts_applied:flags.29?int peer_id:Peer saved_peer_id:flags.28?Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long via_business_bot_id:flags2.0?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int quick_reply_shortcut_id:flags.30?int effect:flags2.2?long factcheck:flags2.3?FactCheck = Message; messageService#2b085862 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?Peer peer_id:Peer reply_to:flags.3?MessageReplyHeader date:int action:MessageAction ttl_period:flags.25?int = Message; @@ -727,6 +727,10 @@ updateBotDeleteBusinessMessage#a02a982e connection_id:string peer:Peer messages: updateNewStoryReaction#1824e40b story_id:int peer:Peer reaction:Reaction = Update; +updateBroadcastRevenueTransactions#dfd961f5 peer:Peer balances:BroadcastRevenueBalances = Update; + +updateStarsBalance#fb85198 balance:long = Update; + updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.differenceEmpty#5d75a138 date:int seq:int = updates.Difference; @@ -1131,7 +1135,7 @@ messageEntitySpoiler#32ca960f offset:int length:int = MessageEntity; messageEntityCustomEmoji#c8cf05f8 offset:int length:int document_id:long = MessageEntity; -messageEntityBlockquote#20df5d0 offset:int length:int = MessageEntity; +messageEntityBlockquote#f1ccaaac flags:# collapsed:flags.0?true offset:int length:int = MessageEntity; inputChannelEmpty#ee8c1e86 = InputChannel; @@ -1267,7 +1271,7 @@ auth.sentCodeTypeSetUpEmailRequired#a5491dea flags:# apple_signin_allowed:flags. auth.sentCodeTypeFragmentSms#d9565c39 url:string length:int = auth.SentCodeType; -auth.sentCodeTypeFirebaseSms#e57b1432 flags:# nonce:flags.0?bytes receipt:flags.1?string push_timeout:flags.1?int length:int = auth.SentCodeType; +auth.sentCodeTypeFirebaseSms#13c90f17 flags:# nonce:flags.0?bytes play_integrity_nonce:flags.2?bytes receipt:flags.1?string push_timeout:flags.1?int length:int = auth.SentCodeType; auth.sentCodeTypeSmsWord#a416ac81 flags:# beginning:flags.0?string = auth.SentCodeType; @@ -1481,6 +1485,8 @@ upload.webFile#21e753bc size:int mime_type:string file_type:storage.FileType mti payments.paymentForm#a0058751 flags:# can_save_credentials:flags.2?true password_missing:flags.3?true form_id:long bot_id:long title:string description:string photo:flags.5?WebDocument invoice:Invoice provider_id:long url:string native_provider:flags.4?string native_params:flags.4?DataJSON additional_methods:flags.6?Vector saved_info:flags.0?PaymentRequestedInfo saved_credentials:flags.1?Vector users:Vector = payments.PaymentForm; +payments.paymentFormStars#7bf6b15c flags:# form_id:long bot_id:long title:string description:string photo:flags.5?WebDocument invoice:Invoice users:Vector = payments.PaymentForm; + payments.validatedRequestedInfo#d1451883 flags:# id:flags.0?string shipping_options:flags.1?Vector = payments.ValidatedRequestedInfo; payments.paymentResult#4e5f810d updates:Updates = payments.PaymentResult; @@ -1489,6 +1495,8 @@ payments.paymentVerificationNeeded#d8411139 url:string = payments.PaymentResult; payments.paymentReceipt#70c4fe03 flags:# date:int bot_id:long provider_id:long title:string description:string photo:flags.2?WebDocument invoice:Invoice info:flags.0?PaymentRequestedInfo shipping:flags.1?ShippingOption tip_amount:flags.3?long currency:string total_amount:long credentials_title:string users:Vector = payments.PaymentReceipt; +payments.paymentReceiptStars#dabbf83a flags:# date:int bot_id:long title:string description:string photo:flags.2?WebDocument invoice:Invoice currency:string total_amount:long transaction_id:string users:Vector = payments.PaymentReceipt; + payments.savedInfo#fb8fe43c flags:# has_saved_credentials:flags.1?true saved_info:flags.0?PaymentRequestedInfo = payments.SavedInfo; inputPaymentCredentialsSaved#c10eb2cf id:string tmp_password:bytes = InputPaymentCredentials; @@ -2195,6 +2203,8 @@ inputInvoiceSlug#c326caef slug:string = InputInvoice; inputInvoicePremiumGiftCode#98986c0d purpose:InputStorePaymentPurpose option:PremiumGiftCodeOption = InputInvoice; +inputInvoiceStars#1da33ad8 option:StarsTopupOption = InputInvoice; + payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice; messages.transcribedAudio#cfb9d957 flags:# pending:flags.0?true transcription_id:long text:string trial_remains_num:flags.1?int trial_remains_until_date:flags.1?int = messages.TranscribedAudio; @@ -2209,6 +2219,8 @@ 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; + premiumGiftOption#74c34319 flags:# months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumGiftOption; paymentFormMethod#88f8f21b url:string title:string = PaymentFormMethod; @@ -2593,6 +2605,32 @@ reactionsNotifySettings#56e34970 flags:# messages_notify_from:flags.0?ReactionNo broadcastRevenueBalances#8438f1c6 current_balance:long available_balance:long overall_revenue:long = BroadcastRevenueBalances; +availableEffect#93c3e27e flags:# premium_required:flags.2?true id:long emoticon:string static_icon_id:flags.0?long effect_sticker_id:long effect_animation_id:flags.1?long = AvailableEffect; + +messages.availableEffectsNotModified#d1ed9a5b = messages.AvailableEffects; + +messages.availableEffects#bddb616e hash:int effects:Vector documents:Vector = messages.AvailableEffects; + +factCheck#b89bfccf flags:# need_check:flags.0?true country:flags.1?string text:flags.1?TextWithEntities hash:long = FactCheck; + +starsTransactionPeerUnsupported#95f2bfe4 = StarsTransactionPeer; + +starsTransactionPeerAppStore#b457b375 = StarsTransactionPeer; + +starsTransactionPeerPlayMarket#7b560a0b = StarsTransactionPeer; + +starsTransactionPeerPremiumBot#250dbaf8 = StarsTransactionPeer; + +starsTransactionPeerFragment#e92fd902 = StarsTransactionPeer; + +starsTransactionPeer#d80da15d peer:Peer = StarsTransactionPeer; + +starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; + +starsTransaction#cc7079b2 flags:# refund:flags.3?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument = StarsTransaction; + +payments.starsStatus#8cf4ee60 flags:# balance:long history:Vector next_offset:flags.0?string chats:Vector users:Vector = payments.StarsStatus; + ---functions--- @@ -2612,6 +2650,10 @@ invokeWithTakeout#aca9fd2e {X:Type} takeout_id:long query:!X = X; invokeWithBusinessConnection#dd289f8e {X:Type} connection_id:string query:!X = X; +invokeWithGooglePlayIntegrity#1df92984 {X:Type} nonce:string token:string query:!X = X; + +invokeWithApnsSecret#dae54f8 {X:Type} nonce:string secret:string query:!X = X; + auth.sendCode#a677244f phone_number:string api_id:int api_hash:string settings:CodeSettings = auth.SentCode; auth.signUp#aac7b717 flags:# no_joined_notifications:flags.0?true phone_number:string phone_code_hash:string first_name:string last_name:string = auth.Authorization; @@ -2636,7 +2678,7 @@ auth.requestPasswordRecovery#d897bc66 = auth.PasswordRecovery; auth.recoverPassword#37096c70 flags:# code:string new_settings:flags.0?account.PasswordInputSettings = auth.Authorization; -auth.resendCode#3ef1a9bf phone_number:string phone_code_hash:string = auth.SentCode; +auth.resendCode#cae47523 flags:# phone_number:string phone_code_hash:string reason:flags.0?string = auth.SentCode; auth.cancelCode#1f040578 phone_number:string phone_code_hash:string = Bool; @@ -2652,7 +2694,7 @@ auth.checkRecoveryPassword#d36bf79 code:string = Bool; auth.importWebTokenAuthorization#2db873a9 api_id:int api_hash:string web_auth_token:string = auth.Authorization; -auth.requestFirebaseSms#89464b50 flags:# phone_number:string phone_code_hash:string safety_net_token:flags.0?string ios_push_secret:flags.1?string = Bool; +auth.requestFirebaseSms#8e39261e flags:# phone_number:string phone_code_hash:string safety_net_token:flags.0?string play_integrity_token:flags.2?string ios_push_secret:flags.1?string = Bool; auth.resetLoginEmail#7e960193 phone_number:string phone_code_hash:string = auth.SentCode; @@ -2960,9 +3002,9 @@ messages.receivedMessages#5a954c0 max_id:int = Vector; messages.setTyping#58943ee2 flags:# peer:InputPeer top_msg_id:flags.0?int action:SendMessageAction = Bool; -messages.sendMessage#dff8042c flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut = Updates; +messages.sendMessage#983f9745 flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long = Updates; -messages.sendMedia#7bd66041 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut = Updates; +messages.sendMedia#7852834e flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long = Updates; messages.forwardMessages#d5039208 flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer top_msg_id:flags.9?int schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut = Updates; @@ -3120,7 +3162,7 @@ messages.readMentions#36e5bf4d flags:# peer:InputPeer top_msg_id:flags.0?int = m messages.getRecentLocations#702a40e0 peer:InputPeer limit:int hash:long = messages.Messages; -messages.sendMultiMedia#c964709 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut = Updates; +messages.sendMultiMedia#37b74355 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long = Updates; messages.uploadEncryptedFile#5057c497 peer:InputEncryptedChat file:InputEncryptedFile = EncryptedFile; @@ -3360,6 +3402,14 @@ messages.getMyStickers#d0b5e1fc offset_id:long limit:int = messages.MyStickers; messages.getEmojiStickerGroups#1dd840f5 hash:int = messages.EmojiGroups; +messages.getAvailableEffects#dea20a39 hash:int = messages.AvailableEffects; + +messages.editFactCheck#589ee75 peer:InputPeer msg_id:int text:TextWithEntities = Updates; + +messages.deleteFactCheck#d1da940c peer:InputPeer msg_id:int = Updates; + +messages.getFactCheck#b9cdc5ee peer:InputPeer msg_id:Vector = Vector; + 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; @@ -3570,6 +3620,8 @@ channels.reportSponsoredMessage#af8ff6b9 channel:InputChannel random_id:bytes op channels.restrictSponsoredMessages#9ae91519 channel:InputChannel restricted:Bool = Updates; +channels.searchPosts#d19f987b hashtag:string offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; + bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; @@ -3634,6 +3686,16 @@ payments.getGiveawayInfo#f4239425 peer:InputPeer msg_id:int = payments.GiveawayI payments.launchPrepaidGiveaway#5ff58f20 peer:InputPeer giveaway_id:long purpose:InputStorePaymentPurpose = Updates; +payments.getStarsTopupOptions#c00ec7d3 = Vector; + +payments.getStarsStatus#104fcfa7 peer:InputPeer = payments.StarsStatus; + +payments.getStarsTransactions#673ac2f9 flags:# inbound:flags.0?true outbound:flags.1?true peer:InputPeer offset:string = payments.StarsStatus; + +payments.sendStarsForm#2bb731d flags:# form_id:long invoice:InputInvoice = payments.PaymentResult; + +payments.refundStarsCharge#25ae8f4a user_id:InputUser charge_id:string = Updates; + 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; @@ -3880,4 +3942,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 179 +// LAYER 181 diff --git a/bin/encode_bench_test.go b/bin/encode_bench_test.go index e5a4a6fdf6..c61027cf0a 100644 --- a/bin/encode_bench_test.go +++ b/bin/encode_bench_test.go @@ -27,7 +27,7 @@ func BenchmarkDecodeSlice(b *testing.B) { styling.TextURL("clickme", "https://google.com"), styling.Plain("\n\n"), styling.Phone("+71234567891"), styling.Plain("\n\n"), styling.Cashtag("$CASHTAG"), styling.Plain("\n\n"), - styling.Blockquote("blockquote"), styling.Plain("\n\n"), + styling.Blockquote("blockquote", false), styling.Plain("\n\n"), styling.BankCard("5550111111111111"), styling.Plain("\n\n"), ); err != nil { b.Fatal(err) diff --git a/examples/go.mod b/examples/go.mod index c49612a5b6..15689ede5a 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -12,7 +12,7 @@ require ( go.uber.org/atomic v1.11.0 go.uber.org/zap v1.27.0 golang.org/x/sync v0.7.0 - golang.org/x/term v0.19.0 + golang.org/x/term v0.21.0 golang.org/x/time v0.5.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 ) @@ -43,14 +43,14 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/segmentio/asm v1.2.0 // indirect - go.opentelemetry.io/otel v1.25.0 // indirect - go.opentelemetry.io/otel/trace v1.25.0 // indirect + go.opentelemetry.io/otel v1.26.0 // indirect + go.opentelemetry.io/otel/trace v1.26.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.22.0 // indirect + golang.org/x/crypto v0.24.0 // indirect golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect - golang.org/x/net v0.24.0 // indirect - golang.org/x/sys v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect google.golang.org/protobuf v1.33.0 // indirect nhooyr.io/websocket v1.8.11 // indirect rsc.io/qr v0.2.0 // indirect diff --git a/examples/go.sum b/examples/go.sum index d6f5a630c0..5199637ff9 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -80,10 +80,10 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.9 h1:8x7aARPEXiXbHmtUwAIv7eV2fQFHrLLavdiJ3uzJXoI= go.etcd.io/bbolt v1.3.9/go.mod h1:zaO32+Ti0PK1ivdPtgMESzuzL2VPoIG1PCQNvOdo/dE= -go.opentelemetry.io/otel v1.25.0 h1:gldB5FfhRl7OJQbUHt/8s0a7cE8fbsPAtdpRaApKy4k= -go.opentelemetry.io/otel v1.25.0/go.mod h1:Wa2ds5NOXEMkCmUou1WA7ZBfLTHWIsp034OVD7AO+Vg= -go.opentelemetry.io/otel/trace v1.25.0 h1:tqukZGLwQYRIFtSQM2u2+yfMVTgGVeqRLPUYx1Dq6RM= -go.opentelemetry.io/otel/trace v1.25.0/go.mod h1:hCCs70XM/ljO+BeQkyFnbK28SBIJ/Emuha+ccrCRT7I= +go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs= +go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4= +go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA= +go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= @@ -95,8 +95,8 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -105,8 +105,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -116,14 +116,14 @@ golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= +golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/telegram/message/entity/options.gen.go b/telegram/message/entity/options.gen.go index 9c67208eef..03ae5c0767 100644 --- a/telegram/message/entity/options.gen.go +++ b/telegram/message/entity/options.gen.go @@ -380,11 +380,12 @@ func (b *Builder) CustomEmoji(s string, documentID int64) *Builder { // Blockquote creates Formatter of Blockquote message entity. // // See https://core.telegram.org/constructor/messageEntityBlockquote. -func Blockquote() Formatter { +func Blockquote(collapsed bool) Formatter { return func(offset, length int) tg.MessageEntityClass { return &tg.MessageEntityBlockquote{ - Offset: offset, - Length: length, + Offset: offset, + Length: length, + Collapsed: collapsed, } } } @@ -392,6 +393,6 @@ func Blockquote() Formatter { // Blockquote adds and formats message as Blockquote message entity. // // See https://core.telegram.org/constructor/messageEntityBlockquote. -func (b *Builder) Blockquote(s string) *Builder { - return b.Format(s, Blockquote()) +func (b *Builder) Blockquote(s string, collapsed bool) *Builder { + return b.Format(s, Blockquote(collapsed)) } diff --git a/telegram/message/entity/options_test.go b/telegram/message/entity/options_test.go index 0ec459486e..4b9333c89c 100644 --- a/telegram/message/entity/options_test.go +++ b/telegram/message/entity/options_test.go @@ -168,7 +168,7 @@ func TestBuilder(t *testing.T) { }, r) }) t.Run("Blockquote", func(t *testing.T) { - _, ent := b.Blockquote("abc").Complete() + _, ent := b.Blockquote("abc", false).Complete() r := ent[0] require.Equal(t, &tg.MessageEntityBlockquote{ Offset: 0, diff --git a/telegram/message/style_example_test.go b/telegram/message/style_example_test.go index 98ef2a88c0..ee8a729f25 100644 --- a/telegram/message/style_example_test.go +++ b/telegram/message/style_example_test.go @@ -37,7 +37,7 @@ func sendStyledText(ctx context.Context) error { styling.TextURL("clickme", "https://google.com"), styling.Plain("\n\n"), styling.Phone("+71234567891"), styling.Plain("\n\n"), styling.Cashtag("$CASHTAG"), styling.Plain("\n\n"), - styling.Blockquote("blockquote"), styling.Plain("\n\n"), + styling.Blockquote("blockquote", false), styling.Plain("\n\n"), styling.BankCard("5550111111111111"), styling.Plain("\n\n"), } diff --git a/telegram/message/styling/options.gen.go b/telegram/message/styling/options.gen.go index df6f7402a6..4c4b9b2589 100644 --- a/telegram/message/styling/options.gen.go +++ b/telegram/message/styling/options.gen.go @@ -205,9 +205,9 @@ func CustomEmoji(s string, documentID int64) StyledTextOption { // Blockquote formats text as Blockquote entity. // // See https://core.telegram.org/constructor/messageEntityBlockquote. -func Blockquote(s string) StyledTextOption { +func Blockquote(s string, collapsed bool) StyledTextOption { return styledTextOption(s, func(b *textBuilder) error { - b.Blockquote(s) + b.Blockquote(s, collapsed) return nil }) } diff --git a/telegram/message/text_test.go b/telegram/message/text_test.go index 325e38ae51..05541d925f 100644 --- a/telegram/message/text_test.go +++ b/telegram/message/text_test.go @@ -83,7 +83,9 @@ func TestBuilder_StyledText(t *testing.T) { {"Strike", styling.Strike, func(o int) tg.MessageEntityClass { return &tg.MessageEntityStrike{Length: o} }}, - {"Blockquote", styling.Blockquote, func(o int) tg.MessageEntityClass { + {"Blockquote", func(msg string) StyledTextOption { + return styling.Blockquote(msg, false) + }, func(o int) tg.MessageEntityClass { return &tg.MessageEntityBlockquote{Length: o} }}, {"BankCard", styling.BankCard, func(o int) tg.MessageEntityClass { diff --git a/telegram/query/messages/queries.gen.go b/telegram/query/messages/queries.gen.go index 6f67c87e40..a89db4e18a 100644 --- a/telegram/query/messages/queries.gen.go +++ b/telegram/query/messages/queries.gen.go @@ -47,6 +47,104 @@ func NewQueryBuilder(raw *tg.Client) *QueryBuilder { return &QueryBuilder{raw: raw} } +// ChannelsSearchPostsQueryBuilder is query builder of ChannelsSearchPosts. +type ChannelsSearchPostsQueryBuilder struct { + raw *tg.Client + req tg.ChannelsSearchPostsRequest + batchSize int + offsetID int + offsetPeer tg.InputPeerClass + offsetRate int +} + +// ChannelsSearchPosts creates query builder of ChannelsSearchPosts. +func (q *QueryBuilder) ChannelsSearchPosts() *ChannelsSearchPostsQueryBuilder { + b := &ChannelsSearchPostsQueryBuilder{ + raw: q.raw, + batchSize: 1, + req: tg.ChannelsSearchPostsRequest{}, + } + + return b +} + +// BatchSize sets buffer of message loaded from one request. +// Be carefully, when set this limit, because Telegram does not return error if limit is too big, +// so results can be incorrect. +func (b *ChannelsSearchPostsQueryBuilder) BatchSize(batchSize int) *ChannelsSearchPostsQueryBuilder { + b.batchSize = batchSize + return b +} + +// OffsetID sets offsetID from which iterate start. +func (b *ChannelsSearchPostsQueryBuilder) OffsetID(offsetID int) *ChannelsSearchPostsQueryBuilder { + b.offsetID = offsetID + return b +} + +// Hashtag sets Hashtag field of ChannelsSearchPosts query. +func (b *ChannelsSearchPostsQueryBuilder) Hashtag(paramHashtag string) *ChannelsSearchPostsQueryBuilder { + b.req.Hashtag = paramHashtag + return b +} + +// Query implements Query interface. +func (b *ChannelsSearchPostsQueryBuilder) Query(ctx context.Context, req Request) (tg.MessagesMessagesClass, error) { + r := &tg.ChannelsSearchPostsRequest{ + Limit: req.Limit, + } + + r.Hashtag = b.req.Hashtag + r.OffsetID = req.OffsetID + r.OffsetPeer = req.OffsetPeer + r.OffsetRate = req.OffsetRate + return b.raw.ChannelsSearchPosts(ctx, r) +} + +// Iter returns iterator using built query. +func (b *ChannelsSearchPostsQueryBuilder) Iter() *Iterator { + iter := NewIterator(b, b.batchSize) + iter = iter.OffsetID(b.offsetID) + return iter +} + +// ForEach calls given callback on each iterator element. +func (b *ChannelsSearchPostsQueryBuilder) ForEach(ctx context.Context, cb func(context.Context, Elem) error) error { + iter := b.Iter() + for iter.Next(ctx) { + if err := cb(ctx, iter.Value()); err != nil { + return err + } + } + return iter.Err() +} + +// Count fetches remote state to get number of elements. +func (b *ChannelsSearchPostsQueryBuilder) Count(ctx context.Context) (int, error) { + iter := b.Iter() + c, err := iter.Total(ctx) + if err != nil { + return 0, errors.Wrap(err, "get total") + } + return c, nil +} + +// Collect creates iterator and collects all elements to slice. +func (b *ChannelsSearchPostsQueryBuilder) Collect(ctx context.Context) ([]Elem, error) { + iter := b.Iter() + c, err := iter.Total(ctx) + if err != nil { + return nil, errors.Wrap(err, "get total") + } + + r := make([]Elem, 0, c) + for iter.Next(ctx) { + r = append(r, iter.Value()) + } + + return r, iter.Err() +} + // GetHistoryQueryBuilder is query builder of MessagesGetHistory. type GetHistoryQueryBuilder struct { raw *tg.Client diff --git a/tg/tl_auth_request_firebase_sms_gen.go b/tg/tl_auth_request_firebase_sms_gen.go index 5fd97d0c0f..d8ab02fb89 100644 --- a/tg/tl_auth_request_firebase_sms_gen.go +++ b/tg/tl_auth_request_firebase_sms_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// AuthRequestFirebaseSMSRequest represents TL type `auth.requestFirebaseSms#89464b50`. +// AuthRequestFirebaseSMSRequest represents TL type `auth.requestFirebaseSms#8e39261e`. // Request an SMS code via Firebase. // // See https://core.telegram.org/method/auth.requestFirebaseSms for reference. @@ -55,6 +55,10 @@ type AuthRequestFirebaseSMSRequest struct { // // Use SetSafetyNetToken and GetSafetyNetToken helpers. SafetyNetToken string + // PlayIntegrityToken field of AuthRequestFirebaseSMSRequest. + // + // Use SetPlayIntegrityToken and GetPlayIntegrityToken helpers. + PlayIntegrityToken string // Secret token received via an apple push notification // // Use SetIosPushSecret and GetIosPushSecret helpers. @@ -62,7 +66,7 @@ type AuthRequestFirebaseSMSRequest struct { } // AuthRequestFirebaseSMSRequestTypeID is TL type id of AuthRequestFirebaseSMSRequest. -const AuthRequestFirebaseSMSRequestTypeID = 0x89464b50 +const AuthRequestFirebaseSMSRequestTypeID = 0x8e39261e // Ensuring interfaces in compile-time for AuthRequestFirebaseSMSRequest. var ( @@ -88,6 +92,9 @@ func (r *AuthRequestFirebaseSMSRequest) Zero() bool { if !(r.SafetyNetToken == "") { return false } + if !(r.PlayIntegrityToken == "") { + return false + } if !(r.IosPushSecret == "") { return false } @@ -109,6 +116,7 @@ func (r *AuthRequestFirebaseSMSRequest) FillFrom(from interface { GetPhoneNumber() (value string) GetPhoneCodeHash() (value string) GetSafetyNetToken() (value string, ok bool) + GetPlayIntegrityToken() (value string, ok bool) GetIosPushSecret() (value string, ok bool) }) { r.PhoneNumber = from.GetPhoneNumber() @@ -117,6 +125,10 @@ func (r *AuthRequestFirebaseSMSRequest) FillFrom(from interface { r.SafetyNetToken = val } + if val, ok := from.GetPlayIntegrityToken(); ok { + r.PlayIntegrityToken = val + } + if val, ok := from.GetIosPushSecret(); ok { r.IosPushSecret = val } @@ -159,6 +171,11 @@ func (r *AuthRequestFirebaseSMSRequest) TypeInfo() tdp.Type { SchemaName: "safety_net_token", Null: !r.Flags.Has(0), }, + { + Name: "PlayIntegrityToken", + SchemaName: "play_integrity_token", + Null: !r.Flags.Has(2), + }, { Name: "IosPushSecret", SchemaName: "ios_push_secret", @@ -173,6 +190,9 @@ func (r *AuthRequestFirebaseSMSRequest) SetFlags() { if !(r.SafetyNetToken == "") { r.Flags.Set(0) } + if !(r.PlayIntegrityToken == "") { + r.Flags.Set(2) + } if !(r.IosPushSecret == "") { r.Flags.Set(1) } @@ -181,7 +201,7 @@ func (r *AuthRequestFirebaseSMSRequest) SetFlags() { // Encode implements bin.Encoder. func (r *AuthRequestFirebaseSMSRequest) Encode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode auth.requestFirebaseSms#89464b50 as nil") + return fmt.Errorf("can't encode auth.requestFirebaseSms#8e39261e as nil") } b.PutID(AuthRequestFirebaseSMSRequestTypeID) return r.EncodeBare(b) @@ -190,17 +210,20 @@ func (r *AuthRequestFirebaseSMSRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (r *AuthRequestFirebaseSMSRequest) EncodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode auth.requestFirebaseSms#89464b50 as nil") + return fmt.Errorf("can't encode auth.requestFirebaseSms#8e39261e as nil") } r.SetFlags() if err := r.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode auth.requestFirebaseSms#89464b50: field flags: %w", err) + return fmt.Errorf("unable to encode auth.requestFirebaseSms#8e39261e: field flags: %w", err) } b.PutString(r.PhoneNumber) b.PutString(r.PhoneCodeHash) if r.Flags.Has(0) { b.PutString(r.SafetyNetToken) } + if r.Flags.Has(2) { + b.PutString(r.PlayIntegrityToken) + } if r.Flags.Has(1) { b.PutString(r.IosPushSecret) } @@ -210,10 +233,10 @@ func (r *AuthRequestFirebaseSMSRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (r *AuthRequestFirebaseSMSRequest) Decode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode auth.requestFirebaseSms#89464b50 to nil") + return fmt.Errorf("can't decode auth.requestFirebaseSms#8e39261e to nil") } if err := b.ConsumeID(AuthRequestFirebaseSMSRequestTypeID); err != nil { - return fmt.Errorf("unable to decode auth.requestFirebaseSms#89464b50: %w", err) + return fmt.Errorf("unable to decode auth.requestFirebaseSms#8e39261e: %w", err) } return r.DecodeBare(b) } @@ -221,38 +244,45 @@ func (r *AuthRequestFirebaseSMSRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (r *AuthRequestFirebaseSMSRequest) DecodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode auth.requestFirebaseSms#89464b50 to nil") + return fmt.Errorf("can't decode auth.requestFirebaseSms#8e39261e to nil") } { if err := r.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode auth.requestFirebaseSms#89464b50: field flags: %w", err) + return fmt.Errorf("unable to decode auth.requestFirebaseSms#8e39261e: field flags: %w", err) } } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode auth.requestFirebaseSms#89464b50: field phone_number: %w", err) + return fmt.Errorf("unable to decode auth.requestFirebaseSms#8e39261e: field phone_number: %w", err) } r.PhoneNumber = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode auth.requestFirebaseSms#89464b50: field phone_code_hash: %w", err) + return fmt.Errorf("unable to decode auth.requestFirebaseSms#8e39261e: field phone_code_hash: %w", err) } r.PhoneCodeHash = value } if r.Flags.Has(0) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode auth.requestFirebaseSms#89464b50: field safety_net_token: %w", err) + return fmt.Errorf("unable to decode auth.requestFirebaseSms#8e39261e: field safety_net_token: %w", err) } r.SafetyNetToken = value } + if r.Flags.Has(2) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.requestFirebaseSms#8e39261e: field play_integrity_token: %w", err) + } + r.PlayIntegrityToken = value + } if r.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode auth.requestFirebaseSms#89464b50: field ios_push_secret: %w", err) + return fmt.Errorf("unable to decode auth.requestFirebaseSms#8e39261e: field ios_push_secret: %w", err) } r.IosPushSecret = value } @@ -293,6 +323,24 @@ func (r *AuthRequestFirebaseSMSRequest) GetSafetyNetToken() (value string, ok bo return r.SafetyNetToken, true } +// SetPlayIntegrityToken sets value of PlayIntegrityToken conditional field. +func (r *AuthRequestFirebaseSMSRequest) SetPlayIntegrityToken(value string) { + r.Flags.Set(2) + r.PlayIntegrityToken = value +} + +// GetPlayIntegrityToken returns value of PlayIntegrityToken conditional field and +// boolean which is true if field was set. +func (r *AuthRequestFirebaseSMSRequest) GetPlayIntegrityToken() (value string, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(2) { + return value, false + } + return r.PlayIntegrityToken, true +} + // SetIosPushSecret sets value of IosPushSecret conditional field. func (r *AuthRequestFirebaseSMSRequest) SetIosPushSecret(value string) { r.Flags.Set(1) @@ -311,7 +359,7 @@ func (r *AuthRequestFirebaseSMSRequest) GetIosPushSecret() (value string, ok boo return r.IosPushSecret, true } -// AuthRequestFirebaseSMS invokes method auth.requestFirebaseSms#89464b50 returning error if any. +// AuthRequestFirebaseSMS invokes method auth.requestFirebaseSms#8e39261e returning error if any. // Request an SMS code via Firebase. // // Possible errors: diff --git a/tg/tl_auth_resend_code_gen.go b/tg/tl_auth_resend_code_gen.go index deca913bbe..ceeb2619a3 100644 --- a/tg/tl_auth_resend_code_gen.go +++ b/tg/tl_auth_resend_code_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// AuthResendCodeRequest represents TL type `auth.resendCode#3ef1a9bf`. +// AuthResendCodeRequest represents TL type `auth.resendCode#cae47523`. // Resend the login code via another medium, the phone code type is determined by the // return value of the previous auth.sendCode/auth.resendCode: see login¹ for more info. // @@ -40,6 +40,8 @@ var ( // // See https://core.telegram.org/method/auth.resendCode for reference. type AuthResendCodeRequest struct { + // Flags field of AuthResendCodeRequest. + Flags bin.Fields // The phone number PhoneNumber string // The phone code hash obtained from auth.sendCode¹ @@ -47,10 +49,14 @@ type AuthResendCodeRequest struct { // Links: // 1) https://core.telegram.org/method/auth.sendCode PhoneCodeHash string + // Reason field of AuthResendCodeRequest. + // + // Use SetReason and GetReason helpers. + Reason string } // AuthResendCodeRequestTypeID is TL type id of AuthResendCodeRequest. -const AuthResendCodeRequestTypeID = 0x3ef1a9bf +const AuthResendCodeRequestTypeID = 0xcae47523 // Ensuring interfaces in compile-time for AuthResendCodeRequest. var ( @@ -64,12 +70,18 @@ func (r *AuthResendCodeRequest) Zero() bool { if r == nil { return true } + if !(r.Flags.Zero()) { + return false + } if !(r.PhoneNumber == "") { return false } if !(r.PhoneCodeHash == "") { return false } + if !(r.Reason == "") { + return false + } return true } @@ -87,9 +99,14 @@ func (r *AuthResendCodeRequest) String() string { func (r *AuthResendCodeRequest) FillFrom(from interface { GetPhoneNumber() (value string) GetPhoneCodeHash() (value string) + GetReason() (value string, ok bool) }) { r.PhoneNumber = from.GetPhoneNumber() r.PhoneCodeHash = from.GetPhoneCodeHash() + if val, ok := from.GetReason(); ok { + r.Reason = val + } + } // TypeID returns type id in TL schema. @@ -123,14 +140,26 @@ func (r *AuthResendCodeRequest) TypeInfo() tdp.Type { Name: "PhoneCodeHash", SchemaName: "phone_code_hash", }, + { + Name: "Reason", + SchemaName: "reason", + Null: !r.Flags.Has(0), + }, } return typ } +// SetFlags sets flags for non-zero fields. +func (r *AuthResendCodeRequest) SetFlags() { + if !(r.Reason == "") { + r.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (r *AuthResendCodeRequest) Encode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode auth.resendCode#3ef1a9bf as nil") + return fmt.Errorf("can't encode auth.resendCode#cae47523 as nil") } b.PutID(AuthResendCodeRequestTypeID) return r.EncodeBare(b) @@ -139,20 +168,27 @@ func (r *AuthResendCodeRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (r *AuthResendCodeRequest) EncodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode auth.resendCode#3ef1a9bf as nil") + return fmt.Errorf("can't encode auth.resendCode#cae47523 as nil") + } + r.SetFlags() + if err := r.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode auth.resendCode#cae47523: field flags: %w", err) } b.PutString(r.PhoneNumber) b.PutString(r.PhoneCodeHash) + if r.Flags.Has(0) { + b.PutString(r.Reason) + } return nil } // Decode implements bin.Decoder. func (r *AuthResendCodeRequest) Decode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode auth.resendCode#3ef1a9bf to nil") + return fmt.Errorf("can't decode auth.resendCode#cae47523 to nil") } if err := b.ConsumeID(AuthResendCodeRequestTypeID); err != nil { - return fmt.Errorf("unable to decode auth.resendCode#3ef1a9bf: %w", err) + return fmt.Errorf("unable to decode auth.resendCode#cae47523: %w", err) } return r.DecodeBare(b) } @@ -160,22 +196,34 @@ func (r *AuthResendCodeRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (r *AuthResendCodeRequest) DecodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode auth.resendCode#3ef1a9bf to nil") + return fmt.Errorf("can't decode auth.resendCode#cae47523 to nil") + } + { + if err := r.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode auth.resendCode#cae47523: field flags: %w", err) + } } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode auth.resendCode#3ef1a9bf: field phone_number: %w", err) + return fmt.Errorf("unable to decode auth.resendCode#cae47523: field phone_number: %w", err) } r.PhoneNumber = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode auth.resendCode#3ef1a9bf: field phone_code_hash: %w", err) + return fmt.Errorf("unable to decode auth.resendCode#cae47523: field phone_code_hash: %w", err) } r.PhoneCodeHash = value } + if r.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.resendCode#cae47523: field reason: %w", err) + } + r.Reason = value + } return nil } @@ -195,7 +243,25 @@ func (r *AuthResendCodeRequest) GetPhoneCodeHash() (value string) { return r.PhoneCodeHash } -// AuthResendCode invokes method auth.resendCode#3ef1a9bf returning error if any. +// SetReason sets value of Reason conditional field. +func (r *AuthResendCodeRequest) SetReason(value string) { + r.Flags.Set(0) + r.Reason = value +} + +// GetReason returns value of Reason conditional field and +// boolean which is true if field was set. +func (r *AuthResendCodeRequest) GetReason() (value string, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(0) { + return value, false + } + return r.Reason, true +} + +// AuthResendCode invokes method auth.resendCode#cae47523 returning error if any. // Resend the login code via another medium, the phone code type is determined by the // return value of the previous auth.sendCode/auth.resendCode: see login¹ for more info. // diff --git a/tg/tl_auth_sent_code_type_gen.go b/tg/tl_auth_sent_code_type_gen.go index 9790a9b5a3..3568c7008b 100644 --- a/tg/tl_auth_sent_code_type_gen.go +++ b/tg/tl_auth_sent_code_type_gen.go @@ -1473,7 +1473,7 @@ func (s *AuthSentCodeTypeFragmentSMS) GetLength() (value int) { return s.Length } -// AuthSentCodeTypeFirebaseSMS represents TL type `auth.sentCodeTypeFirebaseSms#e57b1432`. +// AuthSentCodeTypeFirebaseSMS represents TL type `auth.sentCodeTypeFirebaseSms#13c90f17`. // An authentication code should be delivered via SMS after Firebase attestation, as // described in the auth documentation »¹. // @@ -1494,6 +1494,10 @@ type AuthSentCodeTypeFirebaseSMS struct { // // Use SetNonce and GetNonce helpers. Nonce []byte + // PlayIntegrityNonce field of AuthSentCodeTypeFirebaseSMS. + // + // Use SetPlayIntegrityNonce and GetPlayIntegrityNonce helpers. + PlayIntegrityNonce []byte // On iOS, must be compared with the receipt extracted from the received push // notification. // @@ -1513,7 +1517,7 @@ type AuthSentCodeTypeFirebaseSMS struct { } // AuthSentCodeTypeFirebaseSMSTypeID is TL type id of AuthSentCodeTypeFirebaseSMS. -const AuthSentCodeTypeFirebaseSMSTypeID = 0xe57b1432 +const AuthSentCodeTypeFirebaseSMSTypeID = 0x13c90f17 // construct implements constructor of AuthSentCodeTypeClass. func (s AuthSentCodeTypeFirebaseSMS) construct() AuthSentCodeTypeClass { return &s } @@ -1538,6 +1542,9 @@ func (s *AuthSentCodeTypeFirebaseSMS) Zero() bool { if !(s.Nonce == nil) { return false } + if !(s.PlayIntegrityNonce == nil) { + return false + } if !(s.Receipt == "") { return false } @@ -1563,6 +1570,7 @@ func (s *AuthSentCodeTypeFirebaseSMS) String() string { // FillFrom fills AuthSentCodeTypeFirebaseSMS from given interface. func (s *AuthSentCodeTypeFirebaseSMS) FillFrom(from interface { GetNonce() (value []byte, ok bool) + GetPlayIntegrityNonce() (value []byte, ok bool) GetReceipt() (value string, ok bool) GetPushTimeout() (value int, ok bool) GetLength() (value int) @@ -1571,6 +1579,10 @@ func (s *AuthSentCodeTypeFirebaseSMS) FillFrom(from interface { s.Nonce = val } + if val, ok := from.GetPlayIntegrityNonce(); ok { + s.PlayIntegrityNonce = val + } + if val, ok := from.GetReceipt(); ok { s.Receipt = val } @@ -1610,6 +1622,11 @@ func (s *AuthSentCodeTypeFirebaseSMS) TypeInfo() tdp.Type { SchemaName: "nonce", Null: !s.Flags.Has(0), }, + { + Name: "PlayIntegrityNonce", + SchemaName: "play_integrity_nonce", + Null: !s.Flags.Has(2), + }, { Name: "Receipt", SchemaName: "receipt", @@ -1633,6 +1650,9 @@ func (s *AuthSentCodeTypeFirebaseSMS) SetFlags() { if !(s.Nonce == nil) { s.Flags.Set(0) } + if !(s.PlayIntegrityNonce == nil) { + s.Flags.Set(2) + } if !(s.Receipt == "") { s.Flags.Set(1) } @@ -1644,7 +1664,7 @@ func (s *AuthSentCodeTypeFirebaseSMS) SetFlags() { // Encode implements bin.Encoder. func (s *AuthSentCodeTypeFirebaseSMS) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode auth.sentCodeTypeFirebaseSms#e57b1432 as nil") + return fmt.Errorf("can't encode auth.sentCodeTypeFirebaseSms#13c90f17 as nil") } b.PutID(AuthSentCodeTypeFirebaseSMSTypeID) return s.EncodeBare(b) @@ -1653,15 +1673,18 @@ func (s *AuthSentCodeTypeFirebaseSMS) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *AuthSentCodeTypeFirebaseSMS) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode auth.sentCodeTypeFirebaseSms#e57b1432 as nil") + return fmt.Errorf("can't encode auth.sentCodeTypeFirebaseSms#13c90f17 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode auth.sentCodeTypeFirebaseSms#e57b1432: field flags: %w", err) + return fmt.Errorf("unable to encode auth.sentCodeTypeFirebaseSms#13c90f17: field flags: %w", err) } if s.Flags.Has(0) { b.PutBytes(s.Nonce) } + if s.Flags.Has(2) { + b.PutBytes(s.PlayIntegrityNonce) + } if s.Flags.Has(1) { b.PutString(s.Receipt) } @@ -1675,10 +1698,10 @@ func (s *AuthSentCodeTypeFirebaseSMS) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *AuthSentCodeTypeFirebaseSMS) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode auth.sentCodeTypeFirebaseSms#e57b1432 to nil") + return fmt.Errorf("can't decode auth.sentCodeTypeFirebaseSms#13c90f17 to nil") } if err := b.ConsumeID(AuthSentCodeTypeFirebaseSMSTypeID); err != nil { - return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#e57b1432: %w", err) + return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#13c90f17: %w", err) } return s.DecodeBare(b) } @@ -1686,38 +1709,45 @@ func (s *AuthSentCodeTypeFirebaseSMS) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *AuthSentCodeTypeFirebaseSMS) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode auth.sentCodeTypeFirebaseSms#e57b1432 to nil") + return fmt.Errorf("can't decode auth.sentCodeTypeFirebaseSms#13c90f17 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#e57b1432: field flags: %w", err) + return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#13c90f17: field flags: %w", err) } } if s.Flags.Has(0) { value, err := b.Bytes() if err != nil { - return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#e57b1432: field nonce: %w", err) + return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#13c90f17: field nonce: %w", err) } s.Nonce = value } + if s.Flags.Has(2) { + value, err := b.Bytes() + if err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#13c90f17: field play_integrity_nonce: %w", err) + } + s.PlayIntegrityNonce = value + } if s.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#e57b1432: field receipt: %w", err) + return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#13c90f17: field receipt: %w", err) } s.Receipt = value } if s.Flags.Has(1) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#e57b1432: field push_timeout: %w", err) + return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#13c90f17: field push_timeout: %w", err) } s.PushTimeout = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#e57b1432: field length: %w", err) + return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#13c90f17: field length: %w", err) } s.Length = value } @@ -1742,6 +1772,24 @@ func (s *AuthSentCodeTypeFirebaseSMS) GetNonce() (value []byte, ok bool) { return s.Nonce, true } +// SetPlayIntegrityNonce sets value of PlayIntegrityNonce conditional field. +func (s *AuthSentCodeTypeFirebaseSMS) SetPlayIntegrityNonce(value []byte) { + s.Flags.Set(2) + s.PlayIntegrityNonce = value +} + +// GetPlayIntegrityNonce returns value of PlayIntegrityNonce conditional field and +// boolean which is true if field was set. +func (s *AuthSentCodeTypeFirebaseSMS) GetPlayIntegrityNonce() (value []byte, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(2) { + return value, false + } + return s.PlayIntegrityNonce, true +} + // SetReceipt sets value of Receipt conditional field. func (s *AuthSentCodeTypeFirebaseSMS) SetReceipt(value string) { s.Flags.Set(1) @@ -2154,7 +2202,7 @@ const AuthSentCodeTypeClassName = "auth.SentCodeType" // case *tg.AuthSentCodeTypeEmailCode: // auth.sentCodeTypeEmailCode#f450f59b // case *tg.AuthSentCodeTypeSetUpEmailRequired: // auth.sentCodeTypeSetUpEmailRequired#a5491dea // case *tg.AuthSentCodeTypeFragmentSMS: // auth.sentCodeTypeFragmentSms#d9565c39 -// case *tg.AuthSentCodeTypeFirebaseSMS: // auth.sentCodeTypeFirebaseSms#e57b1432 +// case *tg.AuthSentCodeTypeFirebaseSMS: // auth.sentCodeTypeFirebaseSms#13c90f17 // case *tg.AuthSentCodeTypeSMSWord: // auth.sentCodeTypeSmsWord#a416ac81 // case *tg.AuthSentCodeTypeSMSPhrase: // auth.sentCodeTypeSmsPhrase#b37794af // default: panic(v) @@ -2242,7 +2290,7 @@ func DecodeAuthSentCodeType(buf *bin.Buffer) (AuthSentCodeTypeClass, error) { } return &v, nil case AuthSentCodeTypeFirebaseSMSTypeID: - // Decoding auth.sentCodeTypeFirebaseSms#e57b1432. + // Decoding auth.sentCodeTypeFirebaseSms#13c90f17. v := AuthSentCodeTypeFirebaseSMS{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", err) diff --git a/tg/tl_available_effect_gen.go b/tg/tl_available_effect_gen.go new file mode 100644 index 0000000000..6b20973d23 --- /dev/null +++ b/tg/tl_available_effect_gen.go @@ -0,0 +1,364 @@ +// 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{} +) + +// AvailableEffect represents TL type `availableEffect#93c3e27e`. +// +// See https://core.telegram.org/constructor/availableEffect for reference. +type AvailableEffect struct { + // Flags field of AvailableEffect. + Flags bin.Fields + // PremiumRequired field of AvailableEffect. + PremiumRequired bool + // ID field of AvailableEffect. + ID int64 + // Emoticon field of AvailableEffect. + Emoticon string + // StaticIconID field of AvailableEffect. + // + // Use SetStaticIconID and GetStaticIconID helpers. + StaticIconID int64 + // EffectStickerID field of AvailableEffect. + EffectStickerID int64 + // EffectAnimationID field of AvailableEffect. + // + // Use SetEffectAnimationID and GetEffectAnimationID helpers. + EffectAnimationID int64 +} + +// AvailableEffectTypeID is TL type id of AvailableEffect. +const AvailableEffectTypeID = 0x93c3e27e + +// Ensuring interfaces in compile-time for AvailableEffect. +var ( + _ bin.Encoder = &AvailableEffect{} + _ bin.Decoder = &AvailableEffect{} + _ bin.BareEncoder = &AvailableEffect{} + _ bin.BareDecoder = &AvailableEffect{} +) + +func (a *AvailableEffect) Zero() bool { + if a == nil { + return true + } + if !(a.Flags.Zero()) { + return false + } + if !(a.PremiumRequired == false) { + return false + } + if !(a.ID == 0) { + return false + } + if !(a.Emoticon == "") { + return false + } + if !(a.StaticIconID == 0) { + return false + } + if !(a.EffectStickerID == 0) { + return false + } + if !(a.EffectAnimationID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *AvailableEffect) String() string { + if a == nil { + return "AvailableEffect(nil)" + } + type Alias AvailableEffect + return fmt.Sprintf("AvailableEffect%+v", Alias(*a)) +} + +// FillFrom fills AvailableEffect from given interface. +func (a *AvailableEffect) FillFrom(from interface { + GetPremiumRequired() (value bool) + GetID() (value int64) + GetEmoticon() (value string) + GetStaticIconID() (value int64, ok bool) + GetEffectStickerID() (value int64) + GetEffectAnimationID() (value int64, ok bool) +}) { + a.PremiumRequired = from.GetPremiumRequired() + a.ID = from.GetID() + a.Emoticon = from.GetEmoticon() + if val, ok := from.GetStaticIconID(); ok { + a.StaticIconID = val + } + + a.EffectStickerID = from.GetEffectStickerID() + if val, ok := from.GetEffectAnimationID(); ok { + a.EffectAnimationID = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AvailableEffect) TypeID() uint32 { + return AvailableEffectTypeID +} + +// TypeName returns name of type in TL schema. +func (*AvailableEffect) TypeName() string { + return "availableEffect" +} + +// TypeInfo returns info about TL type. +func (a *AvailableEffect) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "availableEffect", + ID: AvailableEffectTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "PremiumRequired", + SchemaName: "premium_required", + Null: !a.Flags.Has(2), + }, + { + Name: "ID", + SchemaName: "id", + }, + { + Name: "Emoticon", + SchemaName: "emoticon", + }, + { + Name: "StaticIconID", + SchemaName: "static_icon_id", + Null: !a.Flags.Has(0), + }, + { + Name: "EffectStickerID", + SchemaName: "effect_sticker_id", + }, + { + Name: "EffectAnimationID", + SchemaName: "effect_animation_id", + Null: !a.Flags.Has(1), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (a *AvailableEffect) SetFlags() { + if !(a.PremiumRequired == false) { + a.Flags.Set(2) + } + if !(a.StaticIconID == 0) { + a.Flags.Set(0) + } + if !(a.EffectAnimationID == 0) { + a.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (a *AvailableEffect) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode availableEffect#93c3e27e as nil") + } + b.PutID(AvailableEffectTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AvailableEffect) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode availableEffect#93c3e27e as nil") + } + a.SetFlags() + if err := a.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode availableEffect#93c3e27e: field flags: %w", err) + } + b.PutLong(a.ID) + b.PutString(a.Emoticon) + if a.Flags.Has(0) { + b.PutLong(a.StaticIconID) + } + b.PutLong(a.EffectStickerID) + if a.Flags.Has(1) { + b.PutLong(a.EffectAnimationID) + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AvailableEffect) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode availableEffect#93c3e27e to nil") + } + if err := b.ConsumeID(AvailableEffectTypeID); err != nil { + return fmt.Errorf("unable to decode availableEffect#93c3e27e: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AvailableEffect) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode availableEffect#93c3e27e to nil") + } + { + if err := a.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode availableEffect#93c3e27e: field flags: %w", err) + } + } + a.PremiumRequired = a.Flags.Has(2) + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode availableEffect#93c3e27e: field id: %w", err) + } + a.ID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode availableEffect#93c3e27e: field emoticon: %w", err) + } + a.Emoticon = value + } + if a.Flags.Has(0) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode availableEffect#93c3e27e: field static_icon_id: %w", err) + } + a.StaticIconID = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode availableEffect#93c3e27e: field effect_sticker_id: %w", err) + } + a.EffectStickerID = value + } + if a.Flags.Has(1) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode availableEffect#93c3e27e: field effect_animation_id: %w", err) + } + a.EffectAnimationID = value + } + return nil +} + +// SetPremiumRequired sets value of PremiumRequired conditional field. +func (a *AvailableEffect) SetPremiumRequired(value bool) { + if value { + a.Flags.Set(2) + a.PremiumRequired = true + } else { + a.Flags.Unset(2) + a.PremiumRequired = false + } +} + +// GetPremiumRequired returns value of PremiumRequired conditional field. +func (a *AvailableEffect) GetPremiumRequired() (value bool) { + if a == nil { + return + } + return a.Flags.Has(2) +} + +// GetID returns value of ID field. +func (a *AvailableEffect) GetID() (value int64) { + if a == nil { + return + } + return a.ID +} + +// GetEmoticon returns value of Emoticon field. +func (a *AvailableEffect) GetEmoticon() (value string) { + if a == nil { + return + } + return a.Emoticon +} + +// SetStaticIconID sets value of StaticIconID conditional field. +func (a *AvailableEffect) SetStaticIconID(value int64) { + a.Flags.Set(0) + a.StaticIconID = value +} + +// GetStaticIconID returns value of StaticIconID conditional field and +// boolean which is true if field was set. +func (a *AvailableEffect) GetStaticIconID() (value int64, ok bool) { + if a == nil { + return + } + if !a.Flags.Has(0) { + return value, false + } + return a.StaticIconID, true +} + +// GetEffectStickerID returns value of EffectStickerID field. +func (a *AvailableEffect) GetEffectStickerID() (value int64) { + if a == nil { + return + } + return a.EffectStickerID +} + +// SetEffectAnimationID sets value of EffectAnimationID conditional field. +func (a *AvailableEffect) SetEffectAnimationID(value int64) { + a.Flags.Set(1) + a.EffectAnimationID = value +} + +// GetEffectAnimationID returns value of EffectAnimationID conditional field and +// boolean which is true if field was set. +func (a *AvailableEffect) GetEffectAnimationID() (value int64, ok bool) { + if a == nil { + return + } + if !a.Flags.Has(1) { + return value, false + } + return a.EffectAnimationID, true +} diff --git a/tg/tl_available_effect_slices_gen.go b/tg/tl_available_effect_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_available_effect_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_channels_search_posts_gen.go b/tg/tl_channels_search_posts_gen.go new file mode 100644 index 0000000000..48b77700a9 --- /dev/null +++ b/tg/tl_channels_search_posts_gen.go @@ -0,0 +1,286 @@ +// 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{} +) + +// ChannelsSearchPostsRequest represents TL type `channels.searchPosts#d19f987b`. +// +// See https://core.telegram.org/method/channels.searchPosts for reference. +type ChannelsSearchPostsRequest struct { + // Hashtag field of ChannelsSearchPostsRequest. + Hashtag string + // OffsetRate field of ChannelsSearchPostsRequest. + OffsetRate int + // OffsetPeer field of ChannelsSearchPostsRequest. + OffsetPeer InputPeerClass + // OffsetID field of ChannelsSearchPostsRequest. + OffsetID int + // Limit field of ChannelsSearchPostsRequest. + Limit int +} + +// ChannelsSearchPostsRequestTypeID is TL type id of ChannelsSearchPostsRequest. +const ChannelsSearchPostsRequestTypeID = 0xd19f987b + +// Ensuring interfaces in compile-time for ChannelsSearchPostsRequest. +var ( + _ bin.Encoder = &ChannelsSearchPostsRequest{} + _ bin.Decoder = &ChannelsSearchPostsRequest{} + _ bin.BareEncoder = &ChannelsSearchPostsRequest{} + _ bin.BareDecoder = &ChannelsSearchPostsRequest{} +) + +func (s *ChannelsSearchPostsRequest) Zero() bool { + if s == nil { + return true + } + if !(s.Hashtag == "") { + return false + } + if !(s.OffsetRate == 0) { + return false + } + if !(s.OffsetPeer == nil) { + return false + } + if !(s.OffsetID == 0) { + return false + } + if !(s.Limit == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *ChannelsSearchPostsRequest) String() string { + if s == nil { + return "ChannelsSearchPostsRequest(nil)" + } + type Alias ChannelsSearchPostsRequest + return fmt.Sprintf("ChannelsSearchPostsRequest%+v", Alias(*s)) +} + +// FillFrom fills ChannelsSearchPostsRequest from given interface. +func (s *ChannelsSearchPostsRequest) FillFrom(from interface { + GetHashtag() (value string) + GetOffsetRate() (value int) + GetOffsetPeer() (value InputPeerClass) + GetOffsetID() (value int) + GetLimit() (value int) +}) { + s.Hashtag = from.GetHashtag() + s.OffsetRate = from.GetOffsetRate() + s.OffsetPeer = from.GetOffsetPeer() + s.OffsetID = from.GetOffsetID() + s.Limit = from.GetLimit() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelsSearchPostsRequest) TypeID() uint32 { + return ChannelsSearchPostsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelsSearchPostsRequest) TypeName() string { + return "channels.searchPosts" +} + +// TypeInfo returns info about TL type. +func (s *ChannelsSearchPostsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channels.searchPosts", + ID: ChannelsSearchPostsRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hashtag", + SchemaName: "hashtag", + }, + { + Name: "OffsetRate", + SchemaName: "offset_rate", + }, + { + Name: "OffsetPeer", + SchemaName: "offset_peer", + }, + { + Name: "OffsetID", + SchemaName: "offset_id", + }, + { + Name: "Limit", + SchemaName: "limit", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *ChannelsSearchPostsRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode channels.searchPosts#d19f987b as nil") + } + b.PutID(ChannelsSearchPostsRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *ChannelsSearchPostsRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode channels.searchPosts#d19f987b as nil") + } + b.PutString(s.Hashtag) + b.PutInt(s.OffsetRate) + if s.OffsetPeer == nil { + return fmt.Errorf("unable to encode channels.searchPosts#d19f987b: field offset_peer is nil") + } + if err := s.OffsetPeer.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.searchPosts#d19f987b: field offset_peer: %w", err) + } + b.PutInt(s.OffsetID) + b.PutInt(s.Limit) + return nil +} + +// Decode implements bin.Decoder. +func (s *ChannelsSearchPostsRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode channels.searchPosts#d19f987b to nil") + } + if err := b.ConsumeID(ChannelsSearchPostsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode channels.searchPosts#d19f987b: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *ChannelsSearchPostsRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode channels.searchPosts#d19f987b to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode channels.searchPosts#d19f987b: field hashtag: %w", err) + } + s.Hashtag = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channels.searchPosts#d19f987b: field offset_rate: %w", err) + } + s.OffsetRate = value + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode channels.searchPosts#d19f987b: field offset_peer: %w", err) + } + s.OffsetPeer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channels.searchPosts#d19f987b: field offset_id: %w", err) + } + s.OffsetID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channels.searchPosts#d19f987b: field limit: %w", err) + } + s.Limit = value + } + return nil +} + +// GetHashtag returns value of Hashtag field. +func (s *ChannelsSearchPostsRequest) GetHashtag() (value string) { + if s == nil { + return + } + return s.Hashtag +} + +// GetOffsetRate returns value of OffsetRate field. +func (s *ChannelsSearchPostsRequest) GetOffsetRate() (value int) { + if s == nil { + return + } + return s.OffsetRate +} + +// GetOffsetPeer returns value of OffsetPeer field. +func (s *ChannelsSearchPostsRequest) GetOffsetPeer() (value InputPeerClass) { + if s == nil { + return + } + return s.OffsetPeer +} + +// GetOffsetID returns value of OffsetID field. +func (s *ChannelsSearchPostsRequest) GetOffsetID() (value int) { + if s == nil { + return + } + return s.OffsetID +} + +// GetLimit returns value of Limit field. +func (s *ChannelsSearchPostsRequest) GetLimit() (value int) { + if s == nil { + return + } + return s.Limit +} + +// ChannelsSearchPosts invokes method channels.searchPosts#d19f987b returning error if any. +// +// See https://core.telegram.org/method/channels.searchPosts for reference. +func (c *Client) ChannelsSearchPosts(ctx context.Context, request *ChannelsSearchPostsRequest) (MessagesMessagesClass, error) { + var result MessagesMessagesBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Messages, nil +} diff --git a/tg/tl_channels_search_posts_slices_gen.go b/tg/tl_channels_search_posts_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_channels_search_posts_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_fact_check_gen.go b/tg/tl_fact_check_gen.go new file mode 100644 index 0000000000..1e257d5793 --- /dev/null +++ b/tg/tl_fact_check_gen.go @@ -0,0 +1,310 @@ +// 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{} +) + +// FactCheck represents TL type `factCheck#b89bfccf`. +// +// See https://core.telegram.org/constructor/factCheck for reference. +type FactCheck struct { + // Flags field of FactCheck. + Flags bin.Fields + // NeedCheck field of FactCheck. + NeedCheck bool + // Country field of FactCheck. + // + // Use SetCountry and GetCountry helpers. + Country string + // Text field of FactCheck. + // + // Use SetText and GetText helpers. + Text TextWithEntities + // Hash field of FactCheck. + Hash int64 +} + +// FactCheckTypeID is TL type id of FactCheck. +const FactCheckTypeID = 0xb89bfccf + +// Ensuring interfaces in compile-time for FactCheck. +var ( + _ bin.Encoder = &FactCheck{} + _ bin.Decoder = &FactCheck{} + _ bin.BareEncoder = &FactCheck{} + _ bin.BareDecoder = &FactCheck{} +) + +func (f *FactCheck) Zero() bool { + if f == nil { + return true + } + if !(f.Flags.Zero()) { + return false + } + if !(f.NeedCheck == false) { + return false + } + if !(f.Country == "") { + return false + } + if !(f.Text.Zero()) { + return false + } + if !(f.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (f *FactCheck) String() string { + if f == nil { + return "FactCheck(nil)" + } + type Alias FactCheck + return fmt.Sprintf("FactCheck%+v", Alias(*f)) +} + +// FillFrom fills FactCheck from given interface. +func (f *FactCheck) FillFrom(from interface { + GetNeedCheck() (value bool) + GetCountry() (value string, ok bool) + GetText() (value TextWithEntities, ok bool) + GetHash() (value int64) +}) { + f.NeedCheck = from.GetNeedCheck() + if val, ok := from.GetCountry(); ok { + f.Country = val + } + + if val, ok := from.GetText(); ok { + f.Text = val + } + + f.Hash = from.GetHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*FactCheck) TypeID() uint32 { + return FactCheckTypeID +} + +// TypeName returns name of type in TL schema. +func (*FactCheck) TypeName() string { + return "factCheck" +} + +// TypeInfo returns info about TL type. +func (f *FactCheck) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "factCheck", + ID: FactCheckTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "NeedCheck", + SchemaName: "need_check", + Null: !f.Flags.Has(0), + }, + { + Name: "Country", + SchemaName: "country", + Null: !f.Flags.Has(1), + }, + { + Name: "Text", + SchemaName: "text", + Null: !f.Flags.Has(1), + }, + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (f *FactCheck) SetFlags() { + if !(f.NeedCheck == false) { + f.Flags.Set(0) + } + if !(f.Country == "") { + f.Flags.Set(1) + } + if !(f.Text.Zero()) { + f.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (f *FactCheck) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode factCheck#b89bfccf as nil") + } + b.PutID(FactCheckTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *FactCheck) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode factCheck#b89bfccf as nil") + } + f.SetFlags() + if err := f.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode factCheck#b89bfccf: field flags: %w", err) + } + if f.Flags.Has(1) { + b.PutString(f.Country) + } + if f.Flags.Has(1) { + if err := f.Text.Encode(b); err != nil { + return fmt.Errorf("unable to encode factCheck#b89bfccf: field text: %w", err) + } + } + b.PutLong(f.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (f *FactCheck) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode factCheck#b89bfccf to nil") + } + if err := b.ConsumeID(FactCheckTypeID); err != nil { + return fmt.Errorf("unable to decode factCheck#b89bfccf: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *FactCheck) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode factCheck#b89bfccf to nil") + } + { + if err := f.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode factCheck#b89bfccf: field flags: %w", err) + } + } + f.NeedCheck = f.Flags.Has(0) + if f.Flags.Has(1) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode factCheck#b89bfccf: field country: %w", err) + } + f.Country = value + } + if f.Flags.Has(1) { + if err := f.Text.Decode(b); err != nil { + return fmt.Errorf("unable to decode factCheck#b89bfccf: field text: %w", err) + } + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode factCheck#b89bfccf: field hash: %w", err) + } + f.Hash = value + } + return nil +} + +// SetNeedCheck sets value of NeedCheck conditional field. +func (f *FactCheck) SetNeedCheck(value bool) { + if value { + f.Flags.Set(0) + f.NeedCheck = true + } else { + f.Flags.Unset(0) + f.NeedCheck = false + } +} + +// GetNeedCheck returns value of NeedCheck conditional field. +func (f *FactCheck) GetNeedCheck() (value bool) { + if f == nil { + return + } + return f.Flags.Has(0) +} + +// SetCountry sets value of Country conditional field. +func (f *FactCheck) SetCountry(value string) { + f.Flags.Set(1) + f.Country = value +} + +// GetCountry returns value of Country conditional field and +// boolean which is true if field was set. +func (f *FactCheck) GetCountry() (value string, ok bool) { + if f == nil { + return + } + if !f.Flags.Has(1) { + return value, false + } + return f.Country, true +} + +// SetText sets value of Text conditional field. +func (f *FactCheck) SetText(value TextWithEntities) { + f.Flags.Set(1) + f.Text = value +} + +// GetText returns value of Text conditional field and +// boolean which is true if field was set. +func (f *FactCheck) GetText() (value TextWithEntities, ok bool) { + if f == nil { + return + } + if !f.Flags.Has(1) { + return value, false + } + return f.Text, true +} + +// GetHash returns value of Hash field. +func (f *FactCheck) GetHash() (value int64) { + if f == nil { + return + } + return f.Hash +} diff --git a/tg/tl_fact_check_slices_gen.go b/tg/tl_fact_check_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_fact_check_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_fact_check_vector_gen.go b/tg/tl_fact_check_vector_gen.go new file mode 100644 index 0000000000..1612c91c25 --- /dev/null +++ b/tg/tl_fact_check_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{} +) + +// FactCheckVector is a box for Vector +type FactCheckVector struct { + // Elements of Vector + Elems []FactCheck +} + +// FactCheckVectorTypeID is TL type id of FactCheckVector. +const FactCheckVectorTypeID = bin.TypeVector + +// Ensuring interfaces in compile-time for FactCheckVector. +var ( + _ bin.Encoder = &FactCheckVector{} + _ bin.Decoder = &FactCheckVector{} + _ bin.BareEncoder = &FactCheckVector{} + _ bin.BareDecoder = &FactCheckVector{} +) + +func (vec *FactCheckVector) Zero() bool { + if vec == nil { + return true + } + if !(vec.Elems == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (vec *FactCheckVector) String() string { + if vec == nil { + return "FactCheckVector(nil)" + } + type Alias FactCheckVector + return fmt.Sprintf("FactCheckVector%+v", Alias(*vec)) +} + +// FillFrom fills FactCheckVector from given interface. +func (vec *FactCheckVector) FillFrom(from interface { + GetElems() (value []FactCheck) +}) { + vec.Elems = from.GetElems() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*FactCheckVector) TypeID() uint32 { + return FactCheckVectorTypeID +} + +// TypeName returns name of type in TL schema. +func (*FactCheckVector) TypeName() string { + return "" +} + +// TypeInfo returns info about TL type. +func (vec *FactCheckVector) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "", + ID: FactCheckVectorTypeID, + } + if vec == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Elems", + SchemaName: "Elems", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (vec *FactCheckVector) 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 *FactCheckVector) 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 *FactCheckVector) 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 *FactCheckVector) 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([]FactCheck, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value FactCheck + 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 *FactCheckVector) GetElems() (value []FactCheck) { + if vec == nil { + return + } + return vec.Elems +} diff --git a/tg/tl_fact_check_vector_slices_gen.go b/tg/tl_fact_check_vector_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_fact_check_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_handlers_gen.go b/tg/tl_handlers_gen.go index 123ed501eb..6413678fc6 100644 --- a/tg/tl_handlers_gen.go +++ b/tg/tl_handlers_gen.go @@ -1455,3 +1455,23 @@ func (u UpdateDispatcher) OnNewStoryReaction(handler NewStoryReactionHandler) { return handler(ctx, e, update.(*UpdateNewStoryReaction)) } } + +// BroadcastRevenueTransactionsHandler is a BroadcastRevenueTransactions event handler. +type BroadcastRevenueTransactionsHandler func(ctx context.Context, e Entities, update *UpdateBroadcastRevenueTransactions) error + +// OnBroadcastRevenueTransactions sets BroadcastRevenueTransactions handler. +func (u UpdateDispatcher) OnBroadcastRevenueTransactions(handler BroadcastRevenueTransactionsHandler) { + u.handlers[UpdateBroadcastRevenueTransactionsTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateBroadcastRevenueTransactions)) + } +} + +// StarsBalanceHandler is a StarsBalance event handler. +type StarsBalanceHandler func(ctx context.Context, e Entities, update *UpdateStarsBalance) error + +// OnStarsBalance sets StarsBalance handler. +func (u UpdateDispatcher) OnStarsBalance(handler StarsBalanceHandler) { + u.handlers[UpdateStarsBalanceTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateStarsBalance)) + } +} diff --git a/tg/tl_input_invoice_gen.go b/tg/tl_input_invoice_gen.go index 7f58050651..bc0a8564b8 100644 --- a/tg/tl_input_invoice_gen.go +++ b/tg/tl_input_invoice_gen.go @@ -526,6 +526,140 @@ func (i *InputInvoicePremiumGiftCode) GetOption() (value PremiumGiftCodeOption) return i.Option } +// InputInvoiceStars represents TL type `inputInvoiceStars#1da33ad8`. +// +// See https://core.telegram.org/constructor/inputInvoiceStars for reference. +type InputInvoiceStars struct { + // Option field of InputInvoiceStars. + Option StarsTopupOption +} + +// InputInvoiceStarsTypeID is TL type id of InputInvoiceStars. +const InputInvoiceStarsTypeID = 0x1da33ad8 + +// construct implements constructor of InputInvoiceClass. +func (i InputInvoiceStars) construct() InputInvoiceClass { return &i } + +// Ensuring interfaces in compile-time for InputInvoiceStars. +var ( + _ bin.Encoder = &InputInvoiceStars{} + _ bin.Decoder = &InputInvoiceStars{} + _ bin.BareEncoder = &InputInvoiceStars{} + _ bin.BareDecoder = &InputInvoiceStars{} + + _ InputInvoiceClass = &InputInvoiceStars{} +) + +func (i *InputInvoiceStars) Zero() bool { + if i == nil { + return true + } + if !(i.Option.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputInvoiceStars) String() string { + if i == nil { + return "InputInvoiceStars(nil)" + } + type Alias InputInvoiceStars + return fmt.Sprintf("InputInvoiceStars%+v", Alias(*i)) +} + +// FillFrom fills InputInvoiceStars from given interface. +func (i *InputInvoiceStars) FillFrom(from interface { + GetOption() (value StarsTopupOption) +}) { + i.Option = from.GetOption() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputInvoiceStars) TypeID() uint32 { + return InputInvoiceStarsTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputInvoiceStars) TypeName() string { + return "inputInvoiceStars" +} + +// TypeInfo returns info about TL type. +func (i *InputInvoiceStars) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputInvoiceStars", + ID: InputInvoiceStarsTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Option", + SchemaName: "option", + }, + } + return typ +} + +// 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") + } + b.PutID(InputInvoiceStarsTypeID) + return i.EncodeBare(b) +} + +// 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") + } + if err := i.Option.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputInvoiceStars#1da33ad8: field option: %w", err) + } + return nil +} + +// 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") + } + if err := b.ConsumeID(InputInvoiceStarsTypeID); err != nil { + return fmt.Errorf("unable to decode inputInvoiceStars#1da33ad8: %w", err) + } + return i.DecodeBare(b) +} + +// 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") + } + { + if err := i.Option.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputInvoiceStars#1da33ad8: field option: %w", err) + } + } + return nil +} + +// GetOption returns value of Option field. +func (i *InputInvoiceStars) GetOption() (value StarsTopupOption) { + if i == nil { + return + } + return i.Option +} + // InputInvoiceClassName is schema name of InputInvoiceClass. const InputInvoiceClassName = "InputInvoice" @@ -543,6 +677,7 @@ const InputInvoiceClassName = "InputInvoice" // case *tg.InputInvoiceMessage: // inputInvoiceMessage#c5b56859 // case *tg.InputInvoiceSlug: // inputInvoiceSlug#c326caef // case *tg.InputInvoicePremiumGiftCode: // inputInvoicePremiumGiftCode#98986c0d +// case *tg.InputInvoiceStars: // inputInvoiceStars#1da33ad8 // default: panic(v) // } type InputInvoiceClass interface { @@ -592,6 +727,13 @@ func DecodeInputInvoice(buf *bin.Buffer) (InputInvoiceClass, error) { return nil, fmt.Errorf("unable to decode InputInvoiceClass: %w", err) } return &v, nil + case InputInvoiceStarsTypeID: + // Decoding inputInvoiceStars#1da33ad8. + v := InputInvoiceStars{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InputInvoiceClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode InputInvoiceClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_input_invoice_slices_gen.go b/tg/tl_input_invoice_slices_gen.go index 52bf32e495..e433e11be7 100644 --- a/tg/tl_input_invoice_slices_gen.go +++ b/tg/tl_input_invoice_slices_gen.go @@ -155,6 +155,19 @@ func (s InputInvoiceClassArray) AsInputInvoicePremiumGiftCode() (to InputInvoice return to } +// AsInputInvoiceStars returns copy with only InputInvoiceStars constructors. +func (s InputInvoiceClassArray) AsInputInvoiceStars() (to InputInvoiceStarsArray) { + for _, elem := range s { + value, ok := elem.(*InputInvoiceStars) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // InputInvoiceMessageArray is adapter for slice of InputInvoiceMessage. type InputInvoiceMessageArray []InputInvoiceMessage @@ -400,3 +413,85 @@ func (s *InputInvoicePremiumGiftCodeArray) Pop() (v InputInvoicePremiumGiftCode, return v, true } + +// InputInvoiceStarsArray is adapter for slice of InputInvoiceStars. +type InputInvoiceStarsArray []InputInvoiceStars + +// Sort sorts slice of InputInvoiceStars. +func (s InputInvoiceStarsArray) Sort(less func(a, b InputInvoiceStars) bool) InputInvoiceStarsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InputInvoiceStars. +func (s InputInvoiceStarsArray) SortStable(less func(a, b InputInvoiceStars) bool) InputInvoiceStarsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InputInvoiceStars. +func (s InputInvoiceStarsArray) Retain(keep func(x InputInvoiceStars) bool) InputInvoiceStarsArray { + 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 InputInvoiceStarsArray) First() (v InputInvoiceStars, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputInvoiceStarsArray) Last() (v InputInvoiceStars, 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 *InputInvoiceStarsArray) PopFirst() (v InputInvoiceStars, 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 InputInvoiceStars + 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 *InputInvoiceStarsArray) Pop() (v InputInvoiceStars, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_input_media_gen.go b/tg/tl_input_media_gen.go index 928f4b5fff..3b4271e05a 100644 --- a/tg/tl_input_media_gen.go +++ b/tg/tl_input_media_gen.go @@ -2763,7 +2763,7 @@ func (i *InputMediaGame) GetID() (value InputGameClass) { return i.ID } -// InputMediaInvoice represents TL type `inputMediaInvoice#8eb5a6d5`. +// InputMediaInvoice represents TL type `inputMediaInvoice#405fef0d`. // Generated invoice of a bot payment¹ // // Links: @@ -2794,6 +2794,8 @@ type InputMediaInvoice struct { // // Links: // 1) https://t.me/botfather + // + // Use SetProvider and GetProvider helpers. Provider string // JSON-encoded data about the invoice, which will be shared with the payment provider. A // detailed description of required fields should be provided by the payment provider. @@ -2817,7 +2819,7 @@ type InputMediaInvoice struct { } // InputMediaInvoiceTypeID is TL type id of InputMediaInvoice. -const InputMediaInvoiceTypeID = 0x8eb5a6d5 +const InputMediaInvoiceTypeID = 0x405fef0d // construct implements constructor of InputMediaClass. func (i InputMediaInvoice) construct() InputMediaClass { return &i } @@ -2886,7 +2888,7 @@ func (i *InputMediaInvoice) FillFrom(from interface { GetPhoto() (value InputWebDocument, ok bool) GetInvoice() (value Invoice) GetPayload() (value []byte) - GetProvider() (value string) + GetProvider() (value string, ok bool) GetProviderData() (value DataJSON) GetStartParam() (value string, ok bool) GetExtendedMedia() (value InputMediaClass, ok bool) @@ -2899,7 +2901,10 @@ func (i *InputMediaInvoice) FillFrom(from interface { i.Invoice = from.GetInvoice() i.Payload = from.GetPayload() - i.Provider = from.GetProvider() + if val, ok := from.GetProvider(); ok { + i.Provider = val + } + i.ProviderData = from.GetProviderData() if val, ok := from.GetStartParam(); ok { i.StartParam = val @@ -2958,6 +2963,7 @@ func (i *InputMediaInvoice) TypeInfo() tdp.Type { { Name: "Provider", SchemaName: "provider", + Null: !i.Flags.Has(3), }, { Name: "ProviderData", @@ -2982,6 +2988,9 @@ func (i *InputMediaInvoice) SetFlags() { if !(i.Photo.Zero()) { i.Flags.Set(0) } + if !(i.Provider == "") { + i.Flags.Set(3) + } if !(i.StartParam == "") { i.Flags.Set(1) } @@ -2993,7 +3002,7 @@ func (i *InputMediaInvoice) SetFlags() { // Encode implements bin.Encoder. func (i *InputMediaInvoice) Encode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputMediaInvoice#8eb5a6d5 as nil") + return fmt.Errorf("can't encode inputMediaInvoice#405fef0d as nil") } b.PutID(InputMediaInvoiceTypeID) return i.EncodeBare(b) @@ -3002,36 +3011,38 @@ func (i *InputMediaInvoice) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (i *InputMediaInvoice) EncodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputMediaInvoice#8eb5a6d5 as nil") + return fmt.Errorf("can't encode inputMediaInvoice#405fef0d as nil") } i.SetFlags() if err := i.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputMediaInvoice#8eb5a6d5: field flags: %w", err) + return fmt.Errorf("unable to encode inputMediaInvoice#405fef0d: field flags: %w", err) } b.PutString(i.Title) b.PutString(i.Description) if i.Flags.Has(0) { if err := i.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputMediaInvoice#8eb5a6d5: field photo: %w", err) + return fmt.Errorf("unable to encode inputMediaInvoice#405fef0d: field photo: %w", err) } } if err := i.Invoice.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputMediaInvoice#8eb5a6d5: field invoice: %w", err) + return fmt.Errorf("unable to encode inputMediaInvoice#405fef0d: field invoice: %w", err) } b.PutBytes(i.Payload) - b.PutString(i.Provider) + if i.Flags.Has(3) { + b.PutString(i.Provider) + } if err := i.ProviderData.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputMediaInvoice#8eb5a6d5: field provider_data: %w", err) + return fmt.Errorf("unable to encode inputMediaInvoice#405fef0d: field provider_data: %w", err) } if i.Flags.Has(1) { b.PutString(i.StartParam) } if i.Flags.Has(2) { if i.ExtendedMedia == nil { - return fmt.Errorf("unable to encode inputMediaInvoice#8eb5a6d5: field extended_media is nil") + return fmt.Errorf("unable to encode inputMediaInvoice#405fef0d: field extended_media is nil") } if err := i.ExtendedMedia.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputMediaInvoice#8eb5a6d5: field extended_media: %w", err) + return fmt.Errorf("unable to encode inputMediaInvoice#405fef0d: field extended_media: %w", err) } } return nil @@ -3040,10 +3051,10 @@ func (i *InputMediaInvoice) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (i *InputMediaInvoice) Decode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputMediaInvoice#8eb5a6d5 to nil") + return fmt.Errorf("can't decode inputMediaInvoice#405fef0d to nil") } if err := b.ConsumeID(InputMediaInvoiceTypeID); err != nil { - return fmt.Errorf("unable to decode inputMediaInvoice#8eb5a6d5: %w", err) + return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: %w", err) } return i.DecodeBare(b) } @@ -3051,67 +3062,67 @@ func (i *InputMediaInvoice) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (i *InputMediaInvoice) DecodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputMediaInvoice#8eb5a6d5 to nil") + return fmt.Errorf("can't decode inputMediaInvoice#405fef0d to nil") } { if err := i.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputMediaInvoice#8eb5a6d5: field flags: %w", err) + return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field flags: %w", err) } } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode inputMediaInvoice#8eb5a6d5: field title: %w", err) + return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field title: %w", err) } i.Title = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode inputMediaInvoice#8eb5a6d5: field description: %w", err) + return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field description: %w", err) } i.Description = value } if i.Flags.Has(0) { if err := i.Photo.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputMediaInvoice#8eb5a6d5: field photo: %w", err) + return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field photo: %w", err) } } { if err := i.Invoice.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputMediaInvoice#8eb5a6d5: field invoice: %w", err) + return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field invoice: %w", err) } } { value, err := b.Bytes() if err != nil { - return fmt.Errorf("unable to decode inputMediaInvoice#8eb5a6d5: field payload: %w", err) + return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field payload: %w", err) } i.Payload = value } - { + if i.Flags.Has(3) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode inputMediaInvoice#8eb5a6d5: field provider: %w", err) + return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field provider: %w", err) } i.Provider = value } { if err := i.ProviderData.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputMediaInvoice#8eb5a6d5: field provider_data: %w", err) + return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field provider_data: %w", err) } } if i.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode inputMediaInvoice#8eb5a6d5: field start_param: %w", err) + return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field start_param: %w", err) } i.StartParam = value } if i.Flags.Has(2) { value, err := DecodeInputMedia(b) if err != nil { - return fmt.Errorf("unable to decode inputMediaInvoice#8eb5a6d5: field extended_media: %w", err) + return fmt.Errorf("unable to decode inputMediaInvoice#405fef0d: field extended_media: %w", err) } i.ExtendedMedia = value } @@ -3168,12 +3179,22 @@ func (i *InputMediaInvoice) GetPayload() (value []byte) { return i.Payload } -// GetProvider returns value of Provider field. -func (i *InputMediaInvoice) GetProvider() (value string) { +// SetProvider sets value of Provider conditional field. +func (i *InputMediaInvoice) SetProvider(value string) { + i.Flags.Set(3) + i.Provider = value +} + +// GetProvider returns value of Provider conditional field and +// boolean which is true if field was set. +func (i *InputMediaInvoice) GetProvider() (value string, ok bool) { if i == nil { return } - return i.Provider + if !i.Flags.Has(3) { + return value, false + } + return i.Provider, true } // GetProviderData returns value of ProviderData field. @@ -4507,7 +4528,7 @@ const InputMediaClassName = "InputMedia" // case *tg.InputMediaPhotoExternal: // inputMediaPhotoExternal#e5bbfe1a // case *tg.InputMediaDocumentExternal: // inputMediaDocumentExternal#fb52dc99 // case *tg.InputMediaGame: // inputMediaGame#d33f43f3 -// case *tg.InputMediaInvoice: // inputMediaInvoice#8eb5a6d5 +// case *tg.InputMediaInvoice: // inputMediaInvoice#405fef0d // case *tg.InputMediaGeoLive: // inputMediaGeoLive#971fa843 // case *tg.InputMediaPoll: // inputMediaPoll#f94e5f1 // case *tg.InputMediaDice: // inputMediaDice#e66fbf7b @@ -4619,7 +4640,7 @@ func DecodeInputMedia(buf *bin.Buffer) (InputMediaClass, error) { } return &v, nil case InputMediaInvoiceTypeID: - // Decoding inputMediaInvoice#8eb5a6d5. + // Decoding inputMediaInvoice#405fef0d. v := InputMediaInvoice{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err) diff --git a/tg/tl_input_store_payment_purpose_gen.go b/tg/tl_input_store_payment_purpose_gen.go index de5ffda72f..f698ea3773 100644 --- a/tg/tl_input_store_payment_purpose_gen.go +++ b/tg/tl_input_store_payment_purpose_gen.go @@ -1301,6 +1301,212 @@ func (i *InputStorePaymentPremiumGiveaway) MapAdditionalPeers() (value InputPeer return InputPeerClassArray(i.AdditionalPeers), true } +// InputStorePaymentStars represents TL type `inputStorePaymentStars#4f0ee8df`. +// +// See https://core.telegram.org/constructor/inputStorePaymentStars for reference. +type InputStorePaymentStars struct { + // Flags field of InputStorePaymentStars. + Flags bin.Fields + // Stars field of InputStorePaymentStars. + Stars int64 + // Currency field of InputStorePaymentStars. + Currency string + // Amount field of InputStorePaymentStars. + Amount int64 +} + +// InputStorePaymentStarsTypeID is TL type id of InputStorePaymentStars. +const InputStorePaymentStarsTypeID = 0x4f0ee8df + +// construct implements constructor of InputStorePaymentPurposeClass. +func (i InputStorePaymentStars) construct() InputStorePaymentPurposeClass { return &i } + +// Ensuring interfaces in compile-time for InputStorePaymentStars. +var ( + _ bin.Encoder = &InputStorePaymentStars{} + _ bin.Decoder = &InputStorePaymentStars{} + _ bin.BareEncoder = &InputStorePaymentStars{} + _ bin.BareDecoder = &InputStorePaymentStars{} + + _ InputStorePaymentPurposeClass = &InputStorePaymentStars{} +) + +func (i *InputStorePaymentStars) Zero() bool { + if i == nil { + return true + } + if !(i.Flags.Zero()) { + 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 *InputStorePaymentStars) String() string { + if i == nil { + return "InputStorePaymentStars(nil)" + } + type Alias InputStorePaymentStars + return fmt.Sprintf("InputStorePaymentStars%+v", Alias(*i)) +} + +// FillFrom fills InputStorePaymentStars from given interface. +func (i *InputStorePaymentStars) FillFrom(from interface { + GetStars() (value int64) + GetCurrency() (value string) + GetAmount() (value int64) +}) { + 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 (*InputStorePaymentStars) TypeID() uint32 { + return InputStorePaymentStarsTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputStorePaymentStars) TypeName() string { + return "inputStorePaymentStars" +} + +// TypeInfo returns info about TL type. +func (i *InputStorePaymentStars) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputStorePaymentStars", + ID: InputStorePaymentStarsTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Stars", + SchemaName: "stars", + }, + { + Name: "Currency", + SchemaName: "currency", + }, + { + Name: "Amount", + SchemaName: "amount", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (i *InputStorePaymentStars) SetFlags() { +} + +// Encode implements bin.Encoder. +func (i *InputStorePaymentStars) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStorePaymentStars#4f0ee8df as nil") + } + b.PutID(InputStorePaymentStarsTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputStorePaymentStars) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStorePaymentStars#4f0ee8df as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputStorePaymentStars#4f0ee8df: field flags: %w", err) + } + b.PutLong(i.Stars) + b.PutString(i.Currency) + b.PutLong(i.Amount) + return nil +} + +// Decode implements bin.Decoder. +func (i *InputStorePaymentStars) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStorePaymentStars#4f0ee8df to nil") + } + if err := b.ConsumeID(InputStorePaymentStarsTypeID); err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStars#4f0ee8df: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputStorePaymentStars) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStorePaymentStars#4f0ee8df to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStars#4f0ee8df: field flags: %w", err) + } + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStars#4f0ee8df: 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) + } + i.Currency = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStars#4f0ee8df: field amount: %w", err) + } + i.Amount = value + } + return nil +} + +// GetStars returns value of Stars field. +func (i *InputStorePaymentStars) GetStars() (value int64) { + if i == nil { + return + } + return i.Stars +} + +// GetCurrency returns value of Currency field. +func (i *InputStorePaymentStars) GetCurrency() (value string) { + if i == nil { + return + } + return i.Currency +} + +// GetAmount returns value of Amount field. +func (i *InputStorePaymentStars) GetAmount() (value int64) { + if i == nil { + return + } + return i.Amount +} + // InputStorePaymentPurposeClassName is schema name of InputStorePaymentPurposeClass. const InputStorePaymentPurposeClassName = "InputStorePaymentPurpose" @@ -1319,6 +1525,7 @@ const InputStorePaymentPurposeClassName = "InputStorePaymentPurpose" // case *tg.InputStorePaymentGiftPremium: // inputStorePaymentGiftPremium#616f7fe8 // case *tg.InputStorePaymentPremiumGiftCode: // inputStorePaymentPremiumGiftCode#a3805f3f // case *tg.InputStorePaymentPremiumGiveaway: // inputStorePaymentPremiumGiveaway#160544ca +// case *tg.InputStorePaymentStars: // inputStorePaymentStars#4f0ee8df // default: panic(v) // } type InputStorePaymentPurposeClass interface { @@ -1375,6 +1582,13 @@ 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{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_input_store_payment_purpose_slices_gen.go b/tg/tl_input_store_payment_purpose_slices_gen.go index 6f7feba9d2..ce16f77896 100644 --- a/tg/tl_input_store_payment_purpose_slices_gen.go +++ b/tg/tl_input_store_payment_purpose_slices_gen.go @@ -168,6 +168,19 @@ func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentPremiumGiveaway() return to } +// AsInputStorePaymentStars returns copy with only InputStorePaymentStars constructors. +func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentStars() (to InputStorePaymentStarsArray) { + for _, elem := range s { + value, ok := elem.(*InputStorePaymentStars) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // InputStorePaymentPremiumSubscriptionArray is adapter for slice of InputStorePaymentPremiumSubscription. type InputStorePaymentPremiumSubscriptionArray []InputStorePaymentPremiumSubscription @@ -495,3 +508,85 @@ func (s *InputStorePaymentPremiumGiveawayArray) Pop() (v InputStorePaymentPremiu return v, true } + +// InputStorePaymentStarsArray is adapter for slice of InputStorePaymentStars. +type InputStorePaymentStarsArray []InputStorePaymentStars + +// Sort sorts slice of InputStorePaymentStars. +func (s InputStorePaymentStarsArray) Sort(less func(a, b InputStorePaymentStars) bool) InputStorePaymentStarsArray { + 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 { + 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 { + 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 InputStorePaymentStarsArray) First() (v InputStorePaymentStars, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputStorePaymentStarsArray) Last() (v InputStorePaymentStars, 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 *InputStorePaymentStarsArray) PopFirst() (v InputStorePaymentStars, 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 InputStorePaymentStars + 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 *InputStorePaymentStarsArray) Pop() (v InputStorePaymentStars, 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_invoke_with_apns_secret_gen.go b/tg/tl_invoke_with_apns_secret_gen.go new file mode 100644 index 0000000000..81df10170c --- /dev/null +++ b/tg/tl_invoke_with_apns_secret_gen.go @@ -0,0 +1,215 @@ +// 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{} +) + +// InvokeWithApnsSecretRequest represents TL type `invokeWithApnsSecret#dae54f8`. +// +// See https://core.telegram.org/constructor/invokeWithApnsSecret for reference. +type InvokeWithApnsSecretRequest struct { + // Nonce field of InvokeWithApnsSecretRequest. + Nonce string + // Secret field of InvokeWithApnsSecretRequest. + Secret string + // Query field of InvokeWithApnsSecretRequest. + Query bin.Object +} + +// InvokeWithApnsSecretRequestTypeID is TL type id of InvokeWithApnsSecretRequest. +const InvokeWithApnsSecretRequestTypeID = 0xdae54f8 + +// Ensuring interfaces in compile-time for InvokeWithApnsSecretRequest. +var ( + _ bin.Encoder = &InvokeWithApnsSecretRequest{} + _ bin.Decoder = &InvokeWithApnsSecretRequest{} + _ bin.BareEncoder = &InvokeWithApnsSecretRequest{} + _ bin.BareDecoder = &InvokeWithApnsSecretRequest{} +) + +func (i *InvokeWithApnsSecretRequest) Zero() bool { + if i == nil { + return true + } + if !(i.Nonce == "") { + return false + } + if !(i.Secret == "") { + return false + } + if !(i.Query == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InvokeWithApnsSecretRequest) String() string { + if i == nil { + return "InvokeWithApnsSecretRequest(nil)" + } + type Alias InvokeWithApnsSecretRequest + return fmt.Sprintf("InvokeWithApnsSecretRequest%+v", Alias(*i)) +} + +// FillFrom fills InvokeWithApnsSecretRequest from given interface. +func (i *InvokeWithApnsSecretRequest) FillFrom(from interface { + GetNonce() (value string) + GetSecret() (value string) + GetQuery() (value bin.Object) +}) { + i.Nonce = from.GetNonce() + i.Secret = from.GetSecret() + i.Query = from.GetQuery() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InvokeWithApnsSecretRequest) TypeID() uint32 { + return InvokeWithApnsSecretRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*InvokeWithApnsSecretRequest) TypeName() string { + return "invokeWithApnsSecret" +} + +// TypeInfo returns info about TL type. +func (i *InvokeWithApnsSecretRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "invokeWithApnsSecret", + ID: InvokeWithApnsSecretRequestTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Nonce", + SchemaName: "nonce", + }, + { + Name: "Secret", + SchemaName: "secret", + }, + { + Name: "Query", + SchemaName: "query", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *InvokeWithApnsSecretRequest) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode invokeWithApnsSecret#dae54f8 as nil") + } + b.PutID(InvokeWithApnsSecretRequestTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InvokeWithApnsSecretRequest) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode invokeWithApnsSecret#dae54f8 as nil") + } + b.PutString(i.Nonce) + b.PutString(i.Secret) + if err := i.Query.Encode(b); err != nil { + return fmt.Errorf("unable to encode invokeWithApnsSecret#dae54f8: field query: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InvokeWithApnsSecretRequest) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode invokeWithApnsSecret#dae54f8 to nil") + } + if err := b.ConsumeID(InvokeWithApnsSecretRequestTypeID); err != nil { + return fmt.Errorf("unable to decode invokeWithApnsSecret#dae54f8: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InvokeWithApnsSecretRequest) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode invokeWithApnsSecret#dae54f8 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode invokeWithApnsSecret#dae54f8: field nonce: %w", err) + } + i.Nonce = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode invokeWithApnsSecret#dae54f8: field secret: %w", err) + } + i.Secret = value + } + { + if err := i.Query.Decode(b); err != nil { + return fmt.Errorf("unable to decode invokeWithApnsSecret#dae54f8: field query: %w", err) + } + } + return nil +} + +// GetNonce returns value of Nonce field. +func (i *InvokeWithApnsSecretRequest) GetNonce() (value string) { + if i == nil { + return + } + return i.Nonce +} + +// GetSecret returns value of Secret field. +func (i *InvokeWithApnsSecretRequest) GetSecret() (value string) { + if i == nil { + return + } + return i.Secret +} + +// GetQuery returns value of Query field. +func (i *InvokeWithApnsSecretRequest) GetQuery() (value bin.Object) { + if i == nil { + return + } + return i.Query +} diff --git a/tg/tl_invoke_with_apns_secret_slices_gen.go b/tg/tl_invoke_with_apns_secret_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_invoke_with_apns_secret_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_invoke_with_google_play_integrity_gen.go b/tg/tl_invoke_with_google_play_integrity_gen.go new file mode 100644 index 0000000000..b2a28b27ef --- /dev/null +++ b/tg/tl_invoke_with_google_play_integrity_gen.go @@ -0,0 +1,215 @@ +// 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{} +) + +// InvokeWithGooglePlayIntegrityRequest represents TL type `invokeWithGooglePlayIntegrity#1df92984`. +// +// See https://core.telegram.org/constructor/invokeWithGooglePlayIntegrity for reference. +type InvokeWithGooglePlayIntegrityRequest struct { + // Nonce field of InvokeWithGooglePlayIntegrityRequest. + Nonce string + // Token field of InvokeWithGooglePlayIntegrityRequest. + Token string + // Query field of InvokeWithGooglePlayIntegrityRequest. + Query bin.Object +} + +// InvokeWithGooglePlayIntegrityRequestTypeID is TL type id of InvokeWithGooglePlayIntegrityRequest. +const InvokeWithGooglePlayIntegrityRequestTypeID = 0x1df92984 + +// Ensuring interfaces in compile-time for InvokeWithGooglePlayIntegrityRequest. +var ( + _ bin.Encoder = &InvokeWithGooglePlayIntegrityRequest{} + _ bin.Decoder = &InvokeWithGooglePlayIntegrityRequest{} + _ bin.BareEncoder = &InvokeWithGooglePlayIntegrityRequest{} + _ bin.BareDecoder = &InvokeWithGooglePlayIntegrityRequest{} +) + +func (i *InvokeWithGooglePlayIntegrityRequest) Zero() bool { + if i == nil { + return true + } + if !(i.Nonce == "") { + return false + } + if !(i.Token == "") { + return false + } + if !(i.Query == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InvokeWithGooglePlayIntegrityRequest) String() string { + if i == nil { + return "InvokeWithGooglePlayIntegrityRequest(nil)" + } + type Alias InvokeWithGooglePlayIntegrityRequest + return fmt.Sprintf("InvokeWithGooglePlayIntegrityRequest%+v", Alias(*i)) +} + +// FillFrom fills InvokeWithGooglePlayIntegrityRequest from given interface. +func (i *InvokeWithGooglePlayIntegrityRequest) FillFrom(from interface { + GetNonce() (value string) + GetToken() (value string) + GetQuery() (value bin.Object) +}) { + i.Nonce = from.GetNonce() + i.Token = from.GetToken() + i.Query = from.GetQuery() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InvokeWithGooglePlayIntegrityRequest) TypeID() uint32 { + return InvokeWithGooglePlayIntegrityRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*InvokeWithGooglePlayIntegrityRequest) TypeName() string { + return "invokeWithGooglePlayIntegrity" +} + +// TypeInfo returns info about TL type. +func (i *InvokeWithGooglePlayIntegrityRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "invokeWithGooglePlayIntegrity", + ID: InvokeWithGooglePlayIntegrityRequestTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Nonce", + SchemaName: "nonce", + }, + { + Name: "Token", + SchemaName: "token", + }, + { + Name: "Query", + SchemaName: "query", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *InvokeWithGooglePlayIntegrityRequest) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode invokeWithGooglePlayIntegrity#1df92984 as nil") + } + b.PutID(InvokeWithGooglePlayIntegrityRequestTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InvokeWithGooglePlayIntegrityRequest) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode invokeWithGooglePlayIntegrity#1df92984 as nil") + } + b.PutString(i.Nonce) + b.PutString(i.Token) + if err := i.Query.Encode(b); err != nil { + return fmt.Errorf("unable to encode invokeWithGooglePlayIntegrity#1df92984: field query: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InvokeWithGooglePlayIntegrityRequest) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode invokeWithGooglePlayIntegrity#1df92984 to nil") + } + if err := b.ConsumeID(InvokeWithGooglePlayIntegrityRequestTypeID); err != nil { + return fmt.Errorf("unable to decode invokeWithGooglePlayIntegrity#1df92984: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InvokeWithGooglePlayIntegrityRequest) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode invokeWithGooglePlayIntegrity#1df92984 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode invokeWithGooglePlayIntegrity#1df92984: field nonce: %w", err) + } + i.Nonce = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode invokeWithGooglePlayIntegrity#1df92984: field token: %w", err) + } + i.Token = value + } + { + if err := i.Query.Decode(b); err != nil { + return fmt.Errorf("unable to decode invokeWithGooglePlayIntegrity#1df92984: field query: %w", err) + } + } + return nil +} + +// GetNonce returns value of Nonce field. +func (i *InvokeWithGooglePlayIntegrityRequest) GetNonce() (value string) { + if i == nil { + return + } + return i.Nonce +} + +// GetToken returns value of Token field. +func (i *InvokeWithGooglePlayIntegrityRequest) GetToken() (value string) { + if i == nil { + return + } + return i.Token +} + +// GetQuery returns value of Query field. +func (i *InvokeWithGooglePlayIntegrityRequest) GetQuery() (value bin.Object) { + if i == nil { + return + } + return i.Query +} diff --git a/tg/tl_invoke_with_google_play_integrity_slices_gen.go b/tg/tl_invoke_with_google_play_integrity_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_invoke_with_google_play_integrity_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_message_entity_gen.go b/tg/tl_message_entity_gen.go index fc32a77f81..34211b4f09 100644 --- a/tg/tl_message_entity_gen.go +++ b/tg/tl_message_entity_gen.go @@ -3577,11 +3577,15 @@ func (m *MessageEntityCustomEmoji) GetDocumentID() (value int64) { return m.DocumentID } -// MessageEntityBlockquote represents TL type `messageEntityBlockquote#20df5d0`. +// MessageEntityBlockquote represents TL type `messageEntityBlockquote#f1ccaaac`. // Message entity representing a block quote. // // See https://core.telegram.org/constructor/messageEntityBlockquote for reference. type MessageEntityBlockquote struct { + // Flags field of MessageEntityBlockquote. + Flags bin.Fields + // Collapsed field of MessageEntityBlockquote. + Collapsed bool // Offset of message entity within message (in UTF-16 code units¹) // // Links: @@ -3595,7 +3599,7 @@ type MessageEntityBlockquote struct { } // MessageEntityBlockquoteTypeID is TL type id of MessageEntityBlockquote. -const MessageEntityBlockquoteTypeID = 0x20df5d0 +const MessageEntityBlockquoteTypeID = 0xf1ccaaac // construct implements constructor of MessageEntityClass. func (m MessageEntityBlockquote) construct() MessageEntityClass { return &m } @@ -3614,6 +3618,12 @@ func (m *MessageEntityBlockquote) Zero() bool { if m == nil { return true } + if !(m.Flags.Zero()) { + return false + } + if !(m.Collapsed == false) { + return false + } if !(m.Offset == 0) { return false } @@ -3635,9 +3645,11 @@ func (m *MessageEntityBlockquote) String() string { // FillFrom fills MessageEntityBlockquote from given interface. func (m *MessageEntityBlockquote) FillFrom(from interface { + GetCollapsed() (value bool) GetOffset() (value int) GetLength() (value int) }) { + m.Collapsed = from.GetCollapsed() m.Offset = from.GetOffset() m.Length = from.GetLength() } @@ -3665,6 +3677,11 @@ func (m *MessageEntityBlockquote) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Collapsed", + SchemaName: "collapsed", + Null: !m.Flags.Has(0), + }, { Name: "Offset", SchemaName: "offset", @@ -3677,10 +3694,17 @@ func (m *MessageEntityBlockquote) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (m *MessageEntityBlockquote) SetFlags() { + if !(m.Collapsed == false) { + m.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (m *MessageEntityBlockquote) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageEntityBlockquote#20df5d0 as nil") + return fmt.Errorf("can't encode messageEntityBlockquote#f1ccaaac as nil") } b.PutID(MessageEntityBlockquoteTypeID) return m.EncodeBare(b) @@ -3689,7 +3713,11 @@ func (m *MessageEntityBlockquote) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *MessageEntityBlockquote) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageEntityBlockquote#20df5d0 as nil") + return fmt.Errorf("can't encode messageEntityBlockquote#f1ccaaac as nil") + } + m.SetFlags() + if err := m.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageEntityBlockquote#f1ccaaac: field flags: %w", err) } b.PutInt(m.Offset) b.PutInt(m.Length) @@ -3699,10 +3727,10 @@ func (m *MessageEntityBlockquote) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (m *MessageEntityBlockquote) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageEntityBlockquote#20df5d0 to nil") + return fmt.Errorf("can't decode messageEntityBlockquote#f1ccaaac to nil") } if err := b.ConsumeID(MessageEntityBlockquoteTypeID); err != nil { - return fmt.Errorf("unable to decode messageEntityBlockquote#20df5d0: %w", err) + return fmt.Errorf("unable to decode messageEntityBlockquote#f1ccaaac: %w", err) } return m.DecodeBare(b) } @@ -3710,25 +3738,50 @@ func (m *MessageEntityBlockquote) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *MessageEntityBlockquote) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageEntityBlockquote#20df5d0 to nil") + return fmt.Errorf("can't decode messageEntityBlockquote#f1ccaaac to nil") } + { + if err := m.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageEntityBlockquote#f1ccaaac: field flags: %w", err) + } + } + m.Collapsed = m.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageEntityBlockquote#20df5d0: field offset: %w", err) + return fmt.Errorf("unable to decode messageEntityBlockquote#f1ccaaac: field offset: %w", err) } m.Offset = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageEntityBlockquote#20df5d0: field length: %w", err) + return fmt.Errorf("unable to decode messageEntityBlockquote#f1ccaaac: field length: %w", err) } m.Length = value } return nil } +// SetCollapsed sets value of Collapsed conditional field. +func (m *MessageEntityBlockquote) SetCollapsed(value bool) { + if value { + m.Flags.Set(0) + m.Collapsed = true + } else { + m.Flags.Unset(0) + m.Collapsed = false + } +} + +// GetCollapsed returns value of Collapsed conditional field. +func (m *MessageEntityBlockquote) GetCollapsed() (value bool) { + if m == nil { + return + } + return m.Flags.Has(0) +} + // GetOffset returns value of Offset field. func (m *MessageEntityBlockquote) GetOffset() (value int) { if m == nil { @@ -3779,7 +3832,7 @@ const MessageEntityClassName = "MessageEntity" // case *tg.MessageEntityBankCard: // messageEntityBankCard#761e6af4 // case *tg.MessageEntitySpoiler: // messageEntitySpoiler#32ca960f // case *tg.MessageEntityCustomEmoji: // messageEntityCustomEmoji#c8cf05f8 -// case *tg.MessageEntityBlockquote: // messageEntityBlockquote#20df5d0 +// case *tg.MessageEntityBlockquote: // messageEntityBlockquote#f1ccaaac // default: panic(v) // } type MessageEntityClass interface { @@ -3961,7 +4014,7 @@ func DecodeMessageEntity(buf *bin.Buffer) (MessageEntityClass, error) { } return &v, nil case MessageEntityBlockquoteTypeID: - // Decoding messageEntityBlockquote#20df5d0. + // Decoding messageEntityBlockquote#f1ccaaac. v := MessageEntityBlockquote{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err) diff --git a/tg/tl_message_gen.go b/tg/tl_message_gen.go index ec563220cb..245782e236 100644 --- a/tg/tl_message_gen.go +++ b/tg/tl_message_gen.go @@ -240,7 +240,7 @@ func (m *MessageEmpty) GetPeerID() (value PeerClass, ok bool) { return m.PeerID, true } -// Message represents TL type `message#2357bf25`. +// Message represents TL type `message#94345242`. // A message // // See https://core.telegram.org/constructor/message for reference. @@ -397,10 +397,18 @@ type Message struct { // // Use SetQuickReplyShortcutID and GetQuickReplyShortcutID helpers. QuickReplyShortcutID int + // Effect field of Message. + // + // Use SetEffect and GetEffect helpers. + Effect int64 + // Factcheck field of Message. + // + // Use SetFactcheck and GetFactcheck helpers. + Factcheck FactCheck } // MessageTypeID is TL type id of Message. -const MessageTypeID = 0x2357bf25 +const MessageTypeID = 0x94345242 // construct implements constructor of MessageClass. func (m Message) construct() MessageClass { return &m } @@ -533,6 +541,12 @@ func (m *Message) Zero() bool { if !(m.QuickReplyShortcutID == 0) { return false } + if !(m.Effect == 0) { + return false + } + if !(m.Factcheck.Zero()) { + return false + } return true } @@ -584,6 +598,8 @@ func (m *Message) FillFrom(from interface { GetRestrictionReason() (value []RestrictionReason, ok bool) GetTTLPeriod() (value int, ok bool) GetQuickReplyShortcutID() (value int, ok bool) + GetEffect() (value int64, ok bool) + GetFactcheck() (value FactCheck, ok bool) }) { m.Out = from.GetOut() m.Mentioned = from.GetMentioned() @@ -681,6 +697,14 @@ func (m *Message) FillFrom(from interface { m.QuickReplyShortcutID = val } + if val, ok := from.GetEffect(); ok { + m.Effect = val + } + + if val, ok := from.GetFactcheck(); ok { + m.Factcheck = val + } + } // TypeID returns type id in TL schema. @@ -882,6 +906,16 @@ func (m *Message) TypeInfo() tdp.Type { SchemaName: "quick_reply_shortcut_id", Null: !m.Flags.Has(30), }, + { + Name: "Effect", + SchemaName: "effect", + Null: !m.Flags2.Has(2), + }, + { + Name: "Factcheck", + SchemaName: "factcheck", + Null: !m.Flags2.Has(3), + }, } return typ } @@ -984,12 +1018,18 @@ func (m *Message) SetFlags() { if !(m.QuickReplyShortcutID == 0) { m.Flags.Set(30) } + if !(m.Effect == 0) { + m.Flags2.Set(2) + } + if !(m.Factcheck.Zero()) { + m.Flags2.Set(3) + } } // Encode implements bin.Encoder. func (m *Message) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode message#2357bf25 as nil") + return fmt.Errorf("can't encode message#94345242 as nil") } b.PutID(MessageTypeID) return m.EncodeBare(b) @@ -998,44 +1038,44 @@ func (m *Message) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *Message) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode message#2357bf25 as nil") + return fmt.Errorf("can't encode message#94345242 as nil") } m.SetFlags() if err := m.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#2357bf25: field flags: %w", err) + return fmt.Errorf("unable to encode message#94345242: field flags: %w", err) } if err := m.Flags2.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#2357bf25: field flags2: %w", err) + return fmt.Errorf("unable to encode message#94345242: field flags2: %w", err) } b.PutInt(m.ID) if m.Flags.Has(8) { if m.FromID == nil { - return fmt.Errorf("unable to encode message#2357bf25: field from_id is nil") + return fmt.Errorf("unable to encode message#94345242: field from_id is nil") } if err := m.FromID.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#2357bf25: field from_id: %w", err) + return fmt.Errorf("unable to encode message#94345242: field from_id: %w", err) } } if m.Flags.Has(29) { b.PutInt(m.FromBoostsApplied) } if m.PeerID == nil { - return fmt.Errorf("unable to encode message#2357bf25: field peer_id is nil") + return fmt.Errorf("unable to encode message#94345242: field peer_id is nil") } if err := m.PeerID.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#2357bf25: field peer_id: %w", err) + return fmt.Errorf("unable to encode message#94345242: field peer_id: %w", err) } if m.Flags.Has(28) { if m.SavedPeerID == nil { - return fmt.Errorf("unable to encode message#2357bf25: field saved_peer_id is nil") + return fmt.Errorf("unable to encode message#94345242: field saved_peer_id is nil") } if err := m.SavedPeerID.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#2357bf25: field saved_peer_id: %w", err) + return fmt.Errorf("unable to encode message#94345242: field saved_peer_id: %w", err) } } if m.Flags.Has(2) { if err := m.FwdFrom.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#2357bf25: field fwd_from: %w", err) + return fmt.Errorf("unable to encode message#94345242: field fwd_from: %w", err) } } if m.Flags.Has(11) { @@ -1046,38 +1086,38 @@ func (m *Message) EncodeBare(b *bin.Buffer) error { } if m.Flags.Has(3) { if m.ReplyTo == nil { - return fmt.Errorf("unable to encode message#2357bf25: field reply_to is nil") + return fmt.Errorf("unable to encode message#94345242: field reply_to is nil") } if err := m.ReplyTo.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#2357bf25: field reply_to: %w", err) + return fmt.Errorf("unable to encode message#94345242: field reply_to: %w", err) } } b.PutInt(m.Date) b.PutString(m.Message) if m.Flags.Has(9) { if m.Media == nil { - return fmt.Errorf("unable to encode message#2357bf25: field media is nil") + return fmt.Errorf("unable to encode message#94345242: field media is nil") } if err := m.Media.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#2357bf25: field media: %w", err) + return fmt.Errorf("unable to encode message#94345242: field media: %w", err) } } if m.Flags.Has(6) { if m.ReplyMarkup == nil { - return fmt.Errorf("unable to encode message#2357bf25: field reply_markup is nil") + return fmt.Errorf("unable to encode message#94345242: field reply_markup is nil") } if err := m.ReplyMarkup.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#2357bf25: field reply_markup: %w", err) + return fmt.Errorf("unable to encode message#94345242: field reply_markup: %w", err) } } if m.Flags.Has(7) { b.PutVectorHeader(len(m.Entities)) for idx, v := range m.Entities { if v == nil { - return fmt.Errorf("unable to encode message#2357bf25: field entities element with index %d is nil", idx) + return fmt.Errorf("unable to encode message#94345242: field entities element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#2357bf25: field entities element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode message#94345242: field entities element with index %d: %w", idx, err) } } } @@ -1089,7 +1129,7 @@ func (m *Message) EncodeBare(b *bin.Buffer) error { } if m.Flags.Has(23) { if err := m.Replies.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#2357bf25: field replies: %w", err) + return fmt.Errorf("unable to encode message#94345242: field replies: %w", err) } } if m.Flags.Has(15) { @@ -1103,14 +1143,14 @@ func (m *Message) EncodeBare(b *bin.Buffer) error { } if m.Flags.Has(20) { if err := m.Reactions.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#2357bf25: field reactions: %w", err) + return fmt.Errorf("unable to encode message#94345242: field reactions: %w", err) } } if m.Flags.Has(22) { b.PutVectorHeader(len(m.RestrictionReason)) for idx, v := range m.RestrictionReason { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#2357bf25: field restriction_reason element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode message#94345242: field restriction_reason element with index %d: %w", idx, err) } } } @@ -1120,16 +1160,24 @@ func (m *Message) EncodeBare(b *bin.Buffer) error { if m.Flags.Has(30) { b.PutInt(m.QuickReplyShortcutID) } + if m.Flags2.Has(2) { + b.PutLong(m.Effect) + } + if m.Flags2.Has(3) { + if err := m.Factcheck.Encode(b); err != nil { + return fmt.Errorf("unable to encode message#94345242: field factcheck: %w", err) + } + } return nil } // Decode implements bin.Decoder. func (m *Message) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode message#2357bf25 to nil") + return fmt.Errorf("can't decode message#94345242 to nil") } if err := b.ConsumeID(MessageTypeID); err != nil { - return fmt.Errorf("unable to decode message#2357bf25: %w", err) + return fmt.Errorf("unable to decode message#94345242: %w", err) } return m.DecodeBare(b) } @@ -1137,11 +1185,11 @@ func (m *Message) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *Message) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode message#2357bf25 to nil") + return fmt.Errorf("can't decode message#94345242 to nil") } { if err := m.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field flags: %w", err) + return fmt.Errorf("unable to decode message#94345242: field flags: %w", err) } } m.Out = m.Flags.Has(1) @@ -1157,103 +1205,103 @@ func (m *Message) DecodeBare(b *bin.Buffer) error { m.InvertMedia = m.Flags.Has(27) { if err := m.Flags2.Decode(b); err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field flags2: %w", err) + return fmt.Errorf("unable to decode message#94345242: field flags2: %w", err) } } m.Offline = m.Flags2.Has(1) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field id: %w", err) + return fmt.Errorf("unable to decode message#94345242: field id: %w", err) } m.ID = value } if m.Flags.Has(8) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field from_id: %w", err) + return fmt.Errorf("unable to decode message#94345242: field from_id: %w", err) } m.FromID = value } if m.Flags.Has(29) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field from_boosts_applied: %w", err) + return fmt.Errorf("unable to decode message#94345242: field from_boosts_applied: %w", err) } m.FromBoostsApplied = value } { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field peer_id: %w", err) + return fmt.Errorf("unable to decode message#94345242: field peer_id: %w", err) } m.PeerID = value } if m.Flags.Has(28) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field saved_peer_id: %w", err) + return fmt.Errorf("unable to decode message#94345242: field saved_peer_id: %w", err) } m.SavedPeerID = value } if m.Flags.Has(2) { if err := m.FwdFrom.Decode(b); err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field fwd_from: %w", err) + return fmt.Errorf("unable to decode message#94345242: field fwd_from: %w", err) } } if m.Flags.Has(11) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field via_bot_id: %w", err) + return fmt.Errorf("unable to decode message#94345242: field via_bot_id: %w", err) } m.ViaBotID = value } if m.Flags2.Has(0) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field via_business_bot_id: %w", err) + return fmt.Errorf("unable to decode message#94345242: field via_business_bot_id: %w", err) } m.ViaBusinessBotID = value } if m.Flags.Has(3) { value, err := DecodeMessageReplyHeader(b) if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field reply_to: %w", err) + return fmt.Errorf("unable to decode message#94345242: field reply_to: %w", err) } m.ReplyTo = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field date: %w", err) + return fmt.Errorf("unable to decode message#94345242: field date: %w", err) } m.Date = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field message: %w", err) + return fmt.Errorf("unable to decode message#94345242: field message: %w", err) } m.Message = value } if m.Flags.Has(9) { value, err := DecodeMessageMedia(b) if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field media: %w", err) + return fmt.Errorf("unable to decode message#94345242: field media: %w", err) } m.Media = value } if m.Flags.Has(6) { value, err := DecodeReplyMarkup(b) if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field reply_markup: %w", err) + return fmt.Errorf("unable to decode message#94345242: field reply_markup: %w", err) } m.ReplyMarkup = value } if m.Flags.Has(7) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field entities: %w", err) + return fmt.Errorf("unable to decode message#94345242: field entities: %w", err) } if headerLen > 0 { @@ -1262,7 +1310,7 @@ func (m *Message) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageEntity(b) if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field entities: %w", err) + return fmt.Errorf("unable to decode message#94345242: field entities: %w", err) } m.Entities = append(m.Entities, value) } @@ -1270,52 +1318,52 @@ func (m *Message) DecodeBare(b *bin.Buffer) error { if m.Flags.Has(10) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field views: %w", err) + return fmt.Errorf("unable to decode message#94345242: field views: %w", err) } m.Views = value } if m.Flags.Has(10) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field forwards: %w", err) + return fmt.Errorf("unable to decode message#94345242: field forwards: %w", err) } m.Forwards = value } if m.Flags.Has(23) { if err := m.Replies.Decode(b); err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field replies: %w", err) + return fmt.Errorf("unable to decode message#94345242: field replies: %w", err) } } if m.Flags.Has(15) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field edit_date: %w", err) + return fmt.Errorf("unable to decode message#94345242: field edit_date: %w", err) } m.EditDate = value } if m.Flags.Has(16) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field post_author: %w", err) + return fmt.Errorf("unable to decode message#94345242: field post_author: %w", err) } m.PostAuthor = value } if m.Flags.Has(17) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field grouped_id: %w", err) + return fmt.Errorf("unable to decode message#94345242: field grouped_id: %w", err) } m.GroupedID = value } if m.Flags.Has(20) { if err := m.Reactions.Decode(b); err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field reactions: %w", err) + return fmt.Errorf("unable to decode message#94345242: field reactions: %w", err) } } if m.Flags.Has(22) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode message#94345242: field restriction_reason: %w", err) } if headerLen > 0 { @@ -1324,7 +1372,7 @@ func (m *Message) 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 message#2357bf25: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode message#94345242: field restriction_reason: %w", err) } m.RestrictionReason = append(m.RestrictionReason, value) } @@ -1332,17 +1380,29 @@ func (m *Message) DecodeBare(b *bin.Buffer) error { if m.Flags.Has(25) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field ttl_period: %w", err) + return fmt.Errorf("unable to decode message#94345242: field ttl_period: %w", err) } m.TTLPeriod = value } if m.Flags.Has(30) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#2357bf25: field quick_reply_shortcut_id: %w", err) + return fmt.Errorf("unable to decode message#94345242: field quick_reply_shortcut_id: %w", err) } m.QuickReplyShortcutID = value } + if m.Flags2.Has(2) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode message#94345242: field effect: %w", err) + } + m.Effect = value + } + if m.Flags2.Has(3) { + if err := m.Factcheck.Decode(b); err != nil { + return fmt.Errorf("unable to decode message#94345242: field factcheck: %w", err) + } + } return nil } @@ -1966,6 +2026,42 @@ func (m *Message) GetQuickReplyShortcutID() (value int, ok bool) { return m.QuickReplyShortcutID, true } +// SetEffect sets value of Effect conditional field. +func (m *Message) SetEffect(value int64) { + m.Flags2.Set(2) + m.Effect = value +} + +// GetEffect returns value of Effect conditional field and +// boolean which is true if field was set. +func (m *Message) GetEffect() (value int64, ok bool) { + if m == nil { + return + } + if !m.Flags2.Has(2) { + return value, false + } + return m.Effect, true +} + +// SetFactcheck sets value of Factcheck conditional field. +func (m *Message) SetFactcheck(value FactCheck) { + m.Flags2.Set(3) + m.Factcheck = value +} + +// GetFactcheck returns value of Factcheck conditional field and +// boolean which is true if field was set. +func (m *Message) GetFactcheck() (value FactCheck, ok bool) { + if m == nil { + return + } + if !m.Flags2.Has(3) { + return value, false + } + return m.Factcheck, true +} + // MapEntities returns field Entities wrapped in MessageEntityClassArray helper. func (m *Message) MapEntities() (value MessageEntityClassArray, ok bool) { if !m.Flags.Has(7) { @@ -2601,7 +2697,7 @@ const MessageClassName = "Message" // } // switch v := g.(type) { // case *tg.MessageEmpty: // messageEmpty#90a6ca84 -// case *tg.Message: // message#2357bf25 +// case *tg.Message: // message#94345242 // case *tg.MessageService: // messageService#2b085862 // default: panic(v) // } @@ -2739,7 +2835,7 @@ func DecodeMessage(buf *bin.Buffer) (MessageClass, error) { } return &v, nil case MessageTypeID: - // Decoding message#2357bf25. + // Decoding message#94345242. v := Message{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageClass: %w", err) diff --git a/tg/tl_messages_available_effects_gen.go b/tg/tl_messages_available_effects_gen.go new file mode 100644 index 0000000000..fe60da7ebf --- /dev/null +++ b/tg/tl_messages_available_effects_gen.go @@ -0,0 +1,461 @@ +// 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{} +) + +// MessagesAvailableEffectsNotModified represents TL type `messages.availableEffectsNotModified#d1ed9a5b`. +// +// See https://core.telegram.org/constructor/messages.availableEffectsNotModified for reference. +type MessagesAvailableEffectsNotModified struct { +} + +// MessagesAvailableEffectsNotModifiedTypeID is TL type id of MessagesAvailableEffectsNotModified. +const MessagesAvailableEffectsNotModifiedTypeID = 0xd1ed9a5b + +// construct implements constructor of MessagesAvailableEffectsClass. +func (a MessagesAvailableEffectsNotModified) construct() MessagesAvailableEffectsClass { return &a } + +// Ensuring interfaces in compile-time for MessagesAvailableEffectsNotModified. +var ( + _ bin.Encoder = &MessagesAvailableEffectsNotModified{} + _ bin.Decoder = &MessagesAvailableEffectsNotModified{} + _ bin.BareEncoder = &MessagesAvailableEffectsNotModified{} + _ bin.BareDecoder = &MessagesAvailableEffectsNotModified{} + + _ MessagesAvailableEffectsClass = &MessagesAvailableEffectsNotModified{} +) + +func (a *MessagesAvailableEffectsNotModified) Zero() bool { + if a == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (a *MessagesAvailableEffectsNotModified) String() string { + if a == nil { + return "MessagesAvailableEffectsNotModified(nil)" + } + type Alias MessagesAvailableEffectsNotModified + return fmt.Sprintf("MessagesAvailableEffectsNotModified%+v", Alias(*a)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesAvailableEffectsNotModified) TypeID() uint32 { + return MessagesAvailableEffectsNotModifiedTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesAvailableEffectsNotModified) TypeName() string { + return "messages.availableEffectsNotModified" +} + +// TypeInfo returns info about TL type. +func (a *MessagesAvailableEffectsNotModified) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.availableEffectsNotModified", + ID: MessagesAvailableEffectsNotModifiedTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (a *MessagesAvailableEffectsNotModified) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode messages.availableEffectsNotModified#d1ed9a5b as nil") + } + b.PutID(MessagesAvailableEffectsNotModifiedTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *MessagesAvailableEffectsNotModified) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode messages.availableEffectsNotModified#d1ed9a5b as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (a *MessagesAvailableEffectsNotModified) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode messages.availableEffectsNotModified#d1ed9a5b to nil") + } + if err := b.ConsumeID(MessagesAvailableEffectsNotModifiedTypeID); err != nil { + return fmt.Errorf("unable to decode messages.availableEffectsNotModified#d1ed9a5b: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *MessagesAvailableEffectsNotModified) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode messages.availableEffectsNotModified#d1ed9a5b to nil") + } + return nil +} + +// MessagesAvailableEffects represents TL type `messages.availableEffects#bddb616e`. +// +// See https://core.telegram.org/constructor/messages.availableEffects for reference. +type MessagesAvailableEffects struct { + // Hash field of MessagesAvailableEffects. + Hash int + // Effects field of MessagesAvailableEffects. + Effects []AvailableEffect + // Documents field of MessagesAvailableEffects. + Documents []DocumentClass +} + +// MessagesAvailableEffectsTypeID is TL type id of MessagesAvailableEffects. +const MessagesAvailableEffectsTypeID = 0xbddb616e + +// construct implements constructor of MessagesAvailableEffectsClass. +func (a MessagesAvailableEffects) construct() MessagesAvailableEffectsClass { return &a } + +// Ensuring interfaces in compile-time for MessagesAvailableEffects. +var ( + _ bin.Encoder = &MessagesAvailableEffects{} + _ bin.Decoder = &MessagesAvailableEffects{} + _ bin.BareEncoder = &MessagesAvailableEffects{} + _ bin.BareDecoder = &MessagesAvailableEffects{} + + _ MessagesAvailableEffectsClass = &MessagesAvailableEffects{} +) + +func (a *MessagesAvailableEffects) Zero() bool { + if a == nil { + return true + } + if !(a.Hash == 0) { + return false + } + if !(a.Effects == nil) { + return false + } + if !(a.Documents == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *MessagesAvailableEffects) String() string { + if a == nil { + return "MessagesAvailableEffects(nil)" + } + type Alias MessagesAvailableEffects + return fmt.Sprintf("MessagesAvailableEffects%+v", Alias(*a)) +} + +// FillFrom fills MessagesAvailableEffects from given interface. +func (a *MessagesAvailableEffects) FillFrom(from interface { + GetHash() (value int) + GetEffects() (value []AvailableEffect) + GetDocuments() (value []DocumentClass) +}) { + a.Hash = from.GetHash() + a.Effects = from.GetEffects() + a.Documents = from.GetDocuments() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesAvailableEffects) TypeID() uint32 { + return MessagesAvailableEffectsTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesAvailableEffects) TypeName() string { + return "messages.availableEffects" +} + +// TypeInfo returns info about TL type. +func (a *MessagesAvailableEffects) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.availableEffects", + ID: MessagesAvailableEffectsTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + { + Name: "Effects", + SchemaName: "effects", + }, + { + Name: "Documents", + SchemaName: "documents", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (a *MessagesAvailableEffects) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode messages.availableEffects#bddb616e as nil") + } + b.PutID(MessagesAvailableEffectsTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *MessagesAvailableEffects) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode messages.availableEffects#bddb616e as nil") + } + b.PutInt(a.Hash) + b.PutVectorHeader(len(a.Effects)) + for idx, v := range a.Effects { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.availableEffects#bddb616e: field effects element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(a.Documents)) + for idx, v := range a.Documents { + if v == nil { + return fmt.Errorf("unable to encode messages.availableEffects#bddb616e: field documents element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.availableEffects#bddb616e: field documents element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (a *MessagesAvailableEffects) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode messages.availableEffects#bddb616e to nil") + } + if err := b.ConsumeID(MessagesAvailableEffectsTypeID); err != nil { + return fmt.Errorf("unable to decode messages.availableEffects#bddb616e: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *MessagesAvailableEffects) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode messages.availableEffects#bddb616e to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.availableEffects#bddb616e: field hash: %w", err) + } + a.Hash = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.availableEffects#bddb616e: field effects: %w", err) + } + + if headerLen > 0 { + a.Effects = make([]AvailableEffect, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value AvailableEffect + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.availableEffects#bddb616e: field effects: %w", err) + } + a.Effects = append(a.Effects, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.availableEffects#bddb616e: field documents: %w", err) + } + + if headerLen > 0 { + a.Documents = make([]DocumentClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeDocument(b) + if err != nil { + return fmt.Errorf("unable to decode messages.availableEffects#bddb616e: field documents: %w", err) + } + a.Documents = append(a.Documents, value) + } + } + return nil +} + +// GetHash returns value of Hash field. +func (a *MessagesAvailableEffects) GetHash() (value int) { + if a == nil { + return + } + return a.Hash +} + +// GetEffects returns value of Effects field. +func (a *MessagesAvailableEffects) GetEffects() (value []AvailableEffect) { + if a == nil { + return + } + return a.Effects +} + +// GetDocuments returns value of Documents field. +func (a *MessagesAvailableEffects) GetDocuments() (value []DocumentClass) { + if a == nil { + return + } + return a.Documents +} + +// MapDocuments returns field Documents wrapped in DocumentClassArray helper. +func (a *MessagesAvailableEffects) MapDocuments() (value DocumentClassArray) { + return DocumentClassArray(a.Documents) +} + +// MessagesAvailableEffectsClassName is schema name of MessagesAvailableEffectsClass. +const MessagesAvailableEffectsClassName = "messages.AvailableEffects" + +// MessagesAvailableEffectsClass represents messages.AvailableEffects generic type. +// +// See https://core.telegram.org/type/messages.AvailableEffects for reference. +// +// Example: +// +// g, err := tg.DecodeMessagesAvailableEffects(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.MessagesAvailableEffectsNotModified: // messages.availableEffectsNotModified#d1ed9a5b +// case *tg.MessagesAvailableEffects: // messages.availableEffects#bddb616e +// default: panic(v) +// } +type MessagesAvailableEffectsClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() MessagesAvailableEffectsClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool + + // AsModified tries to map MessagesAvailableEffectsClass to MessagesAvailableEffects. + AsModified() (*MessagesAvailableEffects, bool) +} + +// AsModified tries to map MessagesAvailableEffectsNotModified to MessagesAvailableEffects. +func (a *MessagesAvailableEffectsNotModified) AsModified() (*MessagesAvailableEffects, bool) { + return nil, false +} + +// AsModified tries to map MessagesAvailableEffects to MessagesAvailableEffects. +func (a *MessagesAvailableEffects) AsModified() (*MessagesAvailableEffects, bool) { + return a, true +} + +// DecodeMessagesAvailableEffects implements binary de-serialization for MessagesAvailableEffectsClass. +func DecodeMessagesAvailableEffects(buf *bin.Buffer) (MessagesAvailableEffectsClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case MessagesAvailableEffectsNotModifiedTypeID: + // Decoding messages.availableEffectsNotModified#d1ed9a5b. + v := MessagesAvailableEffectsNotModified{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessagesAvailableEffectsClass: %w", err) + } + return &v, nil + case MessagesAvailableEffectsTypeID: + // Decoding messages.availableEffects#bddb616e. + v := MessagesAvailableEffects{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessagesAvailableEffectsClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode MessagesAvailableEffectsClass: %w", bin.NewUnexpectedID(id)) + } +} + +// MessagesAvailableEffects boxes the MessagesAvailableEffectsClass providing a helper. +type MessagesAvailableEffectsBox struct { + AvailableEffects MessagesAvailableEffectsClass +} + +// Decode implements bin.Decoder for MessagesAvailableEffectsBox. +func (b *MessagesAvailableEffectsBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode MessagesAvailableEffectsBox to nil") + } + v, err := DecodeMessagesAvailableEffects(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.AvailableEffects = v + return nil +} + +// Encode implements bin.Encode for MessagesAvailableEffectsBox. +func (b *MessagesAvailableEffectsBox) Encode(buf *bin.Buffer) error { + if b == nil || b.AvailableEffects == nil { + return fmt.Errorf("unable to encode MessagesAvailableEffectsClass as nil") + } + return b.AvailableEffects.Encode(buf) +} diff --git a/tg/tl_messages_available_effects_slices_gen.go b/tg/tl_messages_available_effects_slices_gen.go new file mode 100644 index 0000000000..0aaf443690 --- /dev/null +++ b/tg/tl_messages_available_effects_slices_gen.go @@ -0,0 +1,267 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// MessagesAvailableEffectsClassArray is adapter for slice of MessagesAvailableEffectsClass. +type MessagesAvailableEffectsClassArray []MessagesAvailableEffectsClass + +// Sort sorts slice of MessagesAvailableEffectsClass. +func (s MessagesAvailableEffectsClassArray) Sort(less func(a, b MessagesAvailableEffectsClass) bool) MessagesAvailableEffectsClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessagesAvailableEffectsClass. +func (s MessagesAvailableEffectsClassArray) SortStable(less func(a, b MessagesAvailableEffectsClass) bool) MessagesAvailableEffectsClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessagesAvailableEffectsClass. +func (s MessagesAvailableEffectsClassArray) Retain(keep func(x MessagesAvailableEffectsClass) bool) MessagesAvailableEffectsClassArray { + 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 MessagesAvailableEffectsClassArray) First() (v MessagesAvailableEffectsClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessagesAvailableEffectsClassArray) Last() (v MessagesAvailableEffectsClass, 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 *MessagesAvailableEffectsClassArray) PopFirst() (v MessagesAvailableEffectsClass, 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 MessagesAvailableEffectsClass + 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 *MessagesAvailableEffectsClassArray) Pop() (v MessagesAvailableEffectsClass, 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 +} + +// AsMessagesAvailableEffects returns copy with only MessagesAvailableEffects constructors. +func (s MessagesAvailableEffectsClassArray) AsMessagesAvailableEffects() (to MessagesAvailableEffectsArray) { + for _, elem := range s { + value, ok := elem.(*MessagesAvailableEffects) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AppendOnlyModified appends only Modified constructors to +// given slice. +func (s MessagesAvailableEffectsClassArray) AppendOnlyModified(to []*MessagesAvailableEffects) []*MessagesAvailableEffects { + for _, elem := range s { + value, ok := elem.AsModified() + if !ok { + continue + } + to = append(to, value) + } + + return to +} + +// AsModified returns copy with only Modified constructors. +func (s MessagesAvailableEffectsClassArray) AsModified() (to []*MessagesAvailableEffects) { + return s.AppendOnlyModified(to) +} + +// FirstAsModified returns first element of slice (if exists). +func (s MessagesAvailableEffectsClassArray) FirstAsModified() (v *MessagesAvailableEffects, ok bool) { + value, ok := s.First() + if !ok { + return + } + return value.AsModified() +} + +// LastAsModified returns last element of slice (if exists). +func (s MessagesAvailableEffectsClassArray) LastAsModified() (v *MessagesAvailableEffects, ok bool) { + value, ok := s.Last() + if !ok { + return + } + return value.AsModified() +} + +// PopFirstAsModified returns element of slice (if exists). +func (s *MessagesAvailableEffectsClassArray) PopFirstAsModified() (v *MessagesAvailableEffects, ok bool) { + value, ok := s.PopFirst() + if !ok { + return + } + return value.AsModified() +} + +// PopAsModified returns element of slice (if exists). +func (s *MessagesAvailableEffectsClassArray) PopAsModified() (v *MessagesAvailableEffects, ok bool) { + value, ok := s.Pop() + if !ok { + return + } + return value.AsModified() +} + +// MessagesAvailableEffectsArray is adapter for slice of MessagesAvailableEffects. +type MessagesAvailableEffectsArray []MessagesAvailableEffects + +// Sort sorts slice of MessagesAvailableEffects. +func (s MessagesAvailableEffectsArray) Sort(less func(a, b MessagesAvailableEffects) bool) MessagesAvailableEffectsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessagesAvailableEffects. +func (s MessagesAvailableEffectsArray) SortStable(less func(a, b MessagesAvailableEffects) bool) MessagesAvailableEffectsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessagesAvailableEffects. +func (s MessagesAvailableEffectsArray) Retain(keep func(x MessagesAvailableEffects) bool) MessagesAvailableEffectsArray { + 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 MessagesAvailableEffectsArray) First() (v MessagesAvailableEffects, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessagesAvailableEffectsArray) Last() (v MessagesAvailableEffects, 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 *MessagesAvailableEffectsArray) PopFirst() (v MessagesAvailableEffects, 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 MessagesAvailableEffects + 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 *MessagesAvailableEffectsArray) Pop() (v MessagesAvailableEffects, 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_delete_fact_check_gen.go b/tg/tl_messages_delete_fact_check_gen.go new file mode 100644 index 0000000000..00a5f21a6d --- /dev/null +++ b/tg/tl_messages_delete_fact_check_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{} +) + +// MessagesDeleteFactCheckRequest represents TL type `messages.deleteFactCheck#d1da940c`. +// +// See https://core.telegram.org/method/messages.deleteFactCheck for reference. +type MessagesDeleteFactCheckRequest struct { + // Peer field of MessagesDeleteFactCheckRequest. + Peer InputPeerClass + // MsgID field of MessagesDeleteFactCheckRequest. + MsgID int +} + +// MessagesDeleteFactCheckRequestTypeID is TL type id of MessagesDeleteFactCheckRequest. +const MessagesDeleteFactCheckRequestTypeID = 0xd1da940c + +// Ensuring interfaces in compile-time for MessagesDeleteFactCheckRequest. +var ( + _ bin.Encoder = &MessagesDeleteFactCheckRequest{} + _ bin.Decoder = &MessagesDeleteFactCheckRequest{} + _ bin.BareEncoder = &MessagesDeleteFactCheckRequest{} + _ bin.BareDecoder = &MessagesDeleteFactCheckRequest{} +) + +func (d *MessagesDeleteFactCheckRequest) Zero() bool { + if d == nil { + return true + } + if !(d.Peer == nil) { + return false + } + if !(d.MsgID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (d *MessagesDeleteFactCheckRequest) String() string { + if d == nil { + return "MessagesDeleteFactCheckRequest(nil)" + } + type Alias MessagesDeleteFactCheckRequest + return fmt.Sprintf("MessagesDeleteFactCheckRequest%+v", Alias(*d)) +} + +// FillFrom fills MessagesDeleteFactCheckRequest from given interface. +func (d *MessagesDeleteFactCheckRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetMsgID() (value int) +}) { + d.Peer = from.GetPeer() + d.MsgID = from.GetMsgID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesDeleteFactCheckRequest) TypeID() uint32 { + return MessagesDeleteFactCheckRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesDeleteFactCheckRequest) TypeName() string { + return "messages.deleteFactCheck" +} + +// TypeInfo returns info about TL type. +func (d *MessagesDeleteFactCheckRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.deleteFactCheck", + ID: MessagesDeleteFactCheckRequestTypeID, + } + if d == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "MsgID", + SchemaName: "msg_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (d *MessagesDeleteFactCheckRequest) Encode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode messages.deleteFactCheck#d1da940c as nil") + } + b.PutID(MessagesDeleteFactCheckRequestTypeID) + return d.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (d *MessagesDeleteFactCheckRequest) EncodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode messages.deleteFactCheck#d1da940c as nil") + } + if d.Peer == nil { + return fmt.Errorf("unable to encode messages.deleteFactCheck#d1da940c: field peer is nil") + } + if err := d.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.deleteFactCheck#d1da940c: field peer: %w", err) + } + b.PutInt(d.MsgID) + return nil +} + +// Decode implements bin.Decoder. +func (d *MessagesDeleteFactCheckRequest) Decode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode messages.deleteFactCheck#d1da940c to nil") + } + if err := b.ConsumeID(MessagesDeleteFactCheckRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.deleteFactCheck#d1da940c: %w", err) + } + return d.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (d *MessagesDeleteFactCheckRequest) DecodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode messages.deleteFactCheck#d1da940c to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.deleteFactCheck#d1da940c: field peer: %w", err) + } + d.Peer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.deleteFactCheck#d1da940c: field msg_id: %w", err) + } + d.MsgID = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (d *MessagesDeleteFactCheckRequest) GetPeer() (value InputPeerClass) { + if d == nil { + return + } + return d.Peer +} + +// GetMsgID returns value of MsgID field. +func (d *MessagesDeleteFactCheckRequest) GetMsgID() (value int) { + if d == nil { + return + } + return d.MsgID +} + +// MessagesDeleteFactCheck invokes method messages.deleteFactCheck#d1da940c returning error if any. +// +// See https://core.telegram.org/method/messages.deleteFactCheck for reference. +func (c *Client) MessagesDeleteFactCheck(ctx context.Context, request *MessagesDeleteFactCheckRequest) (UpdatesClass, error) { + var result UpdatesBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Updates, nil +} diff --git a/tg/tl_messages_delete_fact_check_slices_gen.go b/tg/tl_messages_delete_fact_check_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_delete_fact_check_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_edit_fact_check_gen.go b/tg/tl_messages_edit_fact_check_gen.go new file mode 100644 index 0000000000..521e870566 --- /dev/null +++ b/tg/tl_messages_edit_fact_check_gen.go @@ -0,0 +1,232 @@ +// 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{} +) + +// MessagesEditFactCheckRequest represents TL type `messages.editFactCheck#589ee75`. +// +// See https://core.telegram.org/method/messages.editFactCheck for reference. +type MessagesEditFactCheckRequest struct { + // Peer field of MessagesEditFactCheckRequest. + Peer InputPeerClass + // MsgID field of MessagesEditFactCheckRequest. + MsgID int + // Text field of MessagesEditFactCheckRequest. + Text TextWithEntities +} + +// MessagesEditFactCheckRequestTypeID is TL type id of MessagesEditFactCheckRequest. +const MessagesEditFactCheckRequestTypeID = 0x589ee75 + +// Ensuring interfaces in compile-time for MessagesEditFactCheckRequest. +var ( + _ bin.Encoder = &MessagesEditFactCheckRequest{} + _ bin.Decoder = &MessagesEditFactCheckRequest{} + _ bin.BareEncoder = &MessagesEditFactCheckRequest{} + _ bin.BareDecoder = &MessagesEditFactCheckRequest{} +) + +func (e *MessagesEditFactCheckRequest) Zero() bool { + if e == nil { + return true + } + if !(e.Peer == nil) { + return false + } + if !(e.MsgID == 0) { + return false + } + if !(e.Text.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *MessagesEditFactCheckRequest) String() string { + if e == nil { + return "MessagesEditFactCheckRequest(nil)" + } + type Alias MessagesEditFactCheckRequest + return fmt.Sprintf("MessagesEditFactCheckRequest%+v", Alias(*e)) +} + +// FillFrom fills MessagesEditFactCheckRequest from given interface. +func (e *MessagesEditFactCheckRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetMsgID() (value int) + GetText() (value TextWithEntities) +}) { + e.Peer = from.GetPeer() + e.MsgID = from.GetMsgID() + e.Text = from.GetText() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesEditFactCheckRequest) TypeID() uint32 { + return MessagesEditFactCheckRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesEditFactCheckRequest) TypeName() string { + return "messages.editFactCheck" +} + +// TypeInfo returns info about TL type. +func (e *MessagesEditFactCheckRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.editFactCheck", + ID: MessagesEditFactCheckRequestTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "MsgID", + SchemaName: "msg_id", + }, + { + Name: "Text", + SchemaName: "text", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (e *MessagesEditFactCheckRequest) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode messages.editFactCheck#589ee75 as nil") + } + b.PutID(MessagesEditFactCheckRequestTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *MessagesEditFactCheckRequest) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode messages.editFactCheck#589ee75 as nil") + } + if e.Peer == nil { + return fmt.Errorf("unable to encode messages.editFactCheck#589ee75: field peer is nil") + } + if err := e.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.editFactCheck#589ee75: field peer: %w", err) + } + b.PutInt(e.MsgID) + if err := e.Text.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.editFactCheck#589ee75: field text: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (e *MessagesEditFactCheckRequest) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode messages.editFactCheck#589ee75 to nil") + } + if err := b.ConsumeID(MessagesEditFactCheckRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.editFactCheck#589ee75: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *MessagesEditFactCheckRequest) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode messages.editFactCheck#589ee75 to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.editFactCheck#589ee75: field peer: %w", err) + } + e.Peer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.editFactCheck#589ee75: field msg_id: %w", err) + } + e.MsgID = value + } + { + if err := e.Text.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.editFactCheck#589ee75: field text: %w", err) + } + } + return nil +} + +// GetPeer returns value of Peer field. +func (e *MessagesEditFactCheckRequest) GetPeer() (value InputPeerClass) { + if e == nil { + return + } + return e.Peer +} + +// GetMsgID returns value of MsgID field. +func (e *MessagesEditFactCheckRequest) GetMsgID() (value int) { + if e == nil { + return + } + return e.MsgID +} + +// GetText returns value of Text field. +func (e *MessagesEditFactCheckRequest) GetText() (value TextWithEntities) { + if e == nil { + return + } + return e.Text +} + +// MessagesEditFactCheck invokes method messages.editFactCheck#589ee75 returning error if any. +// +// See https://core.telegram.org/method/messages.editFactCheck for reference. +func (c *Client) MessagesEditFactCheck(ctx context.Context, request *MessagesEditFactCheckRequest) (UpdatesClass, error) { + var result UpdatesBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Updates, nil +} diff --git a/tg/tl_messages_edit_fact_check_slices_gen.go b/tg/tl_messages_edit_fact_check_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_edit_fact_check_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_get_available_effects_gen.go b/tg/tl_messages_get_available_effects_gen.go new file mode 100644 index 0000000000..ba4704f4a9 --- /dev/null +++ b/tg/tl_messages_get_available_effects_gen.go @@ -0,0 +1,176 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// MessagesGetAvailableEffectsRequest represents TL type `messages.getAvailableEffects#dea20a39`. +// +// See https://core.telegram.org/method/messages.getAvailableEffects for reference. +type MessagesGetAvailableEffectsRequest struct { + // Hash field of MessagesGetAvailableEffectsRequest. + Hash int +} + +// MessagesGetAvailableEffectsRequestTypeID is TL type id of MessagesGetAvailableEffectsRequest. +const MessagesGetAvailableEffectsRequestTypeID = 0xdea20a39 + +// Ensuring interfaces in compile-time for MessagesGetAvailableEffectsRequest. +var ( + _ bin.Encoder = &MessagesGetAvailableEffectsRequest{} + _ bin.Decoder = &MessagesGetAvailableEffectsRequest{} + _ bin.BareEncoder = &MessagesGetAvailableEffectsRequest{} + _ bin.BareDecoder = &MessagesGetAvailableEffectsRequest{} +) + +func (g *MessagesGetAvailableEffectsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *MessagesGetAvailableEffectsRequest) String() string { + if g == nil { + return "MessagesGetAvailableEffectsRequest(nil)" + } + type Alias MessagesGetAvailableEffectsRequest + return fmt.Sprintf("MessagesGetAvailableEffectsRequest%+v", Alias(*g)) +} + +// FillFrom fills MessagesGetAvailableEffectsRequest from given interface. +func (g *MessagesGetAvailableEffectsRequest) FillFrom(from interface { + GetHash() (value int) +}) { + g.Hash = from.GetHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesGetAvailableEffectsRequest) TypeID() uint32 { + return MessagesGetAvailableEffectsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesGetAvailableEffectsRequest) TypeName() string { + return "messages.getAvailableEffects" +} + +// TypeInfo returns info about TL type. +func (g *MessagesGetAvailableEffectsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.getAvailableEffects", + ID: MessagesGetAvailableEffectsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *MessagesGetAvailableEffectsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getAvailableEffects#dea20a39 as nil") + } + b.PutID(MessagesGetAvailableEffectsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *MessagesGetAvailableEffectsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getAvailableEffects#dea20a39 as nil") + } + b.PutInt(g.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (g *MessagesGetAvailableEffectsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getAvailableEffects#dea20a39 to nil") + } + if err := b.ConsumeID(MessagesGetAvailableEffectsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.getAvailableEffects#dea20a39: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *MessagesGetAvailableEffectsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getAvailableEffects#dea20a39 to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getAvailableEffects#dea20a39: field hash: %w", err) + } + g.Hash = value + } + return nil +} + +// GetHash returns value of Hash field. +func (g *MessagesGetAvailableEffectsRequest) GetHash() (value int) { + if g == nil { + return + } + return g.Hash +} + +// MessagesGetAvailableEffects invokes method messages.getAvailableEffects#dea20a39 returning error if any. +// +// See https://core.telegram.org/method/messages.getAvailableEffects for reference. +func (c *Client) MessagesGetAvailableEffects(ctx context.Context, hash int) (MessagesAvailableEffectsClass, error) { + var result MessagesAvailableEffectsBox + + request := &MessagesGetAvailableEffectsRequest{ + Hash: hash, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.AvailableEffects, nil +} diff --git a/tg/tl_messages_get_available_effects_slices_gen.go b/tg/tl_messages_get_available_effects_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_get_available_effects_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_get_fact_check_gen.go b/tg/tl_messages_get_fact_check_gen.go new file mode 100644 index 0000000000..5daeded415 --- /dev/null +++ b/tg/tl_messages_get_fact_check_gen.go @@ -0,0 +1,218 @@ +// 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{} +) + +// MessagesGetFactCheckRequest represents TL type `messages.getFactCheck#b9cdc5ee`. +// +// See https://core.telegram.org/method/messages.getFactCheck for reference. +type MessagesGetFactCheckRequest struct { + // Peer field of MessagesGetFactCheckRequest. + Peer InputPeerClass + // MsgID field of MessagesGetFactCheckRequest. + MsgID []int +} + +// MessagesGetFactCheckRequestTypeID is TL type id of MessagesGetFactCheckRequest. +const MessagesGetFactCheckRequestTypeID = 0xb9cdc5ee + +// Ensuring interfaces in compile-time for MessagesGetFactCheckRequest. +var ( + _ bin.Encoder = &MessagesGetFactCheckRequest{} + _ bin.Decoder = &MessagesGetFactCheckRequest{} + _ bin.BareEncoder = &MessagesGetFactCheckRequest{} + _ bin.BareDecoder = &MessagesGetFactCheckRequest{} +) + +func (g *MessagesGetFactCheckRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Peer == nil) { + return false + } + if !(g.MsgID == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *MessagesGetFactCheckRequest) String() string { + if g == nil { + return "MessagesGetFactCheckRequest(nil)" + } + type Alias MessagesGetFactCheckRequest + return fmt.Sprintf("MessagesGetFactCheckRequest%+v", Alias(*g)) +} + +// FillFrom fills MessagesGetFactCheckRequest from given interface. +func (g *MessagesGetFactCheckRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetMsgID() (value []int) +}) { + g.Peer = from.GetPeer() + g.MsgID = from.GetMsgID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesGetFactCheckRequest) TypeID() uint32 { + return MessagesGetFactCheckRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesGetFactCheckRequest) TypeName() string { + return "messages.getFactCheck" +} + +// TypeInfo returns info about TL type. +func (g *MessagesGetFactCheckRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.getFactCheck", + ID: MessagesGetFactCheckRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "MsgID", + SchemaName: "msg_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *MessagesGetFactCheckRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getFactCheck#b9cdc5ee as nil") + } + b.PutID(MessagesGetFactCheckRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *MessagesGetFactCheckRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getFactCheck#b9cdc5ee as nil") + } + if g.Peer == nil { + return fmt.Errorf("unable to encode messages.getFactCheck#b9cdc5ee: field peer is nil") + } + if err := g.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getFactCheck#b9cdc5ee: field peer: %w", err) + } + b.PutVectorHeader(len(g.MsgID)) + for _, v := range g.MsgID { + b.PutInt(v) + } + return nil +} + +// Decode implements bin.Decoder. +func (g *MessagesGetFactCheckRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getFactCheck#b9cdc5ee to nil") + } + if err := b.ConsumeID(MessagesGetFactCheckRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.getFactCheck#b9cdc5ee: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *MessagesGetFactCheckRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getFactCheck#b9cdc5ee to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.getFactCheck#b9cdc5ee: field peer: %w", err) + } + g.Peer = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.getFactCheck#b9cdc5ee: field msg_id: %w", err) + } + + if headerLen > 0 { + g.MsgID = make([]int, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getFactCheck#b9cdc5ee: field msg_id: %w", err) + } + g.MsgID = append(g.MsgID, value) + } + } + return nil +} + +// GetPeer returns value of Peer field. +func (g *MessagesGetFactCheckRequest) GetPeer() (value InputPeerClass) { + if g == nil { + return + } + return g.Peer +} + +// GetMsgID returns value of MsgID field. +func (g *MessagesGetFactCheckRequest) GetMsgID() (value []int) { + if g == nil { + return + } + return g.MsgID +} + +// MessagesGetFactCheck invokes method messages.getFactCheck#b9cdc5ee returning error if any. +// +// See https://core.telegram.org/method/messages.getFactCheck for reference. +func (c *Client) MessagesGetFactCheck(ctx context.Context, request *MessagesGetFactCheckRequest) ([]FactCheck, error) { + var result FactCheckVector + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return []FactCheck(result.Elems), nil +} diff --git a/tg/tl_messages_get_fact_check_slices_gen.go b/tg/tl_messages_get_fact_check_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_get_fact_check_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_send_media_gen.go b/tg/tl_messages_send_media_gen.go index 022aac02a0..0f8b9275b4 100644 --- a/tg/tl_messages_send_media_gen.go +++ b/tg/tl_messages_send_media_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSendMediaRequest represents TL type `messages.sendMedia#7bd66041`. +// MessagesSendMediaRequest represents TL type `messages.sendMedia#7852834e`. // Send a media // // See https://core.telegram.org/method/messages.sendMedia for reference. @@ -100,10 +100,14 @@ type MessagesSendMediaRequest struct { // // Use SetQuickReplyShortcut and GetQuickReplyShortcut helpers. QuickReplyShortcut InputQuickReplyShortcutClass + // Effect field of MessagesSendMediaRequest. + // + // Use SetEffect and GetEffect helpers. + Effect int64 } // MessagesSendMediaRequestTypeID is TL type id of MessagesSendMediaRequest. -const MessagesSendMediaRequestTypeID = 0x7bd66041 +const MessagesSendMediaRequestTypeID = 0x7852834e // Ensuring interfaces in compile-time for MessagesSendMediaRequest. var ( @@ -168,6 +172,9 @@ func (s *MessagesSendMediaRequest) Zero() bool { if !(s.QuickReplyShortcut == nil) { return false } + if !(s.Effect == 0) { + return false + } return true } @@ -199,6 +206,7 @@ func (s *MessagesSendMediaRequest) FillFrom(from interface { GetScheduleDate() (value int, ok bool) GetSendAs() (value InputPeerClass, ok bool) GetQuickReplyShortcut() (value InputQuickReplyShortcutClass, ok bool) + GetEffect() (value int64, ok bool) }) { s.Silent = from.GetSilent() s.Background = from.GetBackground() @@ -234,6 +242,10 @@ func (s *MessagesSendMediaRequest) FillFrom(from interface { s.QuickReplyShortcut = val } + if val, ok := from.GetEffect(); ok { + s.Effect = val + } + } // TypeID returns type id in TL schema. @@ -335,6 +347,11 @@ func (s *MessagesSendMediaRequest) TypeInfo() tdp.Type { SchemaName: "quick_reply_shortcut", Null: !s.Flags.Has(17), }, + { + Name: "Effect", + SchemaName: "effect", + Null: !s.Flags.Has(18), + }, } return typ } @@ -377,12 +394,15 @@ func (s *MessagesSendMediaRequest) SetFlags() { if !(s.QuickReplyShortcut == nil) { s.Flags.Set(17) } + if !(s.Effect == 0) { + s.Flags.Set(18) + } } // Encode implements bin.Encoder. func (s *MessagesSendMediaRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendMedia#7bd66041 as nil") + return fmt.Errorf("can't encode messages.sendMedia#7852834e as nil") } b.PutID(MessagesSendMediaRequestTypeID) return s.EncodeBare(b) @@ -391,50 +411,50 @@ func (s *MessagesSendMediaRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSendMediaRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendMedia#7bd66041 as nil") + return fmt.Errorf("can't encode messages.sendMedia#7852834e as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field flags: %w", err) + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field flags: %w", err) } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field peer is nil") + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field peer: %w", err) + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field peer: %w", err) } if s.Flags.Has(0) { if s.ReplyTo == nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field reply_to is nil") + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field reply_to is nil") } if err := s.ReplyTo.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field reply_to: %w", err) + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field reply_to: %w", err) } } if s.Media == nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field media is nil") + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field media is nil") } if err := s.Media.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field media: %w", err) + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field media: %w", err) } b.PutString(s.Message) b.PutLong(s.RandomID) if s.Flags.Has(2) { if s.ReplyMarkup == nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field reply_markup is nil") + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field reply_markup is nil") } if err := s.ReplyMarkup.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field reply_markup: %w", err) + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field reply_markup: %w", err) } } if s.Flags.Has(3) { b.PutVectorHeader(len(s.Entities)) for idx, v := range s.Entities { if v == nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field entities element with index %d is nil", idx) + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field entities element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field entities element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field entities element with index %d: %w", idx, err) } } } @@ -443,30 +463,33 @@ func (s *MessagesSendMediaRequest) EncodeBare(b *bin.Buffer) error { } if s.Flags.Has(13) { if s.SendAs == nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field send_as is nil") + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field send_as is nil") } if err := s.SendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field send_as: %w", err) + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field send_as: %w", err) } } if s.Flags.Has(17) { if s.QuickReplyShortcut == nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field quick_reply_shortcut is nil") + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field quick_reply_shortcut is nil") } if err := s.QuickReplyShortcut.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#7bd66041: field quick_reply_shortcut: %w", err) + return fmt.Errorf("unable to encode messages.sendMedia#7852834e: field quick_reply_shortcut: %w", err) } } + if s.Flags.Has(18) { + b.PutLong(s.Effect) + } return nil } // Decode implements bin.Decoder. func (s *MessagesSendMediaRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendMedia#7bd66041 to nil") + return fmt.Errorf("can't decode messages.sendMedia#7852834e to nil") } if err := b.ConsumeID(MessagesSendMediaRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#7bd66041: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: %w", err) } return s.DecodeBare(b) } @@ -474,11 +497,11 @@ func (s *MessagesSendMediaRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSendMediaRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendMedia#7bd66041 to nil") + return fmt.Errorf("can't decode messages.sendMedia#7852834e to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#7bd66041: field flags: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: field flags: %w", err) } } s.Silent = s.Flags.Has(5) @@ -490,49 +513,49 @@ func (s *MessagesSendMediaRequest) DecodeBare(b *bin.Buffer) error { { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#7bd66041: field peer: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: field peer: %w", err) } s.Peer = value } if s.Flags.Has(0) { value, err := DecodeInputReplyTo(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#7bd66041: field reply_to: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: field reply_to: %w", err) } s.ReplyTo = value } { value, err := DecodeInputMedia(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#7bd66041: field media: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: field media: %w", err) } s.Media = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#7bd66041: field message: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: field message: %w", err) } s.Message = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#7bd66041: field random_id: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: field random_id: %w", err) } s.RandomID = value } if s.Flags.Has(2) { value, err := DecodeReplyMarkup(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#7bd66041: field reply_markup: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: field reply_markup: %w", err) } s.ReplyMarkup = value } if s.Flags.Has(3) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#7bd66041: field entities: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: field entities: %w", err) } if headerLen > 0 { @@ -541,7 +564,7 @@ func (s *MessagesSendMediaRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageEntity(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#7bd66041: field entities: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: field entities: %w", err) } s.Entities = append(s.Entities, value) } @@ -549,24 +572,31 @@ func (s *MessagesSendMediaRequest) DecodeBare(b *bin.Buffer) error { if s.Flags.Has(10) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#7bd66041: field schedule_date: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: field schedule_date: %w", err) } s.ScheduleDate = value } if s.Flags.Has(13) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#7bd66041: field send_as: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: field send_as: %w", err) } s.SendAs = value } if s.Flags.Has(17) { value, err := DecodeInputQuickReplyShortcut(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#7bd66041: field quick_reply_shortcut: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: field quick_reply_shortcut: %w", err) } s.QuickReplyShortcut = value } + if s.Flags.Has(18) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messages.sendMedia#7852834e: field effect: %w", err) + } + s.Effect = value + } return nil } @@ -824,6 +854,24 @@ func (s *MessagesSendMediaRequest) GetQuickReplyShortcut() (value InputQuickRepl return s.QuickReplyShortcut, true } +// SetEffect sets value of Effect conditional field. +func (s *MessagesSendMediaRequest) SetEffect(value int64) { + s.Flags.Set(18) + s.Effect = value +} + +// GetEffect returns value of Effect conditional field and +// boolean which is true if field was set. +func (s *MessagesSendMediaRequest) GetEffect() (value int64, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(18) { + return value, false + } + return s.Effect, true +} + // MapEntities returns field Entities wrapped in MessageEntityClassArray helper. func (s *MessagesSendMediaRequest) MapEntities() (value MessageEntityClassArray, ok bool) { if !s.Flags.Has(3) { @@ -832,7 +880,7 @@ func (s *MessagesSendMediaRequest) MapEntities() (value MessageEntityClassArray, return MessageEntityClassArray(s.Entities), true } -// MessagesSendMedia invokes method messages.sendMedia#7bd66041 returning error if any. +// MessagesSendMedia invokes method messages.sendMedia#7852834e returning error if any. // Send a media // // Possible errors: diff --git a/tg/tl_messages_send_message_gen.go b/tg/tl_messages_send_message_gen.go index c5c49ed215..14f3b687ce 100644 --- a/tg/tl_messages_send_message_gen.go +++ b/tg/tl_messages_send_message_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSendMessageRequest represents TL type `messages.sendMessage#dff8042c`. +// MessagesSendMessageRequest represents TL type `messages.sendMessage#983f9745`. // Sends a message to a chat // // See https://core.telegram.org/method/messages.sendMessage for reference. @@ -100,10 +100,14 @@ type MessagesSendMessageRequest struct { // // Use SetQuickReplyShortcut and GetQuickReplyShortcut helpers. QuickReplyShortcut InputQuickReplyShortcutClass + // Effect field of MessagesSendMessageRequest. + // + // Use SetEffect and GetEffect helpers. + Effect int64 } // MessagesSendMessageRequestTypeID is TL type id of MessagesSendMessageRequest. -const MessagesSendMessageRequestTypeID = 0xdff8042c +const MessagesSendMessageRequestTypeID = 0x983f9745 // Ensuring interfaces in compile-time for MessagesSendMessageRequest. var ( @@ -168,6 +172,9 @@ func (s *MessagesSendMessageRequest) Zero() bool { if !(s.QuickReplyShortcut == nil) { return false } + if !(s.Effect == 0) { + return false + } return true } @@ -199,6 +206,7 @@ func (s *MessagesSendMessageRequest) FillFrom(from interface { GetScheduleDate() (value int, ok bool) GetSendAs() (value InputPeerClass, ok bool) GetQuickReplyShortcut() (value InputQuickReplyShortcutClass, ok bool) + GetEffect() (value int64, ok bool) }) { s.NoWebpage = from.GetNoWebpage() s.Silent = from.GetSilent() @@ -234,6 +242,10 @@ func (s *MessagesSendMessageRequest) FillFrom(from interface { s.QuickReplyShortcut = val } + if val, ok := from.GetEffect(); ok { + s.Effect = val + } + } // TypeID returns type id in TL schema. @@ -336,6 +348,11 @@ func (s *MessagesSendMessageRequest) TypeInfo() tdp.Type { SchemaName: "quick_reply_shortcut", Null: !s.Flags.Has(17), }, + { + Name: "Effect", + SchemaName: "effect", + Null: !s.Flags.Has(18), + }, } return typ } @@ -381,12 +398,15 @@ func (s *MessagesSendMessageRequest) SetFlags() { if !(s.QuickReplyShortcut == nil) { s.Flags.Set(17) } + if !(s.Effect == 0) { + s.Flags.Set(18) + } } // Encode implements bin.Encoder. func (s *MessagesSendMessageRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendMessage#dff8042c as nil") + return fmt.Errorf("can't encode messages.sendMessage#983f9745 as nil") } b.PutID(MessagesSendMessageRequestTypeID) return s.EncodeBare(b) @@ -395,44 +415,44 @@ func (s *MessagesSendMessageRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSendMessageRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendMessage#dff8042c as nil") + return fmt.Errorf("can't encode messages.sendMessage#983f9745 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMessage#dff8042c: field flags: %w", err) + return fmt.Errorf("unable to encode messages.sendMessage#983f9745: field flags: %w", err) } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.sendMessage#dff8042c: field peer is nil") + return fmt.Errorf("unable to encode messages.sendMessage#983f9745: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMessage#dff8042c: field peer: %w", err) + return fmt.Errorf("unable to encode messages.sendMessage#983f9745: field peer: %w", err) } if s.Flags.Has(0) { if s.ReplyTo == nil { - return fmt.Errorf("unable to encode messages.sendMessage#dff8042c: field reply_to is nil") + return fmt.Errorf("unable to encode messages.sendMessage#983f9745: field reply_to is nil") } if err := s.ReplyTo.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMessage#dff8042c: field reply_to: %w", err) + return fmt.Errorf("unable to encode messages.sendMessage#983f9745: field reply_to: %w", err) } } b.PutString(s.Message) b.PutLong(s.RandomID) if s.Flags.Has(2) { if s.ReplyMarkup == nil { - return fmt.Errorf("unable to encode messages.sendMessage#dff8042c: field reply_markup is nil") + return fmt.Errorf("unable to encode messages.sendMessage#983f9745: field reply_markup is nil") } if err := s.ReplyMarkup.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMessage#dff8042c: field reply_markup: %w", err) + return fmt.Errorf("unable to encode messages.sendMessage#983f9745: field reply_markup: %w", err) } } if s.Flags.Has(3) { b.PutVectorHeader(len(s.Entities)) for idx, v := range s.Entities { if v == nil { - return fmt.Errorf("unable to encode messages.sendMessage#dff8042c: field entities element with index %d is nil", idx) + return fmt.Errorf("unable to encode messages.sendMessage#983f9745: field entities element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMessage#dff8042c: field entities element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.sendMessage#983f9745: field entities element with index %d: %w", idx, err) } } } @@ -441,30 +461,33 @@ func (s *MessagesSendMessageRequest) EncodeBare(b *bin.Buffer) error { } if s.Flags.Has(13) { if s.SendAs == nil { - return fmt.Errorf("unable to encode messages.sendMessage#dff8042c: field send_as is nil") + return fmt.Errorf("unable to encode messages.sendMessage#983f9745: field send_as is nil") } if err := s.SendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMessage#dff8042c: field send_as: %w", err) + return fmt.Errorf("unable to encode messages.sendMessage#983f9745: field send_as: %w", err) } } if s.Flags.Has(17) { if s.QuickReplyShortcut == nil { - return fmt.Errorf("unable to encode messages.sendMessage#dff8042c: field quick_reply_shortcut is nil") + return fmt.Errorf("unable to encode messages.sendMessage#983f9745: field quick_reply_shortcut is nil") } if err := s.QuickReplyShortcut.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMessage#dff8042c: field quick_reply_shortcut: %w", err) + return fmt.Errorf("unable to encode messages.sendMessage#983f9745: field quick_reply_shortcut: %w", err) } } + if s.Flags.Has(18) { + b.PutLong(s.Effect) + } return nil } // Decode implements bin.Decoder. func (s *MessagesSendMessageRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendMessage#dff8042c to nil") + return fmt.Errorf("can't decode messages.sendMessage#983f9745 to nil") } if err := b.ConsumeID(MessagesSendMessageRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#dff8042c: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#983f9745: %w", err) } return s.DecodeBare(b) } @@ -472,11 +495,11 @@ func (s *MessagesSendMessageRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSendMessageRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendMessage#dff8042c to nil") + return fmt.Errorf("can't decode messages.sendMessage#983f9745 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#dff8042c: field flags: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#983f9745: field flags: %w", err) } } s.NoWebpage = s.Flags.Has(1) @@ -489,42 +512,42 @@ func (s *MessagesSendMessageRequest) DecodeBare(b *bin.Buffer) error { { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#dff8042c: field peer: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#983f9745: field peer: %w", err) } s.Peer = value } if s.Flags.Has(0) { value, err := DecodeInputReplyTo(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#dff8042c: field reply_to: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#983f9745: field reply_to: %w", err) } s.ReplyTo = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#dff8042c: field message: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#983f9745: field message: %w", err) } s.Message = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#dff8042c: field random_id: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#983f9745: field random_id: %w", err) } s.RandomID = value } if s.Flags.Has(2) { value, err := DecodeReplyMarkup(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#dff8042c: field reply_markup: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#983f9745: field reply_markup: %w", err) } s.ReplyMarkup = value } if s.Flags.Has(3) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#dff8042c: field entities: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#983f9745: field entities: %w", err) } if headerLen > 0 { @@ -533,7 +556,7 @@ func (s *MessagesSendMessageRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageEntity(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#dff8042c: field entities: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#983f9745: field entities: %w", err) } s.Entities = append(s.Entities, value) } @@ -541,24 +564,31 @@ func (s *MessagesSendMessageRequest) DecodeBare(b *bin.Buffer) error { if s.Flags.Has(10) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#dff8042c: field schedule_date: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#983f9745: field schedule_date: %w", err) } s.ScheduleDate = value } if s.Flags.Has(13) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#dff8042c: field send_as: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#983f9745: field send_as: %w", err) } s.SendAs = value } if s.Flags.Has(17) { value, err := DecodeInputQuickReplyShortcut(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#dff8042c: field quick_reply_shortcut: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#983f9745: field quick_reply_shortcut: %w", err) } s.QuickReplyShortcut = value } + if s.Flags.Has(18) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messages.sendMessage#983f9745: field effect: %w", err) + } + s.Effect = value + } return nil } @@ -827,6 +857,24 @@ func (s *MessagesSendMessageRequest) GetQuickReplyShortcut() (value InputQuickRe return s.QuickReplyShortcut, true } +// SetEffect sets value of Effect conditional field. +func (s *MessagesSendMessageRequest) SetEffect(value int64) { + s.Flags.Set(18) + s.Effect = value +} + +// GetEffect returns value of Effect conditional field and +// boolean which is true if field was set. +func (s *MessagesSendMessageRequest) GetEffect() (value int64, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(18) { + return value, false + } + return s.Effect, true +} + // MapEntities returns field Entities wrapped in MessageEntityClassArray helper. func (s *MessagesSendMessageRequest) MapEntities() (value MessageEntityClassArray, ok bool) { if !s.Flags.Has(3) { @@ -835,7 +883,7 @@ func (s *MessagesSendMessageRequest) MapEntities() (value MessageEntityClassArra return MessageEntityClassArray(s.Entities), true } -// MessagesSendMessage invokes method messages.sendMessage#dff8042c returning error if any. +// MessagesSendMessage invokes method messages.sendMessage#983f9745 returning error if any. // Sends a message to a chat // // Possible errors: diff --git a/tg/tl_messages_send_multi_media_gen.go b/tg/tl_messages_send_multi_media_gen.go index b1025b92e8..aac09bb6ba 100644 --- a/tg/tl_messages_send_multi_media_gen.go +++ b/tg/tl_messages_send_multi_media_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSendMultiMediaRequest represents TL type `messages.sendMultiMedia#c964709`. +// MessagesSendMultiMediaRequest represents TL type `messages.sendMultiMedia#37b74355`. // Send an album or grouped media¹ // // Links: @@ -92,10 +92,14 @@ type MessagesSendMultiMediaRequest struct { // // Use SetQuickReplyShortcut and GetQuickReplyShortcut helpers. QuickReplyShortcut InputQuickReplyShortcutClass + // Effect field of MessagesSendMultiMediaRequest. + // + // Use SetEffect and GetEffect helpers. + Effect int64 } // MessagesSendMultiMediaRequestTypeID is TL type id of MessagesSendMultiMediaRequest. -const MessagesSendMultiMediaRequestTypeID = 0xc964709 +const MessagesSendMultiMediaRequestTypeID = 0x37b74355 // Ensuring interfaces in compile-time for MessagesSendMultiMediaRequest. var ( @@ -148,6 +152,9 @@ func (s *MessagesSendMultiMediaRequest) Zero() bool { if !(s.QuickReplyShortcut == nil) { return false } + if !(s.Effect == 0) { + return false + } return true } @@ -175,6 +182,7 @@ func (s *MessagesSendMultiMediaRequest) FillFrom(from interface { GetScheduleDate() (value int, ok bool) GetSendAs() (value InputPeerClass, ok bool) GetQuickReplyShortcut() (value InputQuickReplyShortcutClass, ok bool) + GetEffect() (value int64, ok bool) }) { s.Silent = from.GetSilent() s.Background = from.GetBackground() @@ -200,6 +208,10 @@ func (s *MessagesSendMultiMediaRequest) FillFrom(from interface { s.QuickReplyShortcut = val } + if val, ok := from.GetEffect(); ok { + s.Effect = val + } + } // TypeID returns type id in TL schema. @@ -283,6 +295,11 @@ func (s *MessagesSendMultiMediaRequest) TypeInfo() tdp.Type { SchemaName: "quick_reply_shortcut", Null: !s.Flags.Has(17), }, + { + Name: "Effect", + SchemaName: "effect", + Null: !s.Flags.Has(18), + }, } return typ } @@ -319,12 +336,15 @@ func (s *MessagesSendMultiMediaRequest) SetFlags() { if !(s.QuickReplyShortcut == nil) { s.Flags.Set(17) } + if !(s.Effect == 0) { + s.Flags.Set(18) + } } // Encode implements bin.Encoder. func (s *MessagesSendMultiMediaRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendMultiMedia#c964709 as nil") + return fmt.Errorf("can't encode messages.sendMultiMedia#37b74355 as nil") } b.PutID(MessagesSendMultiMediaRequestTypeID) return s.EncodeBare(b) @@ -333,30 +353,30 @@ func (s *MessagesSendMultiMediaRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSendMultiMediaRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendMultiMedia#c964709 as nil") + return fmt.Errorf("can't encode messages.sendMultiMedia#37b74355 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#c964709: field flags: %w", err) + return fmt.Errorf("unable to encode messages.sendMultiMedia#37b74355: field flags: %w", err) } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#c964709: field peer is nil") + return fmt.Errorf("unable to encode messages.sendMultiMedia#37b74355: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#c964709: field peer: %w", err) + return fmt.Errorf("unable to encode messages.sendMultiMedia#37b74355: field peer: %w", err) } if s.Flags.Has(0) { if s.ReplyTo == nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#c964709: field reply_to is nil") + return fmt.Errorf("unable to encode messages.sendMultiMedia#37b74355: field reply_to is nil") } if err := s.ReplyTo.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#c964709: field reply_to: %w", err) + return fmt.Errorf("unable to encode messages.sendMultiMedia#37b74355: field reply_to: %w", err) } } b.PutVectorHeader(len(s.MultiMedia)) for idx, v := range s.MultiMedia { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#c964709: field multi_media element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.sendMultiMedia#37b74355: field multi_media element with index %d: %w", idx, err) } } if s.Flags.Has(10) { @@ -364,30 +384,33 @@ func (s *MessagesSendMultiMediaRequest) EncodeBare(b *bin.Buffer) error { } if s.Flags.Has(13) { if s.SendAs == nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#c964709: field send_as is nil") + return fmt.Errorf("unable to encode messages.sendMultiMedia#37b74355: field send_as is nil") } if err := s.SendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#c964709: field send_as: %w", err) + return fmt.Errorf("unable to encode messages.sendMultiMedia#37b74355: field send_as: %w", err) } } if s.Flags.Has(17) { if s.QuickReplyShortcut == nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#c964709: field quick_reply_shortcut is nil") + return fmt.Errorf("unable to encode messages.sendMultiMedia#37b74355: field quick_reply_shortcut is nil") } if err := s.QuickReplyShortcut.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#c964709: field quick_reply_shortcut: %w", err) + return fmt.Errorf("unable to encode messages.sendMultiMedia#37b74355: field quick_reply_shortcut: %w", err) } } + if s.Flags.Has(18) { + b.PutLong(s.Effect) + } return nil } // Decode implements bin.Decoder. func (s *MessagesSendMultiMediaRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendMultiMedia#c964709 to nil") + return fmt.Errorf("can't decode messages.sendMultiMedia#37b74355 to nil") } if err := b.ConsumeID(MessagesSendMultiMediaRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#c964709: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#37b74355: %w", err) } return s.DecodeBare(b) } @@ -395,11 +418,11 @@ func (s *MessagesSendMultiMediaRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSendMultiMediaRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendMultiMedia#c964709 to nil") + return fmt.Errorf("can't decode messages.sendMultiMedia#37b74355 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#c964709: field flags: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#37b74355: field flags: %w", err) } } s.Silent = s.Flags.Has(5) @@ -411,21 +434,21 @@ func (s *MessagesSendMultiMediaRequest) DecodeBare(b *bin.Buffer) error { { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#c964709: field peer: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#37b74355: field peer: %w", err) } s.Peer = value } if s.Flags.Has(0) { value, err := DecodeInputReplyTo(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#c964709: field reply_to: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#37b74355: field reply_to: %w", err) } s.ReplyTo = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#c964709: field multi_media: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#37b74355: field multi_media: %w", err) } if headerLen > 0 { @@ -434,7 +457,7 @@ func (s *MessagesSendMultiMediaRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value InputSingleMedia if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#c964709: field multi_media: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#37b74355: field multi_media: %w", err) } s.MultiMedia = append(s.MultiMedia, value) } @@ -442,24 +465,31 @@ func (s *MessagesSendMultiMediaRequest) DecodeBare(b *bin.Buffer) error { if s.Flags.Has(10) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#c964709: field schedule_date: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#37b74355: field schedule_date: %w", err) } s.ScheduleDate = value } if s.Flags.Has(13) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#c964709: field send_as: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#37b74355: field send_as: %w", err) } s.SendAs = value } if s.Flags.Has(17) { value, err := DecodeInputQuickReplyShortcut(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#c964709: field quick_reply_shortcut: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#37b74355: field quick_reply_shortcut: %w", err) } s.QuickReplyShortcut = value } + if s.Flags.Has(18) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messages.sendMultiMedia#37b74355: field effect: %w", err) + } + s.Effect = value + } return nil } @@ -665,7 +695,25 @@ func (s *MessagesSendMultiMediaRequest) GetQuickReplyShortcut() (value InputQuic return s.QuickReplyShortcut, true } -// MessagesSendMultiMedia invokes method messages.sendMultiMedia#c964709 returning error if any. +// SetEffect sets value of Effect conditional field. +func (s *MessagesSendMultiMediaRequest) SetEffect(value int64) { + s.Flags.Set(18) + s.Effect = value +} + +// GetEffect returns value of Effect conditional field and +// boolean which is true if field was set. +func (s *MessagesSendMultiMediaRequest) GetEffect() (value int64, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(18) { + return value, false + } + return s.Effect, true +} + +// MessagesSendMultiMedia invokes method messages.sendMultiMedia#37b74355 returning error if any. // Send an album or grouped media¹ // // Links: diff --git a/tg/tl_payments_get_payment_form_gen.go b/tg/tl_payments_get_payment_form_gen.go index 0e2ab59d7a..ba15c00136 100644 --- a/tg/tl_payments_get_payment_form_gen.go +++ b/tg/tl_payments_get_payment_form_gen.go @@ -250,11 +250,11 @@ func (g *PaymentsGetPaymentFormRequest) GetThemeParams() (value DataJSON, ok boo // 400 UNTIL_DATE_INVALID: Invalid until date provided. // // See https://core.telegram.org/method/payments.getPaymentForm for reference. -func (c *Client) PaymentsGetPaymentForm(ctx context.Context, request *PaymentsGetPaymentFormRequest) (*PaymentsPaymentForm, error) { - var result PaymentsPaymentForm +func (c *Client) PaymentsGetPaymentForm(ctx context.Context, request *PaymentsGetPaymentFormRequest) (PaymentsPaymentFormClass, error) { + var result PaymentsPaymentFormBox if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } - return &result, nil + return result.PaymentForm, nil } diff --git a/tg/tl_payments_get_payment_receipt_gen.go b/tg/tl_payments_get_payment_receipt_gen.go index 1ce96193c4..4854a0a605 100644 --- a/tg/tl_payments_get_payment_receipt_gen.go +++ b/tg/tl_payments_get_payment_receipt_gen.go @@ -201,11 +201,11 @@ func (g *PaymentsGetPaymentReceiptRequest) GetMsgID() (value int) { // 400 MESSAGE_ID_INVALID: The provided message id is invalid. // // See https://core.telegram.org/method/payments.getPaymentReceipt for reference. -func (c *Client) PaymentsGetPaymentReceipt(ctx context.Context, request *PaymentsGetPaymentReceiptRequest) (*PaymentsPaymentReceipt, error) { - var result PaymentsPaymentReceipt +func (c *Client) PaymentsGetPaymentReceipt(ctx context.Context, request *PaymentsGetPaymentReceiptRequest) (PaymentsPaymentReceiptClass, error) { + var result PaymentsPaymentReceiptBox if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } - return &result, nil + return result.PaymentReceipt, nil } diff --git a/tg/tl_payments_get_stars_status_gen.go b/tg/tl_payments_get_stars_status_gen.go new file mode 100644 index 0000000000..5fb9996754 --- /dev/null +++ b/tg/tl_payments_get_stars_status_gen.go @@ -0,0 +1,181 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// PaymentsGetStarsStatusRequest represents TL type `payments.getStarsStatus#104fcfa7`. +// +// See https://core.telegram.org/method/payments.getStarsStatus for reference. +type PaymentsGetStarsStatusRequest struct { + // Peer field of PaymentsGetStarsStatusRequest. + Peer InputPeerClass +} + +// PaymentsGetStarsStatusRequestTypeID is TL type id of PaymentsGetStarsStatusRequest. +const PaymentsGetStarsStatusRequestTypeID = 0x104fcfa7 + +// Ensuring interfaces in compile-time for PaymentsGetStarsStatusRequest. +var ( + _ bin.Encoder = &PaymentsGetStarsStatusRequest{} + _ bin.Decoder = &PaymentsGetStarsStatusRequest{} + _ bin.BareEncoder = &PaymentsGetStarsStatusRequest{} + _ bin.BareDecoder = &PaymentsGetStarsStatusRequest{} +) + +func (g *PaymentsGetStarsStatusRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Peer == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGetStarsStatusRequest) String() string { + if g == nil { + return "PaymentsGetStarsStatusRequest(nil)" + } + type Alias PaymentsGetStarsStatusRequest + return fmt.Sprintf("PaymentsGetStarsStatusRequest%+v", Alias(*g)) +} + +// FillFrom fills PaymentsGetStarsStatusRequest from given interface. +func (g *PaymentsGetStarsStatusRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) +}) { + g.Peer = from.GetPeer() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsGetStarsStatusRequest) TypeID() uint32 { + return PaymentsGetStarsStatusRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGetStarsStatusRequest) TypeName() string { + return "payments.getStarsStatus" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGetStarsStatusRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.getStarsStatus", + ID: PaymentsGetStarsStatusRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *PaymentsGetStarsStatusRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getStarsStatus#104fcfa7 as nil") + } + b.PutID(PaymentsGetStarsStatusRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGetStarsStatusRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getStarsStatus#104fcfa7 as nil") + } + if g.Peer == nil { + return fmt.Errorf("unable to encode payments.getStarsStatus#104fcfa7: field peer is nil") + } + if err := g.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getStarsStatus#104fcfa7: field peer: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGetStarsStatusRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getStarsStatus#104fcfa7 to nil") + } + if err := b.ConsumeID(PaymentsGetStarsStatusRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.getStarsStatus#104fcfa7: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGetStarsStatusRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getStarsStatus#104fcfa7 to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode payments.getStarsStatus#104fcfa7: field peer: %w", err) + } + g.Peer = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (g *PaymentsGetStarsStatusRequest) GetPeer() (value InputPeerClass) { + if g == nil { + return + } + return g.Peer +} + +// PaymentsGetStarsStatus invokes method payments.getStarsStatus#104fcfa7 returning error if any. +// +// See https://core.telegram.org/method/payments.getStarsStatus for reference. +func (c *Client) PaymentsGetStarsStatus(ctx context.Context, peer InputPeerClass) (*PaymentsStarsStatus, error) { + var result PaymentsStarsStatus + + request := &PaymentsGetStarsStatusRequest{ + Peer: peer, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_payments_get_stars_status_slices_gen.go b/tg/tl_payments_get_stars_status_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_get_stars_status_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_payments_get_stars_topup_options_gen.go b/tg/tl_payments_get_stars_topup_options_gen.go new file mode 100644 index 0000000000..bb6f7828a4 --- /dev/null +++ b/tg/tl_payments_get_stars_topup_options_gen.go @@ -0,0 +1,141 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// PaymentsGetStarsTopupOptionsRequest represents TL type `payments.getStarsTopupOptions#c00ec7d3`. +// +// See https://core.telegram.org/method/payments.getStarsTopupOptions for reference. +type PaymentsGetStarsTopupOptionsRequest struct { +} + +// PaymentsGetStarsTopupOptionsRequestTypeID is TL type id of PaymentsGetStarsTopupOptionsRequest. +const PaymentsGetStarsTopupOptionsRequestTypeID = 0xc00ec7d3 + +// Ensuring interfaces in compile-time for PaymentsGetStarsTopupOptionsRequest. +var ( + _ bin.Encoder = &PaymentsGetStarsTopupOptionsRequest{} + _ bin.Decoder = &PaymentsGetStarsTopupOptionsRequest{} + _ bin.BareEncoder = &PaymentsGetStarsTopupOptionsRequest{} + _ bin.BareDecoder = &PaymentsGetStarsTopupOptionsRequest{} +) + +func (g *PaymentsGetStarsTopupOptionsRequest) Zero() bool { + if g == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGetStarsTopupOptionsRequest) String() string { + if g == nil { + return "PaymentsGetStarsTopupOptionsRequest(nil)" + } + type Alias PaymentsGetStarsTopupOptionsRequest + return fmt.Sprintf("PaymentsGetStarsTopupOptionsRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsGetStarsTopupOptionsRequest) TypeID() uint32 { + return PaymentsGetStarsTopupOptionsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGetStarsTopupOptionsRequest) TypeName() string { + return "payments.getStarsTopupOptions" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGetStarsTopupOptionsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.getStarsTopupOptions", + ID: PaymentsGetStarsTopupOptionsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (g *PaymentsGetStarsTopupOptionsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getStarsTopupOptions#c00ec7d3 as nil") + } + b.PutID(PaymentsGetStarsTopupOptionsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGetStarsTopupOptionsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getStarsTopupOptions#c00ec7d3 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGetStarsTopupOptionsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getStarsTopupOptions#c00ec7d3 to nil") + } + if err := b.ConsumeID(PaymentsGetStarsTopupOptionsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.getStarsTopupOptions#c00ec7d3: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGetStarsTopupOptionsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getStarsTopupOptions#c00ec7d3 to nil") + } + return nil +} + +// PaymentsGetStarsTopupOptions invokes method payments.getStarsTopupOptions#c00ec7d3 returning error if any. +// +// See https://core.telegram.org/method/payments.getStarsTopupOptions for reference. +func (c *Client) PaymentsGetStarsTopupOptions(ctx context.Context) ([]StarsTopupOption, error) { + var result StarsTopupOptionVector + + request := &PaymentsGetStarsTopupOptionsRequest{} + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return []StarsTopupOption(result.Elems), nil +} diff --git a/tg/tl_payments_get_stars_topup_options_slices_gen.go b/tg/tl_payments_get_stars_topup_options_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_get_stars_topup_options_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_payments_get_stars_transactions_gen.go b/tg/tl_payments_get_stars_transactions_gen.go new file mode 100644 index 0000000000..4a66d174cc --- /dev/null +++ b/tg/tl_payments_get_stars_transactions_gen.go @@ -0,0 +1,293 @@ +// 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{} +) + +// PaymentsGetStarsTransactionsRequest represents TL type `payments.getStarsTransactions#673ac2f9`. +// +// See https://core.telegram.org/method/payments.getStarsTransactions for reference. +type PaymentsGetStarsTransactionsRequest struct { + // Flags field of PaymentsGetStarsTransactionsRequest. + Flags bin.Fields + // Inbound field of PaymentsGetStarsTransactionsRequest. + Inbound bool + // Outbound field of PaymentsGetStarsTransactionsRequest. + Outbound bool + // Peer field of PaymentsGetStarsTransactionsRequest. + Peer InputPeerClass + // Offset field of PaymentsGetStarsTransactionsRequest. + Offset string +} + +// PaymentsGetStarsTransactionsRequestTypeID is TL type id of PaymentsGetStarsTransactionsRequest. +const PaymentsGetStarsTransactionsRequestTypeID = 0x673ac2f9 + +// Ensuring interfaces in compile-time for PaymentsGetStarsTransactionsRequest. +var ( + _ bin.Encoder = &PaymentsGetStarsTransactionsRequest{} + _ bin.Decoder = &PaymentsGetStarsTransactionsRequest{} + _ bin.BareEncoder = &PaymentsGetStarsTransactionsRequest{} + _ bin.BareDecoder = &PaymentsGetStarsTransactionsRequest{} +) + +func (g *PaymentsGetStarsTransactionsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Flags.Zero()) { + return false + } + if !(g.Inbound == false) { + return false + } + if !(g.Outbound == false) { + return false + } + if !(g.Peer == nil) { + return false + } + if !(g.Offset == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGetStarsTransactionsRequest) String() string { + if g == nil { + return "PaymentsGetStarsTransactionsRequest(nil)" + } + type Alias PaymentsGetStarsTransactionsRequest + return fmt.Sprintf("PaymentsGetStarsTransactionsRequest%+v", Alias(*g)) +} + +// FillFrom fills PaymentsGetStarsTransactionsRequest from given interface. +func (g *PaymentsGetStarsTransactionsRequest) FillFrom(from interface { + GetInbound() (value bool) + GetOutbound() (value bool) + GetPeer() (value InputPeerClass) + GetOffset() (value string) +}) { + g.Inbound = from.GetInbound() + g.Outbound = from.GetOutbound() + g.Peer = from.GetPeer() + g.Offset = from.GetOffset() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsGetStarsTransactionsRequest) TypeID() uint32 { + return PaymentsGetStarsTransactionsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGetStarsTransactionsRequest) TypeName() string { + return "payments.getStarsTransactions" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGetStarsTransactionsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.getStarsTransactions", + ID: PaymentsGetStarsTransactionsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Inbound", + SchemaName: "inbound", + Null: !g.Flags.Has(0), + }, + { + Name: "Outbound", + SchemaName: "outbound", + Null: !g.Flags.Has(1), + }, + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "Offset", + SchemaName: "offset", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (g *PaymentsGetStarsTransactionsRequest) SetFlags() { + if !(g.Inbound == false) { + g.Flags.Set(0) + } + if !(g.Outbound == false) { + g.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (g *PaymentsGetStarsTransactionsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getStarsTransactions#673ac2f9 as nil") + } + b.PutID(PaymentsGetStarsTransactionsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGetStarsTransactionsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getStarsTransactions#673ac2f9 as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getStarsTransactions#673ac2f9: field flags: %w", err) + } + if g.Peer == nil { + return fmt.Errorf("unable to encode payments.getStarsTransactions#673ac2f9: field peer is nil") + } + if err := g.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getStarsTransactions#673ac2f9: field peer: %w", err) + } + b.PutString(g.Offset) + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGetStarsTransactionsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getStarsTransactions#673ac2f9 to nil") + } + if err := b.ConsumeID(PaymentsGetStarsTransactionsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.getStarsTransactions#673ac2f9: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGetStarsTransactionsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getStarsTransactions#673ac2f9 to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.getStarsTransactions#673ac2f9: field flags: %w", err) + } + } + g.Inbound = g.Flags.Has(0) + g.Outbound = g.Flags.Has(1) + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode payments.getStarsTransactions#673ac2f9: field peer: %w", err) + } + g.Peer = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.getStarsTransactions#673ac2f9: field offset: %w", err) + } + g.Offset = value + } + return nil +} + +// SetInbound sets value of Inbound conditional field. +func (g *PaymentsGetStarsTransactionsRequest) SetInbound(value bool) { + if value { + g.Flags.Set(0) + g.Inbound = true + } else { + g.Flags.Unset(0) + g.Inbound = false + } +} + +// GetInbound returns value of Inbound conditional field. +func (g *PaymentsGetStarsTransactionsRequest) GetInbound() (value bool) { + if g == nil { + return + } + return g.Flags.Has(0) +} + +// SetOutbound sets value of Outbound conditional field. +func (g *PaymentsGetStarsTransactionsRequest) SetOutbound(value bool) { + if value { + g.Flags.Set(1) + g.Outbound = true + } else { + g.Flags.Unset(1) + g.Outbound = false + } +} + +// GetOutbound returns value of Outbound conditional field. +func (g *PaymentsGetStarsTransactionsRequest) GetOutbound() (value bool) { + if g == nil { + return + } + return g.Flags.Has(1) +} + +// GetPeer returns value of Peer field. +func (g *PaymentsGetStarsTransactionsRequest) GetPeer() (value InputPeerClass) { + if g == nil { + return + } + return g.Peer +} + +// GetOffset returns value of Offset field. +func (g *PaymentsGetStarsTransactionsRequest) GetOffset() (value string) { + if g == nil { + return + } + return g.Offset +} + +// PaymentsGetStarsTransactions invokes method payments.getStarsTransactions#673ac2f9 returning error if any. +// +// See https://core.telegram.org/method/payments.getStarsTransactions for reference. +func (c *Client) PaymentsGetStarsTransactions(ctx context.Context, request *PaymentsGetStarsTransactionsRequest) (*PaymentsStarsStatus, error) { + var result PaymentsStarsStatus + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_payments_get_stars_transactions_slices_gen.go b/tg/tl_payments_get_stars_transactions_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_get_stars_transactions_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_payment_form_gen.go b/tg/tl_payments_payment_form_gen.go index 8ad0610f84..e6bb3c33b1 100644 --- a/tg/tl_payments_payment_form_gen.go +++ b/tg/tl_payments_payment_form_gen.go @@ -100,12 +100,17 @@ type PaymentsPaymentForm struct { // PaymentsPaymentFormTypeID is TL type id of PaymentsPaymentForm. const PaymentsPaymentFormTypeID = 0xa0058751 +// construct implements constructor of PaymentsPaymentFormClass. +func (p PaymentsPaymentForm) construct() PaymentsPaymentFormClass { return &p } + // Ensuring interfaces in compile-time for PaymentsPaymentForm. var ( _ bin.Encoder = &PaymentsPaymentForm{} _ bin.Decoder = &PaymentsPaymentForm{} _ bin.BareEncoder = &PaymentsPaymentForm{} _ bin.BareDecoder = &PaymentsPaymentForm{} + + _ PaymentsPaymentFormClass = &PaymentsPaymentForm{} ) func (p *PaymentsPaymentForm) Zero() bool { @@ -796,3 +801,478 @@ func (p *PaymentsPaymentForm) GetUsers() (value []UserClass) { func (p *PaymentsPaymentForm) MapUsers() (value UserClassArray) { return UserClassArray(p.Users) } + +// PaymentsPaymentFormStars represents TL type `payments.paymentFormStars#7bf6b15c`. +// +// See https://core.telegram.org/constructor/payments.paymentFormStars for reference. +type PaymentsPaymentFormStars struct { + // Flags field of PaymentsPaymentFormStars. + Flags bin.Fields + // FormID field of PaymentsPaymentFormStars. + FormID int64 + // BotID field of PaymentsPaymentFormStars. + BotID int64 + // Title field of PaymentsPaymentFormStars. + Title string + // Description field of PaymentsPaymentFormStars. + Description string + // Photo field of PaymentsPaymentFormStars. + // + // Use SetPhoto and GetPhoto helpers. + Photo WebDocumentClass + // Invoice field of PaymentsPaymentFormStars. + Invoice Invoice + // Users field of PaymentsPaymentFormStars. + Users []UserClass +} + +// PaymentsPaymentFormStarsTypeID is TL type id of PaymentsPaymentFormStars. +const PaymentsPaymentFormStarsTypeID = 0x7bf6b15c + +// construct implements constructor of PaymentsPaymentFormClass. +func (p PaymentsPaymentFormStars) construct() PaymentsPaymentFormClass { return &p } + +// Ensuring interfaces in compile-time for PaymentsPaymentFormStars. +var ( + _ bin.Encoder = &PaymentsPaymentFormStars{} + _ bin.Decoder = &PaymentsPaymentFormStars{} + _ bin.BareEncoder = &PaymentsPaymentFormStars{} + _ bin.BareDecoder = &PaymentsPaymentFormStars{} + + _ PaymentsPaymentFormClass = &PaymentsPaymentFormStars{} +) + +func (p *PaymentsPaymentFormStars) Zero() bool { + if p == nil { + return true + } + if !(p.Flags.Zero()) { + return false + } + if !(p.FormID == 0) { + return false + } + if !(p.BotID == 0) { + return false + } + if !(p.Title == "") { + return false + } + if !(p.Description == "") { + return false + } + if !(p.Photo == nil) { + return false + } + if !(p.Invoice.Zero()) { + return false + } + if !(p.Users == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (p *PaymentsPaymentFormStars) String() string { + if p == nil { + return "PaymentsPaymentFormStars(nil)" + } + type Alias PaymentsPaymentFormStars + return fmt.Sprintf("PaymentsPaymentFormStars%+v", Alias(*p)) +} + +// FillFrom fills PaymentsPaymentFormStars from given interface. +func (p *PaymentsPaymentFormStars) FillFrom(from interface { + GetFormID() (value int64) + GetBotID() (value int64) + GetTitle() (value string) + GetDescription() (value string) + GetPhoto() (value WebDocumentClass, ok bool) + GetInvoice() (value Invoice) + GetUsers() (value []UserClass) +}) { + p.FormID = from.GetFormID() + p.BotID = from.GetBotID() + p.Title = from.GetTitle() + p.Description = from.GetDescription() + if val, ok := from.GetPhoto(); ok { + p.Photo = val + } + + p.Invoice = from.GetInvoice() + p.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsPaymentFormStars) TypeID() uint32 { + return PaymentsPaymentFormStarsTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsPaymentFormStars) TypeName() string { + return "payments.paymentFormStars" +} + +// TypeInfo returns info about TL type. +func (p *PaymentsPaymentFormStars) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.paymentFormStars", + ID: PaymentsPaymentFormStarsTypeID, + } + if p == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "FormID", + SchemaName: "form_id", + }, + { + Name: "BotID", + SchemaName: "bot_id", + }, + { + Name: "Title", + SchemaName: "title", + }, + { + Name: "Description", + SchemaName: "description", + }, + { + Name: "Photo", + SchemaName: "photo", + Null: !p.Flags.Has(5), + }, + { + Name: "Invoice", + SchemaName: "invoice", + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (p *PaymentsPaymentFormStars) SetFlags() { + if !(p.Photo == nil) { + p.Flags.Set(5) + } +} + +// Encode implements bin.Encoder. +func (p *PaymentsPaymentFormStars) Encode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode payments.paymentFormStars#7bf6b15c as nil") + } + b.PutID(PaymentsPaymentFormStarsTypeID) + return p.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (p *PaymentsPaymentFormStars) EncodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode payments.paymentFormStars#7bf6b15c as nil") + } + p.SetFlags() + if err := p.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.paymentFormStars#7bf6b15c: field flags: %w", err) + } + b.PutLong(p.FormID) + b.PutLong(p.BotID) + b.PutString(p.Title) + b.PutString(p.Description) + if p.Flags.Has(5) { + if p.Photo == nil { + return fmt.Errorf("unable to encode payments.paymentFormStars#7bf6b15c: field photo is nil") + } + if err := p.Photo.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.paymentFormStars#7bf6b15c: field photo: %w", err) + } + } + if err := p.Invoice.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.paymentFormStars#7bf6b15c: field invoice: %w", err) + } + b.PutVectorHeader(len(p.Users)) + for idx, v := range p.Users { + if v == nil { + return fmt.Errorf("unable to encode payments.paymentFormStars#7bf6b15c: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.paymentFormStars#7bf6b15c: field users element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (p *PaymentsPaymentFormStars) Decode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode payments.paymentFormStars#7bf6b15c to nil") + } + if err := b.ConsumeID(PaymentsPaymentFormStarsTypeID); err != nil { + return fmt.Errorf("unable to decode payments.paymentFormStars#7bf6b15c: %w", err) + } + return p.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (p *PaymentsPaymentFormStars) DecodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode payments.paymentFormStars#7bf6b15c to nil") + } + { + if err := p.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.paymentFormStars#7bf6b15c: field flags: %w", err) + } + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentFormStars#7bf6b15c: field form_id: %w", err) + } + p.FormID = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentFormStars#7bf6b15c: field bot_id: %w", err) + } + p.BotID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentFormStars#7bf6b15c: field title: %w", err) + } + p.Title = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentFormStars#7bf6b15c: field description: %w", err) + } + p.Description = value + } + if p.Flags.Has(5) { + value, err := DecodeWebDocument(b) + if err != nil { + return fmt.Errorf("unable to decode payments.paymentFormStars#7bf6b15c: field photo: %w", err) + } + p.Photo = value + } + { + if err := p.Invoice.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.paymentFormStars#7bf6b15c: field invoice: %w", err) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentFormStars#7bf6b15c: 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 payments.paymentFormStars#7bf6b15c: field users: %w", err) + } + p.Users = append(p.Users, value) + } + } + return nil +} + +// GetFormID returns value of FormID field. +func (p *PaymentsPaymentFormStars) GetFormID() (value int64) { + if p == nil { + return + } + return p.FormID +} + +// GetBotID returns value of BotID field. +func (p *PaymentsPaymentFormStars) GetBotID() (value int64) { + if p == nil { + return + } + return p.BotID +} + +// GetTitle returns value of Title field. +func (p *PaymentsPaymentFormStars) GetTitle() (value string) { + if p == nil { + return + } + return p.Title +} + +// GetDescription returns value of Description field. +func (p *PaymentsPaymentFormStars) GetDescription() (value string) { + if p == nil { + return + } + return p.Description +} + +// SetPhoto sets value of Photo conditional field. +func (p *PaymentsPaymentFormStars) SetPhoto(value WebDocumentClass) { + p.Flags.Set(5) + p.Photo = value +} + +// GetPhoto returns value of Photo conditional field and +// boolean which is true if field was set. +func (p *PaymentsPaymentFormStars) GetPhoto() (value WebDocumentClass, ok bool) { + if p == nil { + return + } + if !p.Flags.Has(5) { + return value, false + } + return p.Photo, true +} + +// GetInvoice returns value of Invoice field. +func (p *PaymentsPaymentFormStars) GetInvoice() (value Invoice) { + if p == nil { + return + } + return p.Invoice +} + +// GetUsers returns value of Users field. +func (p *PaymentsPaymentFormStars) GetUsers() (value []UserClass) { + if p == nil { + return + } + return p.Users +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (p *PaymentsPaymentFormStars) MapUsers() (value UserClassArray) { + return UserClassArray(p.Users) +} + +// PaymentsPaymentFormClassName is schema name of PaymentsPaymentFormClass. +const PaymentsPaymentFormClassName = "payments.PaymentForm" + +// PaymentsPaymentFormClass represents payments.PaymentForm generic type. +// +// See https://core.telegram.org/type/payments.PaymentForm for reference. +// +// Example: +// +// g, err := tg.DecodePaymentsPaymentForm(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.PaymentsPaymentForm: // payments.paymentForm#a0058751 +// case *tg.PaymentsPaymentFormStars: // payments.paymentFormStars#7bf6b15c +// default: panic(v) +// } +type PaymentsPaymentFormClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() PaymentsPaymentFormClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool + + // Form ID + GetFormID() (value int64) + + // Bot ID + GetBotID() (value int64) + + // Form title + GetTitle() (value string) + + // Description + GetDescription() (value string) + + // Product photo + GetPhoto() (value WebDocumentClass, ok bool) + + // Invoice + GetInvoice() (value Invoice) + + // Users + GetUsers() (value []UserClass) + // Users + MapUsers() (value UserClassArray) +} + +// DecodePaymentsPaymentForm implements binary de-serialization for PaymentsPaymentFormClass. +func DecodePaymentsPaymentForm(buf *bin.Buffer) (PaymentsPaymentFormClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case PaymentsPaymentFormTypeID: + // Decoding payments.paymentForm#a0058751. + v := PaymentsPaymentForm{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode PaymentsPaymentFormClass: %w", err) + } + return &v, nil + case PaymentsPaymentFormStarsTypeID: + // Decoding payments.paymentFormStars#7bf6b15c. + v := PaymentsPaymentFormStars{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode PaymentsPaymentFormClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode PaymentsPaymentFormClass: %w", bin.NewUnexpectedID(id)) + } +} + +// PaymentsPaymentForm boxes the PaymentsPaymentFormClass providing a helper. +type PaymentsPaymentFormBox struct { + PaymentForm PaymentsPaymentFormClass +} + +// Decode implements bin.Decoder for PaymentsPaymentFormBox. +func (b *PaymentsPaymentFormBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode PaymentsPaymentFormBox to nil") + } + v, err := DecodePaymentsPaymentForm(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.PaymentForm = v + return nil +} + +// Encode implements bin.Encode for PaymentsPaymentFormBox. +func (b *PaymentsPaymentFormBox) Encode(buf *bin.Buffer) error { + if b == nil || b.PaymentForm == nil { + return fmt.Errorf("unable to encode PaymentsPaymentFormClass as nil") + } + return b.PaymentForm.Encode(buf) +} diff --git a/tg/tl_payments_payment_form_slices_gen.go b/tg/tl_payments_payment_form_slices_gen.go index fe21471a4c..ceaf473f58 100644 --- a/tg/tl_payments_payment_form_slices_gen.go +++ b/tg/tl_payments_payment_form_slices_gen.go @@ -33,3 +33,275 @@ var ( _ = tgerr.Error{} _ = tdjson.Encoder{} ) + +// PaymentsPaymentFormClassArray is adapter for slice of PaymentsPaymentFormClass. +type PaymentsPaymentFormClassArray []PaymentsPaymentFormClass + +// Sort sorts slice of PaymentsPaymentFormClass. +func (s PaymentsPaymentFormClassArray) Sort(less func(a, b PaymentsPaymentFormClass) bool) PaymentsPaymentFormClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PaymentsPaymentFormClass. +func (s PaymentsPaymentFormClassArray) SortStable(less func(a, b PaymentsPaymentFormClass) bool) PaymentsPaymentFormClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PaymentsPaymentFormClass. +func (s PaymentsPaymentFormClassArray) Retain(keep func(x PaymentsPaymentFormClass) bool) PaymentsPaymentFormClassArray { + 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 PaymentsPaymentFormClassArray) First() (v PaymentsPaymentFormClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PaymentsPaymentFormClassArray) Last() (v PaymentsPaymentFormClass, 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 *PaymentsPaymentFormClassArray) PopFirst() (v PaymentsPaymentFormClass, 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 PaymentsPaymentFormClass + 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 *PaymentsPaymentFormClassArray) Pop() (v PaymentsPaymentFormClass, 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 +} + +// AsPaymentsPaymentForm returns copy with only PaymentsPaymentForm constructors. +func (s PaymentsPaymentFormClassArray) AsPaymentsPaymentForm() (to PaymentsPaymentFormArray) { + for _, elem := range s { + value, ok := elem.(*PaymentsPaymentForm) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsPaymentsPaymentFormStars returns copy with only PaymentsPaymentFormStars constructors. +func (s PaymentsPaymentFormClassArray) AsPaymentsPaymentFormStars() (to PaymentsPaymentFormStarsArray) { + for _, elem := range s { + value, ok := elem.(*PaymentsPaymentFormStars) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// PaymentsPaymentFormArray is adapter for slice of PaymentsPaymentForm. +type PaymentsPaymentFormArray []PaymentsPaymentForm + +// Sort sorts slice of PaymentsPaymentForm. +func (s PaymentsPaymentFormArray) Sort(less func(a, b PaymentsPaymentForm) bool) PaymentsPaymentFormArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PaymentsPaymentForm. +func (s PaymentsPaymentFormArray) SortStable(less func(a, b PaymentsPaymentForm) bool) PaymentsPaymentFormArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PaymentsPaymentForm. +func (s PaymentsPaymentFormArray) Retain(keep func(x PaymentsPaymentForm) bool) PaymentsPaymentFormArray { + 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 PaymentsPaymentFormArray) First() (v PaymentsPaymentForm, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PaymentsPaymentFormArray) Last() (v PaymentsPaymentForm, 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 *PaymentsPaymentFormArray) PopFirst() (v PaymentsPaymentForm, 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 PaymentsPaymentForm + 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 *PaymentsPaymentFormArray) Pop() (v PaymentsPaymentForm, 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 +} + +// PaymentsPaymentFormStarsArray is adapter for slice of PaymentsPaymentFormStars. +type PaymentsPaymentFormStarsArray []PaymentsPaymentFormStars + +// Sort sorts slice of PaymentsPaymentFormStars. +func (s PaymentsPaymentFormStarsArray) Sort(less func(a, b PaymentsPaymentFormStars) bool) PaymentsPaymentFormStarsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PaymentsPaymentFormStars. +func (s PaymentsPaymentFormStarsArray) SortStable(less func(a, b PaymentsPaymentFormStars) bool) PaymentsPaymentFormStarsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PaymentsPaymentFormStars. +func (s PaymentsPaymentFormStarsArray) Retain(keep func(x PaymentsPaymentFormStars) bool) PaymentsPaymentFormStarsArray { + 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 PaymentsPaymentFormStarsArray) First() (v PaymentsPaymentFormStars, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PaymentsPaymentFormStarsArray) Last() (v PaymentsPaymentFormStars, 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 *PaymentsPaymentFormStarsArray) PopFirst() (v PaymentsPaymentFormStars, 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 PaymentsPaymentFormStars + 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 *PaymentsPaymentFormStarsArray) Pop() (v PaymentsPaymentFormStars, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_payments_payment_receipt_gen.go b/tg/tl_payments_payment_receipt_gen.go index f904599891..c3ba05c282 100644 --- a/tg/tl_payments_payment_receipt_gen.go +++ b/tg/tl_payments_payment_receipt_gen.go @@ -91,12 +91,17 @@ type PaymentsPaymentReceipt struct { // PaymentsPaymentReceiptTypeID is TL type id of PaymentsPaymentReceipt. const PaymentsPaymentReceiptTypeID = 0x70c4fe03 +// construct implements constructor of PaymentsPaymentReceiptClass. +func (p PaymentsPaymentReceipt) construct() PaymentsPaymentReceiptClass { return &p } + // Ensuring interfaces in compile-time for PaymentsPaymentReceipt. var ( _ bin.Encoder = &PaymentsPaymentReceipt{} _ bin.Decoder = &PaymentsPaymentReceipt{} _ bin.BareEncoder = &PaymentsPaymentReceipt{} _ bin.BareDecoder = &PaymentsPaymentReceipt{} + + _ PaymentsPaymentReceiptClass = &PaymentsPaymentReceipt{} ) func (p *PaymentsPaymentReceipt) Zero() bool { @@ -653,3 +658,574 @@ func (p *PaymentsPaymentReceipt) GetUsers() (value []UserClass) { func (p *PaymentsPaymentReceipt) MapUsers() (value UserClassArray) { return UserClassArray(p.Users) } + +// PaymentsPaymentReceiptStars represents TL type `payments.paymentReceiptStars#dabbf83a`. +// +// See https://core.telegram.org/constructor/payments.paymentReceiptStars for reference. +type PaymentsPaymentReceiptStars struct { + // Flags field of PaymentsPaymentReceiptStars. + Flags bin.Fields + // Date field of PaymentsPaymentReceiptStars. + Date int + // BotID field of PaymentsPaymentReceiptStars. + BotID int64 + // Title field of PaymentsPaymentReceiptStars. + Title string + // Description field of PaymentsPaymentReceiptStars. + Description string + // Photo field of PaymentsPaymentReceiptStars. + // + // Use SetPhoto and GetPhoto helpers. + Photo WebDocumentClass + // Invoice field of PaymentsPaymentReceiptStars. + Invoice Invoice + // Currency field of PaymentsPaymentReceiptStars. + Currency string + // TotalAmount field of PaymentsPaymentReceiptStars. + TotalAmount int64 + // TransactionID field of PaymentsPaymentReceiptStars. + TransactionID string + // Users field of PaymentsPaymentReceiptStars. + Users []UserClass +} + +// PaymentsPaymentReceiptStarsTypeID is TL type id of PaymentsPaymentReceiptStars. +const PaymentsPaymentReceiptStarsTypeID = 0xdabbf83a + +// construct implements constructor of PaymentsPaymentReceiptClass. +func (p PaymentsPaymentReceiptStars) construct() PaymentsPaymentReceiptClass { return &p } + +// Ensuring interfaces in compile-time for PaymentsPaymentReceiptStars. +var ( + _ bin.Encoder = &PaymentsPaymentReceiptStars{} + _ bin.Decoder = &PaymentsPaymentReceiptStars{} + _ bin.BareEncoder = &PaymentsPaymentReceiptStars{} + _ bin.BareDecoder = &PaymentsPaymentReceiptStars{} + + _ PaymentsPaymentReceiptClass = &PaymentsPaymentReceiptStars{} +) + +func (p *PaymentsPaymentReceiptStars) Zero() bool { + if p == nil { + return true + } + if !(p.Flags.Zero()) { + return false + } + if !(p.Date == 0) { + return false + } + if !(p.BotID == 0) { + return false + } + if !(p.Title == "") { + return false + } + if !(p.Description == "") { + return false + } + if !(p.Photo == nil) { + return false + } + if !(p.Invoice.Zero()) { + return false + } + if !(p.Currency == "") { + return false + } + if !(p.TotalAmount == 0) { + return false + } + if !(p.TransactionID == "") { + return false + } + if !(p.Users == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (p *PaymentsPaymentReceiptStars) String() string { + if p == nil { + return "PaymentsPaymentReceiptStars(nil)" + } + type Alias PaymentsPaymentReceiptStars + return fmt.Sprintf("PaymentsPaymentReceiptStars%+v", Alias(*p)) +} + +// FillFrom fills PaymentsPaymentReceiptStars from given interface. +func (p *PaymentsPaymentReceiptStars) FillFrom(from interface { + GetDate() (value int) + GetBotID() (value int64) + GetTitle() (value string) + GetDescription() (value string) + GetPhoto() (value WebDocumentClass, ok bool) + GetInvoice() (value Invoice) + GetCurrency() (value string) + GetTotalAmount() (value int64) + GetTransactionID() (value string) + GetUsers() (value []UserClass) +}) { + p.Date = from.GetDate() + p.BotID = from.GetBotID() + p.Title = from.GetTitle() + p.Description = from.GetDescription() + if val, ok := from.GetPhoto(); ok { + p.Photo = val + } + + p.Invoice = from.GetInvoice() + p.Currency = from.GetCurrency() + p.TotalAmount = from.GetTotalAmount() + p.TransactionID = from.GetTransactionID() + p.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsPaymentReceiptStars) TypeID() uint32 { + return PaymentsPaymentReceiptStarsTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsPaymentReceiptStars) TypeName() string { + return "payments.paymentReceiptStars" +} + +// TypeInfo returns info about TL type. +func (p *PaymentsPaymentReceiptStars) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.paymentReceiptStars", + ID: PaymentsPaymentReceiptStarsTypeID, + } + if p == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Date", + SchemaName: "date", + }, + { + Name: "BotID", + SchemaName: "bot_id", + }, + { + Name: "Title", + SchemaName: "title", + }, + { + Name: "Description", + SchemaName: "description", + }, + { + Name: "Photo", + SchemaName: "photo", + Null: !p.Flags.Has(2), + }, + { + Name: "Invoice", + SchemaName: "invoice", + }, + { + Name: "Currency", + SchemaName: "currency", + }, + { + Name: "TotalAmount", + SchemaName: "total_amount", + }, + { + Name: "TransactionID", + SchemaName: "transaction_id", + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (p *PaymentsPaymentReceiptStars) SetFlags() { + if !(p.Photo == nil) { + p.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (p *PaymentsPaymentReceiptStars) Encode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode payments.paymentReceiptStars#dabbf83a as nil") + } + b.PutID(PaymentsPaymentReceiptStarsTypeID) + return p.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (p *PaymentsPaymentReceiptStars) EncodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode payments.paymentReceiptStars#dabbf83a as nil") + } + p.SetFlags() + if err := p.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.paymentReceiptStars#dabbf83a: field flags: %w", err) + } + b.PutInt(p.Date) + b.PutLong(p.BotID) + b.PutString(p.Title) + b.PutString(p.Description) + if p.Flags.Has(2) { + if p.Photo == nil { + return fmt.Errorf("unable to encode payments.paymentReceiptStars#dabbf83a: field photo is nil") + } + if err := p.Photo.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.paymentReceiptStars#dabbf83a: field photo: %w", err) + } + } + if err := p.Invoice.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.paymentReceiptStars#dabbf83a: field invoice: %w", err) + } + b.PutString(p.Currency) + b.PutLong(p.TotalAmount) + b.PutString(p.TransactionID) + b.PutVectorHeader(len(p.Users)) + for idx, v := range p.Users { + if v == nil { + return fmt.Errorf("unable to encode payments.paymentReceiptStars#dabbf83a: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.paymentReceiptStars#dabbf83a: field users element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (p *PaymentsPaymentReceiptStars) Decode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode payments.paymentReceiptStars#dabbf83a to nil") + } + if err := b.ConsumeID(PaymentsPaymentReceiptStarsTypeID); err != nil { + return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: %w", err) + } + return p.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (p *PaymentsPaymentReceiptStars) DecodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode payments.paymentReceiptStars#dabbf83a to nil") + } + { + if err := p.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field flags: %w", err) + } + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field date: %w", err) + } + p.Date = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field bot_id: %w", err) + } + p.BotID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field title: %w", err) + } + p.Title = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field description: %w", err) + } + p.Description = value + } + if p.Flags.Has(2) { + value, err := DecodeWebDocument(b) + if err != nil { + return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field photo: %w", err) + } + p.Photo = value + } + { + if err := p.Invoice.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field invoice: %w", err) + } + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field currency: %w", err) + } + p.Currency = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field total_amount: %w", err) + } + p.TotalAmount = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field transaction_id: %w", err) + } + p.TransactionID = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: 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 payments.paymentReceiptStars#dabbf83a: field users: %w", err) + } + p.Users = append(p.Users, value) + } + } + return nil +} + +// GetDate returns value of Date field. +func (p *PaymentsPaymentReceiptStars) GetDate() (value int) { + if p == nil { + return + } + return p.Date +} + +// GetBotID returns value of BotID field. +func (p *PaymentsPaymentReceiptStars) GetBotID() (value int64) { + if p == nil { + return + } + return p.BotID +} + +// GetTitle returns value of Title field. +func (p *PaymentsPaymentReceiptStars) GetTitle() (value string) { + if p == nil { + return + } + return p.Title +} + +// GetDescription returns value of Description field. +func (p *PaymentsPaymentReceiptStars) GetDescription() (value string) { + if p == nil { + return + } + return p.Description +} + +// SetPhoto sets value of Photo conditional field. +func (p *PaymentsPaymentReceiptStars) SetPhoto(value WebDocumentClass) { + p.Flags.Set(2) + p.Photo = value +} + +// GetPhoto returns value of Photo conditional field and +// boolean which is true if field was set. +func (p *PaymentsPaymentReceiptStars) GetPhoto() (value WebDocumentClass, ok bool) { + if p == nil { + return + } + if !p.Flags.Has(2) { + return value, false + } + return p.Photo, true +} + +// GetInvoice returns value of Invoice field. +func (p *PaymentsPaymentReceiptStars) GetInvoice() (value Invoice) { + if p == nil { + return + } + return p.Invoice +} + +// GetCurrency returns value of Currency field. +func (p *PaymentsPaymentReceiptStars) GetCurrency() (value string) { + if p == nil { + return + } + return p.Currency +} + +// GetTotalAmount returns value of TotalAmount field. +func (p *PaymentsPaymentReceiptStars) GetTotalAmount() (value int64) { + if p == nil { + return + } + return p.TotalAmount +} + +// GetTransactionID returns value of TransactionID field. +func (p *PaymentsPaymentReceiptStars) GetTransactionID() (value string) { + if p == nil { + return + } + return p.TransactionID +} + +// GetUsers returns value of Users field. +func (p *PaymentsPaymentReceiptStars) GetUsers() (value []UserClass) { + if p == nil { + return + } + return p.Users +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (p *PaymentsPaymentReceiptStars) MapUsers() (value UserClassArray) { + return UserClassArray(p.Users) +} + +// PaymentsPaymentReceiptClassName is schema name of PaymentsPaymentReceiptClass. +const PaymentsPaymentReceiptClassName = "payments.PaymentReceipt" + +// PaymentsPaymentReceiptClass represents payments.PaymentReceipt generic type. +// +// See https://core.telegram.org/type/payments.PaymentReceipt for reference. +// +// Example: +// +// g, err := tg.DecodePaymentsPaymentReceipt(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.PaymentsPaymentReceipt: // payments.paymentReceipt#70c4fe03 +// case *tg.PaymentsPaymentReceiptStars: // payments.paymentReceiptStars#dabbf83a +// default: panic(v) +// } +type PaymentsPaymentReceiptClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() PaymentsPaymentReceiptClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool + + // Date of generation + GetDate() (value int) + + // Bot ID + GetBotID() (value int64) + + // Title + GetTitle() (value string) + + // Description + GetDescription() (value string) + + // Photo + GetPhoto() (value WebDocumentClass, ok bool) + + // Invoice + GetInvoice() (value Invoice) + + // Three-letter ISO 4217 currency¹ code + // + // Links: + // 1) https://core.telegram.org/bots/payments#supported-currencies + GetCurrency() (value string) + + // Total amount in the smallest units of the currency (integer, not float/double). For + // example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in + // currencies.json¹, it shows the number of digits past the decimal point for each + // currency (2 for the majority of currencies). + // + // Links: + // 1) https://core.telegram.org/bots/payments/currencies.json + GetTotalAmount() (value int64) + + // Users + GetUsers() (value []UserClass) + // Users + MapUsers() (value UserClassArray) +} + +// DecodePaymentsPaymentReceipt implements binary de-serialization for PaymentsPaymentReceiptClass. +func DecodePaymentsPaymentReceipt(buf *bin.Buffer) (PaymentsPaymentReceiptClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case PaymentsPaymentReceiptTypeID: + // Decoding payments.paymentReceipt#70c4fe03. + v := PaymentsPaymentReceipt{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode PaymentsPaymentReceiptClass: %w", err) + } + return &v, nil + case PaymentsPaymentReceiptStarsTypeID: + // Decoding payments.paymentReceiptStars#dabbf83a. + v := PaymentsPaymentReceiptStars{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode PaymentsPaymentReceiptClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode PaymentsPaymentReceiptClass: %w", bin.NewUnexpectedID(id)) + } +} + +// PaymentsPaymentReceipt boxes the PaymentsPaymentReceiptClass providing a helper. +type PaymentsPaymentReceiptBox struct { + PaymentReceipt PaymentsPaymentReceiptClass +} + +// Decode implements bin.Decoder for PaymentsPaymentReceiptBox. +func (b *PaymentsPaymentReceiptBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode PaymentsPaymentReceiptBox to nil") + } + v, err := DecodePaymentsPaymentReceipt(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.PaymentReceipt = v + return nil +} + +// Encode implements bin.Encode for PaymentsPaymentReceiptBox. +func (b *PaymentsPaymentReceiptBox) Encode(buf *bin.Buffer) error { + if b == nil || b.PaymentReceipt == nil { + return fmt.Errorf("unable to encode PaymentsPaymentReceiptClass as nil") + } + return b.PaymentReceipt.Encode(buf) +} diff --git a/tg/tl_payments_payment_receipt_slices_gen.go b/tg/tl_payments_payment_receipt_slices_gen.go index fe21471a4c..0da6697f8a 100644 --- a/tg/tl_payments_payment_receipt_slices_gen.go +++ b/tg/tl_payments_payment_receipt_slices_gen.go @@ -33,3 +33,317 @@ var ( _ = tgerr.Error{} _ = tdjson.Encoder{} ) + +// PaymentsPaymentReceiptClassArray is adapter for slice of PaymentsPaymentReceiptClass. +type PaymentsPaymentReceiptClassArray []PaymentsPaymentReceiptClass + +// Sort sorts slice of PaymentsPaymentReceiptClass. +func (s PaymentsPaymentReceiptClassArray) Sort(less func(a, b PaymentsPaymentReceiptClass) bool) PaymentsPaymentReceiptClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PaymentsPaymentReceiptClass. +func (s PaymentsPaymentReceiptClassArray) SortStable(less func(a, b PaymentsPaymentReceiptClass) bool) PaymentsPaymentReceiptClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PaymentsPaymentReceiptClass. +func (s PaymentsPaymentReceiptClassArray) Retain(keep func(x PaymentsPaymentReceiptClass) bool) PaymentsPaymentReceiptClassArray { + 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 PaymentsPaymentReceiptClassArray) First() (v PaymentsPaymentReceiptClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PaymentsPaymentReceiptClassArray) Last() (v PaymentsPaymentReceiptClass, 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 *PaymentsPaymentReceiptClassArray) PopFirst() (v PaymentsPaymentReceiptClass, 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 PaymentsPaymentReceiptClass + 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 *PaymentsPaymentReceiptClassArray) Pop() (v PaymentsPaymentReceiptClass, 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 +} + +// SortByDate sorts slice of PaymentsPaymentReceiptClass by Date. +func (s PaymentsPaymentReceiptClassArray) SortByDate() PaymentsPaymentReceiptClassArray { + return s.Sort(func(a, b PaymentsPaymentReceiptClass) bool { + return a.GetDate() < b.GetDate() + }) +} + +// SortStableByDate sorts slice of PaymentsPaymentReceiptClass by Date. +func (s PaymentsPaymentReceiptClassArray) SortStableByDate() PaymentsPaymentReceiptClassArray { + return s.SortStable(func(a, b PaymentsPaymentReceiptClass) bool { + return a.GetDate() < b.GetDate() + }) +} + +// AsPaymentsPaymentReceipt returns copy with only PaymentsPaymentReceipt constructors. +func (s PaymentsPaymentReceiptClassArray) AsPaymentsPaymentReceipt() (to PaymentsPaymentReceiptArray) { + for _, elem := range s { + value, ok := elem.(*PaymentsPaymentReceipt) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsPaymentsPaymentReceiptStars returns copy with only PaymentsPaymentReceiptStars constructors. +func (s PaymentsPaymentReceiptClassArray) AsPaymentsPaymentReceiptStars() (to PaymentsPaymentReceiptStarsArray) { + for _, elem := range s { + value, ok := elem.(*PaymentsPaymentReceiptStars) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// PaymentsPaymentReceiptArray is adapter for slice of PaymentsPaymentReceipt. +type PaymentsPaymentReceiptArray []PaymentsPaymentReceipt + +// Sort sorts slice of PaymentsPaymentReceipt. +func (s PaymentsPaymentReceiptArray) Sort(less func(a, b PaymentsPaymentReceipt) bool) PaymentsPaymentReceiptArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PaymentsPaymentReceipt. +func (s PaymentsPaymentReceiptArray) SortStable(less func(a, b PaymentsPaymentReceipt) bool) PaymentsPaymentReceiptArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PaymentsPaymentReceipt. +func (s PaymentsPaymentReceiptArray) Retain(keep func(x PaymentsPaymentReceipt) bool) PaymentsPaymentReceiptArray { + 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 PaymentsPaymentReceiptArray) First() (v PaymentsPaymentReceipt, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PaymentsPaymentReceiptArray) Last() (v PaymentsPaymentReceipt, 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 *PaymentsPaymentReceiptArray) PopFirst() (v PaymentsPaymentReceipt, 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 PaymentsPaymentReceipt + 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 *PaymentsPaymentReceiptArray) Pop() (v PaymentsPaymentReceipt, 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 +} + +// SortByDate sorts slice of PaymentsPaymentReceipt by Date. +func (s PaymentsPaymentReceiptArray) SortByDate() PaymentsPaymentReceiptArray { + return s.Sort(func(a, b PaymentsPaymentReceipt) bool { + return a.GetDate() < b.GetDate() + }) +} + +// SortStableByDate sorts slice of PaymentsPaymentReceipt by Date. +func (s PaymentsPaymentReceiptArray) SortStableByDate() PaymentsPaymentReceiptArray { + return s.SortStable(func(a, b PaymentsPaymentReceipt) bool { + return a.GetDate() < b.GetDate() + }) +} + +// PaymentsPaymentReceiptStarsArray is adapter for slice of PaymentsPaymentReceiptStars. +type PaymentsPaymentReceiptStarsArray []PaymentsPaymentReceiptStars + +// Sort sorts slice of PaymentsPaymentReceiptStars. +func (s PaymentsPaymentReceiptStarsArray) Sort(less func(a, b PaymentsPaymentReceiptStars) bool) PaymentsPaymentReceiptStarsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PaymentsPaymentReceiptStars. +func (s PaymentsPaymentReceiptStarsArray) SortStable(less func(a, b PaymentsPaymentReceiptStars) bool) PaymentsPaymentReceiptStarsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PaymentsPaymentReceiptStars. +func (s PaymentsPaymentReceiptStarsArray) Retain(keep func(x PaymentsPaymentReceiptStars) bool) PaymentsPaymentReceiptStarsArray { + 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 PaymentsPaymentReceiptStarsArray) First() (v PaymentsPaymentReceiptStars, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PaymentsPaymentReceiptStarsArray) Last() (v PaymentsPaymentReceiptStars, 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 *PaymentsPaymentReceiptStarsArray) PopFirst() (v PaymentsPaymentReceiptStars, 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 PaymentsPaymentReceiptStars + 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 *PaymentsPaymentReceiptStarsArray) Pop() (v PaymentsPaymentReceiptStars, 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 +} + +// SortByDate sorts slice of PaymentsPaymentReceiptStars by Date. +func (s PaymentsPaymentReceiptStarsArray) SortByDate() PaymentsPaymentReceiptStarsArray { + return s.Sort(func(a, b PaymentsPaymentReceiptStars) bool { + return a.GetDate() < b.GetDate() + }) +} + +// SortStableByDate sorts slice of PaymentsPaymentReceiptStars by Date. +func (s PaymentsPaymentReceiptStarsArray) SortStableByDate() PaymentsPaymentReceiptStarsArray { + return s.SortStable(func(a, b PaymentsPaymentReceiptStars) bool { + return a.GetDate() < b.GetDate() + }) +} diff --git a/tg/tl_payments_refund_stars_charge_gen.go b/tg/tl_payments_refund_stars_charge_gen.go new file mode 100644 index 0000000000..f24655cb44 --- /dev/null +++ b/tg/tl_payments_refund_stars_charge_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{} +) + +// PaymentsRefundStarsChargeRequest represents TL type `payments.refundStarsCharge#25ae8f4a`. +// +// See https://core.telegram.org/method/payments.refundStarsCharge for reference. +type PaymentsRefundStarsChargeRequest struct { + // UserID field of PaymentsRefundStarsChargeRequest. + UserID InputUserClass + // ChargeID field of PaymentsRefundStarsChargeRequest. + ChargeID string +} + +// PaymentsRefundStarsChargeRequestTypeID is TL type id of PaymentsRefundStarsChargeRequest. +const PaymentsRefundStarsChargeRequestTypeID = 0x25ae8f4a + +// Ensuring interfaces in compile-time for PaymentsRefundStarsChargeRequest. +var ( + _ bin.Encoder = &PaymentsRefundStarsChargeRequest{} + _ bin.Decoder = &PaymentsRefundStarsChargeRequest{} + _ bin.BareEncoder = &PaymentsRefundStarsChargeRequest{} + _ bin.BareDecoder = &PaymentsRefundStarsChargeRequest{} +) + +func (r *PaymentsRefundStarsChargeRequest) Zero() bool { + if r == nil { + return true + } + if !(r.UserID == nil) { + return false + } + if !(r.ChargeID == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *PaymentsRefundStarsChargeRequest) String() string { + if r == nil { + return "PaymentsRefundStarsChargeRequest(nil)" + } + type Alias PaymentsRefundStarsChargeRequest + return fmt.Sprintf("PaymentsRefundStarsChargeRequest%+v", Alias(*r)) +} + +// FillFrom fills PaymentsRefundStarsChargeRequest from given interface. +func (r *PaymentsRefundStarsChargeRequest) FillFrom(from interface { + GetUserID() (value InputUserClass) + GetChargeID() (value string) +}) { + r.UserID = from.GetUserID() + r.ChargeID = from.GetChargeID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsRefundStarsChargeRequest) TypeID() uint32 { + return PaymentsRefundStarsChargeRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsRefundStarsChargeRequest) TypeName() string { + return "payments.refundStarsCharge" +} + +// TypeInfo returns info about TL type. +func (r *PaymentsRefundStarsChargeRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.refundStarsCharge", + ID: PaymentsRefundStarsChargeRequestTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "ChargeID", + SchemaName: "charge_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (r *PaymentsRefundStarsChargeRequest) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode payments.refundStarsCharge#25ae8f4a as nil") + } + b.PutID(PaymentsRefundStarsChargeRequestTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *PaymentsRefundStarsChargeRequest) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode payments.refundStarsCharge#25ae8f4a as nil") + } + if r.UserID == nil { + return fmt.Errorf("unable to encode payments.refundStarsCharge#25ae8f4a: field user_id is nil") + } + if err := r.UserID.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.refundStarsCharge#25ae8f4a: field user_id: %w", err) + } + b.PutString(r.ChargeID) + return nil +} + +// Decode implements bin.Decoder. +func (r *PaymentsRefundStarsChargeRequest) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode payments.refundStarsCharge#25ae8f4a to nil") + } + if err := b.ConsumeID(PaymentsRefundStarsChargeRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.refundStarsCharge#25ae8f4a: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *PaymentsRefundStarsChargeRequest) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode payments.refundStarsCharge#25ae8f4a to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode payments.refundStarsCharge#25ae8f4a: field user_id: %w", err) + } + r.UserID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.refundStarsCharge#25ae8f4a: field charge_id: %w", err) + } + r.ChargeID = value + } + return nil +} + +// GetUserID returns value of UserID field. +func (r *PaymentsRefundStarsChargeRequest) GetUserID() (value InputUserClass) { + if r == nil { + return + } + return r.UserID +} + +// GetChargeID returns value of ChargeID field. +func (r *PaymentsRefundStarsChargeRequest) GetChargeID() (value string) { + if r == nil { + return + } + return r.ChargeID +} + +// PaymentsRefundStarsCharge invokes method payments.refundStarsCharge#25ae8f4a returning error if any. +// +// See https://core.telegram.org/method/payments.refundStarsCharge for reference. +func (c *Client) PaymentsRefundStarsCharge(ctx context.Context, request *PaymentsRefundStarsChargeRequest) (UpdatesClass, error) { + var result UpdatesBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Updates, nil +} diff --git a/tg/tl_payments_refund_stars_charge_slices_gen.go b/tg/tl_payments_refund_stars_charge_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_refund_stars_charge_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_send_stars_form_gen.go b/tg/tl_payments_send_stars_form_gen.go new file mode 100644 index 0000000000..e2609940c6 --- /dev/null +++ b/tg/tl_payments_send_stars_form_gen.go @@ -0,0 +1,223 @@ +// 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{} +) + +// PaymentsSendStarsFormRequest represents TL type `payments.sendStarsForm#2bb731d`. +// +// See https://core.telegram.org/method/payments.sendStarsForm for reference. +type PaymentsSendStarsFormRequest struct { + // Flags field of PaymentsSendStarsFormRequest. + Flags bin.Fields + // FormID field of PaymentsSendStarsFormRequest. + FormID int64 + // Invoice field of PaymentsSendStarsFormRequest. + Invoice InputInvoiceClass +} + +// PaymentsSendStarsFormRequestTypeID is TL type id of PaymentsSendStarsFormRequest. +const PaymentsSendStarsFormRequestTypeID = 0x2bb731d + +// Ensuring interfaces in compile-time for PaymentsSendStarsFormRequest. +var ( + _ bin.Encoder = &PaymentsSendStarsFormRequest{} + _ bin.Decoder = &PaymentsSendStarsFormRequest{} + _ bin.BareEncoder = &PaymentsSendStarsFormRequest{} + _ bin.BareDecoder = &PaymentsSendStarsFormRequest{} +) + +func (s *PaymentsSendStarsFormRequest) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.FormID == 0) { + return false + } + if !(s.Invoice == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *PaymentsSendStarsFormRequest) String() string { + if s == nil { + return "PaymentsSendStarsFormRequest(nil)" + } + type Alias PaymentsSendStarsFormRequest + return fmt.Sprintf("PaymentsSendStarsFormRequest%+v", Alias(*s)) +} + +// FillFrom fills PaymentsSendStarsFormRequest from given interface. +func (s *PaymentsSendStarsFormRequest) FillFrom(from interface { + GetFormID() (value int64) + GetInvoice() (value InputInvoiceClass) +}) { + s.FormID = from.GetFormID() + s.Invoice = from.GetInvoice() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsSendStarsFormRequest) TypeID() uint32 { + return PaymentsSendStarsFormRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsSendStarsFormRequest) TypeName() string { + return "payments.sendStarsForm" +} + +// TypeInfo returns info about TL type. +func (s *PaymentsSendStarsFormRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.sendStarsForm", + ID: PaymentsSendStarsFormRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "FormID", + SchemaName: "form_id", + }, + { + Name: "Invoice", + SchemaName: "invoice", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *PaymentsSendStarsFormRequest) SetFlags() { +} + +// Encode implements bin.Encoder. +func (s *PaymentsSendStarsFormRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode payments.sendStarsForm#2bb731d as nil") + } + b.PutID(PaymentsSendStarsFormRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *PaymentsSendStarsFormRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode payments.sendStarsForm#2bb731d as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.sendStarsForm#2bb731d: field flags: %w", err) + } + b.PutLong(s.FormID) + if s.Invoice == nil { + return fmt.Errorf("unable to encode payments.sendStarsForm#2bb731d: field invoice is nil") + } + if err := s.Invoice.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.sendStarsForm#2bb731d: field invoice: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *PaymentsSendStarsFormRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode payments.sendStarsForm#2bb731d to nil") + } + if err := b.ConsumeID(PaymentsSendStarsFormRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.sendStarsForm#2bb731d: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *PaymentsSendStarsFormRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode payments.sendStarsForm#2bb731d to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.sendStarsForm#2bb731d: field flags: %w", err) + } + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode payments.sendStarsForm#2bb731d: field form_id: %w", err) + } + s.FormID = value + } + { + value, err := DecodeInputInvoice(b) + if err != nil { + return fmt.Errorf("unable to decode payments.sendStarsForm#2bb731d: field invoice: %w", err) + } + s.Invoice = value + } + return nil +} + +// GetFormID returns value of FormID field. +func (s *PaymentsSendStarsFormRequest) GetFormID() (value int64) { + if s == nil { + return + } + return s.FormID +} + +// GetInvoice returns value of Invoice field. +func (s *PaymentsSendStarsFormRequest) GetInvoice() (value InputInvoiceClass) { + if s == nil { + return + } + return s.Invoice +} + +// PaymentsSendStarsForm invokes method payments.sendStarsForm#2bb731d returning error if any. +// +// See https://core.telegram.org/method/payments.sendStarsForm for reference. +func (c *Client) PaymentsSendStarsForm(ctx context.Context, request *PaymentsSendStarsFormRequest) (PaymentsPaymentResultClass, error) { + var result PaymentsPaymentResultBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.PaymentResult, nil +} diff --git a/tg/tl_payments_send_stars_form_slices_gen.go b/tg/tl_payments_send_stars_form_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_send_stars_form_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_stars_status_gen.go b/tg/tl_payments_stars_status_gen.go new file mode 100644 index 0000000000..d43e047bbc --- /dev/null +++ b/tg/tl_payments_stars_status_gen.go @@ -0,0 +1,369 @@ +// 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{} +) + +// PaymentsStarsStatus represents TL type `payments.starsStatus#8cf4ee60`. +// +// See https://core.telegram.org/constructor/payments.starsStatus for reference. +type PaymentsStarsStatus struct { + // Flags field of PaymentsStarsStatus. + Flags bin.Fields + // Balance field of PaymentsStarsStatus. + Balance int64 + // History field of PaymentsStarsStatus. + History []StarsTransaction + // NextOffset field of PaymentsStarsStatus. + // + // Use SetNextOffset and GetNextOffset helpers. + NextOffset string + // Chats field of PaymentsStarsStatus. + Chats []ChatClass + // Users field of PaymentsStarsStatus. + Users []UserClass +} + +// PaymentsStarsStatusTypeID is TL type id of PaymentsStarsStatus. +const PaymentsStarsStatusTypeID = 0x8cf4ee60 + +// Ensuring interfaces in compile-time for PaymentsStarsStatus. +var ( + _ bin.Encoder = &PaymentsStarsStatus{} + _ bin.Decoder = &PaymentsStarsStatus{} + _ bin.BareEncoder = &PaymentsStarsStatus{} + _ bin.BareDecoder = &PaymentsStarsStatus{} +) + +func (s *PaymentsStarsStatus) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.Balance == 0) { + return false + } + if !(s.History == nil) { + return false + } + if !(s.NextOffset == "") { + return false + } + if !(s.Chats == nil) { + return false + } + if !(s.Users == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *PaymentsStarsStatus) String() string { + if s == nil { + return "PaymentsStarsStatus(nil)" + } + type Alias PaymentsStarsStatus + return fmt.Sprintf("PaymentsStarsStatus%+v", Alias(*s)) +} + +// FillFrom fills PaymentsStarsStatus from given interface. +func (s *PaymentsStarsStatus) FillFrom(from interface { + GetBalance() (value int64) + GetHistory() (value []StarsTransaction) + GetNextOffset() (value string, ok bool) + GetChats() (value []ChatClass) + GetUsers() (value []UserClass) +}) { + s.Balance = from.GetBalance() + s.History = from.GetHistory() + if val, ok := from.GetNextOffset(); ok { + s.NextOffset = val + } + + s.Chats = from.GetChats() + s.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsStarsStatus) TypeID() uint32 { + return PaymentsStarsStatusTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsStarsStatus) TypeName() string { + return "payments.starsStatus" +} + +// TypeInfo returns info about TL type. +func (s *PaymentsStarsStatus) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.starsStatus", + ID: PaymentsStarsStatusTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Balance", + SchemaName: "balance", + }, + { + Name: "History", + SchemaName: "history", + }, + { + Name: "NextOffset", + SchemaName: "next_offset", + Null: !s.Flags.Has(0), + }, + { + Name: "Chats", + SchemaName: "chats", + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *PaymentsStarsStatus) SetFlags() { + if !(s.NextOffset == "") { + s.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (s *PaymentsStarsStatus) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode payments.starsStatus#8cf4ee60 as nil") + } + b.PutID(PaymentsStarsStatusTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *PaymentsStarsStatus) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode payments.starsStatus#8cf4ee60 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.starsStatus#8cf4ee60: field flags: %w", err) + } + b.PutLong(s.Balance) + b.PutVectorHeader(len(s.History)) + for idx, v := range s.History { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.starsStatus#8cf4ee60: field history element with index %d: %w", idx, err) + } + } + if s.Flags.Has(0) { + b.PutString(s.NextOffset) + } + b.PutVectorHeader(len(s.Chats)) + for idx, v := range s.Chats { + if v == nil { + return fmt.Errorf("unable to encode payments.starsStatus#8cf4ee60: field chats element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.starsStatus#8cf4ee60: field chats element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(s.Users)) + for idx, v := range s.Users { + if v == nil { + return fmt.Errorf("unable to encode payments.starsStatus#8cf4ee60: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.starsStatus#8cf4ee60: field users element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (s *PaymentsStarsStatus) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode payments.starsStatus#8cf4ee60 to nil") + } + if err := b.ConsumeID(PaymentsStarsStatusTypeID); err != nil { + return fmt.Errorf("unable to decode payments.starsStatus#8cf4ee60: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *PaymentsStarsStatus) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode payments.starsStatus#8cf4ee60 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.starsStatus#8cf4ee60: field flags: %w", err) + } + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode payments.starsStatus#8cf4ee60: field balance: %w", err) + } + s.Balance = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.starsStatus#8cf4ee60: field history: %w", err) + } + + if headerLen > 0 { + s.History = make([]StarsTransaction, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value StarsTransaction + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.starsStatus#8cf4ee60: field history: %w", err) + } + s.History = append(s.History, value) + } + } + if s.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.starsStatus#8cf4ee60: field next_offset: %w", err) + } + s.NextOffset = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.starsStatus#8cf4ee60: field chats: %w", err) + } + + if headerLen > 0 { + s.Chats = make([]ChatClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeChat(b) + if err != nil { + return fmt.Errorf("unable to decode payments.starsStatus#8cf4ee60: field chats: %w", err) + } + s.Chats = append(s.Chats, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.starsStatus#8cf4ee60: field users: %w", err) + } + + if headerLen > 0 { + s.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeUser(b) + if err != nil { + return fmt.Errorf("unable to decode payments.starsStatus#8cf4ee60: field users: %w", err) + } + s.Users = append(s.Users, value) + } + } + return nil +} + +// GetBalance returns value of Balance field. +func (s *PaymentsStarsStatus) GetBalance() (value int64) { + if s == nil { + return + } + return s.Balance +} + +// GetHistory returns value of History field. +func (s *PaymentsStarsStatus) GetHistory() (value []StarsTransaction) { + if s == nil { + return + } + return s.History +} + +// SetNextOffset sets value of NextOffset conditional field. +func (s *PaymentsStarsStatus) SetNextOffset(value string) { + s.Flags.Set(0) + s.NextOffset = value +} + +// GetNextOffset returns value of NextOffset conditional field and +// boolean which is true if field was set. +func (s *PaymentsStarsStatus) GetNextOffset() (value string, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.NextOffset, true +} + +// GetChats returns value of Chats field. +func (s *PaymentsStarsStatus) GetChats() (value []ChatClass) { + if s == nil { + return + } + return s.Chats +} + +// GetUsers returns value of Users field. +func (s *PaymentsStarsStatus) GetUsers() (value []UserClass) { + if s == nil { + return + } + return s.Users +} + +// MapChats returns field Chats wrapped in ChatClassArray helper. +func (s *PaymentsStarsStatus) MapChats() (value ChatClassArray) { + return ChatClassArray(s.Chats) +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (s *PaymentsStarsStatus) MapUsers() (value UserClassArray) { + return UserClassArray(s.Users) +} diff --git a/tg/tl_payments_stars_status_slices_gen.go b/tg/tl_payments_stars_status_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_stars_status_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_registry_gen.go b/tg/tl_registry_gen.go index 7ac4ab1336..868d4331d5 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 179 +const Layer = 181 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -67,7 +67,7 @@ func TypesMap() map[uint32]string { InputMediaPhotoExternalTypeID: "inputMediaPhotoExternal#e5bbfe1a", InputMediaDocumentExternalTypeID: "inputMediaDocumentExternal#fb52dc99", InputMediaGameTypeID: "inputMediaGame#d33f43f3", - InputMediaInvoiceTypeID: "inputMediaInvoice#8eb5a6d5", + InputMediaInvoiceTypeID: "inputMediaInvoice#405fef0d", InputMediaGeoLiveTypeID: "inputMediaGeoLive#971fa843", InputMediaPollTypeID: "inputMediaPoll#f94e5f1", InputMediaDiceTypeID: "inputMediaDice#e66fbf7b", @@ -128,7 +128,7 @@ func TypesMap() map[uint32]string { ChatPhotoEmptyTypeID: "chatPhotoEmpty#37c1011c", ChatPhotoTypeID: "chatPhoto#1c6e1c11", MessageEmptyTypeID: "messageEmpty#90a6ca84", - MessageTypeID: "message#2357bf25", + MessageTypeID: "message#94345242", MessageServiceTypeID: "messageService#2b085862", MessageMediaEmptyTypeID: "messageMediaEmpty#3ded6320", MessageMediaPhotoTypeID: "messageMediaPhoto#695150d7", @@ -398,6 +398,8 @@ func TypesMap() map[uint32]string { UpdateBotEditBusinessMessageTypeID: "updateBotEditBusinessMessage#7df587c", UpdateBotDeleteBusinessMessageTypeID: "updateBotDeleteBusinessMessage#a02a982e", UpdateNewStoryReactionTypeID: "updateNewStoryReaction#1824e40b", + UpdateBroadcastRevenueTransactionsTypeID: "updateBroadcastRevenueTransactions#dfd961f5", + UpdateStarsBalanceTypeID: "updateStarsBalance#fb85198", UpdatesStateTypeID: "updates.state#a56c2a3e", UpdatesDifferenceEmptyTypeID: "updates.differenceEmpty#5d75a138", UpdatesDifferenceTypeID: "updates.difference#f49ca0", @@ -600,7 +602,7 @@ func TypesMap() map[uint32]string { MessageEntityBankCardTypeID: "messageEntityBankCard#761e6af4", MessageEntitySpoilerTypeID: "messageEntitySpoiler#32ca960f", MessageEntityCustomEmojiTypeID: "messageEntityCustomEmoji#c8cf05f8", - MessageEntityBlockquoteTypeID: "messageEntityBlockquote#20df5d0", + MessageEntityBlockquoteTypeID: "messageEntityBlockquote#f1ccaaac", InputChannelEmptyTypeID: "inputChannelEmpty#ee8c1e86", InputChannelTypeID: "inputChannel#f35aec28", InputChannelFromMessageTypeID: "inputChannelFromMessage#5b934f9d", @@ -668,7 +670,7 @@ func TypesMap() map[uint32]string { AuthSentCodeTypeEmailCodeTypeID: "auth.sentCodeTypeEmailCode#f450f59b", AuthSentCodeTypeSetUpEmailRequiredTypeID: "auth.sentCodeTypeSetUpEmailRequired#a5491dea", AuthSentCodeTypeFragmentSMSTypeID: "auth.sentCodeTypeFragmentSms#d9565c39", - AuthSentCodeTypeFirebaseSMSTypeID: "auth.sentCodeTypeFirebaseSms#e57b1432", + AuthSentCodeTypeFirebaseSMSTypeID: "auth.sentCodeTypeFirebaseSms#13c90f17", AuthSentCodeTypeSMSWordTypeID: "auth.sentCodeTypeSmsWord#a416ac81", AuthSentCodeTypeSMSPhraseTypeID: "auth.sentCodeTypeSmsPhrase#b37794af", MessagesBotCallbackAnswerTypeID: "messages.botCallbackAnswer#36585ea4", @@ -775,10 +777,12 @@ func TypesMap() map[uint32]string { InputWebFileAudioAlbumThumbLocationTypeID: "inputWebFileAudioAlbumThumbLocation#f46fe924", UploadWebFileTypeID: "upload.webFile#21e753bc", PaymentsPaymentFormTypeID: "payments.paymentForm#a0058751", + PaymentsPaymentFormStarsTypeID: "payments.paymentFormStars#7bf6b15c", PaymentsValidatedRequestedInfoTypeID: "payments.validatedRequestedInfo#d1451883", PaymentsPaymentResultTypeID: "payments.paymentResult#4e5f810d", PaymentsPaymentVerificationNeededTypeID: "payments.paymentVerificationNeeded#d8411139", PaymentsPaymentReceiptTypeID: "payments.paymentReceipt#70c4fe03", + PaymentsPaymentReceiptStarsTypeID: "payments.paymentReceiptStars#dabbf83a", PaymentsSavedInfoTypeID: "payments.savedInfo#fb8fe43c", InputPaymentCredentialsSavedTypeID: "inputPaymentCredentialsSaved#c10eb2cf", InputPaymentCredentialsTypeID: "inputPaymentCredentials#3417d728", @@ -1132,6 +1136,7 @@ func TypesMap() map[uint32]string { InputInvoiceMessageTypeID: "inputInvoiceMessage#c5b56859", InputInvoiceSlugTypeID: "inputInvoiceSlug#c326caef", InputInvoicePremiumGiftCodeTypeID: "inputInvoicePremiumGiftCode#98986c0d", + InputInvoiceStarsTypeID: "inputInvoiceStars#1da33ad8", PaymentsExportedInvoiceTypeID: "payments.exportedInvoice#aed0cbd9", MessagesTranscribedAudioTypeID: "messages.transcribedAudio#cfb9d957", HelpPremiumPromoTypeID: "help.premiumPromo#5334759c", @@ -1139,6 +1144,7 @@ func TypesMap() map[uint32]string { InputStorePaymentGiftPremiumTypeID: "inputStorePaymentGiftPremium#616f7fe8", InputStorePaymentPremiumGiftCodeTypeID: "inputStorePaymentPremiumGiftCode#a3805f3f", InputStorePaymentPremiumGiveawayTypeID: "inputStorePaymentPremiumGiveaway#160544ca", + InputStorePaymentStarsTypeID: "inputStorePaymentStars#4f0ee8df", PremiumGiftOptionTypeID: "premiumGiftOption#74c34319", PaymentFormMethodTypeID: "paymentFormMethod#88f8f21b", EmojiStatusEmptyTypeID: "emojiStatusEmpty#2de11aae", @@ -1331,6 +1337,19 @@ func TypesMap() map[uint32]string { ReactionNotificationsFromAllTypeID: "reactionNotificationsFromAll#4b9e22a0", ReactionsNotifySettingsTypeID: "reactionsNotifySettings#56e34970", BroadcastRevenueBalancesTypeID: "broadcastRevenueBalances#8438f1c6", + AvailableEffectTypeID: "availableEffect#93c3e27e", + MessagesAvailableEffectsNotModifiedTypeID: "messages.availableEffectsNotModified#d1ed9a5b", + MessagesAvailableEffectsTypeID: "messages.availableEffects#bddb616e", + FactCheckTypeID: "factCheck#b89bfccf", + StarsTransactionPeerUnsupportedTypeID: "starsTransactionPeerUnsupported#95f2bfe4", + StarsTransactionPeerAppStoreTypeID: "starsTransactionPeerAppStore#b457b375", + StarsTransactionPeerPlayMarketTypeID: "starsTransactionPeerPlayMarket#7b560a0b", + StarsTransactionPeerPremiumBotTypeID: "starsTransactionPeerPremiumBot#250dbaf8", + StarsTransactionPeerFragmentTypeID: "starsTransactionPeerFragment#e92fd902", + StarsTransactionPeerTypeID: "starsTransactionPeer#d80da15d", + StarsTopupOptionTypeID: "starsTopupOption#bd915c0", + StarsTransactionTypeID: "starsTransaction#cc7079b2", + PaymentsStarsStatusTypeID: "payments.starsStatus#8cf4ee60", InvokeAfterMsgRequestTypeID: "invokeAfterMsg#cb9f372d", InvokeAfterMsgsRequestTypeID: "invokeAfterMsgs#3dc4b4f0", InitConnectionRequestTypeID: "initConnection#c1cd5ea9", @@ -1339,6 +1358,8 @@ func TypesMap() map[uint32]string { InvokeWithMessagesRangeRequestTypeID: "invokeWithMessagesRange#365275f2", InvokeWithTakeoutRequestTypeID: "invokeWithTakeout#aca9fd2e", InvokeWithBusinessConnectionRequestTypeID: "invokeWithBusinessConnection#dd289f8e", + InvokeWithGooglePlayIntegrityRequestTypeID: "invokeWithGooglePlayIntegrity#1df92984", + InvokeWithApnsSecretRequestTypeID: "invokeWithApnsSecret#dae54f8", AuthSendCodeRequestTypeID: "auth.sendCode#a677244f", AuthSignUpRequestTypeID: "auth.signUp#aac7b717", AuthSignInRequestTypeID: "auth.signIn#8d52a951", @@ -1351,7 +1372,7 @@ func TypesMap() map[uint32]string { AuthCheckPasswordRequestTypeID: "auth.checkPassword#d18b4d16", AuthRequestPasswordRecoveryRequestTypeID: "auth.requestPasswordRecovery#d897bc66", AuthRecoverPasswordRequestTypeID: "auth.recoverPassword#37096c70", - AuthResendCodeRequestTypeID: "auth.resendCode#3ef1a9bf", + AuthResendCodeRequestTypeID: "auth.resendCode#cae47523", AuthCancelCodeRequestTypeID: "auth.cancelCode#1f040578", AuthDropTempAuthKeysRequestTypeID: "auth.dropTempAuthKeys#8e48a188", AuthExportLoginTokenRequestTypeID: "auth.exportLoginToken#b7e085fe", @@ -1359,7 +1380,7 @@ func TypesMap() map[uint32]string { AuthAcceptLoginTokenRequestTypeID: "auth.acceptLoginToken#e894ad4d", AuthCheckRecoveryPasswordRequestTypeID: "auth.checkRecoveryPassword#d36bf79", AuthImportWebTokenAuthorizationRequestTypeID: "auth.importWebTokenAuthorization#2db873a9", - AuthRequestFirebaseSMSRequestTypeID: "auth.requestFirebaseSms#89464b50", + AuthRequestFirebaseSMSRequestTypeID: "auth.requestFirebaseSms#8e39261e", AuthResetLoginEmailRequestTypeID: "auth.resetLoginEmail#7e960193", AuthReportMissingCodeRequestTypeID: "auth.reportMissingCode#cb9deff6", AccountRegisterDeviceRequestTypeID: "account.registerDevice#ec86017a", @@ -1513,8 +1534,8 @@ func TypesMap() map[uint32]string { MessagesDeleteMessagesRequestTypeID: "messages.deleteMessages#e58e95d2", MessagesReceivedMessagesRequestTypeID: "messages.receivedMessages#5a954c0", MessagesSetTypingRequestTypeID: "messages.setTyping#58943ee2", - MessagesSendMessageRequestTypeID: "messages.sendMessage#dff8042c", - MessagesSendMediaRequestTypeID: "messages.sendMedia#7bd66041", + MessagesSendMessageRequestTypeID: "messages.sendMessage#983f9745", + MessagesSendMediaRequestTypeID: "messages.sendMedia#7852834e", MessagesForwardMessagesRequestTypeID: "messages.forwardMessages#d5039208", MessagesReportSpamRequestTypeID: "messages.reportSpam#cf1592db", MessagesGetPeerSettingsRequestTypeID: "messages.getPeerSettings#efd9a6a2", @@ -1593,7 +1614,7 @@ func TypesMap() map[uint32]string { MessagesGetUnreadMentionsRequestTypeID: "messages.getUnreadMentions#f107e790", MessagesReadMentionsRequestTypeID: "messages.readMentions#36e5bf4d", MessagesGetRecentLocationsRequestTypeID: "messages.getRecentLocations#702a40e0", - MessagesSendMultiMediaRequestTypeID: "messages.sendMultiMedia#c964709", + MessagesSendMultiMediaRequestTypeID: "messages.sendMultiMedia#37b74355", MessagesUploadEncryptedFileRequestTypeID: "messages.uploadEncryptedFile#5057c497", MessagesSearchStickerSetsRequestTypeID: "messages.searchStickerSets#35705b8a", MessagesGetSplitRangesRequestTypeID: "messages.getSplitRanges#1cff7e08", @@ -1713,6 +1734,10 @@ func TypesMap() map[uint32]string { MessagesToggleDialogFilterTagsRequestTypeID: "messages.toggleDialogFilterTags#fd2dda49", MessagesGetMyStickersRequestTypeID: "messages.getMyStickers#d0b5e1fc", MessagesGetEmojiStickerGroupsRequestTypeID: "messages.getEmojiStickerGroups#1dd840f5", + MessagesGetAvailableEffectsRequestTypeID: "messages.getAvailableEffects#dea20a39", + MessagesEditFactCheckRequestTypeID: "messages.editFactCheck#589ee75", + MessagesDeleteFactCheckRequestTypeID: "messages.deleteFactCheck#d1da940c", + MessagesGetFactCheckRequestTypeID: "messages.getFactCheck#b9cdc5ee", UpdatesGetStateRequestTypeID: "updates.getState#edd4882a", UpdatesGetDifferenceRequestTypeID: "updates.getDifference#19c2f763", UpdatesGetChannelDifferenceRequestTypeID: "updates.getChannelDifference#3173d78", @@ -1818,6 +1843,7 @@ func TypesMap() map[uint32]string { ChannelsSetEmojiStickersRequestTypeID: "channels.setEmojiStickers#3cd930b7", ChannelsReportSponsoredMessageRequestTypeID: "channels.reportSponsoredMessage#af8ff6b9", ChannelsRestrictSponsoredMessagesRequestTypeID: "channels.restrictSponsoredMessages#9ae91519", + ChannelsSearchPostsRequestTypeID: "channels.searchPosts#d19f987b", BotsSendCustomRequestRequestTypeID: "bots.sendCustomRequest#aa2769ed", BotsAnswerWebhookJSONQueryRequestTypeID: "bots.answerWebhookJSONQuery#e6213f4d", BotsSetBotCommandsRequestTypeID: "bots.setBotCommands#517165a", @@ -1850,6 +1876,11 @@ func TypesMap() map[uint32]string { PaymentsApplyGiftCodeRequestTypeID: "payments.applyGiftCode#f6e26854", PaymentsGetGiveawayInfoRequestTypeID: "payments.getGiveawayInfo#f4239425", PaymentsLaunchPrepaidGiveawayRequestTypeID: "payments.launchPrepaidGiveaway#5ff58f20", + PaymentsGetStarsTopupOptionsRequestTypeID: "payments.getStarsTopupOptions#c00ec7d3", + PaymentsGetStarsStatusRequestTypeID: "payments.getStarsStatus#104fcfa7", + PaymentsGetStarsTransactionsRequestTypeID: "payments.getStarsTransactions#673ac2f9", + PaymentsSendStarsFormRequestTypeID: "payments.sendStarsForm#2bb731d", + PaymentsRefundStarsChargeRequestTypeID: "payments.refundStarsCharge#25ae8f4a", StickersCreateStickerSetRequestTypeID: "stickers.createStickerSet#9021ab67", StickersRemoveStickerFromSetRequestTypeID: "stickers.removeStickerFromSet#f7760f51", StickersChangeStickerPositionRequestTypeID: "stickers.changeStickerPosition#ffb6d4ca", @@ -2337,6 +2368,8 @@ func NamesMap() map[string]uint32 { "updateBotEditBusinessMessage": UpdateBotEditBusinessMessageTypeID, "updateBotDeleteBusinessMessage": UpdateBotDeleteBusinessMessageTypeID, "updateNewStoryReaction": UpdateNewStoryReactionTypeID, + "updateBroadcastRevenueTransactions": UpdateBroadcastRevenueTransactionsTypeID, + "updateStarsBalance": UpdateStarsBalanceTypeID, "updates.state": UpdatesStateTypeID, "updates.differenceEmpty": UpdatesDifferenceEmptyTypeID, "updates.difference": UpdatesDifferenceTypeID, @@ -2714,10 +2747,12 @@ func NamesMap() map[string]uint32 { "inputWebFileAudioAlbumThumbLocation": InputWebFileAudioAlbumThumbLocationTypeID, "upload.webFile": UploadWebFileTypeID, "payments.paymentForm": PaymentsPaymentFormTypeID, + "payments.paymentFormStars": PaymentsPaymentFormStarsTypeID, "payments.validatedRequestedInfo": PaymentsValidatedRequestedInfoTypeID, "payments.paymentResult": PaymentsPaymentResultTypeID, "payments.paymentVerificationNeeded": PaymentsPaymentVerificationNeededTypeID, "payments.paymentReceipt": PaymentsPaymentReceiptTypeID, + "payments.paymentReceiptStars": PaymentsPaymentReceiptStarsTypeID, "payments.savedInfo": PaymentsSavedInfoTypeID, "inputPaymentCredentialsSaved": InputPaymentCredentialsSavedTypeID, "inputPaymentCredentials": InputPaymentCredentialsTypeID, @@ -3071,6 +3106,7 @@ func NamesMap() map[string]uint32 { "inputInvoiceMessage": InputInvoiceMessageTypeID, "inputInvoiceSlug": InputInvoiceSlugTypeID, "inputInvoicePremiumGiftCode": InputInvoicePremiumGiftCodeTypeID, + "inputInvoiceStars": InputInvoiceStarsTypeID, "payments.exportedInvoice": PaymentsExportedInvoiceTypeID, "messages.transcribedAudio": MessagesTranscribedAudioTypeID, "help.premiumPromo": HelpPremiumPromoTypeID, @@ -3078,6 +3114,7 @@ func NamesMap() map[string]uint32 { "inputStorePaymentGiftPremium": InputStorePaymentGiftPremiumTypeID, "inputStorePaymentPremiumGiftCode": InputStorePaymentPremiumGiftCodeTypeID, "inputStorePaymentPremiumGiveaway": InputStorePaymentPremiumGiveawayTypeID, + "inputStorePaymentStars": InputStorePaymentStarsTypeID, "premiumGiftOption": PremiumGiftOptionTypeID, "paymentFormMethod": PaymentFormMethodTypeID, "emojiStatusEmpty": EmojiStatusEmptyTypeID, @@ -3270,6 +3307,19 @@ func NamesMap() map[string]uint32 { "reactionNotificationsFromAll": ReactionNotificationsFromAllTypeID, "reactionsNotifySettings": ReactionsNotifySettingsTypeID, "broadcastRevenueBalances": BroadcastRevenueBalancesTypeID, + "availableEffect": AvailableEffectTypeID, + "messages.availableEffectsNotModified": MessagesAvailableEffectsNotModifiedTypeID, + "messages.availableEffects": MessagesAvailableEffectsTypeID, + "factCheck": FactCheckTypeID, + "starsTransactionPeerUnsupported": StarsTransactionPeerUnsupportedTypeID, + "starsTransactionPeerAppStore": StarsTransactionPeerAppStoreTypeID, + "starsTransactionPeerPlayMarket": StarsTransactionPeerPlayMarketTypeID, + "starsTransactionPeerPremiumBot": StarsTransactionPeerPremiumBotTypeID, + "starsTransactionPeerFragment": StarsTransactionPeerFragmentTypeID, + "starsTransactionPeer": StarsTransactionPeerTypeID, + "starsTopupOption": StarsTopupOptionTypeID, + "starsTransaction": StarsTransactionTypeID, + "payments.starsStatus": PaymentsStarsStatusTypeID, "invokeAfterMsg": InvokeAfterMsgRequestTypeID, "invokeAfterMsgs": InvokeAfterMsgsRequestTypeID, "initConnection": InitConnectionRequestTypeID, @@ -3278,6 +3328,8 @@ func NamesMap() map[string]uint32 { "invokeWithMessagesRange": InvokeWithMessagesRangeRequestTypeID, "invokeWithTakeout": InvokeWithTakeoutRequestTypeID, "invokeWithBusinessConnection": InvokeWithBusinessConnectionRequestTypeID, + "invokeWithGooglePlayIntegrity": InvokeWithGooglePlayIntegrityRequestTypeID, + "invokeWithApnsSecret": InvokeWithApnsSecretRequestTypeID, "auth.sendCode": AuthSendCodeRequestTypeID, "auth.signUp": AuthSignUpRequestTypeID, "auth.signIn": AuthSignInRequestTypeID, @@ -3652,6 +3704,10 @@ func NamesMap() map[string]uint32 { "messages.toggleDialogFilterTags": MessagesToggleDialogFilterTagsRequestTypeID, "messages.getMyStickers": MessagesGetMyStickersRequestTypeID, "messages.getEmojiStickerGroups": MessagesGetEmojiStickerGroupsRequestTypeID, + "messages.getAvailableEffects": MessagesGetAvailableEffectsRequestTypeID, + "messages.editFactCheck": MessagesEditFactCheckRequestTypeID, + "messages.deleteFactCheck": MessagesDeleteFactCheckRequestTypeID, + "messages.getFactCheck": MessagesGetFactCheckRequestTypeID, "updates.getState": UpdatesGetStateRequestTypeID, "updates.getDifference": UpdatesGetDifferenceRequestTypeID, "updates.getChannelDifference": UpdatesGetChannelDifferenceRequestTypeID, @@ -3757,6 +3813,7 @@ func NamesMap() map[string]uint32 { "channels.setEmojiStickers": ChannelsSetEmojiStickersRequestTypeID, "channels.reportSponsoredMessage": ChannelsReportSponsoredMessageRequestTypeID, "channels.restrictSponsoredMessages": ChannelsRestrictSponsoredMessagesRequestTypeID, + "channels.searchPosts": ChannelsSearchPostsRequestTypeID, "bots.sendCustomRequest": BotsSendCustomRequestRequestTypeID, "bots.answerWebhookJSONQuery": BotsAnswerWebhookJSONQueryRequestTypeID, "bots.setBotCommands": BotsSetBotCommandsRequestTypeID, @@ -3789,6 +3846,11 @@ func NamesMap() map[string]uint32 { "payments.applyGiftCode": PaymentsApplyGiftCodeRequestTypeID, "payments.getGiveawayInfo": PaymentsGetGiveawayInfoRequestTypeID, "payments.launchPrepaidGiveaway": PaymentsLaunchPrepaidGiveawayRequestTypeID, + "payments.getStarsTopupOptions": PaymentsGetStarsTopupOptionsRequestTypeID, + "payments.getStarsStatus": PaymentsGetStarsStatusRequestTypeID, + "payments.getStarsTransactions": PaymentsGetStarsTransactionsRequestTypeID, + "payments.sendStarsForm": PaymentsSendStarsFormRequestTypeID, + "payments.refundStarsCharge": PaymentsRefundStarsChargeRequestTypeID, "stickers.createStickerSet": StickersCreateStickerSetRequestTypeID, "stickers.removeStickerFromSet": StickersRemoveStickerFromSetRequestTypeID, "stickers.changeStickerPosition": StickersChangeStickerPositionRequestTypeID, @@ -4276,6 +4338,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UpdateBotEditBusinessMessageTypeID: func() bin.Object { return &UpdateBotEditBusinessMessage{} }, UpdateBotDeleteBusinessMessageTypeID: func() bin.Object { return &UpdateBotDeleteBusinessMessage{} }, UpdateNewStoryReactionTypeID: func() bin.Object { return &UpdateNewStoryReaction{} }, + UpdateBroadcastRevenueTransactionsTypeID: func() bin.Object { return &UpdateBroadcastRevenueTransactions{} }, + UpdateStarsBalanceTypeID: func() bin.Object { return &UpdateStarsBalance{} }, UpdatesStateTypeID: func() bin.Object { return &UpdatesState{} }, UpdatesDifferenceEmptyTypeID: func() bin.Object { return &UpdatesDifferenceEmpty{} }, UpdatesDifferenceTypeID: func() bin.Object { return &UpdatesDifference{} }, @@ -4653,10 +4717,12 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputWebFileAudioAlbumThumbLocationTypeID: func() bin.Object { return &InputWebFileAudioAlbumThumbLocation{} }, UploadWebFileTypeID: func() bin.Object { return &UploadWebFile{} }, PaymentsPaymentFormTypeID: func() bin.Object { return &PaymentsPaymentForm{} }, + PaymentsPaymentFormStarsTypeID: func() bin.Object { return &PaymentsPaymentFormStars{} }, PaymentsValidatedRequestedInfoTypeID: func() bin.Object { return &PaymentsValidatedRequestedInfo{} }, PaymentsPaymentResultTypeID: func() bin.Object { return &PaymentsPaymentResult{} }, PaymentsPaymentVerificationNeededTypeID: func() bin.Object { return &PaymentsPaymentVerificationNeeded{} }, PaymentsPaymentReceiptTypeID: func() bin.Object { return &PaymentsPaymentReceipt{} }, + PaymentsPaymentReceiptStarsTypeID: func() bin.Object { return &PaymentsPaymentReceiptStars{} }, PaymentsSavedInfoTypeID: func() bin.Object { return &PaymentsSavedInfo{} }, InputPaymentCredentialsSavedTypeID: func() bin.Object { return &InputPaymentCredentialsSaved{} }, InputPaymentCredentialsTypeID: func() bin.Object { return &InputPaymentCredentials{} }, @@ -5010,6 +5076,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputInvoiceMessageTypeID: func() bin.Object { return &InputInvoiceMessage{} }, InputInvoiceSlugTypeID: func() bin.Object { return &InputInvoiceSlug{} }, InputInvoicePremiumGiftCodeTypeID: func() bin.Object { return &InputInvoicePremiumGiftCode{} }, + InputInvoiceStarsTypeID: func() bin.Object { return &InputInvoiceStars{} }, PaymentsExportedInvoiceTypeID: func() bin.Object { return &PaymentsExportedInvoice{} }, MessagesTranscribedAudioTypeID: func() bin.Object { return &MessagesTranscribedAudio{} }, HelpPremiumPromoTypeID: func() bin.Object { return &HelpPremiumPromo{} }, @@ -5017,6 +5084,7 @@ 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{} }, PremiumGiftOptionTypeID: func() bin.Object { return &PremiumGiftOption{} }, PaymentFormMethodTypeID: func() bin.Object { return &PaymentFormMethod{} }, EmojiStatusEmptyTypeID: func() bin.Object { return &EmojiStatusEmpty{} }, @@ -5209,6 +5277,19 @@ func TypesConstructorMap() map[uint32]func() bin.Object { ReactionNotificationsFromAllTypeID: func() bin.Object { return &ReactionNotificationsFromAll{} }, ReactionsNotifySettingsTypeID: func() bin.Object { return &ReactionsNotifySettings{} }, BroadcastRevenueBalancesTypeID: func() bin.Object { return &BroadcastRevenueBalances{} }, + AvailableEffectTypeID: func() bin.Object { return &AvailableEffect{} }, + MessagesAvailableEffectsNotModifiedTypeID: func() bin.Object { return &MessagesAvailableEffectsNotModified{} }, + MessagesAvailableEffectsTypeID: func() bin.Object { return &MessagesAvailableEffects{} }, + FactCheckTypeID: func() bin.Object { return &FactCheck{} }, + StarsTransactionPeerUnsupportedTypeID: func() bin.Object { return &StarsTransactionPeerUnsupported{} }, + StarsTransactionPeerAppStoreTypeID: func() bin.Object { return &StarsTransactionPeerAppStore{} }, + StarsTransactionPeerPlayMarketTypeID: func() bin.Object { return &StarsTransactionPeerPlayMarket{} }, + StarsTransactionPeerPremiumBotTypeID: func() bin.Object { return &StarsTransactionPeerPremiumBot{} }, + StarsTransactionPeerFragmentTypeID: func() bin.Object { return &StarsTransactionPeerFragment{} }, + StarsTransactionPeerTypeID: func() bin.Object { return &StarsTransactionPeer{} }, + StarsTopupOptionTypeID: func() bin.Object { return &StarsTopupOption{} }, + StarsTransactionTypeID: func() bin.Object { return &StarsTransaction{} }, + PaymentsStarsStatusTypeID: func() bin.Object { return &PaymentsStarsStatus{} }, InvokeAfterMsgRequestTypeID: func() bin.Object { return &InvokeAfterMsgRequest{} }, InvokeAfterMsgsRequestTypeID: func() bin.Object { return &InvokeAfterMsgsRequest{} }, InitConnectionRequestTypeID: func() bin.Object { return &InitConnectionRequest{} }, @@ -5217,6 +5298,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InvokeWithMessagesRangeRequestTypeID: func() bin.Object { return &InvokeWithMessagesRangeRequest{} }, InvokeWithTakeoutRequestTypeID: func() bin.Object { return &InvokeWithTakeoutRequest{} }, InvokeWithBusinessConnectionRequestTypeID: func() bin.Object { return &InvokeWithBusinessConnectionRequest{} }, + InvokeWithGooglePlayIntegrityRequestTypeID: func() bin.Object { return &InvokeWithGooglePlayIntegrityRequest{} }, + InvokeWithApnsSecretRequestTypeID: func() bin.Object { return &InvokeWithApnsSecretRequest{} }, AuthSendCodeRequestTypeID: func() bin.Object { return &AuthSendCodeRequest{} }, AuthSignUpRequestTypeID: func() bin.Object { return &AuthSignUpRequest{} }, AuthSignInRequestTypeID: func() bin.Object { return &AuthSignInRequest{} }, @@ -5591,6 +5674,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessagesToggleDialogFilterTagsRequestTypeID: func() bin.Object { return &MessagesToggleDialogFilterTagsRequest{} }, MessagesGetMyStickersRequestTypeID: func() bin.Object { return &MessagesGetMyStickersRequest{} }, MessagesGetEmojiStickerGroupsRequestTypeID: func() bin.Object { return &MessagesGetEmojiStickerGroupsRequest{} }, + MessagesGetAvailableEffectsRequestTypeID: func() bin.Object { return &MessagesGetAvailableEffectsRequest{} }, + MessagesEditFactCheckRequestTypeID: func() bin.Object { return &MessagesEditFactCheckRequest{} }, + MessagesDeleteFactCheckRequestTypeID: func() bin.Object { return &MessagesDeleteFactCheckRequest{} }, + MessagesGetFactCheckRequestTypeID: func() bin.Object { return &MessagesGetFactCheckRequest{} }, UpdatesGetStateRequestTypeID: func() bin.Object { return &UpdatesGetStateRequest{} }, UpdatesGetDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetDifferenceRequest{} }, UpdatesGetChannelDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetChannelDifferenceRequest{} }, @@ -5696,6 +5783,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { ChannelsSetEmojiStickersRequestTypeID: func() bin.Object { return &ChannelsSetEmojiStickersRequest{} }, ChannelsReportSponsoredMessageRequestTypeID: func() bin.Object { return &ChannelsReportSponsoredMessageRequest{} }, ChannelsRestrictSponsoredMessagesRequestTypeID: func() bin.Object { return &ChannelsRestrictSponsoredMessagesRequest{} }, + ChannelsSearchPostsRequestTypeID: func() bin.Object { return &ChannelsSearchPostsRequest{} }, BotsSendCustomRequestRequestTypeID: func() bin.Object { return &BotsSendCustomRequestRequest{} }, BotsAnswerWebhookJSONQueryRequestTypeID: func() bin.Object { return &BotsAnswerWebhookJSONQueryRequest{} }, BotsSetBotCommandsRequestTypeID: func() bin.Object { return &BotsSetBotCommandsRequest{} }, @@ -5728,6 +5816,11 @@ func TypesConstructorMap() map[uint32]func() bin.Object { PaymentsApplyGiftCodeRequestTypeID: func() bin.Object { return &PaymentsApplyGiftCodeRequest{} }, PaymentsGetGiveawayInfoRequestTypeID: func() bin.Object { return &PaymentsGetGiveawayInfoRequest{} }, PaymentsLaunchPrepaidGiveawayRequestTypeID: func() bin.Object { return &PaymentsLaunchPrepaidGiveawayRequest{} }, + PaymentsGetStarsTopupOptionsRequestTypeID: func() bin.Object { return &PaymentsGetStarsTopupOptionsRequest{} }, + PaymentsGetStarsStatusRequestTypeID: func() bin.Object { return &PaymentsGetStarsStatusRequest{} }, + PaymentsGetStarsTransactionsRequestTypeID: func() bin.Object { return &PaymentsGetStarsTransactionsRequest{} }, + PaymentsSendStarsFormRequestTypeID: func() bin.Object { return &PaymentsSendStarsFormRequest{} }, + PaymentsRefundStarsChargeRequestTypeID: func() bin.Object { return &PaymentsRefundStarsChargeRequest{} }, StickersCreateStickerSetRequestTypeID: func() bin.Object { return &StickersCreateStickerSetRequest{} }, StickersRemoveStickerFromSetRequestTypeID: func() bin.Object { return &StickersRemoveStickerFromSetRequest{} }, StickersChangeStickerPositionRequestTypeID: func() bin.Object { return &StickersChangeStickerPositionRequest{} }, @@ -6347,6 +6440,7 @@ func ClassConstructorsMap() map[string][]uint32 { InputInvoiceMessageTypeID, InputInvoiceSlugTypeID, InputInvoicePremiumGiftCodeTypeID, + InputInvoiceStarsTypeID, }, InputMediaClassName: { InputMediaEmptyTypeID, @@ -6458,6 +6552,7 @@ func ClassConstructorsMap() map[string][]uint32 { InputStorePaymentGiftPremiumTypeID, InputStorePaymentPremiumGiftCodeTypeID, InputStorePaymentPremiumGiveawayTypeID, + InputStorePaymentStarsTypeID, }, InputThemeClassName: { InputThemeTypeID, @@ -6627,6 +6722,10 @@ func ClassConstructorsMap() map[string][]uint32 { MessagesAllStickersNotModifiedTypeID, MessagesAllStickersTypeID, }, + MessagesAvailableEffectsClassName: { + MessagesAvailableEffectsNotModifiedTypeID, + MessagesAvailableEffectsTypeID, + }, MessagesAvailableReactionsClassName: { MessagesAvailableReactionsNotModifiedTypeID, MessagesAvailableReactionsTypeID, @@ -6794,6 +6893,14 @@ func ClassConstructorsMap() map[string][]uint32 { PaymentsGiveawayInfoTypeID, PaymentsGiveawayInfoResultsTypeID, }, + PaymentsPaymentFormClassName: { + PaymentsPaymentFormTypeID, + PaymentsPaymentFormStarsTypeID, + }, + PaymentsPaymentReceiptClassName: { + PaymentsPaymentReceiptTypeID, + PaymentsPaymentReceiptStarsTypeID, + }, PaymentsPaymentResultClassName: { PaymentsPaymentResultTypeID, PaymentsPaymentVerificationNeededTypeID, @@ -6999,6 +7106,14 @@ func ClassConstructorsMap() map[string][]uint32 { SendMessageEmojiInteractionTypeID, SendMessageEmojiInteractionSeenTypeID, }, + StarsTransactionPeerClassName: { + StarsTransactionPeerUnsupportedTypeID, + StarsTransactionPeerAppStoreTypeID, + StarsTransactionPeerPlayMarketTypeID, + StarsTransactionPeerPremiumBotTypeID, + StarsTransactionPeerFragmentTypeID, + StarsTransactionPeerTypeID, + }, StatsGraphClassName: { StatsGraphAsyncTypeID, StatsGraphErrorTypeID, @@ -7192,6 +7307,8 @@ func ClassConstructorsMap() map[string][]uint32 { UpdateBotEditBusinessMessageTypeID, UpdateBotDeleteBusinessMessageTypeID, UpdateNewStoryReactionTypeID, + UpdateBroadcastRevenueTransactionsTypeID, + UpdateStarsBalanceTypeID, }, UpdatesChannelDifferenceClassName: { UpdatesChannelDifferenceEmptyTypeID, diff --git a/tg/tl_server_gen.go b/tg/tl_server_gen.go index 82e7cb9a2f..0c1176b1f1 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -6907,6 +6907,74 @@ func (s *ServerDispatcher) OnMessagesGetEmojiStickerGroups(f func(ctx context.Co s.handlers[MessagesGetEmojiStickerGroupsRequestTypeID] = handler } +func (s *ServerDispatcher) OnMessagesGetAvailableEffects(f func(ctx context.Context, hash int) (MessagesAvailableEffectsClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesGetAvailableEffectsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Hash) + if err != nil { + return nil, err + } + return &MessagesAvailableEffectsBox{AvailableEffects: response}, nil + } + + s.handlers[MessagesGetAvailableEffectsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesEditFactCheck(f func(ctx context.Context, request *MessagesEditFactCheckRequest) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesEditFactCheckRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &UpdatesBox{Updates: response}, nil + } + + s.handlers[MessagesEditFactCheckRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesDeleteFactCheck(f func(ctx context.Context, request *MessagesDeleteFactCheckRequest) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesDeleteFactCheckRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &UpdatesBox{Updates: response}, nil + } + + s.handlers[MessagesDeleteFactCheckRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesGetFactCheck(f func(ctx context.Context, request *MessagesGetFactCheckRequest) ([]FactCheck, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesGetFactCheckRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &FactCheckVector{Elems: response}, nil + } + + s.handlers[MessagesGetFactCheckRequestTypeID] = 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 @@ -8780,6 +8848,23 @@ func (s *ServerDispatcher) OnChannelsRestrictSponsoredMessages(f func(ctx contex s.handlers[ChannelsRestrictSponsoredMessagesRequestTypeID] = handler } +func (s *ServerDispatcher) OnChannelsSearchPosts(f func(ctx context.Context, request *ChannelsSearchPostsRequest) (MessagesMessagesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request ChannelsSearchPostsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &MessagesMessagesBox{Messages: response}, nil + } + + s.handlers[ChannelsSearchPostsRequestTypeID] = handler +} + func (s *ServerDispatcher) OnBotsSendCustomRequest(f func(ctx context.Context, request *BotsSendCustomRequestRequest) (*DataJSON, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request BotsSendCustomRequestRequest @@ -9092,7 +9177,7 @@ func (s *ServerDispatcher) OnBotsInvokeWebViewCustomMethod(f func(ctx context.Co s.handlers[BotsInvokeWebViewCustomMethodRequestTypeID] = handler } -func (s *ServerDispatcher) OnPaymentsGetPaymentForm(f func(ctx context.Context, request *PaymentsGetPaymentFormRequest) (*PaymentsPaymentForm, error)) { +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 if err := request.Decode(b); err != nil { @@ -9103,13 +9188,13 @@ func (s *ServerDispatcher) OnPaymentsGetPaymentForm(f func(ctx context.Context, if err != nil { return nil, err } - return response, nil + return &PaymentsPaymentFormBox{PaymentForm: response}, nil } s.handlers[PaymentsGetPaymentFormRequestTypeID] = handler } -func (s *ServerDispatcher) OnPaymentsGetPaymentReceipt(f func(ctx context.Context, request *PaymentsGetPaymentReceiptRequest) (*PaymentsPaymentReceipt, error)) { +func (s *ServerDispatcher) OnPaymentsGetPaymentReceipt(f func(ctx context.Context, request *PaymentsGetPaymentReceiptRequest) (PaymentsPaymentReceiptClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request PaymentsGetPaymentReceiptRequest if err := request.Decode(b); err != nil { @@ -9120,7 +9205,7 @@ func (s *ServerDispatcher) OnPaymentsGetPaymentReceipt(f func(ctx context.Contex if err != nil { return nil, err } - return response, nil + return &PaymentsPaymentReceiptBox{PaymentReceipt: response}, nil } s.handlers[PaymentsGetPaymentReceiptRequestTypeID] = handler @@ -9372,6 +9457,91 @@ func (s *ServerDispatcher) OnPaymentsLaunchPrepaidGiveaway(f func(ctx context.Co s.handlers[PaymentsLaunchPrepaidGiveawayRequestTypeID] = handler } +func (s *ServerDispatcher) OnPaymentsGetStarsTopupOptions(f func(ctx context.Context) ([]StarsTopupOption, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsGetStarsTopupOptionsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx) + if err != nil { + return nil, err + } + return &StarsTopupOptionVector{Elems: response}, nil + } + + s.handlers[PaymentsGetStarsTopupOptionsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsGetStarsStatus(f func(ctx context.Context, peer InputPeerClass) (*PaymentsStarsStatus, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsGetStarsStatusRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Peer) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[PaymentsGetStarsStatusRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsGetStarsTransactions(f func(ctx context.Context, request *PaymentsGetStarsTransactionsRequest) (*PaymentsStarsStatus, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsGetStarsTransactionsRequest + 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[PaymentsGetStarsTransactionsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsSendStarsForm(f func(ctx context.Context, request *PaymentsSendStarsFormRequest) (PaymentsPaymentResultClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsSendStarsFormRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &PaymentsPaymentResultBox{PaymentResult: response}, nil + } + + s.handlers[PaymentsSendStarsFormRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsRefundStarsCharge(f func(ctx context.Context, request *PaymentsRefundStarsChargeRequest) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsRefundStarsChargeRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &UpdatesBox{Updates: response}, nil + } + + s.handlers[PaymentsRefundStarsChargeRequestTypeID] = 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_topup_option_gen.go b/tg/tl_stars_topup_option_gen.go new file mode 100644 index 0000000000..f1317373c9 --- /dev/null +++ b/tg/tl_stars_topup_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{} +) + +// StarsTopupOption represents TL type `starsTopupOption#bd915c0`. +// +// See https://core.telegram.org/constructor/starsTopupOption for reference. +type StarsTopupOption struct { + // Flags field of StarsTopupOption. + Flags bin.Fields + // Extended field of StarsTopupOption. + Extended bool + // Stars field of StarsTopupOption. + Stars int64 + // StoreProduct field of StarsTopupOption. + // + // Use SetStoreProduct and GetStoreProduct helpers. + StoreProduct string + // Currency field of StarsTopupOption. + Currency string + // Amount field of StarsTopupOption. + Amount int64 +} + +// StarsTopupOptionTypeID is TL type id of StarsTopupOption. +const StarsTopupOptionTypeID = 0xbd915c0 + +// Ensuring interfaces in compile-time for StarsTopupOption. +var ( + _ bin.Encoder = &StarsTopupOption{} + _ bin.Decoder = &StarsTopupOption{} + _ bin.BareEncoder = &StarsTopupOption{} + _ bin.BareDecoder = &StarsTopupOption{} +) + +func (s *StarsTopupOption) 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 *StarsTopupOption) String() string { + if s == nil { + return "StarsTopupOption(nil)" + } + type Alias StarsTopupOption + return fmt.Sprintf("StarsTopupOption%+v", Alias(*s)) +} + +// FillFrom fills StarsTopupOption from given interface. +func (s *StarsTopupOption) 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 (*StarsTopupOption) TypeID() uint32 { + return StarsTopupOptionTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsTopupOption) TypeName() string { + return "starsTopupOption" +} + +// TypeInfo returns info about TL type. +func (s *StarsTopupOption) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starsTopupOption", + ID: StarsTopupOptionTypeID, + } + 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 *StarsTopupOption) SetFlags() { + if !(s.Extended == false) { + s.Flags.Set(1) + } + if !(s.StoreProduct == "") { + s.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (s *StarsTopupOption) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTopupOption#bd915c0 as nil") + } + b.PutID(StarsTopupOptionTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarsTopupOption) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTopupOption#bd915c0 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsTopupOption#bd915c0: 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 *StarsTopupOption) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTopupOption#bd915c0 to nil") + } + if err := b.ConsumeID(StarsTopupOptionTypeID); err != nil { + return fmt.Errorf("unable to decode starsTopupOption#bd915c0: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarsTopupOption) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTopupOption#bd915c0 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode starsTopupOption#bd915c0: field flags: %w", err) + } + } + s.Extended = s.Flags.Has(1) + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode starsTopupOption#bd915c0: 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 starsTopupOption#bd915c0: field store_product: %w", err) + } + s.StoreProduct = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode starsTopupOption#bd915c0: field currency: %w", err) + } + s.Currency = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode starsTopupOption#bd915c0: field amount: %w", err) + } + s.Amount = value + } + return nil +} + +// SetExtended sets value of Extended conditional field. +func (s *StarsTopupOption) 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 *StarsTopupOption) GetExtended() (value bool) { + if s == nil { + return + } + return s.Flags.Has(1) +} + +// GetStars returns value of Stars field. +func (s *StarsTopupOption) GetStars() (value int64) { + if s == nil { + return + } + return s.Stars +} + +// SetStoreProduct sets value of StoreProduct conditional field. +func (s *StarsTopupOption) 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 *StarsTopupOption) 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 *StarsTopupOption) GetCurrency() (value string) { + if s == nil { + return + } + return s.Currency +} + +// GetAmount returns value of Amount field. +func (s *StarsTopupOption) GetAmount() (value int64) { + if s == nil { + return + } + return s.Amount +} diff --git a/tg/tl_stars_topup_option_slices_gen.go b/tg/tl_stars_topup_option_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_stars_topup_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_topup_option_vector_gen.go b/tg/tl_stars_topup_option_vector_gen.go new file mode 100644 index 0000000000..35d8f7f954 --- /dev/null +++ b/tg/tl_stars_topup_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{} +) + +// StarsTopupOptionVector is a box for Vector +type StarsTopupOptionVector struct { + // Elements of Vector + Elems []StarsTopupOption +} + +// StarsTopupOptionVectorTypeID is TL type id of StarsTopupOptionVector. +const StarsTopupOptionVectorTypeID = bin.TypeVector + +// Ensuring interfaces in compile-time for StarsTopupOptionVector. +var ( + _ bin.Encoder = &StarsTopupOptionVector{} + _ bin.Decoder = &StarsTopupOptionVector{} + _ bin.BareEncoder = &StarsTopupOptionVector{} + _ bin.BareDecoder = &StarsTopupOptionVector{} +) + +func (vec *StarsTopupOptionVector) Zero() bool { + if vec == nil { + return true + } + if !(vec.Elems == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (vec *StarsTopupOptionVector) String() string { + if vec == nil { + return "StarsTopupOptionVector(nil)" + } + type Alias StarsTopupOptionVector + return fmt.Sprintf("StarsTopupOptionVector%+v", Alias(*vec)) +} + +// FillFrom fills StarsTopupOptionVector from given interface. +func (vec *StarsTopupOptionVector) FillFrom(from interface { + GetElems() (value []StarsTopupOption) +}) { + vec.Elems = from.GetElems() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsTopupOptionVector) TypeID() uint32 { + return StarsTopupOptionVectorTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsTopupOptionVector) TypeName() string { + return "" +} + +// TypeInfo returns info about TL type. +func (vec *StarsTopupOptionVector) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "", + ID: StarsTopupOptionVectorTypeID, + } + if vec == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Elems", + SchemaName: "Elems", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (vec *StarsTopupOptionVector) 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 *StarsTopupOptionVector) 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 *StarsTopupOptionVector) 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 *StarsTopupOptionVector) 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([]StarsTopupOption, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value StarsTopupOption + 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 *StarsTopupOptionVector) GetElems() (value []StarsTopupOption) { + if vec == nil { + return + } + return vec.Elems +} diff --git a/tg/tl_stars_topup_option_vector_slices_gen.go b/tg/tl_stars_topup_option_vector_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_stars_topup_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 new file mode 100644 index 0000000000..0e1f85be1f --- /dev/null +++ b/tg/tl_stars_transaction_gen.go @@ -0,0 +1,449 @@ +// 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{} +) + +// StarsTransaction represents TL type `starsTransaction#cc7079b2`. +// +// See https://core.telegram.org/constructor/starsTransaction for reference. +type StarsTransaction struct { + // Flags field of StarsTransaction. + Flags bin.Fields + // Refund field of StarsTransaction. + Refund bool + // ID field of StarsTransaction. + ID string + // Stars field of StarsTransaction. + Stars int64 + // Date field of StarsTransaction. + Date int + // Peer field of StarsTransaction. + Peer StarsTransactionPeerClass + // Title field of StarsTransaction. + // + // Use SetTitle and GetTitle helpers. + Title string + // Description field of StarsTransaction. + // + // Use SetDescription and GetDescription helpers. + Description string + // Photo field of StarsTransaction. + // + // Use SetPhoto and GetPhoto helpers. + Photo WebDocumentClass +} + +// StarsTransactionTypeID is TL type id of StarsTransaction. +const StarsTransactionTypeID = 0xcc7079b2 + +// Ensuring interfaces in compile-time for StarsTransaction. +var ( + _ bin.Encoder = &StarsTransaction{} + _ bin.Decoder = &StarsTransaction{} + _ bin.BareEncoder = &StarsTransaction{} + _ bin.BareDecoder = &StarsTransaction{} +) + +func (s *StarsTransaction) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.Refund == false) { + return false + } + if !(s.ID == "") { + return false + } + if !(s.Stars == 0) { + return false + } + if !(s.Date == 0) { + return false + } + if !(s.Peer == nil) { + return false + } + if !(s.Title == "") { + return false + } + if !(s.Description == "") { + return false + } + if !(s.Photo == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarsTransaction) String() string { + if s == nil { + return "StarsTransaction(nil)" + } + type Alias StarsTransaction + return fmt.Sprintf("StarsTransaction%+v", Alias(*s)) +} + +// FillFrom fills StarsTransaction from given interface. +func (s *StarsTransaction) FillFrom(from interface { + GetRefund() (value bool) + GetID() (value string) + GetStars() (value int64) + GetDate() (value int) + GetPeer() (value StarsTransactionPeerClass) + GetTitle() (value string, ok bool) + GetDescription() (value string, ok bool) + GetPhoto() (value WebDocumentClass, ok bool) +}) { + s.Refund = from.GetRefund() + s.ID = from.GetID() + s.Stars = from.GetStars() + s.Date = from.GetDate() + s.Peer = from.GetPeer() + if val, ok := from.GetTitle(); ok { + s.Title = val + } + + if val, ok := from.GetDescription(); ok { + s.Description = val + } + + if val, ok := from.GetPhoto(); ok { + s.Photo = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsTransaction) TypeID() uint32 { + return StarsTransactionTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsTransaction) TypeName() string { + return "starsTransaction" +} + +// TypeInfo returns info about TL type. +func (s *StarsTransaction) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starsTransaction", + ID: StarsTransactionTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Refund", + SchemaName: "refund", + Null: !s.Flags.Has(3), + }, + { + Name: "ID", + SchemaName: "id", + }, + { + Name: "Stars", + SchemaName: "stars", + }, + { + Name: "Date", + SchemaName: "date", + }, + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "Title", + SchemaName: "title", + Null: !s.Flags.Has(0), + }, + { + Name: "Description", + SchemaName: "description", + Null: !s.Flags.Has(1), + }, + { + Name: "Photo", + SchemaName: "photo", + Null: !s.Flags.Has(2), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *StarsTransaction) SetFlags() { + if !(s.Refund == false) { + s.Flags.Set(3) + } + if !(s.Title == "") { + s.Flags.Set(0) + } + if !(s.Description == "") { + s.Flags.Set(1) + } + if !(s.Photo == nil) { + s.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (s *StarsTransaction) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransaction#cc7079b2 as nil") + } + b.PutID(StarsTransactionTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarsTransaction) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransaction#cc7079b2 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsTransaction#cc7079b2: field flags: %w", err) + } + b.PutString(s.ID) + b.PutLong(s.Stars) + b.PutInt(s.Date) + if s.Peer == nil { + return fmt.Errorf("unable to encode starsTransaction#cc7079b2: field peer is nil") + } + if err := s.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsTransaction#cc7079b2: field peer: %w", err) + } + if s.Flags.Has(0) { + b.PutString(s.Title) + } + if s.Flags.Has(1) { + b.PutString(s.Description) + } + if s.Flags.Has(2) { + if s.Photo == nil { + return fmt.Errorf("unable to encode starsTransaction#cc7079b2: field photo is nil") + } + if err := s.Photo.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsTransaction#cc7079b2: field photo: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarsTransaction) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransaction#cc7079b2 to nil") + } + if err := b.ConsumeID(StarsTransactionTypeID); err != nil { + return fmt.Errorf("unable to decode starsTransaction#cc7079b2: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarsTransaction) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransaction#cc7079b2 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode starsTransaction#cc7079b2: field flags: %w", err) + } + } + s.Refund = s.Flags.Has(3) + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode starsTransaction#cc7079b2: field id: %w", err) + } + s.ID = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode starsTransaction#cc7079b2: field stars: %w", err) + } + s.Stars = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starsTransaction#cc7079b2: field date: %w", err) + } + s.Date = value + } + { + value, err := DecodeStarsTransactionPeer(b) + if err != nil { + return fmt.Errorf("unable to decode starsTransaction#cc7079b2: field peer: %w", err) + } + s.Peer = value + } + if s.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode starsTransaction#cc7079b2: field title: %w", err) + } + s.Title = value + } + if s.Flags.Has(1) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode starsTransaction#cc7079b2: field description: %w", err) + } + s.Description = value + } + if s.Flags.Has(2) { + value, err := DecodeWebDocument(b) + if err != nil { + return fmt.Errorf("unable to decode starsTransaction#cc7079b2: field photo: %w", err) + } + s.Photo = value + } + return nil +} + +// SetRefund sets value of Refund conditional field. +func (s *StarsTransaction) SetRefund(value bool) { + if value { + s.Flags.Set(3) + s.Refund = true + } else { + s.Flags.Unset(3) + s.Refund = false + } +} + +// GetRefund returns value of Refund conditional field. +func (s *StarsTransaction) GetRefund() (value bool) { + if s == nil { + return + } + return s.Flags.Has(3) +} + +// GetID returns value of ID field. +func (s *StarsTransaction) GetID() (value string) { + if s == nil { + return + } + return s.ID +} + +// GetStars returns value of Stars field. +func (s *StarsTransaction) GetStars() (value int64) { + if s == nil { + return + } + return s.Stars +} + +// GetDate returns value of Date field. +func (s *StarsTransaction) GetDate() (value int) { + if s == nil { + return + } + return s.Date +} + +// GetPeer returns value of Peer field. +func (s *StarsTransaction) GetPeer() (value StarsTransactionPeerClass) { + if s == nil { + return + } + return s.Peer +} + +// SetTitle sets value of Title conditional field. +func (s *StarsTransaction) SetTitle(value string) { + s.Flags.Set(0) + s.Title = value +} + +// GetTitle returns value of Title conditional field and +// boolean which is true if field was set. +func (s *StarsTransaction) GetTitle() (value string, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.Title, true +} + +// SetDescription sets value of Description conditional field. +func (s *StarsTransaction) SetDescription(value string) { + s.Flags.Set(1) + s.Description = value +} + +// GetDescription returns value of Description conditional field and +// boolean which is true if field was set. +func (s *StarsTransaction) GetDescription() (value string, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(1) { + return value, false + } + return s.Description, true +} + +// SetPhoto sets value of Photo conditional field. +func (s *StarsTransaction) SetPhoto(value WebDocumentClass) { + s.Flags.Set(2) + s.Photo = value +} + +// GetPhoto returns value of Photo conditional field and +// boolean which is true if field was set. +func (s *StarsTransaction) GetPhoto() (value WebDocumentClass, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(2) { + return value, false + } + return s.Photo, true +} diff --git a/tg/tl_stars_transaction_peer_gen.go b/tg/tl_stars_transaction_peer_gen.go new file mode 100644 index 0000000000..c1bd005bda --- /dev/null +++ b/tg/tl_stars_transaction_peer_gen.go @@ -0,0 +1,797 @@ +// 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{} +) + +// StarsTransactionPeerUnsupported represents TL type `starsTransactionPeerUnsupported#95f2bfe4`. +// +// See https://core.telegram.org/constructor/starsTransactionPeerUnsupported for reference. +type StarsTransactionPeerUnsupported struct { +} + +// StarsTransactionPeerUnsupportedTypeID is TL type id of StarsTransactionPeerUnsupported. +const StarsTransactionPeerUnsupportedTypeID = 0x95f2bfe4 + +// construct implements constructor of StarsTransactionPeerClass. +func (s StarsTransactionPeerUnsupported) construct() StarsTransactionPeerClass { return &s } + +// Ensuring interfaces in compile-time for StarsTransactionPeerUnsupported. +var ( + _ bin.Encoder = &StarsTransactionPeerUnsupported{} + _ bin.Decoder = &StarsTransactionPeerUnsupported{} + _ bin.BareEncoder = &StarsTransactionPeerUnsupported{} + _ bin.BareDecoder = &StarsTransactionPeerUnsupported{} + + _ StarsTransactionPeerClass = &StarsTransactionPeerUnsupported{} +) + +func (s *StarsTransactionPeerUnsupported) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarsTransactionPeerUnsupported) String() string { + if s == nil { + return "StarsTransactionPeerUnsupported(nil)" + } + type Alias StarsTransactionPeerUnsupported + return fmt.Sprintf("StarsTransactionPeerUnsupported%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsTransactionPeerUnsupported) TypeID() uint32 { + return StarsTransactionPeerUnsupportedTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsTransactionPeerUnsupported) TypeName() string { + return "starsTransactionPeerUnsupported" +} + +// TypeInfo returns info about TL type. +func (s *StarsTransactionPeerUnsupported) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starsTransactionPeerUnsupported", + ID: StarsTransactionPeerUnsupportedTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *StarsTransactionPeerUnsupported) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransactionPeerUnsupported#95f2bfe4 as nil") + } + b.PutID(StarsTransactionPeerUnsupportedTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarsTransactionPeerUnsupported) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransactionPeerUnsupported#95f2bfe4 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarsTransactionPeerUnsupported) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransactionPeerUnsupported#95f2bfe4 to nil") + } + if err := b.ConsumeID(StarsTransactionPeerUnsupportedTypeID); err != nil { + return fmt.Errorf("unable to decode starsTransactionPeerUnsupported#95f2bfe4: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarsTransactionPeerUnsupported) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransactionPeerUnsupported#95f2bfe4 to nil") + } + return nil +} + +// StarsTransactionPeerAppStore represents TL type `starsTransactionPeerAppStore#b457b375`. +// +// See https://core.telegram.org/constructor/starsTransactionPeerAppStore for reference. +type StarsTransactionPeerAppStore struct { +} + +// StarsTransactionPeerAppStoreTypeID is TL type id of StarsTransactionPeerAppStore. +const StarsTransactionPeerAppStoreTypeID = 0xb457b375 + +// construct implements constructor of StarsTransactionPeerClass. +func (s StarsTransactionPeerAppStore) construct() StarsTransactionPeerClass { return &s } + +// Ensuring interfaces in compile-time for StarsTransactionPeerAppStore. +var ( + _ bin.Encoder = &StarsTransactionPeerAppStore{} + _ bin.Decoder = &StarsTransactionPeerAppStore{} + _ bin.BareEncoder = &StarsTransactionPeerAppStore{} + _ bin.BareDecoder = &StarsTransactionPeerAppStore{} + + _ StarsTransactionPeerClass = &StarsTransactionPeerAppStore{} +) + +func (s *StarsTransactionPeerAppStore) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarsTransactionPeerAppStore) String() string { + if s == nil { + return "StarsTransactionPeerAppStore(nil)" + } + type Alias StarsTransactionPeerAppStore + return fmt.Sprintf("StarsTransactionPeerAppStore%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsTransactionPeerAppStore) TypeID() uint32 { + return StarsTransactionPeerAppStoreTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsTransactionPeerAppStore) TypeName() string { + return "starsTransactionPeerAppStore" +} + +// TypeInfo returns info about TL type. +func (s *StarsTransactionPeerAppStore) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starsTransactionPeerAppStore", + ID: StarsTransactionPeerAppStoreTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *StarsTransactionPeerAppStore) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransactionPeerAppStore#b457b375 as nil") + } + b.PutID(StarsTransactionPeerAppStoreTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarsTransactionPeerAppStore) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransactionPeerAppStore#b457b375 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarsTransactionPeerAppStore) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransactionPeerAppStore#b457b375 to nil") + } + if err := b.ConsumeID(StarsTransactionPeerAppStoreTypeID); err != nil { + return fmt.Errorf("unable to decode starsTransactionPeerAppStore#b457b375: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarsTransactionPeerAppStore) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransactionPeerAppStore#b457b375 to nil") + } + return nil +} + +// StarsTransactionPeerPlayMarket represents TL type `starsTransactionPeerPlayMarket#7b560a0b`. +// +// See https://core.telegram.org/constructor/starsTransactionPeerPlayMarket for reference. +type StarsTransactionPeerPlayMarket struct { +} + +// StarsTransactionPeerPlayMarketTypeID is TL type id of StarsTransactionPeerPlayMarket. +const StarsTransactionPeerPlayMarketTypeID = 0x7b560a0b + +// construct implements constructor of StarsTransactionPeerClass. +func (s StarsTransactionPeerPlayMarket) construct() StarsTransactionPeerClass { return &s } + +// Ensuring interfaces in compile-time for StarsTransactionPeerPlayMarket. +var ( + _ bin.Encoder = &StarsTransactionPeerPlayMarket{} + _ bin.Decoder = &StarsTransactionPeerPlayMarket{} + _ bin.BareEncoder = &StarsTransactionPeerPlayMarket{} + _ bin.BareDecoder = &StarsTransactionPeerPlayMarket{} + + _ StarsTransactionPeerClass = &StarsTransactionPeerPlayMarket{} +) + +func (s *StarsTransactionPeerPlayMarket) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarsTransactionPeerPlayMarket) String() string { + if s == nil { + return "StarsTransactionPeerPlayMarket(nil)" + } + type Alias StarsTransactionPeerPlayMarket + return fmt.Sprintf("StarsTransactionPeerPlayMarket%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsTransactionPeerPlayMarket) TypeID() uint32 { + return StarsTransactionPeerPlayMarketTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsTransactionPeerPlayMarket) TypeName() string { + return "starsTransactionPeerPlayMarket" +} + +// TypeInfo returns info about TL type. +func (s *StarsTransactionPeerPlayMarket) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starsTransactionPeerPlayMarket", + ID: StarsTransactionPeerPlayMarketTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *StarsTransactionPeerPlayMarket) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransactionPeerPlayMarket#7b560a0b as nil") + } + b.PutID(StarsTransactionPeerPlayMarketTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarsTransactionPeerPlayMarket) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransactionPeerPlayMarket#7b560a0b as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarsTransactionPeerPlayMarket) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransactionPeerPlayMarket#7b560a0b to nil") + } + if err := b.ConsumeID(StarsTransactionPeerPlayMarketTypeID); err != nil { + return fmt.Errorf("unable to decode starsTransactionPeerPlayMarket#7b560a0b: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarsTransactionPeerPlayMarket) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransactionPeerPlayMarket#7b560a0b to nil") + } + return nil +} + +// StarsTransactionPeerPremiumBot represents TL type `starsTransactionPeerPremiumBot#250dbaf8`. +// +// See https://core.telegram.org/constructor/starsTransactionPeerPremiumBot for reference. +type StarsTransactionPeerPremiumBot struct { +} + +// StarsTransactionPeerPremiumBotTypeID is TL type id of StarsTransactionPeerPremiumBot. +const StarsTransactionPeerPremiumBotTypeID = 0x250dbaf8 + +// construct implements constructor of StarsTransactionPeerClass. +func (s StarsTransactionPeerPremiumBot) construct() StarsTransactionPeerClass { return &s } + +// Ensuring interfaces in compile-time for StarsTransactionPeerPremiumBot. +var ( + _ bin.Encoder = &StarsTransactionPeerPremiumBot{} + _ bin.Decoder = &StarsTransactionPeerPremiumBot{} + _ bin.BareEncoder = &StarsTransactionPeerPremiumBot{} + _ bin.BareDecoder = &StarsTransactionPeerPremiumBot{} + + _ StarsTransactionPeerClass = &StarsTransactionPeerPremiumBot{} +) + +func (s *StarsTransactionPeerPremiumBot) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarsTransactionPeerPremiumBot) String() string { + if s == nil { + return "StarsTransactionPeerPremiumBot(nil)" + } + type Alias StarsTransactionPeerPremiumBot + return fmt.Sprintf("StarsTransactionPeerPremiumBot%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsTransactionPeerPremiumBot) TypeID() uint32 { + return StarsTransactionPeerPremiumBotTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsTransactionPeerPremiumBot) TypeName() string { + return "starsTransactionPeerPremiumBot" +} + +// TypeInfo returns info about TL type. +func (s *StarsTransactionPeerPremiumBot) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starsTransactionPeerPremiumBot", + ID: StarsTransactionPeerPremiumBotTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *StarsTransactionPeerPremiumBot) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransactionPeerPremiumBot#250dbaf8 as nil") + } + b.PutID(StarsTransactionPeerPremiumBotTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarsTransactionPeerPremiumBot) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransactionPeerPremiumBot#250dbaf8 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarsTransactionPeerPremiumBot) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransactionPeerPremiumBot#250dbaf8 to nil") + } + if err := b.ConsumeID(StarsTransactionPeerPremiumBotTypeID); err != nil { + return fmt.Errorf("unable to decode starsTransactionPeerPremiumBot#250dbaf8: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarsTransactionPeerPremiumBot) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransactionPeerPremiumBot#250dbaf8 to nil") + } + return nil +} + +// StarsTransactionPeerFragment represents TL type `starsTransactionPeerFragment#e92fd902`. +// +// See https://core.telegram.org/constructor/starsTransactionPeerFragment for reference. +type StarsTransactionPeerFragment struct { +} + +// StarsTransactionPeerFragmentTypeID is TL type id of StarsTransactionPeerFragment. +const StarsTransactionPeerFragmentTypeID = 0xe92fd902 + +// construct implements constructor of StarsTransactionPeerClass. +func (s StarsTransactionPeerFragment) construct() StarsTransactionPeerClass { return &s } + +// Ensuring interfaces in compile-time for StarsTransactionPeerFragment. +var ( + _ bin.Encoder = &StarsTransactionPeerFragment{} + _ bin.Decoder = &StarsTransactionPeerFragment{} + _ bin.BareEncoder = &StarsTransactionPeerFragment{} + _ bin.BareDecoder = &StarsTransactionPeerFragment{} + + _ StarsTransactionPeerClass = &StarsTransactionPeerFragment{} +) + +func (s *StarsTransactionPeerFragment) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarsTransactionPeerFragment) String() string { + if s == nil { + return "StarsTransactionPeerFragment(nil)" + } + type Alias StarsTransactionPeerFragment + return fmt.Sprintf("StarsTransactionPeerFragment%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsTransactionPeerFragment) TypeID() uint32 { + return StarsTransactionPeerFragmentTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsTransactionPeerFragment) TypeName() string { + return "starsTransactionPeerFragment" +} + +// TypeInfo returns info about TL type. +func (s *StarsTransactionPeerFragment) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starsTransactionPeerFragment", + ID: StarsTransactionPeerFragmentTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *StarsTransactionPeerFragment) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransactionPeerFragment#e92fd902 as nil") + } + b.PutID(StarsTransactionPeerFragmentTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarsTransactionPeerFragment) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransactionPeerFragment#e92fd902 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarsTransactionPeerFragment) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransactionPeerFragment#e92fd902 to nil") + } + if err := b.ConsumeID(StarsTransactionPeerFragmentTypeID); err != nil { + return fmt.Errorf("unable to decode starsTransactionPeerFragment#e92fd902: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarsTransactionPeerFragment) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransactionPeerFragment#e92fd902 to nil") + } + return nil +} + +// StarsTransactionPeer represents TL type `starsTransactionPeer#d80da15d`. +// +// See https://core.telegram.org/constructor/starsTransactionPeer for reference. +type StarsTransactionPeer struct { + // Peer field of StarsTransactionPeer. + Peer PeerClass +} + +// StarsTransactionPeerTypeID is TL type id of StarsTransactionPeer. +const StarsTransactionPeerTypeID = 0xd80da15d + +// construct implements constructor of StarsTransactionPeerClass. +func (s StarsTransactionPeer) construct() StarsTransactionPeerClass { return &s } + +// Ensuring interfaces in compile-time for StarsTransactionPeer. +var ( + _ bin.Encoder = &StarsTransactionPeer{} + _ bin.Decoder = &StarsTransactionPeer{} + _ bin.BareEncoder = &StarsTransactionPeer{} + _ bin.BareDecoder = &StarsTransactionPeer{} + + _ StarsTransactionPeerClass = &StarsTransactionPeer{} +) + +func (s *StarsTransactionPeer) Zero() bool { + if s == nil { + return true + } + if !(s.Peer == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarsTransactionPeer) String() string { + if s == nil { + return "StarsTransactionPeer(nil)" + } + type Alias StarsTransactionPeer + return fmt.Sprintf("StarsTransactionPeer%+v", Alias(*s)) +} + +// FillFrom fills StarsTransactionPeer from given interface. +func (s *StarsTransactionPeer) FillFrom(from interface { + GetPeer() (value PeerClass) +}) { + s.Peer = from.GetPeer() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsTransactionPeer) TypeID() uint32 { + return StarsTransactionPeerTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsTransactionPeer) TypeName() string { + return "starsTransactionPeer" +} + +// TypeInfo returns info about TL type. +func (s *StarsTransactionPeer) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starsTransactionPeer", + ID: StarsTransactionPeerTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarsTransactionPeer) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransactionPeer#d80da15d as nil") + } + b.PutID(StarsTransactionPeerTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarsTransactionPeer) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsTransactionPeer#d80da15d as nil") + } + if s.Peer == nil { + return fmt.Errorf("unable to encode starsTransactionPeer#d80da15d: field peer is nil") + } + if err := s.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsTransactionPeer#d80da15d: field peer: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarsTransactionPeer) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransactionPeer#d80da15d to nil") + } + if err := b.ConsumeID(StarsTransactionPeerTypeID); err != nil { + return fmt.Errorf("unable to decode starsTransactionPeer#d80da15d: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarsTransactionPeer) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsTransactionPeer#d80da15d to nil") + } + { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode starsTransactionPeer#d80da15d: field peer: %w", err) + } + s.Peer = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (s *StarsTransactionPeer) GetPeer() (value PeerClass) { + if s == nil { + return + } + return s.Peer +} + +// StarsTransactionPeerClassName is schema name of StarsTransactionPeerClass. +const StarsTransactionPeerClassName = "StarsTransactionPeer" + +// StarsTransactionPeerClass represents StarsTransactionPeer generic type. +// +// See https://core.telegram.org/type/StarsTransactionPeer for reference. +// +// Example: +// +// g, err := tg.DecodeStarsTransactionPeer(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.StarsTransactionPeerUnsupported: // starsTransactionPeerUnsupported#95f2bfe4 +// case *tg.StarsTransactionPeerAppStore: // starsTransactionPeerAppStore#b457b375 +// case *tg.StarsTransactionPeerPlayMarket: // starsTransactionPeerPlayMarket#7b560a0b +// case *tg.StarsTransactionPeerPremiumBot: // starsTransactionPeerPremiumBot#250dbaf8 +// case *tg.StarsTransactionPeerFragment: // starsTransactionPeerFragment#e92fd902 +// case *tg.StarsTransactionPeer: // starsTransactionPeer#d80da15d +// default: panic(v) +// } +type StarsTransactionPeerClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() StarsTransactionPeerClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool +} + +// DecodeStarsTransactionPeer implements binary de-serialization for StarsTransactionPeerClass. +func DecodeStarsTransactionPeer(buf *bin.Buffer) (StarsTransactionPeerClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case StarsTransactionPeerUnsupportedTypeID: + // Decoding starsTransactionPeerUnsupported#95f2bfe4. + v := StarsTransactionPeerUnsupported{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarsTransactionPeerClass: %w", err) + } + return &v, nil + case StarsTransactionPeerAppStoreTypeID: + // Decoding starsTransactionPeerAppStore#b457b375. + v := StarsTransactionPeerAppStore{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarsTransactionPeerClass: %w", err) + } + return &v, nil + case StarsTransactionPeerPlayMarketTypeID: + // Decoding starsTransactionPeerPlayMarket#7b560a0b. + v := StarsTransactionPeerPlayMarket{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarsTransactionPeerClass: %w", err) + } + return &v, nil + case StarsTransactionPeerPremiumBotTypeID: + // Decoding starsTransactionPeerPremiumBot#250dbaf8. + v := StarsTransactionPeerPremiumBot{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarsTransactionPeerClass: %w", err) + } + return &v, nil + case StarsTransactionPeerFragmentTypeID: + // Decoding starsTransactionPeerFragment#e92fd902. + v := StarsTransactionPeerFragment{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarsTransactionPeerClass: %w", err) + } + return &v, nil + case StarsTransactionPeerTypeID: + // Decoding starsTransactionPeer#d80da15d. + v := StarsTransactionPeer{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarsTransactionPeerClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode StarsTransactionPeerClass: %w", bin.NewUnexpectedID(id)) + } +} + +// StarsTransactionPeer boxes the StarsTransactionPeerClass providing a helper. +type StarsTransactionPeerBox struct { + StarsTransactionPeer StarsTransactionPeerClass +} + +// Decode implements bin.Decoder for StarsTransactionPeerBox. +func (b *StarsTransactionPeerBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode StarsTransactionPeerBox to nil") + } + v, err := DecodeStarsTransactionPeer(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.StarsTransactionPeer = v + return nil +} + +// Encode implements bin.Encode for StarsTransactionPeerBox. +func (b *StarsTransactionPeerBox) Encode(buf *bin.Buffer) error { + if b == nil || b.StarsTransactionPeer == nil { + return fmt.Errorf("unable to encode StarsTransactionPeerClass as nil") + } + return b.StarsTransactionPeer.Encode(buf) +} diff --git a/tg/tl_stars_transaction_peer_slices_gen.go b/tg/tl_stars_transaction_peer_slices_gen.go new file mode 100644 index 0000000000..7ebceaf0dd --- /dev/null +++ b/tg/tl_stars_transaction_peer_slices_gen.go @@ -0,0 +1,212 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// StarsTransactionPeerClassArray is adapter for slice of StarsTransactionPeerClass. +type StarsTransactionPeerClassArray []StarsTransactionPeerClass + +// Sort sorts slice of StarsTransactionPeerClass. +func (s StarsTransactionPeerClassArray) Sort(less func(a, b StarsTransactionPeerClass) bool) StarsTransactionPeerClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of StarsTransactionPeerClass. +func (s StarsTransactionPeerClassArray) SortStable(less func(a, b StarsTransactionPeerClass) bool) StarsTransactionPeerClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of StarsTransactionPeerClass. +func (s StarsTransactionPeerClassArray) Retain(keep func(x StarsTransactionPeerClass) bool) StarsTransactionPeerClassArray { + 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 StarsTransactionPeerClassArray) First() (v StarsTransactionPeerClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s StarsTransactionPeerClassArray) Last() (v StarsTransactionPeerClass, 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 *StarsTransactionPeerClassArray) PopFirst() (v StarsTransactionPeerClass, 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 StarsTransactionPeerClass + 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 *StarsTransactionPeerClassArray) Pop() (v StarsTransactionPeerClass, 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 +} + +// AsStarsTransactionPeer returns copy with only StarsTransactionPeer constructors. +func (s StarsTransactionPeerClassArray) AsStarsTransactionPeer() (to StarsTransactionPeerArray) { + for _, elem := range s { + value, ok := elem.(*StarsTransactionPeer) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// StarsTransactionPeerArray is adapter for slice of StarsTransactionPeer. +type StarsTransactionPeerArray []StarsTransactionPeer + +// Sort sorts slice of StarsTransactionPeer. +func (s StarsTransactionPeerArray) Sort(less func(a, b StarsTransactionPeer) bool) StarsTransactionPeerArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of StarsTransactionPeer. +func (s StarsTransactionPeerArray) SortStable(less func(a, b StarsTransactionPeer) bool) StarsTransactionPeerArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of StarsTransactionPeer. +func (s StarsTransactionPeerArray) Retain(keep func(x StarsTransactionPeer) bool) StarsTransactionPeerArray { + 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 StarsTransactionPeerArray) First() (v StarsTransactionPeer, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s StarsTransactionPeerArray) Last() (v StarsTransactionPeer, 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 *StarsTransactionPeerArray) PopFirst() (v StarsTransactionPeer, 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 StarsTransactionPeer + 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 *StarsTransactionPeerArray) Pop() (v StarsTransactionPeer, 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_stars_transaction_slices_gen.go b/tg/tl_stars_transaction_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_stars_transaction_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_update_gen.go b/tg/tl_update_gen.go index e00f5f0887..65f13258b2 100644 --- a/tg/tl_update_gen.go +++ b/tg/tl_update_gen.go @@ -27136,6 +27136,306 @@ func (u *UpdateNewStoryReaction) GetReaction() (value ReactionClass) { return u.Reaction } +// UpdateBroadcastRevenueTransactions represents TL type `updateBroadcastRevenueTransactions#dfd961f5`. +// +// See https://core.telegram.org/constructor/updateBroadcastRevenueTransactions for reference. +type UpdateBroadcastRevenueTransactions struct { + // Peer field of UpdateBroadcastRevenueTransactions. + Peer PeerClass + // Balances field of UpdateBroadcastRevenueTransactions. + Balances BroadcastRevenueBalances +} + +// UpdateBroadcastRevenueTransactionsTypeID is TL type id of UpdateBroadcastRevenueTransactions. +const UpdateBroadcastRevenueTransactionsTypeID = 0xdfd961f5 + +// construct implements constructor of UpdateClass. +func (u UpdateBroadcastRevenueTransactions) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateBroadcastRevenueTransactions. +var ( + _ bin.Encoder = &UpdateBroadcastRevenueTransactions{} + _ bin.Decoder = &UpdateBroadcastRevenueTransactions{} + _ bin.BareEncoder = &UpdateBroadcastRevenueTransactions{} + _ bin.BareDecoder = &UpdateBroadcastRevenueTransactions{} + + _ UpdateClass = &UpdateBroadcastRevenueTransactions{} +) + +func (u *UpdateBroadcastRevenueTransactions) Zero() bool { + if u == nil { + return true + } + if !(u.Peer == nil) { + return false + } + if !(u.Balances.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateBroadcastRevenueTransactions) String() string { + if u == nil { + return "UpdateBroadcastRevenueTransactions(nil)" + } + type Alias UpdateBroadcastRevenueTransactions + return fmt.Sprintf("UpdateBroadcastRevenueTransactions%+v", Alias(*u)) +} + +// FillFrom fills UpdateBroadcastRevenueTransactions from given interface. +func (u *UpdateBroadcastRevenueTransactions) FillFrom(from interface { + GetPeer() (value PeerClass) + GetBalances() (value BroadcastRevenueBalances) +}) { + u.Peer = from.GetPeer() + u.Balances = from.GetBalances() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateBroadcastRevenueTransactions) TypeID() uint32 { + return UpdateBroadcastRevenueTransactionsTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateBroadcastRevenueTransactions) TypeName() string { + return "updateBroadcastRevenueTransactions" +} + +// TypeInfo returns info about TL type. +func (u *UpdateBroadcastRevenueTransactions) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateBroadcastRevenueTransactions", + ID: UpdateBroadcastRevenueTransactionsTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "Balances", + SchemaName: "balances", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateBroadcastRevenueTransactions) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateBroadcastRevenueTransactions#dfd961f5 as nil") + } + b.PutID(UpdateBroadcastRevenueTransactionsTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateBroadcastRevenueTransactions) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateBroadcastRevenueTransactions#dfd961f5 as nil") + } + if u.Peer == nil { + return fmt.Errorf("unable to encode updateBroadcastRevenueTransactions#dfd961f5: field peer is nil") + } + if err := u.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateBroadcastRevenueTransactions#dfd961f5: field peer: %w", err) + } + if err := u.Balances.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateBroadcastRevenueTransactions#dfd961f5: field balances: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateBroadcastRevenueTransactions) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateBroadcastRevenueTransactions#dfd961f5 to nil") + } + if err := b.ConsumeID(UpdateBroadcastRevenueTransactionsTypeID); err != nil { + return fmt.Errorf("unable to decode updateBroadcastRevenueTransactions#dfd961f5: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateBroadcastRevenueTransactions) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateBroadcastRevenueTransactions#dfd961f5 to nil") + } + { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode updateBroadcastRevenueTransactions#dfd961f5: field peer: %w", err) + } + u.Peer = value + } + { + if err := u.Balances.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateBroadcastRevenueTransactions#dfd961f5: field balances: %w", err) + } + } + return nil +} + +// GetPeer returns value of Peer field. +func (u *UpdateBroadcastRevenueTransactions) GetPeer() (value PeerClass) { + if u == nil { + return + } + return u.Peer +} + +// GetBalances returns value of Balances field. +func (u *UpdateBroadcastRevenueTransactions) GetBalances() (value BroadcastRevenueBalances) { + if u == nil { + return + } + return u.Balances +} + +// UpdateStarsBalance represents TL type `updateStarsBalance#fb85198`. +// +// See https://core.telegram.org/constructor/updateStarsBalance for reference. +type UpdateStarsBalance struct { + // Balance field of UpdateStarsBalance. + Balance int64 +} + +// UpdateStarsBalanceTypeID is TL type id of UpdateStarsBalance. +const UpdateStarsBalanceTypeID = 0xfb85198 + +// construct implements constructor of UpdateClass. +func (u UpdateStarsBalance) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateStarsBalance. +var ( + _ bin.Encoder = &UpdateStarsBalance{} + _ bin.Decoder = &UpdateStarsBalance{} + _ bin.BareEncoder = &UpdateStarsBalance{} + _ bin.BareDecoder = &UpdateStarsBalance{} + + _ UpdateClass = &UpdateStarsBalance{} +) + +func (u *UpdateStarsBalance) Zero() bool { + if u == nil { + return true + } + if !(u.Balance == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateStarsBalance) String() string { + if u == nil { + return "UpdateStarsBalance(nil)" + } + type Alias UpdateStarsBalance + return fmt.Sprintf("UpdateStarsBalance%+v", Alias(*u)) +} + +// FillFrom fills UpdateStarsBalance from given interface. +func (u *UpdateStarsBalance) FillFrom(from interface { + GetBalance() (value int64) +}) { + u.Balance = from.GetBalance() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateStarsBalance) TypeID() uint32 { + return UpdateStarsBalanceTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateStarsBalance) TypeName() string { + return "updateStarsBalance" +} + +// TypeInfo returns info about TL type. +func (u *UpdateStarsBalance) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateStarsBalance", + ID: UpdateStarsBalanceTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Balance", + SchemaName: "balance", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateStarsBalance) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateStarsBalance#fb85198 as nil") + } + b.PutID(UpdateStarsBalanceTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateStarsBalance) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateStarsBalance#fb85198 as nil") + } + b.PutLong(u.Balance) + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateStarsBalance) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateStarsBalance#fb85198 to nil") + } + if err := b.ConsumeID(UpdateStarsBalanceTypeID); err != nil { + return fmt.Errorf("unable to decode updateStarsBalance#fb85198: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateStarsBalance) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateStarsBalance#fb85198 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateStarsBalance#fb85198: field balance: %w", err) + } + u.Balance = value + } + return nil +} + +// GetBalance returns value of Balance field. +func (u *UpdateStarsBalance) GetBalance() (value int64) { + if u == nil { + return + } + return u.Balance +} + // UpdateClassName is schema name of UpdateClass. const UpdateClassName = "Update" @@ -27285,6 +27585,8 @@ const UpdateClassName = "Update" // case *tg.UpdateBotEditBusinessMessage: // updateBotEditBusinessMessage#7df587c // case *tg.UpdateBotDeleteBusinessMessage: // updateBotDeleteBusinessMessage#a02a982e // case *tg.UpdateNewStoryReaction: // updateNewStoryReaction#1824e40b +// case *tg.UpdateBroadcastRevenueTransactions: // updateBroadcastRevenueTransactions#dfd961f5 +// case *tg.UpdateStarsBalance: // updateStarsBalance#fb85198 // default: panic(v) // } type UpdateClass interface { @@ -28258,6 +28560,20 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case UpdateBroadcastRevenueTransactionsTypeID: + // Decoding updateBroadcastRevenueTransactions#dfd961f5. + v := UpdateBroadcastRevenueTransactions{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil + case UpdateStarsBalanceTypeID: + // Decoding updateStarsBalance#fb85198. + v := UpdateStarsBalance{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode UpdateClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_update_slices_gen.go b/tg/tl_update_slices_gen.go index 656129e2cb..4d9fb23952 100644 --- a/tg/tl_update_slices_gen.go +++ b/tg/tl_update_slices_gen.go @@ -1663,6 +1663,32 @@ func (s UpdateClassArray) AsUpdateNewStoryReaction() (to UpdateNewStoryReactionA return to } +// AsUpdateBroadcastRevenueTransactions returns copy with only UpdateBroadcastRevenueTransactions constructors. +func (s UpdateClassArray) AsUpdateBroadcastRevenueTransactions() (to UpdateBroadcastRevenueTransactionsArray) { + for _, elem := range s { + value, ok := elem.(*UpdateBroadcastRevenueTransactions) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsUpdateStarsBalance returns copy with only UpdateStarsBalance constructors. +func (s UpdateClassArray) AsUpdateStarsBalance() (to UpdateStarsBalanceArray) { + for _, elem := range s { + value, ok := elem.(*UpdateStarsBalance) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // UpdateNewMessageArray is adapter for slice of UpdateNewMessage. type UpdateNewMessageArray []UpdateNewMessage @@ -11686,3 +11712,167 @@ func (s *UpdateNewStoryReactionArray) Pop() (v UpdateNewStoryReaction, ok bool) return v, true } + +// UpdateBroadcastRevenueTransactionsArray is adapter for slice of UpdateBroadcastRevenueTransactions. +type UpdateBroadcastRevenueTransactionsArray []UpdateBroadcastRevenueTransactions + +// Sort sorts slice of UpdateBroadcastRevenueTransactions. +func (s UpdateBroadcastRevenueTransactionsArray) Sort(less func(a, b UpdateBroadcastRevenueTransactions) bool) UpdateBroadcastRevenueTransactionsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateBroadcastRevenueTransactions. +func (s UpdateBroadcastRevenueTransactionsArray) SortStable(less func(a, b UpdateBroadcastRevenueTransactions) bool) UpdateBroadcastRevenueTransactionsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateBroadcastRevenueTransactions. +func (s UpdateBroadcastRevenueTransactionsArray) Retain(keep func(x UpdateBroadcastRevenueTransactions) bool) UpdateBroadcastRevenueTransactionsArray { + 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 UpdateBroadcastRevenueTransactionsArray) First() (v UpdateBroadcastRevenueTransactions, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateBroadcastRevenueTransactionsArray) Last() (v UpdateBroadcastRevenueTransactions, 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 *UpdateBroadcastRevenueTransactionsArray) PopFirst() (v UpdateBroadcastRevenueTransactions, 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 UpdateBroadcastRevenueTransactions + 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 *UpdateBroadcastRevenueTransactionsArray) Pop() (v UpdateBroadcastRevenueTransactions, 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 +} + +// UpdateStarsBalanceArray is adapter for slice of UpdateStarsBalance. +type UpdateStarsBalanceArray []UpdateStarsBalance + +// Sort sorts slice of UpdateStarsBalance. +func (s UpdateStarsBalanceArray) Sort(less func(a, b UpdateStarsBalance) bool) UpdateStarsBalanceArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateStarsBalance. +func (s UpdateStarsBalanceArray) SortStable(less func(a, b UpdateStarsBalance) bool) UpdateStarsBalanceArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateStarsBalance. +func (s UpdateStarsBalanceArray) Retain(keep func(x UpdateStarsBalance) bool) UpdateStarsBalanceArray { + 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 UpdateStarsBalanceArray) First() (v UpdateStarsBalance, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateStarsBalanceArray) Last() (v UpdateStarsBalance, 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 *UpdateStarsBalanceArray) PopFirst() (v UpdateStarsBalance, 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 UpdateStarsBalance + 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 *UpdateStarsBalanceArray) Pop() (v UpdateStarsBalance, 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 +}