diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index e079409f61..2f56328bcf 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: 186 -// SHA256: 35167eaa90ebc3170311143745be0c43d5881c3bd3b94fe6dc99f3e80d5e3363 +// Layer: 187 +// SHA256: 13e5ee643d6d776ab46f2cd1a21c9b274a4cb46106dea20770ebce90115e1e42 boolFalse#bc799737 = Bool; @@ -78,7 +78,7 @@ inputMediaStory#89fdd778 peer:InputPeer id:int = InputMedia; inputMediaWebPage#c21b8849 flags:# force_large_media:flags.0?true force_small_media:flags.1?true optional:flags.2?true url:string = InputMedia; -inputMediaPaidMedia#aa661fc3 stars_amount:long extended_media:Vector = InputMedia; +inputMediaPaidMedia#c4103386 flags:# stars_amount:long extended_media:Vector payload:flags.0?string = InputMedia; inputChatPhotoEmpty#1ca48f57 = InputChatPhoto; @@ -222,9 +222,9 @@ messageMediaDice#3f7ee58b value:int emoticon:string = MessageMedia; messageMediaStory#68cb6283 flags:# via_mention:flags.1?true peer:Peer id:int story:flags.0?StoryItem = MessageMedia; -messageMediaGiveaway#daad85b0 flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.2?true channels:Vector countries_iso2:flags.1?Vector prize_description:flags.3?string quantity:int months:int until_date:int = MessageMedia; +messageMediaGiveaway#aa073beb flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.2?true channels:Vector countries_iso2:flags.1?Vector prize_description:flags.3?string quantity:int months:flags.4?int stars:flags.5?long until_date:int = MessageMedia; -messageMediaGiveawayResults#c6991068 flags:# only_new_subscribers:flags.0?true refunded:flags.2?true channel_id:long additional_peers_count:flags.3?int launch_msg_id:int winners_count:int unclaimed_count:int winners:Vector months:int prize_description:flags.1?string until_date:int = MessageMedia; +messageMediaGiveawayResults#ceaa3ea1 flags:# only_new_subscribers:flags.0?true refunded:flags.2?true channel_id:long additional_peers_count:flags.3?int launch_msg_id:int winners_count:int unclaimed_count:int winners:Vector months:flags.4?int stars:flags.5?long prize_description:flags.1?string until_date:int = MessageMedia; messageMediaPaidMedia#a8852491 stars_amount:long extended_media:Vector = MessageMedia; @@ -306,9 +306,9 @@ messageActionSetChatWallPaper#5060a3f4 flags:# same:flags.0?true for_both:flags. messageActionGiftCode#678c2e09 flags:# via_giveaway:flags.0?true unclaimed:flags.2?true boost_peer:flags.1?Peer months:int slug:string currency:flags.2?string amount:flags.2?long crypto_currency:flags.3?string crypto_amount:flags.3?long = MessageAction; -messageActionGiveawayLaunch#332ba9ed = MessageAction; +messageActionGiveawayLaunch#a80f51e4 flags:# stars:flags.0?long = MessageAction; -messageActionGiveawayResults#2a9fadc5 winners_count:int unclaimed_count:int = MessageAction; +messageActionGiveawayResults#87e2f155 flags:# stars:flags.0?true winners_count:int unclaimed_count:int = MessageAction; messageActionBoostApply#cc02aa6d boosts:int = MessageAction; @@ -318,6 +318,8 @@ messageActionPaymentRefunded#41b3e202 flags:# peer:Peer currency:string total_am messageActionGiftStars#45d5b021 flags:# currency:string amount:long stars:long crypto_currency:flags.0?string crypto_amount:flags.0?long transaction_id:flags.1?string = MessageAction; +messageActionPrizeStars#b00c47a2 flags:# unclaimed:flags.0?true stars:long transaction_id:string boost_peer:Peer giveaway_msg_id:int = 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; @@ -744,6 +746,10 @@ updateBusinessBotCallbackQuery#1ea2fda7 flags:# query_id:long user_id:long conne updateStarsRevenueStatus#a584b019 peer:Peer status:StarsRevenueStatus = Update; +updateBotPurchasedPaidMedia#283bd312 user_id:long payload:string qts:int = Update; + +updatePaidReactionPrivacy#51ca7aec private:Bool = Update; + updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.differenceEmpty#5d75a138 date:int seq:int = updates.Difference; @@ -1666,11 +1672,13 @@ channelAdminLogEventActionChangeEmojiStickerSet#46d840ab prev_stickerset:InputSt channelAdminLogEventActionToggleSignatureProfiles#60a79c79 new_value:Bool = ChannelAdminLogEventAction; +channelAdminLogEventActionParticipantSubExtend#64642db3 prev_participant:ChannelParticipant new_participant:ChannelParticipant = ChannelAdminLogEventAction; + channelAdminLogEvent#1fad68cd id:long date:int user_id:long action:ChannelAdminLogEventAction = ChannelAdminLogEvent; channels.adminLogResults#ed8af74d events:Vector chats:Vector users:Vector = channels.AdminLogResults; -channelAdminLogEventsFilter#ea107ae4 flags:# join:flags.0?true leave:flags.1?true invite:flags.2?true ban:flags.3?true unban:flags.4?true kick:flags.5?true unkick:flags.6?true promote:flags.7?true demote:flags.8?true info:flags.9?true settings:flags.10?true pinned:flags.11?true edit:flags.12?true delete:flags.13?true group_call:flags.14?true invites:flags.15?true send:flags.16?true forums:flags.17?true = ChannelAdminLogEventsFilter; +channelAdminLogEventsFilter#ea107ae4 flags:# join:flags.0?true leave:flags.1?true invite:flags.2?true ban:flags.3?true unban:flags.4?true kick:flags.5?true unkick:flags.6?true promote:flags.7?true demote:flags.8?true info:flags.9?true settings:flags.10?true pinned:flags.11?true edit:flags.12?true delete:flags.13?true group_call:flags.14?true invites:flags.15?true send:flags.16?true forums:flags.17?true sub_extend:flags.18?true = ChannelAdminLogEventsFilter; popularContact#5ce14175 client_id:long importers:int = PopularContact; @@ -2240,6 +2248,8 @@ inputStorePaymentStarsTopup#dddd0f56 stars:long currency:string amount:long = In inputStorePaymentStarsGift#1d741ef7 user_id:InputUser stars:long currency:string amount:long = InputStorePaymentPurpose; +inputStorePaymentStarsGiveaway#751f08fa flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.3?true stars:long boost_peer:InputPeer additional_peers:flags.1?Vector countries_iso2:flags.2?Vector prize_description:flags.4?string random_id:long until_date:int currency:string amount:long users:int = InputStorePaymentPurpose; + premiumGiftOption#74c34319 flags:# months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumGiftOption; paymentFormMethod#88f8f21b url:string title:string = PaymentFormMethod; @@ -2442,11 +2452,13 @@ payments.checkedGiftCode#284a1096 flags:# via_giveaway:flags.2?true from_id:flag payments.giveawayInfo#4367daa0 flags:# participating:flags.0?true preparing_results:flags.3?true start_date:int joined_too_early_date:flags.1?int admin_disallowed_chat_id:flags.2?long disallowed_country:flags.4?string = payments.GiveawayInfo; -payments.giveawayInfoResults#cd5570 flags:# winner:flags.0?true refunded:flags.1?true start_date:int gift_code_slug:flags.0?string finish_date:int winners_count:int activated_count:int = payments.GiveawayInfo; +payments.giveawayInfoResults#e175e66f flags:# winner:flags.0?true refunded:flags.1?true start_date:int gift_code_slug:flags.3?string stars_prize:flags.4?long finish_date:int winners_count:int activated_count:flags.2?int = payments.GiveawayInfo; prepaidGiveaway#b2539d54 id:long months:int quantity:int date:int = PrepaidGiveaway; -boost#2a1c8c71 flags:# gift:flags.1?true giveaway:flags.2?true unclaimed:flags.3?true id:string user_id:flags.0?long giveaway_msg_id:flags.2?int date:int expires:int used_gift_slug:flags.4?string multiplier:flags.5?int = Boost; +prepaidStarsGiveaway#9a9d77e0 id:long stars:long quantity:int boosts:int date:int = PrepaidGiveaway; + +boost#4b3e14d6 flags:# gift:flags.1?true giveaway:flags.2?true unclaimed:flags.3?true id:string user_id:flags.0?long giveaway_msg_id:flags.2?int date:int expires:int used_gift_slug:flags.4?string multiplier:flags.5?int stars:flags.6?long = Boost; premium.boostsList#86f8613c flags:# count:int boosts:Vector next_offset:flags.0?string users:Vector = premium.BoostsList; @@ -2626,7 +2638,7 @@ reactionNotificationsFromAll#4b9e22a0 = ReactionNotificationsFrom; reactionsNotifySettings#56e34970 flags:# messages_notify_from:flags.0?ReactionNotificationsFrom stories_notify_from:flags.1?ReactionNotificationsFrom sound:NotificationSound show_previews:Bool = ReactionsNotifySettings; -broadcastRevenueBalances#8438f1c6 current_balance:long available_balance:long overall_revenue:long = BroadcastRevenueBalances; +broadcastRevenueBalances#c3ff71e7 flags:# withdrawal_enabled:flags.0?true current_balance:long available_balance:long overall_revenue:long = BroadcastRevenueBalances; availableEffect#93c3e27e flags:# premium_required:flags.2?true id:long emoticon:string static_icon_id:flags.0?long effect_sticker_id:long effect_animation_id:flags.1?long = AvailableEffect; @@ -2652,7 +2664,7 @@ starsTransactionPeerAds#60682812 = StarsTransactionPeer; starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; -starsTransaction#433aeb2b 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 = StarsTransaction; +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; 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; @@ -2686,6 +2698,10 @@ starsSubscription#538ecf18 flags:# canceled:flags.0?true can_refulfill:flags.1?t messageReactor#4ba3a95a flags:# top:flags.0?true my:flags.1?true anonymous:flags.2?true peer_id:flags.3?Peer count:int = MessageReactor; +starsGiveawayOption#94ce852a flags:# extended:flags.0?true default:flags.1?true stars:long yearly_boosts:int store_product:flags.2?string currency:string amount:long winners:Vector = StarsGiveawayOption; + +starsGiveawayWinnersOption#54236209 flags:# default:flags.0?true users:int per_user_stars:long = StarsGiveawayWinnersOption; + ---functions--- @@ -3467,10 +3483,12 @@ messages.getFactCheck#b9cdc5ee peer:InputPeer msg_id:Vector = Vector; + stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true emojis:flags.5?true text_color:flags.6?true user_id:InputUser title:string short_name:string thumb:flags.2?InputDocument stickers:Vector software:flags.3?string = messages.StickerSet; stickers.removeStickerFromSet#f7760f51 sticker:InputDocument = messages.StickerSet; @@ -4003,4 +4023,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 186 +// LAYER 187 diff --git a/_schema/tdlib.tl b/_schema/tdlib.tl index f0018bacd2..181155018b 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: 186 -// SHA256: b6e9932a15d58b104a43317cdaf69b5ee3500d705e4e08de8d2bc5cf5635160a +// Layer: 187 +// SHA256: 00fe5de958d6979d95da72e956e3c71b137de5b973f259370f4bae0b18978b46 int#a8509bda ? = Int; @@ -114,7 +114,7 @@ inputMediaStory#89fdd778 peer:InputPeer id:int = InputMedia; inputMediaWebPage#c21b8849 flags:# force_large_media:flags.0?true force_small_media:flags.1?true optional:flags.2?true url:string = InputMedia; -inputMediaPaidMedia#aa661fc3 stars_amount:long extended_media:Vector = InputMedia; +inputMediaPaidMedia#c4103386 flags:# stars_amount:long extended_media:Vector payload:flags.0?string = InputMedia; inputChatPhotoEmpty#1ca48f57 = InputChatPhoto; @@ -258,9 +258,9 @@ messageMediaDice#3f7ee58b value:int emoticon:string = MessageMedia; messageMediaStory#68cb6283 flags:# via_mention:flags.1?true peer:Peer id:int story:flags.0?StoryItem = MessageMedia; -messageMediaGiveaway#daad85b0 flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.2?true channels:Vector countries_iso2:flags.1?Vector prize_description:flags.3?string quantity:int months:int until_date:int = MessageMedia; +messageMediaGiveaway#aa073beb flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.2?true channels:Vector countries_iso2:flags.1?Vector prize_description:flags.3?string quantity:int months:flags.4?int stars:flags.5?long until_date:int = MessageMedia; -messageMediaGiveawayResults#c6991068 flags:# only_new_subscribers:flags.0?true refunded:flags.2?true channel_id:long additional_peers_count:flags.3?int launch_msg_id:int winners_count:int unclaimed_count:int winners:Vector months:int prize_description:flags.1?string until_date:int = MessageMedia; +messageMediaGiveawayResults#ceaa3ea1 flags:# only_new_subscribers:flags.0?true refunded:flags.2?true channel_id:long additional_peers_count:flags.3?int launch_msg_id:int winners_count:int unclaimed_count:int winners:Vector months:flags.4?int stars:flags.5?long prize_description:flags.1?string until_date:int = MessageMedia; messageMediaPaidMedia#a8852491 stars_amount:long extended_media:Vector = MessageMedia; @@ -342,9 +342,9 @@ messageActionSetChatWallPaper#5060a3f4 flags:# same:flags.0?true for_both:flags. messageActionGiftCode#678c2e09 flags:# via_giveaway:flags.0?true unclaimed:flags.2?true boost_peer:flags.1?Peer months:int slug:string currency:flags.2?string amount:flags.2?long crypto_currency:flags.3?string crypto_amount:flags.3?long = MessageAction; -messageActionGiveawayLaunch#332ba9ed = MessageAction; +messageActionGiveawayLaunch#a80f51e4 flags:# stars:flags.0?long = MessageAction; -messageActionGiveawayResults#2a9fadc5 winners_count:int unclaimed_count:int = MessageAction; +messageActionGiveawayResults#87e2f155 flags:# stars:flags.0?true winners_count:int unclaimed_count:int = MessageAction; messageActionBoostApply#cc02aa6d boosts:int = MessageAction; @@ -354,6 +354,8 @@ messageActionPaymentRefunded#41b3e202 flags:# peer:Peer currency:string total_am messageActionGiftStars#45d5b021 flags:# currency:string amount:long stars:long crypto_currency:flags.0?string crypto_amount:flags.0?long transaction_id:flags.1?string = MessageAction; +messageActionPrizeStars#b00c47a2 flags:# unclaimed:flags.0?true stars:long transaction_id:string boost_peer:Peer giveaway_msg_id:int = 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; @@ -780,6 +782,10 @@ updateBusinessBotCallbackQuery#1ea2fda7 flags:# query_id:long user_id:long conne updateStarsRevenueStatus#a584b019 peer:Peer status:StarsRevenueStatus = Update; +updateBotPurchasedPaidMedia#283bd312 user_id:long payload:string qts:int = Update; + +updatePaidReactionPrivacy#51ca7aec private:Bool = Update; + updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.differenceEmpty#5d75a138 date:int seq:int = updates.Difference; @@ -1702,11 +1708,13 @@ channelAdminLogEventActionChangeEmojiStickerSet#46d840ab prev_stickerset:InputSt channelAdminLogEventActionToggleSignatureProfiles#60a79c79 new_value:Bool = ChannelAdminLogEventAction; +channelAdminLogEventActionParticipantSubExtend#64642db3 prev_participant:ChannelParticipant new_participant:ChannelParticipant = ChannelAdminLogEventAction; + channelAdminLogEvent#1fad68cd id:long date:int user_id:long action:ChannelAdminLogEventAction = ChannelAdminLogEvent; channels.adminLogResults#ed8af74d events:Vector chats:Vector users:Vector = channels.AdminLogResults; -channelAdminLogEventsFilter#ea107ae4 flags:# join:flags.0?true leave:flags.1?true invite:flags.2?true ban:flags.3?true unban:flags.4?true kick:flags.5?true unkick:flags.6?true promote:flags.7?true demote:flags.8?true info:flags.9?true settings:flags.10?true pinned:flags.11?true edit:flags.12?true delete:flags.13?true group_call:flags.14?true invites:flags.15?true send:flags.16?true forums:flags.17?true = ChannelAdminLogEventsFilter; +channelAdminLogEventsFilter#ea107ae4 flags:# join:flags.0?true leave:flags.1?true invite:flags.2?true ban:flags.3?true unban:flags.4?true kick:flags.5?true unkick:flags.6?true promote:flags.7?true demote:flags.8?true info:flags.9?true settings:flags.10?true pinned:flags.11?true edit:flags.12?true delete:flags.13?true group_call:flags.14?true invites:flags.15?true send:flags.16?true forums:flags.17?true sub_extend:flags.18?true = ChannelAdminLogEventsFilter; popularContact#5ce14175 client_id:long importers:int = PopularContact; @@ -2276,6 +2284,8 @@ inputStorePaymentStarsTopup#dddd0f56 stars:long currency:string amount:long = In inputStorePaymentStarsGift#1d741ef7 user_id:InputUser stars:long currency:string amount:long = InputStorePaymentPurpose; +inputStorePaymentStarsGiveaway#751f08fa flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.3?true stars:long boost_peer:InputPeer additional_peers:flags.1?Vector countries_iso2:flags.2?Vector prize_description:flags.4?string random_id:long until_date:int currency:string amount:long users:int = InputStorePaymentPurpose; + premiumGiftOption#74c34319 flags:# months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumGiftOption; paymentFormMethod#88f8f21b url:string title:string = PaymentFormMethod; @@ -2478,11 +2488,13 @@ payments.checkedGiftCode#284a1096 flags:# via_giveaway:flags.2?true from_id:flag payments.giveawayInfo#4367daa0 flags:# participating:flags.0?true preparing_results:flags.3?true start_date:int joined_too_early_date:flags.1?int admin_disallowed_chat_id:flags.2?long disallowed_country:flags.4?string = payments.GiveawayInfo; -payments.giveawayInfoResults#cd5570 flags:# winner:flags.0?true refunded:flags.1?true start_date:int gift_code_slug:flags.0?string finish_date:int winners_count:int activated_count:int = payments.GiveawayInfo; +payments.giveawayInfoResults#e175e66f flags:# winner:flags.0?true refunded:flags.1?true start_date:int gift_code_slug:flags.3?string stars_prize:flags.4?long finish_date:int winners_count:int activated_count:flags.2?int = payments.GiveawayInfo; prepaidGiveaway#b2539d54 id:long months:int quantity:int date:int = PrepaidGiveaway; -boost#2a1c8c71 flags:# gift:flags.1?true giveaway:flags.2?true unclaimed:flags.3?true id:string user_id:flags.0?long giveaway_msg_id:flags.2?int date:int expires:int used_gift_slug:flags.4?string multiplier:flags.5?int = Boost; +prepaidStarsGiveaway#9a9d77e0 id:long stars:long quantity:int boosts:int date:int = PrepaidGiveaway; + +boost#4b3e14d6 flags:# gift:flags.1?true giveaway:flags.2?true unclaimed:flags.3?true id:string user_id:flags.0?long giveaway_msg_id:flags.2?int date:int expires:int used_gift_slug:flags.4?string multiplier:flags.5?int stars:flags.6?long = Boost; premium.boostsList#86f8613c flags:# count:int boosts:Vector next_offset:flags.0?string users:Vector = premium.BoostsList; @@ -2662,7 +2674,7 @@ reactionNotificationsFromAll#4b9e22a0 = ReactionNotificationsFrom; reactionsNotifySettings#56e34970 flags:# messages_notify_from:flags.0?ReactionNotificationsFrom stories_notify_from:flags.1?ReactionNotificationsFrom sound:NotificationSound show_previews:Bool = ReactionsNotifySettings; -broadcastRevenueBalances#8438f1c6 current_balance:long available_balance:long overall_revenue:long = BroadcastRevenueBalances; +broadcastRevenueBalances#c3ff71e7 flags:# withdrawal_enabled:flags.0?true current_balance:long available_balance:long overall_revenue:long = BroadcastRevenueBalances; availableEffect#93c3e27e flags:# premium_required:flags.2?true id:long emoticon:string static_icon_id:flags.0?long effect_sticker_id:long effect_animation_id:flags.1?long = AvailableEffect; @@ -2688,7 +2700,7 @@ starsTransactionPeerAds#60682812 = StarsTransactionPeer; starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; -starsTransaction#433aeb2b 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 = StarsTransaction; +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; 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; @@ -2722,6 +2734,10 @@ starsSubscription#538ecf18 flags:# canceled:flags.0?true can_refulfill:flags.1?t messageReactor#4ba3a95a flags:# top:flags.0?true my:flags.1?true anonymous:flags.2?true peer_id:flags.3?Peer count:int = MessageReactor; +starsGiveawayOption#94ce852a flags:# extended:flags.0?true default:flags.1?true stars:long yearly_boosts:int store_product:flags.2?string currency:string amount:long winners:Vector = StarsGiveawayOption; + +starsGiveawayWinnersOption#54236209 flags:# default:flags.0?true users:int per_user_stars:long = StarsGiveawayWinnersOption; + ---functions--- @@ -3503,10 +3519,12 @@ messages.getFactCheck#b9cdc5ee peer:InputPeer msg_id:Vector = Vector; + stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true emojis:flags.5?true text_color:flags.6?true user_id:InputUser title:string short_name:string thumb:flags.2?InputDocument stickers:Vector software:flags.3?string = messages.StickerSet; stickers.removeStickerFromSet#f7760f51 sticker:InputDocument = messages.StickerSet; @@ -4039,4 +4059,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 186 +// LAYER 187 diff --git a/_schema/telegram.tl b/_schema/telegram.tl index d1acdf397b..d5109b4366 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: 186 -// SHA256: 35167eaa90ebc3170311143745be0c43d5881c3bd3b94fe6dc99f3e80d5e3363 +// Layer: 187 +// SHA256: 13e5ee643d6d776ab46f2cd1a21c9b274a4cb46106dea20770ebce90115e1e42 boolFalse#bc799737 = Bool; @@ -79,7 +79,7 @@ inputMediaStory#89fdd778 peer:InputPeer id:int = InputMedia; inputMediaWebPage#c21b8849 flags:# force_large_media:flags.0?true force_small_media:flags.1?true optional:flags.2?true url:string = InputMedia; -inputMediaPaidMedia#aa661fc3 stars_amount:long extended_media:Vector = InputMedia; +inputMediaPaidMedia#c4103386 flags:# stars_amount:long extended_media:Vector payload:flags.0?string = InputMedia; inputChatPhotoEmpty#1ca48f57 = InputChatPhoto; @@ -223,9 +223,9 @@ messageMediaDice#3f7ee58b value:int emoticon:string = MessageMedia; messageMediaStory#68cb6283 flags:# via_mention:flags.1?true peer:Peer id:int story:flags.0?StoryItem = MessageMedia; -messageMediaGiveaway#daad85b0 flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.2?true channels:Vector countries_iso2:flags.1?Vector prize_description:flags.3?string quantity:int months:int until_date:int = MessageMedia; +messageMediaGiveaway#aa073beb flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.2?true channels:Vector countries_iso2:flags.1?Vector prize_description:flags.3?string quantity:int months:flags.4?int stars:flags.5?long until_date:int = MessageMedia; -messageMediaGiveawayResults#c6991068 flags:# only_new_subscribers:flags.0?true refunded:flags.2?true channel_id:long additional_peers_count:flags.3?int launch_msg_id:int winners_count:int unclaimed_count:int winners:Vector months:int prize_description:flags.1?string until_date:int = MessageMedia; +messageMediaGiveawayResults#ceaa3ea1 flags:# only_new_subscribers:flags.0?true refunded:flags.2?true channel_id:long additional_peers_count:flags.3?int launch_msg_id:int winners_count:int unclaimed_count:int winners:Vector months:flags.4?int stars:flags.5?long prize_description:flags.1?string until_date:int = MessageMedia; messageMediaPaidMedia#a8852491 stars_amount:long extended_media:Vector = MessageMedia; @@ -307,9 +307,9 @@ messageActionSetChatWallPaper#5060a3f4 flags:# same:flags.0?true for_both:flags. messageActionGiftCode#678c2e09 flags:# via_giveaway:flags.0?true unclaimed:flags.2?true boost_peer:flags.1?Peer months:int slug:string currency:flags.2?string amount:flags.2?long crypto_currency:flags.3?string crypto_amount:flags.3?long = MessageAction; -messageActionGiveawayLaunch#332ba9ed = MessageAction; +messageActionGiveawayLaunch#a80f51e4 flags:# stars:flags.0?long = MessageAction; -messageActionGiveawayResults#2a9fadc5 winners_count:int unclaimed_count:int = MessageAction; +messageActionGiveawayResults#87e2f155 flags:# stars:flags.0?true winners_count:int unclaimed_count:int = MessageAction; messageActionBoostApply#cc02aa6d boosts:int = MessageAction; @@ -319,6 +319,8 @@ messageActionPaymentRefunded#41b3e202 flags:# peer:Peer currency:string total_am messageActionGiftStars#45d5b021 flags:# currency:string amount:long stars:long crypto_currency:flags.0?string crypto_amount:flags.0?long transaction_id:flags.1?string = MessageAction; +messageActionPrizeStars#b00c47a2 flags:# unclaimed:flags.0?true stars:long transaction_id:string boost_peer:Peer giveaway_msg_id:int = 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; @@ -745,6 +747,10 @@ updateBusinessBotCallbackQuery#1ea2fda7 flags:# query_id:long user_id:long conne updateStarsRevenueStatus#a584b019 peer:Peer status:StarsRevenueStatus = Update; +updateBotPurchasedPaidMedia#283bd312 user_id:long payload:string qts:int = Update; + +updatePaidReactionPrivacy#51ca7aec private:Bool = Update; + updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.differenceEmpty#5d75a138 date:int seq:int = updates.Difference; @@ -1667,11 +1673,13 @@ channelAdminLogEventActionChangeEmojiStickerSet#46d840ab prev_stickerset:InputSt channelAdminLogEventActionToggleSignatureProfiles#60a79c79 new_value:Bool = ChannelAdminLogEventAction; +channelAdminLogEventActionParticipantSubExtend#64642db3 prev_participant:ChannelParticipant new_participant:ChannelParticipant = ChannelAdminLogEventAction; + channelAdminLogEvent#1fad68cd id:long date:int user_id:long action:ChannelAdminLogEventAction = ChannelAdminLogEvent; channels.adminLogResults#ed8af74d events:Vector chats:Vector users:Vector = channels.AdminLogResults; -channelAdminLogEventsFilter#ea107ae4 flags:# join:flags.0?true leave:flags.1?true invite:flags.2?true ban:flags.3?true unban:flags.4?true kick:flags.5?true unkick:flags.6?true promote:flags.7?true demote:flags.8?true info:flags.9?true settings:flags.10?true pinned:flags.11?true edit:flags.12?true delete:flags.13?true group_call:flags.14?true invites:flags.15?true send:flags.16?true forums:flags.17?true = ChannelAdminLogEventsFilter; +channelAdminLogEventsFilter#ea107ae4 flags:# join:flags.0?true leave:flags.1?true invite:flags.2?true ban:flags.3?true unban:flags.4?true kick:flags.5?true unkick:flags.6?true promote:flags.7?true demote:flags.8?true info:flags.9?true settings:flags.10?true pinned:flags.11?true edit:flags.12?true delete:flags.13?true group_call:flags.14?true invites:flags.15?true send:flags.16?true forums:flags.17?true sub_extend:flags.18?true = ChannelAdminLogEventsFilter; popularContact#5ce14175 client_id:long importers:int = PopularContact; @@ -2241,6 +2249,8 @@ inputStorePaymentStarsTopup#dddd0f56 stars:long currency:string amount:long = In inputStorePaymentStarsGift#1d741ef7 user_id:InputUser stars:long currency:string amount:long = InputStorePaymentPurpose; +inputStorePaymentStarsGiveaway#751f08fa flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.3?true stars:long boost_peer:InputPeer additional_peers:flags.1?Vector countries_iso2:flags.2?Vector prize_description:flags.4?string random_id:long until_date:int currency:string amount:long users:int = InputStorePaymentPurpose; + premiumGiftOption#74c34319 flags:# months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumGiftOption; paymentFormMethod#88f8f21b url:string title:string = PaymentFormMethod; @@ -2443,11 +2453,13 @@ payments.checkedGiftCode#284a1096 flags:# via_giveaway:flags.2?true from_id:flag payments.giveawayInfo#4367daa0 flags:# participating:flags.0?true preparing_results:flags.3?true start_date:int joined_too_early_date:flags.1?int admin_disallowed_chat_id:flags.2?long disallowed_country:flags.4?string = payments.GiveawayInfo; -payments.giveawayInfoResults#cd5570 flags:# winner:flags.0?true refunded:flags.1?true start_date:int gift_code_slug:flags.0?string finish_date:int winners_count:int activated_count:int = payments.GiveawayInfo; +payments.giveawayInfoResults#e175e66f flags:# winner:flags.0?true refunded:flags.1?true start_date:int gift_code_slug:flags.3?string stars_prize:flags.4?long finish_date:int winners_count:int activated_count:flags.2?int = payments.GiveawayInfo; prepaidGiveaway#b2539d54 id:long months:int quantity:int date:int = PrepaidGiveaway; -boost#2a1c8c71 flags:# gift:flags.1?true giveaway:flags.2?true unclaimed:flags.3?true id:string user_id:flags.0?long giveaway_msg_id:flags.2?int date:int expires:int used_gift_slug:flags.4?string multiplier:flags.5?int = Boost; +prepaidStarsGiveaway#9a9d77e0 id:long stars:long quantity:int boosts:int date:int = PrepaidGiveaway; + +boost#4b3e14d6 flags:# gift:flags.1?true giveaway:flags.2?true unclaimed:flags.3?true id:string user_id:flags.0?long giveaway_msg_id:flags.2?int date:int expires:int used_gift_slug:flags.4?string multiplier:flags.5?int stars:flags.6?long = Boost; premium.boostsList#86f8613c flags:# count:int boosts:Vector next_offset:flags.0?string users:Vector = premium.BoostsList; @@ -2627,7 +2639,7 @@ reactionNotificationsFromAll#4b9e22a0 = ReactionNotificationsFrom; reactionsNotifySettings#56e34970 flags:# messages_notify_from:flags.0?ReactionNotificationsFrom stories_notify_from:flags.1?ReactionNotificationsFrom sound:NotificationSound show_previews:Bool = ReactionsNotifySettings; -broadcastRevenueBalances#8438f1c6 current_balance:long available_balance:long overall_revenue:long = BroadcastRevenueBalances; +broadcastRevenueBalances#c3ff71e7 flags:# withdrawal_enabled:flags.0?true current_balance:long available_balance:long overall_revenue:long = BroadcastRevenueBalances; availableEffect#93c3e27e flags:# premium_required:flags.2?true id:long emoticon:string static_icon_id:flags.0?long effect_sticker_id:long effect_animation_id:flags.1?long = AvailableEffect; @@ -2653,7 +2665,7 @@ starsTransactionPeerAds#60682812 = StarsTransactionPeer; starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; -starsTransaction#433aeb2b 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 = StarsTransaction; +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; 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; @@ -2687,6 +2699,10 @@ starsSubscription#538ecf18 flags:# canceled:flags.0?true can_refulfill:flags.1?t messageReactor#4ba3a95a flags:# top:flags.0?true my:flags.1?true anonymous:flags.2?true peer_id:flags.3?Peer count:int = MessageReactor; +starsGiveawayOption#94ce852a flags:# extended:flags.0?true default:flags.1?true stars:long yearly_boosts:int store_product:flags.2?string currency:string amount:long winners:Vector = StarsGiveawayOption; + +starsGiveawayWinnersOption#54236209 flags:# default:flags.0?true users:int per_user_stars:long = StarsGiveawayWinnersOption; + ---functions--- @@ -3468,10 +3484,12 @@ messages.getFactCheck#b9cdc5ee peer:InputPeer msg_id:Vector = Vector; + stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true emojis:flags.5?true text_color:flags.6?true user_id:InputUser title:string short_name:string thumb:flags.2?InputDocument stickers:Vector software:flags.3?string = messages.StickerSet; stickers.removeStickerFromSet#f7760f51 sticker:InputDocument = messages.StickerSet; @@ -4036,4 +4056,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 186 +// LAYER 187 diff --git a/tg/tl_boost_gen.go b/tg/tl_boost_gen.go index d7d873a16d..32b03a615d 100644 --- a/tg/tl_boost_gen.go +++ b/tg/tl_boost_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// Boost represents TL type `boost#2a1c8c71`. +// Boost represents TL type `boost#4b3e14d6`. // Info about one or more boosts¹ applied by a specific user. // // Links: @@ -90,10 +90,14 @@ type Boost struct { // // Use SetMultiplier and GetMultiplier helpers. Multiplier int + // Stars field of Boost. + // + // Use SetStars and GetStars helpers. + Stars int64 } // BoostTypeID is TL type id of Boost. -const BoostTypeID = 0x2a1c8c71 +const BoostTypeID = 0x4b3e14d6 // Ensuring interfaces in compile-time for Boost. var ( @@ -140,6 +144,9 @@ func (b *Boost) Zero() bool { if !(b.Multiplier == 0) { return false } + if !(b.Stars == 0) { + return false + } return true } @@ -165,6 +172,7 @@ func (b *Boost) FillFrom(from interface { GetExpires() (value int) GetUsedGiftSlug() (value string, ok bool) GetMultiplier() (value int, ok bool) + GetStars() (value int64, ok bool) }) { b.Gift = from.GetGift() b.Giveaway = from.GetGiveaway() @@ -188,6 +196,10 @@ func (b *Boost) FillFrom(from interface { b.Multiplier = val } + if val, ok := from.GetStars(); ok { + b.Stars = val + } + } // TypeID returns type id in TL schema. @@ -260,6 +272,11 @@ func (b *Boost) TypeInfo() tdp.Type { SchemaName: "multiplier", Null: !b.Flags.Has(5), }, + { + Name: "Stars", + SchemaName: "stars", + Null: !b.Flags.Has(6), + }, } return typ } @@ -287,12 +304,15 @@ func (b *Boost) SetFlags() { if !(b.Multiplier == 0) { b.Flags.Set(5) } + if !(b.Stars == 0) { + b.Flags.Set(6) + } } // Encode implements bin.Encoder. func (b *Boost) Encode(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't encode boost#2a1c8c71 as nil") + return fmt.Errorf("can't encode boost#4b3e14d6 as nil") } buf.PutID(BoostTypeID) return b.EncodeBare(buf) @@ -301,11 +321,11 @@ func (b *Boost) Encode(buf *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (b *Boost) EncodeBare(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't encode boost#2a1c8c71 as nil") + return fmt.Errorf("can't encode boost#4b3e14d6 as nil") } b.SetFlags() if err := b.Flags.Encode(buf); err != nil { - return fmt.Errorf("unable to encode boost#2a1c8c71: field flags: %w", err) + return fmt.Errorf("unable to encode boost#4b3e14d6: field flags: %w", err) } buf.PutString(b.ID) if b.Flags.Has(0) { @@ -322,16 +342,19 @@ func (b *Boost) EncodeBare(buf *bin.Buffer) error { if b.Flags.Has(5) { buf.PutInt(b.Multiplier) } + if b.Flags.Has(6) { + buf.PutLong(b.Stars) + } return nil } // Decode implements bin.Decoder. func (b *Boost) Decode(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't decode boost#2a1c8c71 to nil") + return fmt.Errorf("can't decode boost#4b3e14d6 to nil") } if err := buf.ConsumeID(BoostTypeID); err != nil { - return fmt.Errorf("unable to decode boost#2a1c8c71: %w", err) + return fmt.Errorf("unable to decode boost#4b3e14d6: %w", err) } return b.DecodeBare(buf) } @@ -339,11 +362,11 @@ func (b *Boost) Decode(buf *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (b *Boost) DecodeBare(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't decode boost#2a1c8c71 to nil") + return fmt.Errorf("can't decode boost#4b3e14d6 to nil") } { if err := b.Flags.Decode(buf); err != nil { - return fmt.Errorf("unable to decode boost#2a1c8c71: field flags: %w", err) + return fmt.Errorf("unable to decode boost#4b3e14d6: field flags: %w", err) } } b.Gift = b.Flags.Has(1) @@ -352,52 +375,59 @@ func (b *Boost) DecodeBare(buf *bin.Buffer) error { { value, err := buf.String() if err != nil { - return fmt.Errorf("unable to decode boost#2a1c8c71: field id: %w", err) + return fmt.Errorf("unable to decode boost#4b3e14d6: field id: %w", err) } b.ID = value } if b.Flags.Has(0) { value, err := buf.Long() if err != nil { - return fmt.Errorf("unable to decode boost#2a1c8c71: field user_id: %w", err) + return fmt.Errorf("unable to decode boost#4b3e14d6: field user_id: %w", err) } b.UserID = value } if b.Flags.Has(2) { value, err := buf.Int() if err != nil { - return fmt.Errorf("unable to decode boost#2a1c8c71: field giveaway_msg_id: %w", err) + return fmt.Errorf("unable to decode boost#4b3e14d6: field giveaway_msg_id: %w", err) } b.GiveawayMsgID = value } { value, err := buf.Int() if err != nil { - return fmt.Errorf("unable to decode boost#2a1c8c71: field date: %w", err) + return fmt.Errorf("unable to decode boost#4b3e14d6: field date: %w", err) } b.Date = value } { value, err := buf.Int() if err != nil { - return fmt.Errorf("unable to decode boost#2a1c8c71: field expires: %w", err) + return fmt.Errorf("unable to decode boost#4b3e14d6: field expires: %w", err) } b.Expires = value } if b.Flags.Has(4) { value, err := buf.String() if err != nil { - return fmt.Errorf("unable to decode boost#2a1c8c71: field used_gift_slug: %w", err) + return fmt.Errorf("unable to decode boost#4b3e14d6: field used_gift_slug: %w", err) } b.UsedGiftSlug = value } if b.Flags.Has(5) { value, err := buf.Int() if err != nil { - return fmt.Errorf("unable to decode boost#2a1c8c71: field multiplier: %w", err) + return fmt.Errorf("unable to decode boost#4b3e14d6: field multiplier: %w", err) } b.Multiplier = value } + if b.Flags.Has(6) { + value, err := buf.Long() + if err != nil { + return fmt.Errorf("unable to decode boost#4b3e14d6: field stars: %w", err) + } + b.Stars = value + } return nil } @@ -553,3 +583,21 @@ func (b *Boost) GetMultiplier() (value int, ok bool) { } return b.Multiplier, true } + +// SetStars sets value of Stars conditional field. +func (b *Boost) SetStars(value int64) { + b.Flags.Set(6) + b.Stars = value +} + +// GetStars returns value of Stars conditional field and +// boolean which is true if field was set. +func (b *Boost) GetStars() (value int64, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(6) { + return value, false + } + return b.Stars, true +} diff --git a/tg/tl_broadcast_revenue_balances_gen.go b/tg/tl_broadcast_revenue_balances_gen.go index 4ee8c6b861..59715cd579 100644 --- a/tg/tl_broadcast_revenue_balances_gen.go +++ b/tg/tl_broadcast_revenue_balances_gen.go @@ -31,10 +31,14 @@ var ( _ = tdjson.Encoder{} ) -// BroadcastRevenueBalances represents TL type `broadcastRevenueBalances#8438f1c6`. +// BroadcastRevenueBalances represents TL type `broadcastRevenueBalances#c3ff71e7`. // // See https://core.telegram.org/constructor/broadcastRevenueBalances for reference. type BroadcastRevenueBalances struct { + // Flags field of BroadcastRevenueBalances. + Flags bin.Fields + // WithdrawalEnabled field of BroadcastRevenueBalances. + WithdrawalEnabled bool // CurrentBalance field of BroadcastRevenueBalances. CurrentBalance int64 // AvailableBalance field of BroadcastRevenueBalances. @@ -44,7 +48,7 @@ type BroadcastRevenueBalances struct { } // BroadcastRevenueBalancesTypeID is TL type id of BroadcastRevenueBalances. -const BroadcastRevenueBalancesTypeID = 0x8438f1c6 +const BroadcastRevenueBalancesTypeID = 0xc3ff71e7 // Ensuring interfaces in compile-time for BroadcastRevenueBalances. var ( @@ -58,6 +62,12 @@ func (b *BroadcastRevenueBalances) Zero() bool { if b == nil { return true } + if !(b.Flags.Zero()) { + return false + } + if !(b.WithdrawalEnabled == false) { + return false + } if !(b.CurrentBalance == 0) { return false } @@ -82,10 +92,12 @@ func (b *BroadcastRevenueBalances) String() string { // FillFrom fills BroadcastRevenueBalances from given interface. func (b *BroadcastRevenueBalances) FillFrom(from interface { + GetWithdrawalEnabled() (value bool) GetCurrentBalance() (value int64) GetAvailableBalance() (value int64) GetOverallRevenue() (value int64) }) { + b.WithdrawalEnabled = from.GetWithdrawalEnabled() b.CurrentBalance = from.GetCurrentBalance() b.AvailableBalance = from.GetAvailableBalance() b.OverallRevenue = from.GetOverallRevenue() @@ -114,6 +126,11 @@ func (b *BroadcastRevenueBalances) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "WithdrawalEnabled", + SchemaName: "withdrawal_enabled", + Null: !b.Flags.Has(0), + }, { Name: "CurrentBalance", SchemaName: "current_balance", @@ -130,10 +147,17 @@ func (b *BroadcastRevenueBalances) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (b *BroadcastRevenueBalances) SetFlags() { + if !(b.WithdrawalEnabled == false) { + b.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (b *BroadcastRevenueBalances) Encode(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't encode broadcastRevenueBalances#8438f1c6 as nil") + return fmt.Errorf("can't encode broadcastRevenueBalances#c3ff71e7 as nil") } buf.PutID(BroadcastRevenueBalancesTypeID) return b.EncodeBare(buf) @@ -142,7 +166,11 @@ func (b *BroadcastRevenueBalances) Encode(buf *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (b *BroadcastRevenueBalances) EncodeBare(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't encode broadcastRevenueBalances#8438f1c6 as nil") + return fmt.Errorf("can't encode broadcastRevenueBalances#c3ff71e7 as nil") + } + b.SetFlags() + if err := b.Flags.Encode(buf); err != nil { + return fmt.Errorf("unable to encode broadcastRevenueBalances#c3ff71e7: field flags: %w", err) } buf.PutLong(b.CurrentBalance) buf.PutLong(b.AvailableBalance) @@ -153,10 +181,10 @@ func (b *BroadcastRevenueBalances) EncodeBare(buf *bin.Buffer) error { // Decode implements bin.Decoder. func (b *BroadcastRevenueBalances) Decode(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't decode broadcastRevenueBalances#8438f1c6 to nil") + return fmt.Errorf("can't decode broadcastRevenueBalances#c3ff71e7 to nil") } if err := buf.ConsumeID(BroadcastRevenueBalancesTypeID); err != nil { - return fmt.Errorf("unable to decode broadcastRevenueBalances#8438f1c6: %w", err) + return fmt.Errorf("unable to decode broadcastRevenueBalances#c3ff71e7: %w", err) } return b.DecodeBare(buf) } @@ -164,32 +192,57 @@ func (b *BroadcastRevenueBalances) Decode(buf *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (b *BroadcastRevenueBalances) DecodeBare(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't decode broadcastRevenueBalances#8438f1c6 to nil") + return fmt.Errorf("can't decode broadcastRevenueBalances#c3ff71e7 to nil") } + { + if err := b.Flags.Decode(buf); err != nil { + return fmt.Errorf("unable to decode broadcastRevenueBalances#c3ff71e7: field flags: %w", err) + } + } + b.WithdrawalEnabled = b.Flags.Has(0) { value, err := buf.Long() if err != nil { - return fmt.Errorf("unable to decode broadcastRevenueBalances#8438f1c6: field current_balance: %w", err) + return fmt.Errorf("unable to decode broadcastRevenueBalances#c3ff71e7: field current_balance: %w", err) } b.CurrentBalance = value } { value, err := buf.Long() if err != nil { - return fmt.Errorf("unable to decode broadcastRevenueBalances#8438f1c6: field available_balance: %w", err) + return fmt.Errorf("unable to decode broadcastRevenueBalances#c3ff71e7: field available_balance: %w", err) } b.AvailableBalance = value } { value, err := buf.Long() if err != nil { - return fmt.Errorf("unable to decode broadcastRevenueBalances#8438f1c6: field overall_revenue: %w", err) + return fmt.Errorf("unable to decode broadcastRevenueBalances#c3ff71e7: field overall_revenue: %w", err) } b.OverallRevenue = value } return nil } +// SetWithdrawalEnabled sets value of WithdrawalEnabled conditional field. +func (b *BroadcastRevenueBalances) SetWithdrawalEnabled(value bool) { + if value { + b.Flags.Set(0) + b.WithdrawalEnabled = true + } else { + b.Flags.Unset(0) + b.WithdrawalEnabled = false + } +} + +// GetWithdrawalEnabled returns value of WithdrawalEnabled conditional field. +func (b *BroadcastRevenueBalances) GetWithdrawalEnabled() (value bool) { + if b == nil { + return + } + return b.Flags.Has(0) +} + // GetCurrentBalance returns value of CurrentBalance field. func (b *BroadcastRevenueBalances) GetCurrentBalance() (value int64) { if b == nil { diff --git a/tg/tl_channel_admin_log_event_action_gen.go b/tg/tl_channel_admin_log_event_action_gen.go index 6876387029..d0b803a095 100644 --- a/tg/tl_channel_admin_log_event_action_gen.go +++ b/tg/tl_channel_admin_log_event_action_gen.go @@ -7704,6 +7704,179 @@ func (c *ChannelAdminLogEventActionToggleSignatureProfiles) GetNewValue() (value return c.NewValue } +// ChannelAdminLogEventActionParticipantSubExtend represents TL type `channelAdminLogEventActionParticipantSubExtend#64642db3`. +// +// See https://core.telegram.org/constructor/channelAdminLogEventActionParticipantSubExtend for reference. +type ChannelAdminLogEventActionParticipantSubExtend struct { + // PrevParticipant field of ChannelAdminLogEventActionParticipantSubExtend. + PrevParticipant ChannelParticipantClass + // NewParticipant field of ChannelAdminLogEventActionParticipantSubExtend. + NewParticipant ChannelParticipantClass +} + +// ChannelAdminLogEventActionParticipantSubExtendTypeID is TL type id of ChannelAdminLogEventActionParticipantSubExtend. +const ChannelAdminLogEventActionParticipantSubExtendTypeID = 0x64642db3 + +// construct implements constructor of ChannelAdminLogEventActionClass. +func (c ChannelAdminLogEventActionParticipantSubExtend) construct() ChannelAdminLogEventActionClass { + return &c +} + +// Ensuring interfaces in compile-time for ChannelAdminLogEventActionParticipantSubExtend. +var ( + _ bin.Encoder = &ChannelAdminLogEventActionParticipantSubExtend{} + _ bin.Decoder = &ChannelAdminLogEventActionParticipantSubExtend{} + _ bin.BareEncoder = &ChannelAdminLogEventActionParticipantSubExtend{} + _ bin.BareDecoder = &ChannelAdminLogEventActionParticipantSubExtend{} + + _ ChannelAdminLogEventActionClass = &ChannelAdminLogEventActionParticipantSubExtend{} +) + +func (c *ChannelAdminLogEventActionParticipantSubExtend) Zero() bool { + if c == nil { + return true + } + if !(c.PrevParticipant == nil) { + return false + } + if !(c.NewParticipant == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChannelAdminLogEventActionParticipantSubExtend) String() string { + if c == nil { + return "ChannelAdminLogEventActionParticipantSubExtend(nil)" + } + type Alias ChannelAdminLogEventActionParticipantSubExtend + return fmt.Sprintf("ChannelAdminLogEventActionParticipantSubExtend%+v", Alias(*c)) +} + +// FillFrom fills ChannelAdminLogEventActionParticipantSubExtend from given interface. +func (c *ChannelAdminLogEventActionParticipantSubExtend) FillFrom(from interface { + GetPrevParticipant() (value ChannelParticipantClass) + GetNewParticipant() (value ChannelParticipantClass) +}) { + c.PrevParticipant = from.GetPrevParticipant() + c.NewParticipant = from.GetNewParticipant() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelAdminLogEventActionParticipantSubExtend) TypeID() uint32 { + return ChannelAdminLogEventActionParticipantSubExtendTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelAdminLogEventActionParticipantSubExtend) TypeName() string { + return "channelAdminLogEventActionParticipantSubExtend" +} + +// TypeInfo returns info about TL type. +func (c *ChannelAdminLogEventActionParticipantSubExtend) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channelAdminLogEventActionParticipantSubExtend", + ID: ChannelAdminLogEventActionParticipantSubExtendTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "PrevParticipant", + SchemaName: "prev_participant", + }, + { + Name: "NewParticipant", + SchemaName: "new_participant", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *ChannelAdminLogEventActionParticipantSubExtend) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionParticipantSubExtend#64642db3 as nil") + } + b.PutID(ChannelAdminLogEventActionParticipantSubExtendTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChannelAdminLogEventActionParticipantSubExtend) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionParticipantSubExtend#64642db3 as nil") + } + if c.PrevParticipant == nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionParticipantSubExtend#64642db3: field prev_participant is nil") + } + if err := c.PrevParticipant.Encode(b); err != nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionParticipantSubExtend#64642db3: field prev_participant: %w", err) + } + if c.NewParticipant == nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionParticipantSubExtend#64642db3: field new_participant is nil") + } + if err := c.NewParticipant.Encode(b); err != nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionParticipantSubExtend#64642db3: field new_participant: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (c *ChannelAdminLogEventActionParticipantSubExtend) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionParticipantSubExtend#64642db3 to nil") + } + if err := b.ConsumeID(ChannelAdminLogEventActionParticipantSubExtendTypeID); err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionParticipantSubExtend#64642db3: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChannelAdminLogEventActionParticipantSubExtend) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionParticipantSubExtend#64642db3 to nil") + } + { + value, err := DecodeChannelParticipant(b) + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionParticipantSubExtend#64642db3: field prev_participant: %w", err) + } + c.PrevParticipant = value + } + { + value, err := DecodeChannelParticipant(b) + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionParticipantSubExtend#64642db3: field new_participant: %w", err) + } + c.NewParticipant = value + } + return nil +} + +// GetPrevParticipant returns value of PrevParticipant field. +func (c *ChannelAdminLogEventActionParticipantSubExtend) GetPrevParticipant() (value ChannelParticipantClass) { + if c == nil { + return + } + return c.PrevParticipant +} + +// GetNewParticipant returns value of NewParticipant field. +func (c *ChannelAdminLogEventActionParticipantSubExtend) GetNewParticipant() (value ChannelParticipantClass) { + if c == nil { + return + } + return c.NewParticipant +} + // ChannelAdminLogEventActionClassName is schema name of ChannelAdminLogEventActionClass. const ChannelAdminLogEventActionClassName = "ChannelAdminLogEventAction" @@ -7767,6 +7940,7 @@ const ChannelAdminLogEventActionClassName = "ChannelAdminLogEventAction" // case *tg.ChannelAdminLogEventActionChangeEmojiStatus: // channelAdminLogEventActionChangeEmojiStatus#3ea9feb1 // case *tg.ChannelAdminLogEventActionChangeEmojiStickerSet: // channelAdminLogEventActionChangeEmojiStickerSet#46d840ab // case *tg.ChannelAdminLogEventActionToggleSignatureProfiles: // channelAdminLogEventActionToggleSignatureProfiles#60a79c79 +// case *tg.ChannelAdminLogEventActionParticipantSubExtend: // channelAdminLogEventActionParticipantSubExtend#64642db3 // default: panic(v) // } type ChannelAdminLogEventActionClass interface { @@ -8138,6 +8312,13 @@ func DecodeChannelAdminLogEventAction(buf *bin.Buffer) (ChannelAdminLogEventActi return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", err) } return &v, nil + case ChannelAdminLogEventActionParticipantSubExtendTypeID: + // Decoding channelAdminLogEventActionParticipantSubExtend#64642db3. + v := ChannelAdminLogEventActionParticipantSubExtend{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_channel_admin_log_event_action_slices_gen.go b/tg/tl_channel_admin_log_event_action_slices_gen.go index 13518b3afb..eb08c33574 100644 --- a/tg/tl_channel_admin_log_event_action_slices_gen.go +++ b/tg/tl_channel_admin_log_event_action_slices_gen.go @@ -727,6 +727,19 @@ func (s ChannelAdminLogEventActionClassArray) AsChannelAdminLogEventActionToggle return to } +// AsChannelAdminLogEventActionParticipantSubExtend returns copy with only ChannelAdminLogEventActionParticipantSubExtend constructors. +func (s ChannelAdminLogEventActionClassArray) AsChannelAdminLogEventActionParticipantSubExtend() (to ChannelAdminLogEventActionParticipantSubExtendArray) { + for _, elem := range s { + value, ok := elem.(*ChannelAdminLogEventActionParticipantSubExtend) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // ChannelAdminLogEventActionChangeTitleArray is adapter for slice of ChannelAdminLogEventActionChangeTitle. type ChannelAdminLogEventActionChangeTitleArray []ChannelAdminLogEventActionChangeTitle @@ -4580,3 +4593,85 @@ func (s *ChannelAdminLogEventActionToggleSignatureProfilesArray) Pop() (v Channe return v, true } + +// ChannelAdminLogEventActionParticipantSubExtendArray is adapter for slice of ChannelAdminLogEventActionParticipantSubExtend. +type ChannelAdminLogEventActionParticipantSubExtendArray []ChannelAdminLogEventActionParticipantSubExtend + +// Sort sorts slice of ChannelAdminLogEventActionParticipantSubExtend. +func (s ChannelAdminLogEventActionParticipantSubExtendArray) Sort(less func(a, b ChannelAdminLogEventActionParticipantSubExtend) bool) ChannelAdminLogEventActionParticipantSubExtendArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ChannelAdminLogEventActionParticipantSubExtend. +func (s ChannelAdminLogEventActionParticipantSubExtendArray) SortStable(less func(a, b ChannelAdminLogEventActionParticipantSubExtend) bool) ChannelAdminLogEventActionParticipantSubExtendArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ChannelAdminLogEventActionParticipantSubExtend. +func (s ChannelAdminLogEventActionParticipantSubExtendArray) Retain(keep func(x ChannelAdminLogEventActionParticipantSubExtend) bool) ChannelAdminLogEventActionParticipantSubExtendArray { + 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 ChannelAdminLogEventActionParticipantSubExtendArray) First() (v ChannelAdminLogEventActionParticipantSubExtend, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ChannelAdminLogEventActionParticipantSubExtendArray) Last() (v ChannelAdminLogEventActionParticipantSubExtend, 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 *ChannelAdminLogEventActionParticipantSubExtendArray) PopFirst() (v ChannelAdminLogEventActionParticipantSubExtend, 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 ChannelAdminLogEventActionParticipantSubExtend + 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 *ChannelAdminLogEventActionParticipantSubExtendArray) Pop() (v ChannelAdminLogEventActionParticipantSubExtend, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_channel_admin_log_events_filter_gen.go b/tg/tl_channel_admin_log_events_filter_gen.go index ef53ad6418..5c05201d5e 100644 --- a/tg/tl_channel_admin_log_events_filter_gen.go +++ b/tg/tl_channel_admin_log_events_filter_gen.go @@ -139,6 +139,8 @@ type ChannelAdminLogEventsFilter struct { // Links: // 1) https://core.telegram.org/api/forum Forums bool + // SubExtend field of ChannelAdminLogEventsFilter. + SubExtend bool } // ChannelAdminLogEventsFilterTypeID is TL type id of ChannelAdminLogEventsFilter. @@ -213,6 +215,9 @@ func (c *ChannelAdminLogEventsFilter) Zero() bool { if !(c.Forums == false) { return false } + if !(c.SubExtend == false) { + return false + } return true } @@ -246,6 +251,7 @@ func (c *ChannelAdminLogEventsFilter) FillFrom(from interface { GetInvites() (value bool) GetSend() (value bool) GetForums() (value bool) + GetSubExtend() (value bool) }) { c.Join = from.GetJoin() c.Leave = from.GetLeave() @@ -265,6 +271,7 @@ func (c *ChannelAdminLogEventsFilter) FillFrom(from interface { c.Invites = from.GetInvites() c.Send = from.GetSend() c.Forums = from.GetForums() + c.SubExtend = from.GetSubExtend() } // TypeID returns type id in TL schema. @@ -380,6 +387,11 @@ func (c *ChannelAdminLogEventsFilter) TypeInfo() tdp.Type { SchemaName: "forums", Null: !c.Flags.Has(17), }, + { + Name: "SubExtend", + SchemaName: "sub_extend", + Null: !c.Flags.Has(18), + }, } return typ } @@ -440,6 +452,9 @@ func (c *ChannelAdminLogEventsFilter) SetFlags() { if !(c.Forums == false) { c.Flags.Set(17) } + if !(c.SubExtend == false) { + c.Flags.Set(18) + } } // Encode implements bin.Encoder. @@ -502,6 +517,7 @@ func (c *ChannelAdminLogEventsFilter) DecodeBare(b *bin.Buffer) error { c.Invites = c.Flags.Has(15) c.Send = c.Flags.Has(16) c.Forums = c.Flags.Has(17) + c.SubExtend = c.Flags.Has(18) return nil } @@ -846,3 +862,22 @@ func (c *ChannelAdminLogEventsFilter) GetForums() (value bool) { } return c.Flags.Has(17) } + +// SetSubExtend sets value of SubExtend conditional field. +func (c *ChannelAdminLogEventsFilter) SetSubExtend(value bool) { + if value { + c.Flags.Set(18) + c.SubExtend = true + } else { + c.Flags.Unset(18) + c.SubExtend = false + } +} + +// GetSubExtend returns value of SubExtend conditional field. +func (c *ChannelAdminLogEventsFilter) GetSubExtend() (value bool) { + if c == nil { + return + } + return c.Flags.Has(18) +} diff --git a/tg/tl_handlers_gen.go b/tg/tl_handlers_gen.go index e9748120aa..4579f781cc 100644 --- a/tg/tl_handlers_gen.go +++ b/tg/tl_handlers_gen.go @@ -1495,3 +1495,23 @@ func (u UpdateDispatcher) OnStarsRevenueStatus(handler StarsRevenueStatusHandler return handler(ctx, e, update.(*UpdateStarsRevenueStatus)) } } + +// BotPurchasedPaidMediaHandler is a BotPurchasedPaidMedia event handler. +type BotPurchasedPaidMediaHandler func(ctx context.Context, e Entities, update *UpdateBotPurchasedPaidMedia) error + +// OnBotPurchasedPaidMedia sets BotPurchasedPaidMedia handler. +func (u UpdateDispatcher) OnBotPurchasedPaidMedia(handler BotPurchasedPaidMediaHandler) { + u.handlers[UpdateBotPurchasedPaidMediaTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateBotPurchasedPaidMedia)) + } +} + +// PaidReactionPrivacyHandler is a PaidReactionPrivacy event handler. +type PaidReactionPrivacyHandler func(ctx context.Context, e Entities, update *UpdatePaidReactionPrivacy) error + +// OnPaidReactionPrivacy sets PaidReactionPrivacy handler. +func (u UpdateDispatcher) OnPaidReactionPrivacy(handler PaidReactionPrivacyHandler) { + u.handlers[UpdatePaidReactionPrivacyTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdatePaidReactionPrivacy)) + } +} diff --git a/tg/tl_input_media_gen.go b/tg/tl_input_media_gen.go index 31bf371122..107c4c9f49 100644 --- a/tg/tl_input_media_gen.go +++ b/tg/tl_input_media_gen.go @@ -4503,18 +4503,24 @@ func (i *InputMediaWebPage) GetURL() (value string) { return i.URL } -// InputMediaPaidMedia represents TL type `inputMediaPaidMedia#aa661fc3`. +// InputMediaPaidMedia represents TL type `inputMediaPaidMedia#c4103386`. // // See https://core.telegram.org/constructor/inputMediaPaidMedia for reference. type InputMediaPaidMedia struct { + // Flags field of InputMediaPaidMedia. + Flags bin.Fields // StarsAmount field of InputMediaPaidMedia. StarsAmount int64 // ExtendedMedia field of InputMediaPaidMedia. ExtendedMedia []InputMediaClass + // Payload field of InputMediaPaidMedia. + // + // Use SetPayload and GetPayload helpers. + Payload string } // InputMediaPaidMediaTypeID is TL type id of InputMediaPaidMedia. -const InputMediaPaidMediaTypeID = 0xaa661fc3 +const InputMediaPaidMediaTypeID = 0xc4103386 // construct implements constructor of InputMediaClass. func (i InputMediaPaidMedia) construct() InputMediaClass { return &i } @@ -4533,12 +4539,18 @@ func (i *InputMediaPaidMedia) Zero() bool { if i == nil { return true } + if !(i.Flags.Zero()) { + return false + } if !(i.StarsAmount == 0) { return false } if !(i.ExtendedMedia == nil) { return false } + if !(i.Payload == "") { + return false + } return true } @@ -4556,9 +4568,14 @@ func (i *InputMediaPaidMedia) String() string { func (i *InputMediaPaidMedia) FillFrom(from interface { GetStarsAmount() (value int64) GetExtendedMedia() (value []InputMediaClass) + GetPayload() (value string, ok bool) }) { i.StarsAmount = from.GetStarsAmount() i.ExtendedMedia = from.GetExtendedMedia() + if val, ok := from.GetPayload(); ok { + i.Payload = val + } + } // TypeID returns type id in TL schema. @@ -4592,14 +4609,26 @@ func (i *InputMediaPaidMedia) TypeInfo() tdp.Type { Name: "ExtendedMedia", SchemaName: "extended_media", }, + { + Name: "Payload", + SchemaName: "payload", + Null: !i.Flags.Has(0), + }, } return typ } +// SetFlags sets flags for non-zero fields. +func (i *InputMediaPaidMedia) SetFlags() { + if !(i.Payload == "") { + i.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (i *InputMediaPaidMedia) Encode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputMediaPaidMedia#aa661fc3 as nil") + return fmt.Errorf("can't encode inputMediaPaidMedia#c4103386 as nil") } b.PutID(InputMediaPaidMediaTypeID) return i.EncodeBare(b) @@ -4608,28 +4637,35 @@ func (i *InputMediaPaidMedia) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (i *InputMediaPaidMedia) EncodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputMediaPaidMedia#aa661fc3 as nil") + return fmt.Errorf("can't encode inputMediaPaidMedia#c4103386 as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputMediaPaidMedia#c4103386: field flags: %w", err) } b.PutLong(i.StarsAmount) b.PutVectorHeader(len(i.ExtendedMedia)) for idx, v := range i.ExtendedMedia { if v == nil { - return fmt.Errorf("unable to encode inputMediaPaidMedia#aa661fc3: field extended_media element with index %d is nil", idx) + return fmt.Errorf("unable to encode inputMediaPaidMedia#c4103386: field extended_media element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputMediaPaidMedia#aa661fc3: field extended_media element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode inputMediaPaidMedia#c4103386: field extended_media element with index %d: %w", idx, err) } } + if i.Flags.Has(0) { + b.PutString(i.Payload) + } return nil } // Decode implements bin.Decoder. func (i *InputMediaPaidMedia) Decode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputMediaPaidMedia#aa661fc3 to nil") + return fmt.Errorf("can't decode inputMediaPaidMedia#c4103386 to nil") } if err := b.ConsumeID(InputMediaPaidMediaTypeID); err != nil { - return fmt.Errorf("unable to decode inputMediaPaidMedia#aa661fc3: %w", err) + return fmt.Errorf("unable to decode inputMediaPaidMedia#c4103386: %w", err) } return i.DecodeBare(b) } @@ -4637,19 +4673,24 @@ func (i *InputMediaPaidMedia) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (i *InputMediaPaidMedia) DecodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputMediaPaidMedia#aa661fc3 to nil") + return fmt.Errorf("can't decode inputMediaPaidMedia#c4103386 to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputMediaPaidMedia#c4103386: field flags: %w", err) + } } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode inputMediaPaidMedia#aa661fc3: field stars_amount: %w", err) + return fmt.Errorf("unable to decode inputMediaPaidMedia#c4103386: field stars_amount: %w", err) } i.StarsAmount = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode inputMediaPaidMedia#aa661fc3: field extended_media: %w", err) + return fmt.Errorf("unable to decode inputMediaPaidMedia#c4103386: field extended_media: %w", err) } if headerLen > 0 { @@ -4658,11 +4699,18 @@ func (i *InputMediaPaidMedia) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeInputMedia(b) if err != nil { - return fmt.Errorf("unable to decode inputMediaPaidMedia#aa661fc3: field extended_media: %w", err) + return fmt.Errorf("unable to decode inputMediaPaidMedia#c4103386: field extended_media: %w", err) } i.ExtendedMedia = append(i.ExtendedMedia, value) } } + if i.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inputMediaPaidMedia#c4103386: field payload: %w", err) + } + i.Payload = value + } return nil } @@ -4682,6 +4730,24 @@ func (i *InputMediaPaidMedia) GetExtendedMedia() (value []InputMediaClass) { return i.ExtendedMedia } +// SetPayload sets value of Payload conditional field. +func (i *InputMediaPaidMedia) SetPayload(value string) { + i.Flags.Set(0) + i.Payload = value +} + +// GetPayload returns value of Payload conditional field and +// boolean which is true if field was set. +func (i *InputMediaPaidMedia) GetPayload() (value string, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(0) { + return value, false + } + return i.Payload, true +} + // MapExtendedMedia returns field ExtendedMedia wrapped in InputMediaClassArray helper. func (i *InputMediaPaidMedia) MapExtendedMedia() (value InputMediaClassArray) { return InputMediaClassArray(i.ExtendedMedia) @@ -4718,7 +4784,7 @@ const InputMediaClassName = "InputMedia" // case *tg.InputMediaDice: // inputMediaDice#e66fbf7b // case *tg.InputMediaStory: // inputMediaStory#89fdd778 // case *tg.InputMediaWebPage: // inputMediaWebPage#c21b8849 -// case *tg.InputMediaPaidMedia: // inputMediaPaidMedia#aa661fc3 +// case *tg.InputMediaPaidMedia: // inputMediaPaidMedia#c4103386 // default: panic(v) // } type InputMediaClass interface { @@ -4867,7 +4933,7 @@ func DecodeInputMedia(buf *bin.Buffer) (InputMediaClass, error) { } return &v, nil case InputMediaPaidMediaTypeID: - // Decoding inputMediaPaidMedia#aa661fc3. + // Decoding inputMediaPaidMedia#c4103386. v := InputMediaPaidMedia{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode InputMediaClass: %w", err) diff --git a/tg/tl_input_store_payment_purpose_gen.go b/tg/tl_input_store_payment_purpose_gen.go index 35128a6d01..f255b5177e 100644 --- a/tg/tl_input_store_payment_purpose_gen.go +++ b/tg/tl_input_store_payment_purpose_gen.go @@ -1709,6 +1709,578 @@ func (i *InputStorePaymentStarsGift) GetAmount() (value int64) { return i.Amount } +// InputStorePaymentStarsGiveaway represents TL type `inputStorePaymentStarsGiveaway#751f08fa`. +// +// See https://core.telegram.org/constructor/inputStorePaymentStarsGiveaway for reference. +type InputStorePaymentStarsGiveaway struct { + // Flags field of InputStorePaymentStarsGiveaway. + Flags bin.Fields + // OnlyNewSubscribers field of InputStorePaymentStarsGiveaway. + OnlyNewSubscribers bool + // WinnersAreVisible field of InputStorePaymentStarsGiveaway. + WinnersAreVisible bool + // Stars field of InputStorePaymentStarsGiveaway. + Stars int64 + // BoostPeer field of InputStorePaymentStarsGiveaway. + BoostPeer InputPeerClass + // AdditionalPeers field of InputStorePaymentStarsGiveaway. + // + // Use SetAdditionalPeers and GetAdditionalPeers helpers. + AdditionalPeers []InputPeerClass + // CountriesISO2 field of InputStorePaymentStarsGiveaway. + // + // Use SetCountriesISO2 and GetCountriesISO2 helpers. + CountriesISO2 []string + // PrizeDescription field of InputStorePaymentStarsGiveaway. + // + // Use SetPrizeDescription and GetPrizeDescription helpers. + PrizeDescription string + // RandomID field of InputStorePaymentStarsGiveaway. + RandomID int64 + // UntilDate field of InputStorePaymentStarsGiveaway. + UntilDate int + // Currency field of InputStorePaymentStarsGiveaway. + Currency string + // Amount field of InputStorePaymentStarsGiveaway. + Amount int64 + // Users field of InputStorePaymentStarsGiveaway. + Users int +} + +// InputStorePaymentStarsGiveawayTypeID is TL type id of InputStorePaymentStarsGiveaway. +const InputStorePaymentStarsGiveawayTypeID = 0x751f08fa + +// construct implements constructor of InputStorePaymentPurposeClass. +func (i InputStorePaymentStarsGiveaway) construct() InputStorePaymentPurposeClass { return &i } + +// Ensuring interfaces in compile-time for InputStorePaymentStarsGiveaway. +var ( + _ bin.Encoder = &InputStorePaymentStarsGiveaway{} + _ bin.Decoder = &InputStorePaymentStarsGiveaway{} + _ bin.BareEncoder = &InputStorePaymentStarsGiveaway{} + _ bin.BareDecoder = &InputStorePaymentStarsGiveaway{} + + _ InputStorePaymentPurposeClass = &InputStorePaymentStarsGiveaway{} +) + +func (i *InputStorePaymentStarsGiveaway) Zero() bool { + if i == nil { + return true + } + if !(i.Flags.Zero()) { + return false + } + if !(i.OnlyNewSubscribers == false) { + return false + } + if !(i.WinnersAreVisible == false) { + return false + } + if !(i.Stars == 0) { + return false + } + if !(i.BoostPeer == nil) { + return false + } + if !(i.AdditionalPeers == nil) { + return false + } + if !(i.CountriesISO2 == nil) { + return false + } + if !(i.PrizeDescription == "") { + return false + } + if !(i.RandomID == 0) { + return false + } + if !(i.UntilDate == 0) { + return false + } + if !(i.Currency == "") { + return false + } + if !(i.Amount == 0) { + return false + } + if !(i.Users == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputStorePaymentStarsGiveaway) String() string { + if i == nil { + return "InputStorePaymentStarsGiveaway(nil)" + } + type Alias InputStorePaymentStarsGiveaway + return fmt.Sprintf("InputStorePaymentStarsGiveaway%+v", Alias(*i)) +} + +// FillFrom fills InputStorePaymentStarsGiveaway from given interface. +func (i *InputStorePaymentStarsGiveaway) FillFrom(from interface { + GetOnlyNewSubscribers() (value bool) + GetWinnersAreVisible() (value bool) + GetStars() (value int64) + GetBoostPeer() (value InputPeerClass) + GetAdditionalPeers() (value []InputPeerClass, ok bool) + GetCountriesISO2() (value []string, ok bool) + GetPrizeDescription() (value string, ok bool) + GetRandomID() (value int64) + GetUntilDate() (value int) + GetCurrency() (value string) + GetAmount() (value int64) + GetUsers() (value int) +}) { + i.OnlyNewSubscribers = from.GetOnlyNewSubscribers() + i.WinnersAreVisible = from.GetWinnersAreVisible() + i.Stars = from.GetStars() + i.BoostPeer = from.GetBoostPeer() + if val, ok := from.GetAdditionalPeers(); ok { + i.AdditionalPeers = val + } + + if val, ok := from.GetCountriesISO2(); ok { + i.CountriesISO2 = val + } + + if val, ok := from.GetPrizeDescription(); ok { + i.PrizeDescription = val + } + + i.RandomID = from.GetRandomID() + i.UntilDate = from.GetUntilDate() + i.Currency = from.GetCurrency() + i.Amount = from.GetAmount() + i.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputStorePaymentStarsGiveaway) TypeID() uint32 { + return InputStorePaymentStarsGiveawayTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputStorePaymentStarsGiveaway) TypeName() string { + return "inputStorePaymentStarsGiveaway" +} + +// TypeInfo returns info about TL type. +func (i *InputStorePaymentStarsGiveaway) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputStorePaymentStarsGiveaway", + ID: InputStorePaymentStarsGiveawayTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "OnlyNewSubscribers", + SchemaName: "only_new_subscribers", + Null: !i.Flags.Has(0), + }, + { + Name: "WinnersAreVisible", + SchemaName: "winners_are_visible", + Null: !i.Flags.Has(3), + }, + { + Name: "Stars", + SchemaName: "stars", + }, + { + Name: "BoostPeer", + SchemaName: "boost_peer", + }, + { + Name: "AdditionalPeers", + SchemaName: "additional_peers", + Null: !i.Flags.Has(1), + }, + { + Name: "CountriesISO2", + SchemaName: "countries_iso2", + Null: !i.Flags.Has(2), + }, + { + Name: "PrizeDescription", + SchemaName: "prize_description", + Null: !i.Flags.Has(4), + }, + { + Name: "RandomID", + SchemaName: "random_id", + }, + { + Name: "UntilDate", + SchemaName: "until_date", + }, + { + Name: "Currency", + SchemaName: "currency", + }, + { + Name: "Amount", + SchemaName: "amount", + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (i *InputStorePaymentStarsGiveaway) SetFlags() { + if !(i.OnlyNewSubscribers == false) { + i.Flags.Set(0) + } + if !(i.WinnersAreVisible == false) { + i.Flags.Set(3) + } + if !(i.AdditionalPeers == nil) { + i.Flags.Set(1) + } + if !(i.CountriesISO2 == nil) { + i.Flags.Set(2) + } + if !(i.PrizeDescription == "") { + i.Flags.Set(4) + } +} + +// Encode implements bin.Encoder. +func (i *InputStorePaymentStarsGiveaway) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStorePaymentStarsGiveaway#751f08fa as nil") + } + b.PutID(InputStorePaymentStarsGiveawayTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputStorePaymentStarsGiveaway) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStorePaymentStarsGiveaway#751f08fa as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputStorePaymentStarsGiveaway#751f08fa: field flags: %w", err) + } + b.PutLong(i.Stars) + if i.BoostPeer == nil { + return fmt.Errorf("unable to encode inputStorePaymentStarsGiveaway#751f08fa: field boost_peer is nil") + } + if err := i.BoostPeer.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputStorePaymentStarsGiveaway#751f08fa: field boost_peer: %w", err) + } + if i.Flags.Has(1) { + b.PutVectorHeader(len(i.AdditionalPeers)) + for idx, v := range i.AdditionalPeers { + if v == nil { + return fmt.Errorf("unable to encode inputStorePaymentStarsGiveaway#751f08fa: field additional_peers element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputStorePaymentStarsGiveaway#751f08fa: field additional_peers element with index %d: %w", idx, err) + } + } + } + if i.Flags.Has(2) { + b.PutVectorHeader(len(i.CountriesISO2)) + for _, v := range i.CountriesISO2 { + b.PutString(v) + } + } + if i.Flags.Has(4) { + b.PutString(i.PrizeDescription) + } + b.PutLong(i.RandomID) + b.PutInt(i.UntilDate) + b.PutString(i.Currency) + b.PutLong(i.Amount) + b.PutInt(i.Users) + return nil +} + +// Decode implements bin.Decoder. +func (i *InputStorePaymentStarsGiveaway) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStorePaymentStarsGiveaway#751f08fa to nil") + } + if err := b.ConsumeID(InputStorePaymentStarsGiveawayTypeID); err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputStorePaymentStarsGiveaway) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStorePaymentStarsGiveaway#751f08fa to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field flags: %w", err) + } + } + i.OnlyNewSubscribers = i.Flags.Has(0) + i.WinnersAreVisible = i.Flags.Has(3) + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field stars: %w", err) + } + i.Stars = value + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field boost_peer: %w", err) + } + i.BoostPeer = value + } + if i.Flags.Has(1) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field additional_peers: %w", err) + } + + if headerLen > 0 { + i.AdditionalPeers = make([]InputPeerClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field additional_peers: %w", err) + } + i.AdditionalPeers = append(i.AdditionalPeers, value) + } + } + if i.Flags.Has(2) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field countries_iso2: %w", err) + } + + if headerLen > 0 { + i.CountriesISO2 = make([]string, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field countries_iso2: %w", err) + } + i.CountriesISO2 = append(i.CountriesISO2, value) + } + } + if i.Flags.Has(4) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field prize_description: %w", err) + } + i.PrizeDescription = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field random_id: %w", err) + } + i.RandomID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field until_date: %w", err) + } + i.UntilDate = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field currency: %w", err) + } + i.Currency = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field amount: %w", err) + } + i.Amount = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field users: %w", err) + } + i.Users = value + } + return nil +} + +// SetOnlyNewSubscribers sets value of OnlyNewSubscribers conditional field. +func (i *InputStorePaymentStarsGiveaway) SetOnlyNewSubscribers(value bool) { + if value { + i.Flags.Set(0) + i.OnlyNewSubscribers = true + } else { + i.Flags.Unset(0) + i.OnlyNewSubscribers = false + } +} + +// GetOnlyNewSubscribers returns value of OnlyNewSubscribers conditional field. +func (i *InputStorePaymentStarsGiveaway) GetOnlyNewSubscribers() (value bool) { + if i == nil { + return + } + return i.Flags.Has(0) +} + +// SetWinnersAreVisible sets value of WinnersAreVisible conditional field. +func (i *InputStorePaymentStarsGiveaway) SetWinnersAreVisible(value bool) { + if value { + i.Flags.Set(3) + i.WinnersAreVisible = true + } else { + i.Flags.Unset(3) + i.WinnersAreVisible = false + } +} + +// GetWinnersAreVisible returns value of WinnersAreVisible conditional field. +func (i *InputStorePaymentStarsGiveaway) GetWinnersAreVisible() (value bool) { + if i == nil { + return + } + return i.Flags.Has(3) +} + +// GetStars returns value of Stars field. +func (i *InputStorePaymentStarsGiveaway) GetStars() (value int64) { + if i == nil { + return + } + return i.Stars +} + +// GetBoostPeer returns value of BoostPeer field. +func (i *InputStorePaymentStarsGiveaway) GetBoostPeer() (value InputPeerClass) { + if i == nil { + return + } + return i.BoostPeer +} + +// SetAdditionalPeers sets value of AdditionalPeers conditional field. +func (i *InputStorePaymentStarsGiveaway) SetAdditionalPeers(value []InputPeerClass) { + i.Flags.Set(1) + i.AdditionalPeers = value +} + +// GetAdditionalPeers returns value of AdditionalPeers conditional field and +// boolean which is true if field was set. +func (i *InputStorePaymentStarsGiveaway) GetAdditionalPeers() (value []InputPeerClass, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(1) { + return value, false + } + return i.AdditionalPeers, true +} + +// SetCountriesISO2 sets value of CountriesISO2 conditional field. +func (i *InputStorePaymentStarsGiveaway) SetCountriesISO2(value []string) { + i.Flags.Set(2) + i.CountriesISO2 = value +} + +// GetCountriesISO2 returns value of CountriesISO2 conditional field and +// boolean which is true if field was set. +func (i *InputStorePaymentStarsGiveaway) GetCountriesISO2() (value []string, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(2) { + return value, false + } + return i.CountriesISO2, true +} + +// SetPrizeDescription sets value of PrizeDescription conditional field. +func (i *InputStorePaymentStarsGiveaway) SetPrizeDescription(value string) { + i.Flags.Set(4) + i.PrizeDescription = value +} + +// GetPrizeDescription returns value of PrizeDescription conditional field and +// boolean which is true if field was set. +func (i *InputStorePaymentStarsGiveaway) GetPrizeDescription() (value string, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(4) { + return value, false + } + return i.PrizeDescription, true +} + +// GetRandomID returns value of RandomID field. +func (i *InputStorePaymentStarsGiveaway) GetRandomID() (value int64) { + if i == nil { + return + } + return i.RandomID +} + +// GetUntilDate returns value of UntilDate field. +func (i *InputStorePaymentStarsGiveaway) GetUntilDate() (value int) { + if i == nil { + return + } + return i.UntilDate +} + +// GetCurrency returns value of Currency field. +func (i *InputStorePaymentStarsGiveaway) GetCurrency() (value string) { + if i == nil { + return + } + return i.Currency +} + +// GetAmount returns value of Amount field. +func (i *InputStorePaymentStarsGiveaway) GetAmount() (value int64) { + if i == nil { + return + } + return i.Amount +} + +// GetUsers returns value of Users field. +func (i *InputStorePaymentStarsGiveaway) GetUsers() (value int) { + if i == nil { + return + } + return i.Users +} + +// MapAdditionalPeers returns field AdditionalPeers wrapped in InputPeerClassArray helper. +func (i *InputStorePaymentStarsGiveaway) MapAdditionalPeers() (value InputPeerClassArray, ok bool) { + if !i.Flags.Has(1) { + return value, false + } + return InputPeerClassArray(i.AdditionalPeers), true +} + // InputStorePaymentPurposeClassName is schema name of InputStorePaymentPurposeClass. const InputStorePaymentPurposeClassName = "InputStorePaymentPurpose" @@ -1729,6 +2301,7 @@ const InputStorePaymentPurposeClassName = "InputStorePaymentPurpose" // case *tg.InputStorePaymentPremiumGiveaway: // inputStorePaymentPremiumGiveaway#160544ca // case *tg.InputStorePaymentStarsTopup: // inputStorePaymentStarsTopup#dddd0f56 // case *tg.InputStorePaymentStarsGift: // inputStorePaymentStarsGift#1d741ef7 +// case *tg.InputStorePaymentStarsGiveaway: // inputStorePaymentStarsGiveaway#751f08fa // default: panic(v) // } type InputStorePaymentPurposeClass interface { @@ -1799,6 +2372,13 @@ func DecodeInputStorePaymentPurpose(buf *bin.Buffer) (InputStorePaymentPurposeCl return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", err) } return &v, nil + case InputStorePaymentStarsGiveawayTypeID: + // Decoding inputStorePaymentStarsGiveaway#751f08fa. + v := InputStorePaymentStarsGiveaway{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_input_store_payment_purpose_slices_gen.go b/tg/tl_input_store_payment_purpose_slices_gen.go index 07269a90ba..9cdfebe764 100644 --- a/tg/tl_input_store_payment_purpose_slices_gen.go +++ b/tg/tl_input_store_payment_purpose_slices_gen.go @@ -194,6 +194,19 @@ func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentStarsGift() (to I return to } +// AsInputStorePaymentStarsGiveaway returns copy with only InputStorePaymentStarsGiveaway constructors. +func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentStarsGiveaway() (to InputStorePaymentStarsGiveawayArray) { + for _, elem := range s { + value, ok := elem.(*InputStorePaymentStarsGiveaway) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // InputStorePaymentPremiumSubscriptionArray is adapter for slice of InputStorePaymentPremiumSubscription. type InputStorePaymentPremiumSubscriptionArray []InputStorePaymentPremiumSubscription @@ -685,3 +698,85 @@ func (s *InputStorePaymentStarsGiftArray) Pop() (v InputStorePaymentStarsGift, o return v, true } + +// InputStorePaymentStarsGiveawayArray is adapter for slice of InputStorePaymentStarsGiveaway. +type InputStorePaymentStarsGiveawayArray []InputStorePaymentStarsGiveaway + +// Sort sorts slice of InputStorePaymentStarsGiveaway. +func (s InputStorePaymentStarsGiveawayArray) Sort(less func(a, b InputStorePaymentStarsGiveaway) bool) InputStorePaymentStarsGiveawayArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InputStorePaymentStarsGiveaway. +func (s InputStorePaymentStarsGiveawayArray) SortStable(less func(a, b InputStorePaymentStarsGiveaway) bool) InputStorePaymentStarsGiveawayArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InputStorePaymentStarsGiveaway. +func (s InputStorePaymentStarsGiveawayArray) Retain(keep func(x InputStorePaymentStarsGiveaway) bool) InputStorePaymentStarsGiveawayArray { + 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 InputStorePaymentStarsGiveawayArray) First() (v InputStorePaymentStarsGiveaway, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputStorePaymentStarsGiveawayArray) Last() (v InputStorePaymentStarsGiveaway, 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 *InputStorePaymentStarsGiveawayArray) PopFirst() (v InputStorePaymentStarsGiveaway, 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 InputStorePaymentStarsGiveaway + 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 *InputStorePaymentStarsGiveawayArray) Pop() (v InputStorePaymentStarsGiveaway, 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 d9ffc4bee2..c2cd40247d 100644 --- a/tg/tl_message_action_gen.go +++ b/tg/tl_message_action_gen.go @@ -7423,7 +7423,7 @@ func (m *MessageActionGiftCode) GetCryptoAmount() (value int64, ok bool) { return m.CryptoAmount, true } -// MessageActionGiveawayLaunch represents TL type `messageActionGiveawayLaunch#332ba9ed`. +// MessageActionGiveawayLaunch represents TL type `messageActionGiveawayLaunch#a80f51e4`. // A giveaway¹ was started. // // Links: @@ -7431,10 +7431,16 @@ func (m *MessageActionGiftCode) GetCryptoAmount() (value int64, ok bool) { // // See https://core.telegram.org/constructor/messageActionGiveawayLaunch for reference. type MessageActionGiveawayLaunch struct { + // Flags field of MessageActionGiveawayLaunch. + Flags bin.Fields + // Stars field of MessageActionGiveawayLaunch. + // + // Use SetStars and GetStars helpers. + Stars int64 } // MessageActionGiveawayLaunchTypeID is TL type id of MessageActionGiveawayLaunch. -const MessageActionGiveawayLaunchTypeID = 0x332ba9ed +const MessageActionGiveawayLaunchTypeID = 0xa80f51e4 // construct implements constructor of MessageActionClass. func (m MessageActionGiveawayLaunch) construct() MessageActionClass { return &m } @@ -7453,6 +7459,12 @@ func (m *MessageActionGiveawayLaunch) Zero() bool { if m == nil { return true } + if !(m.Flags.Zero()) { + return false + } + if !(m.Stars == 0) { + return false + } return true } @@ -7466,6 +7478,16 @@ func (m *MessageActionGiveawayLaunch) String() string { return fmt.Sprintf("MessageActionGiveawayLaunch%+v", Alias(*m)) } +// FillFrom fills MessageActionGiveawayLaunch from given interface. +func (m *MessageActionGiveawayLaunch) FillFrom(from interface { + GetStars() (value int64, ok bool) +}) { + if val, ok := from.GetStars(); ok { + m.Stars = val + } + +} + // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. @@ -7488,14 +7510,27 @@ func (m *MessageActionGiveawayLaunch) TypeInfo() tdp.Type { typ.Null = true return typ } - typ.Fields = []tdp.Field{} + typ.Fields = []tdp.Field{ + { + Name: "Stars", + SchemaName: "stars", + Null: !m.Flags.Has(0), + }, + } return typ } +// SetFlags sets flags for non-zero fields. +func (m *MessageActionGiveawayLaunch) SetFlags() { + if !(m.Stars == 0) { + m.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (m *MessageActionGiveawayLaunch) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageActionGiveawayLaunch#332ba9ed as nil") + return fmt.Errorf("can't encode messageActionGiveawayLaunch#a80f51e4 as nil") } b.PutID(MessageActionGiveawayLaunchTypeID) return m.EncodeBare(b) @@ -7504,7 +7539,14 @@ func (m *MessageActionGiveawayLaunch) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *MessageActionGiveawayLaunch) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageActionGiveawayLaunch#332ba9ed as nil") + return fmt.Errorf("can't encode messageActionGiveawayLaunch#a80f51e4 as nil") + } + m.SetFlags() + if err := m.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionGiveawayLaunch#a80f51e4: field flags: %w", err) + } + if m.Flags.Has(0) { + b.PutLong(m.Stars) } return nil } @@ -7512,10 +7554,10 @@ func (m *MessageActionGiveawayLaunch) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (m *MessageActionGiveawayLaunch) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageActionGiveawayLaunch#332ba9ed to nil") + return fmt.Errorf("can't decode messageActionGiveawayLaunch#a80f51e4 to nil") } if err := b.ConsumeID(MessageActionGiveawayLaunchTypeID); err != nil { - return fmt.Errorf("unable to decode messageActionGiveawayLaunch#332ba9ed: %w", err) + return fmt.Errorf("unable to decode messageActionGiveawayLaunch#a80f51e4: %w", err) } return m.DecodeBare(b) } @@ -7523,12 +7565,42 @@ func (m *MessageActionGiveawayLaunch) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *MessageActionGiveawayLaunch) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageActionGiveawayLaunch#332ba9ed to nil") + return fmt.Errorf("can't decode messageActionGiveawayLaunch#a80f51e4 to nil") + } + { + if err := m.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageActionGiveawayLaunch#a80f51e4: field flags: %w", err) + } + } + if m.Flags.Has(0) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messageActionGiveawayLaunch#a80f51e4: field stars: %w", err) + } + m.Stars = value } return nil } -// MessageActionGiveawayResults represents TL type `messageActionGiveawayResults#2a9fadc5`. +// SetStars sets value of Stars conditional field. +func (m *MessageActionGiveawayLaunch) SetStars(value int64) { + m.Flags.Set(0) + m.Stars = value +} + +// GetStars returns value of Stars conditional field and +// boolean which is true if field was set. +func (m *MessageActionGiveawayLaunch) GetStars() (value int64, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(0) { + return value, false + } + return m.Stars, true +} + +// MessageActionGiveawayResults represents TL type `messageActionGiveawayResults#87e2f155`. // A giveaway¹ has ended. // // Links: @@ -7536,6 +7608,10 @@ func (m *MessageActionGiveawayLaunch) DecodeBare(b *bin.Buffer) error { // // See https://core.telegram.org/constructor/messageActionGiveawayResults for reference. type MessageActionGiveawayResults struct { + // Flags field of MessageActionGiveawayResults. + Flags bin.Fields + // Stars field of MessageActionGiveawayResults. + Stars bool // Number of winners in the giveaway WinnersCount int // Number of undistributed prizes @@ -7543,7 +7619,7 @@ type MessageActionGiveawayResults struct { } // MessageActionGiveawayResultsTypeID is TL type id of MessageActionGiveawayResults. -const MessageActionGiveawayResultsTypeID = 0x2a9fadc5 +const MessageActionGiveawayResultsTypeID = 0x87e2f155 // construct implements constructor of MessageActionClass. func (m MessageActionGiveawayResults) construct() MessageActionClass { return &m } @@ -7562,6 +7638,12 @@ func (m *MessageActionGiveawayResults) Zero() bool { if m == nil { return true } + if !(m.Flags.Zero()) { + return false + } + if !(m.Stars == false) { + return false + } if !(m.WinnersCount == 0) { return false } @@ -7583,9 +7665,11 @@ func (m *MessageActionGiveawayResults) String() string { // FillFrom fills MessageActionGiveawayResults from given interface. func (m *MessageActionGiveawayResults) FillFrom(from interface { + GetStars() (value bool) GetWinnersCount() (value int) GetUnclaimedCount() (value int) }) { + m.Stars = from.GetStars() m.WinnersCount = from.GetWinnersCount() m.UnclaimedCount = from.GetUnclaimedCount() } @@ -7613,6 +7697,11 @@ func (m *MessageActionGiveawayResults) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Stars", + SchemaName: "stars", + Null: !m.Flags.Has(0), + }, { Name: "WinnersCount", SchemaName: "winners_count", @@ -7625,10 +7714,17 @@ func (m *MessageActionGiveawayResults) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (m *MessageActionGiveawayResults) SetFlags() { + if !(m.Stars == false) { + m.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (m *MessageActionGiveawayResults) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageActionGiveawayResults#2a9fadc5 as nil") + return fmt.Errorf("can't encode messageActionGiveawayResults#87e2f155 as nil") } b.PutID(MessageActionGiveawayResultsTypeID) return m.EncodeBare(b) @@ -7637,7 +7733,11 @@ func (m *MessageActionGiveawayResults) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *MessageActionGiveawayResults) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageActionGiveawayResults#2a9fadc5 as nil") + return fmt.Errorf("can't encode messageActionGiveawayResults#87e2f155 as nil") + } + m.SetFlags() + if err := m.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionGiveawayResults#87e2f155: field flags: %w", err) } b.PutInt(m.WinnersCount) b.PutInt(m.UnclaimedCount) @@ -7647,10 +7747,10 @@ func (m *MessageActionGiveawayResults) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (m *MessageActionGiveawayResults) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageActionGiveawayResults#2a9fadc5 to nil") + return fmt.Errorf("can't decode messageActionGiveawayResults#87e2f155 to nil") } if err := b.ConsumeID(MessageActionGiveawayResultsTypeID); err != nil { - return fmt.Errorf("unable to decode messageActionGiveawayResults#2a9fadc5: %w", err) + return fmt.Errorf("unable to decode messageActionGiveawayResults#87e2f155: %w", err) } return m.DecodeBare(b) } @@ -7658,25 +7758,50 @@ func (m *MessageActionGiveawayResults) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *MessageActionGiveawayResults) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageActionGiveawayResults#2a9fadc5 to nil") + return fmt.Errorf("can't decode messageActionGiveawayResults#87e2f155 to nil") } + { + if err := m.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageActionGiveawayResults#87e2f155: field flags: %w", err) + } + } + m.Stars = m.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageActionGiveawayResults#2a9fadc5: field winners_count: %w", err) + return fmt.Errorf("unable to decode messageActionGiveawayResults#87e2f155: field winners_count: %w", err) } m.WinnersCount = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageActionGiveawayResults#2a9fadc5: field unclaimed_count: %w", err) + return fmt.Errorf("unable to decode messageActionGiveawayResults#87e2f155: field unclaimed_count: %w", err) } m.UnclaimedCount = value } return nil } +// SetStars sets value of Stars conditional field. +func (m *MessageActionGiveawayResults) SetStars(value bool) { + if value { + m.Flags.Set(0) + m.Stars = true + } else { + m.Flags.Unset(0) + m.Stars = false + } +} + +// GetStars returns value of Stars conditional field. +func (m *MessageActionGiveawayResults) GetStars() (value bool) { + if m == nil { + return + } + return m.Flags.Has(0) +} + // GetWinnersCount returns value of WinnersCount field. func (m *MessageActionGiveawayResults) GetWinnersCount() (value int) { if m == nil { @@ -8647,6 +8772,279 @@ func (m *MessageActionGiftStars) GetTransactionID() (value string, ok bool) { return m.TransactionID, true } +// MessageActionPrizeStars represents TL type `messageActionPrizeStars#b00c47a2`. +// +// See https://core.telegram.org/constructor/messageActionPrizeStars for reference. +type MessageActionPrizeStars struct { + // Flags field of MessageActionPrizeStars. + Flags bin.Fields + // Unclaimed field of MessageActionPrizeStars. + Unclaimed bool + // Stars field of MessageActionPrizeStars. + Stars int64 + // TransactionID field of MessageActionPrizeStars. + TransactionID string + // BoostPeer field of MessageActionPrizeStars. + BoostPeer PeerClass + // GiveawayMsgID field of MessageActionPrizeStars. + GiveawayMsgID int +} + +// MessageActionPrizeStarsTypeID is TL type id of MessageActionPrizeStars. +const MessageActionPrizeStarsTypeID = 0xb00c47a2 + +// construct implements constructor of MessageActionClass. +func (m MessageActionPrizeStars) construct() MessageActionClass { return &m } + +// Ensuring interfaces in compile-time for MessageActionPrizeStars. +var ( + _ bin.Encoder = &MessageActionPrizeStars{} + _ bin.Decoder = &MessageActionPrizeStars{} + _ bin.BareEncoder = &MessageActionPrizeStars{} + _ bin.BareDecoder = &MessageActionPrizeStars{} + + _ MessageActionClass = &MessageActionPrizeStars{} +) + +func (m *MessageActionPrizeStars) Zero() bool { + if m == nil { + return true + } + if !(m.Flags.Zero()) { + return false + } + if !(m.Unclaimed == false) { + return false + } + if !(m.Stars == 0) { + return false + } + if !(m.TransactionID == "") { + return false + } + if !(m.BoostPeer == nil) { + return false + } + if !(m.GiveawayMsgID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageActionPrizeStars) String() string { + if m == nil { + return "MessageActionPrizeStars(nil)" + } + type Alias MessageActionPrizeStars + return fmt.Sprintf("MessageActionPrizeStars%+v", Alias(*m)) +} + +// FillFrom fills MessageActionPrizeStars from given interface. +func (m *MessageActionPrizeStars) FillFrom(from interface { + GetUnclaimed() (value bool) + GetStars() (value int64) + GetTransactionID() (value string) + GetBoostPeer() (value PeerClass) + GetGiveawayMsgID() (value int) +}) { + m.Unclaimed = from.GetUnclaimed() + m.Stars = from.GetStars() + m.TransactionID = from.GetTransactionID() + m.BoostPeer = from.GetBoostPeer() + m.GiveawayMsgID = from.GetGiveawayMsgID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageActionPrizeStars) TypeID() uint32 { + return MessageActionPrizeStarsTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageActionPrizeStars) TypeName() string { + return "messageActionPrizeStars" +} + +// TypeInfo returns info about TL type. +func (m *MessageActionPrizeStars) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageActionPrizeStars", + ID: MessageActionPrizeStarsTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Unclaimed", + SchemaName: "unclaimed", + Null: !m.Flags.Has(0), + }, + { + Name: "Stars", + SchemaName: "stars", + }, + { + Name: "TransactionID", + SchemaName: "transaction_id", + }, + { + Name: "BoostPeer", + SchemaName: "boost_peer", + }, + { + Name: "GiveawayMsgID", + SchemaName: "giveaway_msg_id", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (m *MessageActionPrizeStars) SetFlags() { + if !(m.Unclaimed == false) { + m.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (m *MessageActionPrizeStars) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionPrizeStars#b00c47a2 as nil") + } + b.PutID(MessageActionPrizeStarsTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageActionPrizeStars) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionPrizeStars#b00c47a2 as nil") + } + m.SetFlags() + if err := m.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionPrizeStars#b00c47a2: field flags: %w", err) + } + b.PutLong(m.Stars) + b.PutString(m.TransactionID) + if m.BoostPeer == nil { + return fmt.Errorf("unable to encode messageActionPrizeStars#b00c47a2: field boost_peer is nil") + } + if err := m.BoostPeer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionPrizeStars#b00c47a2: field boost_peer: %w", err) + } + b.PutInt(m.GiveawayMsgID) + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageActionPrizeStars) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionPrizeStars#b00c47a2 to nil") + } + if err := b.ConsumeID(MessageActionPrizeStarsTypeID); err != nil { + return fmt.Errorf("unable to decode messageActionPrizeStars#b00c47a2: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageActionPrizeStars) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionPrizeStars#b00c47a2 to nil") + } + { + if err := m.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageActionPrizeStars#b00c47a2: field flags: %w", err) + } + } + m.Unclaimed = m.Flags.Has(0) + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messageActionPrizeStars#b00c47a2: field stars: %w", err) + } + m.Stars = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageActionPrizeStars#b00c47a2: field transaction_id: %w", err) + } + m.TransactionID = value + } + { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode messageActionPrizeStars#b00c47a2: field boost_peer: %w", err) + } + m.BoostPeer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messageActionPrizeStars#b00c47a2: field giveaway_msg_id: %w", err) + } + m.GiveawayMsgID = value + } + return nil +} + +// SetUnclaimed sets value of Unclaimed conditional field. +func (m *MessageActionPrizeStars) SetUnclaimed(value bool) { + if value { + m.Flags.Set(0) + m.Unclaimed = true + } else { + m.Flags.Unset(0) + m.Unclaimed = false + } +} + +// GetUnclaimed returns value of Unclaimed conditional field. +func (m *MessageActionPrizeStars) GetUnclaimed() (value bool) { + if m == nil { + return + } + return m.Flags.Has(0) +} + +// GetStars returns value of Stars field. +func (m *MessageActionPrizeStars) GetStars() (value int64) { + if m == nil { + return + } + return m.Stars +} + +// GetTransactionID returns value of TransactionID field. +func (m *MessageActionPrizeStars) GetTransactionID() (value string) { + if m == nil { + return + } + return m.TransactionID +} + +// GetBoostPeer returns value of BoostPeer field. +func (m *MessageActionPrizeStars) GetBoostPeer() (value PeerClass) { + if m == nil { + return + } + return m.BoostPeer +} + +// GetGiveawayMsgID returns value of GiveawayMsgID field. +func (m *MessageActionPrizeStars) GetGiveawayMsgID() (value int) { + if m == nil { + return + } + return m.GiveawayMsgID +} + // MessageActionClassName is schema name of MessageActionClass. const MessageActionClassName = "MessageAction" @@ -8700,12 +9098,13 @@ const MessageActionClassName = "MessageAction" // case *tg.MessageActionRequestedPeer: // messageActionRequestedPeer#31518e9b // case *tg.MessageActionSetChatWallPaper: // messageActionSetChatWallPaper#5060a3f4 // case *tg.MessageActionGiftCode: // messageActionGiftCode#678c2e09 -// case *tg.MessageActionGiveawayLaunch: // messageActionGiveawayLaunch#332ba9ed -// case *tg.MessageActionGiveawayResults: // messageActionGiveawayResults#2a9fadc5 +// case *tg.MessageActionGiveawayLaunch: // messageActionGiveawayLaunch#a80f51e4 +// case *tg.MessageActionGiveawayResults: // messageActionGiveawayResults#87e2f155 // case *tg.MessageActionBoostApply: // messageActionBoostApply#cc02aa6d // case *tg.MessageActionRequestedPeerSentMe: // messageActionRequestedPeerSentMe#93b31848 // case *tg.MessageActionPaymentRefunded: // messageActionPaymentRefunded#41b3e202 // case *tg.MessageActionGiftStars: // messageActionGiftStars#45d5b021 +// case *tg.MessageActionPrizeStars: // messageActionPrizeStars#b00c47a2 // default: panic(v) // } type MessageActionClass interface { @@ -9008,14 +9407,14 @@ func DecodeMessageAction(buf *bin.Buffer) (MessageActionClass, error) { } return &v, nil case MessageActionGiveawayLaunchTypeID: - // Decoding messageActionGiveawayLaunch#332ba9ed. + // Decoding messageActionGiveawayLaunch#a80f51e4. v := MessageActionGiveawayLaunch{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) } return &v, nil case MessageActionGiveawayResultsTypeID: - // Decoding messageActionGiveawayResults#2a9fadc5. + // Decoding messageActionGiveawayResults#87e2f155. v := MessageActionGiveawayResults{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) @@ -9049,6 +9448,13 @@ func DecodeMessageAction(buf *bin.Buffer) (MessageActionClass, error) { return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) } return &v, nil + case MessageActionPrizeStarsTypeID: + // Decoding messageActionPrizeStars#b00c47a2. + v := MessageActionPrizeStars{} + 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 5b6b4b752e..c2c4a815b1 100644 --- a/tg/tl_message_action_slices_gen.go +++ b/tg/tl_message_action_slices_gen.go @@ -532,6 +532,19 @@ func (s MessageActionClassArray) AsMessageActionGiftCode() (to MessageActionGift return to } +// AsMessageActionGiveawayLaunch returns copy with only MessageActionGiveawayLaunch constructors. +func (s MessageActionClassArray) AsMessageActionGiveawayLaunch() (to MessageActionGiveawayLaunchArray) { + for _, elem := range s { + value, ok := elem.(*MessageActionGiveawayLaunch) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // AsMessageActionGiveawayResults returns copy with only MessageActionGiveawayResults constructors. func (s MessageActionClassArray) AsMessageActionGiveawayResults() (to MessageActionGiveawayResultsArray) { for _, elem := range s { @@ -597,6 +610,19 @@ func (s MessageActionClassArray) AsMessageActionGiftStars() (to MessageActionGif return to } +// AsMessageActionPrizeStars returns copy with only MessageActionPrizeStars constructors. +func (s MessageActionClassArray) AsMessageActionPrizeStars() (to MessageActionPrizeStarsArray) { + for _, elem := range s { + value, ok := elem.(*MessageActionPrizeStars) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // MessageActionChatCreateArray is adapter for slice of MessageActionChatCreate. type MessageActionChatCreateArray []MessageActionChatCreate @@ -3221,6 +3247,88 @@ func (s *MessageActionGiftCodeArray) Pop() (v MessageActionGiftCode, ok bool) { return v, true } +// MessageActionGiveawayLaunchArray is adapter for slice of MessageActionGiveawayLaunch. +type MessageActionGiveawayLaunchArray []MessageActionGiveawayLaunch + +// Sort sorts slice of MessageActionGiveawayLaunch. +func (s MessageActionGiveawayLaunchArray) Sort(less func(a, b MessageActionGiveawayLaunch) bool) MessageActionGiveawayLaunchArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessageActionGiveawayLaunch. +func (s MessageActionGiveawayLaunchArray) SortStable(less func(a, b MessageActionGiveawayLaunch) bool) MessageActionGiveawayLaunchArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessageActionGiveawayLaunch. +func (s MessageActionGiveawayLaunchArray) Retain(keep func(x MessageActionGiveawayLaunch) bool) MessageActionGiveawayLaunchArray { + 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 MessageActionGiveawayLaunchArray) First() (v MessageActionGiveawayLaunch, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessageActionGiveawayLaunchArray) Last() (v MessageActionGiveawayLaunch, 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 *MessageActionGiveawayLaunchArray) PopFirst() (v MessageActionGiveawayLaunch, 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 MessageActionGiveawayLaunch + 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 *MessageActionGiveawayLaunchArray) Pop() (v MessageActionGiveawayLaunch, 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 +} + // MessageActionGiveawayResultsArray is adapter for slice of MessageActionGiveawayResults. type MessageActionGiveawayResultsArray []MessageActionGiveawayResults @@ -3630,3 +3738,85 @@ func (s *MessageActionGiftStarsArray) Pop() (v MessageActionGiftStars, ok bool) return v, true } + +// MessageActionPrizeStarsArray is adapter for slice of MessageActionPrizeStars. +type MessageActionPrizeStarsArray []MessageActionPrizeStars + +// Sort sorts slice of MessageActionPrizeStars. +func (s MessageActionPrizeStarsArray) Sort(less func(a, b MessageActionPrizeStars) bool) MessageActionPrizeStarsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessageActionPrizeStars. +func (s MessageActionPrizeStarsArray) SortStable(less func(a, b MessageActionPrizeStars) bool) MessageActionPrizeStarsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessageActionPrizeStars. +func (s MessageActionPrizeStarsArray) Retain(keep func(x MessageActionPrizeStars) bool) MessageActionPrizeStarsArray { + 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 MessageActionPrizeStarsArray) First() (v MessageActionPrizeStars, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessageActionPrizeStarsArray) Last() (v MessageActionPrizeStars, 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 *MessageActionPrizeStarsArray) PopFirst() (v MessageActionPrizeStars, 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 MessageActionPrizeStars + 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 *MessageActionPrizeStarsArray) Pop() (v MessageActionPrizeStars, 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 b548046874..2b1a4e7336 100644 --- a/tg/tl_message_media_gen.go +++ b/tg/tl_message_media_gen.go @@ -3475,7 +3475,7 @@ func (m *MessageMediaStory) GetStory() (value StoryItemClass, ok bool) { return m.Story, true } -// MessageMediaGiveaway represents TL type `messageMediaGiveaway#daad85b0`. +// MessageMediaGiveaway represents TL type `messageMediaGiveaway#aa073beb`. // Contains info about a giveaway, see here »¹ for more info. // // Links: @@ -3519,13 +3519,19 @@ type MessageMediaGiveaway struct { // // Links: // 1) https://core.telegram.org/api/premium + // + // Use SetMonths and GetMonths helpers. Months int + // Stars field of MessageMediaGiveaway. + // + // Use SetStars and GetStars helpers. + Stars int64 // The end date of the giveaway. UntilDate int } // MessageMediaGiveawayTypeID is TL type id of MessageMediaGiveaway. -const MessageMediaGiveawayTypeID = 0xdaad85b0 +const MessageMediaGiveawayTypeID = 0xaa073beb // construct implements constructor of MessageMediaClass. func (m MessageMediaGiveaway) construct() MessageMediaClass { return &m } @@ -3568,6 +3574,9 @@ func (m *MessageMediaGiveaway) Zero() bool { if !(m.Months == 0) { return false } + if !(m.Stars == 0) { + return false + } if !(m.UntilDate == 0) { return false } @@ -3592,7 +3601,8 @@ func (m *MessageMediaGiveaway) FillFrom(from interface { GetCountriesISO2() (value []string, ok bool) GetPrizeDescription() (value string, ok bool) GetQuantity() (value int) - GetMonths() (value int) + GetMonths() (value int, ok bool) + GetStars() (value int64, ok bool) GetUntilDate() (value int) }) { m.OnlyNewSubscribers = from.GetOnlyNewSubscribers() @@ -3607,7 +3617,14 @@ func (m *MessageMediaGiveaway) FillFrom(from interface { } m.Quantity = from.GetQuantity() - m.Months = from.GetMonths() + if val, ok := from.GetMonths(); ok { + m.Months = val + } + + if val, ok := from.GetStars(); ok { + m.Stars = val + } + m.UntilDate = from.GetUntilDate() } @@ -3665,6 +3682,12 @@ func (m *MessageMediaGiveaway) TypeInfo() tdp.Type { { Name: "Months", SchemaName: "months", + Null: !m.Flags.Has(4), + }, + { + Name: "Stars", + SchemaName: "stars", + Null: !m.Flags.Has(5), }, { Name: "UntilDate", @@ -3688,12 +3711,18 @@ func (m *MessageMediaGiveaway) SetFlags() { if !(m.PrizeDescription == "") { m.Flags.Set(3) } + if !(m.Months == 0) { + m.Flags.Set(4) + } + if !(m.Stars == 0) { + m.Flags.Set(5) + } } // Encode implements bin.Encoder. func (m *MessageMediaGiveaway) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageMediaGiveaway#daad85b0 as nil") + return fmt.Errorf("can't encode messageMediaGiveaway#aa073beb as nil") } b.PutID(MessageMediaGiveawayTypeID) return m.EncodeBare(b) @@ -3702,11 +3731,11 @@ func (m *MessageMediaGiveaway) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *MessageMediaGiveaway) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageMediaGiveaway#daad85b0 as nil") + return fmt.Errorf("can't encode messageMediaGiveaway#aa073beb as nil") } m.SetFlags() if err := m.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageMediaGiveaway#daad85b0: field flags: %w", err) + return fmt.Errorf("unable to encode messageMediaGiveaway#aa073beb: field flags: %w", err) } b.PutVectorHeader(len(m.Channels)) for _, v := range m.Channels { @@ -3722,7 +3751,12 @@ func (m *MessageMediaGiveaway) EncodeBare(b *bin.Buffer) error { b.PutString(m.PrizeDescription) } b.PutInt(m.Quantity) - b.PutInt(m.Months) + if m.Flags.Has(4) { + b.PutInt(m.Months) + } + if m.Flags.Has(5) { + b.PutLong(m.Stars) + } b.PutInt(m.UntilDate) return nil } @@ -3730,10 +3764,10 @@ func (m *MessageMediaGiveaway) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (m *MessageMediaGiveaway) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageMediaGiveaway#daad85b0 to nil") + return fmt.Errorf("can't decode messageMediaGiveaway#aa073beb to nil") } if err := b.ConsumeID(MessageMediaGiveawayTypeID); err != nil { - return fmt.Errorf("unable to decode messageMediaGiveaway#daad85b0: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveaway#aa073beb: %w", err) } return m.DecodeBare(b) } @@ -3741,11 +3775,11 @@ func (m *MessageMediaGiveaway) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *MessageMediaGiveaway) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageMediaGiveaway#daad85b0 to nil") + return fmt.Errorf("can't decode messageMediaGiveaway#aa073beb to nil") } { if err := m.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messageMediaGiveaway#daad85b0: field flags: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveaway#aa073beb: field flags: %w", err) } } m.OnlyNewSubscribers = m.Flags.Has(0) @@ -3753,7 +3787,7 @@ func (m *MessageMediaGiveaway) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveaway#daad85b0: field channels: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveaway#aa073beb: field channels: %w", err) } if headerLen > 0 { @@ -3762,7 +3796,7 @@ func (m *MessageMediaGiveaway) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveaway#daad85b0: field channels: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveaway#aa073beb: field channels: %w", err) } m.Channels = append(m.Channels, value) } @@ -3770,7 +3804,7 @@ func (m *MessageMediaGiveaway) DecodeBare(b *bin.Buffer) error { if m.Flags.Has(1) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveaway#daad85b0: field countries_iso2: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveaway#aa073beb: field countries_iso2: %w", err) } if headerLen > 0 { @@ -3779,7 +3813,7 @@ func (m *MessageMediaGiveaway) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveaway#daad85b0: field countries_iso2: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveaway#aa073beb: field countries_iso2: %w", err) } m.CountriesISO2 = append(m.CountriesISO2, value) } @@ -3787,28 +3821,35 @@ func (m *MessageMediaGiveaway) DecodeBare(b *bin.Buffer) error { if m.Flags.Has(3) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveaway#daad85b0: field prize_description: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveaway#aa073beb: field prize_description: %w", err) } m.PrizeDescription = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveaway#daad85b0: field quantity: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveaway#aa073beb: field quantity: %w", err) } m.Quantity = value } - { + if m.Flags.Has(4) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveaway#daad85b0: field months: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveaway#aa073beb: field months: %w", err) } m.Months = value } + if m.Flags.Has(5) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messageMediaGiveaway#aa073beb: field stars: %w", err) + } + m.Stars = value + } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveaway#daad85b0: field until_date: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveaway#aa073beb: field until_date: %w", err) } m.UntilDate = value } @@ -3905,12 +3946,40 @@ func (m *MessageMediaGiveaway) GetQuantity() (value int) { return m.Quantity } -// GetMonths returns value of Months field. -func (m *MessageMediaGiveaway) GetMonths() (value int) { +// SetMonths sets value of Months conditional field. +func (m *MessageMediaGiveaway) SetMonths(value int) { + m.Flags.Set(4) + m.Months = value +} + +// GetMonths returns value of Months conditional field and +// boolean which is true if field was set. +func (m *MessageMediaGiveaway) GetMonths() (value int, ok bool) { if m == nil { return } - return m.Months + if !m.Flags.Has(4) { + return value, false + } + return m.Months, true +} + +// SetStars sets value of Stars conditional field. +func (m *MessageMediaGiveaway) SetStars(value int64) { + m.Flags.Set(5) + m.Stars = value +} + +// GetStars returns value of Stars conditional field and +// boolean which is true if field was set. +func (m *MessageMediaGiveaway) GetStars() (value int64, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(5) { + return value, false + } + return m.Stars, true } // GetUntilDate returns value of UntilDate field. @@ -3921,7 +3990,7 @@ func (m *MessageMediaGiveaway) GetUntilDate() (value int) { return m.UntilDate } -// MessageMediaGiveawayResults represents TL type `messageMediaGiveawayResults#c6991068`. +// MessageMediaGiveawayResults represents TL type `messageMediaGiveawayResults#ceaa3ea1`. // A giveaway¹ with public winners has finished, this constructor contains info about // the winners. // @@ -3962,7 +4031,13 @@ type MessageMediaGiveawayResults struct { // // Links: // 1) https://core.telegram.org/api/premium + // + // Use SetMonths and GetMonths helpers. Months int + // Stars field of MessageMediaGiveawayResults. + // + // Use SetStars and GetStars helpers. + Stars int64 // Can contain a textual description of additional giveaway prizes. // // Use SetPrizeDescription and GetPrizeDescription helpers. @@ -3973,7 +4048,7 @@ type MessageMediaGiveawayResults struct { } // MessageMediaGiveawayResultsTypeID is TL type id of MessageMediaGiveawayResults. -const MessageMediaGiveawayResultsTypeID = 0xc6991068 +const MessageMediaGiveawayResultsTypeID = 0xceaa3ea1 // construct implements constructor of MessageMediaClass. func (m MessageMediaGiveawayResults) construct() MessageMediaClass { return &m } @@ -4022,6 +4097,9 @@ func (m *MessageMediaGiveawayResults) Zero() bool { if !(m.Months == 0) { return false } + if !(m.Stars == 0) { + return false + } if !(m.PrizeDescription == "") { return false } @@ -4051,7 +4129,8 @@ func (m *MessageMediaGiveawayResults) FillFrom(from interface { GetWinnersCount() (value int) GetUnclaimedCount() (value int) GetWinners() (value []int64) - GetMonths() (value int) + GetMonths() (value int, ok bool) + GetStars() (value int64, ok bool) GetPrizeDescription() (value string, ok bool) GetUntilDate() (value int) }) { @@ -4066,7 +4145,14 @@ func (m *MessageMediaGiveawayResults) FillFrom(from interface { m.WinnersCount = from.GetWinnersCount() m.UnclaimedCount = from.GetUnclaimedCount() m.Winners = from.GetWinners() - m.Months = from.GetMonths() + if val, ok := from.GetMonths(); ok { + m.Months = val + } + + if val, ok := from.GetStars(); ok { + m.Stars = val + } + if val, ok := from.GetPrizeDescription(); ok { m.PrizeDescription = val } @@ -4135,6 +4221,12 @@ func (m *MessageMediaGiveawayResults) TypeInfo() tdp.Type { { Name: "Months", SchemaName: "months", + Null: !m.Flags.Has(4), + }, + { + Name: "Stars", + SchemaName: "stars", + Null: !m.Flags.Has(5), }, { Name: "PrizeDescription", @@ -4160,6 +4252,12 @@ func (m *MessageMediaGiveawayResults) SetFlags() { if !(m.AdditionalPeersCount == 0) { m.Flags.Set(3) } + if !(m.Months == 0) { + m.Flags.Set(4) + } + if !(m.Stars == 0) { + m.Flags.Set(5) + } if !(m.PrizeDescription == "") { m.Flags.Set(1) } @@ -4168,7 +4266,7 @@ func (m *MessageMediaGiveawayResults) SetFlags() { // Encode implements bin.Encoder. func (m *MessageMediaGiveawayResults) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageMediaGiveawayResults#c6991068 as nil") + return fmt.Errorf("can't encode messageMediaGiveawayResults#ceaa3ea1 as nil") } b.PutID(MessageMediaGiveawayResultsTypeID) return m.EncodeBare(b) @@ -4177,11 +4275,11 @@ func (m *MessageMediaGiveawayResults) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *MessageMediaGiveawayResults) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageMediaGiveawayResults#c6991068 as nil") + return fmt.Errorf("can't encode messageMediaGiveawayResults#ceaa3ea1 as nil") } m.SetFlags() if err := m.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageMediaGiveawayResults#c6991068: field flags: %w", err) + return fmt.Errorf("unable to encode messageMediaGiveawayResults#ceaa3ea1: field flags: %w", err) } b.PutLong(m.ChannelID) if m.Flags.Has(3) { @@ -4194,7 +4292,12 @@ func (m *MessageMediaGiveawayResults) EncodeBare(b *bin.Buffer) error { for _, v := range m.Winners { b.PutLong(v) } - b.PutInt(m.Months) + if m.Flags.Has(4) { + b.PutInt(m.Months) + } + if m.Flags.Has(5) { + b.PutLong(m.Stars) + } if m.Flags.Has(1) { b.PutString(m.PrizeDescription) } @@ -4205,10 +4308,10 @@ func (m *MessageMediaGiveawayResults) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (m *MessageMediaGiveawayResults) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageMediaGiveawayResults#c6991068 to nil") + return fmt.Errorf("can't decode messageMediaGiveawayResults#ceaa3ea1 to nil") } if err := b.ConsumeID(MessageMediaGiveawayResultsTypeID); err != nil { - return fmt.Errorf("unable to decode messageMediaGiveawayResults#c6991068: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveawayResults#ceaa3ea1: %w", err) } return m.DecodeBare(b) } @@ -4216,11 +4319,11 @@ func (m *MessageMediaGiveawayResults) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *MessageMediaGiveawayResults) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageMediaGiveawayResults#c6991068 to nil") + return fmt.Errorf("can't decode messageMediaGiveawayResults#ceaa3ea1 to nil") } { if err := m.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messageMediaGiveawayResults#c6991068: field flags: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveawayResults#ceaa3ea1: field flags: %w", err) } } m.OnlyNewSubscribers = m.Flags.Has(0) @@ -4228,42 +4331,42 @@ func (m *MessageMediaGiveawayResults) DecodeBare(b *bin.Buffer) error { { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveawayResults#c6991068: field channel_id: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveawayResults#ceaa3ea1: field channel_id: %w", err) } m.ChannelID = value } if m.Flags.Has(3) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveawayResults#c6991068: field additional_peers_count: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveawayResults#ceaa3ea1: field additional_peers_count: %w", err) } m.AdditionalPeersCount = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveawayResults#c6991068: field launch_msg_id: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveawayResults#ceaa3ea1: field launch_msg_id: %w", err) } m.LaunchMsgID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveawayResults#c6991068: field winners_count: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveawayResults#ceaa3ea1: field winners_count: %w", err) } m.WinnersCount = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveawayResults#c6991068: field unclaimed_count: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveawayResults#ceaa3ea1: field unclaimed_count: %w", err) } m.UnclaimedCount = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveawayResults#c6991068: field winners: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveawayResults#ceaa3ea1: field winners: %w", err) } if headerLen > 0 { @@ -4272,29 +4375,36 @@ func (m *MessageMediaGiveawayResults) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveawayResults#c6991068: field winners: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveawayResults#ceaa3ea1: field winners: %w", err) } m.Winners = append(m.Winners, value) } } - { + if m.Flags.Has(4) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveawayResults#c6991068: field months: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveawayResults#ceaa3ea1: field months: %w", err) } m.Months = value } + if m.Flags.Has(5) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messageMediaGiveawayResults#ceaa3ea1: field stars: %w", err) + } + m.Stars = value + } if m.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveawayResults#c6991068: field prize_description: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveawayResults#ceaa3ea1: field prize_description: %w", err) } m.PrizeDescription = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageMediaGiveawayResults#c6991068: field until_date: %w", err) + return fmt.Errorf("unable to decode messageMediaGiveawayResults#ceaa3ea1: field until_date: %w", err) } m.UntilDate = value } @@ -4397,12 +4507,40 @@ func (m *MessageMediaGiveawayResults) GetWinners() (value []int64) { return m.Winners } -// GetMonths returns value of Months field. -func (m *MessageMediaGiveawayResults) GetMonths() (value int) { +// SetMonths sets value of Months conditional field. +func (m *MessageMediaGiveawayResults) SetMonths(value int) { + m.Flags.Set(4) + m.Months = value +} + +// GetMonths returns value of Months conditional field and +// boolean which is true if field was set. +func (m *MessageMediaGiveawayResults) GetMonths() (value int, ok bool) { if m == nil { return } - return m.Months + if !m.Flags.Has(4) { + return value, false + } + return m.Months, true +} + +// SetStars sets value of Stars conditional field. +func (m *MessageMediaGiveawayResults) SetStars(value int64) { + m.Flags.Set(5) + m.Stars = value +} + +// GetStars returns value of Stars conditional field and +// boolean which is true if field was set. +func (m *MessageMediaGiveawayResults) GetStars() (value int64, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(5) { + return value, false + } + return m.Stars, true } // SetPrizeDescription sets value of PrizeDescription conditional field. @@ -4643,8 +4781,8 @@ const MessageMediaClassName = "MessageMedia" // case *tg.MessageMediaPoll: // messageMediaPoll#4bd6e798 // case *tg.MessageMediaDice: // messageMediaDice#3f7ee58b // case *tg.MessageMediaStory: // messageMediaStory#68cb6283 -// case *tg.MessageMediaGiveaway: // messageMediaGiveaway#daad85b0 -// case *tg.MessageMediaGiveawayResults: // messageMediaGiveawayResults#c6991068 +// case *tg.MessageMediaGiveaway: // messageMediaGiveaway#aa073beb +// case *tg.MessageMediaGiveawayResults: // messageMediaGiveawayResults#ceaa3ea1 // case *tg.MessageMediaPaidMedia: // messageMediaPaidMedia#a8852491 // default: panic(v) // } @@ -4773,14 +4911,14 @@ func DecodeMessageMedia(buf *bin.Buffer) (MessageMediaClass, error) { } return &v, nil case MessageMediaGiveawayTypeID: - // Decoding messageMediaGiveaway#daad85b0. + // Decoding messageMediaGiveaway#aa073beb. v := MessageMediaGiveaway{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageMediaClass: %w", err) } return &v, nil case MessageMediaGiveawayResultsTypeID: - // Decoding messageMediaGiveawayResults#c6991068. + // Decoding messageMediaGiveawayResults#ceaa3ea1. v := MessageMediaGiveawayResults{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageMediaClass: %w", err) diff --git a/tg/tl_messages_get_paid_reaction_privacy_gen.go b/tg/tl_messages_get_paid_reaction_privacy_gen.go new file mode 100644 index 0000000000..9cec4b8adc --- /dev/null +++ b/tg/tl_messages_get_paid_reaction_privacy_gen.go @@ -0,0 +1,141 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// MessagesGetPaidReactionPrivacyRequest represents TL type `messages.getPaidReactionPrivacy#472455aa`. +// +// See https://core.telegram.org/method/messages.getPaidReactionPrivacy for reference. +type MessagesGetPaidReactionPrivacyRequest struct { +} + +// MessagesGetPaidReactionPrivacyRequestTypeID is TL type id of MessagesGetPaidReactionPrivacyRequest. +const MessagesGetPaidReactionPrivacyRequestTypeID = 0x472455aa + +// Ensuring interfaces in compile-time for MessagesGetPaidReactionPrivacyRequest. +var ( + _ bin.Encoder = &MessagesGetPaidReactionPrivacyRequest{} + _ bin.Decoder = &MessagesGetPaidReactionPrivacyRequest{} + _ bin.BareEncoder = &MessagesGetPaidReactionPrivacyRequest{} + _ bin.BareDecoder = &MessagesGetPaidReactionPrivacyRequest{} +) + +func (g *MessagesGetPaidReactionPrivacyRequest) Zero() bool { + if g == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (g *MessagesGetPaidReactionPrivacyRequest) String() string { + if g == nil { + return "MessagesGetPaidReactionPrivacyRequest(nil)" + } + type Alias MessagesGetPaidReactionPrivacyRequest + return fmt.Sprintf("MessagesGetPaidReactionPrivacyRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesGetPaidReactionPrivacyRequest) TypeID() uint32 { + return MessagesGetPaidReactionPrivacyRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesGetPaidReactionPrivacyRequest) TypeName() string { + return "messages.getPaidReactionPrivacy" +} + +// TypeInfo returns info about TL type. +func (g *MessagesGetPaidReactionPrivacyRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.getPaidReactionPrivacy", + ID: MessagesGetPaidReactionPrivacyRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (g *MessagesGetPaidReactionPrivacyRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getPaidReactionPrivacy#472455aa as nil") + } + b.PutID(MessagesGetPaidReactionPrivacyRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *MessagesGetPaidReactionPrivacyRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getPaidReactionPrivacy#472455aa as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (g *MessagesGetPaidReactionPrivacyRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getPaidReactionPrivacy#472455aa to nil") + } + if err := b.ConsumeID(MessagesGetPaidReactionPrivacyRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.getPaidReactionPrivacy#472455aa: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *MessagesGetPaidReactionPrivacyRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getPaidReactionPrivacy#472455aa to nil") + } + return nil +} + +// MessagesGetPaidReactionPrivacy invokes method messages.getPaidReactionPrivacy#472455aa returning error if any. +// +// See https://core.telegram.org/method/messages.getPaidReactionPrivacy for reference. +func (c *Client) MessagesGetPaidReactionPrivacy(ctx context.Context) (UpdatesClass, error) { + var result UpdatesBox + + request := &MessagesGetPaidReactionPrivacyRequest{} + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Updates, nil +} diff --git a/tg/tl_messages_get_paid_reaction_privacy_slices_gen.go b/tg/tl_messages_get_paid_reaction_privacy_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_get_paid_reaction_privacy_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_send_paid_reaction_gen.go b/tg/tl_messages_send_paid_reaction_gen.go index 1ebf6773d6..8459958094 100644 --- a/tg/tl_messages_send_paid_reaction_gen.go +++ b/tg/tl_messages_send_paid_reaction_gen.go @@ -31,14 +31,12 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSendPaidReactionRequest represents TL type `messages.sendPaidReaction#25c8fe3e`. +// MessagesSendPaidReactionRequest represents TL type `messages.sendPaidReaction#9dd6a67b`. // // See https://core.telegram.org/method/messages.sendPaidReaction for reference. type MessagesSendPaidReactionRequest struct { // Flags field of MessagesSendPaidReactionRequest. Flags bin.Fields - // Private field of MessagesSendPaidReactionRequest. - Private bool // Peer field of MessagesSendPaidReactionRequest. Peer InputPeerClass // MsgID field of MessagesSendPaidReactionRequest. @@ -47,10 +45,14 @@ type MessagesSendPaidReactionRequest struct { Count int // RandomID field of MessagesSendPaidReactionRequest. RandomID int64 + // Private field of MessagesSendPaidReactionRequest. + // + // Use SetPrivate and GetPrivate helpers. + Private bool } // MessagesSendPaidReactionRequestTypeID is TL type id of MessagesSendPaidReactionRequest. -const MessagesSendPaidReactionRequestTypeID = 0x25c8fe3e +const MessagesSendPaidReactionRequestTypeID = 0x9dd6a67b // Ensuring interfaces in compile-time for MessagesSendPaidReactionRequest. var ( @@ -67,9 +69,6 @@ func (s *MessagesSendPaidReactionRequest) Zero() bool { if !(s.Flags.Zero()) { return false } - if !(s.Private == false) { - return false - } if !(s.Peer == nil) { return false } @@ -82,6 +81,9 @@ func (s *MessagesSendPaidReactionRequest) Zero() bool { if !(s.RandomID == 0) { return false } + if !(s.Private == false) { + return false + } return true } @@ -97,17 +99,20 @@ func (s *MessagesSendPaidReactionRequest) String() string { // FillFrom fills MessagesSendPaidReactionRequest from given interface. func (s *MessagesSendPaidReactionRequest) FillFrom(from interface { - GetPrivate() (value bool) GetPeer() (value InputPeerClass) GetMsgID() (value int) GetCount() (value int) GetRandomID() (value int64) + GetPrivate() (value bool, ok bool) }) { - s.Private = from.GetPrivate() s.Peer = from.GetPeer() s.MsgID = from.GetMsgID() s.Count = from.GetCount() s.RandomID = from.GetRandomID() + if val, ok := from.GetPrivate(); ok { + s.Private = val + } + } // TypeID returns type id in TL schema. @@ -133,11 +138,6 @@ func (s *MessagesSendPaidReactionRequest) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ - { - Name: "Private", - SchemaName: "private", - Null: !s.Flags.Has(0), - }, { Name: "Peer", SchemaName: "peer", @@ -154,6 +154,11 @@ func (s *MessagesSendPaidReactionRequest) TypeInfo() tdp.Type { Name: "RandomID", SchemaName: "random_id", }, + { + Name: "Private", + SchemaName: "private", + Null: !s.Flags.Has(0), + }, } return typ } @@ -168,7 +173,7 @@ func (s *MessagesSendPaidReactionRequest) SetFlags() { // Encode implements bin.Encoder. func (s *MessagesSendPaidReactionRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendPaidReaction#25c8fe3e as nil") + return fmt.Errorf("can't encode messages.sendPaidReaction#9dd6a67b as nil") } b.PutID(MessagesSendPaidReactionRequestTypeID) return s.EncodeBare(b) @@ -177,31 +182,34 @@ func (s *MessagesSendPaidReactionRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSendPaidReactionRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendPaidReaction#25c8fe3e as nil") + return fmt.Errorf("can't encode messages.sendPaidReaction#9dd6a67b as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendPaidReaction#25c8fe3e: field flags: %w", err) + return fmt.Errorf("unable to encode messages.sendPaidReaction#9dd6a67b: field flags: %w", err) } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.sendPaidReaction#25c8fe3e: field peer is nil") + return fmt.Errorf("unable to encode messages.sendPaidReaction#9dd6a67b: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendPaidReaction#25c8fe3e: field peer: %w", err) + return fmt.Errorf("unable to encode messages.sendPaidReaction#9dd6a67b: field peer: %w", err) } b.PutInt(s.MsgID) b.PutInt(s.Count) b.PutLong(s.RandomID) + if s.Flags.Has(0) { + b.PutBool(s.Private) + } return nil } // Decode implements bin.Decoder. func (s *MessagesSendPaidReactionRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendPaidReaction#25c8fe3e to nil") + return fmt.Errorf("can't decode messages.sendPaidReaction#9dd6a67b to nil") } if err := b.ConsumeID(MessagesSendPaidReactionRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.sendPaidReaction#25c8fe3e: %w", err) + return fmt.Errorf("unable to decode messages.sendPaidReaction#9dd6a67b: %w", err) } return s.DecodeBare(b) } @@ -209,62 +217,49 @@ func (s *MessagesSendPaidReactionRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSendPaidReactionRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendPaidReaction#25c8fe3e to nil") + return fmt.Errorf("can't decode messages.sendPaidReaction#9dd6a67b to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.sendPaidReaction#25c8fe3e: field flags: %w", err) + return fmt.Errorf("unable to decode messages.sendPaidReaction#9dd6a67b: field flags: %w", err) } } - s.Private = s.Flags.Has(0) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendPaidReaction#25c8fe3e: field peer: %w", err) + return fmt.Errorf("unable to decode messages.sendPaidReaction#9dd6a67b: field peer: %w", err) } s.Peer = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendPaidReaction#25c8fe3e: field msg_id: %w", err) + return fmt.Errorf("unable to decode messages.sendPaidReaction#9dd6a67b: field msg_id: %w", err) } s.MsgID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendPaidReaction#25c8fe3e: field count: %w", err) + return fmt.Errorf("unable to decode messages.sendPaidReaction#9dd6a67b: field count: %w", err) } s.Count = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messages.sendPaidReaction#25c8fe3e: field random_id: %w", err) + return fmt.Errorf("unable to decode messages.sendPaidReaction#9dd6a67b: field random_id: %w", err) } s.RandomID = value } - return nil -} - -// SetPrivate sets value of Private conditional field. -func (s *MessagesSendPaidReactionRequest) SetPrivate(value bool) { - if value { - s.Flags.Set(0) - s.Private = true - } else { - s.Flags.Unset(0) - s.Private = false - } -} - -// GetPrivate returns value of Private conditional field. -func (s *MessagesSendPaidReactionRequest) GetPrivate() (value bool) { - if s == nil { - return + if s.Flags.Has(0) { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode messages.sendPaidReaction#9dd6a67b: field private: %w", err) + } + s.Private = value } - return s.Flags.Has(0) + return nil } // GetPeer returns value of Peer field. @@ -299,7 +294,25 @@ func (s *MessagesSendPaidReactionRequest) GetRandomID() (value int64) { return s.RandomID } -// MessagesSendPaidReaction invokes method messages.sendPaidReaction#25c8fe3e returning error if any. +// SetPrivate sets value of Private conditional field. +func (s *MessagesSendPaidReactionRequest) SetPrivate(value bool) { + s.Flags.Set(0) + s.Private = value +} + +// GetPrivate returns value of Private conditional field and +// boolean which is true if field was set. +func (s *MessagesSendPaidReactionRequest) GetPrivate() (value bool, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.Private, true +} + +// MessagesSendPaidReaction invokes method messages.sendPaidReaction#9dd6a67b returning error if any. // // See https://core.telegram.org/method/messages.sendPaidReaction for reference. func (c *Client) MessagesSendPaidReaction(ctx context.Context, request *MessagesSendPaidReactionRequest) (UpdatesClass, error) { diff --git a/tg/tl_payments_get_stars_giveaway_options_gen.go b/tg/tl_payments_get_stars_giveaway_options_gen.go new file mode 100644 index 0000000000..5ca5c85f7b --- /dev/null +++ b/tg/tl_payments_get_stars_giveaway_options_gen.go @@ -0,0 +1,141 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// PaymentsGetStarsGiveawayOptionsRequest represents TL type `payments.getStarsGiveawayOptions#bd1efd3e`. +// +// See https://core.telegram.org/method/payments.getStarsGiveawayOptions for reference. +type PaymentsGetStarsGiveawayOptionsRequest struct { +} + +// PaymentsGetStarsGiveawayOptionsRequestTypeID is TL type id of PaymentsGetStarsGiveawayOptionsRequest. +const PaymentsGetStarsGiveawayOptionsRequestTypeID = 0xbd1efd3e + +// Ensuring interfaces in compile-time for PaymentsGetStarsGiveawayOptionsRequest. +var ( + _ bin.Encoder = &PaymentsGetStarsGiveawayOptionsRequest{} + _ bin.Decoder = &PaymentsGetStarsGiveawayOptionsRequest{} + _ bin.BareEncoder = &PaymentsGetStarsGiveawayOptionsRequest{} + _ bin.BareDecoder = &PaymentsGetStarsGiveawayOptionsRequest{} +) + +func (g *PaymentsGetStarsGiveawayOptionsRequest) Zero() bool { + if g == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGetStarsGiveawayOptionsRequest) String() string { + if g == nil { + return "PaymentsGetStarsGiveawayOptionsRequest(nil)" + } + type Alias PaymentsGetStarsGiveawayOptionsRequest + return fmt.Sprintf("PaymentsGetStarsGiveawayOptionsRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsGetStarsGiveawayOptionsRequest) TypeID() uint32 { + return PaymentsGetStarsGiveawayOptionsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGetStarsGiveawayOptionsRequest) TypeName() string { + return "payments.getStarsGiveawayOptions" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGetStarsGiveawayOptionsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.getStarsGiveawayOptions", + ID: PaymentsGetStarsGiveawayOptionsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (g *PaymentsGetStarsGiveawayOptionsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getStarsGiveawayOptions#bd1efd3e as nil") + } + b.PutID(PaymentsGetStarsGiveawayOptionsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGetStarsGiveawayOptionsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getStarsGiveawayOptions#bd1efd3e as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGetStarsGiveawayOptionsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getStarsGiveawayOptions#bd1efd3e to nil") + } + if err := b.ConsumeID(PaymentsGetStarsGiveawayOptionsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.getStarsGiveawayOptions#bd1efd3e: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGetStarsGiveawayOptionsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getStarsGiveawayOptions#bd1efd3e to nil") + } + return nil +} + +// PaymentsGetStarsGiveawayOptions invokes method payments.getStarsGiveawayOptions#bd1efd3e returning error if any. +// +// See https://core.telegram.org/method/payments.getStarsGiveawayOptions for reference. +func (c *Client) PaymentsGetStarsGiveawayOptions(ctx context.Context) ([]StarsGiveawayOption, error) { + var result StarsGiveawayOptionVector + + request := &PaymentsGetStarsGiveawayOptionsRequest{} + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return []StarsGiveawayOption(result.Elems), nil +} diff --git a/tg/tl_payments_get_stars_giveaway_options_slices_gen.go b/tg/tl_payments_get_stars_giveaway_options_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_get_stars_giveaway_options_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_payments_giveaway_info_gen.go b/tg/tl_payments_giveaway_info_gen.go index b5ba745431..3b226c762f 100644 --- a/tg/tl_payments_giveaway_info_gen.go +++ b/tg/tl_payments_giveaway_info_gen.go @@ -415,7 +415,7 @@ func (g *PaymentsGiveawayInfo) GetDisallowedCountry() (value string, ok bool) { return g.DisallowedCountry, true } -// PaymentsGiveawayInfoResults represents TL type `payments.giveawayInfoResults#cd5570`. +// PaymentsGiveawayInfoResults represents TL type `payments.giveawayInfoResults#e175e66f`. // A giveaway¹ has ended. // // Links: @@ -443,6 +443,10 @@ type PaymentsGiveawayInfoResults struct { // // Use SetGiftCodeSlug and GetGiftCodeSlug helpers. GiftCodeSlug string + // StarsPrize field of PaymentsGiveawayInfoResults. + // + // Use SetStarsPrize and GetStarsPrize helpers. + StarsPrize int64 // End date of the giveaway. May be bigger than the end date specified in parameters of // the giveaway. FinishDate int @@ -452,11 +456,13 @@ type PaymentsGiveawayInfoResults struct { // // Links: // 1) https://core.telegram.org/api/links#premium-giftcode-links + // + // Use SetActivatedCount and GetActivatedCount helpers. ActivatedCount int } // PaymentsGiveawayInfoResultsTypeID is TL type id of PaymentsGiveawayInfoResults. -const PaymentsGiveawayInfoResultsTypeID = 0xcd5570 +const PaymentsGiveawayInfoResultsTypeID = 0xe175e66f // construct implements constructor of PaymentsGiveawayInfoClass. func (g PaymentsGiveawayInfoResults) construct() PaymentsGiveawayInfoClass { return &g } @@ -490,6 +496,9 @@ func (g *PaymentsGiveawayInfoResults) Zero() bool { if !(g.GiftCodeSlug == "") { return false } + if !(g.StarsPrize == 0) { + return false + } if !(g.FinishDate == 0) { return false } @@ -518,9 +527,10 @@ func (g *PaymentsGiveawayInfoResults) FillFrom(from interface { GetRefunded() (value bool) GetStartDate() (value int) GetGiftCodeSlug() (value string, ok bool) + GetStarsPrize() (value int64, ok bool) GetFinishDate() (value int) GetWinnersCount() (value int) - GetActivatedCount() (value int) + GetActivatedCount() (value int, ok bool) }) { g.Winner = from.GetWinner() g.Refunded = from.GetRefunded() @@ -529,9 +539,16 @@ func (g *PaymentsGiveawayInfoResults) FillFrom(from interface { g.GiftCodeSlug = val } + if val, ok := from.GetStarsPrize(); ok { + g.StarsPrize = val + } + g.FinishDate = from.GetFinishDate() g.WinnersCount = from.GetWinnersCount() - g.ActivatedCount = from.GetActivatedCount() + if val, ok := from.GetActivatedCount(); ok { + g.ActivatedCount = val + } + } // TypeID returns type id in TL schema. @@ -574,7 +591,12 @@ func (g *PaymentsGiveawayInfoResults) TypeInfo() tdp.Type { { Name: "GiftCodeSlug", SchemaName: "gift_code_slug", - Null: !g.Flags.Has(0), + Null: !g.Flags.Has(3), + }, + { + Name: "StarsPrize", + SchemaName: "stars_prize", + Null: !g.Flags.Has(4), }, { Name: "FinishDate", @@ -587,6 +609,7 @@ func (g *PaymentsGiveawayInfoResults) TypeInfo() tdp.Type { { Name: "ActivatedCount", SchemaName: "activated_count", + Null: !g.Flags.Has(2), }, } return typ @@ -601,14 +624,20 @@ func (g *PaymentsGiveawayInfoResults) SetFlags() { g.Flags.Set(1) } if !(g.GiftCodeSlug == "") { - g.Flags.Set(0) + g.Flags.Set(3) + } + if !(g.StarsPrize == 0) { + g.Flags.Set(4) + } + if !(g.ActivatedCount == 0) { + g.Flags.Set(2) } } // Encode implements bin.Encoder. func (g *PaymentsGiveawayInfoResults) Encode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode payments.giveawayInfoResults#cd5570 as nil") + return fmt.Errorf("can't encode payments.giveawayInfoResults#e175e66f as nil") } b.PutID(PaymentsGiveawayInfoResultsTypeID) return g.EncodeBare(b) @@ -617,29 +646,34 @@ func (g *PaymentsGiveawayInfoResults) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (g *PaymentsGiveawayInfoResults) EncodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode payments.giveawayInfoResults#cd5570 as nil") + return fmt.Errorf("can't encode payments.giveawayInfoResults#e175e66f as nil") } g.SetFlags() if err := g.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode payments.giveawayInfoResults#cd5570: field flags: %w", err) + return fmt.Errorf("unable to encode payments.giveawayInfoResults#e175e66f: field flags: %w", err) } b.PutInt(g.StartDate) - if g.Flags.Has(0) { + if g.Flags.Has(3) { b.PutString(g.GiftCodeSlug) } + if g.Flags.Has(4) { + b.PutLong(g.StarsPrize) + } b.PutInt(g.FinishDate) b.PutInt(g.WinnersCount) - b.PutInt(g.ActivatedCount) + if g.Flags.Has(2) { + b.PutInt(g.ActivatedCount) + } return nil } // Decode implements bin.Decoder. func (g *PaymentsGiveawayInfoResults) Decode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode payments.giveawayInfoResults#cd5570 to nil") + return fmt.Errorf("can't decode payments.giveawayInfoResults#e175e66f to nil") } if err := b.ConsumeID(PaymentsGiveawayInfoResultsTypeID); err != nil { - return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: %w", err) + return fmt.Errorf("unable to decode payments.giveawayInfoResults#e175e66f: %w", err) } return g.DecodeBare(b) } @@ -647,11 +681,11 @@ func (g *PaymentsGiveawayInfoResults) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (g *PaymentsGiveawayInfoResults) DecodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode payments.giveawayInfoResults#cd5570 to nil") + return fmt.Errorf("can't decode payments.giveawayInfoResults#e175e66f to nil") } { if err := g.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: field flags: %w", err) + return fmt.Errorf("unable to decode payments.giveawayInfoResults#e175e66f: field flags: %w", err) } } g.Winner = g.Flags.Has(0) @@ -659,35 +693,42 @@ func (g *PaymentsGiveawayInfoResults) DecodeBare(b *bin.Buffer) error { { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: field start_date: %w", err) + return fmt.Errorf("unable to decode payments.giveawayInfoResults#e175e66f: field start_date: %w", err) } g.StartDate = value } - if g.Flags.Has(0) { + if g.Flags.Has(3) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: field gift_code_slug: %w", err) + return fmt.Errorf("unable to decode payments.giveawayInfoResults#e175e66f: field gift_code_slug: %w", err) } g.GiftCodeSlug = value } + if g.Flags.Has(4) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode payments.giveawayInfoResults#e175e66f: field stars_prize: %w", err) + } + g.StarsPrize = value + } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: field finish_date: %w", err) + return fmt.Errorf("unable to decode payments.giveawayInfoResults#e175e66f: field finish_date: %w", err) } g.FinishDate = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: field winners_count: %w", err) + return fmt.Errorf("unable to decode payments.giveawayInfoResults#e175e66f: field winners_count: %w", err) } g.WinnersCount = value } - { + if g.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode payments.giveawayInfoResults#cd5570: field activated_count: %w", err) + return fmt.Errorf("unable to decode payments.giveawayInfoResults#e175e66f: field activated_count: %w", err) } g.ActivatedCount = value } @@ -742,7 +783,7 @@ func (g *PaymentsGiveawayInfoResults) GetStartDate() (value int) { // SetGiftCodeSlug sets value of GiftCodeSlug conditional field. func (g *PaymentsGiveawayInfoResults) SetGiftCodeSlug(value string) { - g.Flags.Set(0) + g.Flags.Set(3) g.GiftCodeSlug = value } @@ -752,12 +793,30 @@ func (g *PaymentsGiveawayInfoResults) GetGiftCodeSlug() (value string, ok bool) if g == nil { return } - if !g.Flags.Has(0) { + if !g.Flags.Has(3) { return value, false } return g.GiftCodeSlug, true } +// SetStarsPrize sets value of StarsPrize conditional field. +func (g *PaymentsGiveawayInfoResults) SetStarsPrize(value int64) { + g.Flags.Set(4) + g.StarsPrize = value +} + +// GetStarsPrize returns value of StarsPrize conditional field and +// boolean which is true if field was set. +func (g *PaymentsGiveawayInfoResults) GetStarsPrize() (value int64, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(4) { + return value, false + } + return g.StarsPrize, true +} + // GetFinishDate returns value of FinishDate field. func (g *PaymentsGiveawayInfoResults) GetFinishDate() (value int) { if g == nil { @@ -774,12 +833,22 @@ func (g *PaymentsGiveawayInfoResults) GetWinnersCount() (value int) { return g.WinnersCount } -// GetActivatedCount returns value of ActivatedCount field. -func (g *PaymentsGiveawayInfoResults) GetActivatedCount() (value int) { +// SetActivatedCount sets value of ActivatedCount conditional field. +func (g *PaymentsGiveawayInfoResults) SetActivatedCount(value int) { + g.Flags.Set(2) + g.ActivatedCount = value +} + +// GetActivatedCount returns value of ActivatedCount conditional field and +// boolean which is true if field was set. +func (g *PaymentsGiveawayInfoResults) GetActivatedCount() (value int, ok bool) { if g == nil { return } - return g.ActivatedCount + if !g.Flags.Has(2) { + return value, false + } + return g.ActivatedCount, true } // PaymentsGiveawayInfoClassName is schema name of PaymentsGiveawayInfoClass. @@ -797,7 +866,7 @@ const PaymentsGiveawayInfoClassName = "payments.GiveawayInfo" // } // switch v := g.(type) { // case *tg.PaymentsGiveawayInfo: // payments.giveawayInfo#4367daa0 -// case *tg.PaymentsGiveawayInfoResults: // payments.giveawayInfoResults#cd5570 +// case *tg.PaymentsGiveawayInfoResults: // payments.giveawayInfoResults#e175e66f // default: panic(v) // } type PaymentsGiveawayInfoClass interface { @@ -837,7 +906,7 @@ func DecodePaymentsGiveawayInfo(buf *bin.Buffer) (PaymentsGiveawayInfoClass, err } return &v, nil case PaymentsGiveawayInfoResultsTypeID: - // Decoding payments.giveawayInfoResults#cd5570. + // Decoding payments.giveawayInfoResults#e175e66f. v := PaymentsGiveawayInfoResults{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode PaymentsGiveawayInfoClass: %w", err) diff --git a/tg/tl_premium_boosts_status_gen.go b/tg/tl_premium_boosts_status_gen.go index 605d14ec1d..0901d43acf 100644 --- a/tg/tl_premium_boosts_status_gen.go +++ b/tg/tl_premium_boosts_status_gen.go @@ -82,7 +82,7 @@ type PremiumBoostsStatus struct { // 1) https://core.telegram.org/api/giveaways // // Use SetPrepaidGiveaways and GetPrepaidGiveaways helpers. - PrepaidGiveaways []PrepaidGiveaway + PrepaidGiveaways []PrepaidGiveawayClass // Indicates which of our boost slots¹ we've assigned to this peer (populated if // my_boost is set). // @@ -164,7 +164,7 @@ func (b *PremiumBoostsStatus) FillFrom(from interface { GetNextLevelBoosts() (value int, ok bool) GetPremiumAudience() (value StatsPercentValue, ok bool) GetBoostURL() (value string) - GetPrepaidGiveaways() (value []PrepaidGiveaway, ok bool) + GetPrepaidGiveaways() (value []PrepaidGiveawayClass, ok bool) GetMyBoostSlots() (value []int, ok bool) }) { b.MyBoost = from.GetMyBoost() @@ -325,6 +325,9 @@ func (b *PremiumBoostsStatus) EncodeBare(buf *bin.Buffer) error { if b.Flags.Has(3) { buf.PutVectorHeader(len(b.PrepaidGiveaways)) for idx, v := range b.PrepaidGiveaways { + if v == nil { + return fmt.Errorf("unable to encode premium.boostsStatus#4959427a: field prepaid_giveaways element with index %d is nil", idx) + } if err := v.Encode(buf); err != nil { return fmt.Errorf("unable to encode premium.boostsStatus#4959427a: field prepaid_giveaways element with index %d: %w", idx, err) } @@ -415,11 +418,11 @@ func (b *PremiumBoostsStatus) DecodeBare(buf *bin.Buffer) error { } if headerLen > 0 { - b.PrepaidGiveaways = make([]PrepaidGiveaway, 0, headerLen%bin.PreallocateLimit) + b.PrepaidGiveaways = make([]PrepaidGiveawayClass, 0, headerLen%bin.PreallocateLimit) } for idx := 0; idx < headerLen; idx++ { - var value PrepaidGiveaway - if err := value.Decode(buf); err != nil { + value, err := DecodePrepaidGiveaway(buf) + if err != nil { return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field prepaid_giveaways: %w", err) } b.PrepaidGiveaways = append(b.PrepaidGiveaways, value) @@ -551,14 +554,14 @@ func (b *PremiumBoostsStatus) GetBoostURL() (value string) { } // SetPrepaidGiveaways sets value of PrepaidGiveaways conditional field. -func (b *PremiumBoostsStatus) SetPrepaidGiveaways(value []PrepaidGiveaway) { +func (b *PremiumBoostsStatus) SetPrepaidGiveaways(value []PrepaidGiveawayClass) { b.Flags.Set(3) b.PrepaidGiveaways = value } // GetPrepaidGiveaways returns value of PrepaidGiveaways conditional field and // boolean which is true if field was set. -func (b *PremiumBoostsStatus) GetPrepaidGiveaways() (value []PrepaidGiveaway, ok bool) { +func (b *PremiumBoostsStatus) GetPrepaidGiveaways() (value []PrepaidGiveawayClass, ok bool) { if b == nil { return } @@ -585,3 +588,11 @@ func (b *PremiumBoostsStatus) GetMyBoostSlots() (value []int, ok bool) { } return b.MyBoostSlots, true } + +// MapPrepaidGiveaways returns field PrepaidGiveaways wrapped in PrepaidGiveawayClassArray helper. +func (b *PremiumBoostsStatus) MapPrepaidGiveaways() (value PrepaidGiveawayClassArray, ok bool) { + if !b.Flags.Has(3) { + return value, false + } + return PrepaidGiveawayClassArray(b.PrepaidGiveaways), true +} diff --git a/tg/tl_prepaid_giveaway_gen.go b/tg/tl_prepaid_giveaway_gen.go index a1a7a6fd44..44be3ba8c1 100644 --- a/tg/tl_prepaid_giveaway_gen.go +++ b/tg/tl_prepaid_giveaway_gen.go @@ -58,12 +58,17 @@ type PrepaidGiveaway struct { // PrepaidGiveawayTypeID is TL type id of PrepaidGiveaway. const PrepaidGiveawayTypeID = 0xb2539d54 +// construct implements constructor of PrepaidGiveawayClass. +func (p PrepaidGiveaway) construct() PrepaidGiveawayClass { return &p } + // Ensuring interfaces in compile-time for PrepaidGiveaway. var ( _ bin.Encoder = &PrepaidGiveaway{} _ bin.Decoder = &PrepaidGiveaway{} _ bin.BareEncoder = &PrepaidGiveaway{} _ bin.BareDecoder = &PrepaidGiveaway{} + + _ PrepaidGiveawayClass = &PrepaidGiveaway{} ) func (p *PrepaidGiveaway) Zero() bool { @@ -250,3 +255,346 @@ func (p *PrepaidGiveaway) GetDate() (value int) { } return p.Date } + +// PrepaidStarsGiveaway represents TL type `prepaidStarsGiveaway#9a9d77e0`. +// +// See https://core.telegram.org/constructor/prepaidStarsGiveaway for reference. +type PrepaidStarsGiveaway struct { + // ID field of PrepaidStarsGiveaway. + ID int64 + // Stars field of PrepaidStarsGiveaway. + Stars int64 + // Quantity field of PrepaidStarsGiveaway. + Quantity int + // Boosts field of PrepaidStarsGiveaway. + Boosts int + // Date field of PrepaidStarsGiveaway. + Date int +} + +// PrepaidStarsGiveawayTypeID is TL type id of PrepaidStarsGiveaway. +const PrepaidStarsGiveawayTypeID = 0x9a9d77e0 + +// construct implements constructor of PrepaidGiveawayClass. +func (p PrepaidStarsGiveaway) construct() PrepaidGiveawayClass { return &p } + +// Ensuring interfaces in compile-time for PrepaidStarsGiveaway. +var ( + _ bin.Encoder = &PrepaidStarsGiveaway{} + _ bin.Decoder = &PrepaidStarsGiveaway{} + _ bin.BareEncoder = &PrepaidStarsGiveaway{} + _ bin.BareDecoder = &PrepaidStarsGiveaway{} + + _ PrepaidGiveawayClass = &PrepaidStarsGiveaway{} +) + +func (p *PrepaidStarsGiveaway) Zero() bool { + if p == nil { + return true + } + if !(p.ID == 0) { + return false + } + if !(p.Stars == 0) { + return false + } + if !(p.Quantity == 0) { + return false + } + if !(p.Boosts == 0) { + return false + } + if !(p.Date == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (p *PrepaidStarsGiveaway) String() string { + if p == nil { + return "PrepaidStarsGiveaway(nil)" + } + type Alias PrepaidStarsGiveaway + return fmt.Sprintf("PrepaidStarsGiveaway%+v", Alias(*p)) +} + +// FillFrom fills PrepaidStarsGiveaway from given interface. +func (p *PrepaidStarsGiveaway) FillFrom(from interface { + GetID() (value int64) + GetStars() (value int64) + GetQuantity() (value int) + GetBoosts() (value int) + GetDate() (value int) +}) { + p.ID = from.GetID() + p.Stars = from.GetStars() + p.Quantity = from.GetQuantity() + p.Boosts = from.GetBoosts() + p.Date = from.GetDate() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PrepaidStarsGiveaway) TypeID() uint32 { + return PrepaidStarsGiveawayTypeID +} + +// TypeName returns name of type in TL schema. +func (*PrepaidStarsGiveaway) TypeName() string { + return "prepaidStarsGiveaway" +} + +// TypeInfo returns info about TL type. +func (p *PrepaidStarsGiveaway) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "prepaidStarsGiveaway", + ID: PrepaidStarsGiveawayTypeID, + } + if p == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ID", + SchemaName: "id", + }, + { + Name: "Stars", + SchemaName: "stars", + }, + { + Name: "Quantity", + SchemaName: "quantity", + }, + { + Name: "Boosts", + SchemaName: "boosts", + }, + { + Name: "Date", + SchemaName: "date", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (p *PrepaidStarsGiveaway) Encode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode prepaidStarsGiveaway#9a9d77e0 as nil") + } + b.PutID(PrepaidStarsGiveawayTypeID) + return p.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (p *PrepaidStarsGiveaway) EncodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode prepaidStarsGiveaway#9a9d77e0 as nil") + } + b.PutLong(p.ID) + b.PutLong(p.Stars) + b.PutInt(p.Quantity) + b.PutInt(p.Boosts) + b.PutInt(p.Date) + return nil +} + +// Decode implements bin.Decoder. +func (p *PrepaidStarsGiveaway) Decode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode prepaidStarsGiveaway#9a9d77e0 to nil") + } + if err := b.ConsumeID(PrepaidStarsGiveawayTypeID); err != nil { + return fmt.Errorf("unable to decode prepaidStarsGiveaway#9a9d77e0: %w", err) + } + return p.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (p *PrepaidStarsGiveaway) DecodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode prepaidStarsGiveaway#9a9d77e0 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode prepaidStarsGiveaway#9a9d77e0: field id: %w", err) + } + p.ID = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode prepaidStarsGiveaway#9a9d77e0: field stars: %w", err) + } + p.Stars = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode prepaidStarsGiveaway#9a9d77e0: field quantity: %w", err) + } + p.Quantity = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode prepaidStarsGiveaway#9a9d77e0: field boosts: %w", err) + } + p.Boosts = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode prepaidStarsGiveaway#9a9d77e0: field date: %w", err) + } + p.Date = value + } + return nil +} + +// GetID returns value of ID field. +func (p *PrepaidStarsGiveaway) GetID() (value int64) { + if p == nil { + return + } + return p.ID +} + +// GetStars returns value of Stars field. +func (p *PrepaidStarsGiveaway) GetStars() (value int64) { + if p == nil { + return + } + return p.Stars +} + +// GetQuantity returns value of Quantity field. +func (p *PrepaidStarsGiveaway) GetQuantity() (value int) { + if p == nil { + return + } + return p.Quantity +} + +// GetBoosts returns value of Boosts field. +func (p *PrepaidStarsGiveaway) GetBoosts() (value int) { + if p == nil { + return + } + return p.Boosts +} + +// GetDate returns value of Date field. +func (p *PrepaidStarsGiveaway) GetDate() (value int) { + if p == nil { + return + } + return p.Date +} + +// PrepaidGiveawayClassName is schema name of PrepaidGiveawayClass. +const PrepaidGiveawayClassName = "PrepaidGiveaway" + +// PrepaidGiveawayClass represents PrepaidGiveaway generic type. +// +// See https://core.telegram.org/type/PrepaidGiveaway for reference. +// +// Example: +// +// g, err := tg.DecodePrepaidGiveaway(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.PrepaidGiveaway: // prepaidGiveaway#b2539d54 +// case *tg.PrepaidStarsGiveaway: // prepaidStarsGiveaway#9a9d77e0 +// default: panic(v) +// } +type PrepaidGiveawayClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() PrepaidGiveawayClass + + // 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 + + // Prepaid giveaway ID. + GetID() (value int64) + + // Number of given away Telegram Premium¹ subscriptions. + // + // Links: + // 1) https://core.telegram.org/api/premium + GetQuantity() (value int) + + // Payment date. + GetDate() (value int) +} + +// DecodePrepaidGiveaway implements binary de-serialization for PrepaidGiveawayClass. +func DecodePrepaidGiveaway(buf *bin.Buffer) (PrepaidGiveawayClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case PrepaidGiveawayTypeID: + // Decoding prepaidGiveaway#b2539d54. + v := PrepaidGiveaway{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode PrepaidGiveawayClass: %w", err) + } + return &v, nil + case PrepaidStarsGiveawayTypeID: + // Decoding prepaidStarsGiveaway#9a9d77e0. + v := PrepaidStarsGiveaway{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode PrepaidGiveawayClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode PrepaidGiveawayClass: %w", bin.NewUnexpectedID(id)) + } +} + +// PrepaidGiveaway boxes the PrepaidGiveawayClass providing a helper. +type PrepaidGiveawayBox struct { + PrepaidGiveaway PrepaidGiveawayClass +} + +// Decode implements bin.Decoder for PrepaidGiveawayBox. +func (b *PrepaidGiveawayBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode PrepaidGiveawayBox to nil") + } + v, err := DecodePrepaidGiveaway(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.PrepaidGiveaway = v + return nil +} + +// Encode implements bin.Encode for PrepaidGiveawayBox. +func (b *PrepaidGiveawayBox) Encode(buf *bin.Buffer) error { + if b == nil || b.PrepaidGiveaway == nil { + return fmt.Errorf("unable to encode PrepaidGiveawayClass as nil") + } + return b.PrepaidGiveaway.Encode(buf) +} diff --git a/tg/tl_prepaid_giveaway_slices_gen.go b/tg/tl_prepaid_giveaway_slices_gen.go index fe21471a4c..b9db13ecb6 100644 --- a/tg/tl_prepaid_giveaway_slices_gen.go +++ b/tg/tl_prepaid_giveaway_slices_gen.go @@ -33,3 +33,423 @@ var ( _ = tgerr.Error{} _ = tdjson.Encoder{} ) + +// PrepaidGiveawayClassArray is adapter for slice of PrepaidGiveawayClass. +type PrepaidGiveawayClassArray []PrepaidGiveawayClass + +// Sort sorts slice of PrepaidGiveawayClass. +func (s PrepaidGiveawayClassArray) Sort(less func(a, b PrepaidGiveawayClass) bool) PrepaidGiveawayClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PrepaidGiveawayClass. +func (s PrepaidGiveawayClassArray) SortStable(less func(a, b PrepaidGiveawayClass) bool) PrepaidGiveawayClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PrepaidGiveawayClass. +func (s PrepaidGiveawayClassArray) Retain(keep func(x PrepaidGiveawayClass) bool) PrepaidGiveawayClassArray { + 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 PrepaidGiveawayClassArray) First() (v PrepaidGiveawayClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PrepaidGiveawayClassArray) Last() (v PrepaidGiveawayClass, 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 *PrepaidGiveawayClassArray) PopFirst() (v PrepaidGiveawayClass, 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 PrepaidGiveawayClass + 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 *PrepaidGiveawayClassArray) Pop() (v PrepaidGiveawayClass, 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 +} + +// SortByID sorts slice of PrepaidGiveawayClass by ID. +func (s PrepaidGiveawayClassArray) SortByID() PrepaidGiveawayClassArray { + return s.Sort(func(a, b PrepaidGiveawayClass) bool { + return a.GetID() < b.GetID() + }) +} + +// SortStableByID sorts slice of PrepaidGiveawayClass by ID. +func (s PrepaidGiveawayClassArray) SortStableByID() PrepaidGiveawayClassArray { + return s.SortStable(func(a, b PrepaidGiveawayClass) bool { + return a.GetID() < b.GetID() + }) +} + +// SortByDate sorts slice of PrepaidGiveawayClass by Date. +func (s PrepaidGiveawayClassArray) SortByDate() PrepaidGiveawayClassArray { + return s.Sort(func(a, b PrepaidGiveawayClass) bool { + return a.GetDate() < b.GetDate() + }) +} + +// SortStableByDate sorts slice of PrepaidGiveawayClass by Date. +func (s PrepaidGiveawayClassArray) SortStableByDate() PrepaidGiveawayClassArray { + return s.SortStable(func(a, b PrepaidGiveawayClass) bool { + return a.GetDate() < b.GetDate() + }) +} + +// FillPrepaidGiveawayMap fills only PrepaidGiveaway constructors to given map. +func (s PrepaidGiveawayClassArray) FillPrepaidGiveawayMap(to map[int64]*PrepaidGiveaway) { + for _, elem := range s { + value, ok := elem.(*PrepaidGiveaway) + if !ok { + continue + } + to[value.GetID()] = value + } +} + +// PrepaidGiveawayToMap collects only PrepaidGiveaway constructors to map. +func (s PrepaidGiveawayClassArray) PrepaidGiveawayToMap() map[int64]*PrepaidGiveaway { + r := make(map[int64]*PrepaidGiveaway, len(s)) + s.FillPrepaidGiveawayMap(r) + return r +} + +// AsPrepaidGiveaway returns copy with only PrepaidGiveaway constructors. +func (s PrepaidGiveawayClassArray) AsPrepaidGiveaway() (to PrepaidGiveawayArray) { + for _, elem := range s { + value, ok := elem.(*PrepaidGiveaway) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// FillPrepaidStarsGiveawayMap fills only PrepaidStarsGiveaway constructors to given map. +func (s PrepaidGiveawayClassArray) FillPrepaidStarsGiveawayMap(to map[int64]*PrepaidStarsGiveaway) { + for _, elem := range s { + value, ok := elem.(*PrepaidStarsGiveaway) + if !ok { + continue + } + to[value.GetID()] = value + } +} + +// PrepaidStarsGiveawayToMap collects only PrepaidStarsGiveaway constructors to map. +func (s PrepaidGiveawayClassArray) PrepaidStarsGiveawayToMap() map[int64]*PrepaidStarsGiveaway { + r := make(map[int64]*PrepaidStarsGiveaway, len(s)) + s.FillPrepaidStarsGiveawayMap(r) + return r +} + +// AsPrepaidStarsGiveaway returns copy with only PrepaidStarsGiveaway constructors. +func (s PrepaidGiveawayClassArray) AsPrepaidStarsGiveaway() (to PrepaidStarsGiveawayArray) { + for _, elem := range s { + value, ok := elem.(*PrepaidStarsGiveaway) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// PrepaidGiveawayArray is adapter for slice of PrepaidGiveaway. +type PrepaidGiveawayArray []PrepaidGiveaway + +// Sort sorts slice of PrepaidGiveaway. +func (s PrepaidGiveawayArray) Sort(less func(a, b PrepaidGiveaway) bool) PrepaidGiveawayArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PrepaidGiveaway. +func (s PrepaidGiveawayArray) SortStable(less func(a, b PrepaidGiveaway) bool) PrepaidGiveawayArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PrepaidGiveaway. +func (s PrepaidGiveawayArray) Retain(keep func(x PrepaidGiveaway) bool) PrepaidGiveawayArray { + 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 PrepaidGiveawayArray) First() (v PrepaidGiveaway, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PrepaidGiveawayArray) Last() (v PrepaidGiveaway, 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 *PrepaidGiveawayArray) PopFirst() (v PrepaidGiveaway, 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 PrepaidGiveaway + 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 *PrepaidGiveawayArray) Pop() (v PrepaidGiveaway, 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 +} + +// SortByID sorts slice of PrepaidGiveaway by ID. +func (s PrepaidGiveawayArray) SortByID() PrepaidGiveawayArray { + return s.Sort(func(a, b PrepaidGiveaway) bool { + return a.GetID() < b.GetID() + }) +} + +// SortStableByID sorts slice of PrepaidGiveaway by ID. +func (s PrepaidGiveawayArray) SortStableByID() PrepaidGiveawayArray { + return s.SortStable(func(a, b PrepaidGiveaway) bool { + return a.GetID() < b.GetID() + }) +} + +// SortByDate sorts slice of PrepaidGiveaway by Date. +func (s PrepaidGiveawayArray) SortByDate() PrepaidGiveawayArray { + return s.Sort(func(a, b PrepaidGiveaway) bool { + return a.GetDate() < b.GetDate() + }) +} + +// SortStableByDate sorts slice of PrepaidGiveaway by Date. +func (s PrepaidGiveawayArray) SortStableByDate() PrepaidGiveawayArray { + return s.SortStable(func(a, b PrepaidGiveaway) bool { + return a.GetDate() < b.GetDate() + }) +} + +// FillMap fills constructors to given map. +func (s PrepaidGiveawayArray) FillMap(to map[int64]PrepaidGiveaway) { + for _, value := range s { + to[value.GetID()] = value + } +} + +// ToMap collects constructors to map. +func (s PrepaidGiveawayArray) ToMap() map[int64]PrepaidGiveaway { + r := make(map[int64]PrepaidGiveaway, len(s)) + s.FillMap(r) + return r +} + +// PrepaidStarsGiveawayArray is adapter for slice of PrepaidStarsGiveaway. +type PrepaidStarsGiveawayArray []PrepaidStarsGiveaway + +// Sort sorts slice of PrepaidStarsGiveaway. +func (s PrepaidStarsGiveawayArray) Sort(less func(a, b PrepaidStarsGiveaway) bool) PrepaidStarsGiveawayArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PrepaidStarsGiveaway. +func (s PrepaidStarsGiveawayArray) SortStable(less func(a, b PrepaidStarsGiveaway) bool) PrepaidStarsGiveawayArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PrepaidStarsGiveaway. +func (s PrepaidStarsGiveawayArray) Retain(keep func(x PrepaidStarsGiveaway) bool) PrepaidStarsGiveawayArray { + 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 PrepaidStarsGiveawayArray) First() (v PrepaidStarsGiveaway, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PrepaidStarsGiveawayArray) Last() (v PrepaidStarsGiveaway, 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 *PrepaidStarsGiveawayArray) PopFirst() (v PrepaidStarsGiveaway, 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 PrepaidStarsGiveaway + 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 *PrepaidStarsGiveawayArray) Pop() (v PrepaidStarsGiveaway, 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 +} + +// SortByID sorts slice of PrepaidStarsGiveaway by ID. +func (s PrepaidStarsGiveawayArray) SortByID() PrepaidStarsGiveawayArray { + return s.Sort(func(a, b PrepaidStarsGiveaway) bool { + return a.GetID() < b.GetID() + }) +} + +// SortStableByID sorts slice of PrepaidStarsGiveaway by ID. +func (s PrepaidStarsGiveawayArray) SortStableByID() PrepaidStarsGiveawayArray { + return s.SortStable(func(a, b PrepaidStarsGiveaway) bool { + return a.GetID() < b.GetID() + }) +} + +// SortByDate sorts slice of PrepaidStarsGiveaway by Date. +func (s PrepaidStarsGiveawayArray) SortByDate() PrepaidStarsGiveawayArray { + return s.Sort(func(a, b PrepaidStarsGiveaway) bool { + return a.GetDate() < b.GetDate() + }) +} + +// SortStableByDate sorts slice of PrepaidStarsGiveaway by Date. +func (s PrepaidStarsGiveawayArray) SortStableByDate() PrepaidStarsGiveawayArray { + return s.SortStable(func(a, b PrepaidStarsGiveaway) bool { + return a.GetDate() < b.GetDate() + }) +} + +// FillMap fills constructors to given map. +func (s PrepaidStarsGiveawayArray) FillMap(to map[int64]PrepaidStarsGiveaway) { + for _, value := range s { + to[value.GetID()] = value + } +} + +// ToMap collects constructors to map. +func (s PrepaidStarsGiveawayArray) ToMap() map[int64]PrepaidStarsGiveaway { + r := make(map[int64]PrepaidStarsGiveaway, len(s)) + s.FillMap(r) + return r +} diff --git a/tg/tl_registry_gen.go b/tg/tl_registry_gen.go index ced3d22608..0686b6dfe5 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 186 +const Layer = 187 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -74,7 +74,7 @@ func TypesMap() map[uint32]string { InputMediaDiceTypeID: "inputMediaDice#e66fbf7b", InputMediaStoryTypeID: "inputMediaStory#89fdd778", InputMediaWebPageTypeID: "inputMediaWebPage#c21b8849", - InputMediaPaidMediaTypeID: "inputMediaPaidMedia#aa661fc3", + InputMediaPaidMediaTypeID: "inputMediaPaidMedia#c4103386", InputChatPhotoEmptyTypeID: "inputChatPhotoEmpty#1ca48f57", InputChatUploadedPhotoTypeID: "inputChatUploadedPhoto#bdcdaec0", InputChatPhotoTypeID: "inputChatPhoto#8953ad37", @@ -146,8 +146,8 @@ func TypesMap() map[uint32]string { MessageMediaPollTypeID: "messageMediaPoll#4bd6e798", MessageMediaDiceTypeID: "messageMediaDice#3f7ee58b", MessageMediaStoryTypeID: "messageMediaStory#68cb6283", - MessageMediaGiveawayTypeID: "messageMediaGiveaway#daad85b0", - MessageMediaGiveawayResultsTypeID: "messageMediaGiveawayResults#c6991068", + MessageMediaGiveawayTypeID: "messageMediaGiveaway#aa073beb", + MessageMediaGiveawayResultsTypeID: "messageMediaGiveawayResults#ceaa3ea1", MessageMediaPaidMediaTypeID: "messageMediaPaidMedia#a8852491", MessageActionEmptyTypeID: "messageActionEmpty#b6aef7b0", MessageActionChatCreateTypeID: "messageActionChatCreate#bd47cbad", @@ -188,12 +188,13 @@ func TypesMap() map[uint32]string { MessageActionRequestedPeerTypeID: "messageActionRequestedPeer#31518e9b", MessageActionSetChatWallPaperTypeID: "messageActionSetChatWallPaper#5060a3f4", MessageActionGiftCodeTypeID: "messageActionGiftCode#678c2e09", - MessageActionGiveawayLaunchTypeID: "messageActionGiveawayLaunch#332ba9ed", - MessageActionGiveawayResultsTypeID: "messageActionGiveawayResults#2a9fadc5", + MessageActionGiveawayLaunchTypeID: "messageActionGiveawayLaunch#a80f51e4", + MessageActionGiveawayResultsTypeID: "messageActionGiveawayResults#87e2f155", MessageActionBoostApplyTypeID: "messageActionBoostApply#cc02aa6d", MessageActionRequestedPeerSentMeTypeID: "messageActionRequestedPeerSentMe#93b31848", MessageActionPaymentRefundedTypeID: "messageActionPaymentRefunded#41b3e202", MessageActionGiftStarsTypeID: "messageActionGiftStars#45d5b021", + MessageActionPrizeStarsTypeID: "messageActionPrizeStars#b00c47a2", DialogTypeID: "dialog#d58a08c6", DialogFolderTypeID: "dialogFolder#71bd134c", PhotoEmptyTypeID: "photoEmpty#2331b22d", @@ -407,6 +408,8 @@ func TypesMap() map[uint32]string { UpdateStarsBalanceTypeID: "updateStarsBalance#fb85198", UpdateBusinessBotCallbackQueryTypeID: "updateBusinessBotCallbackQuery#1ea2fda7", UpdateStarsRevenueStatusTypeID: "updateStarsRevenueStatus#a584b019", + UpdateBotPurchasedPaidMediaTypeID: "updateBotPurchasedPaidMedia#283bd312", + UpdatePaidReactionPrivacyTypeID: "updatePaidReactionPrivacy#51ca7aec", UpdatesStateTypeID: "updates.state#a56c2a3e", UpdatesDifferenceEmptyTypeID: "updates.differenceEmpty#5d75a138", UpdatesDifferenceTypeID: "updates.difference#f49ca0", @@ -868,6 +871,7 @@ func TypesMap() map[uint32]string { ChannelAdminLogEventActionChangeEmojiStatusTypeID: "channelAdminLogEventActionChangeEmojiStatus#3ea9feb1", ChannelAdminLogEventActionChangeEmojiStickerSetTypeID: "channelAdminLogEventActionChangeEmojiStickerSet#46d840ab", ChannelAdminLogEventActionToggleSignatureProfilesTypeID: "channelAdminLogEventActionToggleSignatureProfiles#60a79c79", + ChannelAdminLogEventActionParticipantSubExtendTypeID: "channelAdminLogEventActionParticipantSubExtend#64642db3", ChannelAdminLogEventTypeID: "channelAdminLogEvent#1fad68cd", ChannelsAdminLogResultsTypeID: "channels.adminLogResults#ed8af74d", ChannelAdminLogEventsFilterTypeID: "channelAdminLogEventsFilter#ea107ae4", @@ -1155,6 +1159,7 @@ func TypesMap() map[uint32]string { InputStorePaymentPremiumGiveawayTypeID: "inputStorePaymentPremiumGiveaway#160544ca", InputStorePaymentStarsTopupTypeID: "inputStorePaymentStarsTopup#dddd0f56", InputStorePaymentStarsGiftTypeID: "inputStorePaymentStarsGift#1d741ef7", + InputStorePaymentStarsGiveawayTypeID: "inputStorePaymentStarsGiveaway#751f08fa", PremiumGiftOptionTypeID: "premiumGiftOption#74c34319", PaymentFormMethodTypeID: "paymentFormMethod#88f8f21b", EmojiStatusEmptyTypeID: "emojiStatusEmpty#2de11aae", @@ -1256,9 +1261,10 @@ func TypesMap() map[uint32]string { PremiumGiftCodeOptionTypeID: "premiumGiftCodeOption#257e962b", PaymentsCheckedGiftCodeTypeID: "payments.checkedGiftCode#284a1096", PaymentsGiveawayInfoTypeID: "payments.giveawayInfo#4367daa0", - PaymentsGiveawayInfoResultsTypeID: "payments.giveawayInfoResults#cd5570", + PaymentsGiveawayInfoResultsTypeID: "payments.giveawayInfoResults#e175e66f", PrepaidGiveawayTypeID: "prepaidGiveaway#b2539d54", - BoostTypeID: "boost#2a1c8c71", + PrepaidStarsGiveawayTypeID: "prepaidStarsGiveaway#9a9d77e0", + BoostTypeID: "boost#4b3e14d6", PremiumBoostsListTypeID: "premium.boostsList#86f8613c", MyBoostTypeID: "myBoost#c448415c", PremiumMyBoostsTypeID: "premium.myBoosts#9ae228e2", @@ -1348,7 +1354,7 @@ func TypesMap() map[uint32]string { ReactionNotificationsFromContactsTypeID: "reactionNotificationsFromContacts#bac3a61a", ReactionNotificationsFromAllTypeID: "reactionNotificationsFromAll#4b9e22a0", ReactionsNotifySettingsTypeID: "reactionsNotifySettings#56e34970", - BroadcastRevenueBalancesTypeID: "broadcastRevenueBalances#8438f1c6", + BroadcastRevenueBalancesTypeID: "broadcastRevenueBalances#c3ff71e7", AvailableEffectTypeID: "availableEffect#93c3e27e", MessagesAvailableEffectsNotModifiedTypeID: "messages.availableEffectsNotModified#d1ed9a5b", MessagesAvailableEffectsTypeID: "messages.availableEffects#bddb616e", @@ -1361,7 +1367,7 @@ func TypesMap() map[uint32]string { StarsTransactionPeerTypeID: "starsTransactionPeer#d80da15d", StarsTransactionPeerAdsTypeID: "starsTransactionPeerAds#60682812", StarsTopupOptionTypeID: "starsTopupOption#bd915c0", - StarsTransactionTypeID: "starsTransaction#433aeb2b", + StarsTransactionTypeID: "starsTransaction#ee7522d5", PaymentsStarsStatusTypeID: "payments.starsStatus#bbfa316c", FoundStoryTypeID: "foundStory#e87acbc0", StoriesFoundStoriesTypeID: "stories.foundStories#e2de7737", @@ -1378,6 +1384,8 @@ func TypesMap() map[uint32]string { StarsSubscriptionPricingTypeID: "starsSubscriptionPricing#5416d58", StarsSubscriptionTypeID: "starsSubscription#538ecf18", MessageReactorTypeID: "messageReactor#4ba3a95a", + StarsGiveawayOptionTypeID: "starsGiveawayOption#94ce852a", + StarsGiveawayWinnersOptionTypeID: "starsGiveawayWinnersOption#54236209", InvokeAfterMsgRequestTypeID: "invokeAfterMsg#cb9f372d", InvokeAfterMsgsRequestTypeID: "invokeAfterMsgs#3dc4b4f0", InitConnectionRequestTypeID: "initConnection#c1cd5ea9", @@ -1767,8 +1775,9 @@ func TypesMap() map[uint32]string { MessagesDeleteFactCheckRequestTypeID: "messages.deleteFactCheck#d1da940c", MessagesGetFactCheckRequestTypeID: "messages.getFactCheck#b9cdc5ee", MessagesRequestMainWebViewRequestTypeID: "messages.requestMainWebView#c9e01e7b", - MessagesSendPaidReactionRequestTypeID: "messages.sendPaidReaction#25c8fe3e", + MessagesSendPaidReactionRequestTypeID: "messages.sendPaidReaction#9dd6a67b", MessagesTogglePaidReactionPrivacyRequestTypeID: "messages.togglePaidReactionPrivacy#849ad397", + MessagesGetPaidReactionPrivacyRequestTypeID: "messages.getPaidReactionPrivacy#472455aa", UpdatesGetStateRequestTypeID: "updates.getState#edd4882a", UpdatesGetDifferenceRequestTypeID: "updates.getDifference#19c2f763", UpdatesGetChannelDifferenceRequestTypeID: "updates.getChannelDifference#3173d78", @@ -1927,6 +1936,7 @@ func TypesMap() map[uint32]string { PaymentsGetStarsSubscriptionsRequestTypeID: "payments.getStarsSubscriptions#32512c5", PaymentsChangeStarsSubscriptionRequestTypeID: "payments.changeStarsSubscription#c7770878", PaymentsFulfillStarsSubscriptionRequestTypeID: "payments.fulfillStarsSubscription#cc5bebb3", + PaymentsGetStarsGiveawayOptionsRequestTypeID: "payments.getStarsGiveawayOptions#bd1efd3e", StickersCreateStickerSetRequestTypeID: "stickers.createStickerSet#9021ab67", StickersRemoveStickerFromSetRequestTypeID: "stickers.removeStickerFromSet#f7760f51", StickersChangeStickerPositionRequestTypeID: "stickers.changeStickerPosition#ffb6d4ca", @@ -2211,6 +2221,7 @@ func NamesMap() map[string]uint32 { "messageActionRequestedPeerSentMe": MessageActionRequestedPeerSentMeTypeID, "messageActionPaymentRefunded": MessageActionPaymentRefundedTypeID, "messageActionGiftStars": MessageActionGiftStarsTypeID, + "messageActionPrizeStars": MessageActionPrizeStarsTypeID, "dialog": DialogTypeID, "dialogFolder": DialogFolderTypeID, "photoEmpty": PhotoEmptyTypeID, @@ -2424,6 +2435,8 @@ func NamesMap() map[string]uint32 { "updateStarsBalance": UpdateStarsBalanceTypeID, "updateBusinessBotCallbackQuery": UpdateBusinessBotCallbackQueryTypeID, "updateStarsRevenueStatus": UpdateStarsRevenueStatusTypeID, + "updateBotPurchasedPaidMedia": UpdateBotPurchasedPaidMediaTypeID, + "updatePaidReactionPrivacy": UpdatePaidReactionPrivacyTypeID, "updates.state": UpdatesStateTypeID, "updates.differenceEmpty": UpdatesDifferenceEmptyTypeID, "updates.difference": UpdatesDifferenceTypeID, @@ -2885,6 +2898,7 @@ func NamesMap() map[string]uint32 { "channelAdminLogEventActionChangeEmojiStatus": ChannelAdminLogEventActionChangeEmojiStatusTypeID, "channelAdminLogEventActionChangeEmojiStickerSet": ChannelAdminLogEventActionChangeEmojiStickerSetTypeID, "channelAdminLogEventActionToggleSignatureProfiles": ChannelAdminLogEventActionToggleSignatureProfilesTypeID, + "channelAdminLogEventActionParticipantSubExtend": ChannelAdminLogEventActionParticipantSubExtendTypeID, "channelAdminLogEvent": ChannelAdminLogEventTypeID, "channels.adminLogResults": ChannelsAdminLogResultsTypeID, "channelAdminLogEventsFilter": ChannelAdminLogEventsFilterTypeID, @@ -3172,6 +3186,7 @@ func NamesMap() map[string]uint32 { "inputStorePaymentPremiumGiveaway": InputStorePaymentPremiumGiveawayTypeID, "inputStorePaymentStarsTopup": InputStorePaymentStarsTopupTypeID, "inputStorePaymentStarsGift": InputStorePaymentStarsGiftTypeID, + "inputStorePaymentStarsGiveaway": InputStorePaymentStarsGiveawayTypeID, "premiumGiftOption": PremiumGiftOptionTypeID, "paymentFormMethod": PaymentFormMethodTypeID, "emojiStatusEmpty": EmojiStatusEmptyTypeID, @@ -3275,6 +3290,7 @@ func NamesMap() map[string]uint32 { "payments.giveawayInfo": PaymentsGiveawayInfoTypeID, "payments.giveawayInfoResults": PaymentsGiveawayInfoResultsTypeID, "prepaidGiveaway": PrepaidGiveawayTypeID, + "prepaidStarsGiveaway": PrepaidStarsGiveawayTypeID, "boost": BoostTypeID, "premium.boostsList": PremiumBoostsListTypeID, "myBoost": MyBoostTypeID, @@ -3395,6 +3411,8 @@ func NamesMap() map[string]uint32 { "starsSubscriptionPricing": StarsSubscriptionPricingTypeID, "starsSubscription": StarsSubscriptionTypeID, "messageReactor": MessageReactorTypeID, + "starsGiveawayOption": StarsGiveawayOptionTypeID, + "starsGiveawayWinnersOption": StarsGiveawayWinnersOptionTypeID, "invokeAfterMsg": InvokeAfterMsgRequestTypeID, "invokeAfterMsgs": InvokeAfterMsgsRequestTypeID, "initConnection": InitConnectionRequestTypeID, @@ -3786,6 +3804,7 @@ func NamesMap() map[string]uint32 { "messages.requestMainWebView": MessagesRequestMainWebViewRequestTypeID, "messages.sendPaidReaction": MessagesSendPaidReactionRequestTypeID, "messages.togglePaidReactionPrivacy": MessagesTogglePaidReactionPrivacyRequestTypeID, + "messages.getPaidReactionPrivacy": MessagesGetPaidReactionPrivacyRequestTypeID, "updates.getState": UpdatesGetStateRequestTypeID, "updates.getDifference": UpdatesGetDifferenceRequestTypeID, "updates.getChannelDifference": UpdatesGetChannelDifferenceRequestTypeID, @@ -3944,6 +3963,7 @@ func NamesMap() map[string]uint32 { "payments.getStarsSubscriptions": PaymentsGetStarsSubscriptionsRequestTypeID, "payments.changeStarsSubscription": PaymentsChangeStarsSubscriptionRequestTypeID, "payments.fulfillStarsSubscription": PaymentsFulfillStarsSubscriptionRequestTypeID, + "payments.getStarsGiveawayOptions": PaymentsGetStarsGiveawayOptionsRequestTypeID, "stickers.createStickerSet": StickersCreateStickerSetRequestTypeID, "stickers.removeStickerFromSet": StickersRemoveStickerFromSetRequestTypeID, "stickers.changeStickerPosition": StickersChangeStickerPositionRequestTypeID, @@ -4228,6 +4248,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessageActionRequestedPeerSentMeTypeID: func() bin.Object { return &MessageActionRequestedPeerSentMe{} }, MessageActionPaymentRefundedTypeID: func() bin.Object { return &MessageActionPaymentRefunded{} }, MessageActionGiftStarsTypeID: func() bin.Object { return &MessageActionGiftStars{} }, + MessageActionPrizeStarsTypeID: func() bin.Object { return &MessageActionPrizeStars{} }, DialogTypeID: func() bin.Object { return &Dialog{} }, DialogFolderTypeID: func() bin.Object { return &DialogFolder{} }, PhotoEmptyTypeID: func() bin.Object { return &PhotoEmpty{} }, @@ -4441,6 +4462,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UpdateStarsBalanceTypeID: func() bin.Object { return &UpdateStarsBalance{} }, UpdateBusinessBotCallbackQueryTypeID: func() bin.Object { return &UpdateBusinessBotCallbackQuery{} }, UpdateStarsRevenueStatusTypeID: func() bin.Object { return &UpdateStarsRevenueStatus{} }, + UpdateBotPurchasedPaidMediaTypeID: func() bin.Object { return &UpdateBotPurchasedPaidMedia{} }, + UpdatePaidReactionPrivacyTypeID: func() bin.Object { return &UpdatePaidReactionPrivacy{} }, UpdatesStateTypeID: func() bin.Object { return &UpdatesState{} }, UpdatesDifferenceEmptyTypeID: func() bin.Object { return &UpdatesDifferenceEmpty{} }, UpdatesDifferenceTypeID: func() bin.Object { return &UpdatesDifference{} }, @@ -4902,6 +4925,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { ChannelAdminLogEventActionChangeEmojiStatusTypeID: func() bin.Object { return &ChannelAdminLogEventActionChangeEmojiStatus{} }, ChannelAdminLogEventActionChangeEmojiStickerSetTypeID: func() bin.Object { return &ChannelAdminLogEventActionChangeEmojiStickerSet{} }, ChannelAdminLogEventActionToggleSignatureProfilesTypeID: func() bin.Object { return &ChannelAdminLogEventActionToggleSignatureProfiles{} }, + ChannelAdminLogEventActionParticipantSubExtendTypeID: func() bin.Object { return &ChannelAdminLogEventActionParticipantSubExtend{} }, ChannelAdminLogEventTypeID: func() bin.Object { return &ChannelAdminLogEvent{} }, ChannelsAdminLogResultsTypeID: func() bin.Object { return &ChannelsAdminLogResults{} }, ChannelAdminLogEventsFilterTypeID: func() bin.Object { return &ChannelAdminLogEventsFilter{} }, @@ -5189,6 +5213,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputStorePaymentPremiumGiveawayTypeID: func() bin.Object { return &InputStorePaymentPremiumGiveaway{} }, InputStorePaymentStarsTopupTypeID: func() bin.Object { return &InputStorePaymentStarsTopup{} }, InputStorePaymentStarsGiftTypeID: func() bin.Object { return &InputStorePaymentStarsGift{} }, + InputStorePaymentStarsGiveawayTypeID: func() bin.Object { return &InputStorePaymentStarsGiveaway{} }, PremiumGiftOptionTypeID: func() bin.Object { return &PremiumGiftOption{} }, PaymentFormMethodTypeID: func() bin.Object { return &PaymentFormMethod{} }, EmojiStatusEmptyTypeID: func() bin.Object { return &EmojiStatusEmpty{} }, @@ -5292,6 +5317,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { PaymentsGiveawayInfoTypeID: func() bin.Object { return &PaymentsGiveawayInfo{} }, PaymentsGiveawayInfoResultsTypeID: func() bin.Object { return &PaymentsGiveawayInfoResults{} }, PrepaidGiveawayTypeID: func() bin.Object { return &PrepaidGiveaway{} }, + PrepaidStarsGiveawayTypeID: func() bin.Object { return &PrepaidStarsGiveaway{} }, BoostTypeID: func() bin.Object { return &Boost{} }, PremiumBoostsListTypeID: func() bin.Object { return &PremiumBoostsList{} }, MyBoostTypeID: func() bin.Object { return &MyBoost{} }, @@ -5412,6 +5438,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { StarsSubscriptionPricingTypeID: func() bin.Object { return &StarsSubscriptionPricing{} }, StarsSubscriptionTypeID: func() bin.Object { return &StarsSubscription{} }, MessageReactorTypeID: func() bin.Object { return &MessageReactor{} }, + StarsGiveawayOptionTypeID: func() bin.Object { return &StarsGiveawayOption{} }, + StarsGiveawayWinnersOptionTypeID: func() bin.Object { return &StarsGiveawayWinnersOption{} }, InvokeAfterMsgRequestTypeID: func() bin.Object { return &InvokeAfterMsgRequest{} }, InvokeAfterMsgsRequestTypeID: func() bin.Object { return &InvokeAfterMsgsRequest{} }, InitConnectionRequestTypeID: func() bin.Object { return &InitConnectionRequest{} }, @@ -5803,6 +5831,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessagesRequestMainWebViewRequestTypeID: func() bin.Object { return &MessagesRequestMainWebViewRequest{} }, MessagesSendPaidReactionRequestTypeID: func() bin.Object { return &MessagesSendPaidReactionRequest{} }, MessagesTogglePaidReactionPrivacyRequestTypeID: func() bin.Object { return &MessagesTogglePaidReactionPrivacyRequest{} }, + MessagesGetPaidReactionPrivacyRequestTypeID: func() bin.Object { return &MessagesGetPaidReactionPrivacyRequest{} }, UpdatesGetStateRequestTypeID: func() bin.Object { return &UpdatesGetStateRequest{} }, UpdatesGetDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetDifferenceRequest{} }, UpdatesGetChannelDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetChannelDifferenceRequest{} }, @@ -5961,6 +5990,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { PaymentsGetStarsSubscriptionsRequestTypeID: func() bin.Object { return &PaymentsGetStarsSubscriptionsRequest{} }, PaymentsChangeStarsSubscriptionRequestTypeID: func() bin.Object { return &PaymentsChangeStarsSubscriptionRequest{} }, PaymentsFulfillStarsSubscriptionRequestTypeID: func() bin.Object { return &PaymentsFulfillStarsSubscriptionRequest{} }, + PaymentsGetStarsGiveawayOptionsRequestTypeID: func() bin.Object { return &PaymentsGetStarsGiveawayOptionsRequest{} }, StickersCreateStickerSetRequestTypeID: func() bin.Object { return &StickersCreateStickerSetRequest{} }, StickersRemoveStickerFromSetRequestTypeID: func() bin.Object { return &StickersRemoveStickerFromSetRequest{} }, StickersChangeStickerPositionRequestTypeID: func() bin.Object { return &StickersChangeStickerPositionRequest{} }, @@ -6263,6 +6293,7 @@ func ClassConstructorsMap() map[string][]uint32 { ChannelAdminLogEventActionChangeEmojiStatusTypeID, ChannelAdminLogEventActionChangeEmojiStickerSetTypeID, ChannelAdminLogEventActionToggleSignatureProfilesTypeID, + ChannelAdminLogEventActionParticipantSubExtendTypeID, }, ChannelLocationClassName: { ChannelLocationEmptyTypeID, @@ -6699,6 +6730,7 @@ func ClassConstructorsMap() map[string][]uint32 { InputStorePaymentPremiumGiveawayTypeID, InputStorePaymentStarsTopupTypeID, InputStorePaymentStarsGiftTypeID, + InputStorePaymentStarsGiveawayTypeID, }, InputThemeClassName: { InputThemeTypeID, @@ -6808,6 +6840,7 @@ func ClassConstructorsMap() map[string][]uint32 { MessageActionRequestedPeerSentMeTypeID, MessageActionPaymentRefundedTypeID, MessageActionGiftStarsTypeID, + MessageActionPrizeStarsTypeID, }, MessageClassName: { MessageEmptyTypeID, @@ -7103,6 +7136,10 @@ func ClassConstructorsMap() map[string][]uint32 { PostInteractionCountersMessageTypeID, PostInteractionCountersStoryTypeID, }, + PrepaidGiveawayClassName: { + PrepaidGiveawayTypeID, + PrepaidStarsGiveawayTypeID, + }, PrivacyKeyClassName: { PrivacyKeyStatusTimestampTypeID, PrivacyKeyChatInviteTypeID, @@ -7465,6 +7502,8 @@ func ClassConstructorsMap() map[string][]uint32 { UpdateStarsBalanceTypeID, UpdateBusinessBotCallbackQueryTypeID, UpdateStarsRevenueStatusTypeID, + UpdateBotPurchasedPaidMediaTypeID, + UpdatePaidReactionPrivacyTypeID, }, UpdatesChannelDifferenceClassName: { UpdatesChannelDifferenceEmptyTypeID, diff --git a/tg/tl_server_gen.go b/tg/tl_server_gen.go index 9a0da404cb..7c35e3ea47 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -7030,6 +7030,23 @@ func (s *ServerDispatcher) OnMessagesTogglePaidReactionPrivacy(f func(ctx contex s.handlers[MessagesTogglePaidReactionPrivacyRequestTypeID] = handler } +func (s *ServerDispatcher) OnMessagesGetPaidReactionPrivacy(f func(ctx context.Context) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesGetPaidReactionPrivacyRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx) + if err != nil { + return nil, err + } + return &UpdatesBox{Updates: response}, nil + } + + s.handlers[MessagesGetPaidReactionPrivacyRequestTypeID] = handler +} + func (s *ServerDispatcher) OnUpdatesGetState(f func(ctx context.Context) (*UpdatesState, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request UpdatesGetStateRequest @@ -9868,6 +9885,23 @@ func (s *ServerDispatcher) OnPaymentsFulfillStarsSubscription(f func(ctx context s.handlers[PaymentsFulfillStarsSubscriptionRequestTypeID] = handler } +func (s *ServerDispatcher) OnPaymentsGetStarsGiveawayOptions(f func(ctx context.Context) ([]StarsGiveawayOption, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsGetStarsGiveawayOptionsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx) + if err != nil { + return nil, err + } + return &StarsGiveawayOptionVector{Elems: response}, nil + } + + s.handlers[PaymentsGetStarsGiveawayOptionsRequestTypeID] = handler +} + func (s *ServerDispatcher) OnStickersCreateStickerSet(f func(ctx context.Context, request *StickersCreateStickerSetRequest) (MessagesStickerSetClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request StickersCreateStickerSetRequest diff --git a/tg/tl_stars_giveaway_option_gen.go b/tg/tl_stars_giveaway_option_gen.go new file mode 100644 index 0000000000..dc95d8f64a --- /dev/null +++ b/tg/tl_stars_giveaway_option_gen.go @@ -0,0 +1,420 @@ +// 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{} +) + +// StarsGiveawayOption represents TL type `starsGiveawayOption#94ce852a`. +// +// See https://core.telegram.org/constructor/starsGiveawayOption for reference. +type StarsGiveawayOption struct { + // Flags field of StarsGiveawayOption. + Flags bin.Fields + // Extended field of StarsGiveawayOption. + Extended bool + // Default field of StarsGiveawayOption. + Default bool + // Stars field of StarsGiveawayOption. + Stars int64 + // YearlyBoosts field of StarsGiveawayOption. + YearlyBoosts int + // StoreProduct field of StarsGiveawayOption. + // + // Use SetStoreProduct and GetStoreProduct helpers. + StoreProduct string + // Currency field of StarsGiveawayOption. + Currency string + // Amount field of StarsGiveawayOption. + Amount int64 + // Winners field of StarsGiveawayOption. + Winners []StarsGiveawayWinnersOption +} + +// StarsGiveawayOptionTypeID is TL type id of StarsGiveawayOption. +const StarsGiveawayOptionTypeID = 0x94ce852a + +// Ensuring interfaces in compile-time for StarsGiveawayOption. +var ( + _ bin.Encoder = &StarsGiveawayOption{} + _ bin.Decoder = &StarsGiveawayOption{} + _ bin.BareEncoder = &StarsGiveawayOption{} + _ bin.BareDecoder = &StarsGiveawayOption{} +) + +func (s *StarsGiveawayOption) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.Extended == false) { + return false + } + if !(s.Default == false) { + return false + } + if !(s.Stars == 0) { + return false + } + if !(s.YearlyBoosts == 0) { + return false + } + if !(s.StoreProduct == "") { + return false + } + if !(s.Currency == "") { + return false + } + if !(s.Amount == 0) { + return false + } + if !(s.Winners == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarsGiveawayOption) String() string { + if s == nil { + return "StarsGiveawayOption(nil)" + } + type Alias StarsGiveawayOption + return fmt.Sprintf("StarsGiveawayOption%+v", Alias(*s)) +} + +// FillFrom fills StarsGiveawayOption from given interface. +func (s *StarsGiveawayOption) FillFrom(from interface { + GetExtended() (value bool) + GetDefault() (value bool) + GetStars() (value int64) + GetYearlyBoosts() (value int) + GetStoreProduct() (value string, ok bool) + GetCurrency() (value string) + GetAmount() (value int64) + GetWinners() (value []StarsGiveawayWinnersOption) +}) { + s.Extended = from.GetExtended() + s.Default = from.GetDefault() + s.Stars = from.GetStars() + s.YearlyBoosts = from.GetYearlyBoosts() + if val, ok := from.GetStoreProduct(); ok { + s.StoreProduct = val + } + + s.Currency = from.GetCurrency() + s.Amount = from.GetAmount() + s.Winners = from.GetWinners() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsGiveawayOption) TypeID() uint32 { + return StarsGiveawayOptionTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsGiveawayOption) TypeName() string { + return "starsGiveawayOption" +} + +// TypeInfo returns info about TL type. +func (s *StarsGiveawayOption) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starsGiveawayOption", + ID: StarsGiveawayOptionTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Extended", + SchemaName: "extended", + Null: !s.Flags.Has(0), + }, + { + Name: "Default", + SchemaName: "default", + Null: !s.Flags.Has(1), + }, + { + Name: "Stars", + SchemaName: "stars", + }, + { + Name: "YearlyBoosts", + SchemaName: "yearly_boosts", + }, + { + Name: "StoreProduct", + SchemaName: "store_product", + Null: !s.Flags.Has(2), + }, + { + Name: "Currency", + SchemaName: "currency", + }, + { + Name: "Amount", + SchemaName: "amount", + }, + { + Name: "Winners", + SchemaName: "winners", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *StarsGiveawayOption) SetFlags() { + if !(s.Extended == false) { + s.Flags.Set(0) + } + if !(s.Default == false) { + s.Flags.Set(1) + } + if !(s.StoreProduct == "") { + s.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (s *StarsGiveawayOption) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsGiveawayOption#94ce852a as nil") + } + b.PutID(StarsGiveawayOptionTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarsGiveawayOption) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsGiveawayOption#94ce852a as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsGiveawayOption#94ce852a: field flags: %w", err) + } + b.PutLong(s.Stars) + b.PutInt(s.YearlyBoosts) + if s.Flags.Has(2) { + b.PutString(s.StoreProduct) + } + b.PutString(s.Currency) + b.PutLong(s.Amount) + b.PutVectorHeader(len(s.Winners)) + for idx, v := range s.Winners { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsGiveawayOption#94ce852a: field winners element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarsGiveawayOption) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsGiveawayOption#94ce852a to nil") + } + if err := b.ConsumeID(StarsGiveawayOptionTypeID); err != nil { + return fmt.Errorf("unable to decode starsGiveawayOption#94ce852a: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarsGiveawayOption) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsGiveawayOption#94ce852a to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode starsGiveawayOption#94ce852a: field flags: %w", err) + } + } + s.Extended = s.Flags.Has(0) + s.Default = s.Flags.Has(1) + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode starsGiveawayOption#94ce852a: field stars: %w", err) + } + s.Stars = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starsGiveawayOption#94ce852a: field yearly_boosts: %w", err) + } + s.YearlyBoosts = value + } + if s.Flags.Has(2) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode starsGiveawayOption#94ce852a: field store_product: %w", err) + } + s.StoreProduct = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode starsGiveawayOption#94ce852a: field currency: %w", err) + } + s.Currency = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode starsGiveawayOption#94ce852a: field amount: %w", err) + } + s.Amount = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode starsGiveawayOption#94ce852a: field winners: %w", err) + } + + if headerLen > 0 { + s.Winners = make([]StarsGiveawayWinnersOption, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value StarsGiveawayWinnersOption + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode starsGiveawayOption#94ce852a: field winners: %w", err) + } + s.Winners = append(s.Winners, value) + } + } + return nil +} + +// SetExtended sets value of Extended conditional field. +func (s *StarsGiveawayOption) SetExtended(value bool) { + if value { + s.Flags.Set(0) + s.Extended = true + } else { + s.Flags.Unset(0) + s.Extended = false + } +} + +// GetExtended returns value of Extended conditional field. +func (s *StarsGiveawayOption) GetExtended() (value bool) { + if s == nil { + return + } + return s.Flags.Has(0) +} + +// SetDefault sets value of Default conditional field. +func (s *StarsGiveawayOption) SetDefault(value bool) { + if value { + s.Flags.Set(1) + s.Default = true + } else { + s.Flags.Unset(1) + s.Default = false + } +} + +// GetDefault returns value of Default conditional field. +func (s *StarsGiveawayOption) GetDefault() (value bool) { + if s == nil { + return + } + return s.Flags.Has(1) +} + +// GetStars returns value of Stars field. +func (s *StarsGiveawayOption) GetStars() (value int64) { + if s == nil { + return + } + return s.Stars +} + +// GetYearlyBoosts returns value of YearlyBoosts field. +func (s *StarsGiveawayOption) GetYearlyBoosts() (value int) { + if s == nil { + return + } + return s.YearlyBoosts +} + +// SetStoreProduct sets value of StoreProduct conditional field. +func (s *StarsGiveawayOption) SetStoreProduct(value string) { + s.Flags.Set(2) + s.StoreProduct = value +} + +// GetStoreProduct returns value of StoreProduct conditional field and +// boolean which is true if field was set. +func (s *StarsGiveawayOption) GetStoreProduct() (value string, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(2) { + return value, false + } + return s.StoreProduct, true +} + +// GetCurrency returns value of Currency field. +func (s *StarsGiveawayOption) GetCurrency() (value string) { + if s == nil { + return + } + return s.Currency +} + +// GetAmount returns value of Amount field. +func (s *StarsGiveawayOption) GetAmount() (value int64) { + if s == nil { + return + } + return s.Amount +} + +// GetWinners returns value of Winners field. +func (s *StarsGiveawayOption) GetWinners() (value []StarsGiveawayWinnersOption) { + if s == nil { + return + } + return s.Winners +} diff --git a/tg/tl_stars_giveaway_option_slices_gen.go b/tg/tl_stars_giveaway_option_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_stars_giveaway_option_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_stars_giveaway_option_vector_gen.go b/tg/tl_stars_giveaway_option_vector_gen.go new file mode 100644 index 0000000000..ba8898e38a --- /dev/null +++ b/tg/tl_stars_giveaway_option_vector_gen.go @@ -0,0 +1,172 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// StarsGiveawayOptionVector is a box for Vector +type StarsGiveawayOptionVector struct { + // Elements of Vector + Elems []StarsGiveawayOption +} + +// StarsGiveawayOptionVectorTypeID is TL type id of StarsGiveawayOptionVector. +const StarsGiveawayOptionVectorTypeID = bin.TypeVector + +// Ensuring interfaces in compile-time for StarsGiveawayOptionVector. +var ( + _ bin.Encoder = &StarsGiveawayOptionVector{} + _ bin.Decoder = &StarsGiveawayOptionVector{} + _ bin.BareEncoder = &StarsGiveawayOptionVector{} + _ bin.BareDecoder = &StarsGiveawayOptionVector{} +) + +func (vec *StarsGiveawayOptionVector) Zero() bool { + if vec == nil { + return true + } + if !(vec.Elems == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (vec *StarsGiveawayOptionVector) String() string { + if vec == nil { + return "StarsGiveawayOptionVector(nil)" + } + type Alias StarsGiveawayOptionVector + return fmt.Sprintf("StarsGiveawayOptionVector%+v", Alias(*vec)) +} + +// FillFrom fills StarsGiveawayOptionVector from given interface. +func (vec *StarsGiveawayOptionVector) FillFrom(from interface { + GetElems() (value []StarsGiveawayOption) +}) { + vec.Elems = from.GetElems() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsGiveawayOptionVector) TypeID() uint32 { + return StarsGiveawayOptionVectorTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsGiveawayOptionVector) TypeName() string { + return "" +} + +// TypeInfo returns info about TL type. +func (vec *StarsGiveawayOptionVector) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "", + ID: StarsGiveawayOptionVectorTypeID, + } + if vec == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Elems", + SchemaName: "Elems", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (vec *StarsGiveawayOptionVector) Encode(b *bin.Buffer) error { + if vec == nil { + return fmt.Errorf("can't encode Vector as nil") + } + + return vec.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (vec *StarsGiveawayOptionVector) EncodeBare(b *bin.Buffer) error { + if vec == nil { + return fmt.Errorf("can't encode Vector as nil") + } + b.PutVectorHeader(len(vec.Elems)) + for idx, v := range vec.Elems { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode Vector: field Elems element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (vec *StarsGiveawayOptionVector) Decode(b *bin.Buffer) error { + if vec == nil { + return fmt.Errorf("can't decode Vector to nil") + } + + return vec.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (vec *StarsGiveawayOptionVector) DecodeBare(b *bin.Buffer) error { + if vec == nil { + return fmt.Errorf("can't decode Vector to nil") + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode Vector: field Elems: %w", err) + } + + if headerLen > 0 { + vec.Elems = make([]StarsGiveawayOption, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value StarsGiveawayOption + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode Vector: field Elems: %w", err) + } + vec.Elems = append(vec.Elems, value) + } + } + return nil +} + +// GetElems returns value of Elems field. +func (vec *StarsGiveawayOptionVector) GetElems() (value []StarsGiveawayOption) { + if vec == nil { + return + } + return vec.Elems +} diff --git a/tg/tl_stars_giveaway_option_vector_slices_gen.go b/tg/tl_stars_giveaway_option_vector_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_stars_giveaway_option_vector_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_stars_giveaway_winners_option_gen.go b/tg/tl_stars_giveaway_winners_option_gen.go new file mode 100644 index 0000000000..caa566aea4 --- /dev/null +++ b/tg/tl_stars_giveaway_winners_option_gen.go @@ -0,0 +1,241 @@ +// 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{} +) + +// StarsGiveawayWinnersOption represents TL type `starsGiveawayWinnersOption#54236209`. +// +// See https://core.telegram.org/constructor/starsGiveawayWinnersOption for reference. +type StarsGiveawayWinnersOption struct { + // Flags field of StarsGiveawayWinnersOption. + Flags bin.Fields + // Default field of StarsGiveawayWinnersOption. + Default bool + // Users field of StarsGiveawayWinnersOption. + Users int + // PerUserStars field of StarsGiveawayWinnersOption. + PerUserStars int64 +} + +// StarsGiveawayWinnersOptionTypeID is TL type id of StarsGiveawayWinnersOption. +const StarsGiveawayWinnersOptionTypeID = 0x54236209 + +// Ensuring interfaces in compile-time for StarsGiveawayWinnersOption. +var ( + _ bin.Encoder = &StarsGiveawayWinnersOption{} + _ bin.Decoder = &StarsGiveawayWinnersOption{} + _ bin.BareEncoder = &StarsGiveawayWinnersOption{} + _ bin.BareDecoder = &StarsGiveawayWinnersOption{} +) + +func (s *StarsGiveawayWinnersOption) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.Default == false) { + return false + } + if !(s.Users == 0) { + return false + } + if !(s.PerUserStars == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarsGiveawayWinnersOption) String() string { + if s == nil { + return "StarsGiveawayWinnersOption(nil)" + } + type Alias StarsGiveawayWinnersOption + return fmt.Sprintf("StarsGiveawayWinnersOption%+v", Alias(*s)) +} + +// FillFrom fills StarsGiveawayWinnersOption from given interface. +func (s *StarsGiveawayWinnersOption) FillFrom(from interface { + GetDefault() (value bool) + GetUsers() (value int) + GetPerUserStars() (value int64) +}) { + s.Default = from.GetDefault() + s.Users = from.GetUsers() + s.PerUserStars = from.GetPerUserStars() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsGiveawayWinnersOption) TypeID() uint32 { + return StarsGiveawayWinnersOptionTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsGiveawayWinnersOption) TypeName() string { + return "starsGiveawayWinnersOption" +} + +// TypeInfo returns info about TL type. +func (s *StarsGiveawayWinnersOption) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starsGiveawayWinnersOption", + ID: StarsGiveawayWinnersOptionTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Default", + SchemaName: "default", + Null: !s.Flags.Has(0), + }, + { + Name: "Users", + SchemaName: "users", + }, + { + Name: "PerUserStars", + SchemaName: "per_user_stars", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *StarsGiveawayWinnersOption) SetFlags() { + if !(s.Default == false) { + s.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (s *StarsGiveawayWinnersOption) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsGiveawayWinnersOption#54236209 as nil") + } + b.PutID(StarsGiveawayWinnersOptionTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarsGiveawayWinnersOption) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsGiveawayWinnersOption#54236209 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsGiveawayWinnersOption#54236209: field flags: %w", err) + } + b.PutInt(s.Users) + b.PutLong(s.PerUserStars) + return nil +} + +// Decode implements bin.Decoder. +func (s *StarsGiveawayWinnersOption) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsGiveawayWinnersOption#54236209 to nil") + } + if err := b.ConsumeID(StarsGiveawayWinnersOptionTypeID); err != nil { + return fmt.Errorf("unable to decode starsGiveawayWinnersOption#54236209: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarsGiveawayWinnersOption) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsGiveawayWinnersOption#54236209 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode starsGiveawayWinnersOption#54236209: field flags: %w", err) + } + } + s.Default = s.Flags.Has(0) + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starsGiveawayWinnersOption#54236209: field users: %w", err) + } + s.Users = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode starsGiveawayWinnersOption#54236209: field per_user_stars: %w", err) + } + s.PerUserStars = value + } + return nil +} + +// SetDefault sets value of Default conditional field. +func (s *StarsGiveawayWinnersOption) SetDefault(value bool) { + if value { + s.Flags.Set(0) + s.Default = true + } else { + s.Flags.Unset(0) + s.Default = false + } +} + +// GetDefault returns value of Default conditional field. +func (s *StarsGiveawayWinnersOption) GetDefault() (value bool) { + if s == nil { + return + } + return s.Flags.Has(0) +} + +// GetUsers returns value of Users field. +func (s *StarsGiveawayWinnersOption) GetUsers() (value int) { + if s == nil { + return + } + return s.Users +} + +// GetPerUserStars returns value of PerUserStars field. +func (s *StarsGiveawayWinnersOption) GetPerUserStars() (value int64) { + if s == nil { + return + } + return s.PerUserStars +} diff --git a/tg/tl_stars_giveaway_winners_option_slices_gen.go b/tg/tl_stars_giveaway_winners_option_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_stars_giveaway_winners_option_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_stars_transaction_gen.go b/tg/tl_stars_transaction_gen.go index 026c35119c..9cefe73375 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#433aeb2b`. +// StarsTransaction represents TL type `starsTransaction#ee7522d5`. // // See https://core.telegram.org/constructor/starsTransaction for reference. type StarsTransaction struct { @@ -91,10 +91,14 @@ type StarsTransaction struct { // // Use SetSubscriptionPeriod and GetSubscriptionPeriod helpers. SubscriptionPeriod int + // GiveawayPostID field of StarsTransaction. + // + // Use SetGiveawayPostID and GetGiveawayPostID helpers. + GiveawayPostID int } // StarsTransactionTypeID is TL type id of StarsTransaction. -const StarsTransactionTypeID = 0x433aeb2b +const StarsTransactionTypeID = 0xee7522d5 // Ensuring interfaces in compile-time for StarsTransaction. var ( @@ -165,6 +169,9 @@ func (s *StarsTransaction) Zero() bool { if !(s.SubscriptionPeriod == 0) { return false } + if !(s.GiveawayPostID == 0) { + return false + } return true } @@ -198,6 +205,7 @@ func (s *StarsTransaction) FillFrom(from interface { GetMsgID() (value int, ok bool) GetExtendedMedia() (value []MessageMediaClass, ok bool) GetSubscriptionPeriod() (value int, ok bool) + GetGiveawayPostID() (value int, ok bool) }) { s.Refund = from.GetRefund() s.Pending = from.GetPending() @@ -244,6 +252,10 @@ func (s *StarsTransaction) FillFrom(from interface { s.SubscriptionPeriod = val } + if val, ok := from.GetGiveawayPostID(); ok { + s.GiveawayPostID = val + } + } // TypeID returns type id in TL schema. @@ -355,6 +367,11 @@ func (s *StarsTransaction) TypeInfo() tdp.Type { SchemaName: "subscription_period", Null: !s.Flags.Has(12), }, + { + Name: "GiveawayPostID", + SchemaName: "giveaway_post_id", + Null: !s.Flags.Has(13), + }, } return typ } @@ -403,12 +420,15 @@ func (s *StarsTransaction) SetFlags() { if !(s.SubscriptionPeriod == 0) { s.Flags.Set(12) } + if !(s.GiveawayPostID == 0) { + s.Flags.Set(13) + } } // Encode implements bin.Encoder. func (s *StarsTransaction) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starsTransaction#433aeb2b as nil") + return fmt.Errorf("can't encode starsTransaction#ee7522d5 as nil") } b.PutID(StarsTransactionTypeID) return s.EncodeBare(b) @@ -417,20 +437,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#433aeb2b as nil") + return fmt.Errorf("can't encode starsTransaction#ee7522d5 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsTransaction#433aeb2b: field flags: %w", err) + return fmt.Errorf("unable to encode starsTransaction#ee7522d5: 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#433aeb2b: field peer is nil") + return fmt.Errorf("unable to encode starsTransaction#ee7522d5: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsTransaction#433aeb2b: field peer: %w", err) + return fmt.Errorf("unable to encode starsTransaction#ee7522d5: field peer: %w", err) } if s.Flags.Has(0) { b.PutString(s.Title) @@ -440,10 +460,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#433aeb2b: field photo is nil") + return fmt.Errorf("unable to encode starsTransaction#ee7522d5: field photo is nil") } if err := s.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsTransaction#433aeb2b: field photo: %w", err) + return fmt.Errorf("unable to encode starsTransaction#ee7522d5: field photo: %w", err) } } if s.Flags.Has(5) { @@ -462,26 +482,29 @@ 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#433aeb2b: field extended_media element with index %d is nil", idx) + return fmt.Errorf("unable to encode starsTransaction#ee7522d5: field extended_media element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsTransaction#433aeb2b: field extended_media element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode starsTransaction#ee7522d5: field extended_media element with index %d: %w", idx, err) } } } if s.Flags.Has(12) { b.PutInt(s.SubscriptionPeriod) } + if s.Flags.Has(13) { + b.PutInt(s.GiveawayPostID) + } return nil } // Decode implements bin.Decoder. func (s *StarsTransaction) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode starsTransaction#433aeb2b to nil") + return fmt.Errorf("can't decode starsTransaction#ee7522d5 to nil") } if err := b.ConsumeID(StarsTransactionTypeID); err != nil { - return fmt.Errorf("unable to decode starsTransaction#433aeb2b: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: %w", err) } return s.DecodeBare(b) } @@ -489,11 +512,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#433aeb2b to nil") + return fmt.Errorf("can't decode starsTransaction#ee7522d5 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode starsTransaction#433aeb2b: field flags: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field flags: %w", err) } } s.Refund = s.Flags.Has(3) @@ -504,84 +527,84 @@ func (s *StarsTransaction) DecodeBare(b *bin.Buffer) error { { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#433aeb2b: field id: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field id: %w", err) } s.ID = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#433aeb2b: field stars: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field stars: %w", err) } s.Stars = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#433aeb2b: field date: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field date: %w", err) } s.Date = value } { value, err := DecodeStarsTransactionPeer(b) if err != nil { - return fmt.Errorf("unable to decode starsTransaction#433aeb2b: field peer: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: 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#433aeb2b: field title: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: 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#433aeb2b: field description: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: 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#433aeb2b: field photo: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: 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#433aeb2b: field transaction_date: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: 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#433aeb2b: field transaction_url: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: 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#433aeb2b: field bot_payload: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: 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#433aeb2b: field msg_id: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: 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#433aeb2b: field extended_media: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field extended_media: %w", err) } if headerLen > 0 { @@ -590,7 +613,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#433aeb2b: field extended_media: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: field extended_media: %w", err) } s.ExtendedMedia = append(s.ExtendedMedia, value) } @@ -598,10 +621,17 @@ 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#433aeb2b: field subscription_period: %w", err) + return fmt.Errorf("unable to decode starsTransaction#ee7522d5: 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) + } + s.GiveawayPostID = value + } return nil } @@ -894,6 +924,24 @@ func (s *StarsTransaction) GetSubscriptionPeriod() (value int, ok bool) { return s.SubscriptionPeriod, true } +// SetGiveawayPostID sets value of GiveawayPostID conditional field. +func (s *StarsTransaction) SetGiveawayPostID(value int) { + s.Flags.Set(13) + s.GiveawayPostID = value +} + +// GetGiveawayPostID returns value of GiveawayPostID conditional field and +// boolean which is true if field was set. +func (s *StarsTransaction) GetGiveawayPostID() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(13) { + return value, false + } + return s.GiveawayPostID, 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_update_gen.go b/tg/tl_update_gen.go index 21133f03b5..1e83ab5352 100644 --- a/tg/tl_update_gen.go +++ b/tg/tl_update_gen.go @@ -27986,6 +27986,328 @@ func (u *UpdateStarsRevenueStatus) GetStatus() (value StarsRevenueStatus) { return u.Status } +// UpdateBotPurchasedPaidMedia represents TL type `updateBotPurchasedPaidMedia#283bd312`. +// +// See https://core.telegram.org/constructor/updateBotPurchasedPaidMedia for reference. +type UpdateBotPurchasedPaidMedia struct { + // UserID field of UpdateBotPurchasedPaidMedia. + UserID int64 + // Payload field of UpdateBotPurchasedPaidMedia. + Payload string + // Qts field of UpdateBotPurchasedPaidMedia. + Qts int +} + +// UpdateBotPurchasedPaidMediaTypeID is TL type id of UpdateBotPurchasedPaidMedia. +const UpdateBotPurchasedPaidMediaTypeID = 0x283bd312 + +// construct implements constructor of UpdateClass. +func (u UpdateBotPurchasedPaidMedia) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateBotPurchasedPaidMedia. +var ( + _ bin.Encoder = &UpdateBotPurchasedPaidMedia{} + _ bin.Decoder = &UpdateBotPurchasedPaidMedia{} + _ bin.BareEncoder = &UpdateBotPurchasedPaidMedia{} + _ bin.BareDecoder = &UpdateBotPurchasedPaidMedia{} + + _ UpdateClass = &UpdateBotPurchasedPaidMedia{} +) + +func (u *UpdateBotPurchasedPaidMedia) Zero() bool { + if u == nil { + return true + } + if !(u.UserID == 0) { + return false + } + if !(u.Payload == "") { + return false + } + if !(u.Qts == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateBotPurchasedPaidMedia) String() string { + if u == nil { + return "UpdateBotPurchasedPaidMedia(nil)" + } + type Alias UpdateBotPurchasedPaidMedia + return fmt.Sprintf("UpdateBotPurchasedPaidMedia%+v", Alias(*u)) +} + +// FillFrom fills UpdateBotPurchasedPaidMedia from given interface. +func (u *UpdateBotPurchasedPaidMedia) FillFrom(from interface { + GetUserID() (value int64) + GetPayload() (value string) + GetQts() (value int) +}) { + u.UserID = from.GetUserID() + u.Payload = from.GetPayload() + u.Qts = from.GetQts() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateBotPurchasedPaidMedia) TypeID() uint32 { + return UpdateBotPurchasedPaidMediaTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateBotPurchasedPaidMedia) TypeName() string { + return "updateBotPurchasedPaidMedia" +} + +// TypeInfo returns info about TL type. +func (u *UpdateBotPurchasedPaidMedia) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateBotPurchasedPaidMedia", + ID: UpdateBotPurchasedPaidMediaTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "Payload", + SchemaName: "payload", + }, + { + Name: "Qts", + SchemaName: "qts", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateBotPurchasedPaidMedia) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateBotPurchasedPaidMedia#283bd312 as nil") + } + b.PutID(UpdateBotPurchasedPaidMediaTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateBotPurchasedPaidMedia) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateBotPurchasedPaidMedia#283bd312 as nil") + } + b.PutLong(u.UserID) + b.PutString(u.Payload) + b.PutInt(u.Qts) + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateBotPurchasedPaidMedia) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateBotPurchasedPaidMedia#283bd312 to nil") + } + if err := b.ConsumeID(UpdateBotPurchasedPaidMediaTypeID); err != nil { + return fmt.Errorf("unable to decode updateBotPurchasedPaidMedia#283bd312: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateBotPurchasedPaidMedia) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateBotPurchasedPaidMedia#283bd312 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateBotPurchasedPaidMedia#283bd312: field user_id: %w", err) + } + u.UserID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode updateBotPurchasedPaidMedia#283bd312: field payload: %w", err) + } + u.Payload = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode updateBotPurchasedPaidMedia#283bd312: field qts: %w", err) + } + u.Qts = value + } + return nil +} + +// GetUserID returns value of UserID field. +func (u *UpdateBotPurchasedPaidMedia) GetUserID() (value int64) { + if u == nil { + return + } + return u.UserID +} + +// GetPayload returns value of Payload field. +func (u *UpdateBotPurchasedPaidMedia) GetPayload() (value string) { + if u == nil { + return + } + return u.Payload +} + +// GetQts returns value of Qts field. +func (u *UpdateBotPurchasedPaidMedia) GetQts() (value int) { + if u == nil { + return + } + return u.Qts +} + +// UpdatePaidReactionPrivacy represents TL type `updatePaidReactionPrivacy#51ca7aec`. +// +// See https://core.telegram.org/constructor/updatePaidReactionPrivacy for reference. +type UpdatePaidReactionPrivacy struct { + // Private field of UpdatePaidReactionPrivacy. + Private bool +} + +// UpdatePaidReactionPrivacyTypeID is TL type id of UpdatePaidReactionPrivacy. +const UpdatePaidReactionPrivacyTypeID = 0x51ca7aec + +// construct implements constructor of UpdateClass. +func (u UpdatePaidReactionPrivacy) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdatePaidReactionPrivacy. +var ( + _ bin.Encoder = &UpdatePaidReactionPrivacy{} + _ bin.Decoder = &UpdatePaidReactionPrivacy{} + _ bin.BareEncoder = &UpdatePaidReactionPrivacy{} + _ bin.BareDecoder = &UpdatePaidReactionPrivacy{} + + _ UpdateClass = &UpdatePaidReactionPrivacy{} +) + +func (u *UpdatePaidReactionPrivacy) Zero() bool { + if u == nil { + return true + } + if !(u.Private == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdatePaidReactionPrivacy) String() string { + if u == nil { + return "UpdatePaidReactionPrivacy(nil)" + } + type Alias UpdatePaidReactionPrivacy + return fmt.Sprintf("UpdatePaidReactionPrivacy%+v", Alias(*u)) +} + +// FillFrom fills UpdatePaidReactionPrivacy from given interface. +func (u *UpdatePaidReactionPrivacy) FillFrom(from interface { + GetPrivate() (value bool) +}) { + u.Private = from.GetPrivate() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdatePaidReactionPrivacy) TypeID() uint32 { + return UpdatePaidReactionPrivacyTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdatePaidReactionPrivacy) TypeName() string { + return "updatePaidReactionPrivacy" +} + +// TypeInfo returns info about TL type. +func (u *UpdatePaidReactionPrivacy) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updatePaidReactionPrivacy", + ID: UpdatePaidReactionPrivacyTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Private", + SchemaName: "private", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdatePaidReactionPrivacy) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updatePaidReactionPrivacy#51ca7aec as nil") + } + b.PutID(UpdatePaidReactionPrivacyTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdatePaidReactionPrivacy) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updatePaidReactionPrivacy#51ca7aec as nil") + } + b.PutBool(u.Private) + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdatePaidReactionPrivacy) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updatePaidReactionPrivacy#51ca7aec to nil") + } + if err := b.ConsumeID(UpdatePaidReactionPrivacyTypeID); err != nil { + return fmt.Errorf("unable to decode updatePaidReactionPrivacy#51ca7aec: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdatePaidReactionPrivacy) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updatePaidReactionPrivacy#51ca7aec to nil") + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode updatePaidReactionPrivacy#51ca7aec: field private: %w", err) + } + u.Private = value + } + return nil +} + +// GetPrivate returns value of Private field. +func (u *UpdatePaidReactionPrivacy) GetPrivate() (value bool) { + if u == nil { + return + } + return u.Private +} + // UpdateClassName is schema name of UpdateClass. const UpdateClassName = "Update" @@ -28139,6 +28461,8 @@ const UpdateClassName = "Update" // case *tg.UpdateStarsBalance: // updateStarsBalance#fb85198 // case *tg.UpdateBusinessBotCallbackQuery: // updateBusinessBotCallbackQuery#1ea2fda7 // case *tg.UpdateStarsRevenueStatus: // updateStarsRevenueStatus#a584b019 +// case *tg.UpdateBotPurchasedPaidMedia: // updateBotPurchasedPaidMedia#283bd312 +// case *tg.UpdatePaidReactionPrivacy: // updatePaidReactionPrivacy#51ca7aec // default: panic(v) // } type UpdateClass interface { @@ -29140,6 +29464,20 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case UpdateBotPurchasedPaidMediaTypeID: + // Decoding updateBotPurchasedPaidMedia#283bd312. + v := UpdateBotPurchasedPaidMedia{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil + case UpdatePaidReactionPrivacyTypeID: + // Decoding updatePaidReactionPrivacy#51ca7aec. + v := UpdatePaidReactionPrivacy{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode UpdateClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_update_slices_gen.go b/tg/tl_update_slices_gen.go index 8b9b2dac10..2586f5041e 100644 --- a/tg/tl_update_slices_gen.go +++ b/tg/tl_update_slices_gen.go @@ -1715,6 +1715,32 @@ func (s UpdateClassArray) AsUpdateStarsRevenueStatus() (to UpdateStarsRevenueSta return to } +// AsUpdateBotPurchasedPaidMedia returns copy with only UpdateBotPurchasedPaidMedia constructors. +func (s UpdateClassArray) AsUpdateBotPurchasedPaidMedia() (to UpdateBotPurchasedPaidMediaArray) { + for _, elem := range s { + value, ok := elem.(*UpdateBotPurchasedPaidMedia) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsUpdatePaidReactionPrivacy returns copy with only UpdatePaidReactionPrivacy constructors. +func (s UpdateClassArray) AsUpdatePaidReactionPrivacy() (to UpdatePaidReactionPrivacyArray) { + for _, elem := range s { + value, ok := elem.(*UpdatePaidReactionPrivacy) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // UpdateNewMessageArray is adapter for slice of UpdateNewMessage. type UpdateNewMessageArray []UpdateNewMessage @@ -12066,3 +12092,167 @@ func (s *UpdateStarsRevenueStatusArray) Pop() (v UpdateStarsRevenueStatus, ok bo return v, true } + +// UpdateBotPurchasedPaidMediaArray is adapter for slice of UpdateBotPurchasedPaidMedia. +type UpdateBotPurchasedPaidMediaArray []UpdateBotPurchasedPaidMedia + +// Sort sorts slice of UpdateBotPurchasedPaidMedia. +func (s UpdateBotPurchasedPaidMediaArray) Sort(less func(a, b UpdateBotPurchasedPaidMedia) bool) UpdateBotPurchasedPaidMediaArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateBotPurchasedPaidMedia. +func (s UpdateBotPurchasedPaidMediaArray) SortStable(less func(a, b UpdateBotPurchasedPaidMedia) bool) UpdateBotPurchasedPaidMediaArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateBotPurchasedPaidMedia. +func (s UpdateBotPurchasedPaidMediaArray) Retain(keep func(x UpdateBotPurchasedPaidMedia) bool) UpdateBotPurchasedPaidMediaArray { + 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 UpdateBotPurchasedPaidMediaArray) First() (v UpdateBotPurchasedPaidMedia, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateBotPurchasedPaidMediaArray) Last() (v UpdateBotPurchasedPaidMedia, 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 *UpdateBotPurchasedPaidMediaArray) PopFirst() (v UpdateBotPurchasedPaidMedia, 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 UpdateBotPurchasedPaidMedia + 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 *UpdateBotPurchasedPaidMediaArray) Pop() (v UpdateBotPurchasedPaidMedia, 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 +} + +// UpdatePaidReactionPrivacyArray is adapter for slice of UpdatePaidReactionPrivacy. +type UpdatePaidReactionPrivacyArray []UpdatePaidReactionPrivacy + +// Sort sorts slice of UpdatePaidReactionPrivacy. +func (s UpdatePaidReactionPrivacyArray) Sort(less func(a, b UpdatePaidReactionPrivacy) bool) UpdatePaidReactionPrivacyArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdatePaidReactionPrivacy. +func (s UpdatePaidReactionPrivacyArray) SortStable(less func(a, b UpdatePaidReactionPrivacy) bool) UpdatePaidReactionPrivacyArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdatePaidReactionPrivacy. +func (s UpdatePaidReactionPrivacyArray) Retain(keep func(x UpdatePaidReactionPrivacy) bool) UpdatePaidReactionPrivacyArray { + 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 UpdatePaidReactionPrivacyArray) First() (v UpdatePaidReactionPrivacy, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdatePaidReactionPrivacyArray) Last() (v UpdatePaidReactionPrivacy, 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 *UpdatePaidReactionPrivacyArray) PopFirst() (v UpdatePaidReactionPrivacy, 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 UpdatePaidReactionPrivacy + 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 *UpdatePaidReactionPrivacyArray) Pop() (v UpdatePaidReactionPrivacy, 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_updates_classifier_gen.go b/tg/tl_updates_classifier_gen.go index d37f3b1c84..7d887f6675 100644 --- a/tg/tl_updates_classifier_gen.go +++ b/tg/tl_updates_classifier_gen.go @@ -84,6 +84,8 @@ func IsQtsUpdate(u UpdateClass) (qts int, ok bool) { return u.Qts, true case *UpdateBotDeleteBusinessMessage: return u.Qts, true + case *UpdateBotPurchasedPaidMedia: + return u.Qts, true } return