diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index 2f56328bcf..2f1a727d74 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: 187 -// SHA256: 13e5ee643d6d776ab46f2cd1a21c9b274a4cb46106dea20770ebce90115e1e42 +// Layer: 189 +// SHA256: 274a71c5b60947275de376cce5cecb0a907181439ae6d53c54f4a0331c66be75 boolFalse#bc799737 = Bool; @@ -204,7 +204,7 @@ messageMediaContact#70322949 phone_number:string first_name:string last_name:str messageMediaUnsupported#9f84f49e = MessageMedia; -messageMediaDocument#4cf4d72d flags:# nopremium:flags.3?true spoiler:flags.4?true video:flags.6?true round:flags.7?true voice:flags.8?true document:flags.0?Document alt_document:flags.5?Document ttl_seconds:flags.2?int = MessageMedia; +messageMediaDocument#dd570bd5 flags:# nopremium:flags.3?true spoiler:flags.4?true video:flags.6?true round:flags.7?true voice:flags.8?true document:flags.0?Document alt_documents:flags.5?Vector ttl_seconds:flags.2?int = MessageMedia; messageMediaWebPage#ddf10c3b flags:# force_large_media:flags.0?true force_small_media:flags.1?true manual:flags.3?true safe:flags.4?true webpage:WebPage = MessageMedia; @@ -320,6 +320,8 @@ messageActionGiftStars#45d5b021 flags:# currency:string amount:long stars:long c messageActionPrizeStars#b00c47a2 flags:# unclaimed:flags.0?true stars:long transaction_id:string boost_peer:Peer giveaway_msg_id:int = MessageAction; +messageActionStarGift#9bb3ef44 flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true gift:StarGift message:flags.1?TextWithEntities convert_stars:long = MessageAction; + dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true view_forum_as_messages:flags.6?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -394,7 +396,7 @@ inputReportReasonIllegalDrugs#a8eb2be = ReportReason; inputReportReasonPersonalDetails#9ec7863d = ReportReason; -userFull#cc997720 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int = UserFull; +userFull#1f58e369 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int stargifts_count:flags2.8?int = UserFull; contact#145ade0b user_id:long mutual:Bool = Contact; @@ -984,7 +986,7 @@ documentAttributeAnimated#11b58939 = DocumentAttribute; documentAttributeSticker#6319d612 flags:# mask:flags.1?true alt:string stickerset:InputStickerSet mask_coords:flags.0?MaskCoords = DocumentAttribute; -documentAttributeVideo#17399fad flags:# round_message:flags.0?true supports_streaming:flags.1?true nosound:flags.3?true duration:double w:int h:int preload_prefix_size:flags.2?int video_start_ts:flags.4?double = DocumentAttribute; +documentAttributeVideo#43c57c48 flags:# round_message:flags.0?true supports_streaming:flags.1?true nosound:flags.3?true duration:double w:int h:int preload_prefix_size:flags.2?int video_start_ts:flags.4?double video_codec:flags.5?string = DocumentAttribute; documentAttributeAudio#9852f9c6 flags:# voice:flags.10?true duration:int title:flags.0?string performer:flags.1?string waveform:flags.2?bytes = DocumentAttribute; @@ -1104,6 +1106,8 @@ keyboardButtonRequestPeer#53d7bfd8 text:string button_id:int peer_type:RequestPe inputKeyboardButtonRequestPeer#c9662d05 flags:# name_requested:flags.0?true username_requested:flags.1?true photo_requested:flags.2?true text:string button_id:int peer_type:RequestPeerType max_quantity:int = KeyboardButton; +keyboardButtonCopy#75d2698e text:string copy_text:string = KeyboardButton; + keyboardButtonRow#77608b83 buttons:Vector = KeyboardButtonRow; replyKeyboardHide#a03e5b85 flags:# selective:flags.2?true = ReplyMarkup; @@ -1508,6 +1512,8 @@ payments.paymentForm#a0058751 flags:# can_save_credentials:flags.2?true password 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.paymentFormStarGift#b425cfe1 form_id:long invoice:Invoice = payments.PaymentForm; + payments.validatedRequestedInfo#d1451883 flags:# id:flags.0?string shipping_options:flags.1?Vector = payments.ValidatedRequestedInfo; payments.paymentResult#4e5f810d updates:Updates = payments.PaymentResult; @@ -2230,6 +2236,8 @@ inputInvoiceStars#65f00ce3 purpose:InputStorePaymentPurpose = InputInvoice; inputInvoiceChatInviteSubscription#34e793f1 hash:string = InputInvoice; +inputInvoiceStarGift#25d8c1d8 flags:# hide_name:flags.0?true user_id:InputUser gift_id:long message:flags.1?TextWithEntities = 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; @@ -2664,7 +2672,7 @@ starsTransactionPeerAds#60682812 = StarsTransactionPeer; starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; -starsTransaction#ee7522d5 flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true reaction:flags.11?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector subscription_period:flags.12?int giveaway_post_id:flags.13?int = StarsTransaction; +starsTransaction#a9ee4c2 flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true reaction:flags.11?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector subscription_period:flags.12?int giveaway_post_id:flags.13?int stargift:flags.14?StarGift = StarsTransaction; payments.starsStatus#bbfa316c flags:# balance:long subscriptions:flags.1?Vector subscriptions_next_offset:flags.2?string subscriptions_missing_balance:flags.4?long history:flags.3?Vector next_offset:flags.0?string chats:Vector users:Vector = payments.StarsStatus; @@ -2702,6 +2710,24 @@ starsGiveawayOption#94ce852a flags:# extended:flags.0?true default:flags.1?true starsGiveawayWinnersOption#54236209 flags:# default:flags.0?true users:int per_user_stars:long = StarsGiveawayWinnersOption; +starGift#aea174ee flags:# limited:flags.0?true id:long sticker:Document stars:long availability_remains:flags.0?int availability_total:flags.0?int convert_stars:long = StarGift; + +payments.starGiftsNotModified#a388a368 = payments.StarGifts; + +payments.starGifts#901689ea hash:int gifts:Vector = payments.StarGifts; + +userStarGift#eea49a6e flags:# name_hidden:flags.0?true unsaved:flags.5?true from_id:flags.1?long date:int gift:StarGift message:flags.2?TextWithEntities msg_id:flags.3?int convert_stars:flags.4?long = UserStarGift; + +payments.userStarGifts#6b65b517 flags:# count:int gifts:Vector next_offset:flags.0?string users:Vector = payments.UserStarGifts; + +messageReportOption#7903e3d9 text:string option:bytes = MessageReportOption; + +reportResultChooseOption#f0e4e0b6 title:string options:Vector = ReportResult; + +reportResultAddComment#6f09ac31 flags:# optional:flags.0?true option:bytes = ReportResult; + +reportResultReported#8db33c4b = ReportResult; + ---functions--- @@ -3083,7 +3109,7 @@ messages.reportSpam#cf1592db peer:InputPeer = Bool; messages.getPeerSettings#efd9a6a2 peer:InputPeer = messages.PeerSettings; -messages.report#8953ab4e peer:InputPeer id:Vector reason:ReportReason message:string = Bool; +messages.report#fc78af9b peer:InputPeer id:Vector option:bytes message:string = ReportResult; messages.getChats#49e9528f id:Vector = messages.Chats; @@ -3681,7 +3707,7 @@ channels.reportAntiSpamFalsePositive#a850a693 channel:InputChannel msg_id:int = channels.toggleParticipantsHidden#6a6e7854 channel:InputChannel enabled:Bool = Updates; -channels.clickSponsoredMessage#18afbc93 channel:InputChannel random_id:bytes = Bool; +channels.clickSponsoredMessage#1445d75 flags:# media:flags.0?true fullscreen:flags.1?true channel:InputChannel random_id:bytes = Bool; channels.updateColor#d8aa3671 flags:# for_profile:flags.1?true channel:InputChannel color:flags.2?int background_emoji_id:flags.0?long = Updates; @@ -3785,7 +3811,7 @@ payments.getStarsStatus#104fcfa7 peer:InputPeer = payments.StarsStatus; payments.getStarsTransactions#69da4557 flags:# inbound:flags.0?true outbound:flags.1?true ascending:flags.2?true subscription_id:flags.3?string peer:InputPeer offset:string limit:int = payments.StarsStatus; -payments.sendStarsForm#2bb731d flags:# form_id:long invoice:InputInvoice = payments.PaymentResult; +payments.sendStarsForm#7998c914 form_id:long invoice:InputInvoice = payments.PaymentResult; payments.refundStarsCharge#25ae8f4a user_id:InputUser charge_id:string = Updates; @@ -3807,6 +3833,14 @@ payments.fulfillStarsSubscription#cc5bebb3 peer:InputPeer subscription_id:string payments.getStarsGiveawayOptions#bd1efd3e = Vector; +payments.getStarGifts#c4563590 hash:int = payments.StarGifts; + +payments.getUserStarGifts#5e72c7e1 user_id:InputUser offset:string limit:int = payments.UserStarGifts; + +payments.saveStarGift#87acf08e flags:# unsave:flags.0?true user_id:InputUser msg_id:int = Bool; + +payments.convertStarGift#421e027 user_id:InputUser msg_id:int = Bool; + 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; @@ -3975,7 +4009,7 @@ stories.getStoriesViews#28e16cc8 peer:InputPeer id:Vector = stories.StoryVi stories.exportStoryLink#7b8def20 peer:InputPeer id:int = ExportedStoryLink; -stories.report#1923fa8c peer:InputPeer id:Vector reason:ReportReason message:string = Bool; +stories.report#19d8eb45 peer:InputPeer id:Vector option:bytes message:string = ReportResult; stories.activateStealthMode#57bbd166 flags:# past:flags.0?true future:flags.1?true = Updates; @@ -4023,4 +4057,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 187 +// LAYER 189 diff --git a/_schema/tdlib.tl b/_schema/tdlib.tl index 181155018b..3ebe173c66 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: 187 -// SHA256: 00fe5de958d6979d95da72e956e3c71b137de5b973f259370f4bae0b18978b46 +// Layer: 189 +// SHA256: eff9073ed808ffbcfe0d8fd73c3fb125d65e897792d8e53327c5e4af2a4c07d7 int#a8509bda ? = Int; @@ -240,7 +240,7 @@ messageMediaContact#70322949 phone_number:string first_name:string last_name:str messageMediaUnsupported#9f84f49e = MessageMedia; -messageMediaDocument#4cf4d72d flags:# nopremium:flags.3?true spoiler:flags.4?true video:flags.6?true round:flags.7?true voice:flags.8?true document:flags.0?Document alt_document:flags.5?Document ttl_seconds:flags.2?int = MessageMedia; +messageMediaDocument#dd570bd5 flags:# nopremium:flags.3?true spoiler:flags.4?true video:flags.6?true round:flags.7?true voice:flags.8?true document:flags.0?Document alt_documents:flags.5?Vector ttl_seconds:flags.2?int = MessageMedia; messageMediaWebPage#ddf10c3b flags:# force_large_media:flags.0?true force_small_media:flags.1?true manual:flags.3?true safe:flags.4?true webpage:WebPage = MessageMedia; @@ -356,6 +356,8 @@ messageActionGiftStars#45d5b021 flags:# currency:string amount:long stars:long c messageActionPrizeStars#b00c47a2 flags:# unclaimed:flags.0?true stars:long transaction_id:string boost_peer:Peer giveaway_msg_id:int = MessageAction; +messageActionStarGift#9bb3ef44 flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true gift:StarGift message:flags.1?TextWithEntities convert_stars:long = MessageAction; + dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true view_forum_as_messages:flags.6?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -430,7 +432,7 @@ inputReportReasonIllegalDrugs#a8eb2be = ReportReason; inputReportReasonPersonalDetails#9ec7863d = ReportReason; -userFull#cc997720 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int = UserFull; +userFull#1f58e369 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int stargifts_count:flags2.8?int = UserFull; contact#145ade0b user_id:long mutual:Bool = Contact; @@ -1020,7 +1022,7 @@ documentAttributeAnimated#11b58939 = DocumentAttribute; documentAttributeSticker#6319d612 flags:# mask:flags.1?true alt:string stickerset:InputStickerSet mask_coords:flags.0?MaskCoords = DocumentAttribute; -documentAttributeVideo#17399fad flags:# round_message:flags.0?true supports_streaming:flags.1?true nosound:flags.3?true duration:double w:int h:int preload_prefix_size:flags.2?int video_start_ts:flags.4?double = DocumentAttribute; +documentAttributeVideo#43c57c48 flags:# round_message:flags.0?true supports_streaming:flags.1?true nosound:flags.3?true duration:double w:int h:int preload_prefix_size:flags.2?int video_start_ts:flags.4?double video_codec:flags.5?string = DocumentAttribute; documentAttributeAudio#9852f9c6 flags:# voice:flags.10?true duration:int title:flags.0?string performer:flags.1?string waveform:flags.2?bytes = DocumentAttribute; @@ -1140,6 +1142,8 @@ keyboardButtonRequestPeer#53d7bfd8 text:string button_id:int peer_type:RequestPe inputKeyboardButtonRequestPeer#c9662d05 flags:# name_requested:flags.0?true username_requested:flags.1?true photo_requested:flags.2?true text:string button_id:int peer_type:RequestPeerType max_quantity:int = KeyboardButton; +keyboardButtonCopy#75d2698e text:string copy_text:string = KeyboardButton; + keyboardButtonRow#77608b83 buttons:Vector = KeyboardButtonRow; replyKeyboardHide#a03e5b85 flags:# selective:flags.2?true = ReplyMarkup; @@ -1544,6 +1548,8 @@ payments.paymentForm#a0058751 flags:# can_save_credentials:flags.2?true password 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.paymentFormStarGift#b425cfe1 form_id:long invoice:Invoice = payments.PaymentForm; + payments.validatedRequestedInfo#d1451883 flags:# id:flags.0?string shipping_options:flags.1?Vector = payments.ValidatedRequestedInfo; payments.paymentResult#4e5f810d updates:Updates = payments.PaymentResult; @@ -2266,6 +2272,8 @@ inputInvoiceStars#65f00ce3 purpose:InputStorePaymentPurpose = InputInvoice; inputInvoiceChatInviteSubscription#34e793f1 hash:string = InputInvoice; +inputInvoiceStarGift#25d8c1d8 flags:# hide_name:flags.0?true user_id:InputUser gift_id:long message:flags.1?TextWithEntities = 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; @@ -2700,7 +2708,7 @@ starsTransactionPeerAds#60682812 = StarsTransactionPeer; starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; -starsTransaction#ee7522d5 flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true reaction:flags.11?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector subscription_period:flags.12?int giveaway_post_id:flags.13?int = StarsTransaction; +starsTransaction#a9ee4c2 flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true reaction:flags.11?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector subscription_period:flags.12?int giveaway_post_id:flags.13?int stargift:flags.14?StarGift = StarsTransaction; payments.starsStatus#bbfa316c flags:# balance:long subscriptions:flags.1?Vector subscriptions_next_offset:flags.2?string subscriptions_missing_balance:flags.4?long history:flags.3?Vector next_offset:flags.0?string chats:Vector users:Vector = payments.StarsStatus; @@ -2738,6 +2746,24 @@ starsGiveawayOption#94ce852a flags:# extended:flags.0?true default:flags.1?true starsGiveawayWinnersOption#54236209 flags:# default:flags.0?true users:int per_user_stars:long = StarsGiveawayWinnersOption; +starGift#aea174ee flags:# limited:flags.0?true id:long sticker:Document stars:long availability_remains:flags.0?int availability_total:flags.0?int convert_stars:long = StarGift; + +payments.starGiftsNotModified#a388a368 = payments.StarGifts; + +payments.starGifts#901689ea hash:int gifts:Vector = payments.StarGifts; + +userStarGift#eea49a6e flags:# name_hidden:flags.0?true unsaved:flags.5?true from_id:flags.1?long date:int gift:StarGift message:flags.2?TextWithEntities msg_id:flags.3?int convert_stars:flags.4?long = UserStarGift; + +payments.userStarGifts#6b65b517 flags:# count:int gifts:Vector next_offset:flags.0?string users:Vector = payments.UserStarGifts; + +messageReportOption#7903e3d9 text:string option:bytes = MessageReportOption; + +reportResultChooseOption#f0e4e0b6 title:string options:Vector = ReportResult; + +reportResultAddComment#6f09ac31 flags:# optional:flags.0?true option:bytes = ReportResult; + +reportResultReported#8db33c4b = ReportResult; + ---functions--- @@ -3119,7 +3145,7 @@ messages.reportSpam#cf1592db peer:InputPeer = Bool; messages.getPeerSettings#efd9a6a2 peer:InputPeer = messages.PeerSettings; -messages.report#8953ab4e peer:InputPeer id:Vector reason:ReportReason message:string = Bool; +messages.report#fc78af9b peer:InputPeer id:Vector option:bytes message:string = ReportResult; messages.getChats#49e9528f id:Vector = messages.Chats; @@ -3717,7 +3743,7 @@ channels.reportAntiSpamFalsePositive#a850a693 channel:InputChannel msg_id:int = channels.toggleParticipantsHidden#6a6e7854 channel:InputChannel enabled:Bool = Updates; -channels.clickSponsoredMessage#18afbc93 channel:InputChannel random_id:bytes = Bool; +channels.clickSponsoredMessage#1445d75 flags:# media:flags.0?true fullscreen:flags.1?true channel:InputChannel random_id:bytes = Bool; channels.updateColor#d8aa3671 flags:# for_profile:flags.1?true channel:InputChannel color:flags.2?int background_emoji_id:flags.0?long = Updates; @@ -3821,7 +3847,7 @@ payments.getStarsStatus#104fcfa7 peer:InputPeer = payments.StarsStatus; payments.getStarsTransactions#69da4557 flags:# inbound:flags.0?true outbound:flags.1?true ascending:flags.2?true subscription_id:flags.3?string peer:InputPeer offset:string limit:int = payments.StarsStatus; -payments.sendStarsForm#2bb731d flags:# form_id:long invoice:InputInvoice = payments.PaymentResult; +payments.sendStarsForm#7998c914 form_id:long invoice:InputInvoice = payments.PaymentResult; payments.refundStarsCharge#25ae8f4a user_id:InputUser charge_id:string = Updates; @@ -3843,6 +3869,14 @@ payments.fulfillStarsSubscription#cc5bebb3 peer:InputPeer subscription_id:string payments.getStarsGiveawayOptions#bd1efd3e = Vector; +payments.getStarGifts#c4563590 hash:int = payments.StarGifts; + +payments.getUserStarGifts#5e72c7e1 user_id:InputUser offset:string limit:int = payments.UserStarGifts; + +payments.saveStarGift#87acf08e flags:# unsave:flags.0?true user_id:InputUser msg_id:int = Bool; + +payments.convertStarGift#421e027 user_id:InputUser msg_id:int = Bool; + 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; @@ -4011,7 +4045,7 @@ stories.getStoriesViews#28e16cc8 peer:InputPeer id:Vector = stories.StoryVi stories.exportStoryLink#7b8def20 peer:InputPeer id:int = ExportedStoryLink; -stories.report#1923fa8c peer:InputPeer id:Vector reason:ReportReason message:string = Bool; +stories.report#19d8eb45 peer:InputPeer id:Vector option:bytes message:string = ReportResult; stories.activateStealthMode#57bbd166 flags:# past:flags.0?true future:flags.1?true = Updates; @@ -4059,4 +4093,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 187 +// LAYER 189 diff --git a/_schema/telegram.tl b/_schema/telegram.tl index d5109b4366..97265ef4c9 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: 187 -// SHA256: 13e5ee643d6d776ab46f2cd1a21c9b274a4cb46106dea20770ebce90115e1e42 +// Layer: 189 +// SHA256: 274a71c5b60947275de376cce5cecb0a907181439ae6d53c54f4a0331c66be75 boolFalse#bc799737 = Bool; @@ -205,7 +205,7 @@ messageMediaContact#70322949 phone_number:string first_name:string last_name:str messageMediaUnsupported#9f84f49e = MessageMedia; -messageMediaDocument#4cf4d72d flags:# nopremium:flags.3?true spoiler:flags.4?true video:flags.6?true round:flags.7?true voice:flags.8?true document:flags.0?Document alt_document:flags.5?Document ttl_seconds:flags.2?int = MessageMedia; +messageMediaDocument#dd570bd5 flags:# nopremium:flags.3?true spoiler:flags.4?true video:flags.6?true round:flags.7?true voice:flags.8?true document:flags.0?Document alt_documents:flags.5?Vector ttl_seconds:flags.2?int = MessageMedia; messageMediaWebPage#ddf10c3b flags:# force_large_media:flags.0?true force_small_media:flags.1?true manual:flags.3?true safe:flags.4?true webpage:WebPage = MessageMedia; @@ -321,6 +321,8 @@ messageActionGiftStars#45d5b021 flags:# currency:string amount:long stars:long c messageActionPrizeStars#b00c47a2 flags:# unclaimed:flags.0?true stars:long transaction_id:string boost_peer:Peer giveaway_msg_id:int = MessageAction; +messageActionStarGift#9bb3ef44 flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true gift:StarGift message:flags.1?TextWithEntities convert_stars:long = MessageAction; + dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true view_forum_as_messages:flags.6?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -395,7 +397,7 @@ inputReportReasonIllegalDrugs#a8eb2be = ReportReason; inputReportReasonPersonalDetails#9ec7863d = ReportReason; -userFull#cc997720 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int = UserFull; +userFull#1f58e369 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int stargifts_count:flags2.8?int = UserFull; contact#145ade0b user_id:long mutual:Bool = Contact; @@ -985,7 +987,7 @@ documentAttributeAnimated#11b58939 = DocumentAttribute; documentAttributeSticker#6319d612 flags:# mask:flags.1?true alt:string stickerset:InputStickerSet mask_coords:flags.0?MaskCoords = DocumentAttribute; -documentAttributeVideo#17399fad flags:# round_message:flags.0?true supports_streaming:flags.1?true nosound:flags.3?true duration:double w:int h:int preload_prefix_size:flags.2?int video_start_ts:flags.4?double = DocumentAttribute; +documentAttributeVideo#43c57c48 flags:# round_message:flags.0?true supports_streaming:flags.1?true nosound:flags.3?true duration:double w:int h:int preload_prefix_size:flags.2?int video_start_ts:flags.4?double video_codec:flags.5?string = DocumentAttribute; documentAttributeAudio#9852f9c6 flags:# voice:flags.10?true duration:int title:flags.0?string performer:flags.1?string waveform:flags.2?bytes = DocumentAttribute; @@ -1105,6 +1107,8 @@ keyboardButtonRequestPeer#53d7bfd8 text:string button_id:int peer_type:RequestPe inputKeyboardButtonRequestPeer#c9662d05 flags:# name_requested:flags.0?true username_requested:flags.1?true photo_requested:flags.2?true text:string button_id:int peer_type:RequestPeerType max_quantity:int = KeyboardButton; +keyboardButtonCopy#75d2698e text:string copy_text:string = KeyboardButton; + keyboardButtonRow#77608b83 buttons:Vector = KeyboardButtonRow; replyKeyboardHide#a03e5b85 flags:# selective:flags.2?true = ReplyMarkup; @@ -1509,6 +1513,8 @@ payments.paymentForm#a0058751 flags:# can_save_credentials:flags.2?true password 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.paymentFormStarGift#b425cfe1 form_id:long invoice:Invoice = payments.PaymentForm; + payments.validatedRequestedInfo#d1451883 flags:# id:flags.0?string shipping_options:flags.1?Vector = payments.ValidatedRequestedInfo; payments.paymentResult#4e5f810d updates:Updates = payments.PaymentResult; @@ -2231,6 +2237,8 @@ inputInvoiceStars#65f00ce3 purpose:InputStorePaymentPurpose = InputInvoice; inputInvoiceChatInviteSubscription#34e793f1 hash:string = InputInvoice; +inputInvoiceStarGift#25d8c1d8 flags:# hide_name:flags.0?true user_id:InputUser gift_id:long message:flags.1?TextWithEntities = 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; @@ -2665,7 +2673,7 @@ starsTransactionPeerAds#60682812 = StarsTransactionPeer; starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; -starsTransaction#ee7522d5 flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true reaction:flags.11?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector subscription_period:flags.12?int giveaway_post_id:flags.13?int = StarsTransaction; +starsTransaction#a9ee4c2 flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true reaction:flags.11?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector subscription_period:flags.12?int giveaway_post_id:flags.13?int stargift:flags.14?StarGift = StarsTransaction; payments.starsStatus#bbfa316c flags:# balance:long subscriptions:flags.1?Vector subscriptions_next_offset:flags.2?string subscriptions_missing_balance:flags.4?long history:flags.3?Vector next_offset:flags.0?string chats:Vector users:Vector = payments.StarsStatus; @@ -2703,6 +2711,24 @@ starsGiveawayOption#94ce852a flags:# extended:flags.0?true default:flags.1?true starsGiveawayWinnersOption#54236209 flags:# default:flags.0?true users:int per_user_stars:long = StarsGiveawayWinnersOption; +starGift#aea174ee flags:# limited:flags.0?true id:long sticker:Document stars:long availability_remains:flags.0?int availability_total:flags.0?int convert_stars:long = StarGift; + +payments.starGiftsNotModified#a388a368 = payments.StarGifts; + +payments.starGifts#901689ea hash:int gifts:Vector = payments.StarGifts; + +userStarGift#eea49a6e flags:# name_hidden:flags.0?true unsaved:flags.5?true from_id:flags.1?long date:int gift:StarGift message:flags.2?TextWithEntities msg_id:flags.3?int convert_stars:flags.4?long = UserStarGift; + +payments.userStarGifts#6b65b517 flags:# count:int gifts:Vector next_offset:flags.0?string users:Vector = payments.UserStarGifts; + +messageReportOption#7903e3d9 text:string option:bytes = MessageReportOption; + +reportResultChooseOption#f0e4e0b6 title:string options:Vector = ReportResult; + +reportResultAddComment#6f09ac31 flags:# optional:flags.0?true option:bytes = ReportResult; + +reportResultReported#8db33c4b = ReportResult; + ---functions--- @@ -3084,7 +3110,7 @@ messages.reportSpam#cf1592db peer:InputPeer = Bool; messages.getPeerSettings#efd9a6a2 peer:InputPeer = messages.PeerSettings; -messages.report#8953ab4e peer:InputPeer id:Vector reason:ReportReason message:string = Bool; +messages.report#fc78af9b peer:InputPeer id:Vector option:bytes message:string = ReportResult; messages.getChats#49e9528f id:Vector = messages.Chats; @@ -3682,7 +3708,7 @@ channels.reportAntiSpamFalsePositive#a850a693 channel:InputChannel msg_id:int = channels.toggleParticipantsHidden#6a6e7854 channel:InputChannel enabled:Bool = Updates; -channels.clickSponsoredMessage#18afbc93 channel:InputChannel random_id:bytes = Bool; +channels.clickSponsoredMessage#1445d75 flags:# media:flags.0?true fullscreen:flags.1?true channel:InputChannel random_id:bytes = Bool; channels.updateColor#d8aa3671 flags:# for_profile:flags.1?true channel:InputChannel color:flags.2?int background_emoji_id:flags.0?long = Updates; @@ -3786,7 +3812,7 @@ payments.getStarsStatus#104fcfa7 peer:InputPeer = payments.StarsStatus; payments.getStarsTransactions#69da4557 flags:# inbound:flags.0?true outbound:flags.1?true ascending:flags.2?true subscription_id:flags.3?string peer:InputPeer offset:string limit:int = payments.StarsStatus; -payments.sendStarsForm#2bb731d flags:# form_id:long invoice:InputInvoice = payments.PaymentResult; +payments.sendStarsForm#7998c914 form_id:long invoice:InputInvoice = payments.PaymentResult; payments.refundStarsCharge#25ae8f4a user_id:InputUser charge_id:string = Updates; @@ -3808,6 +3834,14 @@ payments.fulfillStarsSubscription#cc5bebb3 peer:InputPeer subscription_id:string payments.getStarsGiveawayOptions#bd1efd3e = Vector; +payments.getStarGifts#c4563590 hash:int = payments.StarGifts; + +payments.getUserStarGifts#5e72c7e1 user_id:InputUser offset:string limit:int = payments.UserStarGifts; + +payments.saveStarGift#87acf08e flags:# unsave:flags.0?true user_id:InputUser msg_id:int = Bool; + +payments.convertStarGift#421e027 user_id:InputUser msg_id:int = Bool; + 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; @@ -3976,7 +4010,7 @@ stories.getStoriesViews#28e16cc8 peer:InputPeer id:Vector = stories.StoryVi stories.exportStoryLink#7b8def20 peer:InputPeer id:int = ExportedStoryLink; -stories.report#1923fa8c peer:InputPeer id:Vector reason:ReportReason message:string = Bool; +stories.report#19d8eb45 peer:InputPeer id:Vector option:bytes message:string = ReportResult; stories.activateStealthMode#57bbd166 flags:# past:flags.0?true future:flags.1?true = Updates; @@ -4056,4 +4090,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 187 +// LAYER 189 diff --git a/telegram/message/report.go b/telegram/message/report.go index 5660c9c595..ee2c2c50f9 100644 --- a/telegram/message/report.go +++ b/telegram/message/report.go @@ -22,58 +22,23 @@ func (b *ReportBuilder) Message(msg string) *ReportBuilder { return b } -func (b *ReportBuilder) send(ctx context.Context, reason tg.ReportReasonClass) (bool, error) { +func (b *ReportBuilder) send(ctx context.Context, option []byte) (tg.ReportResultClass, error) { p, err := b.peer(ctx) if err != nil { - return false, errors.Wrap(err, "peer") + return nil, errors.Wrap(err, "peer") } return b.sender.report(ctx, &tg.MessagesReportRequest{ Peer: p, ID: b.ids, - Reason: reason, + Option: option, Message: b.message, }) } -// Spam sends report for spam. -func (b *ReportBuilder) Spam(ctx context.Context) (bool, error) { - return b.send(ctx, &tg.InputReportReasonSpam{}) -} - -// Violence sends report for violence. -func (b *ReportBuilder) Violence(ctx context.Context) (bool, error) { - return b.send(ctx, &tg.InputReportReasonViolence{}) -} - -// Pornography sends report for pornography. -func (b *ReportBuilder) Pornography(ctx context.Context) (bool, error) { - return b.send(ctx, &tg.InputReportReasonPornography{}) -} - -// ChildAbuse sends report for child abuse. -func (b *ReportBuilder) ChildAbuse(ctx context.Context) (bool, error) { - return b.send(ctx, &tg.InputReportReasonChildAbuse{}) -} - -// Other sends report for other. -func (b *ReportBuilder) Other(ctx context.Context) (bool, error) { - return b.send(ctx, &tg.InputReportReasonOther{}) -} - -// Copyright sends report for copyrighted content. -func (b *ReportBuilder) Copyright(ctx context.Context) (bool, error) { - return b.send(ctx, &tg.InputReportReasonCopyright{}) -} - -// GeoIrrelevant sends report for irrelevant geogroup. -func (b *ReportBuilder) GeoIrrelevant(ctx context.Context) (bool, error) { - return b.send(ctx, &tg.InputReportReasonGeoIrrelevant{}) -} - -// Fake sends report for fake. -func (b *ReportBuilder) Fake(ctx context.Context) (bool, error) { - return b.send(ctx, &tg.InputReportReasonFake{}) +// Option sends report with provided option field. +func (b *ReportBuilder) Option(ctx context.Context, option []byte) (tg.ReportResultClass, error) { + return b.send(ctx, option) } // Report reports messages in a chat for violation of Telegram's Terms of Service. diff --git a/telegram/message/report_test.go b/telegram/message/report_test.go index 3251689168..db91c1140a 100644 --- a/telegram/message/report_test.go +++ b/telegram/message/report_test.go @@ -14,16 +14,16 @@ import ( "github.com/gotd/td/tgmock" ) -func expectSendReport(t *testing.T, reason tg.ReportReasonClass, mock *tgmock.Mock, id int, msg string) { +func expectSendReport(t *testing.T, option []byte, mock *tgmock.Mock, id int, msg string) { mock.ExpectFunc(func(b bin.Encoder) { req, ok := b.(*tg.MessagesReportRequest) require.True(t, ok) require.Equal(t, &tg.InputPeerSelf{}, req.Peer) - require.Equal(t, reason, req.Reason) + require.Equal(t, option, req.Option) require.NotZero(t, req.ID) require.Equal(t, id, req.ID[0]) require.Equal(t, msg, req.Message) - }).ThenTrue() + }).ThenResult(&tg.ReportResultReported{}) } func TestRequestBuilder_Report(t *testing.T) { @@ -37,39 +37,11 @@ func TestRequestBuilder_Report(t *testing.T) { report := sender.Self().Report(id).Message(msg) - var r bool - expectSendReport(t, &tg.InputReportReasonSpam{}, mock, id, msg) - r, err = report.Spam(ctx) - require.NoError(t, err) - require.True(t, r) - expectSendReport(t, &tg.InputReportReasonViolence{}, mock, id, msg) - r, err = report.Violence(ctx) - require.NoError(t, err) - require.True(t, r) - expectSendReport(t, &tg.InputReportReasonPornography{}, mock, id, msg) - r, err = report.Pornography(ctx) - require.NoError(t, err) - require.True(t, r) - expectSendReport(t, &tg.InputReportReasonChildAbuse{}, mock, id, msg) - r, err = report.ChildAbuse(ctx) - require.NoError(t, err) - require.True(t, r) - expectSendReport(t, &tg.InputReportReasonOther{}, mock, id, msg) - r, err = report.Other(ctx) - require.NoError(t, err) - require.True(t, r) - expectSendReport(t, &tg.InputReportReasonCopyright{}, mock, id, msg) - r, err = report.Copyright(ctx) - require.NoError(t, err) - require.True(t, r) - expectSendReport(t, &tg.InputReportReasonGeoIrrelevant{}, mock, id, msg) - r, err = report.GeoIrrelevant(ctx) - require.NoError(t, err) - require.True(t, r) - expectSendReport(t, &tg.InputReportReasonFake{}, mock, id, msg) - r, err = report.Fake(ctx) + option := []byte{1, 2, 3} + expectSendReport(t, option, mock, id, msg) + r, err := report.Option(ctx, option) require.NoError(t, err) - require.True(t, r) + require.NotNil(t, r) } func TestRequestBuilder_ReportSpam(t *testing.T) { diff --git a/telegram/message/sender.go b/telegram/message/sender.go index 21238ee8b1..2df3b83109 100644 --- a/telegram/message/sender.go +++ b/telegram/message/sender.go @@ -160,7 +160,7 @@ func (s *Sender) setTyping(ctx context.Context, req *tg.MessagesSetTypingRequest } // report reports a message in a chat for violation of Telegram's Terms of Service. -func (s *Sender) report(ctx context.Context, req *tg.MessagesReportRequest) (bool, error) { +func (s *Sender) report(ctx context.Context, req *tg.MessagesReportRequest) (tg.ReportResultClass, error) { return s.raw.MessagesReport(ctx, req) } diff --git a/tg/tl_channels_click_sponsored_message_gen.go b/tg/tl_channels_click_sponsored_message_gen.go index 099196584c..b5cd28419a 100644 --- a/tg/tl_channels_click_sponsored_message_gen.go +++ b/tg/tl_channels_click_sponsored_message_gen.go @@ -31,11 +31,17 @@ var ( _ = tdjson.Encoder{} ) -// ChannelsClickSponsoredMessageRequest represents TL type `channels.clickSponsoredMessage#18afbc93`. +// ChannelsClickSponsoredMessageRequest represents TL type `channels.clickSponsoredMessage#1445d75`. // Informs the server that the user has either: // // See https://core.telegram.org/method/channels.clickSponsoredMessage for reference. type ChannelsClickSponsoredMessageRequest struct { + // Flags field of ChannelsClickSponsoredMessageRequest. + Flags bin.Fields + // Media field of ChannelsClickSponsoredMessageRequest. + Media bool + // Fullscreen field of ChannelsClickSponsoredMessageRequest. + Fullscreen bool // Channel where the sponsored message was posted Channel InputChannelClass // Message ID @@ -43,7 +49,7 @@ type ChannelsClickSponsoredMessageRequest struct { } // ChannelsClickSponsoredMessageRequestTypeID is TL type id of ChannelsClickSponsoredMessageRequest. -const ChannelsClickSponsoredMessageRequestTypeID = 0x18afbc93 +const ChannelsClickSponsoredMessageRequestTypeID = 0x1445d75 // Ensuring interfaces in compile-time for ChannelsClickSponsoredMessageRequest. var ( @@ -57,6 +63,15 @@ func (c *ChannelsClickSponsoredMessageRequest) Zero() bool { if c == nil { return true } + if !(c.Flags.Zero()) { + return false + } + if !(c.Media == false) { + return false + } + if !(c.Fullscreen == false) { + return false + } if !(c.Channel == nil) { return false } @@ -78,9 +93,13 @@ func (c *ChannelsClickSponsoredMessageRequest) String() string { // FillFrom fills ChannelsClickSponsoredMessageRequest from given interface. func (c *ChannelsClickSponsoredMessageRequest) FillFrom(from interface { + GetMedia() (value bool) + GetFullscreen() (value bool) GetChannel() (value InputChannelClass) GetRandomID() (value []byte) }) { + c.Media = from.GetMedia() + c.Fullscreen = from.GetFullscreen() c.Channel = from.GetChannel() c.RandomID = from.GetRandomID() } @@ -108,6 +127,16 @@ func (c *ChannelsClickSponsoredMessageRequest) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Media", + SchemaName: "media", + Null: !c.Flags.Has(0), + }, + { + Name: "Fullscreen", + SchemaName: "fullscreen", + Null: !c.Flags.Has(1), + }, { Name: "Channel", SchemaName: "channel", @@ -120,10 +149,20 @@ func (c *ChannelsClickSponsoredMessageRequest) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (c *ChannelsClickSponsoredMessageRequest) SetFlags() { + if !(c.Media == false) { + c.Flags.Set(0) + } + if !(c.Fullscreen == false) { + c.Flags.Set(1) + } +} + // Encode implements bin.Encoder. func (c *ChannelsClickSponsoredMessageRequest) Encode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channels.clickSponsoredMessage#18afbc93 as nil") + return fmt.Errorf("can't encode channels.clickSponsoredMessage#1445d75 as nil") } b.PutID(ChannelsClickSponsoredMessageRequestTypeID) return c.EncodeBare(b) @@ -132,13 +171,17 @@ func (c *ChannelsClickSponsoredMessageRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (c *ChannelsClickSponsoredMessageRequest) EncodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channels.clickSponsoredMessage#18afbc93 as nil") + return fmt.Errorf("can't encode channels.clickSponsoredMessage#1445d75 as nil") + } + c.SetFlags() + if err := c.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.clickSponsoredMessage#1445d75: field flags: %w", err) } if c.Channel == nil { - return fmt.Errorf("unable to encode channels.clickSponsoredMessage#18afbc93: field channel is nil") + return fmt.Errorf("unable to encode channels.clickSponsoredMessage#1445d75: field channel is nil") } if err := c.Channel.Encode(b); err != nil { - return fmt.Errorf("unable to encode channels.clickSponsoredMessage#18afbc93: field channel: %w", err) + return fmt.Errorf("unable to encode channels.clickSponsoredMessage#1445d75: field channel: %w", err) } b.PutBytes(c.RandomID) return nil @@ -147,10 +190,10 @@ func (c *ChannelsClickSponsoredMessageRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (c *ChannelsClickSponsoredMessageRequest) Decode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channels.clickSponsoredMessage#18afbc93 to nil") + return fmt.Errorf("can't decode channels.clickSponsoredMessage#1445d75 to nil") } if err := b.ConsumeID(ChannelsClickSponsoredMessageRequestTypeID); err != nil { - return fmt.Errorf("unable to decode channels.clickSponsoredMessage#18afbc93: %w", err) + return fmt.Errorf("unable to decode channels.clickSponsoredMessage#1445d75: %w", err) } return c.DecodeBare(b) } @@ -158,25 +201,70 @@ func (c *ChannelsClickSponsoredMessageRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (c *ChannelsClickSponsoredMessageRequest) DecodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channels.clickSponsoredMessage#18afbc93 to nil") + return fmt.Errorf("can't decode channels.clickSponsoredMessage#1445d75 to nil") + } + { + if err := c.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode channels.clickSponsoredMessage#1445d75: field flags: %w", err) + } } + c.Media = c.Flags.Has(0) + c.Fullscreen = c.Flags.Has(1) { value, err := DecodeInputChannel(b) if err != nil { - return fmt.Errorf("unable to decode channels.clickSponsoredMessage#18afbc93: field channel: %w", err) + return fmt.Errorf("unable to decode channels.clickSponsoredMessage#1445d75: field channel: %w", err) } c.Channel = value } { value, err := b.Bytes() if err != nil { - return fmt.Errorf("unable to decode channels.clickSponsoredMessage#18afbc93: field random_id: %w", err) + return fmt.Errorf("unable to decode channels.clickSponsoredMessage#1445d75: field random_id: %w", err) } c.RandomID = value } return nil } +// SetMedia sets value of Media conditional field. +func (c *ChannelsClickSponsoredMessageRequest) SetMedia(value bool) { + if value { + c.Flags.Set(0) + c.Media = true + } else { + c.Flags.Unset(0) + c.Media = false + } +} + +// GetMedia returns value of Media conditional field. +func (c *ChannelsClickSponsoredMessageRequest) GetMedia() (value bool) { + if c == nil { + return + } + return c.Flags.Has(0) +} + +// SetFullscreen sets value of Fullscreen conditional field. +func (c *ChannelsClickSponsoredMessageRequest) SetFullscreen(value bool) { + if value { + c.Flags.Set(1) + c.Fullscreen = true + } else { + c.Flags.Unset(1) + c.Fullscreen = false + } +} + +// GetFullscreen returns value of Fullscreen conditional field. +func (c *ChannelsClickSponsoredMessageRequest) GetFullscreen() (value bool) { + if c == nil { + return + } + return c.Flags.Has(1) +} + // GetChannel returns value of Channel field. func (c *ChannelsClickSponsoredMessageRequest) GetChannel() (value InputChannelClass) { if c == nil { @@ -198,7 +286,7 @@ func (c *ChannelsClickSponsoredMessageRequest) GetChannelAsNotEmpty() (NotEmptyI return c.Channel.AsNotEmpty() } -// ChannelsClickSponsoredMessage invokes method channels.clickSponsoredMessage#18afbc93 returning error if any. +// ChannelsClickSponsoredMessage invokes method channels.clickSponsoredMessage#1445d75 returning error if any. // Informs the server that the user has either: // // Possible errors: diff --git a/tg/tl_document_attribute_gen.go b/tg/tl_document_attribute_gen.go index d6183ac264..e051e79368 100644 --- a/tg/tl_document_attribute_gen.go +++ b/tg/tl_document_attribute_gen.go @@ -566,7 +566,7 @@ func (d *DocumentAttributeSticker) GetMaskCoords() (value MaskCoords, ok bool) { return d.MaskCoords, true } -// DocumentAttributeVideo represents TL type `documentAttributeVideo#17399fad`. +// DocumentAttributeVideo represents TL type `documentAttributeVideo#43c57c48`. // Defines a video // // See https://core.telegram.org/constructor/documentAttributeVideo for reference. @@ -601,10 +601,14 @@ type DocumentAttributeVideo struct { // // Use SetVideoStartTs and GetVideoStartTs helpers. VideoStartTs float64 + // VideoCodec field of DocumentAttributeVideo. + // + // Use SetVideoCodec and GetVideoCodec helpers. + VideoCodec string } // DocumentAttributeVideoTypeID is TL type id of DocumentAttributeVideo. -const DocumentAttributeVideoTypeID = 0x17399fad +const DocumentAttributeVideoTypeID = 0x43c57c48 // construct implements constructor of DocumentAttributeClass. func (d DocumentAttributeVideo) construct() DocumentAttributeClass { return &d } @@ -650,6 +654,9 @@ func (d *DocumentAttributeVideo) Zero() bool { if !(d.VideoStartTs == 0) { return false } + if !(d.VideoCodec == "") { + return false + } return true } @@ -673,6 +680,7 @@ func (d *DocumentAttributeVideo) FillFrom(from interface { GetH() (value int) GetPreloadPrefixSize() (value int, ok bool) GetVideoStartTs() (value float64, ok bool) + GetVideoCodec() (value string, ok bool) }) { d.RoundMessage = from.GetRoundMessage() d.SupportsStreaming = from.GetSupportsStreaming() @@ -688,6 +696,10 @@ func (d *DocumentAttributeVideo) FillFrom(from interface { d.VideoStartTs = val } + if val, ok := from.GetVideoCodec(); ok { + d.VideoCodec = val + } + } // TypeID returns type id in TL schema. @@ -750,6 +762,11 @@ func (d *DocumentAttributeVideo) TypeInfo() tdp.Type { SchemaName: "video_start_ts", Null: !d.Flags.Has(4), }, + { + Name: "VideoCodec", + SchemaName: "video_codec", + Null: !d.Flags.Has(5), + }, } return typ } @@ -771,12 +788,15 @@ func (d *DocumentAttributeVideo) SetFlags() { if !(d.VideoStartTs == 0) { d.Flags.Set(4) } + if !(d.VideoCodec == "") { + d.Flags.Set(5) + } } // Encode implements bin.Encoder. func (d *DocumentAttributeVideo) Encode(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't encode documentAttributeVideo#17399fad as nil") + return fmt.Errorf("can't encode documentAttributeVideo#43c57c48 as nil") } b.PutID(DocumentAttributeVideoTypeID) return d.EncodeBare(b) @@ -785,11 +805,11 @@ func (d *DocumentAttributeVideo) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (d *DocumentAttributeVideo) EncodeBare(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't encode documentAttributeVideo#17399fad as nil") + return fmt.Errorf("can't encode documentAttributeVideo#43c57c48 as nil") } d.SetFlags() if err := d.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode documentAttributeVideo#17399fad: field flags: %w", err) + return fmt.Errorf("unable to encode documentAttributeVideo#43c57c48: field flags: %w", err) } b.PutDouble(d.Duration) b.PutInt(d.W) @@ -800,16 +820,19 @@ func (d *DocumentAttributeVideo) EncodeBare(b *bin.Buffer) error { if d.Flags.Has(4) { b.PutDouble(d.VideoStartTs) } + if d.Flags.Has(5) { + b.PutString(d.VideoCodec) + } return nil } // Decode implements bin.Decoder. func (d *DocumentAttributeVideo) Decode(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't decode documentAttributeVideo#17399fad to nil") + return fmt.Errorf("can't decode documentAttributeVideo#43c57c48 to nil") } if err := b.ConsumeID(DocumentAttributeVideoTypeID); err != nil { - return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: %w", err) + return fmt.Errorf("unable to decode documentAttributeVideo#43c57c48: %w", err) } return d.DecodeBare(b) } @@ -817,11 +840,11 @@ func (d *DocumentAttributeVideo) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (d *DocumentAttributeVideo) DecodeBare(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't decode documentAttributeVideo#17399fad to nil") + return fmt.Errorf("can't decode documentAttributeVideo#43c57c48 to nil") } { if err := d.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: field flags: %w", err) + return fmt.Errorf("unable to decode documentAttributeVideo#43c57c48: field flags: %w", err) } } d.RoundMessage = d.Flags.Has(0) @@ -830,38 +853,45 @@ func (d *DocumentAttributeVideo) DecodeBare(b *bin.Buffer) error { { value, err := b.Double() if err != nil { - return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: field duration: %w", err) + return fmt.Errorf("unable to decode documentAttributeVideo#43c57c48: field duration: %w", err) } d.Duration = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: field w: %w", err) + return fmt.Errorf("unable to decode documentAttributeVideo#43c57c48: field w: %w", err) } d.W = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: field h: %w", err) + return fmt.Errorf("unable to decode documentAttributeVideo#43c57c48: field h: %w", err) } d.H = value } if d.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: field preload_prefix_size: %w", err) + return fmt.Errorf("unable to decode documentAttributeVideo#43c57c48: field preload_prefix_size: %w", err) } d.PreloadPrefixSize = value } if d.Flags.Has(4) { value, err := b.Double() if err != nil { - return fmt.Errorf("unable to decode documentAttributeVideo#17399fad: field video_start_ts: %w", err) + return fmt.Errorf("unable to decode documentAttributeVideo#43c57c48: field video_start_ts: %w", err) } d.VideoStartTs = value } + if d.Flags.Has(5) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode documentAttributeVideo#43c57c48: field video_codec: %w", err) + } + d.VideoCodec = value + } return nil } @@ -982,6 +1012,24 @@ func (d *DocumentAttributeVideo) GetVideoStartTs() (value float64, ok bool) { return d.VideoStartTs, true } +// SetVideoCodec sets value of VideoCodec conditional field. +func (d *DocumentAttributeVideo) SetVideoCodec(value string) { + d.Flags.Set(5) + d.VideoCodec = value +} + +// GetVideoCodec returns value of VideoCodec conditional field and +// boolean which is true if field was set. +func (d *DocumentAttributeVideo) GetVideoCodec() (value string, ok bool) { + if d == nil { + return + } + if !d.Flags.Has(5) { + return value, false + } + return d.VideoCodec, true +} + // DocumentAttributeAudio represents TL type `documentAttributeAudio#9852f9c6`. // Represents an audio file // @@ -1835,7 +1883,7 @@ const DocumentAttributeClassName = "DocumentAttribute" // case *tg.DocumentAttributeImageSize: // documentAttributeImageSize#6c37c15c // case *tg.DocumentAttributeAnimated: // documentAttributeAnimated#11b58939 // case *tg.DocumentAttributeSticker: // documentAttributeSticker#6319d612 -// case *tg.DocumentAttributeVideo: // documentAttributeVideo#17399fad +// case *tg.DocumentAttributeVideo: // documentAttributeVideo#43c57c48 // case *tg.DocumentAttributeAudio: // documentAttributeAudio#9852f9c6 // case *tg.DocumentAttributeFilename: // documentAttributeFilename#15590068 // case *tg.DocumentAttributeHasStickers: // documentAttributeHasStickers#9801d2f7 @@ -1890,7 +1938,7 @@ func DecodeDocumentAttribute(buf *bin.Buffer) (DocumentAttributeClass, error) { } return &v, nil case DocumentAttributeVideoTypeID: - // Decoding documentAttributeVideo#17399fad. + // Decoding documentAttributeVideo#43c57c48. v := DocumentAttributeVideo{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode DocumentAttributeClass: %w", err) diff --git a/tg/tl_input_invoice_gen.go b/tg/tl_input_invoice_gen.go index db48d094fb..63beb499a1 100644 --- a/tg/tl_input_invoice_gen.go +++ b/tg/tl_input_invoice_gen.go @@ -809,6 +809,273 @@ func (i *InputInvoiceChatInviteSubscription) GetHash() (value string) { return i.Hash } +// InputInvoiceStarGift represents TL type `inputInvoiceStarGift#25d8c1d8`. +// +// See https://core.telegram.org/constructor/inputInvoiceStarGift for reference. +type InputInvoiceStarGift struct { + // Flags field of InputInvoiceStarGift. + Flags bin.Fields + // HideName field of InputInvoiceStarGift. + HideName bool + // UserID field of InputInvoiceStarGift. + UserID InputUserClass + // GiftID field of InputInvoiceStarGift. + GiftID int64 + // Message field of InputInvoiceStarGift. + // + // Use SetMessage and GetMessage helpers. + Message TextWithEntities +} + +// InputInvoiceStarGiftTypeID is TL type id of InputInvoiceStarGift. +const InputInvoiceStarGiftTypeID = 0x25d8c1d8 + +// construct implements constructor of InputInvoiceClass. +func (i InputInvoiceStarGift) construct() InputInvoiceClass { return &i } + +// Ensuring interfaces in compile-time for InputInvoiceStarGift. +var ( + _ bin.Encoder = &InputInvoiceStarGift{} + _ bin.Decoder = &InputInvoiceStarGift{} + _ bin.BareEncoder = &InputInvoiceStarGift{} + _ bin.BareDecoder = &InputInvoiceStarGift{} + + _ InputInvoiceClass = &InputInvoiceStarGift{} +) + +func (i *InputInvoiceStarGift) Zero() bool { + if i == nil { + return true + } + if !(i.Flags.Zero()) { + return false + } + if !(i.HideName == false) { + return false + } + if !(i.UserID == nil) { + return false + } + if !(i.GiftID == 0) { + return false + } + if !(i.Message.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputInvoiceStarGift) String() string { + if i == nil { + return "InputInvoiceStarGift(nil)" + } + type Alias InputInvoiceStarGift + return fmt.Sprintf("InputInvoiceStarGift%+v", Alias(*i)) +} + +// FillFrom fills InputInvoiceStarGift from given interface. +func (i *InputInvoiceStarGift) FillFrom(from interface { + GetHideName() (value bool) + GetUserID() (value InputUserClass) + GetGiftID() (value int64) + GetMessage() (value TextWithEntities, ok bool) +}) { + i.HideName = from.GetHideName() + i.UserID = from.GetUserID() + i.GiftID = from.GetGiftID() + if val, ok := from.GetMessage(); ok { + i.Message = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputInvoiceStarGift) TypeID() uint32 { + return InputInvoiceStarGiftTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputInvoiceStarGift) TypeName() string { + return "inputInvoiceStarGift" +} + +// TypeInfo returns info about TL type. +func (i *InputInvoiceStarGift) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputInvoiceStarGift", + ID: InputInvoiceStarGiftTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "HideName", + SchemaName: "hide_name", + Null: !i.Flags.Has(0), + }, + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "GiftID", + SchemaName: "gift_id", + }, + { + Name: "Message", + SchemaName: "message", + Null: !i.Flags.Has(1), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (i *InputInvoiceStarGift) SetFlags() { + if !(i.HideName == false) { + i.Flags.Set(0) + } + if !(i.Message.Zero()) { + i.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (i *InputInvoiceStarGift) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputInvoiceStarGift#25d8c1d8 as nil") + } + b.PutID(InputInvoiceStarGiftTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputInvoiceStarGift) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputInvoiceStarGift#25d8c1d8 as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputInvoiceStarGift#25d8c1d8: field flags: %w", err) + } + if i.UserID == nil { + return fmt.Errorf("unable to encode inputInvoiceStarGift#25d8c1d8: field user_id is nil") + } + if err := i.UserID.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputInvoiceStarGift#25d8c1d8: field user_id: %w", err) + } + b.PutLong(i.GiftID) + if i.Flags.Has(1) { + if err := i.Message.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputInvoiceStarGift#25d8c1d8: field message: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InputInvoiceStarGift) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputInvoiceStarGift#25d8c1d8 to nil") + } + if err := b.ConsumeID(InputInvoiceStarGiftTypeID); err != nil { + return fmt.Errorf("unable to decode inputInvoiceStarGift#25d8c1d8: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputInvoiceStarGift) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputInvoiceStarGift#25d8c1d8 to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputInvoiceStarGift#25d8c1d8: field flags: %w", err) + } + } + i.HideName = i.Flags.Has(0) + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode inputInvoiceStarGift#25d8c1d8: field user_id: %w", err) + } + i.UserID = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode inputInvoiceStarGift#25d8c1d8: field gift_id: %w", err) + } + i.GiftID = value + } + if i.Flags.Has(1) { + if err := i.Message.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputInvoiceStarGift#25d8c1d8: field message: %w", err) + } + } + return nil +} + +// SetHideName sets value of HideName conditional field. +func (i *InputInvoiceStarGift) SetHideName(value bool) { + if value { + i.Flags.Set(0) + i.HideName = true + } else { + i.Flags.Unset(0) + i.HideName = false + } +} + +// GetHideName returns value of HideName conditional field. +func (i *InputInvoiceStarGift) GetHideName() (value bool) { + if i == nil { + return + } + return i.Flags.Has(0) +} + +// GetUserID returns value of UserID field. +func (i *InputInvoiceStarGift) GetUserID() (value InputUserClass) { + if i == nil { + return + } + return i.UserID +} + +// GetGiftID returns value of GiftID field. +func (i *InputInvoiceStarGift) GetGiftID() (value int64) { + if i == nil { + return + } + return i.GiftID +} + +// SetMessage sets value of Message conditional field. +func (i *InputInvoiceStarGift) SetMessage(value TextWithEntities) { + i.Flags.Set(1) + i.Message = value +} + +// GetMessage returns value of Message conditional field and +// boolean which is true if field was set. +func (i *InputInvoiceStarGift) GetMessage() (value TextWithEntities, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(1) { + return value, false + } + return i.Message, true +} + // InputInvoiceClassName is schema name of InputInvoiceClass. const InputInvoiceClassName = "InputInvoice" @@ -828,6 +1095,7 @@ const InputInvoiceClassName = "InputInvoice" // case *tg.InputInvoicePremiumGiftCode: // inputInvoicePremiumGiftCode#98986c0d // case *tg.InputInvoiceStars: // inputInvoiceStars#65f00ce3 // case *tg.InputInvoiceChatInviteSubscription: // inputInvoiceChatInviteSubscription#34e793f1 +// case *tg.InputInvoiceStarGift: // inputInvoiceStarGift#25d8c1d8 // default: panic(v) // } type InputInvoiceClass interface { @@ -891,6 +1159,13 @@ func DecodeInputInvoice(buf *bin.Buffer) (InputInvoiceClass, error) { return nil, fmt.Errorf("unable to decode InputInvoiceClass: %w", err) } return &v, nil + case InputInvoiceStarGiftTypeID: + // Decoding inputInvoiceStarGift#25d8c1d8. + v := InputInvoiceStarGift{} + 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 cce3cea65c..2c74bd9b54 100644 --- a/tg/tl_input_invoice_slices_gen.go +++ b/tg/tl_input_invoice_slices_gen.go @@ -181,6 +181,19 @@ func (s InputInvoiceClassArray) AsInputInvoiceChatInviteSubscription() (to Input return to } +// AsInputInvoiceStarGift returns copy with only InputInvoiceStarGift constructors. +func (s InputInvoiceClassArray) AsInputInvoiceStarGift() (to InputInvoiceStarGiftArray) { + for _, elem := range s { + value, ok := elem.(*InputInvoiceStarGift) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // InputInvoiceMessageArray is adapter for slice of InputInvoiceMessage. type InputInvoiceMessageArray []InputInvoiceMessage @@ -590,3 +603,85 @@ func (s *InputInvoiceChatInviteSubscriptionArray) Pop() (v InputInvoiceChatInvit return v, true } + +// InputInvoiceStarGiftArray is adapter for slice of InputInvoiceStarGift. +type InputInvoiceStarGiftArray []InputInvoiceStarGift + +// Sort sorts slice of InputInvoiceStarGift. +func (s InputInvoiceStarGiftArray) Sort(less func(a, b InputInvoiceStarGift) bool) InputInvoiceStarGiftArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InputInvoiceStarGift. +func (s InputInvoiceStarGiftArray) SortStable(less func(a, b InputInvoiceStarGift) bool) InputInvoiceStarGiftArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InputInvoiceStarGift. +func (s InputInvoiceStarGiftArray) Retain(keep func(x InputInvoiceStarGift) bool) InputInvoiceStarGiftArray { + 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 InputInvoiceStarGiftArray) First() (v InputInvoiceStarGift, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputInvoiceStarGiftArray) Last() (v InputInvoiceStarGift, 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 *InputInvoiceStarGiftArray) PopFirst() (v InputInvoiceStarGift, 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 InputInvoiceStarGift + 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 *InputInvoiceStarGiftArray) Pop() (v InputInvoiceStarGift, 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_keyboard_button_gen.go b/tg/tl_keyboard_button_gen.go index 1e57a4c1c8..a758882625 100644 --- a/tg/tl_keyboard_button_gen.go +++ b/tg/tl_keyboard_button_gen.go @@ -3465,6 +3465,167 @@ func (i *InputKeyboardButtonRequestPeer) GetMaxQuantity() (value int) { return i.MaxQuantity } +// KeyboardButtonCopy represents TL type `keyboardButtonCopy#75d2698e`. +// +// See https://core.telegram.org/constructor/keyboardButtonCopy for reference. +type KeyboardButtonCopy struct { + // Text field of KeyboardButtonCopy. + Text string + // CopyText field of KeyboardButtonCopy. + CopyText string +} + +// KeyboardButtonCopyTypeID is TL type id of KeyboardButtonCopy. +const KeyboardButtonCopyTypeID = 0x75d2698e + +// construct implements constructor of KeyboardButtonClass. +func (k KeyboardButtonCopy) construct() KeyboardButtonClass { return &k } + +// Ensuring interfaces in compile-time for KeyboardButtonCopy. +var ( + _ bin.Encoder = &KeyboardButtonCopy{} + _ bin.Decoder = &KeyboardButtonCopy{} + _ bin.BareEncoder = &KeyboardButtonCopy{} + _ bin.BareDecoder = &KeyboardButtonCopy{} + + _ KeyboardButtonClass = &KeyboardButtonCopy{} +) + +func (k *KeyboardButtonCopy) Zero() bool { + if k == nil { + return true + } + if !(k.Text == "") { + return false + } + if !(k.CopyText == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (k *KeyboardButtonCopy) String() string { + if k == nil { + return "KeyboardButtonCopy(nil)" + } + type Alias KeyboardButtonCopy + return fmt.Sprintf("KeyboardButtonCopy%+v", Alias(*k)) +} + +// FillFrom fills KeyboardButtonCopy from given interface. +func (k *KeyboardButtonCopy) FillFrom(from interface { + GetText() (value string) + GetCopyText() (value string) +}) { + k.Text = from.GetText() + k.CopyText = from.GetCopyText() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*KeyboardButtonCopy) TypeID() uint32 { + return KeyboardButtonCopyTypeID +} + +// TypeName returns name of type in TL schema. +func (*KeyboardButtonCopy) TypeName() string { + return "keyboardButtonCopy" +} + +// TypeInfo returns info about TL type. +func (k *KeyboardButtonCopy) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "keyboardButtonCopy", + ID: KeyboardButtonCopyTypeID, + } + if k == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Text", + SchemaName: "text", + }, + { + Name: "CopyText", + SchemaName: "copy_text", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (k *KeyboardButtonCopy) Encode(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't encode keyboardButtonCopy#75d2698e as nil") + } + b.PutID(KeyboardButtonCopyTypeID) + return k.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (k *KeyboardButtonCopy) EncodeBare(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't encode keyboardButtonCopy#75d2698e as nil") + } + b.PutString(k.Text) + b.PutString(k.CopyText) + return nil +} + +// Decode implements bin.Decoder. +func (k *KeyboardButtonCopy) Decode(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't decode keyboardButtonCopy#75d2698e to nil") + } + if err := b.ConsumeID(KeyboardButtonCopyTypeID); err != nil { + return fmt.Errorf("unable to decode keyboardButtonCopy#75d2698e: %w", err) + } + return k.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (k *KeyboardButtonCopy) DecodeBare(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't decode keyboardButtonCopy#75d2698e to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode keyboardButtonCopy#75d2698e: field text: %w", err) + } + k.Text = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode keyboardButtonCopy#75d2698e: field copy_text: %w", err) + } + k.CopyText = value + } + return nil +} + +// GetText returns value of Text field. +func (k *KeyboardButtonCopy) GetText() (value string) { + if k == nil { + return + } + return k.Text +} + +// GetCopyText returns value of CopyText field. +func (k *KeyboardButtonCopy) GetCopyText() (value string) { + if k == nil { + return + } + return k.CopyText +} + // KeyboardButtonClassName is schema name of KeyboardButtonClass. const KeyboardButtonClassName = "KeyboardButton" @@ -3496,6 +3657,7 @@ const KeyboardButtonClassName = "KeyboardButton" // case *tg.KeyboardButtonSimpleWebView: // keyboardButtonSimpleWebView#a0c0505c // case *tg.KeyboardButtonRequestPeer: // keyboardButtonRequestPeer#53d7bfd8 // case *tg.InputKeyboardButtonRequestPeer: // inputKeyboardButtonRequestPeer#c9662d05 +// case *tg.KeyboardButtonCopy: // keyboardButtonCopy#75d2698e // default: panic(v) // } type KeyboardButtonClass interface { @@ -3646,6 +3808,13 @@ func DecodeKeyboardButton(buf *bin.Buffer) (KeyboardButtonClass, error) { return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) } return &v, nil + case KeyboardButtonCopyTypeID: + // Decoding keyboardButtonCopy#75d2698e. + v := KeyboardButtonCopy{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_keyboard_button_slices_gen.go b/tg/tl_keyboard_button_slices_gen.go index 6fa97ce117..3f83ff131b 100644 --- a/tg/tl_keyboard_button_slices_gen.go +++ b/tg/tl_keyboard_button_slices_gen.go @@ -337,6 +337,19 @@ func (s KeyboardButtonClassArray) AsInputKeyboardButtonRequestPeer() (to InputKe return to } +// AsKeyboardButtonCopy returns copy with only KeyboardButtonCopy constructors. +func (s KeyboardButtonClassArray) AsKeyboardButtonCopy() (to KeyboardButtonCopyArray) { + for _, elem := range s { + value, ok := elem.(*KeyboardButtonCopy) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // KeyboardButtonArray is adapter for slice of KeyboardButton. type KeyboardButtonArray []KeyboardButton @@ -1730,3 +1743,85 @@ func (s *InputKeyboardButtonRequestPeerArray) Pop() (v InputKeyboardButtonReques return v, true } + +// KeyboardButtonCopyArray is adapter for slice of KeyboardButtonCopy. +type KeyboardButtonCopyArray []KeyboardButtonCopy + +// Sort sorts slice of KeyboardButtonCopy. +func (s KeyboardButtonCopyArray) Sort(less func(a, b KeyboardButtonCopy) bool) KeyboardButtonCopyArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of KeyboardButtonCopy. +func (s KeyboardButtonCopyArray) SortStable(less func(a, b KeyboardButtonCopy) bool) KeyboardButtonCopyArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of KeyboardButtonCopy. +func (s KeyboardButtonCopyArray) Retain(keep func(x KeyboardButtonCopy) bool) KeyboardButtonCopyArray { + 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 KeyboardButtonCopyArray) First() (v KeyboardButtonCopy, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s KeyboardButtonCopyArray) Last() (v KeyboardButtonCopy, 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 *KeyboardButtonCopyArray) PopFirst() (v KeyboardButtonCopy, 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 KeyboardButtonCopy + 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 *KeyboardButtonCopyArray) Pop() (v KeyboardButtonCopy, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_message_action_gen.go b/tg/tl_message_action_gen.go index e19caf4539..8717d41053 100644 --- a/tg/tl_message_action_gen.go +++ b/tg/tl_message_action_gen.go @@ -9090,6 +9090,338 @@ func (m *MessageActionPrizeStars) GetGiveawayMsgID() (value int) { return m.GiveawayMsgID } +// MessageActionStarGift represents TL type `messageActionStarGift#9bb3ef44`. +// +// See https://core.telegram.org/constructor/messageActionStarGift for reference. +type MessageActionStarGift struct { + // Flags field of MessageActionStarGift. + Flags bin.Fields + // NameHidden field of MessageActionStarGift. + NameHidden bool + // Saved field of MessageActionStarGift. + Saved bool + // Converted field of MessageActionStarGift. + Converted bool + // Gift field of MessageActionStarGift. + Gift StarGift + // Message field of MessageActionStarGift. + // + // Use SetMessage and GetMessage helpers. + Message TextWithEntities + // ConvertStars field of MessageActionStarGift. + ConvertStars int64 +} + +// MessageActionStarGiftTypeID is TL type id of MessageActionStarGift. +const MessageActionStarGiftTypeID = 0x9bb3ef44 + +// construct implements constructor of MessageActionClass. +func (m MessageActionStarGift) construct() MessageActionClass { return &m } + +// Ensuring interfaces in compile-time for MessageActionStarGift. +var ( + _ bin.Encoder = &MessageActionStarGift{} + _ bin.Decoder = &MessageActionStarGift{} + _ bin.BareEncoder = &MessageActionStarGift{} + _ bin.BareDecoder = &MessageActionStarGift{} + + _ MessageActionClass = &MessageActionStarGift{} +) + +func (m *MessageActionStarGift) Zero() bool { + if m == nil { + return true + } + if !(m.Flags.Zero()) { + return false + } + if !(m.NameHidden == false) { + return false + } + if !(m.Saved == false) { + return false + } + if !(m.Converted == false) { + return false + } + if !(m.Gift.Zero()) { + return false + } + if !(m.Message.Zero()) { + return false + } + if !(m.ConvertStars == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageActionStarGift) String() string { + if m == nil { + return "MessageActionStarGift(nil)" + } + type Alias MessageActionStarGift + return fmt.Sprintf("MessageActionStarGift%+v", Alias(*m)) +} + +// FillFrom fills MessageActionStarGift from given interface. +func (m *MessageActionStarGift) FillFrom(from interface { + GetNameHidden() (value bool) + GetSaved() (value bool) + GetConverted() (value bool) + GetGift() (value StarGift) + GetMessage() (value TextWithEntities, ok bool) + GetConvertStars() (value int64) +}) { + m.NameHidden = from.GetNameHidden() + m.Saved = from.GetSaved() + m.Converted = from.GetConverted() + m.Gift = from.GetGift() + if val, ok := from.GetMessage(); ok { + m.Message = val + } + + m.ConvertStars = from.GetConvertStars() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageActionStarGift) TypeID() uint32 { + return MessageActionStarGiftTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageActionStarGift) TypeName() string { + return "messageActionStarGift" +} + +// TypeInfo returns info about TL type. +func (m *MessageActionStarGift) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageActionStarGift", + ID: MessageActionStarGiftTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "NameHidden", + SchemaName: "name_hidden", + Null: !m.Flags.Has(0), + }, + { + Name: "Saved", + SchemaName: "saved", + Null: !m.Flags.Has(2), + }, + { + Name: "Converted", + SchemaName: "converted", + Null: !m.Flags.Has(3), + }, + { + Name: "Gift", + SchemaName: "gift", + }, + { + Name: "Message", + SchemaName: "message", + Null: !m.Flags.Has(1), + }, + { + Name: "ConvertStars", + SchemaName: "convert_stars", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (m *MessageActionStarGift) SetFlags() { + if !(m.NameHidden == false) { + m.Flags.Set(0) + } + if !(m.Saved == false) { + m.Flags.Set(2) + } + if !(m.Converted == false) { + m.Flags.Set(3) + } + if !(m.Message.Zero()) { + m.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (m *MessageActionStarGift) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionStarGift#9bb3ef44 as nil") + } + b.PutID(MessageActionStarGiftTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageActionStarGift) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionStarGift#9bb3ef44 as nil") + } + m.SetFlags() + if err := m.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionStarGift#9bb3ef44: field flags: %w", err) + } + if err := m.Gift.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionStarGift#9bb3ef44: field gift: %w", err) + } + if m.Flags.Has(1) { + if err := m.Message.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionStarGift#9bb3ef44: field message: %w", err) + } + } + b.PutLong(m.ConvertStars) + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageActionStarGift) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionStarGift#9bb3ef44 to nil") + } + if err := b.ConsumeID(MessageActionStarGiftTypeID); err != nil { + return fmt.Errorf("unable to decode messageActionStarGift#9bb3ef44: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageActionStarGift) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionStarGift#9bb3ef44 to nil") + } + { + if err := m.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageActionStarGift#9bb3ef44: field flags: %w", err) + } + } + m.NameHidden = m.Flags.Has(0) + m.Saved = m.Flags.Has(2) + m.Converted = m.Flags.Has(3) + { + if err := m.Gift.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageActionStarGift#9bb3ef44: field gift: %w", err) + } + } + if m.Flags.Has(1) { + if err := m.Message.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageActionStarGift#9bb3ef44: field message: %w", err) + } + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messageActionStarGift#9bb3ef44: field convert_stars: %w", err) + } + m.ConvertStars = value + } + return nil +} + +// SetNameHidden sets value of NameHidden conditional field. +func (m *MessageActionStarGift) SetNameHidden(value bool) { + if value { + m.Flags.Set(0) + m.NameHidden = true + } else { + m.Flags.Unset(0) + m.NameHidden = false + } +} + +// GetNameHidden returns value of NameHidden conditional field. +func (m *MessageActionStarGift) GetNameHidden() (value bool) { + if m == nil { + return + } + return m.Flags.Has(0) +} + +// SetSaved sets value of Saved conditional field. +func (m *MessageActionStarGift) SetSaved(value bool) { + if value { + m.Flags.Set(2) + m.Saved = true + } else { + m.Flags.Unset(2) + m.Saved = false + } +} + +// GetSaved returns value of Saved conditional field. +func (m *MessageActionStarGift) GetSaved() (value bool) { + if m == nil { + return + } + return m.Flags.Has(2) +} + +// SetConverted sets value of Converted conditional field. +func (m *MessageActionStarGift) SetConverted(value bool) { + if value { + m.Flags.Set(3) + m.Converted = true + } else { + m.Flags.Unset(3) + m.Converted = false + } +} + +// GetConverted returns value of Converted conditional field. +func (m *MessageActionStarGift) GetConverted() (value bool) { + if m == nil { + return + } + return m.Flags.Has(3) +} + +// GetGift returns value of Gift field. +func (m *MessageActionStarGift) GetGift() (value StarGift) { + if m == nil { + return + } + return m.Gift +} + +// SetMessage sets value of Message conditional field. +func (m *MessageActionStarGift) SetMessage(value TextWithEntities) { + m.Flags.Set(1) + m.Message = value +} + +// GetMessage returns value of Message conditional field and +// boolean which is true if field was set. +func (m *MessageActionStarGift) GetMessage() (value TextWithEntities, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(1) { + return value, false + } + return m.Message, true +} + +// GetConvertStars returns value of ConvertStars field. +func (m *MessageActionStarGift) GetConvertStars() (value int64) { + if m == nil { + return + } + return m.ConvertStars +} + // MessageActionClassName is schema name of MessageActionClass. const MessageActionClassName = "MessageAction" @@ -9150,6 +9482,7 @@ const MessageActionClassName = "MessageAction" // case *tg.MessageActionPaymentRefunded: // messageActionPaymentRefunded#41b3e202 // case *tg.MessageActionGiftStars: // messageActionGiftStars#45d5b021 // case *tg.MessageActionPrizeStars: // messageActionPrizeStars#b00c47a2 +// case *tg.MessageActionStarGift: // messageActionStarGift#9bb3ef44 // default: panic(v) // } type MessageActionClass interface { @@ -9500,6 +9833,13 @@ func DecodeMessageAction(buf *bin.Buffer) (MessageActionClass, error) { return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) } return &v, nil + case MessageActionStarGiftTypeID: + // Decoding messageActionStarGift#9bb3ef44. + v := MessageActionStarGift{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode MessageActionClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_message_action_slices_gen.go b/tg/tl_message_action_slices_gen.go index c2c4a815b1..834750fa94 100644 --- a/tg/tl_message_action_slices_gen.go +++ b/tg/tl_message_action_slices_gen.go @@ -623,6 +623,19 @@ func (s MessageActionClassArray) AsMessageActionPrizeStars() (to MessageActionPr return to } +// AsMessageActionStarGift returns copy with only MessageActionStarGift constructors. +func (s MessageActionClassArray) AsMessageActionStarGift() (to MessageActionStarGiftArray) { + for _, elem := range s { + value, ok := elem.(*MessageActionStarGift) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // MessageActionChatCreateArray is adapter for slice of MessageActionChatCreate. type MessageActionChatCreateArray []MessageActionChatCreate @@ -3820,3 +3833,85 @@ func (s *MessageActionPrizeStarsArray) Pop() (v MessageActionPrizeStars, ok bool return v, true } + +// MessageActionStarGiftArray is adapter for slice of MessageActionStarGift. +type MessageActionStarGiftArray []MessageActionStarGift + +// Sort sorts slice of MessageActionStarGift. +func (s MessageActionStarGiftArray) Sort(less func(a, b MessageActionStarGift) bool) MessageActionStarGiftArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessageActionStarGift. +func (s MessageActionStarGiftArray) SortStable(less func(a, b MessageActionStarGift) bool) MessageActionStarGiftArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessageActionStarGift. +func (s MessageActionStarGiftArray) Retain(keep func(x MessageActionStarGift) bool) MessageActionStarGiftArray { + 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 MessageActionStarGiftArray) First() (v MessageActionStarGift, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessageActionStarGiftArray) Last() (v MessageActionStarGift, 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 *MessageActionStarGiftArray) PopFirst() (v MessageActionStarGift, 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 MessageActionStarGift + 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 *MessageActionStarGiftArray) Pop() (v MessageActionStarGift, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_message_media_gen.go b/tg/tl_message_media_gen.go index e408a3bfc1..8d39d50881 100644 --- a/tg/tl_message_media_gen.go +++ b/tg/tl_message_media_gen.go @@ -883,7 +883,7 @@ func (m *MessageMediaUnsupported) DecodeBare(b *bin.Buffer) error { return nil } -// MessageMediaDocument represents TL type `messageMediaDocument#4cf4d72d`. +// MessageMediaDocument represents TL type `messageMediaDocument#dd570bd5`. // Document (video, audio, voice, sticker, any media type except photo) // // See https://core.telegram.org/constructor/messageMediaDocument for reference. @@ -908,12 +908,10 @@ type MessageMediaDocument struct { // // Use SetDocument and GetDocument helpers. Document DocumentClass - // Currently only used for story videos, may contain an alternative version of the story - // video, explicitly encoded using H.264 (in MPEG4 transport) at a lower resolution than - // document. + // AltDocuments field of MessageMediaDocument. // - // Use SetAltDocument and GetAltDocument helpers. - AltDocument DocumentClass + // Use SetAltDocuments and GetAltDocuments helpers. + AltDocuments []DocumentClass // Time to live of self-destructing document // // Use SetTTLSeconds and GetTTLSeconds helpers. @@ -921,7 +919,7 @@ type MessageMediaDocument struct { } // MessageMediaDocumentTypeID is TL type id of MessageMediaDocument. -const MessageMediaDocumentTypeID = 0x4cf4d72d +const MessageMediaDocumentTypeID = 0xdd570bd5 // construct implements constructor of MessageMediaClass. func (m MessageMediaDocument) construct() MessageMediaClass { return &m } @@ -961,7 +959,7 @@ func (m *MessageMediaDocument) Zero() bool { if !(m.Document == nil) { return false } - if !(m.AltDocument == nil) { + if !(m.AltDocuments == nil) { return false } if !(m.TTLSeconds == 0) { @@ -988,7 +986,7 @@ func (m *MessageMediaDocument) FillFrom(from interface { GetRound() (value bool) GetVoice() (value bool) GetDocument() (value DocumentClass, ok bool) - GetAltDocument() (value DocumentClass, ok bool) + GetAltDocuments() (value []DocumentClass, ok bool) GetTTLSeconds() (value int, ok bool) }) { m.Nopremium = from.GetNopremium() @@ -1000,8 +998,8 @@ func (m *MessageMediaDocument) FillFrom(from interface { m.Document = val } - if val, ok := from.GetAltDocument(); ok { - m.AltDocument = val + if val, ok := from.GetAltDocuments(); ok { + m.AltDocuments = val } if val, ok := from.GetTTLSeconds(); ok { @@ -1064,8 +1062,8 @@ func (m *MessageMediaDocument) TypeInfo() tdp.Type { Null: !m.Flags.Has(0), }, { - Name: "AltDocument", - SchemaName: "alt_document", + Name: "AltDocuments", + SchemaName: "alt_documents", Null: !m.Flags.Has(5), }, { @@ -1097,7 +1095,7 @@ func (m *MessageMediaDocument) SetFlags() { if !(m.Document == nil) { m.Flags.Set(0) } - if !(m.AltDocument == nil) { + if !(m.AltDocuments == nil) { m.Flags.Set(5) } if !(m.TTLSeconds == 0) { @@ -1108,7 +1106,7 @@ func (m *MessageMediaDocument) SetFlags() { // Encode implements bin.Encoder. func (m *MessageMediaDocument) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageMediaDocument#4cf4d72d as nil") + return fmt.Errorf("can't encode messageMediaDocument#dd570bd5 as nil") } b.PutID(MessageMediaDocumentTypeID) return m.EncodeBare(b) @@ -1117,26 +1115,29 @@ func (m *MessageMediaDocument) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *MessageMediaDocument) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageMediaDocument#4cf4d72d as nil") + return fmt.Errorf("can't encode messageMediaDocument#dd570bd5 as nil") } m.SetFlags() if err := m.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageMediaDocument#4cf4d72d: field flags: %w", err) + return fmt.Errorf("unable to encode messageMediaDocument#dd570bd5: field flags: %w", err) } if m.Flags.Has(0) { if m.Document == nil { - return fmt.Errorf("unable to encode messageMediaDocument#4cf4d72d: field document is nil") + return fmt.Errorf("unable to encode messageMediaDocument#dd570bd5: field document is nil") } if err := m.Document.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageMediaDocument#4cf4d72d: field document: %w", err) + return fmt.Errorf("unable to encode messageMediaDocument#dd570bd5: field document: %w", err) } } if m.Flags.Has(5) { - if m.AltDocument == nil { - return fmt.Errorf("unable to encode messageMediaDocument#4cf4d72d: field alt_document is nil") - } - if err := m.AltDocument.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageMediaDocument#4cf4d72d: field alt_document: %w", err) + b.PutVectorHeader(len(m.AltDocuments)) + for idx, v := range m.AltDocuments { + if v == nil { + return fmt.Errorf("unable to encode messageMediaDocument#dd570bd5: field alt_documents element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageMediaDocument#dd570bd5: field alt_documents element with index %d: %w", idx, err) + } } } if m.Flags.Has(2) { @@ -1148,10 +1149,10 @@ func (m *MessageMediaDocument) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (m *MessageMediaDocument) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageMediaDocument#4cf4d72d to nil") + return fmt.Errorf("can't decode messageMediaDocument#dd570bd5 to nil") } if err := b.ConsumeID(MessageMediaDocumentTypeID); err != nil { - return fmt.Errorf("unable to decode messageMediaDocument#4cf4d72d: %w", err) + return fmt.Errorf("unable to decode messageMediaDocument#dd570bd5: %w", err) } return m.DecodeBare(b) } @@ -1159,11 +1160,11 @@ func (m *MessageMediaDocument) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *MessageMediaDocument) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageMediaDocument#4cf4d72d to nil") + return fmt.Errorf("can't decode messageMediaDocument#dd570bd5 to nil") } { if err := m.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messageMediaDocument#4cf4d72d: field flags: %w", err) + return fmt.Errorf("unable to decode messageMediaDocument#dd570bd5: field flags: %w", err) } } m.Nopremium = m.Flags.Has(3) @@ -1174,21 +1175,31 @@ func (m *MessageMediaDocument) DecodeBare(b *bin.Buffer) error { if m.Flags.Has(0) { value, err := DecodeDocument(b) if err != nil { - return fmt.Errorf("unable to decode messageMediaDocument#4cf4d72d: field document: %w", err) + return fmt.Errorf("unable to decode messageMediaDocument#dd570bd5: field document: %w", err) } m.Document = value } if m.Flags.Has(5) { - value, err := DecodeDocument(b) + headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messageMediaDocument#4cf4d72d: field alt_document: %w", err) + return fmt.Errorf("unable to decode messageMediaDocument#dd570bd5: field alt_documents: %w", err) + } + + if headerLen > 0 { + m.AltDocuments = 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 messageMediaDocument#dd570bd5: field alt_documents: %w", err) + } + m.AltDocuments = append(m.AltDocuments, value) } - m.AltDocument = value } if m.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageMediaDocument#4cf4d72d: field ttl_seconds: %w", err) + return fmt.Errorf("unable to decode messageMediaDocument#dd570bd5: field ttl_seconds: %w", err) } m.TTLSeconds = value } @@ -1308,22 +1319,22 @@ func (m *MessageMediaDocument) GetDocument() (value DocumentClass, ok bool) { return m.Document, true } -// SetAltDocument sets value of AltDocument conditional field. -func (m *MessageMediaDocument) SetAltDocument(value DocumentClass) { +// SetAltDocuments sets value of AltDocuments conditional field. +func (m *MessageMediaDocument) SetAltDocuments(value []DocumentClass) { m.Flags.Set(5) - m.AltDocument = value + m.AltDocuments = value } -// GetAltDocument returns value of AltDocument conditional field and +// GetAltDocuments returns value of AltDocuments conditional field and // boolean which is true if field was set. -func (m *MessageMediaDocument) GetAltDocument() (value DocumentClass, ok bool) { +func (m *MessageMediaDocument) GetAltDocuments() (value []DocumentClass, ok bool) { if m == nil { return } if !m.Flags.Has(5) { return value, false } - return m.AltDocument, true + return m.AltDocuments, true } // SetTTLSeconds sets value of TTLSeconds conditional field. @@ -1344,6 +1355,14 @@ func (m *MessageMediaDocument) GetTTLSeconds() (value int, ok bool) { return m.TTLSeconds, true } +// MapAltDocuments returns field AltDocuments wrapped in DocumentClassArray helper. +func (m *MessageMediaDocument) MapAltDocuments() (value DocumentClassArray, ok bool) { + if !m.Flags.Has(5) { + return value, false + } + return DocumentClassArray(m.AltDocuments), true +} + // MessageMediaWebPage represents TL type `messageMediaWebPage#ddf10c3b`. // Preview of webpage // @@ -4784,7 +4803,7 @@ const MessageMediaClassName = "MessageMedia" // case *tg.MessageMediaGeo: // messageMediaGeo#56e0d474 // case *tg.MessageMediaContact: // messageMediaContact#70322949 // case *tg.MessageMediaUnsupported: // messageMediaUnsupported#9f84f49e -// case *tg.MessageMediaDocument: // messageMediaDocument#4cf4d72d +// case *tg.MessageMediaDocument: // messageMediaDocument#dd570bd5 // case *tg.MessageMediaWebPage: // messageMediaWebPage#ddf10c3b // case *tg.MessageMediaVenue: // messageMediaVenue#2ec0533f // case *tg.MessageMediaGame: // messageMediaGame#fdb19008 @@ -4860,7 +4879,7 @@ func DecodeMessageMedia(buf *bin.Buffer) (MessageMediaClass, error) { } return &v, nil case MessageMediaDocumentTypeID: - // Decoding messageMediaDocument#4cf4d72d. + // Decoding messageMediaDocument#dd570bd5. v := MessageMediaDocument{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageMediaClass: %w", err) diff --git a/tg/tl_message_report_option_gen.go b/tg/tl_message_report_option_gen.go new file mode 100644 index 0000000000..f3a6fe48df --- /dev/null +++ b/tg/tl_message_report_option_gen.go @@ -0,0 +1,188 @@ +// 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{} +) + +// MessageReportOption represents TL type `messageReportOption#7903e3d9`. +// +// See https://core.telegram.org/constructor/messageReportOption for reference. +type MessageReportOption struct { + // Text field of MessageReportOption. + Text string + // Option field of MessageReportOption. + Option []byte +} + +// MessageReportOptionTypeID is TL type id of MessageReportOption. +const MessageReportOptionTypeID = 0x7903e3d9 + +// Ensuring interfaces in compile-time for MessageReportOption. +var ( + _ bin.Encoder = &MessageReportOption{} + _ bin.Decoder = &MessageReportOption{} + _ bin.BareEncoder = &MessageReportOption{} + _ bin.BareDecoder = &MessageReportOption{} +) + +func (m *MessageReportOption) Zero() bool { + if m == nil { + return true + } + if !(m.Text == "") { + return false + } + if !(m.Option == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageReportOption) String() string { + if m == nil { + return "MessageReportOption(nil)" + } + type Alias MessageReportOption + return fmt.Sprintf("MessageReportOption%+v", Alias(*m)) +} + +// FillFrom fills MessageReportOption from given interface. +func (m *MessageReportOption) FillFrom(from interface { + GetText() (value string) + GetOption() (value []byte) +}) { + m.Text = from.GetText() + m.Option = from.GetOption() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageReportOption) TypeID() uint32 { + return MessageReportOptionTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageReportOption) TypeName() string { + return "messageReportOption" +} + +// TypeInfo returns info about TL type. +func (m *MessageReportOption) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageReportOption", + ID: MessageReportOptionTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Text", + SchemaName: "text", + }, + { + Name: "Option", + SchemaName: "option", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (m *MessageReportOption) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageReportOption#7903e3d9 as nil") + } + b.PutID(MessageReportOptionTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageReportOption) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageReportOption#7903e3d9 as nil") + } + b.PutString(m.Text) + b.PutBytes(m.Option) + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageReportOption) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageReportOption#7903e3d9 to nil") + } + if err := b.ConsumeID(MessageReportOptionTypeID); err != nil { + return fmt.Errorf("unable to decode messageReportOption#7903e3d9: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageReportOption) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageReportOption#7903e3d9 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageReportOption#7903e3d9: field text: %w", err) + } + m.Text = value + } + { + value, err := b.Bytes() + if err != nil { + return fmt.Errorf("unable to decode messageReportOption#7903e3d9: field option: %w", err) + } + m.Option = value + } + return nil +} + +// GetText returns value of Text field. +func (m *MessageReportOption) GetText() (value string) { + if m == nil { + return + } + return m.Text +} + +// GetOption returns value of Option field. +func (m *MessageReportOption) GetOption() (value []byte) { + if m == nil { + return + } + return m.Option +} diff --git a/tg/tl_message_report_option_slices_gen.go b/tg/tl_message_report_option_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_message_report_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_messages_report_gen.go b/tg/tl_messages_report_gen.go index ff363bc3bf..a04e2dca0f 100644 --- a/tg/tl_messages_report_gen.go +++ b/tg/tl_messages_report_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesReportRequest represents TL type `messages.report#8953ab4e`. +// MessagesReportRequest represents TL type `messages.report#fc78af9b`. // Report a message in a chat for violation of telegram's Terms of Service // // See https://core.telegram.org/method/messages.report for reference. @@ -40,14 +40,14 @@ type MessagesReportRequest struct { Peer InputPeerClass // IDs of messages to report ID []int - // Why are these messages being reported - Reason ReportReasonClass + // Option field of MessagesReportRequest. + Option []byte // Comment for report moderation Message string } // MessagesReportRequestTypeID is TL type id of MessagesReportRequest. -const MessagesReportRequestTypeID = 0x8953ab4e +const MessagesReportRequestTypeID = 0xfc78af9b // Ensuring interfaces in compile-time for MessagesReportRequest. var ( @@ -67,7 +67,7 @@ func (r *MessagesReportRequest) Zero() bool { if !(r.ID == nil) { return false } - if !(r.Reason == nil) { + if !(r.Option == nil) { return false } if !(r.Message == "") { @@ -90,12 +90,12 @@ func (r *MessagesReportRequest) String() string { func (r *MessagesReportRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) GetID() (value []int) - GetReason() (value ReportReasonClass) + GetOption() (value []byte) GetMessage() (value string) }) { r.Peer = from.GetPeer() r.ID = from.GetID() - r.Reason = from.GetReason() + r.Option = from.GetOption() r.Message = from.GetMessage() } @@ -131,8 +131,8 @@ func (r *MessagesReportRequest) TypeInfo() tdp.Type { SchemaName: "id", }, { - Name: "Reason", - SchemaName: "reason", + Name: "Option", + SchemaName: "option", }, { Name: "Message", @@ -145,7 +145,7 @@ func (r *MessagesReportRequest) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (r *MessagesReportRequest) Encode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.report#8953ab4e as nil") + return fmt.Errorf("can't encode messages.report#fc78af9b as nil") } b.PutID(MessagesReportRequestTypeID) return r.EncodeBare(b) @@ -154,24 +154,19 @@ func (r *MessagesReportRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (r *MessagesReportRequest) EncodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.report#8953ab4e as nil") + return fmt.Errorf("can't encode messages.report#fc78af9b as nil") } if r.Peer == nil { - return fmt.Errorf("unable to encode messages.report#8953ab4e: field peer is nil") + return fmt.Errorf("unable to encode messages.report#fc78af9b: field peer is nil") } if err := r.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.report#8953ab4e: field peer: %w", err) + return fmt.Errorf("unable to encode messages.report#fc78af9b: field peer: %w", err) } b.PutVectorHeader(len(r.ID)) for _, v := range r.ID { b.PutInt(v) } - if r.Reason == nil { - return fmt.Errorf("unable to encode messages.report#8953ab4e: field reason is nil") - } - if err := r.Reason.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.report#8953ab4e: field reason: %w", err) - } + b.PutBytes(r.Option) b.PutString(r.Message) return nil } @@ -179,10 +174,10 @@ func (r *MessagesReportRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (r *MessagesReportRequest) Decode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.report#8953ab4e to nil") + return fmt.Errorf("can't decode messages.report#fc78af9b to nil") } if err := b.ConsumeID(MessagesReportRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.report#8953ab4e: %w", err) + return fmt.Errorf("unable to decode messages.report#fc78af9b: %w", err) } return r.DecodeBare(b) } @@ -190,19 +185,19 @@ func (r *MessagesReportRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (r *MessagesReportRequest) DecodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.report#8953ab4e to nil") + return fmt.Errorf("can't decode messages.report#fc78af9b to nil") } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.report#8953ab4e: field peer: %w", err) + return fmt.Errorf("unable to decode messages.report#fc78af9b: field peer: %w", err) } r.Peer = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.report#8953ab4e: field id: %w", err) + return fmt.Errorf("unable to decode messages.report#fc78af9b: field id: %w", err) } if headerLen > 0 { @@ -211,22 +206,22 @@ func (r *MessagesReportRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.report#8953ab4e: field id: %w", err) + return fmt.Errorf("unable to decode messages.report#fc78af9b: field id: %w", err) } r.ID = append(r.ID, value) } } { - value, err := DecodeReportReason(b) + value, err := b.Bytes() if err != nil { - return fmt.Errorf("unable to decode messages.report#8953ab4e: field reason: %w", err) + return fmt.Errorf("unable to decode messages.report#fc78af9b: field option: %w", err) } - r.Reason = value + r.Option = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.report#8953ab4e: field message: %w", err) + return fmt.Errorf("unable to decode messages.report#fc78af9b: field message: %w", err) } r.Message = value } @@ -249,12 +244,12 @@ func (r *MessagesReportRequest) GetID() (value []int) { return r.ID } -// GetReason returns value of Reason field. -func (r *MessagesReportRequest) GetReason() (value ReportReasonClass) { +// GetOption returns value of Option field. +func (r *MessagesReportRequest) GetOption() (value []byte) { if r == nil { return } - return r.Reason + return r.Option } // GetMessage returns value of Message field. @@ -265,7 +260,7 @@ func (r *MessagesReportRequest) GetMessage() (value string) { return r.Message } -// MessagesReport invokes method messages.report#8953ab4e returning error if any. +// MessagesReport invokes method messages.report#fc78af9b returning error if any. // Report a message in a chat for violation of telegram's Terms of Service // // Possible errors: @@ -275,12 +270,11 @@ func (r *MessagesReportRequest) GetMessage() (value string) { // 400 PEER_ID_INVALID: The provided peer id is invalid. // // See https://core.telegram.org/method/messages.report for reference. -func (c *Client) MessagesReport(ctx context.Context, request *MessagesReportRequest) (bool, error) { - var result BoolBox +func (c *Client) MessagesReport(ctx context.Context, request *MessagesReportRequest) (ReportResultClass, error) { + var result ReportResultBox if err := c.rpc.Invoke(ctx, request, &result); err != nil { - return false, err + return nil, err } - _, ok := result.Bool.(*BoolTrue) - return ok, nil + return result.ReportResult, nil } diff --git a/tg/tl_payments_convert_star_gift_gen.go b/tg/tl_payments_convert_star_gift_gen.go new file mode 100644 index 0000000000..84c74a1541 --- /dev/null +++ b/tg/tl_payments_convert_star_gift_gen.go @@ -0,0 +1,206 @@ +// 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{} +) + +// PaymentsConvertStarGiftRequest represents TL type `payments.convertStarGift#421e027`. +// +// See https://core.telegram.org/method/payments.convertStarGift for reference. +type PaymentsConvertStarGiftRequest struct { + // UserID field of PaymentsConvertStarGiftRequest. + UserID InputUserClass + // MsgID field of PaymentsConvertStarGiftRequest. + MsgID int +} + +// PaymentsConvertStarGiftRequestTypeID is TL type id of PaymentsConvertStarGiftRequest. +const PaymentsConvertStarGiftRequestTypeID = 0x421e027 + +// Ensuring interfaces in compile-time for PaymentsConvertStarGiftRequest. +var ( + _ bin.Encoder = &PaymentsConvertStarGiftRequest{} + _ bin.Decoder = &PaymentsConvertStarGiftRequest{} + _ bin.BareEncoder = &PaymentsConvertStarGiftRequest{} + _ bin.BareDecoder = &PaymentsConvertStarGiftRequest{} +) + +func (c *PaymentsConvertStarGiftRequest) Zero() bool { + if c == nil { + return true + } + if !(c.UserID == nil) { + return false + } + if !(c.MsgID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *PaymentsConvertStarGiftRequest) String() string { + if c == nil { + return "PaymentsConvertStarGiftRequest(nil)" + } + type Alias PaymentsConvertStarGiftRequest + return fmt.Sprintf("PaymentsConvertStarGiftRequest%+v", Alias(*c)) +} + +// FillFrom fills PaymentsConvertStarGiftRequest from given interface. +func (c *PaymentsConvertStarGiftRequest) FillFrom(from interface { + GetUserID() (value InputUserClass) + GetMsgID() (value int) +}) { + c.UserID = from.GetUserID() + c.MsgID = from.GetMsgID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsConvertStarGiftRequest) TypeID() uint32 { + return PaymentsConvertStarGiftRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsConvertStarGiftRequest) TypeName() string { + return "payments.convertStarGift" +} + +// TypeInfo returns info about TL type. +func (c *PaymentsConvertStarGiftRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.convertStarGift", + ID: PaymentsConvertStarGiftRequestTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "MsgID", + SchemaName: "msg_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *PaymentsConvertStarGiftRequest) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode payments.convertStarGift#421e027 as nil") + } + b.PutID(PaymentsConvertStarGiftRequestTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *PaymentsConvertStarGiftRequest) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode payments.convertStarGift#421e027 as nil") + } + if c.UserID == nil { + return fmt.Errorf("unable to encode payments.convertStarGift#421e027: field user_id is nil") + } + if err := c.UserID.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.convertStarGift#421e027: field user_id: %w", err) + } + b.PutInt(c.MsgID) + return nil +} + +// Decode implements bin.Decoder. +func (c *PaymentsConvertStarGiftRequest) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode payments.convertStarGift#421e027 to nil") + } + if err := b.ConsumeID(PaymentsConvertStarGiftRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.convertStarGift#421e027: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *PaymentsConvertStarGiftRequest) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode payments.convertStarGift#421e027 to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode payments.convertStarGift#421e027: field user_id: %w", err) + } + c.UserID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.convertStarGift#421e027: field msg_id: %w", err) + } + c.MsgID = value + } + return nil +} + +// GetUserID returns value of UserID field. +func (c *PaymentsConvertStarGiftRequest) GetUserID() (value InputUserClass) { + if c == nil { + return + } + return c.UserID +} + +// GetMsgID returns value of MsgID field. +func (c *PaymentsConvertStarGiftRequest) GetMsgID() (value int) { + if c == nil { + return + } + return c.MsgID +} + +// PaymentsConvertStarGift invokes method payments.convertStarGift#421e027 returning error if any. +// +// See https://core.telegram.org/method/payments.convertStarGift for reference. +func (c *Client) PaymentsConvertStarGift(ctx context.Context, request *PaymentsConvertStarGiftRequest) (bool, error) { + var result BoolBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return false, err + } + _, ok := result.Bool.(*BoolTrue) + return ok, nil +} diff --git a/tg/tl_payments_convert_star_gift_slices_gen.go b/tg/tl_payments_convert_star_gift_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_convert_star_gift_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_star_gifts_gen.go b/tg/tl_payments_get_star_gifts_gen.go new file mode 100644 index 0000000000..6fd1cce460 --- /dev/null +++ b/tg/tl_payments_get_star_gifts_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{} +) + +// PaymentsGetStarGiftsRequest represents TL type `payments.getStarGifts#c4563590`. +// +// See https://core.telegram.org/method/payments.getStarGifts for reference. +type PaymentsGetStarGiftsRequest struct { + // Hash field of PaymentsGetStarGiftsRequest. + Hash int +} + +// PaymentsGetStarGiftsRequestTypeID is TL type id of PaymentsGetStarGiftsRequest. +const PaymentsGetStarGiftsRequestTypeID = 0xc4563590 + +// Ensuring interfaces in compile-time for PaymentsGetStarGiftsRequest. +var ( + _ bin.Encoder = &PaymentsGetStarGiftsRequest{} + _ bin.Decoder = &PaymentsGetStarGiftsRequest{} + _ bin.BareEncoder = &PaymentsGetStarGiftsRequest{} + _ bin.BareDecoder = &PaymentsGetStarGiftsRequest{} +) + +func (g *PaymentsGetStarGiftsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGetStarGiftsRequest) String() string { + if g == nil { + return "PaymentsGetStarGiftsRequest(nil)" + } + type Alias PaymentsGetStarGiftsRequest + return fmt.Sprintf("PaymentsGetStarGiftsRequest%+v", Alias(*g)) +} + +// FillFrom fills PaymentsGetStarGiftsRequest from given interface. +func (g *PaymentsGetStarGiftsRequest) 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 (*PaymentsGetStarGiftsRequest) TypeID() uint32 { + return PaymentsGetStarGiftsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGetStarGiftsRequest) TypeName() string { + return "payments.getStarGifts" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGetStarGiftsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.getStarGifts", + ID: PaymentsGetStarGiftsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *PaymentsGetStarGiftsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getStarGifts#c4563590 as nil") + } + b.PutID(PaymentsGetStarGiftsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGetStarGiftsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getStarGifts#c4563590 as nil") + } + b.PutInt(g.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGetStarGiftsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getStarGifts#c4563590 to nil") + } + if err := b.ConsumeID(PaymentsGetStarGiftsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.getStarGifts#c4563590: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGetStarGiftsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getStarGifts#c4563590 to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.getStarGifts#c4563590: field hash: %w", err) + } + g.Hash = value + } + return nil +} + +// GetHash returns value of Hash field. +func (g *PaymentsGetStarGiftsRequest) GetHash() (value int) { + if g == nil { + return + } + return g.Hash +} + +// PaymentsGetStarGifts invokes method payments.getStarGifts#c4563590 returning error if any. +// +// See https://core.telegram.org/method/payments.getStarGifts for reference. +func (c *Client) PaymentsGetStarGifts(ctx context.Context, hash int) (PaymentsStarGiftsClass, error) { + var result PaymentsStarGiftsBox + + request := &PaymentsGetStarGiftsRequest{ + Hash: hash, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.StarGifts, nil +} diff --git a/tg/tl_payments_get_star_gifts_slices_gen.go b/tg/tl_payments_get_star_gifts_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_get_star_gifts_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_user_star_gifts_gen.go b/tg/tl_payments_get_user_star_gifts_gen.go new file mode 100644 index 0000000000..69d5e6c0ae --- /dev/null +++ b/tg/tl_payments_get_user_star_gifts_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{} +) + +// PaymentsGetUserStarGiftsRequest represents TL type `payments.getUserStarGifts#5e72c7e1`. +// +// See https://core.telegram.org/method/payments.getUserStarGifts for reference. +type PaymentsGetUserStarGiftsRequest struct { + // UserID field of PaymentsGetUserStarGiftsRequest. + UserID InputUserClass + // Offset field of PaymentsGetUserStarGiftsRequest. + Offset string + // Limit field of PaymentsGetUserStarGiftsRequest. + Limit int +} + +// PaymentsGetUserStarGiftsRequestTypeID is TL type id of PaymentsGetUserStarGiftsRequest. +const PaymentsGetUserStarGiftsRequestTypeID = 0x5e72c7e1 + +// Ensuring interfaces in compile-time for PaymentsGetUserStarGiftsRequest. +var ( + _ bin.Encoder = &PaymentsGetUserStarGiftsRequest{} + _ bin.Decoder = &PaymentsGetUserStarGiftsRequest{} + _ bin.BareEncoder = &PaymentsGetUserStarGiftsRequest{} + _ bin.BareDecoder = &PaymentsGetUserStarGiftsRequest{} +) + +func (g *PaymentsGetUserStarGiftsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.UserID == nil) { + return false + } + if !(g.Offset == "") { + return false + } + if !(g.Limit == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGetUserStarGiftsRequest) String() string { + if g == nil { + return "PaymentsGetUserStarGiftsRequest(nil)" + } + type Alias PaymentsGetUserStarGiftsRequest + return fmt.Sprintf("PaymentsGetUserStarGiftsRequest%+v", Alias(*g)) +} + +// FillFrom fills PaymentsGetUserStarGiftsRequest from given interface. +func (g *PaymentsGetUserStarGiftsRequest) FillFrom(from interface { + GetUserID() (value InputUserClass) + GetOffset() (value string) + GetLimit() (value int) +}) { + g.UserID = from.GetUserID() + g.Offset = from.GetOffset() + g.Limit = from.GetLimit() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsGetUserStarGiftsRequest) TypeID() uint32 { + return PaymentsGetUserStarGiftsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGetUserStarGiftsRequest) TypeName() string { + return "payments.getUserStarGifts" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGetUserStarGiftsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.getUserStarGifts", + ID: PaymentsGetUserStarGiftsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "Offset", + SchemaName: "offset", + }, + { + Name: "Limit", + SchemaName: "limit", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *PaymentsGetUserStarGiftsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getUserStarGifts#5e72c7e1 as nil") + } + b.PutID(PaymentsGetUserStarGiftsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGetUserStarGiftsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getUserStarGifts#5e72c7e1 as nil") + } + if g.UserID == nil { + return fmt.Errorf("unable to encode payments.getUserStarGifts#5e72c7e1: field user_id is nil") + } + if err := g.UserID.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getUserStarGifts#5e72c7e1: field user_id: %w", err) + } + b.PutString(g.Offset) + b.PutInt(g.Limit) + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGetUserStarGiftsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getUserStarGifts#5e72c7e1 to nil") + } + if err := b.ConsumeID(PaymentsGetUserStarGiftsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.getUserStarGifts#5e72c7e1: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGetUserStarGiftsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getUserStarGifts#5e72c7e1 to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode payments.getUserStarGifts#5e72c7e1: field user_id: %w", err) + } + g.UserID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.getUserStarGifts#5e72c7e1: field offset: %w", err) + } + g.Offset = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.getUserStarGifts#5e72c7e1: field limit: %w", err) + } + g.Limit = value + } + return nil +} + +// GetUserID returns value of UserID field. +func (g *PaymentsGetUserStarGiftsRequest) GetUserID() (value InputUserClass) { + if g == nil { + return + } + return g.UserID +} + +// GetOffset returns value of Offset field. +func (g *PaymentsGetUserStarGiftsRequest) GetOffset() (value string) { + if g == nil { + return + } + return g.Offset +} + +// GetLimit returns value of Limit field. +func (g *PaymentsGetUserStarGiftsRequest) GetLimit() (value int) { + if g == nil { + return + } + return g.Limit +} + +// PaymentsGetUserStarGifts invokes method payments.getUserStarGifts#5e72c7e1 returning error if any. +// +// See https://core.telegram.org/method/payments.getUserStarGifts for reference. +func (c *Client) PaymentsGetUserStarGifts(ctx context.Context, request *PaymentsGetUserStarGiftsRequest) (*PaymentsUserStarGifts, error) { + var result PaymentsUserStarGifts + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_payments_get_user_star_gifts_slices_gen.go b/tg/tl_payments_get_user_star_gifts_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_get_user_star_gifts_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 fadc30b49d..3595d201c6 100644 --- a/tg/tl_payments_payment_form_gen.go +++ b/tg/tl_payments_payment_form_gen.go @@ -1173,6 +1173,167 @@ func (p *PaymentsPaymentFormStars) MapUsers() (value UserClassArray) { return UserClassArray(p.Users) } +// PaymentsPaymentFormStarGift represents TL type `payments.paymentFormStarGift#b425cfe1`. +// +// See https://core.telegram.org/constructor/payments.paymentFormStarGift for reference. +type PaymentsPaymentFormStarGift struct { + // FormID field of PaymentsPaymentFormStarGift. + FormID int64 + // Invoice field of PaymentsPaymentFormStarGift. + Invoice Invoice +} + +// PaymentsPaymentFormStarGiftTypeID is TL type id of PaymentsPaymentFormStarGift. +const PaymentsPaymentFormStarGiftTypeID = 0xb425cfe1 + +// construct implements constructor of PaymentsPaymentFormClass. +func (p PaymentsPaymentFormStarGift) construct() PaymentsPaymentFormClass { return &p } + +// Ensuring interfaces in compile-time for PaymentsPaymentFormStarGift. +var ( + _ bin.Encoder = &PaymentsPaymentFormStarGift{} + _ bin.Decoder = &PaymentsPaymentFormStarGift{} + _ bin.BareEncoder = &PaymentsPaymentFormStarGift{} + _ bin.BareDecoder = &PaymentsPaymentFormStarGift{} + + _ PaymentsPaymentFormClass = &PaymentsPaymentFormStarGift{} +) + +func (p *PaymentsPaymentFormStarGift) Zero() bool { + if p == nil { + return true + } + if !(p.FormID == 0) { + return false + } + if !(p.Invoice.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (p *PaymentsPaymentFormStarGift) String() string { + if p == nil { + return "PaymentsPaymentFormStarGift(nil)" + } + type Alias PaymentsPaymentFormStarGift + return fmt.Sprintf("PaymentsPaymentFormStarGift%+v", Alias(*p)) +} + +// FillFrom fills PaymentsPaymentFormStarGift from given interface. +func (p *PaymentsPaymentFormStarGift) FillFrom(from interface { + GetFormID() (value int64) + GetInvoice() (value Invoice) +}) { + p.FormID = from.GetFormID() + p.Invoice = from.GetInvoice() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsPaymentFormStarGift) TypeID() uint32 { + return PaymentsPaymentFormStarGiftTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsPaymentFormStarGift) TypeName() string { + return "payments.paymentFormStarGift" +} + +// TypeInfo returns info about TL type. +func (p *PaymentsPaymentFormStarGift) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.paymentFormStarGift", + ID: PaymentsPaymentFormStarGiftTypeID, + } + if p == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "FormID", + SchemaName: "form_id", + }, + { + Name: "Invoice", + SchemaName: "invoice", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (p *PaymentsPaymentFormStarGift) Encode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode payments.paymentFormStarGift#b425cfe1 as nil") + } + b.PutID(PaymentsPaymentFormStarGiftTypeID) + return p.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (p *PaymentsPaymentFormStarGift) EncodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode payments.paymentFormStarGift#b425cfe1 as nil") + } + b.PutLong(p.FormID) + if err := p.Invoice.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.paymentFormStarGift#b425cfe1: field invoice: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (p *PaymentsPaymentFormStarGift) Decode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode payments.paymentFormStarGift#b425cfe1 to nil") + } + if err := b.ConsumeID(PaymentsPaymentFormStarGiftTypeID); err != nil { + return fmt.Errorf("unable to decode payments.paymentFormStarGift#b425cfe1: %w", err) + } + return p.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (p *PaymentsPaymentFormStarGift) DecodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode payments.paymentFormStarGift#b425cfe1 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode payments.paymentFormStarGift#b425cfe1: field form_id: %w", err) + } + p.FormID = value + } + { + if err := p.Invoice.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.paymentFormStarGift#b425cfe1: field invoice: %w", err) + } + } + return nil +} + +// GetFormID returns value of FormID field. +func (p *PaymentsPaymentFormStarGift) GetFormID() (value int64) { + if p == nil { + return + } + return p.FormID +} + +// GetInvoice returns value of Invoice field. +func (p *PaymentsPaymentFormStarGift) GetInvoice() (value Invoice) { + if p == nil { + return + } + return p.Invoice +} + // PaymentsPaymentFormClassName is schema name of PaymentsPaymentFormClass. const PaymentsPaymentFormClassName = "payments.PaymentForm" @@ -1189,6 +1350,7 @@ const PaymentsPaymentFormClassName = "payments.PaymentForm" // switch v := g.(type) { // case *tg.PaymentsPaymentForm: // payments.paymentForm#a0058751 // case *tg.PaymentsPaymentFormStars: // payments.paymentFormStars#7bf6b15c +// case *tg.PaymentsPaymentFormStarGift: // payments.paymentFormStarGift#b425cfe1 // default: panic(v) // } type PaymentsPaymentFormClass interface { @@ -1212,25 +1374,8 @@ type PaymentsPaymentFormClass interface { // 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. @@ -1254,6 +1399,13 @@ func DecodePaymentsPaymentForm(buf *bin.Buffer) (PaymentsPaymentFormClass, error return nil, fmt.Errorf("unable to decode PaymentsPaymentFormClass: %w", err) } return &v, nil + case PaymentsPaymentFormStarGiftTypeID: + // Decoding payments.paymentFormStarGift#b425cfe1. + v := PaymentsPaymentFormStarGift{} + 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)) } diff --git a/tg/tl_payments_payment_form_slices_gen.go b/tg/tl_payments_payment_form_slices_gen.go index ceaf473f58..859bcb1b38 100644 --- a/tg/tl_payments_payment_form_slices_gen.go +++ b/tg/tl_payments_payment_form_slices_gen.go @@ -142,6 +142,19 @@ func (s PaymentsPaymentFormClassArray) AsPaymentsPaymentFormStars() (to Payments return to } +// AsPaymentsPaymentFormStarGift returns copy with only PaymentsPaymentFormStarGift constructors. +func (s PaymentsPaymentFormClassArray) AsPaymentsPaymentFormStarGift() (to PaymentsPaymentFormStarGiftArray) { + for _, elem := range s { + value, ok := elem.(*PaymentsPaymentFormStarGift) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // PaymentsPaymentFormArray is adapter for slice of PaymentsPaymentForm. type PaymentsPaymentFormArray []PaymentsPaymentForm @@ -305,3 +318,85 @@ func (s *PaymentsPaymentFormStarsArray) Pop() (v PaymentsPaymentFormStars, ok bo return v, true } + +// PaymentsPaymentFormStarGiftArray is adapter for slice of PaymentsPaymentFormStarGift. +type PaymentsPaymentFormStarGiftArray []PaymentsPaymentFormStarGift + +// Sort sorts slice of PaymentsPaymentFormStarGift. +func (s PaymentsPaymentFormStarGiftArray) Sort(less func(a, b PaymentsPaymentFormStarGift) bool) PaymentsPaymentFormStarGiftArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PaymentsPaymentFormStarGift. +func (s PaymentsPaymentFormStarGiftArray) SortStable(less func(a, b PaymentsPaymentFormStarGift) bool) PaymentsPaymentFormStarGiftArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PaymentsPaymentFormStarGift. +func (s PaymentsPaymentFormStarGiftArray) Retain(keep func(x PaymentsPaymentFormStarGift) bool) PaymentsPaymentFormStarGiftArray { + 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 PaymentsPaymentFormStarGiftArray) First() (v PaymentsPaymentFormStarGift, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PaymentsPaymentFormStarGiftArray) Last() (v PaymentsPaymentFormStarGift, 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 *PaymentsPaymentFormStarGiftArray) PopFirst() (v PaymentsPaymentFormStarGift, 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 PaymentsPaymentFormStarGift + 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 *PaymentsPaymentFormStarGiftArray) Pop() (v PaymentsPaymentFormStarGift, 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_save_star_gift_gen.go b/tg/tl_payments_save_star_gift_gen.go new file mode 100644 index 0000000000..3f3aad428d --- /dev/null +++ b/tg/tl_payments_save_star_gift_gen.go @@ -0,0 +1,259 @@ +// 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{} +) + +// PaymentsSaveStarGiftRequest represents TL type `payments.saveStarGift#87acf08e`. +// +// See https://core.telegram.org/method/payments.saveStarGift for reference. +type PaymentsSaveStarGiftRequest struct { + // Flags field of PaymentsSaveStarGiftRequest. + Flags bin.Fields + // Unsave field of PaymentsSaveStarGiftRequest. + Unsave bool + // UserID field of PaymentsSaveStarGiftRequest. + UserID InputUserClass + // MsgID field of PaymentsSaveStarGiftRequest. + MsgID int +} + +// PaymentsSaveStarGiftRequestTypeID is TL type id of PaymentsSaveStarGiftRequest. +const PaymentsSaveStarGiftRequestTypeID = 0x87acf08e + +// Ensuring interfaces in compile-time for PaymentsSaveStarGiftRequest. +var ( + _ bin.Encoder = &PaymentsSaveStarGiftRequest{} + _ bin.Decoder = &PaymentsSaveStarGiftRequest{} + _ bin.BareEncoder = &PaymentsSaveStarGiftRequest{} + _ bin.BareDecoder = &PaymentsSaveStarGiftRequest{} +) + +func (s *PaymentsSaveStarGiftRequest) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.Unsave == false) { + return false + } + if !(s.UserID == nil) { + return false + } + if !(s.MsgID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *PaymentsSaveStarGiftRequest) String() string { + if s == nil { + return "PaymentsSaveStarGiftRequest(nil)" + } + type Alias PaymentsSaveStarGiftRequest + return fmt.Sprintf("PaymentsSaveStarGiftRequest%+v", Alias(*s)) +} + +// FillFrom fills PaymentsSaveStarGiftRequest from given interface. +func (s *PaymentsSaveStarGiftRequest) FillFrom(from interface { + GetUnsave() (value bool) + GetUserID() (value InputUserClass) + GetMsgID() (value int) +}) { + s.Unsave = from.GetUnsave() + s.UserID = from.GetUserID() + s.MsgID = from.GetMsgID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsSaveStarGiftRequest) TypeID() uint32 { + return PaymentsSaveStarGiftRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsSaveStarGiftRequest) TypeName() string { + return "payments.saveStarGift" +} + +// TypeInfo returns info about TL type. +func (s *PaymentsSaveStarGiftRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.saveStarGift", + ID: PaymentsSaveStarGiftRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Unsave", + SchemaName: "unsave", + Null: !s.Flags.Has(0), + }, + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "MsgID", + SchemaName: "msg_id", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *PaymentsSaveStarGiftRequest) SetFlags() { + if !(s.Unsave == false) { + s.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (s *PaymentsSaveStarGiftRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode payments.saveStarGift#87acf08e as nil") + } + b.PutID(PaymentsSaveStarGiftRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *PaymentsSaveStarGiftRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode payments.saveStarGift#87acf08e as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.saveStarGift#87acf08e: field flags: %w", err) + } + if s.UserID == nil { + return fmt.Errorf("unable to encode payments.saveStarGift#87acf08e: field user_id is nil") + } + if err := s.UserID.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.saveStarGift#87acf08e: field user_id: %w", err) + } + b.PutInt(s.MsgID) + return nil +} + +// Decode implements bin.Decoder. +func (s *PaymentsSaveStarGiftRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode payments.saveStarGift#87acf08e to nil") + } + if err := b.ConsumeID(PaymentsSaveStarGiftRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.saveStarGift#87acf08e: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *PaymentsSaveStarGiftRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode payments.saveStarGift#87acf08e to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.saveStarGift#87acf08e: field flags: %w", err) + } + } + s.Unsave = s.Flags.Has(0) + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode payments.saveStarGift#87acf08e: field user_id: %w", err) + } + s.UserID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.saveStarGift#87acf08e: field msg_id: %w", err) + } + s.MsgID = value + } + return nil +} + +// SetUnsave sets value of Unsave conditional field. +func (s *PaymentsSaveStarGiftRequest) SetUnsave(value bool) { + if value { + s.Flags.Set(0) + s.Unsave = true + } else { + s.Flags.Unset(0) + s.Unsave = false + } +} + +// GetUnsave returns value of Unsave conditional field. +func (s *PaymentsSaveStarGiftRequest) GetUnsave() (value bool) { + if s == nil { + return + } + return s.Flags.Has(0) +} + +// GetUserID returns value of UserID field. +func (s *PaymentsSaveStarGiftRequest) GetUserID() (value InputUserClass) { + if s == nil { + return + } + return s.UserID +} + +// GetMsgID returns value of MsgID field. +func (s *PaymentsSaveStarGiftRequest) GetMsgID() (value int) { + if s == nil { + return + } + return s.MsgID +} + +// PaymentsSaveStarGift invokes method payments.saveStarGift#87acf08e returning error if any. +// +// See https://core.telegram.org/method/payments.saveStarGift for reference. +func (c *Client) PaymentsSaveStarGift(ctx context.Context, request *PaymentsSaveStarGiftRequest) (bool, error) { + var result BoolBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return false, err + } + _, ok := result.Bool.(*BoolTrue) + return ok, nil +} diff --git a/tg/tl_payments_save_star_gift_slices_gen.go b/tg/tl_payments_save_star_gift_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_save_star_gift_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 index ad06264328..a61e9423c8 100644 --- a/tg/tl_payments_send_stars_form_gen.go +++ b/tg/tl_payments_send_stars_form_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// PaymentsSendStarsFormRequest represents TL type `payments.sendStarsForm#2bb731d`. +// PaymentsSendStarsFormRequest represents TL type `payments.sendStarsForm#7998c914`. // Make a payment using Telegram Stars, see here »¹ for more info. // // Links: @@ -39,11 +39,6 @@ var ( // // See https://core.telegram.org/method/payments.sendStarsForm for reference. type PaymentsSendStarsFormRequest struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields // Payment form ID FormID int64 // Invoice @@ -51,7 +46,7 @@ type PaymentsSendStarsFormRequest struct { } // PaymentsSendStarsFormRequestTypeID is TL type id of PaymentsSendStarsFormRequest. -const PaymentsSendStarsFormRequestTypeID = 0x2bb731d +const PaymentsSendStarsFormRequestTypeID = 0x7998c914 // Ensuring interfaces in compile-time for PaymentsSendStarsFormRequest. var ( @@ -65,9 +60,6 @@ func (s *PaymentsSendStarsFormRequest) Zero() bool { if s == nil { return true } - if !(s.Flags.Zero()) { - return false - } if !(s.FormID == 0) { return false } @@ -131,14 +123,10 @@ func (s *PaymentsSendStarsFormRequest) TypeInfo() tdp.Type { 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") + return fmt.Errorf("can't encode payments.sendStarsForm#7998c914 as nil") } b.PutID(PaymentsSendStarsFormRequestTypeID) return s.EncodeBare(b) @@ -147,18 +135,14 @@ func (s *PaymentsSendStarsFormRequest) Encode(b *bin.Buffer) error { // 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) + return fmt.Errorf("can't encode payments.sendStarsForm#7998c914 as nil") } b.PutLong(s.FormID) if s.Invoice == nil { - return fmt.Errorf("unable to encode payments.sendStarsForm#2bb731d: field invoice is nil") + return fmt.Errorf("unable to encode payments.sendStarsForm#7998c914: 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 fmt.Errorf("unable to encode payments.sendStarsForm#7998c914: field invoice: %w", err) } return nil } @@ -166,10 +150,10 @@ func (s *PaymentsSendStarsFormRequest) EncodeBare(b *bin.Buffer) error { // 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") + return fmt.Errorf("can't decode payments.sendStarsForm#7998c914 to nil") } if err := b.ConsumeID(PaymentsSendStarsFormRequestTypeID); err != nil { - return fmt.Errorf("unable to decode payments.sendStarsForm#2bb731d: %w", err) + return fmt.Errorf("unable to decode payments.sendStarsForm#7998c914: %w", err) } return s.DecodeBare(b) } @@ -177,24 +161,19 @@ func (s *PaymentsSendStarsFormRequest) Decode(b *bin.Buffer) error { // 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) - } + return fmt.Errorf("can't decode payments.sendStarsForm#7998c914 to nil") } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode payments.sendStarsForm#2bb731d: field form_id: %w", err) + return fmt.Errorf("unable to decode payments.sendStarsForm#7998c914: 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) + return fmt.Errorf("unable to decode payments.sendStarsForm#7998c914: field invoice: %w", err) } s.Invoice = value } @@ -217,7 +196,7 @@ func (s *PaymentsSendStarsFormRequest) GetInvoice() (value InputInvoiceClass) { return s.Invoice } -// PaymentsSendStarsForm invokes method payments.sendStarsForm#2bb731d returning error if any. +// PaymentsSendStarsForm invokes method payments.sendStarsForm#7998c914 returning error if any. // Make a payment using Telegram Stars, see here »¹ for more info. // // Links: diff --git a/tg/tl_payments_star_gifts_gen.go b/tg/tl_payments_star_gifts_gen.go new file mode 100644 index 0000000000..6ab94689b7 --- /dev/null +++ b/tg/tl_payments_star_gifts_gen.go @@ -0,0 +1,411 @@ +// 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{} +) + +// PaymentsStarGiftsNotModified represents TL type `payments.starGiftsNotModified#a388a368`. +// +// See https://core.telegram.org/constructor/payments.starGiftsNotModified for reference. +type PaymentsStarGiftsNotModified struct { +} + +// PaymentsStarGiftsNotModifiedTypeID is TL type id of PaymentsStarGiftsNotModified. +const PaymentsStarGiftsNotModifiedTypeID = 0xa388a368 + +// construct implements constructor of PaymentsStarGiftsClass. +func (s PaymentsStarGiftsNotModified) construct() PaymentsStarGiftsClass { return &s } + +// Ensuring interfaces in compile-time for PaymentsStarGiftsNotModified. +var ( + _ bin.Encoder = &PaymentsStarGiftsNotModified{} + _ bin.Decoder = &PaymentsStarGiftsNotModified{} + _ bin.BareEncoder = &PaymentsStarGiftsNotModified{} + _ bin.BareDecoder = &PaymentsStarGiftsNotModified{} + + _ PaymentsStarGiftsClass = &PaymentsStarGiftsNotModified{} +) + +func (s *PaymentsStarGiftsNotModified) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *PaymentsStarGiftsNotModified) String() string { + if s == nil { + return "PaymentsStarGiftsNotModified(nil)" + } + type Alias PaymentsStarGiftsNotModified + return fmt.Sprintf("PaymentsStarGiftsNotModified%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsStarGiftsNotModified) TypeID() uint32 { + return PaymentsStarGiftsNotModifiedTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsStarGiftsNotModified) TypeName() string { + return "payments.starGiftsNotModified" +} + +// TypeInfo returns info about TL type. +func (s *PaymentsStarGiftsNotModified) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.starGiftsNotModified", + ID: PaymentsStarGiftsNotModifiedTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *PaymentsStarGiftsNotModified) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode payments.starGiftsNotModified#a388a368 as nil") + } + b.PutID(PaymentsStarGiftsNotModifiedTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *PaymentsStarGiftsNotModified) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode payments.starGiftsNotModified#a388a368 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *PaymentsStarGiftsNotModified) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode payments.starGiftsNotModified#a388a368 to nil") + } + if err := b.ConsumeID(PaymentsStarGiftsNotModifiedTypeID); err != nil { + return fmt.Errorf("unable to decode payments.starGiftsNotModified#a388a368: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *PaymentsStarGiftsNotModified) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode payments.starGiftsNotModified#a388a368 to nil") + } + return nil +} + +// PaymentsStarGifts represents TL type `payments.starGifts#901689ea`. +// +// See https://core.telegram.org/constructor/payments.starGifts for reference. +type PaymentsStarGifts struct { + // Hash field of PaymentsStarGifts. + Hash int + // Gifts field of PaymentsStarGifts. + Gifts []StarGift +} + +// PaymentsStarGiftsTypeID is TL type id of PaymentsStarGifts. +const PaymentsStarGiftsTypeID = 0x901689ea + +// construct implements constructor of PaymentsStarGiftsClass. +func (s PaymentsStarGifts) construct() PaymentsStarGiftsClass { return &s } + +// Ensuring interfaces in compile-time for PaymentsStarGifts. +var ( + _ bin.Encoder = &PaymentsStarGifts{} + _ bin.Decoder = &PaymentsStarGifts{} + _ bin.BareEncoder = &PaymentsStarGifts{} + _ bin.BareDecoder = &PaymentsStarGifts{} + + _ PaymentsStarGiftsClass = &PaymentsStarGifts{} +) + +func (s *PaymentsStarGifts) Zero() bool { + if s == nil { + return true + } + if !(s.Hash == 0) { + return false + } + if !(s.Gifts == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *PaymentsStarGifts) String() string { + if s == nil { + return "PaymentsStarGifts(nil)" + } + type Alias PaymentsStarGifts + return fmt.Sprintf("PaymentsStarGifts%+v", Alias(*s)) +} + +// FillFrom fills PaymentsStarGifts from given interface. +func (s *PaymentsStarGifts) FillFrom(from interface { + GetHash() (value int) + GetGifts() (value []StarGift) +}) { + s.Hash = from.GetHash() + s.Gifts = from.GetGifts() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsStarGifts) TypeID() uint32 { + return PaymentsStarGiftsTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsStarGifts) TypeName() string { + return "payments.starGifts" +} + +// TypeInfo returns info about TL type. +func (s *PaymentsStarGifts) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.starGifts", + ID: PaymentsStarGiftsTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + { + Name: "Gifts", + SchemaName: "gifts", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *PaymentsStarGifts) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode payments.starGifts#901689ea as nil") + } + b.PutID(PaymentsStarGiftsTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *PaymentsStarGifts) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode payments.starGifts#901689ea as nil") + } + b.PutInt(s.Hash) + b.PutVectorHeader(len(s.Gifts)) + for idx, v := range s.Gifts { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.starGifts#901689ea: field gifts element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (s *PaymentsStarGifts) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode payments.starGifts#901689ea to nil") + } + if err := b.ConsumeID(PaymentsStarGiftsTypeID); err != nil { + return fmt.Errorf("unable to decode payments.starGifts#901689ea: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *PaymentsStarGifts) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode payments.starGifts#901689ea to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.starGifts#901689ea: field hash: %w", err) + } + s.Hash = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.starGifts#901689ea: field gifts: %w", err) + } + + if headerLen > 0 { + s.Gifts = make([]StarGift, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value StarGift + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.starGifts#901689ea: field gifts: %w", err) + } + s.Gifts = append(s.Gifts, value) + } + } + return nil +} + +// GetHash returns value of Hash field. +func (s *PaymentsStarGifts) GetHash() (value int) { + if s == nil { + return + } + return s.Hash +} + +// GetGifts returns value of Gifts field. +func (s *PaymentsStarGifts) GetGifts() (value []StarGift) { + if s == nil { + return + } + return s.Gifts +} + +// PaymentsStarGiftsClassName is schema name of PaymentsStarGiftsClass. +const PaymentsStarGiftsClassName = "payments.StarGifts" + +// PaymentsStarGiftsClass represents payments.StarGifts generic type. +// +// See https://core.telegram.org/type/payments.StarGifts for reference. +// +// Example: +// +// g, err := tg.DecodePaymentsStarGifts(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.PaymentsStarGiftsNotModified: // payments.starGiftsNotModified#a388a368 +// case *tg.PaymentsStarGifts: // payments.starGifts#901689ea +// default: panic(v) +// } +type PaymentsStarGiftsClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() PaymentsStarGiftsClass + + // 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 PaymentsStarGiftsClass to PaymentsStarGifts. + AsModified() (*PaymentsStarGifts, bool) +} + +// AsModified tries to map PaymentsStarGiftsNotModified to PaymentsStarGifts. +func (s *PaymentsStarGiftsNotModified) AsModified() (*PaymentsStarGifts, bool) { + return nil, false +} + +// AsModified tries to map PaymentsStarGifts to PaymentsStarGifts. +func (s *PaymentsStarGifts) AsModified() (*PaymentsStarGifts, bool) { + return s, true +} + +// DecodePaymentsStarGifts implements binary de-serialization for PaymentsStarGiftsClass. +func DecodePaymentsStarGifts(buf *bin.Buffer) (PaymentsStarGiftsClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case PaymentsStarGiftsNotModifiedTypeID: + // Decoding payments.starGiftsNotModified#a388a368. + v := PaymentsStarGiftsNotModified{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode PaymentsStarGiftsClass: %w", err) + } + return &v, nil + case PaymentsStarGiftsTypeID: + // Decoding payments.starGifts#901689ea. + v := PaymentsStarGifts{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode PaymentsStarGiftsClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode PaymentsStarGiftsClass: %w", bin.NewUnexpectedID(id)) + } +} + +// PaymentsStarGifts boxes the PaymentsStarGiftsClass providing a helper. +type PaymentsStarGiftsBox struct { + StarGifts PaymentsStarGiftsClass +} + +// Decode implements bin.Decoder for PaymentsStarGiftsBox. +func (b *PaymentsStarGiftsBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode PaymentsStarGiftsBox to nil") + } + v, err := DecodePaymentsStarGifts(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.StarGifts = v + return nil +} + +// Encode implements bin.Encode for PaymentsStarGiftsBox. +func (b *PaymentsStarGiftsBox) Encode(buf *bin.Buffer) error { + if b == nil || b.StarGifts == nil { + return fmt.Errorf("unable to encode PaymentsStarGiftsClass as nil") + } + return b.StarGifts.Encode(buf) +} diff --git a/tg/tl_payments_star_gifts_slices_gen.go b/tg/tl_payments_star_gifts_slices_gen.go new file mode 100644 index 0000000000..504fdedaf0 --- /dev/null +++ b/tg/tl_payments_star_gifts_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{} +) + +// PaymentsStarGiftsClassArray is adapter for slice of PaymentsStarGiftsClass. +type PaymentsStarGiftsClassArray []PaymentsStarGiftsClass + +// Sort sorts slice of PaymentsStarGiftsClass. +func (s PaymentsStarGiftsClassArray) Sort(less func(a, b PaymentsStarGiftsClass) bool) PaymentsStarGiftsClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PaymentsStarGiftsClass. +func (s PaymentsStarGiftsClassArray) SortStable(less func(a, b PaymentsStarGiftsClass) bool) PaymentsStarGiftsClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PaymentsStarGiftsClass. +func (s PaymentsStarGiftsClassArray) Retain(keep func(x PaymentsStarGiftsClass) bool) PaymentsStarGiftsClassArray { + 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 PaymentsStarGiftsClassArray) First() (v PaymentsStarGiftsClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PaymentsStarGiftsClassArray) Last() (v PaymentsStarGiftsClass, 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 *PaymentsStarGiftsClassArray) PopFirst() (v PaymentsStarGiftsClass, 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 PaymentsStarGiftsClass + 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 *PaymentsStarGiftsClassArray) Pop() (v PaymentsStarGiftsClass, 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 +} + +// AsPaymentsStarGifts returns copy with only PaymentsStarGifts constructors. +func (s PaymentsStarGiftsClassArray) AsPaymentsStarGifts() (to PaymentsStarGiftsArray) { + for _, elem := range s { + value, ok := elem.(*PaymentsStarGifts) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AppendOnlyModified appends only Modified constructors to +// given slice. +func (s PaymentsStarGiftsClassArray) AppendOnlyModified(to []*PaymentsStarGifts) []*PaymentsStarGifts { + 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 PaymentsStarGiftsClassArray) AsModified() (to []*PaymentsStarGifts) { + return s.AppendOnlyModified(to) +} + +// FirstAsModified returns first element of slice (if exists). +func (s PaymentsStarGiftsClassArray) FirstAsModified() (v *PaymentsStarGifts, ok bool) { + value, ok := s.First() + if !ok { + return + } + return value.AsModified() +} + +// LastAsModified returns last element of slice (if exists). +func (s PaymentsStarGiftsClassArray) LastAsModified() (v *PaymentsStarGifts, ok bool) { + value, ok := s.Last() + if !ok { + return + } + return value.AsModified() +} + +// PopFirstAsModified returns element of slice (if exists). +func (s *PaymentsStarGiftsClassArray) PopFirstAsModified() (v *PaymentsStarGifts, ok bool) { + value, ok := s.PopFirst() + if !ok { + return + } + return value.AsModified() +} + +// PopAsModified returns element of slice (if exists). +func (s *PaymentsStarGiftsClassArray) PopAsModified() (v *PaymentsStarGifts, ok bool) { + value, ok := s.Pop() + if !ok { + return + } + return value.AsModified() +} + +// PaymentsStarGiftsArray is adapter for slice of PaymentsStarGifts. +type PaymentsStarGiftsArray []PaymentsStarGifts + +// Sort sorts slice of PaymentsStarGifts. +func (s PaymentsStarGiftsArray) Sort(less func(a, b PaymentsStarGifts) bool) PaymentsStarGiftsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PaymentsStarGifts. +func (s PaymentsStarGiftsArray) SortStable(less func(a, b PaymentsStarGifts) bool) PaymentsStarGiftsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PaymentsStarGifts. +func (s PaymentsStarGiftsArray) Retain(keep func(x PaymentsStarGifts) bool) PaymentsStarGiftsArray { + 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 PaymentsStarGiftsArray) First() (v PaymentsStarGifts, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PaymentsStarGiftsArray) Last() (v PaymentsStarGifts, 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 *PaymentsStarGiftsArray) PopFirst() (v PaymentsStarGifts, 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 PaymentsStarGifts + 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 *PaymentsStarGiftsArray) Pop() (v PaymentsStarGifts, 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_user_star_gifts_gen.go b/tg/tl_payments_user_star_gifts_gen.go new file mode 100644 index 0000000000..ef6c9496cd --- /dev/null +++ b/tg/tl_payments_user_star_gifts_gen.go @@ -0,0 +1,319 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// PaymentsUserStarGifts represents TL type `payments.userStarGifts#6b65b517`. +// +// See https://core.telegram.org/constructor/payments.userStarGifts for reference. +type PaymentsUserStarGifts struct { + // Flags field of PaymentsUserStarGifts. + Flags bin.Fields + // Count field of PaymentsUserStarGifts. + Count int + // Gifts field of PaymentsUserStarGifts. + Gifts []UserStarGift + // NextOffset field of PaymentsUserStarGifts. + // + // Use SetNextOffset and GetNextOffset helpers. + NextOffset string + // Users field of PaymentsUserStarGifts. + Users []UserClass +} + +// PaymentsUserStarGiftsTypeID is TL type id of PaymentsUserStarGifts. +const PaymentsUserStarGiftsTypeID = 0x6b65b517 + +// Ensuring interfaces in compile-time for PaymentsUserStarGifts. +var ( + _ bin.Encoder = &PaymentsUserStarGifts{} + _ bin.Decoder = &PaymentsUserStarGifts{} + _ bin.BareEncoder = &PaymentsUserStarGifts{} + _ bin.BareDecoder = &PaymentsUserStarGifts{} +) + +func (u *PaymentsUserStarGifts) Zero() bool { + if u == nil { + return true + } + if !(u.Flags.Zero()) { + return false + } + if !(u.Count == 0) { + return false + } + if !(u.Gifts == nil) { + return false + } + if !(u.NextOffset == "") { + return false + } + if !(u.Users == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *PaymentsUserStarGifts) String() string { + if u == nil { + return "PaymentsUserStarGifts(nil)" + } + type Alias PaymentsUserStarGifts + return fmt.Sprintf("PaymentsUserStarGifts%+v", Alias(*u)) +} + +// FillFrom fills PaymentsUserStarGifts from given interface. +func (u *PaymentsUserStarGifts) FillFrom(from interface { + GetCount() (value int) + GetGifts() (value []UserStarGift) + GetNextOffset() (value string, ok bool) + GetUsers() (value []UserClass) +}) { + u.Count = from.GetCount() + u.Gifts = from.GetGifts() + if val, ok := from.GetNextOffset(); ok { + u.NextOffset = val + } + + u.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsUserStarGifts) TypeID() uint32 { + return PaymentsUserStarGiftsTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsUserStarGifts) TypeName() string { + return "payments.userStarGifts" +} + +// TypeInfo returns info about TL type. +func (u *PaymentsUserStarGifts) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.userStarGifts", + ID: PaymentsUserStarGiftsTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Count", + SchemaName: "count", + }, + { + Name: "Gifts", + SchemaName: "gifts", + }, + { + Name: "NextOffset", + SchemaName: "next_offset", + Null: !u.Flags.Has(0), + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (u *PaymentsUserStarGifts) SetFlags() { + if !(u.NextOffset == "") { + u.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (u *PaymentsUserStarGifts) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode payments.userStarGifts#6b65b517 as nil") + } + b.PutID(PaymentsUserStarGiftsTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *PaymentsUserStarGifts) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode payments.userStarGifts#6b65b517 as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.userStarGifts#6b65b517: field flags: %w", err) + } + b.PutInt(u.Count) + b.PutVectorHeader(len(u.Gifts)) + for idx, v := range u.Gifts { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.userStarGifts#6b65b517: field gifts element with index %d: %w", idx, err) + } + } + if u.Flags.Has(0) { + b.PutString(u.NextOffset) + } + b.PutVectorHeader(len(u.Users)) + for idx, v := range u.Users { + if v == nil { + return fmt.Errorf("unable to encode payments.userStarGifts#6b65b517: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.userStarGifts#6b65b517: field users element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (u *PaymentsUserStarGifts) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode payments.userStarGifts#6b65b517 to nil") + } + if err := b.ConsumeID(PaymentsUserStarGiftsTypeID); err != nil { + return fmt.Errorf("unable to decode payments.userStarGifts#6b65b517: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *PaymentsUserStarGifts) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode payments.userStarGifts#6b65b517 to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.userStarGifts#6b65b517: field flags: %w", err) + } + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.userStarGifts#6b65b517: field count: %w", err) + } + u.Count = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.userStarGifts#6b65b517: field gifts: %w", err) + } + + if headerLen > 0 { + u.Gifts = make([]UserStarGift, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value UserStarGift + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.userStarGifts#6b65b517: field gifts: %w", err) + } + u.Gifts = append(u.Gifts, value) + } + } + if u.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.userStarGifts#6b65b517: field next_offset: %w", err) + } + u.NextOffset = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.userStarGifts#6b65b517: field users: %w", err) + } + + if headerLen > 0 { + u.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.userStarGifts#6b65b517: field users: %w", err) + } + u.Users = append(u.Users, value) + } + } + return nil +} + +// GetCount returns value of Count field. +func (u *PaymentsUserStarGifts) GetCount() (value int) { + if u == nil { + return + } + return u.Count +} + +// GetGifts returns value of Gifts field. +func (u *PaymentsUserStarGifts) GetGifts() (value []UserStarGift) { + if u == nil { + return + } + return u.Gifts +} + +// SetNextOffset sets value of NextOffset conditional field. +func (u *PaymentsUserStarGifts) SetNextOffset(value string) { + u.Flags.Set(0) + u.NextOffset = value +} + +// GetNextOffset returns value of NextOffset conditional field and +// boolean which is true if field was set. +func (u *PaymentsUserStarGifts) GetNextOffset() (value string, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.NextOffset, true +} + +// GetUsers returns value of Users field. +func (u *PaymentsUserStarGifts) GetUsers() (value []UserClass) { + if u == nil { + return + } + return u.Users +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (u *PaymentsUserStarGifts) MapUsers() (value UserClassArray) { + return UserClassArray(u.Users) +} diff --git a/tg/tl_payments_user_star_gifts_slices_gen.go b/tg/tl_payments_user_star_gifts_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_user_star_gifts_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 0686b6dfe5..df45f511ef 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 187 +const Layer = 189 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -137,7 +137,7 @@ func TypesMap() map[uint32]string { MessageMediaGeoTypeID: "messageMediaGeo#56e0d474", MessageMediaContactTypeID: "messageMediaContact#70322949", MessageMediaUnsupportedTypeID: "messageMediaUnsupported#9f84f49e", - MessageMediaDocumentTypeID: "messageMediaDocument#4cf4d72d", + MessageMediaDocumentTypeID: "messageMediaDocument#dd570bd5", MessageMediaWebPageTypeID: "messageMediaWebPage#ddf10c3b", MessageMediaVenueTypeID: "messageMediaVenue#2ec0533f", MessageMediaGameTypeID: "messageMediaGame#fdb19008", @@ -195,6 +195,7 @@ func TypesMap() map[uint32]string { MessageActionPaymentRefundedTypeID: "messageActionPaymentRefunded#41b3e202", MessageActionGiftStarsTypeID: "messageActionGiftStars#45d5b021", MessageActionPrizeStarsTypeID: "messageActionPrizeStars#b00c47a2", + MessageActionStarGiftTypeID: "messageActionStarGift#9bb3ef44", DialogTypeID: "dialog#d58a08c6", DialogFolderTypeID: "dialogFolder#71bd134c", PhotoEmptyTypeID: "photoEmpty#2331b22d", @@ -232,7 +233,7 @@ func TypesMap() map[uint32]string { InputReportReasonFakeTypeID: "inputReportReasonFake#f5ddd6e7", InputReportReasonIllegalDrugsTypeID: "inputReportReasonIllegalDrugs#a8eb2be", InputReportReasonPersonalDetailsTypeID: "inputReportReasonPersonalDetails#9ec7863d", - UserFullTypeID: "userFull#cc997720", + UserFullTypeID: "userFull#1f58e369", ContactTypeID: "contact#145ade0b", ImportedContactTypeID: "importedContact#c13e3c50", ContactStatusTypeID: "contactStatus#16d9703b", @@ -527,7 +528,7 @@ func TypesMap() map[uint32]string { DocumentAttributeImageSizeTypeID: "documentAttributeImageSize#6c37c15c", DocumentAttributeAnimatedTypeID: "documentAttributeAnimated#11b58939", DocumentAttributeStickerTypeID: "documentAttributeSticker#6319d612", - DocumentAttributeVideoTypeID: "documentAttributeVideo#17399fad", + DocumentAttributeVideoTypeID: "documentAttributeVideo#43c57c48", DocumentAttributeAudioTypeID: "documentAttributeAudio#9852f9c6", DocumentAttributeFilenameTypeID: "documentAttributeFilename#15590068", DocumentAttributeHasStickersTypeID: "documentAttributeHasStickers#9801d2f7", @@ -587,6 +588,7 @@ func TypesMap() map[uint32]string { KeyboardButtonSimpleWebViewTypeID: "keyboardButtonSimpleWebView#a0c0505c", KeyboardButtonRequestPeerTypeID: "keyboardButtonRequestPeer#53d7bfd8", InputKeyboardButtonRequestPeerTypeID: "inputKeyboardButtonRequestPeer#c9662d05", + KeyboardButtonCopyTypeID: "keyboardButtonCopy#75d2698e", KeyboardButtonRowTypeID: "keyboardButtonRow#77608b83", ReplyKeyboardHideTypeID: "replyKeyboardHide#a03e5b85", ReplyKeyboardForceReplyTypeID: "replyKeyboardForceReply#86b40b08", @@ -789,6 +791,7 @@ func TypesMap() map[uint32]string { UploadWebFileTypeID: "upload.webFile#21e753bc", PaymentsPaymentFormTypeID: "payments.paymentForm#a0058751", PaymentsPaymentFormStarsTypeID: "payments.paymentFormStars#7bf6b15c", + PaymentsPaymentFormStarGiftTypeID: "payments.paymentFormStarGift#b425cfe1", PaymentsValidatedRequestedInfoTypeID: "payments.validatedRequestedInfo#d1451883", PaymentsPaymentResultTypeID: "payments.paymentResult#4e5f810d", PaymentsPaymentVerificationNeededTypeID: "payments.paymentVerificationNeeded#d8411139", @@ -1150,6 +1153,7 @@ func TypesMap() map[uint32]string { InputInvoicePremiumGiftCodeTypeID: "inputInvoicePremiumGiftCode#98986c0d", InputInvoiceStarsTypeID: "inputInvoiceStars#65f00ce3", InputInvoiceChatInviteSubscriptionTypeID: "inputInvoiceChatInviteSubscription#34e793f1", + InputInvoiceStarGiftTypeID: "inputInvoiceStarGift#25d8c1d8", PaymentsExportedInvoiceTypeID: "payments.exportedInvoice#aed0cbd9", MessagesTranscribedAudioTypeID: "messages.transcribedAudio#cfb9d957", HelpPremiumPromoTypeID: "help.premiumPromo#5334759c", @@ -1367,7 +1371,7 @@ func TypesMap() map[uint32]string { StarsTransactionPeerTypeID: "starsTransactionPeer#d80da15d", StarsTransactionPeerAdsTypeID: "starsTransactionPeerAds#60682812", StarsTopupOptionTypeID: "starsTopupOption#bd915c0", - StarsTransactionTypeID: "starsTransaction#ee7522d5", + StarsTransactionTypeID: "starsTransaction#a9ee4c2", PaymentsStarsStatusTypeID: "payments.starsStatus#bbfa316c", FoundStoryTypeID: "foundStory#e87acbc0", StoriesFoundStoriesTypeID: "stories.foundStories#e2de7737", @@ -1386,6 +1390,15 @@ func TypesMap() map[uint32]string { MessageReactorTypeID: "messageReactor#4ba3a95a", StarsGiveawayOptionTypeID: "starsGiveawayOption#94ce852a", StarsGiveawayWinnersOptionTypeID: "starsGiveawayWinnersOption#54236209", + StarGiftTypeID: "starGift#aea174ee", + PaymentsStarGiftsNotModifiedTypeID: "payments.starGiftsNotModified#a388a368", + PaymentsStarGiftsTypeID: "payments.starGifts#901689ea", + UserStarGiftTypeID: "userStarGift#eea49a6e", + PaymentsUserStarGiftsTypeID: "payments.userStarGifts#6b65b517", + MessageReportOptionTypeID: "messageReportOption#7903e3d9", + ReportResultChooseOptionTypeID: "reportResultChooseOption#f0e4e0b6", + ReportResultAddCommentTypeID: "reportResultAddComment#6f09ac31", + ReportResultReportedTypeID: "reportResultReported#8db33c4b", InvokeAfterMsgRequestTypeID: "invokeAfterMsg#cb9f372d", InvokeAfterMsgsRequestTypeID: "invokeAfterMsgs#3dc4b4f0", InitConnectionRequestTypeID: "initConnection#c1cd5ea9", @@ -1575,7 +1588,7 @@ func TypesMap() map[uint32]string { MessagesForwardMessagesRequestTypeID: "messages.forwardMessages#d5039208", MessagesReportSpamRequestTypeID: "messages.reportSpam#cf1592db", MessagesGetPeerSettingsRequestTypeID: "messages.getPeerSettings#efd9a6a2", - MessagesReportRequestTypeID: "messages.report#8953ab4e", + MessagesReportRequestTypeID: "messages.report#fc78af9b", MessagesGetChatsRequestTypeID: "messages.getChats#49e9528f", MessagesGetFullChatRequestTypeID: "messages.getFullChat#aeb00b34", MessagesEditChatTitleRequestTypeID: "messages.editChatTitle#73783ffd", @@ -1874,7 +1887,7 @@ func TypesMap() map[uint32]string { ChannelsToggleAntiSpamRequestTypeID: "channels.toggleAntiSpam#68f3e4eb", ChannelsReportAntiSpamFalsePositiveRequestTypeID: "channels.reportAntiSpamFalsePositive#a850a693", ChannelsToggleParticipantsHiddenRequestTypeID: "channels.toggleParticipantsHidden#6a6e7854", - ChannelsClickSponsoredMessageRequestTypeID: "channels.clickSponsoredMessage#18afbc93", + ChannelsClickSponsoredMessageRequestTypeID: "channels.clickSponsoredMessage#1445d75", ChannelsUpdateColorRequestTypeID: "channels.updateColor#d8aa3671", ChannelsToggleViewForumAsMessagesRequestTypeID: "channels.toggleViewForumAsMessages#9738bb15", ChannelsGetChannelRecommendationsRequestTypeID: "channels.getChannelRecommendations#25a71742", @@ -1926,7 +1939,7 @@ func TypesMap() map[uint32]string { PaymentsGetStarsTopupOptionsRequestTypeID: "payments.getStarsTopupOptions#c00ec7d3", PaymentsGetStarsStatusRequestTypeID: "payments.getStarsStatus#104fcfa7", PaymentsGetStarsTransactionsRequestTypeID: "payments.getStarsTransactions#69da4557", - PaymentsSendStarsFormRequestTypeID: "payments.sendStarsForm#2bb731d", + PaymentsSendStarsFormRequestTypeID: "payments.sendStarsForm#7998c914", PaymentsRefundStarsChargeRequestTypeID: "payments.refundStarsCharge#25ae8f4a", PaymentsGetStarsRevenueStatsRequestTypeID: "payments.getStarsRevenueStats#d91ffad6", PaymentsGetStarsRevenueWithdrawalURLRequestTypeID: "payments.getStarsRevenueWithdrawalUrl#13bbe8b3", @@ -1937,6 +1950,10 @@ func TypesMap() map[uint32]string { PaymentsChangeStarsSubscriptionRequestTypeID: "payments.changeStarsSubscription#c7770878", PaymentsFulfillStarsSubscriptionRequestTypeID: "payments.fulfillStarsSubscription#cc5bebb3", PaymentsGetStarsGiveawayOptionsRequestTypeID: "payments.getStarsGiveawayOptions#bd1efd3e", + PaymentsGetStarGiftsRequestTypeID: "payments.getStarGifts#c4563590", + PaymentsGetUserStarGiftsRequestTypeID: "payments.getUserStarGifts#5e72c7e1", + PaymentsSaveStarGiftRequestTypeID: "payments.saveStarGift#87acf08e", + PaymentsConvertStarGiftRequestTypeID: "payments.convertStarGift#421e027", StickersCreateStickerSetRequestTypeID: "stickers.createStickerSet#9021ab67", StickersRemoveStickerFromSetRequestTypeID: "stickers.removeStickerFromSet#f7760f51", StickersChangeStickerPositionRequestTypeID: "stickers.changeStickerPosition#ffb6d4ca", @@ -2021,7 +2038,7 @@ func TypesMap() map[uint32]string { StoriesGetStoryViewsListRequestTypeID: "stories.getStoryViewsList#7ed23c57", StoriesGetStoriesViewsRequestTypeID: "stories.getStoriesViews#28e16cc8", StoriesExportStoryLinkRequestTypeID: "stories.exportStoryLink#7b8def20", - StoriesReportRequestTypeID: "stories.report#1923fa8c", + StoriesReportRequestTypeID: "stories.report#19d8eb45", StoriesActivateStealthModeRequestTypeID: "stories.activateStealthMode#57bbd166", StoriesSendReactionRequestTypeID: "stories.sendReaction#7fd736b2", StoriesGetPeerStoriesRequestTypeID: "stories.getPeerStories#2c4ada50", @@ -2222,6 +2239,7 @@ func NamesMap() map[string]uint32 { "messageActionPaymentRefunded": MessageActionPaymentRefundedTypeID, "messageActionGiftStars": MessageActionGiftStarsTypeID, "messageActionPrizeStars": MessageActionPrizeStarsTypeID, + "messageActionStarGift": MessageActionStarGiftTypeID, "dialog": DialogTypeID, "dialogFolder": DialogFolderTypeID, "photoEmpty": PhotoEmptyTypeID, @@ -2614,6 +2632,7 @@ func NamesMap() map[string]uint32 { "keyboardButtonSimpleWebView": KeyboardButtonSimpleWebViewTypeID, "keyboardButtonRequestPeer": KeyboardButtonRequestPeerTypeID, "inputKeyboardButtonRequestPeer": InputKeyboardButtonRequestPeerTypeID, + "keyboardButtonCopy": KeyboardButtonCopyTypeID, "keyboardButtonRow": KeyboardButtonRowTypeID, "replyKeyboardHide": ReplyKeyboardHideTypeID, "replyKeyboardForceReply": ReplyKeyboardForceReplyTypeID, @@ -2816,6 +2835,7 @@ func NamesMap() map[string]uint32 { "upload.webFile": UploadWebFileTypeID, "payments.paymentForm": PaymentsPaymentFormTypeID, "payments.paymentFormStars": PaymentsPaymentFormStarsTypeID, + "payments.paymentFormStarGift": PaymentsPaymentFormStarGiftTypeID, "payments.validatedRequestedInfo": PaymentsValidatedRequestedInfoTypeID, "payments.paymentResult": PaymentsPaymentResultTypeID, "payments.paymentVerificationNeeded": PaymentsPaymentVerificationNeededTypeID, @@ -3177,6 +3197,7 @@ func NamesMap() map[string]uint32 { "inputInvoicePremiumGiftCode": InputInvoicePremiumGiftCodeTypeID, "inputInvoiceStars": InputInvoiceStarsTypeID, "inputInvoiceChatInviteSubscription": InputInvoiceChatInviteSubscriptionTypeID, + "inputInvoiceStarGift": InputInvoiceStarGiftTypeID, "payments.exportedInvoice": PaymentsExportedInvoiceTypeID, "messages.transcribedAudio": MessagesTranscribedAudioTypeID, "help.premiumPromo": HelpPremiumPromoTypeID, @@ -3413,6 +3434,15 @@ func NamesMap() map[string]uint32 { "messageReactor": MessageReactorTypeID, "starsGiveawayOption": StarsGiveawayOptionTypeID, "starsGiveawayWinnersOption": StarsGiveawayWinnersOptionTypeID, + "starGift": StarGiftTypeID, + "payments.starGiftsNotModified": PaymentsStarGiftsNotModifiedTypeID, + "payments.starGifts": PaymentsStarGiftsTypeID, + "userStarGift": UserStarGiftTypeID, + "payments.userStarGifts": PaymentsUserStarGiftsTypeID, + "messageReportOption": MessageReportOptionTypeID, + "reportResultChooseOption": ReportResultChooseOptionTypeID, + "reportResultAddComment": ReportResultAddCommentTypeID, + "reportResultReported": ReportResultReportedTypeID, "invokeAfterMsg": InvokeAfterMsgRequestTypeID, "invokeAfterMsgs": InvokeAfterMsgsRequestTypeID, "initConnection": InitConnectionRequestTypeID, @@ -3964,6 +3994,10 @@ func NamesMap() map[string]uint32 { "payments.changeStarsSubscription": PaymentsChangeStarsSubscriptionRequestTypeID, "payments.fulfillStarsSubscription": PaymentsFulfillStarsSubscriptionRequestTypeID, "payments.getStarsGiveawayOptions": PaymentsGetStarsGiveawayOptionsRequestTypeID, + "payments.getStarGifts": PaymentsGetStarGiftsRequestTypeID, + "payments.getUserStarGifts": PaymentsGetUserStarGiftsRequestTypeID, + "payments.saveStarGift": PaymentsSaveStarGiftRequestTypeID, + "payments.convertStarGift": PaymentsConvertStarGiftRequestTypeID, "stickers.createStickerSet": StickersCreateStickerSetRequestTypeID, "stickers.removeStickerFromSet": StickersRemoveStickerFromSetRequestTypeID, "stickers.changeStickerPosition": StickersChangeStickerPositionRequestTypeID, @@ -4249,6 +4283,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessageActionPaymentRefundedTypeID: func() bin.Object { return &MessageActionPaymentRefunded{} }, MessageActionGiftStarsTypeID: func() bin.Object { return &MessageActionGiftStars{} }, MessageActionPrizeStarsTypeID: func() bin.Object { return &MessageActionPrizeStars{} }, + MessageActionStarGiftTypeID: func() bin.Object { return &MessageActionStarGift{} }, DialogTypeID: func() bin.Object { return &Dialog{} }, DialogFolderTypeID: func() bin.Object { return &DialogFolder{} }, PhotoEmptyTypeID: func() bin.Object { return &PhotoEmpty{} }, @@ -4641,6 +4676,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { KeyboardButtonSimpleWebViewTypeID: func() bin.Object { return &KeyboardButtonSimpleWebView{} }, KeyboardButtonRequestPeerTypeID: func() bin.Object { return &KeyboardButtonRequestPeer{} }, InputKeyboardButtonRequestPeerTypeID: func() bin.Object { return &InputKeyboardButtonRequestPeer{} }, + KeyboardButtonCopyTypeID: func() bin.Object { return &KeyboardButtonCopy{} }, KeyboardButtonRowTypeID: func() bin.Object { return &KeyboardButtonRow{} }, ReplyKeyboardHideTypeID: func() bin.Object { return &ReplyKeyboardHide{} }, ReplyKeyboardForceReplyTypeID: func() bin.Object { return &ReplyKeyboardForceReply{} }, @@ -4843,6 +4879,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UploadWebFileTypeID: func() bin.Object { return &UploadWebFile{} }, PaymentsPaymentFormTypeID: func() bin.Object { return &PaymentsPaymentForm{} }, PaymentsPaymentFormStarsTypeID: func() bin.Object { return &PaymentsPaymentFormStars{} }, + PaymentsPaymentFormStarGiftTypeID: func() bin.Object { return &PaymentsPaymentFormStarGift{} }, PaymentsValidatedRequestedInfoTypeID: func() bin.Object { return &PaymentsValidatedRequestedInfo{} }, PaymentsPaymentResultTypeID: func() bin.Object { return &PaymentsPaymentResult{} }, PaymentsPaymentVerificationNeededTypeID: func() bin.Object { return &PaymentsPaymentVerificationNeeded{} }, @@ -5204,6 +5241,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputInvoicePremiumGiftCodeTypeID: func() bin.Object { return &InputInvoicePremiumGiftCode{} }, InputInvoiceStarsTypeID: func() bin.Object { return &InputInvoiceStars{} }, InputInvoiceChatInviteSubscriptionTypeID: func() bin.Object { return &InputInvoiceChatInviteSubscription{} }, + InputInvoiceStarGiftTypeID: func() bin.Object { return &InputInvoiceStarGift{} }, PaymentsExportedInvoiceTypeID: func() bin.Object { return &PaymentsExportedInvoice{} }, MessagesTranscribedAudioTypeID: func() bin.Object { return &MessagesTranscribedAudio{} }, HelpPremiumPromoTypeID: func() bin.Object { return &HelpPremiumPromo{} }, @@ -5440,6 +5478,15 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessageReactorTypeID: func() bin.Object { return &MessageReactor{} }, StarsGiveawayOptionTypeID: func() bin.Object { return &StarsGiveawayOption{} }, StarsGiveawayWinnersOptionTypeID: func() bin.Object { return &StarsGiveawayWinnersOption{} }, + StarGiftTypeID: func() bin.Object { return &StarGift{} }, + PaymentsStarGiftsNotModifiedTypeID: func() bin.Object { return &PaymentsStarGiftsNotModified{} }, + PaymentsStarGiftsTypeID: func() bin.Object { return &PaymentsStarGifts{} }, + UserStarGiftTypeID: func() bin.Object { return &UserStarGift{} }, + PaymentsUserStarGiftsTypeID: func() bin.Object { return &PaymentsUserStarGifts{} }, + MessageReportOptionTypeID: func() bin.Object { return &MessageReportOption{} }, + ReportResultChooseOptionTypeID: func() bin.Object { return &ReportResultChooseOption{} }, + ReportResultAddCommentTypeID: func() bin.Object { return &ReportResultAddComment{} }, + ReportResultReportedTypeID: func() bin.Object { return &ReportResultReported{} }, InvokeAfterMsgRequestTypeID: func() bin.Object { return &InvokeAfterMsgRequest{} }, InvokeAfterMsgsRequestTypeID: func() bin.Object { return &InvokeAfterMsgsRequest{} }, InitConnectionRequestTypeID: func() bin.Object { return &InitConnectionRequest{} }, @@ -5991,6 +6038,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { PaymentsChangeStarsSubscriptionRequestTypeID: func() bin.Object { return &PaymentsChangeStarsSubscriptionRequest{} }, PaymentsFulfillStarsSubscriptionRequestTypeID: func() bin.Object { return &PaymentsFulfillStarsSubscriptionRequest{} }, PaymentsGetStarsGiveawayOptionsRequestTypeID: func() bin.Object { return &PaymentsGetStarsGiveawayOptionsRequest{} }, + PaymentsGetStarGiftsRequestTypeID: func() bin.Object { return &PaymentsGetStarGiftsRequest{} }, + PaymentsGetUserStarGiftsRequestTypeID: func() bin.Object { return &PaymentsGetUserStarGiftsRequest{} }, + PaymentsSaveStarGiftRequestTypeID: func() bin.Object { return &PaymentsSaveStarGiftRequest{} }, + PaymentsConvertStarGiftRequestTypeID: func() bin.Object { return &PaymentsConvertStarGiftRequest{} }, StickersCreateStickerSetRequestTypeID: func() bin.Object { return &StickersCreateStickerSetRequest{} }, StickersRemoveStickerFromSetRequestTypeID: func() bin.Object { return &StickersRemoveStickerFromSetRequest{} }, StickersChangeStickerPositionRequestTypeID: func() bin.Object { return &StickersChangeStickerPositionRequest{} }, @@ -6616,6 +6667,7 @@ func ClassConstructorsMap() map[string][]uint32 { InputInvoicePremiumGiftCodeTypeID, InputInvoiceStarsTypeID, InputInvoiceChatInviteSubscriptionTypeID, + InputInvoiceStarGiftTypeID, }, InputMediaClassName: { InputMediaEmptyTypeID, @@ -6778,6 +6830,7 @@ func ClassConstructorsMap() map[string][]uint32 { KeyboardButtonSimpleWebViewTypeID, KeyboardButtonRequestPeerTypeID, InputKeyboardButtonRequestPeerTypeID, + KeyboardButtonCopyTypeID, }, LangPackStringClassName: { LangPackStringTypeID, @@ -6841,6 +6894,7 @@ func ClassConstructorsMap() map[string][]uint32 { MessageActionPaymentRefundedTypeID, MessageActionGiftStarsTypeID, MessageActionPrizeStarsTypeID, + MessageActionStarGiftTypeID, }, MessageClassName: { MessageEmptyTypeID, @@ -7080,6 +7134,7 @@ func ClassConstructorsMap() map[string][]uint32 { PaymentsPaymentFormClassName: { PaymentsPaymentFormTypeID, PaymentsPaymentFormStarsTypeID, + PaymentsPaymentFormStarGiftTypeID, }, PaymentsPaymentReceiptClassName: { PaymentsPaymentReceiptTypeID, @@ -7089,6 +7144,10 @@ func ClassConstructorsMap() map[string][]uint32 { PaymentsPaymentResultTypeID, PaymentsPaymentVerificationNeededTypeID, }, + PaymentsStarGiftsClassName: { + PaymentsStarGiftsNotModifiedTypeID, + PaymentsStarGiftsTypeID, + }, PeerClassName: { PeerUserTypeID, PeerChatTypeID, @@ -7204,6 +7263,11 @@ func ClassConstructorsMap() map[string][]uint32 { InputReportReasonIllegalDrugsTypeID, InputReportReasonPersonalDetailsTypeID, }, + ReportResultClassName: { + ReportResultChooseOptionTypeID, + ReportResultAddCommentTypeID, + ReportResultReportedTypeID, + }, RequestPeerTypeClassName: { RequestPeerTypeUserTypeID, RequestPeerTypeChatTypeID, diff --git a/tg/tl_report_result_gen.go b/tg/tl_report_result_gen.go new file mode 100644 index 0000000000..6b14179c0a --- /dev/null +++ b/tg/tl_report_result_gen.go @@ -0,0 +1,593 @@ +// 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{} +) + +// ReportResultChooseOption represents TL type `reportResultChooseOption#f0e4e0b6`. +// +// See https://core.telegram.org/constructor/reportResultChooseOption for reference. +type ReportResultChooseOption struct { + // Title field of ReportResultChooseOption. + Title string + // Options field of ReportResultChooseOption. + Options []MessageReportOption +} + +// ReportResultChooseOptionTypeID is TL type id of ReportResultChooseOption. +const ReportResultChooseOptionTypeID = 0xf0e4e0b6 + +// construct implements constructor of ReportResultClass. +func (r ReportResultChooseOption) construct() ReportResultClass { return &r } + +// Ensuring interfaces in compile-time for ReportResultChooseOption. +var ( + _ bin.Encoder = &ReportResultChooseOption{} + _ bin.Decoder = &ReportResultChooseOption{} + _ bin.BareEncoder = &ReportResultChooseOption{} + _ bin.BareDecoder = &ReportResultChooseOption{} + + _ ReportResultClass = &ReportResultChooseOption{} +) + +func (r *ReportResultChooseOption) Zero() bool { + if r == nil { + return true + } + if !(r.Title == "") { + return false + } + if !(r.Options == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *ReportResultChooseOption) String() string { + if r == nil { + return "ReportResultChooseOption(nil)" + } + type Alias ReportResultChooseOption + return fmt.Sprintf("ReportResultChooseOption%+v", Alias(*r)) +} + +// FillFrom fills ReportResultChooseOption from given interface. +func (r *ReportResultChooseOption) FillFrom(from interface { + GetTitle() (value string) + GetOptions() (value []MessageReportOption) +}) { + r.Title = from.GetTitle() + r.Options = from.GetOptions() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ReportResultChooseOption) TypeID() uint32 { + return ReportResultChooseOptionTypeID +} + +// TypeName returns name of type in TL schema. +func (*ReportResultChooseOption) TypeName() string { + return "reportResultChooseOption" +} + +// TypeInfo returns info about TL type. +func (r *ReportResultChooseOption) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "reportResultChooseOption", + ID: ReportResultChooseOptionTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Title", + SchemaName: "title", + }, + { + Name: "Options", + SchemaName: "options", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (r *ReportResultChooseOption) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reportResultChooseOption#f0e4e0b6 as nil") + } + b.PutID(ReportResultChooseOptionTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *ReportResultChooseOption) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reportResultChooseOption#f0e4e0b6 as nil") + } + b.PutString(r.Title) + b.PutVectorHeader(len(r.Options)) + for idx, v := range r.Options { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode reportResultChooseOption#f0e4e0b6: field options element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (r *ReportResultChooseOption) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reportResultChooseOption#f0e4e0b6 to nil") + } + if err := b.ConsumeID(ReportResultChooseOptionTypeID); err != nil { + return fmt.Errorf("unable to decode reportResultChooseOption#f0e4e0b6: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *ReportResultChooseOption) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reportResultChooseOption#f0e4e0b6 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode reportResultChooseOption#f0e4e0b6: field title: %w", err) + } + r.Title = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode reportResultChooseOption#f0e4e0b6: field options: %w", err) + } + + if headerLen > 0 { + r.Options = make([]MessageReportOption, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value MessageReportOption + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode reportResultChooseOption#f0e4e0b6: field options: %w", err) + } + r.Options = append(r.Options, value) + } + } + return nil +} + +// GetTitle returns value of Title field. +func (r *ReportResultChooseOption) GetTitle() (value string) { + if r == nil { + return + } + return r.Title +} + +// GetOptions returns value of Options field. +func (r *ReportResultChooseOption) GetOptions() (value []MessageReportOption) { + if r == nil { + return + } + return r.Options +} + +// ReportResultAddComment represents TL type `reportResultAddComment#6f09ac31`. +// +// See https://core.telegram.org/constructor/reportResultAddComment for reference. +type ReportResultAddComment struct { + // Flags field of ReportResultAddComment. + Flags bin.Fields + // Optional field of ReportResultAddComment. + Optional bool + // Option field of ReportResultAddComment. + Option []byte +} + +// ReportResultAddCommentTypeID is TL type id of ReportResultAddComment. +const ReportResultAddCommentTypeID = 0x6f09ac31 + +// construct implements constructor of ReportResultClass. +func (r ReportResultAddComment) construct() ReportResultClass { return &r } + +// Ensuring interfaces in compile-time for ReportResultAddComment. +var ( + _ bin.Encoder = &ReportResultAddComment{} + _ bin.Decoder = &ReportResultAddComment{} + _ bin.BareEncoder = &ReportResultAddComment{} + _ bin.BareDecoder = &ReportResultAddComment{} + + _ ReportResultClass = &ReportResultAddComment{} +) + +func (r *ReportResultAddComment) Zero() bool { + if r == nil { + return true + } + if !(r.Flags.Zero()) { + return false + } + if !(r.Optional == false) { + return false + } + if !(r.Option == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *ReportResultAddComment) String() string { + if r == nil { + return "ReportResultAddComment(nil)" + } + type Alias ReportResultAddComment + return fmt.Sprintf("ReportResultAddComment%+v", Alias(*r)) +} + +// FillFrom fills ReportResultAddComment from given interface. +func (r *ReportResultAddComment) FillFrom(from interface { + GetOptional() (value bool) + GetOption() (value []byte) +}) { + r.Optional = from.GetOptional() + r.Option = from.GetOption() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ReportResultAddComment) TypeID() uint32 { + return ReportResultAddCommentTypeID +} + +// TypeName returns name of type in TL schema. +func (*ReportResultAddComment) TypeName() string { + return "reportResultAddComment" +} + +// TypeInfo returns info about TL type. +func (r *ReportResultAddComment) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "reportResultAddComment", + ID: ReportResultAddCommentTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Optional", + SchemaName: "optional", + Null: !r.Flags.Has(0), + }, + { + Name: "Option", + SchemaName: "option", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (r *ReportResultAddComment) SetFlags() { + if !(r.Optional == false) { + r.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (r *ReportResultAddComment) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reportResultAddComment#6f09ac31 as nil") + } + b.PutID(ReportResultAddCommentTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *ReportResultAddComment) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reportResultAddComment#6f09ac31 as nil") + } + r.SetFlags() + if err := r.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode reportResultAddComment#6f09ac31: field flags: %w", err) + } + b.PutBytes(r.Option) + return nil +} + +// Decode implements bin.Decoder. +func (r *ReportResultAddComment) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reportResultAddComment#6f09ac31 to nil") + } + if err := b.ConsumeID(ReportResultAddCommentTypeID); err != nil { + return fmt.Errorf("unable to decode reportResultAddComment#6f09ac31: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *ReportResultAddComment) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reportResultAddComment#6f09ac31 to nil") + } + { + if err := r.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode reportResultAddComment#6f09ac31: field flags: %w", err) + } + } + r.Optional = r.Flags.Has(0) + { + value, err := b.Bytes() + if err != nil { + return fmt.Errorf("unable to decode reportResultAddComment#6f09ac31: field option: %w", err) + } + r.Option = value + } + return nil +} + +// SetOptional sets value of Optional conditional field. +func (r *ReportResultAddComment) SetOptional(value bool) { + if value { + r.Flags.Set(0) + r.Optional = true + } else { + r.Flags.Unset(0) + r.Optional = false + } +} + +// GetOptional returns value of Optional conditional field. +func (r *ReportResultAddComment) GetOptional() (value bool) { + if r == nil { + return + } + return r.Flags.Has(0) +} + +// GetOption returns value of Option field. +func (r *ReportResultAddComment) GetOption() (value []byte) { + if r == nil { + return + } + return r.Option +} + +// ReportResultReported represents TL type `reportResultReported#8db33c4b`. +// +// See https://core.telegram.org/constructor/reportResultReported for reference. +type ReportResultReported struct { +} + +// ReportResultReportedTypeID is TL type id of ReportResultReported. +const ReportResultReportedTypeID = 0x8db33c4b + +// construct implements constructor of ReportResultClass. +func (r ReportResultReported) construct() ReportResultClass { return &r } + +// Ensuring interfaces in compile-time for ReportResultReported. +var ( + _ bin.Encoder = &ReportResultReported{} + _ bin.Decoder = &ReportResultReported{} + _ bin.BareEncoder = &ReportResultReported{} + _ bin.BareDecoder = &ReportResultReported{} + + _ ReportResultClass = &ReportResultReported{} +) + +func (r *ReportResultReported) Zero() bool { + if r == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (r *ReportResultReported) String() string { + if r == nil { + return "ReportResultReported(nil)" + } + type Alias ReportResultReported + return fmt.Sprintf("ReportResultReported%+v", Alias(*r)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ReportResultReported) TypeID() uint32 { + return ReportResultReportedTypeID +} + +// TypeName returns name of type in TL schema. +func (*ReportResultReported) TypeName() string { + return "reportResultReported" +} + +// TypeInfo returns info about TL type. +func (r *ReportResultReported) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "reportResultReported", + ID: ReportResultReportedTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (r *ReportResultReported) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reportResultReported#8db33c4b as nil") + } + b.PutID(ReportResultReportedTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *ReportResultReported) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reportResultReported#8db33c4b as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (r *ReportResultReported) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reportResultReported#8db33c4b to nil") + } + if err := b.ConsumeID(ReportResultReportedTypeID); err != nil { + return fmt.Errorf("unable to decode reportResultReported#8db33c4b: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *ReportResultReported) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reportResultReported#8db33c4b to nil") + } + return nil +} + +// ReportResultClassName is schema name of ReportResultClass. +const ReportResultClassName = "ReportResult" + +// ReportResultClass represents ReportResult generic type. +// +// See https://core.telegram.org/type/ReportResult for reference. +// +// Example: +// +// g, err := tg.DecodeReportResult(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.ReportResultChooseOption: // reportResultChooseOption#f0e4e0b6 +// case *tg.ReportResultAddComment: // reportResultAddComment#6f09ac31 +// case *tg.ReportResultReported: // reportResultReported#8db33c4b +// default: panic(v) +// } +type ReportResultClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() ReportResultClass + + // 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 +} + +// DecodeReportResult implements binary de-serialization for ReportResultClass. +func DecodeReportResult(buf *bin.Buffer) (ReportResultClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case ReportResultChooseOptionTypeID: + // Decoding reportResultChooseOption#f0e4e0b6. + v := ReportResultChooseOption{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ReportResultClass: %w", err) + } + return &v, nil + case ReportResultAddCommentTypeID: + // Decoding reportResultAddComment#6f09ac31. + v := ReportResultAddComment{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ReportResultClass: %w", err) + } + return &v, nil + case ReportResultReportedTypeID: + // Decoding reportResultReported#8db33c4b. + v := ReportResultReported{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ReportResultClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode ReportResultClass: %w", bin.NewUnexpectedID(id)) + } +} + +// ReportResult boxes the ReportResultClass providing a helper. +type ReportResultBox struct { + ReportResult ReportResultClass +} + +// Decode implements bin.Decoder for ReportResultBox. +func (b *ReportResultBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode ReportResultBox to nil") + } + v, err := DecodeReportResult(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.ReportResult = v + return nil +} + +// Encode implements bin.Encode for ReportResultBox. +func (b *ReportResultBox) Encode(buf *bin.Buffer) error { + if b == nil || b.ReportResult == nil { + return fmt.Errorf("unable to encode ReportResultClass as nil") + } + return b.ReportResult.Encode(buf) +} diff --git a/tg/tl_report_result_slices_gen.go b/tg/tl_report_result_slices_gen.go new file mode 100644 index 0000000000..034283b305 --- /dev/null +++ b/tg/tl_report_result_slices_gen.go @@ -0,0 +1,307 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// ReportResultClassArray is adapter for slice of ReportResultClass. +type ReportResultClassArray []ReportResultClass + +// Sort sorts slice of ReportResultClass. +func (s ReportResultClassArray) Sort(less func(a, b ReportResultClass) bool) ReportResultClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ReportResultClass. +func (s ReportResultClassArray) SortStable(less func(a, b ReportResultClass) bool) ReportResultClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ReportResultClass. +func (s ReportResultClassArray) Retain(keep func(x ReportResultClass) bool) ReportResultClassArray { + 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 ReportResultClassArray) First() (v ReportResultClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ReportResultClassArray) Last() (v ReportResultClass, 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 *ReportResultClassArray) PopFirst() (v ReportResultClass, 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 ReportResultClass + 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 *ReportResultClassArray) Pop() (v ReportResultClass, 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 +} + +// AsReportResultChooseOption returns copy with only ReportResultChooseOption constructors. +func (s ReportResultClassArray) AsReportResultChooseOption() (to ReportResultChooseOptionArray) { + for _, elem := range s { + value, ok := elem.(*ReportResultChooseOption) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsReportResultAddComment returns copy with only ReportResultAddComment constructors. +func (s ReportResultClassArray) AsReportResultAddComment() (to ReportResultAddCommentArray) { + for _, elem := range s { + value, ok := elem.(*ReportResultAddComment) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// ReportResultChooseOptionArray is adapter for slice of ReportResultChooseOption. +type ReportResultChooseOptionArray []ReportResultChooseOption + +// Sort sorts slice of ReportResultChooseOption. +func (s ReportResultChooseOptionArray) Sort(less func(a, b ReportResultChooseOption) bool) ReportResultChooseOptionArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ReportResultChooseOption. +func (s ReportResultChooseOptionArray) SortStable(less func(a, b ReportResultChooseOption) bool) ReportResultChooseOptionArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ReportResultChooseOption. +func (s ReportResultChooseOptionArray) Retain(keep func(x ReportResultChooseOption) bool) ReportResultChooseOptionArray { + 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 ReportResultChooseOptionArray) First() (v ReportResultChooseOption, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ReportResultChooseOptionArray) Last() (v ReportResultChooseOption, 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 *ReportResultChooseOptionArray) PopFirst() (v ReportResultChooseOption, 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 ReportResultChooseOption + 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 *ReportResultChooseOptionArray) Pop() (v ReportResultChooseOption, 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 +} + +// ReportResultAddCommentArray is adapter for slice of ReportResultAddComment. +type ReportResultAddCommentArray []ReportResultAddComment + +// Sort sorts slice of ReportResultAddComment. +func (s ReportResultAddCommentArray) Sort(less func(a, b ReportResultAddComment) bool) ReportResultAddCommentArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ReportResultAddComment. +func (s ReportResultAddCommentArray) SortStable(less func(a, b ReportResultAddComment) bool) ReportResultAddCommentArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ReportResultAddComment. +func (s ReportResultAddCommentArray) Retain(keep func(x ReportResultAddComment) bool) ReportResultAddCommentArray { + 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 ReportResultAddCommentArray) First() (v ReportResultAddComment, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ReportResultAddCommentArray) Last() (v ReportResultAddComment, 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 *ReportResultAddCommentArray) PopFirst() (v ReportResultAddComment, 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 ReportResultAddComment + 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 *ReportResultAddCommentArray) Pop() (v ReportResultAddComment, 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_server_gen.go b/tg/tl_server_gen.go index 7c35e3ea47..fe020917da 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -3388,7 +3388,7 @@ func (s *ServerDispatcher) OnMessagesGetPeerSettings(f func(ctx context.Context, s.handlers[MessagesGetPeerSettingsRequestTypeID] = handler } -func (s *ServerDispatcher) OnMessagesReport(f func(ctx context.Context, request *MessagesReportRequest) (bool, error)) { +func (s *ServerDispatcher) OnMessagesReport(f func(ctx context.Context, request *MessagesReportRequest) (ReportResultClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request MessagesReportRequest if err := request.Decode(b); err != nil { @@ -3399,11 +3399,7 @@ func (s *ServerDispatcher) OnMessagesReport(f func(ctx context.Context, request if err != nil { return nil, err } - if response { - return &BoolBox{Bool: &BoolTrue{}}, nil - } - - return &BoolBox{Bool: &BoolFalse{}}, nil + return &ReportResultBox{ReportResult: response}, nil } s.handlers[MessagesReportRequestTypeID] = handler @@ -9902,6 +9898,82 @@ func (s *ServerDispatcher) OnPaymentsGetStarsGiveawayOptions(f func(ctx context. s.handlers[PaymentsGetStarsGiveawayOptionsRequestTypeID] = handler } +func (s *ServerDispatcher) OnPaymentsGetStarGifts(f func(ctx context.Context, hash int) (PaymentsStarGiftsClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsGetStarGiftsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Hash) + if err != nil { + return nil, err + } + return &PaymentsStarGiftsBox{StarGifts: response}, nil + } + + s.handlers[PaymentsGetStarGiftsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsGetUserStarGifts(f func(ctx context.Context, request *PaymentsGetUserStarGiftsRequest) (*PaymentsUserStarGifts, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsGetUserStarGiftsRequest + 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[PaymentsGetUserStarGiftsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsSaveStarGift(f func(ctx context.Context, request *PaymentsSaveStarGiftRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsSaveStarGiftRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[PaymentsSaveStarGiftRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsConvertStarGift(f func(ctx context.Context, request *PaymentsConvertStarGiftRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsConvertStarGiftRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[PaymentsConvertStarGiftRequestTypeID] = 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 @@ -11378,7 +11450,7 @@ func (s *ServerDispatcher) OnStoriesExportStoryLink(f func(ctx context.Context, s.handlers[StoriesExportStoryLinkRequestTypeID] = handler } -func (s *ServerDispatcher) OnStoriesReport(f func(ctx context.Context, request *StoriesReportRequest) (bool, error)) { +func (s *ServerDispatcher) OnStoriesReport(f func(ctx context.Context, request *StoriesReportRequest) (ReportResultClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request StoriesReportRequest if err := request.Decode(b); err != nil { @@ -11389,11 +11461,7 @@ func (s *ServerDispatcher) OnStoriesReport(f func(ctx context.Context, request * if err != nil { return nil, err } - if response { - return &BoolBox{Bool: &BoolTrue{}}, nil - } - - return &BoolBox{Bool: &BoolFalse{}}, nil + return &ReportResultBox{ReportResult: response}, nil } s.handlers[StoriesReportRequestTypeID] = handler diff --git a/tg/tl_star_gift_gen.go b/tg/tl_star_gift_gen.go new file mode 100644 index 0000000000..09f03c8783 --- /dev/null +++ b/tg/tl_star_gift_gen.go @@ -0,0 +1,401 @@ +// 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{} +) + +// StarGift represents TL type `starGift#aea174ee`. +// +// See https://core.telegram.org/constructor/starGift for reference. +type StarGift struct { + // Flags field of StarGift. + Flags bin.Fields + // Limited field of StarGift. + Limited bool + // ID field of StarGift. + ID int64 + // Sticker field of StarGift. + Sticker DocumentClass + // Stars field of StarGift. + Stars int64 + // AvailabilityRemains field of StarGift. + // + // Use SetAvailabilityRemains and GetAvailabilityRemains helpers. + AvailabilityRemains int + // AvailabilityTotal field of StarGift. + // + // Use SetAvailabilityTotal and GetAvailabilityTotal helpers. + AvailabilityTotal int + // ConvertStars field of StarGift. + ConvertStars int64 +} + +// StarGiftTypeID is TL type id of StarGift. +const StarGiftTypeID = 0xaea174ee + +// Ensuring interfaces in compile-time for StarGift. +var ( + _ bin.Encoder = &StarGift{} + _ bin.Decoder = &StarGift{} + _ bin.BareEncoder = &StarGift{} + _ bin.BareDecoder = &StarGift{} +) + +func (s *StarGift) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.Limited == false) { + return false + } + if !(s.ID == 0) { + return false + } + if !(s.Sticker == nil) { + return false + } + if !(s.Stars == 0) { + return false + } + if !(s.AvailabilityRemains == 0) { + return false + } + if !(s.AvailabilityTotal == 0) { + return false + } + if !(s.ConvertStars == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarGift) String() string { + if s == nil { + return "StarGift(nil)" + } + type Alias StarGift + return fmt.Sprintf("StarGift%+v", Alias(*s)) +} + +// FillFrom fills StarGift from given interface. +func (s *StarGift) FillFrom(from interface { + GetLimited() (value bool) + GetID() (value int64) + GetSticker() (value DocumentClass) + GetStars() (value int64) + GetAvailabilityRemains() (value int, ok bool) + GetAvailabilityTotal() (value int, ok bool) + GetConvertStars() (value int64) +}) { + s.Limited = from.GetLimited() + s.ID = from.GetID() + s.Sticker = from.GetSticker() + s.Stars = from.GetStars() + if val, ok := from.GetAvailabilityRemains(); ok { + s.AvailabilityRemains = val + } + + if val, ok := from.GetAvailabilityTotal(); ok { + s.AvailabilityTotal = val + } + + s.ConvertStars = from.GetConvertStars() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarGift) TypeID() uint32 { + return StarGiftTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarGift) TypeName() string { + return "starGift" +} + +// TypeInfo returns info about TL type. +func (s *StarGift) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starGift", + ID: StarGiftTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Limited", + SchemaName: "limited", + Null: !s.Flags.Has(0), + }, + { + Name: "ID", + SchemaName: "id", + }, + { + Name: "Sticker", + SchemaName: "sticker", + }, + { + Name: "Stars", + SchemaName: "stars", + }, + { + Name: "AvailabilityRemains", + SchemaName: "availability_remains", + Null: !s.Flags.Has(0), + }, + { + Name: "AvailabilityTotal", + SchemaName: "availability_total", + Null: !s.Flags.Has(0), + }, + { + Name: "ConvertStars", + SchemaName: "convert_stars", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *StarGift) SetFlags() { + if !(s.Limited == false) { + s.Flags.Set(0) + } + if !(s.AvailabilityRemains == 0) { + s.Flags.Set(0) + } + if !(s.AvailabilityTotal == 0) { + s.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (s *StarGift) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starGift#aea174ee as nil") + } + b.PutID(StarGiftTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarGift) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starGift#aea174ee as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode starGift#aea174ee: field flags: %w", err) + } + b.PutLong(s.ID) + if s.Sticker == nil { + return fmt.Errorf("unable to encode starGift#aea174ee: field sticker is nil") + } + if err := s.Sticker.Encode(b); err != nil { + return fmt.Errorf("unable to encode starGift#aea174ee: field sticker: %w", err) + } + b.PutLong(s.Stars) + if s.Flags.Has(0) { + b.PutInt(s.AvailabilityRemains) + } + if s.Flags.Has(0) { + b.PutInt(s.AvailabilityTotal) + } + b.PutLong(s.ConvertStars) + return nil +} + +// Decode implements bin.Decoder. +func (s *StarGift) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starGift#aea174ee to nil") + } + if err := b.ConsumeID(StarGiftTypeID); err != nil { + return fmt.Errorf("unable to decode starGift#aea174ee: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarGift) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starGift#aea174ee to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode starGift#aea174ee: field flags: %w", err) + } + } + s.Limited = s.Flags.Has(0) + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode starGift#aea174ee: field id: %w", err) + } + s.ID = value + } + { + value, err := DecodeDocument(b) + if err != nil { + return fmt.Errorf("unable to decode starGift#aea174ee: field sticker: %w", err) + } + s.Sticker = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode starGift#aea174ee: field stars: %w", err) + } + s.Stars = value + } + if s.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starGift#aea174ee: field availability_remains: %w", err) + } + s.AvailabilityRemains = value + } + if s.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starGift#aea174ee: field availability_total: %w", err) + } + s.AvailabilityTotal = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode starGift#aea174ee: field convert_stars: %w", err) + } + s.ConvertStars = value + } + return nil +} + +// SetLimited sets value of Limited conditional field. +func (s *StarGift) SetLimited(value bool) { + if value { + s.Flags.Set(0) + s.Limited = true + } else { + s.Flags.Unset(0) + s.Limited = false + } +} + +// GetLimited returns value of Limited conditional field. +func (s *StarGift) GetLimited() (value bool) { + if s == nil { + return + } + return s.Flags.Has(0) +} + +// GetID returns value of ID field. +func (s *StarGift) GetID() (value int64) { + if s == nil { + return + } + return s.ID +} + +// GetSticker returns value of Sticker field. +func (s *StarGift) GetSticker() (value DocumentClass) { + if s == nil { + return + } + return s.Sticker +} + +// GetStars returns value of Stars field. +func (s *StarGift) GetStars() (value int64) { + if s == nil { + return + } + return s.Stars +} + +// SetAvailabilityRemains sets value of AvailabilityRemains conditional field. +func (s *StarGift) SetAvailabilityRemains(value int) { + s.Flags.Set(0) + s.AvailabilityRemains = value +} + +// GetAvailabilityRemains returns value of AvailabilityRemains conditional field and +// boolean which is true if field was set. +func (s *StarGift) GetAvailabilityRemains() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.AvailabilityRemains, true +} + +// SetAvailabilityTotal sets value of AvailabilityTotal conditional field. +func (s *StarGift) SetAvailabilityTotal(value int) { + s.Flags.Set(0) + s.AvailabilityTotal = value +} + +// GetAvailabilityTotal returns value of AvailabilityTotal conditional field and +// boolean which is true if field was set. +func (s *StarGift) GetAvailabilityTotal() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.AvailabilityTotal, true +} + +// GetConvertStars returns value of ConvertStars field. +func (s *StarGift) GetConvertStars() (value int64) { + if s == nil { + return + } + return s.ConvertStars +} + +// GetStickerAsNotEmpty returns mapped value of Sticker field. +func (s *StarGift) GetStickerAsNotEmpty() (*Document, bool) { + return s.Sticker.AsNotEmpty() +} diff --git a/tg/tl_star_gift_slices_gen.go b/tg/tl_star_gift_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_star_gift_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_stars_transaction_gen.go b/tg/tl_stars_transaction_gen.go index cce80bfd9a..b5bf80bd99 100644 --- a/tg/tl_stars_transaction_gen.go +++ b/tg/tl_stars_transaction_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// StarsTransaction represents TL type `starsTransaction#ee7522d5`. +// StarsTransaction represents TL type `starsTransaction#a9ee4c2`. // Represents a Telegram Stars transaction »¹. // // Links: @@ -118,10 +118,14 @@ type StarsTransaction struct { // // Use SetGiveawayPostID and GetGiveawayPostID helpers. GiveawayPostID int + // Stargift field of StarsTransaction. + // + // Use SetStargift and GetStargift helpers. + Stargift StarGift } // StarsTransactionTypeID is TL type id of StarsTransaction. -const StarsTransactionTypeID = 0xee7522d5 +const StarsTransactionTypeID = 0xa9ee4c2 // Ensuring interfaces in compile-time for StarsTransaction. var ( @@ -195,6 +199,9 @@ func (s *StarsTransaction) Zero() bool { if !(s.GiveawayPostID == 0) { return false } + if !(s.Stargift.Zero()) { + return false + } return true } @@ -229,6 +236,7 @@ func (s *StarsTransaction) FillFrom(from interface { GetExtendedMedia() (value []MessageMediaClass, ok bool) GetSubscriptionPeriod() (value int, ok bool) GetGiveawayPostID() (value int, ok bool) + GetStargift() (value StarGift, ok bool) }) { s.Refund = from.GetRefund() s.Pending = from.GetPending() @@ -279,6 +287,10 @@ func (s *StarsTransaction) FillFrom(from interface { s.GiveawayPostID = val } + if val, ok := from.GetStargift(); ok { + s.Stargift = val + } + } // TypeID returns type id in TL schema. @@ -395,6 +407,11 @@ func (s *StarsTransaction) TypeInfo() tdp.Type { SchemaName: "giveaway_post_id", Null: !s.Flags.Has(13), }, + { + Name: "Stargift", + SchemaName: "stargift", + Null: !s.Flags.Has(14), + }, } return typ } @@ -446,12 +463,15 @@ func (s *StarsTransaction) SetFlags() { if !(s.GiveawayPostID == 0) { s.Flags.Set(13) } + if !(s.Stargift.Zero()) { + s.Flags.Set(14) + } } // Encode implements bin.Encoder. func (s *StarsTransaction) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starsTransaction#ee7522d5 as nil") + return fmt.Errorf("can't encode starsTransaction#a9ee4c2 as nil") } b.PutID(StarsTransactionTypeID) return s.EncodeBare(b) @@ -460,20 +480,20 @@ func (s *StarsTransaction) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *StarsTransaction) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starsTransaction#ee7522d5 as nil") + return fmt.Errorf("can't encode starsTransaction#a9ee4c2 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsTransaction#ee7522d5: field flags: %w", err) + return fmt.Errorf("unable to encode starsTransaction#a9ee4c2: 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#ee7522d5: field peer is nil") + return fmt.Errorf("unable to encode starsTransaction#a9ee4c2: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsTransaction#ee7522d5: field peer: %w", err) + return fmt.Errorf("unable to encode starsTransaction#a9ee4c2: field peer: %w", err) } if s.Flags.Has(0) { b.PutString(s.Title) @@ -483,10 +503,10 @@ func (s *StarsTransaction) EncodeBare(b *bin.Buffer) error { } if s.Flags.Has(2) { if s.Photo == nil { - return fmt.Errorf("unable to encode starsTransaction#ee7522d5: field photo is nil") + return fmt.Errorf("unable to encode starsTransaction#a9ee4c2: field photo is nil") } if err := s.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsTransaction#ee7522d5: field photo: %w", err) + return fmt.Errorf("unable to encode starsTransaction#a9ee4c2: field photo: %w", err) } } if s.Flags.Has(5) { @@ -505,10 +525,10 @@ func (s *StarsTransaction) EncodeBare(b *bin.Buffer) error { b.PutVectorHeader(len(s.ExtendedMedia)) for idx, v := range s.ExtendedMedia { if v == nil { - return fmt.Errorf("unable to encode starsTransaction#ee7522d5: field extended_media element with index %d is nil", idx) + return fmt.Errorf("unable to encode starsTransaction#a9ee4c2: field extended_media element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsTransaction#ee7522d5: field extended_media element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode starsTransaction#a9ee4c2: field extended_media element with index %d: %w", idx, err) } } } @@ -518,16 +538,21 @@ func (s *StarsTransaction) EncodeBare(b *bin.Buffer) error { if s.Flags.Has(13) { b.PutInt(s.GiveawayPostID) } + if s.Flags.Has(14) { + if err := s.Stargift.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsTransaction#a9ee4c2: field stargift: %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#ee7522d5 to nil") + return fmt.Errorf("can't decode starsTransaction#a9ee4c2 to nil") } if err := b.ConsumeID(StarsTransactionTypeID); err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: %w", err) } return s.DecodeBare(b) } @@ -535,11 +560,11 @@ func (s *StarsTransaction) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *StarsTransaction) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode starsTransaction#ee7522d5 to nil") + return fmt.Errorf("can't decode starsTransaction#a9ee4c2 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field flags: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field flags: %w", err) } } s.Refund = s.Flags.Has(3) @@ -550,84 +575,84 @@ func (s *StarsTransaction) DecodeBare(b *bin.Buffer) error { { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field id: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field id: %w", err) } s.ID = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field stars: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field stars: %w", err) } s.Stars = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field date: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field date: %w", err) } s.Date = value } { value, err := DecodeStarsTransactionPeer(b) if err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field peer: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: 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#ee7522d5: field title: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: 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#ee7522d5: field description: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: 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#ee7522d5: field photo: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field photo: %w", err) } s.Photo = value } if s.Flags.Has(5) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field transaction_date: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field transaction_date: %w", err) } s.TransactionDate = value } if s.Flags.Has(5) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field transaction_url: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field transaction_url: %w", err) } s.TransactionURL = value } if s.Flags.Has(7) { value, err := b.Bytes() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field bot_payload: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field bot_payload: %w", err) } s.BotPayload = value } if s.Flags.Has(8) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field msg_id: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field msg_id: %w", err) } s.MsgID = value } if s.Flags.Has(9) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field extended_media: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field extended_media: %w", err) } if headerLen > 0 { @@ -636,7 +661,7 @@ func (s *StarsTransaction) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageMedia(b) if err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field extended_media: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field extended_media: %w", err) } s.ExtendedMedia = append(s.ExtendedMedia, value) } @@ -644,17 +669,22 @@ func (s *StarsTransaction) DecodeBare(b *bin.Buffer) error { if s.Flags.Has(12) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field subscription_period: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field subscription_period: %w", err) } s.SubscriptionPeriod = value } if s.Flags.Has(13) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field giveaway_post_id: %w", err) + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field giveaway_post_id: %w", err) } s.GiveawayPostID = value } + if s.Flags.Has(14) { + if err := s.Stargift.Decode(b); err != nil { + return fmt.Errorf("unable to decode starsTransaction#a9ee4c2: field stargift: %w", err) + } + } return nil } @@ -965,6 +995,24 @@ func (s *StarsTransaction) GetGiveawayPostID() (value int, ok bool) { return s.GiveawayPostID, true } +// SetStargift sets value of Stargift conditional field. +func (s *StarsTransaction) SetStargift(value StarGift) { + s.Flags.Set(14) + s.Stargift = value +} + +// GetStargift returns value of Stargift conditional field and +// boolean which is true if field was set. +func (s *StarsTransaction) GetStargift() (value StarGift, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(14) { + return value, false + } + return s.Stargift, true +} + // MapExtendedMedia returns field ExtendedMedia wrapped in MessageMediaClassArray helper. func (s *StarsTransaction) MapExtendedMedia() (value MessageMediaClassArray, ok bool) { if !s.Flags.Has(9) { diff --git a/tg/tl_stories_report_gen.go b/tg/tl_stories_report_gen.go index bca9a16361..bbcf89c77b 100644 --- a/tg/tl_stories_report_gen.go +++ b/tg/tl_stories_report_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// StoriesReportRequest represents TL type `stories.report#1923fa8c`. +// StoriesReportRequest represents TL type `stories.report#19d8eb45`. // Report a story. // // See https://core.telegram.org/method/stories.report for reference. @@ -40,14 +40,14 @@ type StoriesReportRequest struct { Peer InputPeerClass // IDs of the stories to report. ID []int - // Why are these storeis being reported. - Reason ReportReasonClass + // Option field of StoriesReportRequest. + Option []byte // Comment for report moderation Message string } // StoriesReportRequestTypeID is TL type id of StoriesReportRequest. -const StoriesReportRequestTypeID = 0x1923fa8c +const StoriesReportRequestTypeID = 0x19d8eb45 // Ensuring interfaces in compile-time for StoriesReportRequest. var ( @@ -67,7 +67,7 @@ func (r *StoriesReportRequest) Zero() bool { if !(r.ID == nil) { return false } - if !(r.Reason == nil) { + if !(r.Option == nil) { return false } if !(r.Message == "") { @@ -90,12 +90,12 @@ func (r *StoriesReportRequest) String() string { func (r *StoriesReportRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) GetID() (value []int) - GetReason() (value ReportReasonClass) + GetOption() (value []byte) GetMessage() (value string) }) { r.Peer = from.GetPeer() r.ID = from.GetID() - r.Reason = from.GetReason() + r.Option = from.GetOption() r.Message = from.GetMessage() } @@ -131,8 +131,8 @@ func (r *StoriesReportRequest) TypeInfo() tdp.Type { SchemaName: "id", }, { - Name: "Reason", - SchemaName: "reason", + Name: "Option", + SchemaName: "option", }, { Name: "Message", @@ -145,7 +145,7 @@ func (r *StoriesReportRequest) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (r *StoriesReportRequest) Encode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode stories.report#1923fa8c as nil") + return fmt.Errorf("can't encode stories.report#19d8eb45 as nil") } b.PutID(StoriesReportRequestTypeID) return r.EncodeBare(b) @@ -154,24 +154,19 @@ func (r *StoriesReportRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (r *StoriesReportRequest) EncodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode stories.report#1923fa8c as nil") + return fmt.Errorf("can't encode stories.report#19d8eb45 as nil") } if r.Peer == nil { - return fmt.Errorf("unable to encode stories.report#1923fa8c: field peer is nil") + return fmt.Errorf("unable to encode stories.report#19d8eb45: field peer is nil") } if err := r.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode stories.report#1923fa8c: field peer: %w", err) + return fmt.Errorf("unable to encode stories.report#19d8eb45: field peer: %w", err) } b.PutVectorHeader(len(r.ID)) for _, v := range r.ID { b.PutInt(v) } - if r.Reason == nil { - return fmt.Errorf("unable to encode stories.report#1923fa8c: field reason is nil") - } - if err := r.Reason.Encode(b); err != nil { - return fmt.Errorf("unable to encode stories.report#1923fa8c: field reason: %w", err) - } + b.PutBytes(r.Option) b.PutString(r.Message) return nil } @@ -179,10 +174,10 @@ func (r *StoriesReportRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (r *StoriesReportRequest) Decode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode stories.report#1923fa8c to nil") + return fmt.Errorf("can't decode stories.report#19d8eb45 to nil") } if err := b.ConsumeID(StoriesReportRequestTypeID); err != nil { - return fmt.Errorf("unable to decode stories.report#1923fa8c: %w", err) + return fmt.Errorf("unable to decode stories.report#19d8eb45: %w", err) } return r.DecodeBare(b) } @@ -190,19 +185,19 @@ func (r *StoriesReportRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (r *StoriesReportRequest) DecodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode stories.report#1923fa8c to nil") + return fmt.Errorf("can't decode stories.report#19d8eb45 to nil") } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode stories.report#1923fa8c: field peer: %w", err) + return fmt.Errorf("unable to decode stories.report#19d8eb45: field peer: %w", err) } r.Peer = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode stories.report#1923fa8c: field id: %w", err) + return fmt.Errorf("unable to decode stories.report#19d8eb45: field id: %w", err) } if headerLen > 0 { @@ -211,22 +206,22 @@ func (r *StoriesReportRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode stories.report#1923fa8c: field id: %w", err) + return fmt.Errorf("unable to decode stories.report#19d8eb45: field id: %w", err) } r.ID = append(r.ID, value) } } { - value, err := DecodeReportReason(b) + value, err := b.Bytes() if err != nil { - return fmt.Errorf("unable to decode stories.report#1923fa8c: field reason: %w", err) + return fmt.Errorf("unable to decode stories.report#19d8eb45: field option: %w", err) } - r.Reason = value + r.Option = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode stories.report#1923fa8c: field message: %w", err) + return fmt.Errorf("unable to decode stories.report#19d8eb45: field message: %w", err) } r.Message = value } @@ -249,12 +244,12 @@ func (r *StoriesReportRequest) GetID() (value []int) { return r.ID } -// GetReason returns value of Reason field. -func (r *StoriesReportRequest) GetReason() (value ReportReasonClass) { +// GetOption returns value of Option field. +func (r *StoriesReportRequest) GetOption() (value []byte) { if r == nil { return } - return r.Reason + return r.Option } // GetMessage returns value of Message field. @@ -265,7 +260,7 @@ func (r *StoriesReportRequest) GetMessage() (value string) { return r.Message } -// StoriesReport invokes method stories.report#1923fa8c returning error if any. +// StoriesReport invokes method stories.report#19d8eb45 returning error if any. // Report a story. // // Possible errors: @@ -273,12 +268,11 @@ func (r *StoriesReportRequest) GetMessage() (value string) { // 400 PEER_ID_INVALID: The provided peer id is invalid. // // See https://core.telegram.org/method/stories.report for reference. -func (c *Client) StoriesReport(ctx context.Context, request *StoriesReportRequest) (bool, error) { - var result BoolBox +func (c *Client) StoriesReport(ctx context.Context, request *StoriesReportRequest) (ReportResultClass, error) { + var result ReportResultBox if err := c.rpc.Invoke(ctx, request, &result); err != nil { - return false, err + return nil, err } - _, ok := result.Bool.(*BoolTrue) - return ok, nil + return result.ReportResult, nil } diff --git a/tg/tl_user_full_gen.go b/tg/tl_user_full_gen.go index d9ba474be1..c90014fef7 100644 --- a/tg/tl_user_full_gen.go +++ b/tg/tl_user_full_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// UserFull represents TL type `userFull#cc997720`. +// UserFull represents TL type `userFull#1f58e369`. // Extended user info // When updating the local peer database »¹, all fields from the newly received // constructor take priority over the old constructor cached locally (including by @@ -270,10 +270,14 @@ type UserFull struct { // // Use SetPersonalChannelMessage and GetPersonalChannelMessage helpers. PersonalChannelMessage int + // StargiftsCount field of UserFull. + // + // Use SetStargiftsCount and GetStargiftsCount helpers. + StargiftsCount int } // UserFullTypeID is TL type id of UserFull. -const UserFullTypeID = 0xcc997720 +const UserFullTypeID = 0x1f58e369 // Ensuring interfaces in compile-time for UserFull. var ( @@ -416,6 +420,9 @@ func (u *UserFull) Zero() bool { if !(u.PersonalChannelMessage == 0) { return false } + if !(u.StargiftsCount == 0) { + return false + } return true } @@ -472,6 +479,7 @@ func (u *UserFull) FillFrom(from interface { GetBirthday() (value Birthday, ok bool) GetPersonalChannelID() (value int64, ok bool) GetPersonalChannelMessage() (value int, ok bool) + GetStargiftsCount() (value int, ok bool) }) { u.Blocked = from.GetBlocked() u.PhoneCallsAvailable = from.GetPhoneCallsAvailable() @@ -583,6 +591,10 @@ func (u *UserFull) FillFrom(from interface { u.PersonalChannelMessage = val } + if val, ok := from.GetStargiftsCount(); ok { + u.StargiftsCount = val + } + } // TypeID returns type id in TL schema. @@ -809,6 +821,11 @@ func (u *UserFull) TypeInfo() tdp.Type { SchemaName: "personal_channel_message", Null: !u.Flags2.Has(6), }, + { + Name: "StargiftsCount", + SchemaName: "stargifts_count", + Null: !u.Flags2.Has(8), + }, } return typ } @@ -926,12 +943,15 @@ func (u *UserFull) SetFlags() { if !(u.PersonalChannelMessage == 0) { u.Flags2.Set(6) } + if !(u.StargiftsCount == 0) { + u.Flags2.Set(8) + } } // Encode implements bin.Encoder. func (u *UserFull) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode userFull#cc997720 as nil") + return fmt.Errorf("can't encode userFull#1f58e369 as nil") } b.PutID(UserFullTypeID) return u.EncodeBare(b) @@ -940,52 +960,52 @@ func (u *UserFull) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UserFull) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode userFull#cc997720 as nil") + return fmt.Errorf("can't encode userFull#1f58e369 as nil") } u.SetFlags() if err := u.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field flags: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field flags: %w", err) } if err := u.Flags2.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field flags2: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field flags2: %w", err) } b.PutLong(u.ID) if u.Flags.Has(1) { b.PutString(u.About) } if err := u.Settings.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field settings: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field settings: %w", err) } if u.Flags.Has(21) { if u.PersonalPhoto == nil { - return fmt.Errorf("unable to encode userFull#cc997720: field personal_photo is nil") + return fmt.Errorf("unable to encode userFull#1f58e369: field personal_photo is nil") } if err := u.PersonalPhoto.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field personal_photo: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field personal_photo: %w", err) } } if u.Flags.Has(2) { if u.ProfilePhoto == nil { - return fmt.Errorf("unable to encode userFull#cc997720: field profile_photo is nil") + return fmt.Errorf("unable to encode userFull#1f58e369: field profile_photo is nil") } if err := u.ProfilePhoto.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field profile_photo: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field profile_photo: %w", err) } } if u.Flags.Has(22) { if u.FallbackPhoto == nil { - return fmt.Errorf("unable to encode userFull#cc997720: field fallback_photo is nil") + return fmt.Errorf("unable to encode userFull#1f58e369: field fallback_photo is nil") } if err := u.FallbackPhoto.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field fallback_photo: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field fallback_photo: %w", err) } } if err := u.NotifySettings.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field notify_settings: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field notify_settings: %w", err) } if u.Flags.Has(3) { if err := u.BotInfo.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field bot_info: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field bot_info: %w", err) } } if u.Flags.Has(6) { @@ -1006,63 +1026,63 @@ func (u *UserFull) EncodeBare(b *bin.Buffer) error { } if u.Flags.Has(17) { if err := u.BotGroupAdminRights.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field bot_group_admin_rights: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field bot_group_admin_rights: %w", err) } } if u.Flags.Has(18) { if err := u.BotBroadcastAdminRights.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field bot_broadcast_admin_rights: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field bot_broadcast_admin_rights: %w", err) } } if u.Flags.Has(19) { b.PutVectorHeader(len(u.PremiumGifts)) for idx, v := range u.PremiumGifts { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field premium_gifts element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode userFull#1f58e369: field premium_gifts element with index %d: %w", idx, err) } } } if u.Flags.Has(24) { if u.Wallpaper == nil { - return fmt.Errorf("unable to encode userFull#cc997720: field wallpaper is nil") + return fmt.Errorf("unable to encode userFull#1f58e369: field wallpaper is nil") } if err := u.Wallpaper.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field wallpaper: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field wallpaper: %w", err) } } if u.Flags.Has(25) { if err := u.Stories.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field stories: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field stories: %w", err) } } if u.Flags2.Has(0) { if err := u.BusinessWorkHours.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field business_work_hours: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field business_work_hours: %w", err) } } if u.Flags2.Has(1) { if err := u.BusinessLocation.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field business_location: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field business_location: %w", err) } } if u.Flags2.Has(2) { if err := u.BusinessGreetingMessage.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field business_greeting_message: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field business_greeting_message: %w", err) } } if u.Flags2.Has(3) { if err := u.BusinessAwayMessage.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field business_away_message: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field business_away_message: %w", err) } } if u.Flags2.Has(4) { if err := u.BusinessIntro.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field business_intro: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field business_intro: %w", err) } } if u.Flags2.Has(5) { if err := u.Birthday.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cc997720: field birthday: %w", err) + return fmt.Errorf("unable to encode userFull#1f58e369: field birthday: %w", err) } } if u.Flags2.Has(6) { @@ -1071,16 +1091,19 @@ func (u *UserFull) EncodeBare(b *bin.Buffer) error { if u.Flags2.Has(6) { b.PutInt(u.PersonalChannelMessage) } + if u.Flags2.Has(8) { + b.PutInt(u.StargiftsCount) + } return nil } // Decode implements bin.Decoder. func (u *UserFull) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode userFull#cc997720 to nil") + return fmt.Errorf("can't decode userFull#1f58e369 to nil") } if err := b.ConsumeID(UserFullTypeID); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: %w", err) } return u.DecodeBare(b) } @@ -1088,11 +1111,11 @@ func (u *UserFull) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UserFull) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode userFull#cc997720 to nil") + return fmt.Errorf("can't decode userFull#1f58e369 to nil") } { if err := u.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field flags: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field flags: %w", err) } } u.Blocked = u.Flags.Has(0) @@ -1110,116 +1133,116 @@ func (u *UserFull) DecodeBare(b *bin.Buffer) error { u.ReadDatesPrivate = u.Flags.Has(30) { if err := u.Flags2.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field flags2: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field flags2: %w", err) } } u.SponsoredEnabled = u.Flags2.Has(7) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field id: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field id: %w", err) } u.ID = value } if u.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field about: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field about: %w", err) } u.About = value } { if err := u.Settings.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field settings: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field settings: %w", err) } } if u.Flags.Has(21) { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field personal_photo: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field personal_photo: %w", err) } u.PersonalPhoto = value } if u.Flags.Has(2) { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field profile_photo: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field profile_photo: %w", err) } u.ProfilePhoto = value } if u.Flags.Has(22) { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field fallback_photo: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field fallback_photo: %w", err) } u.FallbackPhoto = value } { if err := u.NotifySettings.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field notify_settings: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field notify_settings: %w", err) } } if u.Flags.Has(3) { if err := u.BotInfo.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field bot_info: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field bot_info: %w", err) } } if u.Flags.Has(6) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field pinned_msg_id: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field pinned_msg_id: %w", err) } u.PinnedMsgID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field common_chats_count: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field common_chats_count: %w", err) } u.CommonChatsCount = value } if u.Flags.Has(11) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field folder_id: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field folder_id: %w", err) } u.FolderID = value } if u.Flags.Has(14) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field ttl_period: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field ttl_period: %w", err) } u.TTLPeriod = value } if u.Flags.Has(15) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field theme_emoticon: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field theme_emoticon: %w", err) } u.ThemeEmoticon = value } if u.Flags.Has(16) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field private_forward_name: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field private_forward_name: %w", err) } u.PrivateForwardName = value } if u.Flags.Has(17) { if err := u.BotGroupAdminRights.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field bot_group_admin_rights: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field bot_group_admin_rights: %w", err) } } if u.Flags.Has(18) { if err := u.BotBroadcastAdminRights.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field bot_broadcast_admin_rights: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field bot_broadcast_admin_rights: %w", err) } } if u.Flags.Has(19) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field premium_gifts: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field premium_gifts: %w", err) } if headerLen > 0 { @@ -1228,7 +1251,7 @@ func (u *UserFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value PremiumGiftOption if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field premium_gifts: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field premium_gifts: %w", err) } u.PremiumGifts = append(u.PremiumGifts, value) } @@ -1236,59 +1259,66 @@ func (u *UserFull) DecodeBare(b *bin.Buffer) error { if u.Flags.Has(24) { value, err := DecodeWallPaper(b) if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field wallpaper: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field wallpaper: %w", err) } u.Wallpaper = value } if u.Flags.Has(25) { if err := u.Stories.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field stories: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field stories: %w", err) } } if u.Flags2.Has(0) { if err := u.BusinessWorkHours.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field business_work_hours: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field business_work_hours: %w", err) } } if u.Flags2.Has(1) { if err := u.BusinessLocation.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field business_location: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field business_location: %w", err) } } if u.Flags2.Has(2) { if err := u.BusinessGreetingMessage.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field business_greeting_message: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field business_greeting_message: %w", err) } } if u.Flags2.Has(3) { if err := u.BusinessAwayMessage.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field business_away_message: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field business_away_message: %w", err) } } if u.Flags2.Has(4) { if err := u.BusinessIntro.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field business_intro: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field business_intro: %w", err) } } if u.Flags2.Has(5) { if err := u.Birthday.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field birthday: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field birthday: %w", err) } } if u.Flags2.Has(6) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field personal_channel_id: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field personal_channel_id: %w", err) } u.PersonalChannelID = value } if u.Flags2.Has(6) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#cc997720: field personal_channel_message: %w", err) + return fmt.Errorf("unable to decode userFull#1f58e369: field personal_channel_message: %w", err) } u.PersonalChannelMessage = value } + if u.Flags2.Has(8) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode userFull#1f58e369: field stargifts_count: %w", err) + } + u.StargiftsCount = value + } return nil } @@ -2004,6 +2034,24 @@ func (u *UserFull) GetPersonalChannelMessage() (value int, ok bool) { return u.PersonalChannelMessage, true } +// SetStargiftsCount sets value of StargiftsCount conditional field. +func (u *UserFull) SetStargiftsCount(value int) { + u.Flags2.Set(8) + u.StargiftsCount = value +} + +// GetStargiftsCount returns value of StargiftsCount conditional field and +// boolean which is true if field was set. +func (u *UserFull) GetStargiftsCount() (value int, ok bool) { + if u == nil { + return + } + if !u.Flags2.Has(8) { + return value, false + } + return u.StargiftsCount, true +} + // GetPersonalPhotoAsNotEmpty returns mapped value of PersonalPhoto conditional field and // boolean which is true if field was set. func (u *UserFull) GetPersonalPhotoAsNotEmpty() (*Photo, bool) { diff --git a/tg/tl_user_star_gift_gen.go b/tg/tl_user_star_gift_gen.go new file mode 100644 index 0000000000..175a1000be --- /dev/null +++ b/tg/tl_user_star_gift_gen.go @@ -0,0 +1,468 @@ +// 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{} +) + +// UserStarGift represents TL type `userStarGift#eea49a6e`. +// +// See https://core.telegram.org/constructor/userStarGift for reference. +type UserStarGift struct { + // Flags field of UserStarGift. + Flags bin.Fields + // NameHidden field of UserStarGift. + NameHidden bool + // Unsaved field of UserStarGift. + Unsaved bool + // FromID field of UserStarGift. + // + // Use SetFromID and GetFromID helpers. + FromID int64 + // Date field of UserStarGift. + Date int + // Gift field of UserStarGift. + Gift StarGift + // Message field of UserStarGift. + // + // Use SetMessage and GetMessage helpers. + Message TextWithEntities + // MsgID field of UserStarGift. + // + // Use SetMsgID and GetMsgID helpers. + MsgID int + // ConvertStars field of UserStarGift. + // + // Use SetConvertStars and GetConvertStars helpers. + ConvertStars int64 +} + +// UserStarGiftTypeID is TL type id of UserStarGift. +const UserStarGiftTypeID = 0xeea49a6e + +// Ensuring interfaces in compile-time for UserStarGift. +var ( + _ bin.Encoder = &UserStarGift{} + _ bin.Decoder = &UserStarGift{} + _ bin.BareEncoder = &UserStarGift{} + _ bin.BareDecoder = &UserStarGift{} +) + +func (u *UserStarGift) Zero() bool { + if u == nil { + return true + } + if !(u.Flags.Zero()) { + return false + } + if !(u.NameHidden == false) { + return false + } + if !(u.Unsaved == false) { + return false + } + if !(u.FromID == 0) { + return false + } + if !(u.Date == 0) { + return false + } + if !(u.Gift.Zero()) { + return false + } + if !(u.Message.Zero()) { + return false + } + if !(u.MsgID == 0) { + return false + } + if !(u.ConvertStars == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UserStarGift) String() string { + if u == nil { + return "UserStarGift(nil)" + } + type Alias UserStarGift + return fmt.Sprintf("UserStarGift%+v", Alias(*u)) +} + +// FillFrom fills UserStarGift from given interface. +func (u *UserStarGift) FillFrom(from interface { + GetNameHidden() (value bool) + GetUnsaved() (value bool) + GetFromID() (value int64, ok bool) + GetDate() (value int) + GetGift() (value StarGift) + GetMessage() (value TextWithEntities, ok bool) + GetMsgID() (value int, ok bool) + GetConvertStars() (value int64, ok bool) +}) { + u.NameHidden = from.GetNameHidden() + u.Unsaved = from.GetUnsaved() + if val, ok := from.GetFromID(); ok { + u.FromID = val + } + + u.Date = from.GetDate() + u.Gift = from.GetGift() + if val, ok := from.GetMessage(); ok { + u.Message = val + } + + if val, ok := from.GetMsgID(); ok { + u.MsgID = val + } + + if val, ok := from.GetConvertStars(); ok { + u.ConvertStars = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UserStarGift) TypeID() uint32 { + return UserStarGiftTypeID +} + +// TypeName returns name of type in TL schema. +func (*UserStarGift) TypeName() string { + return "userStarGift" +} + +// TypeInfo returns info about TL type. +func (u *UserStarGift) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "userStarGift", + ID: UserStarGiftTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "NameHidden", + SchemaName: "name_hidden", + Null: !u.Flags.Has(0), + }, + { + Name: "Unsaved", + SchemaName: "unsaved", + Null: !u.Flags.Has(5), + }, + { + Name: "FromID", + SchemaName: "from_id", + Null: !u.Flags.Has(1), + }, + { + Name: "Date", + SchemaName: "date", + }, + { + Name: "Gift", + SchemaName: "gift", + }, + { + Name: "Message", + SchemaName: "message", + Null: !u.Flags.Has(2), + }, + { + Name: "MsgID", + SchemaName: "msg_id", + Null: !u.Flags.Has(3), + }, + { + Name: "ConvertStars", + SchemaName: "convert_stars", + Null: !u.Flags.Has(4), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (u *UserStarGift) SetFlags() { + if !(u.NameHidden == false) { + u.Flags.Set(0) + } + if !(u.Unsaved == false) { + u.Flags.Set(5) + } + if !(u.FromID == 0) { + u.Flags.Set(1) + } + if !(u.Message.Zero()) { + u.Flags.Set(2) + } + if !(u.MsgID == 0) { + u.Flags.Set(3) + } + if !(u.ConvertStars == 0) { + u.Flags.Set(4) + } +} + +// Encode implements bin.Encoder. +func (u *UserStarGift) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode userStarGift#eea49a6e as nil") + } + b.PutID(UserStarGiftTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UserStarGift) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode userStarGift#eea49a6e as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode userStarGift#eea49a6e: field flags: %w", err) + } + if u.Flags.Has(1) { + b.PutLong(u.FromID) + } + b.PutInt(u.Date) + if err := u.Gift.Encode(b); err != nil { + return fmt.Errorf("unable to encode userStarGift#eea49a6e: field gift: %w", err) + } + if u.Flags.Has(2) { + if err := u.Message.Encode(b); err != nil { + return fmt.Errorf("unable to encode userStarGift#eea49a6e: field message: %w", err) + } + } + if u.Flags.Has(3) { + b.PutInt(u.MsgID) + } + if u.Flags.Has(4) { + b.PutLong(u.ConvertStars) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UserStarGift) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode userStarGift#eea49a6e to nil") + } + if err := b.ConsumeID(UserStarGiftTypeID); err != nil { + return fmt.Errorf("unable to decode userStarGift#eea49a6e: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UserStarGift) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode userStarGift#eea49a6e to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode userStarGift#eea49a6e: field flags: %w", err) + } + } + u.NameHidden = u.Flags.Has(0) + u.Unsaved = u.Flags.Has(5) + if u.Flags.Has(1) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode userStarGift#eea49a6e: field from_id: %w", err) + } + u.FromID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode userStarGift#eea49a6e: field date: %w", err) + } + u.Date = value + } + { + if err := u.Gift.Decode(b); err != nil { + return fmt.Errorf("unable to decode userStarGift#eea49a6e: field gift: %w", err) + } + } + if u.Flags.Has(2) { + if err := u.Message.Decode(b); err != nil { + return fmt.Errorf("unable to decode userStarGift#eea49a6e: field message: %w", err) + } + } + if u.Flags.Has(3) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode userStarGift#eea49a6e: field msg_id: %w", err) + } + u.MsgID = value + } + if u.Flags.Has(4) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode userStarGift#eea49a6e: field convert_stars: %w", err) + } + u.ConvertStars = value + } + return nil +} + +// SetNameHidden sets value of NameHidden conditional field. +func (u *UserStarGift) SetNameHidden(value bool) { + if value { + u.Flags.Set(0) + u.NameHidden = true + } else { + u.Flags.Unset(0) + u.NameHidden = false + } +} + +// GetNameHidden returns value of NameHidden conditional field. +func (u *UserStarGift) GetNameHidden() (value bool) { + if u == nil { + return + } + return u.Flags.Has(0) +} + +// SetUnsaved sets value of Unsaved conditional field. +func (u *UserStarGift) SetUnsaved(value bool) { + if value { + u.Flags.Set(5) + u.Unsaved = true + } else { + u.Flags.Unset(5) + u.Unsaved = false + } +} + +// GetUnsaved returns value of Unsaved conditional field. +func (u *UserStarGift) GetUnsaved() (value bool) { + if u == nil { + return + } + return u.Flags.Has(5) +} + +// SetFromID sets value of FromID conditional field. +func (u *UserStarGift) SetFromID(value int64) { + u.Flags.Set(1) + u.FromID = value +} + +// GetFromID returns value of FromID conditional field and +// boolean which is true if field was set. +func (u *UserStarGift) GetFromID() (value int64, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(1) { + return value, false + } + return u.FromID, true +} + +// GetDate returns value of Date field. +func (u *UserStarGift) GetDate() (value int) { + if u == nil { + return + } + return u.Date +} + +// GetGift returns value of Gift field. +func (u *UserStarGift) GetGift() (value StarGift) { + if u == nil { + return + } + return u.Gift +} + +// SetMessage sets value of Message conditional field. +func (u *UserStarGift) SetMessage(value TextWithEntities) { + u.Flags.Set(2) + u.Message = value +} + +// GetMessage returns value of Message conditional field and +// boolean which is true if field was set. +func (u *UserStarGift) GetMessage() (value TextWithEntities, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(2) { + return value, false + } + return u.Message, true +} + +// SetMsgID sets value of MsgID conditional field. +func (u *UserStarGift) SetMsgID(value int) { + u.Flags.Set(3) + u.MsgID = value +} + +// GetMsgID returns value of MsgID conditional field and +// boolean which is true if field was set. +func (u *UserStarGift) GetMsgID() (value int, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(3) { + return value, false + } + return u.MsgID, true +} + +// SetConvertStars sets value of ConvertStars conditional field. +func (u *UserStarGift) SetConvertStars(value int64) { + u.Flags.Set(4) + u.ConvertStars = value +} + +// GetConvertStars returns value of ConvertStars conditional field and +// boolean which is true if field was set. +func (u *UserStarGift) GetConvertStars() (value int64, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(4) { + return value, false + } + return u.ConvertStars, true +} diff --git a/tg/tl_user_star_gift_slices_gen.go b/tg/tl_user_star_gift_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_user_star_gift_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{} +)