diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index db34e695a5..274b586ebd 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: 193 -// SHA256: 588d13327ad4d323f81aca924d229c272fb446dc723714d1d107e4699fcb2085 +// Layer: 195 +// SHA256: a2228b646b7d44dd8aedbf3e4c22749697bd16bf628aca14fb1031cee656e9f6 boolFalse#bc799737 = Bool; @@ -256,9 +256,9 @@ messageActionHistoryClear#9fbab604 = MessageAction; messageActionGameScore#92a72876 game_id:long score:int = MessageAction; -messageActionPaymentSentMe#8f31b327 flags:# recurring_init:flags.2?true recurring_used:flags.3?true currency:string total_amount:long payload:bytes info:flags.0?PaymentRequestedInfo shipping_option_id:flags.1?string charge:PaymentCharge = MessageAction; +messageActionPaymentSentMe#ffa00ccc flags:# recurring_init:flags.2?true recurring_used:flags.3?true currency:string total_amount:long payload:bytes info:flags.0?PaymentRequestedInfo shipping_option_id:flags.1?string charge:PaymentCharge subscription_until_date:flags.4?int = MessageAction; -messageActionPaymentSent#96163f56 flags:# recurring_init:flags.2?true recurring_used:flags.3?true currency:string total_amount:long invoice_slug:flags.0?string = MessageAction; +messageActionPaymentSent#c624b16e flags:# recurring_init:flags.2?true recurring_used:flags.3?true currency:string total_amount:long invoice_slug:flags.0?string subscription_until_date:flags.4?int = MessageAction; messageActionPhoneCall#80e11a7f flags:# video:flags.2?true call_id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = MessageAction; @@ -396,7 +396,7 @@ inputReportReasonIllegalDrugs#a8eb2be = ReportReason; inputReportReasonPersonalDetails#9ec7863d = ReportReason; -userFull#1f58e369 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true can_view_revenue:flags2.9?true bot_can_manage_emoji_status:flags2.10?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int stargifts_count:flags2.8?int = UserFull; +userFull#979d2376 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true can_view_revenue:flags2.9?true bot_can_manage_emoji_status:flags2.10?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int stargifts_count:flags2.8?int starref_program:flags2.11?StarRefProgram = UserFull; contact#145ade0b user_id:long mutual:Bool = Contact; @@ -742,7 +742,7 @@ updateNewStoryReaction#1824e40b story_id:int peer:Peer reaction:Reaction = Updat updateBroadcastRevenueTransactions#dfd961f5 peer:Peer balances:BroadcastRevenueBalances = Update; -updateStarsBalance#fb85198 balance:long = Update; +updateStarsBalance#4e80a379 balance:StarsAmount = Update; updateBusinessBotCallbackQuery#1ea2fda7 flags:# query_id:long user_id:long connection_id:string message:Message reply_to_message:flags.2?Message chat_instance:long data:flags.0?bytes = Update; @@ -752,8 +752,6 @@ updateBotPurchasedPaidMedia#283bd312 user_id:long payload:string qts:int = Updat updatePaidReactionPrivacy#51ca7aec private:Bool = Update; -updateBotSubscriptionExpire#2d13c6ee user_id:long payload:string invoice_slug:string until_date:int qts:int = 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; @@ -2688,9 +2686,9 @@ starsTransactionPeerAPI#f9677aad = StarsTransactionPeer; starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; -starsTransaction#35d4f276 flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true reaction:flags.11?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector subscription_period:flags.12?int giveaway_post_id:flags.13?int stargift:flags.14?StarGift floodskip_number:flags.15?int = StarsTransaction; +starsTransaction#64dfc926 flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true reaction:flags.11?true id:string stars:StarsAmount date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector subscription_period:flags.12?int giveaway_post_id:flags.13?int stargift:flags.14?StarGift floodskip_number:flags.15?int starref_commission_permille:flags.16?int starref_peer:flags.17?Peer starref_amount:flags.17?StarsAmount = 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; +payments.starsStatus#6c9ce8ed flags:# balance:StarsAmount 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; foundStory#e87acbc0 peer:Peer story:StoryItem = FoundStory; @@ -2698,7 +2696,7 @@ stories.foundStories#e2de7737 flags:# count:int stories:Vector next_ geoPointAddress#de4c5d93 flags:# country_iso2:string state:flags.0?string city:flags.1?string street:flags.2?string = GeoPointAddress; -starsRevenueStatus#79342946 flags:# withdrawal_enabled:flags.0?true current_balance:long available_balance:long overall_revenue:long next_withdrawal_at:flags.1?int = StarsRevenueStatus; +starsRevenueStatus#febe5491 flags:# withdrawal_enabled:flags.0?true current_balance:StarsAmount available_balance:StarsAmount overall_revenue:StarsAmount next_withdrawal_at:flags.1?int = StarsRevenueStatus; payments.starsRevenueStats#c92bb73b revenue_graph:StatsGraph status:StarsRevenueStatus usd_rate:double = payments.StarsRevenueStats; @@ -2750,6 +2748,20 @@ messages.preparedInlineMessage#ff57708d query_id:long result:BotInlineResult pee botAppSettings#c99b1950 flags:# placeholder_path:flags.0?bytes background_color:flags.1?int background_dark_color:flags.2?int header_color:flags.3?int header_dark_color:flags.4?int = BotAppSettings; +starRefProgram#dd0c66f2 flags:# bot_id:long commission_permille:int duration_months:flags.0?int end_date:flags.1?int daily_revenue_per_user:flags.2?StarsAmount = StarRefProgram; + +connectedBotStarRef#19a13f71 flags:# revoked:flags.1?true url:string date:int bot_id:long commission_permille:int duration_months:flags.0?int participants:long revenue:long = ConnectedBotStarRef; + +payments.connectedStarRefBots#98d5ea1d count:int connected_bots:Vector users:Vector = payments.ConnectedStarRefBots; + +payments.suggestedStarRefBots#b4d5d859 flags:# count:int suggested_bots:Vector users:Vector next_offset:flags.0?string = payments.SuggestedStarRefBots; + +starsAmount#bbb6b4a3 amount:long nanos:int = StarsAmount; + +messages.foundStickersNotModified#6010c534 flags:# next_offset:flags.0?int = messages.FoundStickers; + +messages.foundStickers#82c9e290 flags:# next_offset:flags.0?int hash:long stickers:Vector = messages.FoundStickers; + ---functions--- @@ -3071,7 +3083,7 @@ contacts.getBlocked#9a868f80 flags:# my_stories_from:flags.0?true offset:int lim contacts.search#11f812d8 q:string limit:int = contacts.Found; -contacts.resolveUsername#f93ccba3 username:string = contacts.ResolvedPeer; +contacts.resolveUsername#725afbbc flags:# username:string referer:flags.0?string = contacts.ResolvedPeer; contacts.getTopPeers#973478b6 flags:# correspondents:flags.0?true bots_pm:flags.1?true bots_inline:flags.2?true phone_calls:flags.3?true forward_users:flags.4?true forward_chats:flags.5?true groups:flags.10?true channels:flags.15?true bots_app:flags.16?true offset:int limit:int hash:long = contacts.TopPeers; @@ -3549,6 +3561,8 @@ messages.savePreparedInlineMessage#f21f7f2f flags:# result:InputBotInlineResult messages.getPreparedInlineMessage#857ebdb8 bot:InputUser id:string = messages.PreparedInlineMessage; +messages.searchStickers#29b1c66a flags:# emojis:flags.0?true q:string emoticon:string lang_code:Vector offset:int limit:int hash:long = messages.FoundStickers; + updates.getState#edd4882a = updates.State; updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference; @@ -3805,6 +3819,10 @@ bots.toggleUserEmojiStatusPermission#6de6392 bot:InputUser enabled:Bool = Bool; bots.checkDownloadFileParams#50077589 bot:InputUser file_name:string url:string = Bool; +bots.getAdminedBots#b0711d83 = Vector; + +bots.updateStarRefProgram#778b5ab3 flags:# bot:InputUser commission_permille:int duration_months:flags.0?int = StarRefProgram; + payments.getPaymentForm#37148dbb flags:# invoice:InputInvoice theme_params:flags.0?DataJSON = payments.PaymentForm; payments.getPaymentReceipt#2478d1cc peer:InputPeer msg_id:int = payments.PaymentReceipt; @@ -3873,7 +3891,17 @@ payments.saveStarGift#87acf08e flags:# unsave:flags.0?true user_id:InputUser msg payments.convertStarGift#421e027 user_id:InputUser msg_id:int = Bool; -payments.botCancelStarsSubscription#57f9ece6 flags:# restore:flags.0?true user_id:InputUser invoice_slug:flags.1?string charge_id:flags.2?string = Bool; +payments.botCancelStarsSubscription#6dfa0622 flags:# restore:flags.0?true user_id:InputUser charge_id:string = Bool; + +payments.getConnectedStarRefBots#5869a553 flags:# peer:InputPeer offset_date:flags.2?int offset_link:flags.2?string limit:int = payments.ConnectedStarRefBots; + +payments.getConnectedStarRefBot#b7d998f0 peer:InputPeer bot:InputUser = payments.ConnectedStarRefBots; + +payments.getSuggestedStarRefBots#d6b48f7 flags:# order_by_revenue:flags.0?true order_by_date:flags.1?true peer:InputPeer offset:string limit:int = payments.SuggestedStarRefBots; + +payments.connectStarRefBot#7ed5348a peer:InputPeer bot:InputUser = payments.ConnectedStarRefBots; + +payments.editConnectedStarRefBot#e4fca4a3 flags:# revoked:flags.0?true peer:InputPeer link:string = payments.ConnectedStarRefBots; 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; @@ -4091,4 +4119,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 193 +// LAYER 195 diff --git a/_schema/tdlib.tl b/_schema/tdlib.tl index 88eb755109..7d47c06ae5 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: 194 -// SHA256: 6042b82379650b0c118b359d30556485b5a25045412ca0b11854095c751febe5 +// Layer: 195 +// SHA256: 339e6c05fea4c53ea77beccb55a227ef05c6130c69818517cf898965550903c3 int#a8509bda ? = Int; @@ -432,7 +432,7 @@ inputReportReasonIllegalDrugs#a8eb2be = ReportReason; inputReportReasonPersonalDetails#9ec7863d = ReportReason; -userFull#1f58e369 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true can_view_revenue:flags2.9?true bot_can_manage_emoji_status:flags2.10?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int stargifts_count:flags2.8?int = UserFull; +userFull#979d2376 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true can_view_revenue:flags2.9?true bot_can_manage_emoji_status:flags2.10?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int stargifts_count:flags2.8?int starref_program:flags2.11?StarRefProgram = UserFull; contact#145ade0b user_id:long mutual:Bool = Contact; @@ -778,7 +778,7 @@ updateNewStoryReaction#1824e40b story_id:int peer:Peer reaction:Reaction = Updat updateBroadcastRevenueTransactions#dfd961f5 peer:Peer balances:BroadcastRevenueBalances = Update; -updateStarsBalance#fb85198 balance:long = Update; +updateStarsBalance#4e80a379 balance:StarsAmount = Update; updateBusinessBotCallbackQuery#1ea2fda7 flags:# query_id:long user_id:long connection_id:string message:Message reply_to_message:flags.2?Message chat_instance:long data:flags.0?bytes = Update; @@ -2722,9 +2722,9 @@ starsTransactionPeerAPI#f9677aad = StarsTransactionPeer; starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; -starsTransaction#35d4f276 flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true reaction:flags.11?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector subscription_period:flags.12?int giveaway_post_id:flags.13?int stargift:flags.14?StarGift floodskip_number:flags.15?int = StarsTransaction; +starsTransaction#64dfc926 flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true reaction:flags.11?true id:string stars:StarsAmount date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector subscription_period:flags.12?int giveaway_post_id:flags.13?int stargift:flags.14?StarGift floodskip_number:flags.15?int starref_commission_permille:flags.16?int starref_peer:flags.17?Peer starref_amount:flags.17?StarsAmount = 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; +payments.starsStatus#6c9ce8ed flags:# balance:StarsAmount 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; foundStory#e87acbc0 peer:Peer story:StoryItem = FoundStory; @@ -2732,7 +2732,7 @@ stories.foundStories#e2de7737 flags:# count:int stories:Vector next_ geoPointAddress#de4c5d93 flags:# country_iso2:string state:flags.0?string city:flags.1?string street:flags.2?string = GeoPointAddress; -starsRevenueStatus#79342946 flags:# withdrawal_enabled:flags.0?true current_balance:long available_balance:long overall_revenue:long next_withdrawal_at:flags.1?int = StarsRevenueStatus; +starsRevenueStatus#febe5491 flags:# withdrawal_enabled:flags.0?true current_balance:StarsAmount available_balance:StarsAmount overall_revenue:StarsAmount next_withdrawal_at:flags.1?int = StarsRevenueStatus; payments.starsRevenueStats#c92bb73b revenue_graph:StatsGraph status:StarsRevenueStatus usd_rate:double = payments.StarsRevenueStats; @@ -2784,6 +2784,20 @@ messages.preparedInlineMessage#ff57708d query_id:long result:BotInlineResult pee botAppSettings#c99b1950 flags:# placeholder_path:flags.0?bytes background_color:flags.1?int background_dark_color:flags.2?int header_color:flags.3?int header_dark_color:flags.4?int = BotAppSettings; +starRefProgram#dd0c66f2 flags:# bot_id:long commission_permille:int duration_months:flags.0?int end_date:flags.1?int daily_revenue_per_user:flags.2?StarsAmount = StarRefProgram; + +connectedBotStarRef#19a13f71 flags:# revoked:flags.1?true url:string date:int bot_id:long commission_permille:int duration_months:flags.0?int participants:long revenue:long = ConnectedBotStarRef; + +payments.connectedStarRefBots#98d5ea1d count:int connected_bots:Vector users:Vector = payments.ConnectedStarRefBots; + +payments.suggestedStarRefBots#b4d5d859 flags:# count:int suggested_bots:Vector users:Vector next_offset:flags.0?string = payments.SuggestedStarRefBots; + +starsAmount#bbb6b4a3 amount:long nanos:int = StarsAmount; + +messages.foundStickersNotModified#6010c534 flags:# next_offset:flags.0?int = messages.FoundStickers; + +messages.foundStickers#82c9e290 flags:# next_offset:flags.0?int hash:long stickers:Vector = messages.FoundStickers; + ---functions--- @@ -3105,7 +3119,7 @@ contacts.getBlocked#9a868f80 flags:# my_stories_from:flags.0?true offset:int lim contacts.search#11f812d8 q:string limit:int = contacts.Found; -contacts.resolveUsername#f93ccba3 username:string = contacts.ResolvedPeer; +contacts.resolveUsername#725afbbc flags:# username:string referer:flags.0?string = contacts.ResolvedPeer; contacts.getTopPeers#973478b6 flags:# correspondents:flags.0?true bots_pm:flags.1?true bots_inline:flags.2?true phone_calls:flags.3?true forward_users:flags.4?true forward_chats:flags.5?true groups:flags.10?true channels:flags.15?true bots_app:flags.16?true offset:int limit:int hash:long = contacts.TopPeers; @@ -3583,6 +3597,8 @@ messages.savePreparedInlineMessage#f21f7f2f flags:# result:InputBotInlineResult messages.getPreparedInlineMessage#857ebdb8 bot:InputUser id:string = messages.PreparedInlineMessage; +messages.searchStickers#29b1c66a flags:# emojis:flags.0?true q:string emoticon:string lang_code:Vector offset:int limit:int hash:long = messages.FoundStickers; + updates.getState#edd4882a = updates.State; updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference; @@ -3839,6 +3855,10 @@ bots.toggleUserEmojiStatusPermission#6de6392 bot:InputUser enabled:Bool = Bool; bots.checkDownloadFileParams#50077589 bot:InputUser file_name:string url:string = Bool; +bots.getAdminedBots#b0711d83 = Vector; + +bots.updateStarRefProgram#778b5ab3 flags:# bot:InputUser commission_permille:int duration_months:flags.0?int = StarRefProgram; + payments.getPaymentForm#37148dbb flags:# invoice:InputInvoice theme_params:flags.0?DataJSON = payments.PaymentForm; payments.getPaymentReceipt#2478d1cc peer:InputPeer msg_id:int = payments.PaymentReceipt; @@ -3909,6 +3929,16 @@ payments.convertStarGift#421e027 user_id:InputUser msg_id:int = Bool; payments.botCancelStarsSubscription#6dfa0622 flags:# restore:flags.0?true user_id:InputUser charge_id:string = Bool; +payments.getConnectedStarRefBots#5869a553 flags:# peer:InputPeer offset_date:flags.2?int offset_link:flags.2?string limit:int = payments.ConnectedStarRefBots; + +payments.getConnectedStarRefBot#b7d998f0 peer:InputPeer bot:InputUser = payments.ConnectedStarRefBots; + +payments.getSuggestedStarRefBots#d6b48f7 flags:# order_by_revenue:flags.0?true order_by_date:flags.1?true peer:InputPeer offset:string limit:int = payments.SuggestedStarRefBots; + +payments.connectStarRefBot#7ed5348a peer:InputPeer bot:InputUser = payments.ConnectedStarRefBots; + +payments.editConnectedStarRefBot#e4fca4a3 flags:# revoked:flags.0?true peer:InputPeer link:string = payments.ConnectedStarRefBots; + 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; @@ -4125,4 +4155,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 194 +// LAYER 195 diff --git a/_schema/telegram.tl b/_schema/telegram.tl index 4c905ff811..aac655572f 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: 193 -// SHA256: 588d13327ad4d323f81aca924d229c272fb446dc723714d1d107e4699fcb2085 +// Layer: 195 +// SHA256: a2228b646b7d44dd8aedbf3e4c22749697bd16bf628aca14fb1031cee656e9f6 boolFalse#bc799737 = Bool; @@ -257,9 +257,9 @@ messageActionHistoryClear#9fbab604 = MessageAction; messageActionGameScore#92a72876 game_id:long score:int = MessageAction; -messageActionPaymentSentMe#8f31b327 flags:# recurring_init:flags.2?true recurring_used:flags.3?true currency:string total_amount:long payload:bytes info:flags.0?PaymentRequestedInfo shipping_option_id:flags.1?string charge:PaymentCharge = MessageAction; +messageActionPaymentSentMe#ffa00ccc flags:# recurring_init:flags.2?true recurring_used:flags.3?true currency:string total_amount:long payload:bytes info:flags.0?PaymentRequestedInfo shipping_option_id:flags.1?string charge:PaymentCharge subscription_until_date:flags.4?int = MessageAction; -messageActionPaymentSent#96163f56 flags:# recurring_init:flags.2?true recurring_used:flags.3?true currency:string total_amount:long invoice_slug:flags.0?string = MessageAction; +messageActionPaymentSent#c624b16e flags:# recurring_init:flags.2?true recurring_used:flags.3?true currency:string total_amount:long invoice_slug:flags.0?string subscription_until_date:flags.4?int = MessageAction; messageActionPhoneCall#80e11a7f flags:# video:flags.2?true call_id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = MessageAction; @@ -397,7 +397,7 @@ inputReportReasonIllegalDrugs#a8eb2be = ReportReason; inputReportReasonPersonalDetails#9ec7863d = ReportReason; -userFull#1f58e369 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true can_view_revenue:flags2.9?true bot_can_manage_emoji_status:flags2.10?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int stargifts_count:flags2.8?int = UserFull; +userFull#979d2376 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true can_view_revenue:flags2.9?true bot_can_manage_emoji_status:flags2.10?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int stargifts_count:flags2.8?int starref_program:flags2.11?StarRefProgram = UserFull; contact#145ade0b user_id:long mutual:Bool = Contact; @@ -743,7 +743,7 @@ updateNewStoryReaction#1824e40b story_id:int peer:Peer reaction:Reaction = Updat updateBroadcastRevenueTransactions#dfd961f5 peer:Peer balances:BroadcastRevenueBalances = Update; -updateStarsBalance#fb85198 balance:long = Update; +updateStarsBalance#4e80a379 balance:StarsAmount = Update; updateBusinessBotCallbackQuery#1ea2fda7 flags:# query_id:long user_id:long connection_id:string message:Message reply_to_message:flags.2?Message chat_instance:long data:flags.0?bytes = Update; @@ -753,8 +753,6 @@ updateBotPurchasedPaidMedia#283bd312 user_id:long payload:string qts:int = Updat updatePaidReactionPrivacy#51ca7aec private:Bool = Update; -updateBotSubscriptionExpire#2d13c6ee user_id:long payload:string invoice_slug:string until_date:int qts:int = 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; @@ -2689,9 +2687,9 @@ starsTransactionPeerAPI#f9677aad = StarsTransactionPeer; starsTopupOption#bd915c0 flags:# extended:flags.1?true stars:long store_product:flags.0?string currency:string amount:long = StarsTopupOption; -starsTransaction#35d4f276 flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true reaction:flags.11?true id:string stars:long date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector subscription_period:flags.12?int giveaway_post_id:flags.13?int stargift:flags.14?StarGift floodskip_number:flags.15?int = StarsTransaction; +starsTransaction#64dfc926 flags:# refund:flags.3?true pending:flags.4?true failed:flags.6?true gift:flags.10?true reaction:flags.11?true id:string stars:StarsAmount date:int peer:StarsTransactionPeer title:flags.0?string description:flags.1?string photo:flags.2?WebDocument transaction_date:flags.5?int transaction_url:flags.5?string bot_payload:flags.7?bytes msg_id:flags.8?int extended_media:flags.9?Vector subscription_period:flags.12?int giveaway_post_id:flags.13?int stargift:flags.14?StarGift floodskip_number:flags.15?int starref_commission_permille:flags.16?int starref_peer:flags.17?Peer starref_amount:flags.17?StarsAmount = 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; +payments.starsStatus#6c9ce8ed flags:# balance:StarsAmount 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; foundStory#e87acbc0 peer:Peer story:StoryItem = FoundStory; @@ -2699,7 +2697,7 @@ stories.foundStories#e2de7737 flags:# count:int stories:Vector next_ geoPointAddress#de4c5d93 flags:# country_iso2:string state:flags.0?string city:flags.1?string street:flags.2?string = GeoPointAddress; -starsRevenueStatus#79342946 flags:# withdrawal_enabled:flags.0?true current_balance:long available_balance:long overall_revenue:long next_withdrawal_at:flags.1?int = StarsRevenueStatus; +starsRevenueStatus#febe5491 flags:# withdrawal_enabled:flags.0?true current_balance:StarsAmount available_balance:StarsAmount overall_revenue:StarsAmount next_withdrawal_at:flags.1?int = StarsRevenueStatus; payments.starsRevenueStats#c92bb73b revenue_graph:StatsGraph status:StarsRevenueStatus usd_rate:double = payments.StarsRevenueStats; @@ -2751,6 +2749,20 @@ messages.preparedInlineMessage#ff57708d query_id:long result:BotInlineResult pee botAppSettings#c99b1950 flags:# placeholder_path:flags.0?bytes background_color:flags.1?int background_dark_color:flags.2?int header_color:flags.3?int header_dark_color:flags.4?int = BotAppSettings; +starRefProgram#dd0c66f2 flags:# bot_id:long commission_permille:int duration_months:flags.0?int end_date:flags.1?int daily_revenue_per_user:flags.2?StarsAmount = StarRefProgram; + +connectedBotStarRef#19a13f71 flags:# revoked:flags.1?true url:string date:int bot_id:long commission_permille:int duration_months:flags.0?int participants:long revenue:long = ConnectedBotStarRef; + +payments.connectedStarRefBots#98d5ea1d count:int connected_bots:Vector users:Vector = payments.ConnectedStarRefBots; + +payments.suggestedStarRefBots#b4d5d859 flags:# count:int suggested_bots:Vector users:Vector next_offset:flags.0?string = payments.SuggestedStarRefBots; + +starsAmount#bbb6b4a3 amount:long nanos:int = StarsAmount; + +messages.foundStickersNotModified#6010c534 flags:# next_offset:flags.0?int = messages.FoundStickers; + +messages.foundStickers#82c9e290 flags:# next_offset:flags.0?int hash:long stickers:Vector = messages.FoundStickers; + ---functions--- @@ -3072,7 +3084,7 @@ contacts.getBlocked#9a868f80 flags:# my_stories_from:flags.0?true offset:int lim contacts.search#11f812d8 q:string limit:int = contacts.Found; -contacts.resolveUsername#f93ccba3 username:string = contacts.ResolvedPeer; +contacts.resolveUsername#725afbbc flags:# username:string referer:flags.0?string = contacts.ResolvedPeer; contacts.getTopPeers#973478b6 flags:# correspondents:flags.0?true bots_pm:flags.1?true bots_inline:flags.2?true phone_calls:flags.3?true forward_users:flags.4?true forward_chats:flags.5?true groups:flags.10?true channels:flags.15?true bots_app:flags.16?true offset:int limit:int hash:long = contacts.TopPeers; @@ -3550,6 +3562,8 @@ messages.savePreparedInlineMessage#f21f7f2f flags:# result:InputBotInlineResult messages.getPreparedInlineMessage#857ebdb8 bot:InputUser id:string = messages.PreparedInlineMessage; +messages.searchStickers#29b1c66a flags:# emojis:flags.0?true q:string emoticon:string lang_code:Vector offset:int limit:int hash:long = messages.FoundStickers; + updates.getState#edd4882a = updates.State; updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference; @@ -3806,6 +3820,10 @@ bots.toggleUserEmojiStatusPermission#6de6392 bot:InputUser enabled:Bool = Bool; bots.checkDownloadFileParams#50077589 bot:InputUser file_name:string url:string = Bool; +bots.getAdminedBots#b0711d83 = Vector; + +bots.updateStarRefProgram#778b5ab3 flags:# bot:InputUser commission_permille:int duration_months:flags.0?int = StarRefProgram; + payments.getPaymentForm#37148dbb flags:# invoice:InputInvoice theme_params:flags.0?DataJSON = payments.PaymentForm; payments.getPaymentReceipt#2478d1cc peer:InputPeer msg_id:int = payments.PaymentReceipt; @@ -3874,7 +3892,17 @@ payments.saveStarGift#87acf08e flags:# unsave:flags.0?true user_id:InputUser msg payments.convertStarGift#421e027 user_id:InputUser msg_id:int = Bool; -payments.botCancelStarsSubscription#57f9ece6 flags:# restore:flags.0?true user_id:InputUser invoice_slug:flags.1?string charge_id:flags.2?string = Bool; +payments.botCancelStarsSubscription#6dfa0622 flags:# restore:flags.0?true user_id:InputUser charge_id:string = Bool; + +payments.getConnectedStarRefBots#5869a553 flags:# peer:InputPeer offset_date:flags.2?int offset_link:flags.2?string limit:int = payments.ConnectedStarRefBots; + +payments.getConnectedStarRefBot#b7d998f0 peer:InputPeer bot:InputUser = payments.ConnectedStarRefBots; + +payments.getSuggestedStarRefBots#d6b48f7 flags:# order_by_revenue:flags.0?true order_by_date:flags.1?true peer:InputPeer offset:string limit:int = payments.SuggestedStarRefBots; + +payments.connectStarRefBot#7ed5348a peer:InputPeer bot:InputUser = payments.ConnectedStarRefBots; + +payments.editConnectedStarRefBot#e4fca4a3 flags:# revoked:flags.0?true peer:InputPeer link:string = payments.ConnectedStarRefBots; 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; @@ -4124,4 +4152,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 193 +// LAYER 195 diff --git a/telegram/message/peer/resolver.go b/telegram/message/peer/resolver.go index 2a96afbc54..5d4a9c820f 100644 --- a/telegram/message/peer/resolver.go +++ b/telegram/message/peer/resolver.go @@ -29,7 +29,9 @@ type plainResolver struct { } func (p plainResolver) ResolveDomain(ctx context.Context, domain string) (tg.InputPeerClass, error) { - peer, err := p.raw.ContactsResolveUsername(ctx, domain) + peer, err := p.raw.ContactsResolveUsername(ctx, &tg.ContactsResolveUsernameRequest{ + Username: domain, + }) if err != nil { return nil, errors.Wrap(err, "resolve") } diff --git a/telegram/peers/resolve.go b/telegram/peers/resolve.go index 4ed0a04d90..d741abed2d 100644 --- a/telegram/peers/resolve.go +++ b/telegram/peers/resolve.go @@ -165,7 +165,9 @@ func (m *Manager) ResolveDomain(ctx context.Context, domain string) (Peer, error } ch := m.sg.DoChan(domain, func() (interface{}, error) { - result, err := m.api.ContactsResolveUsername(ctx, domain) + result, err := m.api.ContactsResolveUsername(ctx, &tg.ContactsResolveUsernameRequest{ + Username: domain, + }) if err != nil { return nil, errors.Wrap(err, "resolve") } diff --git a/tg/tl_bots_get_admined_bots_gen.go b/tg/tl_bots_get_admined_bots_gen.go new file mode 100644 index 0000000000..4e412d882d --- /dev/null +++ b/tg/tl_bots_get_admined_bots_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{} +) + +// BotsGetAdminedBotsRequest represents TL type `bots.getAdminedBots#b0711d83`. +// +// See https://core.telegram.org/method/bots.getAdminedBots for reference. +type BotsGetAdminedBotsRequest struct { +} + +// BotsGetAdminedBotsRequestTypeID is TL type id of BotsGetAdminedBotsRequest. +const BotsGetAdminedBotsRequestTypeID = 0xb0711d83 + +// Ensuring interfaces in compile-time for BotsGetAdminedBotsRequest. +var ( + _ bin.Encoder = &BotsGetAdminedBotsRequest{} + _ bin.Decoder = &BotsGetAdminedBotsRequest{} + _ bin.BareEncoder = &BotsGetAdminedBotsRequest{} + _ bin.BareDecoder = &BotsGetAdminedBotsRequest{} +) + +func (g *BotsGetAdminedBotsRequest) Zero() bool { + if g == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (g *BotsGetAdminedBotsRequest) String() string { + if g == nil { + return "BotsGetAdminedBotsRequest(nil)" + } + type Alias BotsGetAdminedBotsRequest + return fmt.Sprintf("BotsGetAdminedBotsRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsGetAdminedBotsRequest) TypeID() uint32 { + return BotsGetAdminedBotsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsGetAdminedBotsRequest) TypeName() string { + return "bots.getAdminedBots" +} + +// TypeInfo returns info about TL type. +func (g *BotsGetAdminedBotsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.getAdminedBots", + ID: BotsGetAdminedBotsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (g *BotsGetAdminedBotsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode bots.getAdminedBots#b0711d83 as nil") + } + b.PutID(BotsGetAdminedBotsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *BotsGetAdminedBotsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode bots.getAdminedBots#b0711d83 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (g *BotsGetAdminedBotsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode bots.getAdminedBots#b0711d83 to nil") + } + if err := b.ConsumeID(BotsGetAdminedBotsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode bots.getAdminedBots#b0711d83: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *BotsGetAdminedBotsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode bots.getAdminedBots#b0711d83 to nil") + } + return nil +} + +// BotsGetAdminedBots invokes method bots.getAdminedBots#b0711d83 returning error if any. +// +// See https://core.telegram.org/method/bots.getAdminedBots for reference. +func (c *Client) BotsGetAdminedBots(ctx context.Context) ([]UserClass, error) { + var result UserClassVector + + request := &BotsGetAdminedBotsRequest{} + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return []UserClass(result.Elems), nil +} diff --git a/tg/tl_bots_get_admined_bots_slices_gen.go b/tg/tl_bots_get_admined_bots_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_bots_get_admined_bots_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_bots_update_star_ref_program_gen.go b/tg/tl_bots_update_star_ref_program_gen.go new file mode 100644 index 0000000000..c0635d2ad5 --- /dev/null +++ b/tg/tl_bots_update_star_ref_program_gen.go @@ -0,0 +1,271 @@ +// 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{} +) + +// BotsUpdateStarRefProgramRequest represents TL type `bots.updateStarRefProgram#778b5ab3`. +// +// See https://core.telegram.org/method/bots.updateStarRefProgram for reference. +type BotsUpdateStarRefProgramRequest struct { + // Flags field of BotsUpdateStarRefProgramRequest. + Flags bin.Fields + // Bot field of BotsUpdateStarRefProgramRequest. + Bot InputUserClass + // CommissionPermille field of BotsUpdateStarRefProgramRequest. + CommissionPermille int + // DurationMonths field of BotsUpdateStarRefProgramRequest. + // + // Use SetDurationMonths and GetDurationMonths helpers. + DurationMonths int +} + +// BotsUpdateStarRefProgramRequestTypeID is TL type id of BotsUpdateStarRefProgramRequest. +const BotsUpdateStarRefProgramRequestTypeID = 0x778b5ab3 + +// Ensuring interfaces in compile-time for BotsUpdateStarRefProgramRequest. +var ( + _ bin.Encoder = &BotsUpdateStarRefProgramRequest{} + _ bin.Decoder = &BotsUpdateStarRefProgramRequest{} + _ bin.BareEncoder = &BotsUpdateStarRefProgramRequest{} + _ bin.BareDecoder = &BotsUpdateStarRefProgramRequest{} +) + +func (u *BotsUpdateStarRefProgramRequest) Zero() bool { + if u == nil { + return true + } + if !(u.Flags.Zero()) { + return false + } + if !(u.Bot == nil) { + return false + } + if !(u.CommissionPermille == 0) { + return false + } + if !(u.DurationMonths == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *BotsUpdateStarRefProgramRequest) String() string { + if u == nil { + return "BotsUpdateStarRefProgramRequest(nil)" + } + type Alias BotsUpdateStarRefProgramRequest + return fmt.Sprintf("BotsUpdateStarRefProgramRequest%+v", Alias(*u)) +} + +// FillFrom fills BotsUpdateStarRefProgramRequest from given interface. +func (u *BotsUpdateStarRefProgramRequest) FillFrom(from interface { + GetBot() (value InputUserClass) + GetCommissionPermille() (value int) + GetDurationMonths() (value int, ok bool) +}) { + u.Bot = from.GetBot() + u.CommissionPermille = from.GetCommissionPermille() + if val, ok := from.GetDurationMonths(); ok { + u.DurationMonths = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsUpdateStarRefProgramRequest) TypeID() uint32 { + return BotsUpdateStarRefProgramRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsUpdateStarRefProgramRequest) TypeName() string { + return "bots.updateStarRefProgram" +} + +// TypeInfo returns info about TL type. +func (u *BotsUpdateStarRefProgramRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.updateStarRefProgram", + ID: BotsUpdateStarRefProgramRequestTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Bot", + SchemaName: "bot", + }, + { + Name: "CommissionPermille", + SchemaName: "commission_permille", + }, + { + Name: "DurationMonths", + SchemaName: "duration_months", + Null: !u.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (u *BotsUpdateStarRefProgramRequest) SetFlags() { + if !(u.DurationMonths == 0) { + u.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (u *BotsUpdateStarRefProgramRequest) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode bots.updateStarRefProgram#778b5ab3 as nil") + } + b.PutID(BotsUpdateStarRefProgramRequestTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *BotsUpdateStarRefProgramRequest) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode bots.updateStarRefProgram#778b5ab3 as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.updateStarRefProgram#778b5ab3: field flags: %w", err) + } + if u.Bot == nil { + return fmt.Errorf("unable to encode bots.updateStarRefProgram#778b5ab3: field bot is nil") + } + if err := u.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.updateStarRefProgram#778b5ab3: field bot: %w", err) + } + b.PutInt(u.CommissionPermille) + if u.Flags.Has(0) { + b.PutInt(u.DurationMonths) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *BotsUpdateStarRefProgramRequest) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode bots.updateStarRefProgram#778b5ab3 to nil") + } + if err := b.ConsumeID(BotsUpdateStarRefProgramRequestTypeID); err != nil { + return fmt.Errorf("unable to decode bots.updateStarRefProgram#778b5ab3: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *BotsUpdateStarRefProgramRequest) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode bots.updateStarRefProgram#778b5ab3 to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode bots.updateStarRefProgram#778b5ab3: field flags: %w", err) + } + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode bots.updateStarRefProgram#778b5ab3: field bot: %w", err) + } + u.Bot = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode bots.updateStarRefProgram#778b5ab3: field commission_permille: %w", err) + } + u.CommissionPermille = value + } + if u.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode bots.updateStarRefProgram#778b5ab3: field duration_months: %w", err) + } + u.DurationMonths = value + } + return nil +} + +// GetBot returns value of Bot field. +func (u *BotsUpdateStarRefProgramRequest) GetBot() (value InputUserClass) { + if u == nil { + return + } + return u.Bot +} + +// GetCommissionPermille returns value of CommissionPermille field. +func (u *BotsUpdateStarRefProgramRequest) GetCommissionPermille() (value int) { + if u == nil { + return + } + return u.CommissionPermille +} + +// SetDurationMonths sets value of DurationMonths conditional field. +func (u *BotsUpdateStarRefProgramRequest) SetDurationMonths(value int) { + u.Flags.Set(0) + u.DurationMonths = value +} + +// GetDurationMonths returns value of DurationMonths conditional field and +// boolean which is true if field was set. +func (u *BotsUpdateStarRefProgramRequest) GetDurationMonths() (value int, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.DurationMonths, true +} + +// BotsUpdateStarRefProgram invokes method bots.updateStarRefProgram#778b5ab3 returning error if any. +// +// See https://core.telegram.org/method/bots.updateStarRefProgram for reference. +func (c *Client) BotsUpdateStarRefProgram(ctx context.Context, request *BotsUpdateStarRefProgramRequest) (*StarRefProgram, error) { + var result StarRefProgram + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_bots_update_star_ref_program_slices_gen.go b/tg/tl_bots_update_star_ref_program_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_bots_update_star_ref_program_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_connected_bot_star_ref_gen.go b/tg/tl_connected_bot_star_ref_gen.go new file mode 100644 index 0000000000..f805be592e --- /dev/null +++ b/tg/tl_connected_bot_star_ref_gen.go @@ -0,0 +1,397 @@ +// 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{} +) + +// ConnectedBotStarRef represents TL type `connectedBotStarRef#19a13f71`. +// +// See https://core.telegram.org/constructor/connectedBotStarRef for reference. +type ConnectedBotStarRef struct { + // Flags field of ConnectedBotStarRef. + Flags bin.Fields + // Revoked field of ConnectedBotStarRef. + Revoked bool + // URL field of ConnectedBotStarRef. + URL string + // Date field of ConnectedBotStarRef. + Date int + // BotID field of ConnectedBotStarRef. + BotID int64 + // CommissionPermille field of ConnectedBotStarRef. + CommissionPermille int + // DurationMonths field of ConnectedBotStarRef. + // + // Use SetDurationMonths and GetDurationMonths helpers. + DurationMonths int + // Participants field of ConnectedBotStarRef. + Participants int64 + // Revenue field of ConnectedBotStarRef. + Revenue int64 +} + +// ConnectedBotStarRefTypeID is TL type id of ConnectedBotStarRef. +const ConnectedBotStarRefTypeID = 0x19a13f71 + +// Ensuring interfaces in compile-time for ConnectedBotStarRef. +var ( + _ bin.Encoder = &ConnectedBotStarRef{} + _ bin.Decoder = &ConnectedBotStarRef{} + _ bin.BareEncoder = &ConnectedBotStarRef{} + _ bin.BareDecoder = &ConnectedBotStarRef{} +) + +func (c *ConnectedBotStarRef) Zero() bool { + if c == nil { + return true + } + if !(c.Flags.Zero()) { + return false + } + if !(c.Revoked == false) { + return false + } + if !(c.URL == "") { + return false + } + if !(c.Date == 0) { + return false + } + if !(c.BotID == 0) { + return false + } + if !(c.CommissionPermille == 0) { + return false + } + if !(c.DurationMonths == 0) { + return false + } + if !(c.Participants == 0) { + return false + } + if !(c.Revenue == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ConnectedBotStarRef) String() string { + if c == nil { + return "ConnectedBotStarRef(nil)" + } + type Alias ConnectedBotStarRef + return fmt.Sprintf("ConnectedBotStarRef%+v", Alias(*c)) +} + +// FillFrom fills ConnectedBotStarRef from given interface. +func (c *ConnectedBotStarRef) FillFrom(from interface { + GetRevoked() (value bool) + GetURL() (value string) + GetDate() (value int) + GetBotID() (value int64) + GetCommissionPermille() (value int) + GetDurationMonths() (value int, ok bool) + GetParticipants() (value int64) + GetRevenue() (value int64) +}) { + c.Revoked = from.GetRevoked() + c.URL = from.GetURL() + c.Date = from.GetDate() + c.BotID = from.GetBotID() + c.CommissionPermille = from.GetCommissionPermille() + if val, ok := from.GetDurationMonths(); ok { + c.DurationMonths = val + } + + c.Participants = from.GetParticipants() + c.Revenue = from.GetRevenue() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ConnectedBotStarRef) TypeID() uint32 { + return ConnectedBotStarRefTypeID +} + +// TypeName returns name of type in TL schema. +func (*ConnectedBotStarRef) TypeName() string { + return "connectedBotStarRef" +} + +// TypeInfo returns info about TL type. +func (c *ConnectedBotStarRef) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "connectedBotStarRef", + ID: ConnectedBotStarRefTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Revoked", + SchemaName: "revoked", + Null: !c.Flags.Has(1), + }, + { + Name: "URL", + SchemaName: "url", + }, + { + Name: "Date", + SchemaName: "date", + }, + { + Name: "BotID", + SchemaName: "bot_id", + }, + { + Name: "CommissionPermille", + SchemaName: "commission_permille", + }, + { + Name: "DurationMonths", + SchemaName: "duration_months", + Null: !c.Flags.Has(0), + }, + { + Name: "Participants", + SchemaName: "participants", + }, + { + Name: "Revenue", + SchemaName: "revenue", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (c *ConnectedBotStarRef) SetFlags() { + if !(c.Revoked == false) { + c.Flags.Set(1) + } + if !(c.DurationMonths == 0) { + c.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (c *ConnectedBotStarRef) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode connectedBotStarRef#19a13f71 as nil") + } + b.PutID(ConnectedBotStarRefTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ConnectedBotStarRef) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode connectedBotStarRef#19a13f71 as nil") + } + c.SetFlags() + if err := c.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode connectedBotStarRef#19a13f71: field flags: %w", err) + } + b.PutString(c.URL) + b.PutInt(c.Date) + b.PutLong(c.BotID) + b.PutInt(c.CommissionPermille) + if c.Flags.Has(0) { + b.PutInt(c.DurationMonths) + } + b.PutLong(c.Participants) + b.PutLong(c.Revenue) + return nil +} + +// Decode implements bin.Decoder. +func (c *ConnectedBotStarRef) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode connectedBotStarRef#19a13f71 to nil") + } + if err := b.ConsumeID(ConnectedBotStarRefTypeID); err != nil { + return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ConnectedBotStarRef) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode connectedBotStarRef#19a13f71 to nil") + } + { + if err := c.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field flags: %w", err) + } + } + c.Revoked = c.Flags.Has(1) + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field url: %w", err) + } + c.URL = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field date: %w", err) + } + c.Date = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field bot_id: %w", err) + } + c.BotID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field commission_permille: %w", err) + } + c.CommissionPermille = value + } + if c.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field duration_months: %w", err) + } + c.DurationMonths = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field participants: %w", err) + } + c.Participants = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field revenue: %w", err) + } + c.Revenue = value + } + return nil +} + +// SetRevoked sets value of Revoked conditional field. +func (c *ConnectedBotStarRef) SetRevoked(value bool) { + if value { + c.Flags.Set(1) + c.Revoked = true + } else { + c.Flags.Unset(1) + c.Revoked = false + } +} + +// GetRevoked returns value of Revoked conditional field. +func (c *ConnectedBotStarRef) GetRevoked() (value bool) { + if c == nil { + return + } + return c.Flags.Has(1) +} + +// GetURL returns value of URL field. +func (c *ConnectedBotStarRef) GetURL() (value string) { + if c == nil { + return + } + return c.URL +} + +// GetDate returns value of Date field. +func (c *ConnectedBotStarRef) GetDate() (value int) { + if c == nil { + return + } + return c.Date +} + +// GetBotID returns value of BotID field. +func (c *ConnectedBotStarRef) GetBotID() (value int64) { + if c == nil { + return + } + return c.BotID +} + +// GetCommissionPermille returns value of CommissionPermille field. +func (c *ConnectedBotStarRef) GetCommissionPermille() (value int) { + if c == nil { + return + } + return c.CommissionPermille +} + +// SetDurationMonths sets value of DurationMonths conditional field. +func (c *ConnectedBotStarRef) SetDurationMonths(value int) { + c.Flags.Set(0) + c.DurationMonths = value +} + +// GetDurationMonths returns value of DurationMonths conditional field and +// boolean which is true if field was set. +func (c *ConnectedBotStarRef) GetDurationMonths() (value int, ok bool) { + if c == nil { + return + } + if !c.Flags.Has(0) { + return value, false + } + return c.DurationMonths, true +} + +// GetParticipants returns value of Participants field. +func (c *ConnectedBotStarRef) GetParticipants() (value int64) { + if c == nil { + return + } + return c.Participants +} + +// GetRevenue returns value of Revenue field. +func (c *ConnectedBotStarRef) GetRevenue() (value int64) { + if c == nil { + return + } + return c.Revenue +} diff --git a/tg/tl_connected_bot_star_ref_slices_gen.go b/tg/tl_connected_bot_star_ref_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_connected_bot_star_ref_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_contacts_resolve_username_gen.go b/tg/tl_contacts_resolve_username_gen.go index cb12d9ea9d..94db7241ca 100644 --- a/tg/tl_contacts_resolve_username_gen.go +++ b/tg/tl_contacts_resolve_username_gen.go @@ -31,17 +31,23 @@ var ( _ = tdjson.Encoder{} ) -// ContactsResolveUsernameRequest represents TL type `contacts.resolveUsername#f93ccba3`. +// ContactsResolveUsernameRequest represents TL type `contacts.resolveUsername#725afbbc`. // Resolve a @username to get peer info // // See https://core.telegram.org/method/contacts.resolveUsername for reference. type ContactsResolveUsernameRequest struct { + // Flags field of ContactsResolveUsernameRequest. + Flags bin.Fields // @username to resolve Username string + // Referer field of ContactsResolveUsernameRequest. + // + // Use SetReferer and GetReferer helpers. + Referer string } // ContactsResolveUsernameRequestTypeID is TL type id of ContactsResolveUsernameRequest. -const ContactsResolveUsernameRequestTypeID = 0xf93ccba3 +const ContactsResolveUsernameRequestTypeID = 0x725afbbc // Ensuring interfaces in compile-time for ContactsResolveUsernameRequest. var ( @@ -55,9 +61,15 @@ func (r *ContactsResolveUsernameRequest) Zero() bool { if r == nil { return true } + if !(r.Flags.Zero()) { + return false + } if !(r.Username == "") { return false } + if !(r.Referer == "") { + return false + } return true } @@ -74,8 +86,13 @@ func (r *ContactsResolveUsernameRequest) String() string { // FillFrom fills ContactsResolveUsernameRequest from given interface. func (r *ContactsResolveUsernameRequest) FillFrom(from interface { GetUsername() (value string) + GetReferer() (value string, ok bool) }) { r.Username = from.GetUsername() + if val, ok := from.GetReferer(); ok { + r.Referer = val + } + } // TypeID returns type id in TL schema. @@ -105,14 +122,26 @@ func (r *ContactsResolveUsernameRequest) TypeInfo() tdp.Type { Name: "Username", SchemaName: "username", }, + { + Name: "Referer", + SchemaName: "referer", + Null: !r.Flags.Has(0), + }, } return typ } +// SetFlags sets flags for non-zero fields. +func (r *ContactsResolveUsernameRequest) SetFlags() { + if !(r.Referer == "") { + r.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (r *ContactsResolveUsernameRequest) Encode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode contacts.resolveUsername#f93ccba3 as nil") + return fmt.Errorf("can't encode contacts.resolveUsername#725afbbc as nil") } b.PutID(ContactsResolveUsernameRequestTypeID) return r.EncodeBare(b) @@ -121,19 +150,26 @@ func (r *ContactsResolveUsernameRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (r *ContactsResolveUsernameRequest) EncodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode contacts.resolveUsername#f93ccba3 as nil") + return fmt.Errorf("can't encode contacts.resolveUsername#725afbbc as nil") + } + r.SetFlags() + if err := r.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode contacts.resolveUsername#725afbbc: field flags: %w", err) } b.PutString(r.Username) + if r.Flags.Has(0) { + b.PutString(r.Referer) + } return nil } // Decode implements bin.Decoder. func (r *ContactsResolveUsernameRequest) Decode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode contacts.resolveUsername#f93ccba3 to nil") + return fmt.Errorf("can't decode contacts.resolveUsername#725afbbc to nil") } if err := b.ConsumeID(ContactsResolveUsernameRequestTypeID); err != nil { - return fmt.Errorf("unable to decode contacts.resolveUsername#f93ccba3: %w", err) + return fmt.Errorf("unable to decode contacts.resolveUsername#725afbbc: %w", err) } return r.DecodeBare(b) } @@ -141,15 +177,27 @@ func (r *ContactsResolveUsernameRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (r *ContactsResolveUsernameRequest) DecodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode contacts.resolveUsername#f93ccba3 to nil") + return fmt.Errorf("can't decode contacts.resolveUsername#725afbbc to nil") + } + { + if err := r.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode contacts.resolveUsername#725afbbc: field flags: %w", err) + } } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode contacts.resolveUsername#f93ccba3: field username: %w", err) + return fmt.Errorf("unable to decode contacts.resolveUsername#725afbbc: field username: %w", err) } r.Username = value } + if r.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode contacts.resolveUsername#725afbbc: field referer: %w", err) + } + r.Referer = value + } return nil } @@ -161,7 +209,25 @@ func (r *ContactsResolveUsernameRequest) GetUsername() (value string) { return r.Username } -// ContactsResolveUsername invokes method contacts.resolveUsername#f93ccba3 returning error if any. +// SetReferer sets value of Referer conditional field. +func (r *ContactsResolveUsernameRequest) SetReferer(value string) { + r.Flags.Set(0) + r.Referer = value +} + +// GetReferer returns value of Referer conditional field and +// boolean which is true if field was set. +func (r *ContactsResolveUsernameRequest) GetReferer() (value string, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(0) { + return value, false + } + return r.Referer, true +} + +// ContactsResolveUsername invokes method contacts.resolveUsername#725afbbc returning error if any. // Resolve a @username to get peer info // // Possible errors: @@ -172,12 +238,9 @@ func (r *ContactsResolveUsernameRequest) GetUsername() (value string) { // // See https://core.telegram.org/method/contacts.resolveUsername for reference. // Can be used by bots. -func (c *Client) ContactsResolveUsername(ctx context.Context, username string) (*ContactsResolvedPeer, error) { +func (c *Client) ContactsResolveUsername(ctx context.Context, request *ContactsResolveUsernameRequest) (*ContactsResolvedPeer, error) { var result ContactsResolvedPeer - request := &ContactsResolveUsernameRequest{ - Username: username, - } if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } diff --git a/tg/tl_handlers_gen.go b/tg/tl_handlers_gen.go index 1abb09997e..4579f781cc 100644 --- a/tg/tl_handlers_gen.go +++ b/tg/tl_handlers_gen.go @@ -1515,13 +1515,3 @@ func (u UpdateDispatcher) OnPaidReactionPrivacy(handler PaidReactionPrivacyHandl return handler(ctx, e, update.(*UpdatePaidReactionPrivacy)) } } - -// BotSubscriptionExpireHandler is a BotSubscriptionExpire event handler. -type BotSubscriptionExpireHandler func(ctx context.Context, e Entities, update *UpdateBotSubscriptionExpire) error - -// OnBotSubscriptionExpire sets BotSubscriptionExpire handler. -func (u UpdateDispatcher) OnBotSubscriptionExpire(handler BotSubscriptionExpireHandler) { - u.handlers[UpdateBotSubscriptionExpireTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { - return handler(ctx, e, update.(*UpdateBotSubscriptionExpire)) - } -} diff --git a/tg/tl_message_action_gen.go b/tg/tl_message_action_gen.go index ea9583e2be..662ace2108 100644 --- a/tg/tl_message_action_gen.go +++ b/tg/tl_message_action_gen.go @@ -1907,7 +1907,7 @@ func (m *MessageActionGameScore) GetScore() (value int) { return m.Score } -// MessageActionPaymentSentMe represents TL type `messageActionPaymentSentMe#8f31b327`. +// MessageActionPaymentSentMe represents TL type `messageActionPaymentSentMe#ffa00ccc`. // A user just sent a payment to me (a bot) // // See https://core.telegram.org/constructor/messageActionPaymentSentMe for reference. @@ -1947,10 +1947,14 @@ type MessageActionPaymentSentMe struct { ShippingOptionID string // Provider payment identifier Charge PaymentCharge + // SubscriptionUntilDate field of MessageActionPaymentSentMe. + // + // Use SetSubscriptionUntilDate and GetSubscriptionUntilDate helpers. + SubscriptionUntilDate int } // MessageActionPaymentSentMeTypeID is TL type id of MessageActionPaymentSentMe. -const MessageActionPaymentSentMeTypeID = 0x8f31b327 +const MessageActionPaymentSentMeTypeID = 0xffa00ccc // construct implements constructor of MessageActionClass. func (m MessageActionPaymentSentMe) construct() MessageActionClass { return &m } @@ -1996,6 +2000,9 @@ func (m *MessageActionPaymentSentMe) Zero() bool { if !(m.Charge.Zero()) { return false } + if !(m.SubscriptionUntilDate == 0) { + return false + } return true } @@ -2019,6 +2026,7 @@ func (m *MessageActionPaymentSentMe) FillFrom(from interface { GetInfo() (value PaymentRequestedInfo, ok bool) GetShippingOptionID() (value string, ok bool) GetCharge() (value PaymentCharge) + GetSubscriptionUntilDate() (value int, ok bool) }) { m.RecurringInit = from.GetRecurringInit() m.RecurringUsed = from.GetRecurringUsed() @@ -2034,6 +2042,10 @@ func (m *MessageActionPaymentSentMe) FillFrom(from interface { } m.Charge = from.GetCharge() + if val, ok := from.GetSubscriptionUntilDate(); ok { + m.SubscriptionUntilDate = val + } + } // TypeID returns type id in TL schema. @@ -2095,6 +2107,11 @@ func (m *MessageActionPaymentSentMe) TypeInfo() tdp.Type { Name: "Charge", SchemaName: "charge", }, + { + Name: "SubscriptionUntilDate", + SchemaName: "subscription_until_date", + Null: !m.Flags.Has(4), + }, } return typ } @@ -2113,12 +2130,15 @@ func (m *MessageActionPaymentSentMe) SetFlags() { if !(m.ShippingOptionID == "") { m.Flags.Set(1) } + if !(m.SubscriptionUntilDate == 0) { + m.Flags.Set(4) + } } // Encode implements bin.Encoder. func (m *MessageActionPaymentSentMe) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageActionPaymentSentMe#8f31b327 as nil") + return fmt.Errorf("can't encode messageActionPaymentSentMe#ffa00ccc as nil") } b.PutID(MessageActionPaymentSentMeTypeID) return m.EncodeBare(b) @@ -2127,25 +2147,28 @@ func (m *MessageActionPaymentSentMe) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *MessageActionPaymentSentMe) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageActionPaymentSentMe#8f31b327 as nil") + return fmt.Errorf("can't encode messageActionPaymentSentMe#ffa00ccc as nil") } m.SetFlags() if err := m.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageActionPaymentSentMe#8f31b327: field flags: %w", err) + return fmt.Errorf("unable to encode messageActionPaymentSentMe#ffa00ccc: field flags: %w", err) } b.PutString(m.Currency) b.PutLong(m.TotalAmount) b.PutBytes(m.Payload) if m.Flags.Has(0) { if err := m.Info.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageActionPaymentSentMe#8f31b327: field info: %w", err) + return fmt.Errorf("unable to encode messageActionPaymentSentMe#ffa00ccc: field info: %w", err) } } if m.Flags.Has(1) { b.PutString(m.ShippingOptionID) } if err := m.Charge.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageActionPaymentSentMe#8f31b327: field charge: %w", err) + return fmt.Errorf("unable to encode messageActionPaymentSentMe#ffa00ccc: field charge: %w", err) + } + if m.Flags.Has(4) { + b.PutInt(m.SubscriptionUntilDate) } return nil } @@ -2153,10 +2176,10 @@ func (m *MessageActionPaymentSentMe) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (m *MessageActionPaymentSentMe) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageActionPaymentSentMe#8f31b327 to nil") + return fmt.Errorf("can't decode messageActionPaymentSentMe#ffa00ccc to nil") } if err := b.ConsumeID(MessageActionPaymentSentMeTypeID); err != nil { - return fmt.Errorf("unable to decode messageActionPaymentSentMe#8f31b327: %w", err) + return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: %w", err) } return m.DecodeBare(b) } @@ -2164,11 +2187,11 @@ func (m *MessageActionPaymentSentMe) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *MessageActionPaymentSentMe) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageActionPaymentSentMe#8f31b327 to nil") + return fmt.Errorf("can't decode messageActionPaymentSentMe#ffa00ccc to nil") } { if err := m.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messageActionPaymentSentMe#8f31b327: field flags: %w", err) + return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field flags: %w", err) } } m.RecurringInit = m.Flags.Has(2) @@ -2176,41 +2199,48 @@ func (m *MessageActionPaymentSentMe) DecodeBare(b *bin.Buffer) error { { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messageActionPaymentSentMe#8f31b327: field currency: %w", err) + return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field currency: %w", err) } m.Currency = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messageActionPaymentSentMe#8f31b327: field total_amount: %w", err) + return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field total_amount: %w", err) } m.TotalAmount = value } { value, err := b.Bytes() if err != nil { - return fmt.Errorf("unable to decode messageActionPaymentSentMe#8f31b327: field payload: %w", err) + return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field payload: %w", err) } m.Payload = value } if m.Flags.Has(0) { if err := m.Info.Decode(b); err != nil { - return fmt.Errorf("unable to decode messageActionPaymentSentMe#8f31b327: field info: %w", err) + return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field info: %w", err) } } if m.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messageActionPaymentSentMe#8f31b327: field shipping_option_id: %w", err) + return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field shipping_option_id: %w", err) } m.ShippingOptionID = value } { if err := m.Charge.Decode(b); err != nil { - return fmt.Errorf("unable to decode messageActionPaymentSentMe#8f31b327: field charge: %w", err) + return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field charge: %w", err) } } + if m.Flags.Has(4) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field subscription_until_date: %w", err) + } + m.SubscriptionUntilDate = value + } return nil } @@ -2320,7 +2350,25 @@ func (m *MessageActionPaymentSentMe) GetCharge() (value PaymentCharge) { return m.Charge } -// MessageActionPaymentSent represents TL type `messageActionPaymentSent#96163f56`. +// SetSubscriptionUntilDate sets value of SubscriptionUntilDate conditional field. +func (m *MessageActionPaymentSentMe) SetSubscriptionUntilDate(value int) { + m.Flags.Set(4) + m.SubscriptionUntilDate = value +} + +// GetSubscriptionUntilDate returns value of SubscriptionUntilDate conditional field and +// boolean which is true if field was set. +func (m *MessageActionPaymentSentMe) GetSubscriptionUntilDate() (value int, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(4) { + return value, false + } + return m.SubscriptionUntilDate, true +} + +// MessageActionPaymentSent represents TL type `messageActionPaymentSent#c624b16e`. // A payment was sent // // See https://core.telegram.org/constructor/messageActionPaymentSent for reference. @@ -2357,10 +2405,14 @@ type MessageActionPaymentSent struct { // // Use SetInvoiceSlug and GetInvoiceSlug helpers. InvoiceSlug string + // SubscriptionUntilDate field of MessageActionPaymentSent. + // + // Use SetSubscriptionUntilDate and GetSubscriptionUntilDate helpers. + SubscriptionUntilDate int } // MessageActionPaymentSentTypeID is TL type id of MessageActionPaymentSent. -const MessageActionPaymentSentTypeID = 0x96163f56 +const MessageActionPaymentSentTypeID = 0xc624b16e // construct implements constructor of MessageActionClass. func (m MessageActionPaymentSent) construct() MessageActionClass { return &m } @@ -2397,6 +2449,9 @@ func (m *MessageActionPaymentSent) Zero() bool { if !(m.InvoiceSlug == "") { return false } + if !(m.SubscriptionUntilDate == 0) { + return false + } return true } @@ -2417,6 +2472,7 @@ func (m *MessageActionPaymentSent) FillFrom(from interface { GetCurrency() (value string) GetTotalAmount() (value int64) GetInvoiceSlug() (value string, ok bool) + GetSubscriptionUntilDate() (value int, ok bool) }) { m.RecurringInit = from.GetRecurringInit() m.RecurringUsed = from.GetRecurringUsed() @@ -2426,6 +2482,10 @@ func (m *MessageActionPaymentSent) FillFrom(from interface { m.InvoiceSlug = val } + if val, ok := from.GetSubscriptionUntilDate(); ok { + m.SubscriptionUntilDate = val + } + } // TypeID returns type id in TL schema. @@ -2474,6 +2534,11 @@ func (m *MessageActionPaymentSent) TypeInfo() tdp.Type { SchemaName: "invoice_slug", Null: !m.Flags.Has(0), }, + { + Name: "SubscriptionUntilDate", + SchemaName: "subscription_until_date", + Null: !m.Flags.Has(4), + }, } return typ } @@ -2489,12 +2554,15 @@ func (m *MessageActionPaymentSent) SetFlags() { if !(m.InvoiceSlug == "") { m.Flags.Set(0) } + if !(m.SubscriptionUntilDate == 0) { + m.Flags.Set(4) + } } // Encode implements bin.Encoder. func (m *MessageActionPaymentSent) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageActionPaymentSent#96163f56 as nil") + return fmt.Errorf("can't encode messageActionPaymentSent#c624b16e as nil") } b.PutID(MessageActionPaymentSentTypeID) return m.EncodeBare(b) @@ -2503,27 +2571,30 @@ func (m *MessageActionPaymentSent) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *MessageActionPaymentSent) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageActionPaymentSent#96163f56 as nil") + return fmt.Errorf("can't encode messageActionPaymentSent#c624b16e as nil") } m.SetFlags() if err := m.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageActionPaymentSent#96163f56: field flags: %w", err) + return fmt.Errorf("unable to encode messageActionPaymentSent#c624b16e: field flags: %w", err) } b.PutString(m.Currency) b.PutLong(m.TotalAmount) if m.Flags.Has(0) { b.PutString(m.InvoiceSlug) } + if m.Flags.Has(4) { + b.PutInt(m.SubscriptionUntilDate) + } return nil } // Decode implements bin.Decoder. func (m *MessageActionPaymentSent) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageActionPaymentSent#96163f56 to nil") + return fmt.Errorf("can't decode messageActionPaymentSent#c624b16e to nil") } if err := b.ConsumeID(MessageActionPaymentSentTypeID); err != nil { - return fmt.Errorf("unable to decode messageActionPaymentSent#96163f56: %w", err) + return fmt.Errorf("unable to decode messageActionPaymentSent#c624b16e: %w", err) } return m.DecodeBare(b) } @@ -2531,11 +2602,11 @@ func (m *MessageActionPaymentSent) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *MessageActionPaymentSent) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageActionPaymentSent#96163f56 to nil") + return fmt.Errorf("can't decode messageActionPaymentSent#c624b16e to nil") } { if err := m.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messageActionPaymentSent#96163f56: field flags: %w", err) + return fmt.Errorf("unable to decode messageActionPaymentSent#c624b16e: field flags: %w", err) } } m.RecurringInit = m.Flags.Has(2) @@ -2543,24 +2614,31 @@ func (m *MessageActionPaymentSent) DecodeBare(b *bin.Buffer) error { { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messageActionPaymentSent#96163f56: field currency: %w", err) + return fmt.Errorf("unable to decode messageActionPaymentSent#c624b16e: field currency: %w", err) } m.Currency = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messageActionPaymentSent#96163f56: field total_amount: %w", err) + return fmt.Errorf("unable to decode messageActionPaymentSent#c624b16e: field total_amount: %w", err) } m.TotalAmount = value } if m.Flags.Has(0) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messageActionPaymentSent#96163f56: field invoice_slug: %w", err) + return fmt.Errorf("unable to decode messageActionPaymentSent#c624b16e: field invoice_slug: %w", err) } m.InvoiceSlug = value } + if m.Flags.Has(4) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messageActionPaymentSent#c624b16e: field subscription_until_date: %w", err) + } + m.SubscriptionUntilDate = value + } return nil } @@ -2636,6 +2714,24 @@ func (m *MessageActionPaymentSent) GetInvoiceSlug() (value string, ok bool) { return m.InvoiceSlug, true } +// SetSubscriptionUntilDate sets value of SubscriptionUntilDate conditional field. +func (m *MessageActionPaymentSent) SetSubscriptionUntilDate(value int) { + m.Flags.Set(4) + m.SubscriptionUntilDate = value +} + +// GetSubscriptionUntilDate returns value of SubscriptionUntilDate conditional field and +// boolean which is true if field was set. +func (m *MessageActionPaymentSent) GetSubscriptionUntilDate() (value int, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(4) { + return value, false + } + return m.SubscriptionUntilDate, true +} + // MessageActionPhoneCall represents TL type `messageActionPhoneCall#80e11a7f`. // A phone call // @@ -9610,8 +9706,8 @@ const MessageActionClassName = "MessageAction" // case *tg.MessageActionPinMessage: // messageActionPinMessage#94bd38ed // case *tg.MessageActionHistoryClear: // messageActionHistoryClear#9fbab604 // case *tg.MessageActionGameScore: // messageActionGameScore#92a72876 -// case *tg.MessageActionPaymentSentMe: // messageActionPaymentSentMe#8f31b327 -// case *tg.MessageActionPaymentSent: // messageActionPaymentSent#96163f56 +// case *tg.MessageActionPaymentSentMe: // messageActionPaymentSentMe#ffa00ccc +// case *tg.MessageActionPaymentSent: // messageActionPaymentSent#c624b16e // case *tg.MessageActionPhoneCall: // messageActionPhoneCall#80e11a7f // case *tg.MessageActionScreenshotTaken: // messageActionScreenshotTaken#4792929b // case *tg.MessageActionCustomAction: // messageActionCustomAction#fae69f56 @@ -9770,14 +9866,14 @@ func DecodeMessageAction(buf *bin.Buffer) (MessageActionClass, error) { } return &v, nil case MessageActionPaymentSentMeTypeID: - // Decoding messageActionPaymentSentMe#8f31b327. + // Decoding messageActionPaymentSentMe#ffa00ccc. v := MessageActionPaymentSentMe{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) } return &v, nil case MessageActionPaymentSentTypeID: - // Decoding messageActionPaymentSent#96163f56. + // Decoding messageActionPaymentSent#c624b16e. v := MessageActionPaymentSent{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) diff --git a/tg/tl_messages_found_stickers_gen.go b/tg/tl_messages_found_stickers_gen.go new file mode 100644 index 0000000000..7c3284133c --- /dev/null +++ b/tg/tl_messages_found_stickers_gen.go @@ -0,0 +1,560 @@ +// 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{} +) + +// MessagesFoundStickersNotModified represents TL type `messages.foundStickersNotModified#6010c534`. +// +// See https://core.telegram.org/constructor/messages.foundStickersNotModified for reference. +type MessagesFoundStickersNotModified struct { + // Flags field of MessagesFoundStickersNotModified. + Flags bin.Fields + // NextOffset field of MessagesFoundStickersNotModified. + // + // Use SetNextOffset and GetNextOffset helpers. + NextOffset int +} + +// MessagesFoundStickersNotModifiedTypeID is TL type id of MessagesFoundStickersNotModified. +const MessagesFoundStickersNotModifiedTypeID = 0x6010c534 + +// construct implements constructor of MessagesFoundStickersClass. +func (f MessagesFoundStickersNotModified) construct() MessagesFoundStickersClass { return &f } + +// Ensuring interfaces in compile-time for MessagesFoundStickersNotModified. +var ( + _ bin.Encoder = &MessagesFoundStickersNotModified{} + _ bin.Decoder = &MessagesFoundStickersNotModified{} + _ bin.BareEncoder = &MessagesFoundStickersNotModified{} + _ bin.BareDecoder = &MessagesFoundStickersNotModified{} + + _ MessagesFoundStickersClass = &MessagesFoundStickersNotModified{} +) + +func (f *MessagesFoundStickersNotModified) Zero() bool { + if f == nil { + return true + } + if !(f.Flags.Zero()) { + return false + } + if !(f.NextOffset == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (f *MessagesFoundStickersNotModified) String() string { + if f == nil { + return "MessagesFoundStickersNotModified(nil)" + } + type Alias MessagesFoundStickersNotModified + return fmt.Sprintf("MessagesFoundStickersNotModified%+v", Alias(*f)) +} + +// FillFrom fills MessagesFoundStickersNotModified from given interface. +func (f *MessagesFoundStickersNotModified) FillFrom(from interface { + GetNextOffset() (value int, ok bool) +}) { + if val, ok := from.GetNextOffset(); ok { + f.NextOffset = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesFoundStickersNotModified) TypeID() uint32 { + return MessagesFoundStickersNotModifiedTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesFoundStickersNotModified) TypeName() string { + return "messages.foundStickersNotModified" +} + +// TypeInfo returns info about TL type. +func (f *MessagesFoundStickersNotModified) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.foundStickersNotModified", + ID: MessagesFoundStickersNotModifiedTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "NextOffset", + SchemaName: "next_offset", + Null: !f.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (f *MessagesFoundStickersNotModified) SetFlags() { + if !(f.NextOffset == 0) { + f.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (f *MessagesFoundStickersNotModified) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode messages.foundStickersNotModified#6010c534 as nil") + } + b.PutID(MessagesFoundStickersNotModifiedTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *MessagesFoundStickersNotModified) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode messages.foundStickersNotModified#6010c534 as nil") + } + f.SetFlags() + if err := f.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.foundStickersNotModified#6010c534: field flags: %w", err) + } + if f.Flags.Has(0) { + b.PutInt(f.NextOffset) + } + return nil +} + +// Decode implements bin.Decoder. +func (f *MessagesFoundStickersNotModified) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode messages.foundStickersNotModified#6010c534 to nil") + } + if err := b.ConsumeID(MessagesFoundStickersNotModifiedTypeID); err != nil { + return fmt.Errorf("unable to decode messages.foundStickersNotModified#6010c534: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *MessagesFoundStickersNotModified) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode messages.foundStickersNotModified#6010c534 to nil") + } + { + if err := f.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.foundStickersNotModified#6010c534: field flags: %w", err) + } + } + if f.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.foundStickersNotModified#6010c534: field next_offset: %w", err) + } + f.NextOffset = value + } + return nil +} + +// SetNextOffset sets value of NextOffset conditional field. +func (f *MessagesFoundStickersNotModified) SetNextOffset(value int) { + f.Flags.Set(0) + f.NextOffset = value +} + +// GetNextOffset returns value of NextOffset conditional field and +// boolean which is true if field was set. +func (f *MessagesFoundStickersNotModified) GetNextOffset() (value int, ok bool) { + if f == nil { + return + } + if !f.Flags.Has(0) { + return value, false + } + return f.NextOffset, true +} + +// MessagesFoundStickers represents TL type `messages.foundStickers#82c9e290`. +// +// See https://core.telegram.org/constructor/messages.foundStickers for reference. +type MessagesFoundStickers struct { + // Flags field of MessagesFoundStickers. + Flags bin.Fields + // NextOffset field of MessagesFoundStickers. + // + // Use SetNextOffset and GetNextOffset helpers. + NextOffset int + // Hash field of MessagesFoundStickers. + Hash int64 + // Stickers field of MessagesFoundStickers. + Stickers []DocumentClass +} + +// MessagesFoundStickersTypeID is TL type id of MessagesFoundStickers. +const MessagesFoundStickersTypeID = 0x82c9e290 + +// construct implements constructor of MessagesFoundStickersClass. +func (f MessagesFoundStickers) construct() MessagesFoundStickersClass { return &f } + +// Ensuring interfaces in compile-time for MessagesFoundStickers. +var ( + _ bin.Encoder = &MessagesFoundStickers{} + _ bin.Decoder = &MessagesFoundStickers{} + _ bin.BareEncoder = &MessagesFoundStickers{} + _ bin.BareDecoder = &MessagesFoundStickers{} + + _ MessagesFoundStickersClass = &MessagesFoundStickers{} +) + +func (f *MessagesFoundStickers) Zero() bool { + if f == nil { + return true + } + if !(f.Flags.Zero()) { + return false + } + if !(f.NextOffset == 0) { + return false + } + if !(f.Hash == 0) { + return false + } + if !(f.Stickers == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (f *MessagesFoundStickers) String() string { + if f == nil { + return "MessagesFoundStickers(nil)" + } + type Alias MessagesFoundStickers + return fmt.Sprintf("MessagesFoundStickers%+v", Alias(*f)) +} + +// FillFrom fills MessagesFoundStickers from given interface. +func (f *MessagesFoundStickers) FillFrom(from interface { + GetNextOffset() (value int, ok bool) + GetHash() (value int64) + GetStickers() (value []DocumentClass) +}) { + if val, ok := from.GetNextOffset(); ok { + f.NextOffset = val + } + + f.Hash = from.GetHash() + f.Stickers = from.GetStickers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesFoundStickers) TypeID() uint32 { + return MessagesFoundStickersTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesFoundStickers) TypeName() string { + return "messages.foundStickers" +} + +// TypeInfo returns info about TL type. +func (f *MessagesFoundStickers) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.foundStickers", + ID: MessagesFoundStickersTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "NextOffset", + SchemaName: "next_offset", + Null: !f.Flags.Has(0), + }, + { + Name: "Hash", + SchemaName: "hash", + }, + { + Name: "Stickers", + SchemaName: "stickers", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (f *MessagesFoundStickers) SetFlags() { + if !(f.NextOffset == 0) { + f.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (f *MessagesFoundStickers) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode messages.foundStickers#82c9e290 as nil") + } + b.PutID(MessagesFoundStickersTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *MessagesFoundStickers) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode messages.foundStickers#82c9e290 as nil") + } + f.SetFlags() + if err := f.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.foundStickers#82c9e290: field flags: %w", err) + } + if f.Flags.Has(0) { + b.PutInt(f.NextOffset) + } + b.PutLong(f.Hash) + b.PutVectorHeader(len(f.Stickers)) + for idx, v := range f.Stickers { + if v == nil { + return fmt.Errorf("unable to encode messages.foundStickers#82c9e290: field stickers element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.foundStickers#82c9e290: field stickers element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (f *MessagesFoundStickers) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode messages.foundStickers#82c9e290 to nil") + } + if err := b.ConsumeID(MessagesFoundStickersTypeID); err != nil { + return fmt.Errorf("unable to decode messages.foundStickers#82c9e290: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *MessagesFoundStickers) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode messages.foundStickers#82c9e290 to nil") + } + { + if err := f.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.foundStickers#82c9e290: field flags: %w", err) + } + } + if f.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.foundStickers#82c9e290: field next_offset: %w", err) + } + f.NextOffset = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messages.foundStickers#82c9e290: field hash: %w", err) + } + f.Hash = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.foundStickers#82c9e290: field stickers: %w", err) + } + + if headerLen > 0 { + f.Stickers = make([]DocumentClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeDocument(b) + if err != nil { + return fmt.Errorf("unable to decode messages.foundStickers#82c9e290: field stickers: %w", err) + } + f.Stickers = append(f.Stickers, value) + } + } + return nil +} + +// SetNextOffset sets value of NextOffset conditional field. +func (f *MessagesFoundStickers) SetNextOffset(value int) { + f.Flags.Set(0) + f.NextOffset = value +} + +// GetNextOffset returns value of NextOffset conditional field and +// boolean which is true if field was set. +func (f *MessagesFoundStickers) GetNextOffset() (value int, ok bool) { + if f == nil { + return + } + if !f.Flags.Has(0) { + return value, false + } + return f.NextOffset, true +} + +// GetHash returns value of Hash field. +func (f *MessagesFoundStickers) GetHash() (value int64) { + if f == nil { + return + } + return f.Hash +} + +// GetStickers returns value of Stickers field. +func (f *MessagesFoundStickers) GetStickers() (value []DocumentClass) { + if f == nil { + return + } + return f.Stickers +} + +// MapStickers returns field Stickers wrapped in DocumentClassArray helper. +func (f *MessagesFoundStickers) MapStickers() (value DocumentClassArray) { + return DocumentClassArray(f.Stickers) +} + +// MessagesFoundStickersClassName is schema name of MessagesFoundStickersClass. +const MessagesFoundStickersClassName = "messages.FoundStickers" + +// MessagesFoundStickersClass represents messages.FoundStickers generic type. +// +// See https://core.telegram.org/type/messages.FoundStickers for reference. +// +// Example: +// +// g, err := tg.DecodeMessagesFoundStickers(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.MessagesFoundStickersNotModified: // messages.foundStickersNotModified#6010c534 +// case *tg.MessagesFoundStickers: // messages.foundStickers#82c9e290 +// default: panic(v) +// } +type MessagesFoundStickersClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() MessagesFoundStickersClass + + // 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 + + // NextOffset field of MessagesFoundStickersNotModified. + GetNextOffset() (value int, ok bool) + + // AsModified tries to map MessagesFoundStickersClass to MessagesFoundStickers. + AsModified() (*MessagesFoundStickers, bool) +} + +// AsModified tries to map MessagesFoundStickersNotModified to MessagesFoundStickers. +func (f *MessagesFoundStickersNotModified) AsModified() (*MessagesFoundStickers, bool) { + return nil, false +} + +// AsModified tries to map MessagesFoundStickers to MessagesFoundStickers. +func (f *MessagesFoundStickers) AsModified() (*MessagesFoundStickers, bool) { + return f, true +} + +// DecodeMessagesFoundStickers implements binary de-serialization for MessagesFoundStickersClass. +func DecodeMessagesFoundStickers(buf *bin.Buffer) (MessagesFoundStickersClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case MessagesFoundStickersNotModifiedTypeID: + // Decoding messages.foundStickersNotModified#6010c534. + v := MessagesFoundStickersNotModified{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessagesFoundStickersClass: %w", err) + } + return &v, nil + case MessagesFoundStickersTypeID: + // Decoding messages.foundStickers#82c9e290. + v := MessagesFoundStickers{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessagesFoundStickersClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode MessagesFoundStickersClass: %w", bin.NewUnexpectedID(id)) + } +} + +// MessagesFoundStickers boxes the MessagesFoundStickersClass providing a helper. +type MessagesFoundStickersBox struct { + FoundStickers MessagesFoundStickersClass +} + +// Decode implements bin.Decoder for MessagesFoundStickersBox. +func (b *MessagesFoundStickersBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode MessagesFoundStickersBox to nil") + } + v, err := DecodeMessagesFoundStickers(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.FoundStickers = v + return nil +} + +// Encode implements bin.Encode for MessagesFoundStickersBox. +func (b *MessagesFoundStickersBox) Encode(buf *bin.Buffer) error { + if b == nil || b.FoundStickers == nil { + return fmt.Errorf("unable to encode MessagesFoundStickersClass as nil") + } + return b.FoundStickers.Encode(buf) +} diff --git a/tg/tl_messages_found_stickers_slices_gen.go b/tg/tl_messages_found_stickers_slices_gen.go new file mode 100644 index 0000000000..d515da1d09 --- /dev/null +++ b/tg/tl_messages_found_stickers_slices_gen.go @@ -0,0 +1,362 @@ +//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{} +) + +// MessagesFoundStickersClassArray is adapter for slice of MessagesFoundStickersClass. +type MessagesFoundStickersClassArray []MessagesFoundStickersClass + +// Sort sorts slice of MessagesFoundStickersClass. +func (s MessagesFoundStickersClassArray) Sort(less func(a, b MessagesFoundStickersClass) bool) MessagesFoundStickersClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessagesFoundStickersClass. +func (s MessagesFoundStickersClassArray) SortStable(less func(a, b MessagesFoundStickersClass) bool) MessagesFoundStickersClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessagesFoundStickersClass. +func (s MessagesFoundStickersClassArray) Retain(keep func(x MessagesFoundStickersClass) bool) MessagesFoundStickersClassArray { + 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 MessagesFoundStickersClassArray) First() (v MessagesFoundStickersClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessagesFoundStickersClassArray) Last() (v MessagesFoundStickersClass, 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 *MessagesFoundStickersClassArray) PopFirst() (v MessagesFoundStickersClass, 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 MessagesFoundStickersClass + 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 *MessagesFoundStickersClassArray) Pop() (v MessagesFoundStickersClass, 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 +} + +// AsMessagesFoundStickersNotModified returns copy with only MessagesFoundStickersNotModified constructors. +func (s MessagesFoundStickersClassArray) AsMessagesFoundStickersNotModified() (to MessagesFoundStickersNotModifiedArray) { + for _, elem := range s { + value, ok := elem.(*MessagesFoundStickersNotModified) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsMessagesFoundStickers returns copy with only MessagesFoundStickers constructors. +func (s MessagesFoundStickersClassArray) AsMessagesFoundStickers() (to MessagesFoundStickersArray) { + for _, elem := range s { + value, ok := elem.(*MessagesFoundStickers) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AppendOnlyModified appends only Modified constructors to +// given slice. +func (s MessagesFoundStickersClassArray) AppendOnlyModified(to []*MessagesFoundStickers) []*MessagesFoundStickers { + for _, elem := range s { + value, ok := elem.AsModified() + if !ok { + continue + } + to = append(to, value) + } + + return to +} + +// AsModified returns copy with only Modified constructors. +func (s MessagesFoundStickersClassArray) AsModified() (to []*MessagesFoundStickers) { + return s.AppendOnlyModified(to) +} + +// FirstAsModified returns first element of slice (if exists). +func (s MessagesFoundStickersClassArray) FirstAsModified() (v *MessagesFoundStickers, ok bool) { + value, ok := s.First() + if !ok { + return + } + return value.AsModified() +} + +// LastAsModified returns last element of slice (if exists). +func (s MessagesFoundStickersClassArray) LastAsModified() (v *MessagesFoundStickers, ok bool) { + value, ok := s.Last() + if !ok { + return + } + return value.AsModified() +} + +// PopFirstAsModified returns element of slice (if exists). +func (s *MessagesFoundStickersClassArray) PopFirstAsModified() (v *MessagesFoundStickers, ok bool) { + value, ok := s.PopFirst() + if !ok { + return + } + return value.AsModified() +} + +// PopAsModified returns element of slice (if exists). +func (s *MessagesFoundStickersClassArray) PopAsModified() (v *MessagesFoundStickers, ok bool) { + value, ok := s.Pop() + if !ok { + return + } + return value.AsModified() +} + +// MessagesFoundStickersNotModifiedArray is adapter for slice of MessagesFoundStickersNotModified. +type MessagesFoundStickersNotModifiedArray []MessagesFoundStickersNotModified + +// Sort sorts slice of MessagesFoundStickersNotModified. +func (s MessagesFoundStickersNotModifiedArray) Sort(less func(a, b MessagesFoundStickersNotModified) bool) MessagesFoundStickersNotModifiedArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessagesFoundStickersNotModified. +func (s MessagesFoundStickersNotModifiedArray) SortStable(less func(a, b MessagesFoundStickersNotModified) bool) MessagesFoundStickersNotModifiedArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessagesFoundStickersNotModified. +func (s MessagesFoundStickersNotModifiedArray) Retain(keep func(x MessagesFoundStickersNotModified) bool) MessagesFoundStickersNotModifiedArray { + 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 MessagesFoundStickersNotModifiedArray) First() (v MessagesFoundStickersNotModified, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessagesFoundStickersNotModifiedArray) Last() (v MessagesFoundStickersNotModified, 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 *MessagesFoundStickersNotModifiedArray) PopFirst() (v MessagesFoundStickersNotModified, 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 MessagesFoundStickersNotModified + 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 *MessagesFoundStickersNotModifiedArray) Pop() (v MessagesFoundStickersNotModified, 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 +} + +// MessagesFoundStickersArray is adapter for slice of MessagesFoundStickers. +type MessagesFoundStickersArray []MessagesFoundStickers + +// Sort sorts slice of MessagesFoundStickers. +func (s MessagesFoundStickersArray) Sort(less func(a, b MessagesFoundStickers) bool) MessagesFoundStickersArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessagesFoundStickers. +func (s MessagesFoundStickersArray) SortStable(less func(a, b MessagesFoundStickers) bool) MessagesFoundStickersArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessagesFoundStickers. +func (s MessagesFoundStickersArray) Retain(keep func(x MessagesFoundStickers) bool) MessagesFoundStickersArray { + 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 MessagesFoundStickersArray) First() (v MessagesFoundStickers, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessagesFoundStickersArray) Last() (v MessagesFoundStickers, 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 *MessagesFoundStickersArray) PopFirst() (v MessagesFoundStickers, 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 MessagesFoundStickers + 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 *MessagesFoundStickersArray) Pop() (v MessagesFoundStickers, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_messages_search_stickers_gen.go b/tg/tl_messages_search_stickers_gen.go new file mode 100644 index 0000000000..4b453f1ac7 --- /dev/null +++ b/tg/tl_messages_search_stickers_gen.go @@ -0,0 +1,374 @@ +// 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{} +) + +// MessagesSearchStickersRequest represents TL type `messages.searchStickers#29b1c66a`. +// +// See https://core.telegram.org/method/messages.searchStickers for reference. +type MessagesSearchStickersRequest struct { + // Flags field of MessagesSearchStickersRequest. + Flags bin.Fields + // Emojis field of MessagesSearchStickersRequest. + Emojis bool + // Q field of MessagesSearchStickersRequest. + Q string + // Emoticon field of MessagesSearchStickersRequest. + Emoticon string + // LangCode field of MessagesSearchStickersRequest. + LangCode []string + // Offset field of MessagesSearchStickersRequest. + Offset int + // Limit field of MessagesSearchStickersRequest. + Limit int + // Hash field of MessagesSearchStickersRequest. + Hash int64 +} + +// MessagesSearchStickersRequestTypeID is TL type id of MessagesSearchStickersRequest. +const MessagesSearchStickersRequestTypeID = 0x29b1c66a + +// Ensuring interfaces in compile-time for MessagesSearchStickersRequest. +var ( + _ bin.Encoder = &MessagesSearchStickersRequest{} + _ bin.Decoder = &MessagesSearchStickersRequest{} + _ bin.BareEncoder = &MessagesSearchStickersRequest{} + _ bin.BareDecoder = &MessagesSearchStickersRequest{} +) + +func (s *MessagesSearchStickersRequest) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.Emojis == false) { + return false + } + if !(s.Q == "") { + return false + } + if !(s.Emoticon == "") { + return false + } + if !(s.LangCode == nil) { + return false + } + if !(s.Offset == 0) { + return false + } + if !(s.Limit == 0) { + return false + } + if !(s.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *MessagesSearchStickersRequest) String() string { + if s == nil { + return "MessagesSearchStickersRequest(nil)" + } + type Alias MessagesSearchStickersRequest + return fmt.Sprintf("MessagesSearchStickersRequest%+v", Alias(*s)) +} + +// FillFrom fills MessagesSearchStickersRequest from given interface. +func (s *MessagesSearchStickersRequest) FillFrom(from interface { + GetEmojis() (value bool) + GetQ() (value string) + GetEmoticon() (value string) + GetLangCode() (value []string) + GetOffset() (value int) + GetLimit() (value int) + GetHash() (value int64) +}) { + s.Emojis = from.GetEmojis() + s.Q = from.GetQ() + s.Emoticon = from.GetEmoticon() + s.LangCode = from.GetLangCode() + s.Offset = from.GetOffset() + s.Limit = from.GetLimit() + s.Hash = from.GetHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesSearchStickersRequest) TypeID() uint32 { + return MessagesSearchStickersRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesSearchStickersRequest) TypeName() string { + return "messages.searchStickers" +} + +// TypeInfo returns info about TL type. +func (s *MessagesSearchStickersRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.searchStickers", + ID: MessagesSearchStickersRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Emojis", + SchemaName: "emojis", + Null: !s.Flags.Has(0), + }, + { + Name: "Q", + SchemaName: "q", + }, + { + Name: "Emoticon", + SchemaName: "emoticon", + }, + { + Name: "LangCode", + SchemaName: "lang_code", + }, + { + Name: "Offset", + SchemaName: "offset", + }, + { + Name: "Limit", + SchemaName: "limit", + }, + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *MessagesSearchStickersRequest) SetFlags() { + if !(s.Emojis == false) { + s.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (s *MessagesSearchStickersRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.searchStickers#29b1c66a as nil") + } + b.PutID(MessagesSearchStickersRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *MessagesSearchStickersRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.searchStickers#29b1c66a as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.searchStickers#29b1c66a: field flags: %w", err) + } + b.PutString(s.Q) + b.PutString(s.Emoticon) + b.PutVectorHeader(len(s.LangCode)) + for _, v := range s.LangCode { + b.PutString(v) + } + b.PutInt(s.Offset) + b.PutInt(s.Limit) + b.PutLong(s.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (s *MessagesSearchStickersRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.searchStickers#29b1c66a to nil") + } + if err := b.ConsumeID(MessagesSearchStickersRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.searchStickers#29b1c66a: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *MessagesSearchStickersRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.searchStickers#29b1c66a to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.searchStickers#29b1c66a: field flags: %w", err) + } + } + s.Emojis = s.Flags.Has(0) + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messages.searchStickers#29b1c66a: field q: %w", err) + } + s.Q = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messages.searchStickers#29b1c66a: field emoticon: %w", err) + } + s.Emoticon = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.searchStickers#29b1c66a: field lang_code: %w", err) + } + + if headerLen > 0 { + s.LangCode = 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 messages.searchStickers#29b1c66a: field lang_code: %w", err) + } + s.LangCode = append(s.LangCode, value) + } + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.searchStickers#29b1c66a: field offset: %w", err) + } + s.Offset = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.searchStickers#29b1c66a: field limit: %w", err) + } + s.Limit = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messages.searchStickers#29b1c66a: field hash: %w", err) + } + s.Hash = value + } + return nil +} + +// SetEmojis sets value of Emojis conditional field. +func (s *MessagesSearchStickersRequest) SetEmojis(value bool) { + if value { + s.Flags.Set(0) + s.Emojis = true + } else { + s.Flags.Unset(0) + s.Emojis = false + } +} + +// GetEmojis returns value of Emojis conditional field. +func (s *MessagesSearchStickersRequest) GetEmojis() (value bool) { + if s == nil { + return + } + return s.Flags.Has(0) +} + +// GetQ returns value of Q field. +func (s *MessagesSearchStickersRequest) GetQ() (value string) { + if s == nil { + return + } + return s.Q +} + +// GetEmoticon returns value of Emoticon field. +func (s *MessagesSearchStickersRequest) GetEmoticon() (value string) { + if s == nil { + return + } + return s.Emoticon +} + +// GetLangCode returns value of LangCode field. +func (s *MessagesSearchStickersRequest) GetLangCode() (value []string) { + if s == nil { + return + } + return s.LangCode +} + +// GetOffset returns value of Offset field. +func (s *MessagesSearchStickersRequest) GetOffset() (value int) { + if s == nil { + return + } + return s.Offset +} + +// GetLimit returns value of Limit field. +func (s *MessagesSearchStickersRequest) GetLimit() (value int) { + if s == nil { + return + } + return s.Limit +} + +// GetHash returns value of Hash field. +func (s *MessagesSearchStickersRequest) GetHash() (value int64) { + if s == nil { + return + } + return s.Hash +} + +// MessagesSearchStickers invokes method messages.searchStickers#29b1c66a returning error if any. +// +// See https://core.telegram.org/method/messages.searchStickers for reference. +func (c *Client) MessagesSearchStickers(ctx context.Context, request *MessagesSearchStickersRequest) (MessagesFoundStickersClass, error) { + var result MessagesFoundStickersBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.FoundStickers, nil +} diff --git a/tg/tl_messages_search_stickers_slices_gen.go b/tg/tl_messages_search_stickers_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_search_stickers_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_bot_cancel_stars_subscription_gen.go b/tg/tl_payments_bot_cancel_stars_subscription_gen.go index aa2eb5908a..64cdbd6c97 100644 --- a/tg/tl_payments_bot_cancel_stars_subscription_gen.go +++ b/tg/tl_payments_bot_cancel_stars_subscription_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// PaymentsBotCancelStarsSubscriptionRequest represents TL type `payments.botCancelStarsSubscription#57f9ece6`. +// PaymentsBotCancelStarsSubscriptionRequest represents TL type `payments.botCancelStarsSubscription#6dfa0622`. // // See https://core.telegram.org/method/payments.botCancelStarsSubscription for reference. type PaymentsBotCancelStarsSubscriptionRequest struct { @@ -41,18 +41,12 @@ type PaymentsBotCancelStarsSubscriptionRequest struct { Restore bool // UserID field of PaymentsBotCancelStarsSubscriptionRequest. UserID InputUserClass - // InvoiceSlug field of PaymentsBotCancelStarsSubscriptionRequest. - // - // Use SetInvoiceSlug and GetInvoiceSlug helpers. - InvoiceSlug string // ChargeID field of PaymentsBotCancelStarsSubscriptionRequest. - // - // Use SetChargeID and GetChargeID helpers. ChargeID string } // PaymentsBotCancelStarsSubscriptionRequestTypeID is TL type id of PaymentsBotCancelStarsSubscriptionRequest. -const PaymentsBotCancelStarsSubscriptionRequestTypeID = 0x57f9ece6 +const PaymentsBotCancelStarsSubscriptionRequestTypeID = 0x6dfa0622 // Ensuring interfaces in compile-time for PaymentsBotCancelStarsSubscriptionRequest. var ( @@ -75,9 +69,6 @@ func (b *PaymentsBotCancelStarsSubscriptionRequest) Zero() bool { if !(b.UserID == nil) { return false } - if !(b.InvoiceSlug == "") { - return false - } if !(b.ChargeID == "") { return false } @@ -98,19 +89,11 @@ func (b *PaymentsBotCancelStarsSubscriptionRequest) String() string { func (b *PaymentsBotCancelStarsSubscriptionRequest) FillFrom(from interface { GetRestore() (value bool) GetUserID() (value InputUserClass) - GetInvoiceSlug() (value string, ok bool) - GetChargeID() (value string, ok bool) + GetChargeID() (value string) }) { b.Restore = from.GetRestore() b.UserID = from.GetUserID() - if val, ok := from.GetInvoiceSlug(); ok { - b.InvoiceSlug = val - } - - if val, ok := from.GetChargeID(); ok { - b.ChargeID = val - } - + b.ChargeID = from.GetChargeID() } // TypeID returns type id in TL schema. @@ -145,15 +128,9 @@ func (b *PaymentsBotCancelStarsSubscriptionRequest) TypeInfo() tdp.Type { Name: "UserID", SchemaName: "user_id", }, - { - Name: "InvoiceSlug", - SchemaName: "invoice_slug", - Null: !b.Flags.Has(1), - }, { Name: "ChargeID", SchemaName: "charge_id", - Null: !b.Flags.Has(2), }, } return typ @@ -164,18 +141,12 @@ func (b *PaymentsBotCancelStarsSubscriptionRequest) SetFlags() { if !(b.Restore == false) { b.Flags.Set(0) } - if !(b.InvoiceSlug == "") { - b.Flags.Set(1) - } - if !(b.ChargeID == "") { - b.Flags.Set(2) - } } // Encode implements bin.Encoder. func (b *PaymentsBotCancelStarsSubscriptionRequest) Encode(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't encode payments.botCancelStarsSubscription#57f9ece6 as nil") + return fmt.Errorf("can't encode payments.botCancelStarsSubscription#6dfa0622 as nil") } buf.PutID(PaymentsBotCancelStarsSubscriptionRequestTypeID) return b.EncodeBare(buf) @@ -184,34 +155,29 @@ func (b *PaymentsBotCancelStarsSubscriptionRequest) Encode(buf *bin.Buffer) erro // EncodeBare implements bin.BareEncoder. func (b *PaymentsBotCancelStarsSubscriptionRequest) EncodeBare(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't encode payments.botCancelStarsSubscription#57f9ece6 as nil") + return fmt.Errorf("can't encode payments.botCancelStarsSubscription#6dfa0622 as nil") } b.SetFlags() if err := b.Flags.Encode(buf); err != nil { - return fmt.Errorf("unable to encode payments.botCancelStarsSubscription#57f9ece6: field flags: %w", err) + return fmt.Errorf("unable to encode payments.botCancelStarsSubscription#6dfa0622: field flags: %w", err) } if b.UserID == nil { - return fmt.Errorf("unable to encode payments.botCancelStarsSubscription#57f9ece6: field user_id is nil") + return fmt.Errorf("unable to encode payments.botCancelStarsSubscription#6dfa0622: field user_id is nil") } if err := b.UserID.Encode(buf); err != nil { - return fmt.Errorf("unable to encode payments.botCancelStarsSubscription#57f9ece6: field user_id: %w", err) - } - if b.Flags.Has(1) { - buf.PutString(b.InvoiceSlug) - } - if b.Flags.Has(2) { - buf.PutString(b.ChargeID) + return fmt.Errorf("unable to encode payments.botCancelStarsSubscription#6dfa0622: field user_id: %w", err) } + buf.PutString(b.ChargeID) return nil } // Decode implements bin.Decoder. func (b *PaymentsBotCancelStarsSubscriptionRequest) Decode(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't decode payments.botCancelStarsSubscription#57f9ece6 to nil") + return fmt.Errorf("can't decode payments.botCancelStarsSubscription#6dfa0622 to nil") } if err := buf.ConsumeID(PaymentsBotCancelStarsSubscriptionRequestTypeID); err != nil { - return fmt.Errorf("unable to decode payments.botCancelStarsSubscription#57f9ece6: %w", err) + return fmt.Errorf("unable to decode payments.botCancelStarsSubscription#6dfa0622: %w", err) } return b.DecodeBare(buf) } @@ -219,32 +185,25 @@ func (b *PaymentsBotCancelStarsSubscriptionRequest) Decode(buf *bin.Buffer) erro // DecodeBare implements bin.BareDecoder. func (b *PaymentsBotCancelStarsSubscriptionRequest) DecodeBare(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't decode payments.botCancelStarsSubscription#57f9ece6 to nil") + return fmt.Errorf("can't decode payments.botCancelStarsSubscription#6dfa0622 to nil") } { if err := b.Flags.Decode(buf); err != nil { - return fmt.Errorf("unable to decode payments.botCancelStarsSubscription#57f9ece6: field flags: %w", err) + return fmt.Errorf("unable to decode payments.botCancelStarsSubscription#6dfa0622: field flags: %w", err) } } b.Restore = b.Flags.Has(0) { value, err := DecodeInputUser(buf) if err != nil { - return fmt.Errorf("unable to decode payments.botCancelStarsSubscription#57f9ece6: field user_id: %w", err) + return fmt.Errorf("unable to decode payments.botCancelStarsSubscription#6dfa0622: field user_id: %w", err) } b.UserID = value } - if b.Flags.Has(1) { - value, err := buf.String() - if err != nil { - return fmt.Errorf("unable to decode payments.botCancelStarsSubscription#57f9ece6: field invoice_slug: %w", err) - } - b.InvoiceSlug = value - } - if b.Flags.Has(2) { + { value, err := buf.String() if err != nil { - return fmt.Errorf("unable to decode payments.botCancelStarsSubscription#57f9ece6: field charge_id: %w", err) + return fmt.Errorf("unable to decode payments.botCancelStarsSubscription#6dfa0622: field charge_id: %w", err) } b.ChargeID = value } @@ -278,43 +237,15 @@ func (b *PaymentsBotCancelStarsSubscriptionRequest) GetUserID() (value InputUser return b.UserID } -// SetInvoiceSlug sets value of InvoiceSlug conditional field. -func (b *PaymentsBotCancelStarsSubscriptionRequest) SetInvoiceSlug(value string) { - b.Flags.Set(1) - b.InvoiceSlug = value -} - -// GetInvoiceSlug returns value of InvoiceSlug conditional field and -// boolean which is true if field was set. -func (b *PaymentsBotCancelStarsSubscriptionRequest) GetInvoiceSlug() (value string, ok bool) { - if b == nil { - return - } - if !b.Flags.Has(1) { - return value, false - } - return b.InvoiceSlug, true -} - -// SetChargeID sets value of ChargeID conditional field. -func (b *PaymentsBotCancelStarsSubscriptionRequest) SetChargeID(value string) { - b.Flags.Set(2) - b.ChargeID = value -} - -// GetChargeID returns value of ChargeID conditional field and -// boolean which is true if field was set. -func (b *PaymentsBotCancelStarsSubscriptionRequest) GetChargeID() (value string, ok bool) { +// GetChargeID returns value of ChargeID field. +func (b *PaymentsBotCancelStarsSubscriptionRequest) GetChargeID() (value string) { if b == nil { return } - if !b.Flags.Has(2) { - return value, false - } - return b.ChargeID, true + return b.ChargeID } -// PaymentsBotCancelStarsSubscription invokes method payments.botCancelStarsSubscription#57f9ece6 returning error if any. +// PaymentsBotCancelStarsSubscription invokes method payments.botCancelStarsSubscription#6dfa0622 returning error if any. // // See https://core.telegram.org/method/payments.botCancelStarsSubscription for reference. func (c *Client) PaymentsBotCancelStarsSubscription(ctx context.Context, request *PaymentsBotCancelStarsSubscriptionRequest) (bool, error) { diff --git a/tg/tl_payments_connect_star_ref_bot_gen.go b/tg/tl_payments_connect_star_ref_bot_gen.go new file mode 100644 index 0000000000..2441e355d6 --- /dev/null +++ b/tg/tl_payments_connect_star_ref_bot_gen.go @@ -0,0 +1,210 @@ +// 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{} +) + +// PaymentsConnectStarRefBotRequest represents TL type `payments.connectStarRefBot#7ed5348a`. +// +// See https://core.telegram.org/method/payments.connectStarRefBot for reference. +type PaymentsConnectStarRefBotRequest struct { + // Peer field of PaymentsConnectStarRefBotRequest. + Peer InputPeerClass + // Bot field of PaymentsConnectStarRefBotRequest. + Bot InputUserClass +} + +// PaymentsConnectStarRefBotRequestTypeID is TL type id of PaymentsConnectStarRefBotRequest. +const PaymentsConnectStarRefBotRequestTypeID = 0x7ed5348a + +// Ensuring interfaces in compile-time for PaymentsConnectStarRefBotRequest. +var ( + _ bin.Encoder = &PaymentsConnectStarRefBotRequest{} + _ bin.Decoder = &PaymentsConnectStarRefBotRequest{} + _ bin.BareEncoder = &PaymentsConnectStarRefBotRequest{} + _ bin.BareDecoder = &PaymentsConnectStarRefBotRequest{} +) + +func (c *PaymentsConnectStarRefBotRequest) Zero() bool { + if c == nil { + return true + } + if !(c.Peer == nil) { + return false + } + if !(c.Bot == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *PaymentsConnectStarRefBotRequest) String() string { + if c == nil { + return "PaymentsConnectStarRefBotRequest(nil)" + } + type Alias PaymentsConnectStarRefBotRequest + return fmt.Sprintf("PaymentsConnectStarRefBotRequest%+v", Alias(*c)) +} + +// FillFrom fills PaymentsConnectStarRefBotRequest from given interface. +func (c *PaymentsConnectStarRefBotRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetBot() (value InputUserClass) +}) { + c.Peer = from.GetPeer() + c.Bot = from.GetBot() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsConnectStarRefBotRequest) TypeID() uint32 { + return PaymentsConnectStarRefBotRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsConnectStarRefBotRequest) TypeName() string { + return "payments.connectStarRefBot" +} + +// TypeInfo returns info about TL type. +func (c *PaymentsConnectStarRefBotRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.connectStarRefBot", + ID: PaymentsConnectStarRefBotRequestTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "Bot", + SchemaName: "bot", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *PaymentsConnectStarRefBotRequest) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode payments.connectStarRefBot#7ed5348a as nil") + } + b.PutID(PaymentsConnectStarRefBotRequestTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *PaymentsConnectStarRefBotRequest) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode payments.connectStarRefBot#7ed5348a as nil") + } + if c.Peer == nil { + return fmt.Errorf("unable to encode payments.connectStarRefBot#7ed5348a: field peer is nil") + } + if err := c.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.connectStarRefBot#7ed5348a: field peer: %w", err) + } + if c.Bot == nil { + return fmt.Errorf("unable to encode payments.connectStarRefBot#7ed5348a: field bot is nil") + } + if err := c.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.connectStarRefBot#7ed5348a: field bot: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (c *PaymentsConnectStarRefBotRequest) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode payments.connectStarRefBot#7ed5348a to nil") + } + if err := b.ConsumeID(PaymentsConnectStarRefBotRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.connectStarRefBot#7ed5348a: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *PaymentsConnectStarRefBotRequest) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode payments.connectStarRefBot#7ed5348a to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode payments.connectStarRefBot#7ed5348a: field peer: %w", err) + } + c.Peer = value + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode payments.connectStarRefBot#7ed5348a: field bot: %w", err) + } + c.Bot = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (c *PaymentsConnectStarRefBotRequest) GetPeer() (value InputPeerClass) { + if c == nil { + return + } + return c.Peer +} + +// GetBot returns value of Bot field. +func (c *PaymentsConnectStarRefBotRequest) GetBot() (value InputUserClass) { + if c == nil { + return + } + return c.Bot +} + +// PaymentsConnectStarRefBot invokes method payments.connectStarRefBot#7ed5348a returning error if any. +// +// See https://core.telegram.org/method/payments.connectStarRefBot for reference. +func (c *Client) PaymentsConnectStarRefBot(ctx context.Context, request *PaymentsConnectStarRefBotRequest) (*PaymentsConnectedStarRefBots, error) { + var result PaymentsConnectedStarRefBots + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_payments_connect_star_ref_bot_slices_gen.go b/tg/tl_payments_connect_star_ref_bot_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_connect_star_ref_bot_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_connected_star_ref_bots_gen.go b/tg/tl_payments_connected_star_ref_bots_gen.go new file mode 100644 index 0000000000..d15b699754 --- /dev/null +++ b/tg/tl_payments_connected_star_ref_bots_gen.go @@ -0,0 +1,253 @@ +// 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{} +) + +// PaymentsConnectedStarRefBots represents TL type `payments.connectedStarRefBots#98d5ea1d`. +// +// See https://core.telegram.org/constructor/payments.connectedStarRefBots for reference. +type PaymentsConnectedStarRefBots struct { + // Count field of PaymentsConnectedStarRefBots. + Count int + // ConnectedBots field of PaymentsConnectedStarRefBots. + ConnectedBots []ConnectedBotStarRef + // Users field of PaymentsConnectedStarRefBots. + Users []UserClass +} + +// PaymentsConnectedStarRefBotsTypeID is TL type id of PaymentsConnectedStarRefBots. +const PaymentsConnectedStarRefBotsTypeID = 0x98d5ea1d + +// Ensuring interfaces in compile-time for PaymentsConnectedStarRefBots. +var ( + _ bin.Encoder = &PaymentsConnectedStarRefBots{} + _ bin.Decoder = &PaymentsConnectedStarRefBots{} + _ bin.BareEncoder = &PaymentsConnectedStarRefBots{} + _ bin.BareDecoder = &PaymentsConnectedStarRefBots{} +) + +func (c *PaymentsConnectedStarRefBots) Zero() bool { + if c == nil { + return true + } + if !(c.Count == 0) { + return false + } + if !(c.ConnectedBots == nil) { + return false + } + if !(c.Users == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *PaymentsConnectedStarRefBots) String() string { + if c == nil { + return "PaymentsConnectedStarRefBots(nil)" + } + type Alias PaymentsConnectedStarRefBots + return fmt.Sprintf("PaymentsConnectedStarRefBots%+v", Alias(*c)) +} + +// FillFrom fills PaymentsConnectedStarRefBots from given interface. +func (c *PaymentsConnectedStarRefBots) FillFrom(from interface { + GetCount() (value int) + GetConnectedBots() (value []ConnectedBotStarRef) + GetUsers() (value []UserClass) +}) { + c.Count = from.GetCount() + c.ConnectedBots = from.GetConnectedBots() + c.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsConnectedStarRefBots) TypeID() uint32 { + return PaymentsConnectedStarRefBotsTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsConnectedStarRefBots) TypeName() string { + return "payments.connectedStarRefBots" +} + +// TypeInfo returns info about TL type. +func (c *PaymentsConnectedStarRefBots) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.connectedStarRefBots", + ID: PaymentsConnectedStarRefBotsTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Count", + SchemaName: "count", + }, + { + Name: "ConnectedBots", + SchemaName: "connected_bots", + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *PaymentsConnectedStarRefBots) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode payments.connectedStarRefBots#98d5ea1d as nil") + } + b.PutID(PaymentsConnectedStarRefBotsTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *PaymentsConnectedStarRefBots) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode payments.connectedStarRefBots#98d5ea1d as nil") + } + b.PutInt(c.Count) + b.PutVectorHeader(len(c.ConnectedBots)) + for idx, v := range c.ConnectedBots { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.connectedStarRefBots#98d5ea1d: field connected_bots element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(c.Users)) + for idx, v := range c.Users { + if v == nil { + return fmt.Errorf("unable to encode payments.connectedStarRefBots#98d5ea1d: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.connectedStarRefBots#98d5ea1d: field users element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (c *PaymentsConnectedStarRefBots) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode payments.connectedStarRefBots#98d5ea1d to nil") + } + if err := b.ConsumeID(PaymentsConnectedStarRefBotsTypeID); err != nil { + return fmt.Errorf("unable to decode payments.connectedStarRefBots#98d5ea1d: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *PaymentsConnectedStarRefBots) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode payments.connectedStarRefBots#98d5ea1d to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.connectedStarRefBots#98d5ea1d: field count: %w", err) + } + c.Count = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.connectedStarRefBots#98d5ea1d: field connected_bots: %w", err) + } + + if headerLen > 0 { + c.ConnectedBots = make([]ConnectedBotStarRef, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value ConnectedBotStarRef + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.connectedStarRefBots#98d5ea1d: field connected_bots: %w", err) + } + c.ConnectedBots = append(c.ConnectedBots, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.connectedStarRefBots#98d5ea1d: field users: %w", err) + } + + if headerLen > 0 { + c.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeUser(b) + if err != nil { + return fmt.Errorf("unable to decode payments.connectedStarRefBots#98d5ea1d: field users: %w", err) + } + c.Users = append(c.Users, value) + } + } + return nil +} + +// GetCount returns value of Count field. +func (c *PaymentsConnectedStarRefBots) GetCount() (value int) { + if c == nil { + return + } + return c.Count +} + +// GetConnectedBots returns value of ConnectedBots field. +func (c *PaymentsConnectedStarRefBots) GetConnectedBots() (value []ConnectedBotStarRef) { + if c == nil { + return + } + return c.ConnectedBots +} + +// GetUsers returns value of Users field. +func (c *PaymentsConnectedStarRefBots) GetUsers() (value []UserClass) { + if c == nil { + return + } + return c.Users +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (c *PaymentsConnectedStarRefBots) MapUsers() (value UserClassArray) { + return UserClassArray(c.Users) +} diff --git a/tg/tl_payments_connected_star_ref_bots_slices_gen.go b/tg/tl_payments_connected_star_ref_bots_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_connected_star_ref_bots_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_payments_edit_connected_star_ref_bot_gen.go b/tg/tl_payments_edit_connected_star_ref_bot_gen.go new file mode 100644 index 0000000000..fc95a8d97a --- /dev/null +++ b/tg/tl_payments_edit_connected_star_ref_bot_gen.go @@ -0,0 +1,258 @@ +// 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{} +) + +// PaymentsEditConnectedStarRefBotRequest represents TL type `payments.editConnectedStarRefBot#e4fca4a3`. +// +// See https://core.telegram.org/method/payments.editConnectedStarRefBot for reference. +type PaymentsEditConnectedStarRefBotRequest struct { + // Flags field of PaymentsEditConnectedStarRefBotRequest. + Flags bin.Fields + // Revoked field of PaymentsEditConnectedStarRefBotRequest. + Revoked bool + // Peer field of PaymentsEditConnectedStarRefBotRequest. + Peer InputPeerClass + // Link field of PaymentsEditConnectedStarRefBotRequest. + Link string +} + +// PaymentsEditConnectedStarRefBotRequestTypeID is TL type id of PaymentsEditConnectedStarRefBotRequest. +const PaymentsEditConnectedStarRefBotRequestTypeID = 0xe4fca4a3 + +// Ensuring interfaces in compile-time for PaymentsEditConnectedStarRefBotRequest. +var ( + _ bin.Encoder = &PaymentsEditConnectedStarRefBotRequest{} + _ bin.Decoder = &PaymentsEditConnectedStarRefBotRequest{} + _ bin.BareEncoder = &PaymentsEditConnectedStarRefBotRequest{} + _ bin.BareDecoder = &PaymentsEditConnectedStarRefBotRequest{} +) + +func (e *PaymentsEditConnectedStarRefBotRequest) Zero() bool { + if e == nil { + return true + } + if !(e.Flags.Zero()) { + return false + } + if !(e.Revoked == false) { + return false + } + if !(e.Peer == nil) { + return false + } + if !(e.Link == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *PaymentsEditConnectedStarRefBotRequest) String() string { + if e == nil { + return "PaymentsEditConnectedStarRefBotRequest(nil)" + } + type Alias PaymentsEditConnectedStarRefBotRequest + return fmt.Sprintf("PaymentsEditConnectedStarRefBotRequest%+v", Alias(*e)) +} + +// FillFrom fills PaymentsEditConnectedStarRefBotRequest from given interface. +func (e *PaymentsEditConnectedStarRefBotRequest) FillFrom(from interface { + GetRevoked() (value bool) + GetPeer() (value InputPeerClass) + GetLink() (value string) +}) { + e.Revoked = from.GetRevoked() + e.Peer = from.GetPeer() + e.Link = from.GetLink() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsEditConnectedStarRefBotRequest) TypeID() uint32 { + return PaymentsEditConnectedStarRefBotRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsEditConnectedStarRefBotRequest) TypeName() string { + return "payments.editConnectedStarRefBot" +} + +// TypeInfo returns info about TL type. +func (e *PaymentsEditConnectedStarRefBotRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.editConnectedStarRefBot", + ID: PaymentsEditConnectedStarRefBotRequestTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Revoked", + SchemaName: "revoked", + Null: !e.Flags.Has(0), + }, + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "Link", + SchemaName: "link", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (e *PaymentsEditConnectedStarRefBotRequest) SetFlags() { + if !(e.Revoked == false) { + e.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (e *PaymentsEditConnectedStarRefBotRequest) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode payments.editConnectedStarRefBot#e4fca4a3 as nil") + } + b.PutID(PaymentsEditConnectedStarRefBotRequestTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *PaymentsEditConnectedStarRefBotRequest) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode payments.editConnectedStarRefBot#e4fca4a3 as nil") + } + e.SetFlags() + if err := e.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.editConnectedStarRefBot#e4fca4a3: field flags: %w", err) + } + if e.Peer == nil { + return fmt.Errorf("unable to encode payments.editConnectedStarRefBot#e4fca4a3: field peer is nil") + } + if err := e.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.editConnectedStarRefBot#e4fca4a3: field peer: %w", err) + } + b.PutString(e.Link) + return nil +} + +// Decode implements bin.Decoder. +func (e *PaymentsEditConnectedStarRefBotRequest) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode payments.editConnectedStarRefBot#e4fca4a3 to nil") + } + if err := b.ConsumeID(PaymentsEditConnectedStarRefBotRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.editConnectedStarRefBot#e4fca4a3: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *PaymentsEditConnectedStarRefBotRequest) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode payments.editConnectedStarRefBot#e4fca4a3 to nil") + } + { + if err := e.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.editConnectedStarRefBot#e4fca4a3: field flags: %w", err) + } + } + e.Revoked = e.Flags.Has(0) + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode payments.editConnectedStarRefBot#e4fca4a3: field peer: %w", err) + } + e.Peer = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.editConnectedStarRefBot#e4fca4a3: field link: %w", err) + } + e.Link = value + } + return nil +} + +// SetRevoked sets value of Revoked conditional field. +func (e *PaymentsEditConnectedStarRefBotRequest) SetRevoked(value bool) { + if value { + e.Flags.Set(0) + e.Revoked = true + } else { + e.Flags.Unset(0) + e.Revoked = false + } +} + +// GetRevoked returns value of Revoked conditional field. +func (e *PaymentsEditConnectedStarRefBotRequest) GetRevoked() (value bool) { + if e == nil { + return + } + return e.Flags.Has(0) +} + +// GetPeer returns value of Peer field. +func (e *PaymentsEditConnectedStarRefBotRequest) GetPeer() (value InputPeerClass) { + if e == nil { + return + } + return e.Peer +} + +// GetLink returns value of Link field. +func (e *PaymentsEditConnectedStarRefBotRequest) GetLink() (value string) { + if e == nil { + return + } + return e.Link +} + +// PaymentsEditConnectedStarRefBot invokes method payments.editConnectedStarRefBot#e4fca4a3 returning error if any. +// +// See https://core.telegram.org/method/payments.editConnectedStarRefBot for reference. +func (c *Client) PaymentsEditConnectedStarRefBot(ctx context.Context, request *PaymentsEditConnectedStarRefBotRequest) (*PaymentsConnectedStarRefBots, error) { + var result PaymentsConnectedStarRefBots + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_payments_edit_connected_star_ref_bot_slices_gen.go b/tg/tl_payments_edit_connected_star_ref_bot_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_edit_connected_star_ref_bot_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_payments_get_connected_star_ref_bot_gen.go b/tg/tl_payments_get_connected_star_ref_bot_gen.go new file mode 100644 index 0000000000..90ded662ca --- /dev/null +++ b/tg/tl_payments_get_connected_star_ref_bot_gen.go @@ -0,0 +1,210 @@ +// 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{} +) + +// PaymentsGetConnectedStarRefBotRequest represents TL type `payments.getConnectedStarRefBot#b7d998f0`. +// +// See https://core.telegram.org/method/payments.getConnectedStarRefBot for reference. +type PaymentsGetConnectedStarRefBotRequest struct { + // Peer field of PaymentsGetConnectedStarRefBotRequest. + Peer InputPeerClass + // Bot field of PaymentsGetConnectedStarRefBotRequest. + Bot InputUserClass +} + +// PaymentsGetConnectedStarRefBotRequestTypeID is TL type id of PaymentsGetConnectedStarRefBotRequest. +const PaymentsGetConnectedStarRefBotRequestTypeID = 0xb7d998f0 + +// Ensuring interfaces in compile-time for PaymentsGetConnectedStarRefBotRequest. +var ( + _ bin.Encoder = &PaymentsGetConnectedStarRefBotRequest{} + _ bin.Decoder = &PaymentsGetConnectedStarRefBotRequest{} + _ bin.BareEncoder = &PaymentsGetConnectedStarRefBotRequest{} + _ bin.BareDecoder = &PaymentsGetConnectedStarRefBotRequest{} +) + +func (g *PaymentsGetConnectedStarRefBotRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Peer == nil) { + return false + } + if !(g.Bot == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGetConnectedStarRefBotRequest) String() string { + if g == nil { + return "PaymentsGetConnectedStarRefBotRequest(nil)" + } + type Alias PaymentsGetConnectedStarRefBotRequest + return fmt.Sprintf("PaymentsGetConnectedStarRefBotRequest%+v", Alias(*g)) +} + +// FillFrom fills PaymentsGetConnectedStarRefBotRequest from given interface. +func (g *PaymentsGetConnectedStarRefBotRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetBot() (value InputUserClass) +}) { + g.Peer = from.GetPeer() + g.Bot = from.GetBot() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsGetConnectedStarRefBotRequest) TypeID() uint32 { + return PaymentsGetConnectedStarRefBotRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGetConnectedStarRefBotRequest) TypeName() string { + return "payments.getConnectedStarRefBot" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGetConnectedStarRefBotRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.getConnectedStarRefBot", + ID: PaymentsGetConnectedStarRefBotRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "Bot", + SchemaName: "bot", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *PaymentsGetConnectedStarRefBotRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getConnectedStarRefBot#b7d998f0 as nil") + } + b.PutID(PaymentsGetConnectedStarRefBotRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGetConnectedStarRefBotRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getConnectedStarRefBot#b7d998f0 as nil") + } + if g.Peer == nil { + return fmt.Errorf("unable to encode payments.getConnectedStarRefBot#b7d998f0: field peer is nil") + } + if err := g.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getConnectedStarRefBot#b7d998f0: field peer: %w", err) + } + if g.Bot == nil { + return fmt.Errorf("unable to encode payments.getConnectedStarRefBot#b7d998f0: field bot is nil") + } + if err := g.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getConnectedStarRefBot#b7d998f0: field bot: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGetConnectedStarRefBotRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getConnectedStarRefBot#b7d998f0 to nil") + } + if err := b.ConsumeID(PaymentsGetConnectedStarRefBotRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.getConnectedStarRefBot#b7d998f0: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGetConnectedStarRefBotRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getConnectedStarRefBot#b7d998f0 to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode payments.getConnectedStarRefBot#b7d998f0: field peer: %w", err) + } + g.Peer = value + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode payments.getConnectedStarRefBot#b7d998f0: field bot: %w", err) + } + g.Bot = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (g *PaymentsGetConnectedStarRefBotRequest) GetPeer() (value InputPeerClass) { + if g == nil { + return + } + return g.Peer +} + +// GetBot returns value of Bot field. +func (g *PaymentsGetConnectedStarRefBotRequest) GetBot() (value InputUserClass) { + if g == nil { + return + } + return g.Bot +} + +// PaymentsGetConnectedStarRefBot invokes method payments.getConnectedStarRefBot#b7d998f0 returning error if any. +// +// See https://core.telegram.org/method/payments.getConnectedStarRefBot for reference. +func (c *Client) PaymentsGetConnectedStarRefBot(ctx context.Context, request *PaymentsGetConnectedStarRefBotRequest) (*PaymentsConnectedStarRefBots, error) { + var result PaymentsConnectedStarRefBots + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_payments_get_connected_star_ref_bot_slices_gen.go b/tg/tl_payments_get_connected_star_ref_bot_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_get_connected_star_ref_bot_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_payments_get_connected_star_ref_bots_gen.go b/tg/tl_payments_get_connected_star_ref_bots_gen.go new file mode 100644 index 0000000000..1a6b079828 --- /dev/null +++ b/tg/tl_payments_get_connected_star_ref_bots_gen.go @@ -0,0 +1,319 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// PaymentsGetConnectedStarRefBotsRequest represents TL type `payments.getConnectedStarRefBots#5869a553`. +// +// See https://core.telegram.org/method/payments.getConnectedStarRefBots for reference. +type PaymentsGetConnectedStarRefBotsRequest struct { + // Flags field of PaymentsGetConnectedStarRefBotsRequest. + Flags bin.Fields + // Peer field of PaymentsGetConnectedStarRefBotsRequest. + Peer InputPeerClass + // OffsetDate field of PaymentsGetConnectedStarRefBotsRequest. + // + // Use SetOffsetDate and GetOffsetDate helpers. + OffsetDate int + // OffsetLink field of PaymentsGetConnectedStarRefBotsRequest. + // + // Use SetOffsetLink and GetOffsetLink helpers. + OffsetLink string + // Limit field of PaymentsGetConnectedStarRefBotsRequest. + Limit int +} + +// PaymentsGetConnectedStarRefBotsRequestTypeID is TL type id of PaymentsGetConnectedStarRefBotsRequest. +const PaymentsGetConnectedStarRefBotsRequestTypeID = 0x5869a553 + +// Ensuring interfaces in compile-time for PaymentsGetConnectedStarRefBotsRequest. +var ( + _ bin.Encoder = &PaymentsGetConnectedStarRefBotsRequest{} + _ bin.Decoder = &PaymentsGetConnectedStarRefBotsRequest{} + _ bin.BareEncoder = &PaymentsGetConnectedStarRefBotsRequest{} + _ bin.BareDecoder = &PaymentsGetConnectedStarRefBotsRequest{} +) + +func (g *PaymentsGetConnectedStarRefBotsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Flags.Zero()) { + return false + } + if !(g.Peer == nil) { + return false + } + if !(g.OffsetDate == 0) { + return false + } + if !(g.OffsetLink == "") { + return false + } + if !(g.Limit == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGetConnectedStarRefBotsRequest) String() string { + if g == nil { + return "PaymentsGetConnectedStarRefBotsRequest(nil)" + } + type Alias PaymentsGetConnectedStarRefBotsRequest + return fmt.Sprintf("PaymentsGetConnectedStarRefBotsRequest%+v", Alias(*g)) +} + +// FillFrom fills PaymentsGetConnectedStarRefBotsRequest from given interface. +func (g *PaymentsGetConnectedStarRefBotsRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetOffsetDate() (value int, ok bool) + GetOffsetLink() (value string, ok bool) + GetLimit() (value int) +}) { + g.Peer = from.GetPeer() + if val, ok := from.GetOffsetDate(); ok { + g.OffsetDate = val + } + + if val, ok := from.GetOffsetLink(); ok { + g.OffsetLink = val + } + + g.Limit = from.GetLimit() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsGetConnectedStarRefBotsRequest) TypeID() uint32 { + return PaymentsGetConnectedStarRefBotsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGetConnectedStarRefBotsRequest) TypeName() string { + return "payments.getConnectedStarRefBots" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGetConnectedStarRefBotsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.getConnectedStarRefBots", + ID: PaymentsGetConnectedStarRefBotsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "OffsetDate", + SchemaName: "offset_date", + Null: !g.Flags.Has(2), + }, + { + Name: "OffsetLink", + SchemaName: "offset_link", + Null: !g.Flags.Has(2), + }, + { + Name: "Limit", + SchemaName: "limit", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (g *PaymentsGetConnectedStarRefBotsRequest) SetFlags() { + if !(g.OffsetDate == 0) { + g.Flags.Set(2) + } + if !(g.OffsetLink == "") { + g.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (g *PaymentsGetConnectedStarRefBotsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getConnectedStarRefBots#5869a553 as nil") + } + b.PutID(PaymentsGetConnectedStarRefBotsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGetConnectedStarRefBotsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getConnectedStarRefBots#5869a553 as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getConnectedStarRefBots#5869a553: field flags: %w", err) + } + if g.Peer == nil { + return fmt.Errorf("unable to encode payments.getConnectedStarRefBots#5869a553: field peer is nil") + } + if err := g.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getConnectedStarRefBots#5869a553: field peer: %w", err) + } + if g.Flags.Has(2) { + b.PutInt(g.OffsetDate) + } + if g.Flags.Has(2) { + b.PutString(g.OffsetLink) + } + b.PutInt(g.Limit) + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGetConnectedStarRefBotsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getConnectedStarRefBots#5869a553 to nil") + } + if err := b.ConsumeID(PaymentsGetConnectedStarRefBotsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.getConnectedStarRefBots#5869a553: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGetConnectedStarRefBotsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getConnectedStarRefBots#5869a553 to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.getConnectedStarRefBots#5869a553: field flags: %w", err) + } + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode payments.getConnectedStarRefBots#5869a553: field peer: %w", err) + } + g.Peer = value + } + if g.Flags.Has(2) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.getConnectedStarRefBots#5869a553: field offset_date: %w", err) + } + g.OffsetDate = value + } + if g.Flags.Has(2) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.getConnectedStarRefBots#5869a553: field offset_link: %w", err) + } + g.OffsetLink = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.getConnectedStarRefBots#5869a553: field limit: %w", err) + } + g.Limit = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (g *PaymentsGetConnectedStarRefBotsRequest) GetPeer() (value InputPeerClass) { + if g == nil { + return + } + return g.Peer +} + +// SetOffsetDate sets value of OffsetDate conditional field. +func (g *PaymentsGetConnectedStarRefBotsRequest) SetOffsetDate(value int) { + g.Flags.Set(2) + g.OffsetDate = value +} + +// GetOffsetDate returns value of OffsetDate conditional field and +// boolean which is true if field was set. +func (g *PaymentsGetConnectedStarRefBotsRequest) GetOffsetDate() (value int, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(2) { + return value, false + } + return g.OffsetDate, true +} + +// SetOffsetLink sets value of OffsetLink conditional field. +func (g *PaymentsGetConnectedStarRefBotsRequest) SetOffsetLink(value string) { + g.Flags.Set(2) + g.OffsetLink = value +} + +// GetOffsetLink returns value of OffsetLink conditional field and +// boolean which is true if field was set. +func (g *PaymentsGetConnectedStarRefBotsRequest) GetOffsetLink() (value string, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(2) { + return value, false + } + return g.OffsetLink, true +} + +// GetLimit returns value of Limit field. +func (g *PaymentsGetConnectedStarRefBotsRequest) GetLimit() (value int) { + if g == nil { + return + } + return g.Limit +} + +// PaymentsGetConnectedStarRefBots invokes method payments.getConnectedStarRefBots#5869a553 returning error if any. +// +// See https://core.telegram.org/method/payments.getConnectedStarRefBots for reference. +func (c *Client) PaymentsGetConnectedStarRefBots(ctx context.Context, request *PaymentsGetConnectedStarRefBotsRequest) (*PaymentsConnectedStarRefBots, error) { + var result PaymentsConnectedStarRefBots + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_payments_get_connected_star_ref_bots_slices_gen.go b/tg/tl_payments_get_connected_star_ref_bots_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_get_connected_star_ref_bots_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_payments_get_suggested_star_ref_bots_gen.go b/tg/tl_payments_get_suggested_star_ref_bots_gen.go new file mode 100644 index 0000000000..1fbfc8ca43 --- /dev/null +++ b/tg/tl_payments_get_suggested_star_ref_bots_gen.go @@ -0,0 +1,320 @@ +// 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{} +) + +// PaymentsGetSuggestedStarRefBotsRequest represents TL type `payments.getSuggestedStarRefBots#d6b48f7`. +// +// See https://core.telegram.org/method/payments.getSuggestedStarRefBots for reference. +type PaymentsGetSuggestedStarRefBotsRequest struct { + // Flags field of PaymentsGetSuggestedStarRefBotsRequest. + Flags bin.Fields + // OrderByRevenue field of PaymentsGetSuggestedStarRefBotsRequest. + OrderByRevenue bool + // OrderByDate field of PaymentsGetSuggestedStarRefBotsRequest. + OrderByDate bool + // Peer field of PaymentsGetSuggestedStarRefBotsRequest. + Peer InputPeerClass + // Offset field of PaymentsGetSuggestedStarRefBotsRequest. + Offset string + // Limit field of PaymentsGetSuggestedStarRefBotsRequest. + Limit int +} + +// PaymentsGetSuggestedStarRefBotsRequestTypeID is TL type id of PaymentsGetSuggestedStarRefBotsRequest. +const PaymentsGetSuggestedStarRefBotsRequestTypeID = 0xd6b48f7 + +// Ensuring interfaces in compile-time for PaymentsGetSuggestedStarRefBotsRequest. +var ( + _ bin.Encoder = &PaymentsGetSuggestedStarRefBotsRequest{} + _ bin.Decoder = &PaymentsGetSuggestedStarRefBotsRequest{} + _ bin.BareEncoder = &PaymentsGetSuggestedStarRefBotsRequest{} + _ bin.BareDecoder = &PaymentsGetSuggestedStarRefBotsRequest{} +) + +func (g *PaymentsGetSuggestedStarRefBotsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Flags.Zero()) { + return false + } + if !(g.OrderByRevenue == false) { + return false + } + if !(g.OrderByDate == false) { + return false + } + if !(g.Peer == nil) { + return false + } + if !(g.Offset == "") { + return false + } + if !(g.Limit == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *PaymentsGetSuggestedStarRefBotsRequest) String() string { + if g == nil { + return "PaymentsGetSuggestedStarRefBotsRequest(nil)" + } + type Alias PaymentsGetSuggestedStarRefBotsRequest + return fmt.Sprintf("PaymentsGetSuggestedStarRefBotsRequest%+v", Alias(*g)) +} + +// FillFrom fills PaymentsGetSuggestedStarRefBotsRequest from given interface. +func (g *PaymentsGetSuggestedStarRefBotsRequest) FillFrom(from interface { + GetOrderByRevenue() (value bool) + GetOrderByDate() (value bool) + GetPeer() (value InputPeerClass) + GetOffset() (value string) + GetLimit() (value int) +}) { + g.OrderByRevenue = from.GetOrderByRevenue() + g.OrderByDate = from.GetOrderByDate() + g.Peer = from.GetPeer() + g.Offset = from.GetOffset() + g.Limit = from.GetLimit() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsGetSuggestedStarRefBotsRequest) TypeID() uint32 { + return PaymentsGetSuggestedStarRefBotsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsGetSuggestedStarRefBotsRequest) TypeName() string { + return "payments.getSuggestedStarRefBots" +} + +// TypeInfo returns info about TL type. +func (g *PaymentsGetSuggestedStarRefBotsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.getSuggestedStarRefBots", + ID: PaymentsGetSuggestedStarRefBotsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "OrderByRevenue", + SchemaName: "order_by_revenue", + Null: !g.Flags.Has(0), + }, + { + Name: "OrderByDate", + SchemaName: "order_by_date", + Null: !g.Flags.Has(1), + }, + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "Offset", + SchemaName: "offset", + }, + { + Name: "Limit", + SchemaName: "limit", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (g *PaymentsGetSuggestedStarRefBotsRequest) SetFlags() { + if !(g.OrderByRevenue == false) { + g.Flags.Set(0) + } + if !(g.OrderByDate == false) { + g.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (g *PaymentsGetSuggestedStarRefBotsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getSuggestedStarRefBots#d6b48f7 as nil") + } + b.PutID(PaymentsGetSuggestedStarRefBotsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *PaymentsGetSuggestedStarRefBotsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode payments.getSuggestedStarRefBots#d6b48f7 as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getSuggestedStarRefBots#d6b48f7: field flags: %w", err) + } + if g.Peer == nil { + return fmt.Errorf("unable to encode payments.getSuggestedStarRefBots#d6b48f7: field peer is nil") + } + if err := g.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.getSuggestedStarRefBots#d6b48f7: field peer: %w", err) + } + b.PutString(g.Offset) + b.PutInt(g.Limit) + return nil +} + +// Decode implements bin.Decoder. +func (g *PaymentsGetSuggestedStarRefBotsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getSuggestedStarRefBots#d6b48f7 to nil") + } + if err := b.ConsumeID(PaymentsGetSuggestedStarRefBotsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode payments.getSuggestedStarRefBots#d6b48f7: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *PaymentsGetSuggestedStarRefBotsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode payments.getSuggestedStarRefBots#d6b48f7 to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.getSuggestedStarRefBots#d6b48f7: field flags: %w", err) + } + } + g.OrderByRevenue = g.Flags.Has(0) + g.OrderByDate = g.Flags.Has(1) + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode payments.getSuggestedStarRefBots#d6b48f7: field peer: %w", err) + } + g.Peer = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.getSuggestedStarRefBots#d6b48f7: field offset: %w", err) + } + g.Offset = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.getSuggestedStarRefBots#d6b48f7: field limit: %w", err) + } + g.Limit = value + } + return nil +} + +// SetOrderByRevenue sets value of OrderByRevenue conditional field. +func (g *PaymentsGetSuggestedStarRefBotsRequest) SetOrderByRevenue(value bool) { + if value { + g.Flags.Set(0) + g.OrderByRevenue = true + } else { + g.Flags.Unset(0) + g.OrderByRevenue = false + } +} + +// GetOrderByRevenue returns value of OrderByRevenue conditional field. +func (g *PaymentsGetSuggestedStarRefBotsRequest) GetOrderByRevenue() (value bool) { + if g == nil { + return + } + return g.Flags.Has(0) +} + +// SetOrderByDate sets value of OrderByDate conditional field. +func (g *PaymentsGetSuggestedStarRefBotsRequest) SetOrderByDate(value bool) { + if value { + g.Flags.Set(1) + g.OrderByDate = true + } else { + g.Flags.Unset(1) + g.OrderByDate = false + } +} + +// GetOrderByDate returns value of OrderByDate conditional field. +func (g *PaymentsGetSuggestedStarRefBotsRequest) GetOrderByDate() (value bool) { + if g == nil { + return + } + return g.Flags.Has(1) +} + +// GetPeer returns value of Peer field. +func (g *PaymentsGetSuggestedStarRefBotsRequest) GetPeer() (value InputPeerClass) { + if g == nil { + return + } + return g.Peer +} + +// GetOffset returns value of Offset field. +func (g *PaymentsGetSuggestedStarRefBotsRequest) GetOffset() (value string) { + if g == nil { + return + } + return g.Offset +} + +// GetLimit returns value of Limit field. +func (g *PaymentsGetSuggestedStarRefBotsRequest) GetLimit() (value int) { + if g == nil { + return + } + return g.Limit +} + +// PaymentsGetSuggestedStarRefBots invokes method payments.getSuggestedStarRefBots#d6b48f7 returning error if any. +// +// See https://core.telegram.org/method/payments.getSuggestedStarRefBots for reference. +func (c *Client) PaymentsGetSuggestedStarRefBots(ctx context.Context, request *PaymentsGetSuggestedStarRefBotsRequest) (*PaymentsSuggestedStarRefBots, error) { + var result PaymentsSuggestedStarRefBots + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_payments_get_suggested_star_ref_bots_slices_gen.go b/tg/tl_payments_get_suggested_star_ref_bots_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_get_suggested_star_ref_bots_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_payments_stars_status_gen.go b/tg/tl_payments_stars_status_gen.go index 8a112146aa..4db650683c 100644 --- a/tg/tl_payments_stars_status_gen.go +++ b/tg/tl_payments_stars_status_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// PaymentsStarsStatus represents TL type `payments.starsStatus#bbfa316c`. +// PaymentsStarsStatus represents TL type `payments.starsStatus#6c9ce8ed`. // Info about the current Telegram Star subscriptions, balance and transaction history // »¹. // @@ -46,7 +46,7 @@ type PaymentsStarsStatus struct { // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields // Current Telegram Star balance. - Balance int64 + Balance StarsAmount // Info about current Telegram Star subscriptions, only returned when invoking payments // getStarsTransactions¹ and payments.getStarsSubscriptions². // @@ -92,7 +92,7 @@ type PaymentsStarsStatus struct { } // PaymentsStarsStatusTypeID is TL type id of PaymentsStarsStatus. -const PaymentsStarsStatusTypeID = 0xbbfa316c +const PaymentsStarsStatusTypeID = 0x6c9ce8ed // Ensuring interfaces in compile-time for PaymentsStarsStatus. var ( @@ -109,7 +109,7 @@ func (s *PaymentsStarsStatus) Zero() bool { if !(s.Flags.Zero()) { return false } - if !(s.Balance == 0) { + if !(s.Balance.Zero()) { return false } if !(s.Subscriptions == nil) { @@ -148,7 +148,7 @@ func (s *PaymentsStarsStatus) String() string { // FillFrom fills PaymentsStarsStatus from given interface. func (s *PaymentsStarsStatus) FillFrom(from interface { - GetBalance() (value int64) + GetBalance() (value StarsAmount) GetSubscriptions() (value []StarsSubscription, ok bool) GetSubscriptionsNextOffset() (value string, ok bool) GetSubscriptionsMissingBalance() (value int64, ok bool) @@ -268,7 +268,7 @@ func (s *PaymentsStarsStatus) SetFlags() { // Encode implements bin.Encoder. func (s *PaymentsStarsStatus) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode payments.starsStatus#bbfa316c as nil") + return fmt.Errorf("can't encode payments.starsStatus#6c9ce8ed as nil") } b.PutID(PaymentsStarsStatusTypeID) return s.EncodeBare(b) @@ -277,18 +277,20 @@ func (s *PaymentsStarsStatus) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *PaymentsStarsStatus) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode payments.starsStatus#bbfa316c as nil") + return fmt.Errorf("can't encode payments.starsStatus#6c9ce8ed as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode payments.starsStatus#bbfa316c: field flags: %w", err) + return fmt.Errorf("unable to encode payments.starsStatus#6c9ce8ed: field flags: %w", err) + } + if err := s.Balance.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.starsStatus#6c9ce8ed: field balance: %w", err) } - b.PutLong(s.Balance) if s.Flags.Has(1) { b.PutVectorHeader(len(s.Subscriptions)) for idx, v := range s.Subscriptions { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode payments.starsStatus#bbfa316c: field subscriptions element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode payments.starsStatus#6c9ce8ed: field subscriptions element with index %d: %w", idx, err) } } } @@ -302,7 +304,7 @@ func (s *PaymentsStarsStatus) EncodeBare(b *bin.Buffer) error { b.PutVectorHeader(len(s.History)) for idx, v := range s.History { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode payments.starsStatus#bbfa316c: field history element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode payments.starsStatus#6c9ce8ed: field history element with index %d: %w", idx, err) } } } @@ -312,19 +314,19 @@ func (s *PaymentsStarsStatus) EncodeBare(b *bin.Buffer) error { b.PutVectorHeader(len(s.Chats)) for idx, v := range s.Chats { if v == nil { - return fmt.Errorf("unable to encode payments.starsStatus#bbfa316c: field chats element with index %d is nil", idx) + return fmt.Errorf("unable to encode payments.starsStatus#6c9ce8ed: field chats element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode payments.starsStatus#bbfa316c: field chats element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode payments.starsStatus#6c9ce8ed: field chats element with index %d: %w", idx, err) } } b.PutVectorHeader(len(s.Users)) for idx, v := range s.Users { if v == nil { - return fmt.Errorf("unable to encode payments.starsStatus#bbfa316c: field users element with index %d is nil", idx) + return fmt.Errorf("unable to encode payments.starsStatus#6c9ce8ed: field users element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode payments.starsStatus#bbfa316c: field users element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode payments.starsStatus#6c9ce8ed: field users element with index %d: %w", idx, err) } } return nil @@ -333,10 +335,10 @@ func (s *PaymentsStarsStatus) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *PaymentsStarsStatus) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode payments.starsStatus#bbfa316c to nil") + return fmt.Errorf("can't decode payments.starsStatus#6c9ce8ed to nil") } if err := b.ConsumeID(PaymentsStarsStatusTypeID); err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: %w", err) + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: %w", err) } return s.DecodeBare(b) } @@ -344,24 +346,22 @@ func (s *PaymentsStarsStatus) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *PaymentsStarsStatus) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode payments.starsStatus#bbfa316c to nil") + return fmt.Errorf("can't decode payments.starsStatus#6c9ce8ed to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: field flags: %w", err) + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: field flags: %w", err) } } { - value, err := b.Long() - if err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: field balance: %w", err) + if err := s.Balance.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: field balance: %w", err) } - s.Balance = value } if s.Flags.Has(1) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: field subscriptions: %w", err) + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: field subscriptions: %w", err) } if headerLen > 0 { @@ -370,7 +370,7 @@ func (s *PaymentsStarsStatus) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value StarsSubscription if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: field subscriptions: %w", err) + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: field subscriptions: %w", err) } s.Subscriptions = append(s.Subscriptions, value) } @@ -378,21 +378,21 @@ func (s *PaymentsStarsStatus) DecodeBare(b *bin.Buffer) error { if s.Flags.Has(2) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: field subscriptions_next_offset: %w", err) + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: field subscriptions_next_offset: %w", err) } s.SubscriptionsNextOffset = value } if s.Flags.Has(4) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: field subscriptions_missing_balance: %w", err) + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: field subscriptions_missing_balance: %w", err) } s.SubscriptionsMissingBalance = value } if s.Flags.Has(3) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: field history: %w", err) + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: field history: %w", err) } if headerLen > 0 { @@ -401,7 +401,7 @@ func (s *PaymentsStarsStatus) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value StarsTransaction if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: field history: %w", err) + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: field history: %w", err) } s.History = append(s.History, value) } @@ -409,14 +409,14 @@ func (s *PaymentsStarsStatus) DecodeBare(b *bin.Buffer) error { if s.Flags.Has(0) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: field next_offset: %w", err) + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: field next_offset: %w", err) } s.NextOffset = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: field chats: %w", err) + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: field chats: %w", err) } if headerLen > 0 { @@ -425,7 +425,7 @@ func (s *PaymentsStarsStatus) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeChat(b) if err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: field chats: %w", err) + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: field chats: %w", err) } s.Chats = append(s.Chats, value) } @@ -433,7 +433,7 @@ func (s *PaymentsStarsStatus) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: field users: %w", err) + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: field users: %w", err) } if headerLen > 0 { @@ -442,7 +442,7 @@ func (s *PaymentsStarsStatus) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeUser(b) if err != nil { - return fmt.Errorf("unable to decode payments.starsStatus#bbfa316c: field users: %w", err) + return fmt.Errorf("unable to decode payments.starsStatus#6c9ce8ed: field users: %w", err) } s.Users = append(s.Users, value) } @@ -451,7 +451,7 @@ func (s *PaymentsStarsStatus) DecodeBare(b *bin.Buffer) error { } // GetBalance returns value of Balance field. -func (s *PaymentsStarsStatus) GetBalance() (value int64) { +func (s *PaymentsStarsStatus) GetBalance() (value StarsAmount) { if s == nil { return } diff --git a/tg/tl_payments_suggested_star_ref_bots_gen.go b/tg/tl_payments_suggested_star_ref_bots_gen.go new file mode 100644 index 0000000000..cf8bd768e4 --- /dev/null +++ b/tg/tl_payments_suggested_star_ref_bots_gen.go @@ -0,0 +1,319 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// PaymentsSuggestedStarRefBots represents TL type `payments.suggestedStarRefBots#b4d5d859`. +// +// See https://core.telegram.org/constructor/payments.suggestedStarRefBots for reference. +type PaymentsSuggestedStarRefBots struct { + // Flags field of PaymentsSuggestedStarRefBots. + Flags bin.Fields + // Count field of PaymentsSuggestedStarRefBots. + Count int + // SuggestedBots field of PaymentsSuggestedStarRefBots. + SuggestedBots []StarRefProgram + // Users field of PaymentsSuggestedStarRefBots. + Users []UserClass + // NextOffset field of PaymentsSuggestedStarRefBots. + // + // Use SetNextOffset and GetNextOffset helpers. + NextOffset string +} + +// PaymentsSuggestedStarRefBotsTypeID is TL type id of PaymentsSuggestedStarRefBots. +const PaymentsSuggestedStarRefBotsTypeID = 0xb4d5d859 + +// Ensuring interfaces in compile-time for PaymentsSuggestedStarRefBots. +var ( + _ bin.Encoder = &PaymentsSuggestedStarRefBots{} + _ bin.Decoder = &PaymentsSuggestedStarRefBots{} + _ bin.BareEncoder = &PaymentsSuggestedStarRefBots{} + _ bin.BareDecoder = &PaymentsSuggestedStarRefBots{} +) + +func (s *PaymentsSuggestedStarRefBots) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.Count == 0) { + return false + } + if !(s.SuggestedBots == nil) { + return false + } + if !(s.Users == nil) { + return false + } + if !(s.NextOffset == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *PaymentsSuggestedStarRefBots) String() string { + if s == nil { + return "PaymentsSuggestedStarRefBots(nil)" + } + type Alias PaymentsSuggestedStarRefBots + return fmt.Sprintf("PaymentsSuggestedStarRefBots%+v", Alias(*s)) +} + +// FillFrom fills PaymentsSuggestedStarRefBots from given interface. +func (s *PaymentsSuggestedStarRefBots) FillFrom(from interface { + GetCount() (value int) + GetSuggestedBots() (value []StarRefProgram) + GetUsers() (value []UserClass) + GetNextOffset() (value string, ok bool) +}) { + s.Count = from.GetCount() + s.SuggestedBots = from.GetSuggestedBots() + s.Users = from.GetUsers() + if val, ok := from.GetNextOffset(); ok { + s.NextOffset = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PaymentsSuggestedStarRefBots) TypeID() uint32 { + return PaymentsSuggestedStarRefBotsTypeID +} + +// TypeName returns name of type in TL schema. +func (*PaymentsSuggestedStarRefBots) TypeName() string { + return "payments.suggestedStarRefBots" +} + +// TypeInfo returns info about TL type. +func (s *PaymentsSuggestedStarRefBots) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "payments.suggestedStarRefBots", + ID: PaymentsSuggestedStarRefBotsTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Count", + SchemaName: "count", + }, + { + Name: "SuggestedBots", + SchemaName: "suggested_bots", + }, + { + Name: "Users", + SchemaName: "users", + }, + { + Name: "NextOffset", + SchemaName: "next_offset", + Null: !s.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *PaymentsSuggestedStarRefBots) SetFlags() { + if !(s.NextOffset == "") { + s.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (s *PaymentsSuggestedStarRefBots) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode payments.suggestedStarRefBots#b4d5d859 as nil") + } + b.PutID(PaymentsSuggestedStarRefBotsTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *PaymentsSuggestedStarRefBots) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode payments.suggestedStarRefBots#b4d5d859 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.suggestedStarRefBots#b4d5d859: field flags: %w", err) + } + b.PutInt(s.Count) + b.PutVectorHeader(len(s.SuggestedBots)) + for idx, v := range s.SuggestedBots { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.suggestedStarRefBots#b4d5d859: field suggested_bots element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(s.Users)) + for idx, v := range s.Users { + if v == nil { + return fmt.Errorf("unable to encode payments.suggestedStarRefBots#b4d5d859: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode payments.suggestedStarRefBots#b4d5d859: field users element with index %d: %w", idx, err) + } + } + if s.Flags.Has(0) { + b.PutString(s.NextOffset) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *PaymentsSuggestedStarRefBots) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode payments.suggestedStarRefBots#b4d5d859 to nil") + } + if err := b.ConsumeID(PaymentsSuggestedStarRefBotsTypeID); err != nil { + return fmt.Errorf("unable to decode payments.suggestedStarRefBots#b4d5d859: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *PaymentsSuggestedStarRefBots) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode payments.suggestedStarRefBots#b4d5d859 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.suggestedStarRefBots#b4d5d859: field flags: %w", err) + } + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode payments.suggestedStarRefBots#b4d5d859: field count: %w", err) + } + s.Count = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.suggestedStarRefBots#b4d5d859: field suggested_bots: %w", err) + } + + if headerLen > 0 { + s.SuggestedBots = make([]StarRefProgram, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value StarRefProgram + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode payments.suggestedStarRefBots#b4d5d859: field suggested_bots: %w", err) + } + s.SuggestedBots = append(s.SuggestedBots, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode payments.suggestedStarRefBots#b4d5d859: field users: %w", err) + } + + if headerLen > 0 { + s.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeUser(b) + if err != nil { + return fmt.Errorf("unable to decode payments.suggestedStarRefBots#b4d5d859: field users: %w", err) + } + s.Users = append(s.Users, value) + } + } + if s.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode payments.suggestedStarRefBots#b4d5d859: field next_offset: %w", err) + } + s.NextOffset = value + } + return nil +} + +// GetCount returns value of Count field. +func (s *PaymentsSuggestedStarRefBots) GetCount() (value int) { + if s == nil { + return + } + return s.Count +} + +// GetSuggestedBots returns value of SuggestedBots field. +func (s *PaymentsSuggestedStarRefBots) GetSuggestedBots() (value []StarRefProgram) { + if s == nil { + return + } + return s.SuggestedBots +} + +// GetUsers returns value of Users field. +func (s *PaymentsSuggestedStarRefBots) GetUsers() (value []UserClass) { + if s == nil { + return + } + return s.Users +} + +// SetNextOffset sets value of NextOffset conditional field. +func (s *PaymentsSuggestedStarRefBots) SetNextOffset(value string) { + s.Flags.Set(0) + s.NextOffset = value +} + +// GetNextOffset returns value of NextOffset conditional field and +// boolean which is true if field was set. +func (s *PaymentsSuggestedStarRefBots) GetNextOffset() (value string, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.NextOffset, true +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (s *PaymentsSuggestedStarRefBots) MapUsers() (value UserClassArray) { + return UserClassArray(s.Users) +} diff --git a/tg/tl_payments_suggested_star_ref_bots_slices_gen.go b/tg/tl_payments_suggested_star_ref_bots_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_payments_suggested_star_ref_bots_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_registry_gen.go b/tg/tl_registry_gen.go index 85aaabf850..cfeb8aec51 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 193 +const Layer = 195 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -163,8 +163,8 @@ func TypesMap() map[uint32]string { MessageActionPinMessageTypeID: "messageActionPinMessage#94bd38ed", MessageActionHistoryClearTypeID: "messageActionHistoryClear#9fbab604", MessageActionGameScoreTypeID: "messageActionGameScore#92a72876", - MessageActionPaymentSentMeTypeID: "messageActionPaymentSentMe#8f31b327", - MessageActionPaymentSentTypeID: "messageActionPaymentSent#96163f56", + MessageActionPaymentSentMeTypeID: "messageActionPaymentSentMe#ffa00ccc", + MessageActionPaymentSentTypeID: "messageActionPaymentSent#c624b16e", MessageActionPhoneCallTypeID: "messageActionPhoneCall#80e11a7f", MessageActionScreenshotTakenTypeID: "messageActionScreenshotTaken#4792929b", MessageActionCustomActionTypeID: "messageActionCustomAction#fae69f56", @@ -233,7 +233,7 @@ func TypesMap() map[uint32]string { InputReportReasonFakeTypeID: "inputReportReasonFake#f5ddd6e7", InputReportReasonIllegalDrugsTypeID: "inputReportReasonIllegalDrugs#a8eb2be", InputReportReasonPersonalDetailsTypeID: "inputReportReasonPersonalDetails#9ec7863d", - UserFullTypeID: "userFull#1f58e369", + UserFullTypeID: "userFull#979d2376", ContactTypeID: "contact#145ade0b", ImportedContactTypeID: "importedContact#c13e3c50", ContactStatusTypeID: "contactStatus#16d9703b", @@ -406,12 +406,11 @@ func TypesMap() map[uint32]string { UpdateBotDeleteBusinessMessageTypeID: "updateBotDeleteBusinessMessage#a02a982e", UpdateNewStoryReactionTypeID: "updateNewStoryReaction#1824e40b", UpdateBroadcastRevenueTransactionsTypeID: "updateBroadcastRevenueTransactions#dfd961f5", - UpdateStarsBalanceTypeID: "updateStarsBalance#fb85198", + UpdateStarsBalanceTypeID: "updateStarsBalance#4e80a379", UpdateBusinessBotCallbackQueryTypeID: "updateBusinessBotCallbackQuery#1ea2fda7", UpdateStarsRevenueStatusTypeID: "updateStarsRevenueStatus#a584b019", UpdateBotPurchasedPaidMediaTypeID: "updateBotPurchasedPaidMedia#283bd312", UpdatePaidReactionPrivacyTypeID: "updatePaidReactionPrivacy#51ca7aec", - UpdateBotSubscriptionExpireTypeID: "updateBotSubscriptionExpire#2d13c6ee", UpdatesStateTypeID: "updates.state#a56c2a3e", UpdatesDifferenceEmptyTypeID: "updates.differenceEmpty#5d75a138", UpdatesDifferenceTypeID: "updates.difference#f49ca0", @@ -1379,12 +1378,12 @@ func TypesMap() map[uint32]string { StarsTransactionPeerAdsTypeID: "starsTransactionPeerAds#60682812", StarsTransactionPeerAPITypeID: "starsTransactionPeerAPI#f9677aad", StarsTopupOptionTypeID: "starsTopupOption#bd915c0", - StarsTransactionTypeID: "starsTransaction#35d4f276", - PaymentsStarsStatusTypeID: "payments.starsStatus#bbfa316c", + StarsTransactionTypeID: "starsTransaction#64dfc926", + PaymentsStarsStatusTypeID: "payments.starsStatus#6c9ce8ed", FoundStoryTypeID: "foundStory#e87acbc0", StoriesFoundStoriesTypeID: "stories.foundStories#e2de7737", GeoPointAddressTypeID: "geoPointAddress#de4c5d93", - StarsRevenueStatusTypeID: "starsRevenueStatus#79342946", + StarsRevenueStatusTypeID: "starsRevenueStatus#febe5491", PaymentsStarsRevenueStatsTypeID: "payments.starsRevenueStats#c92bb73b", PaymentsStarsRevenueWithdrawalURLTypeID: "payments.starsRevenueWithdrawalUrl#1dab80b7", PaymentsStarsRevenueAdsAccountURLTypeID: "payments.starsRevenueAdsAccountUrl#394e7f21", @@ -1410,6 +1409,13 @@ func TypesMap() map[uint32]string { MessagesBotPreparedInlineMessageTypeID: "messages.botPreparedInlineMessage#8ecf0511", MessagesPreparedInlineMessageTypeID: "messages.preparedInlineMessage#ff57708d", BotAppSettingsTypeID: "botAppSettings#c99b1950", + StarRefProgramTypeID: "starRefProgram#dd0c66f2", + ConnectedBotStarRefTypeID: "connectedBotStarRef#19a13f71", + PaymentsConnectedStarRefBotsTypeID: "payments.connectedStarRefBots#98d5ea1d", + PaymentsSuggestedStarRefBotsTypeID: "payments.suggestedStarRefBots#b4d5d859", + StarsAmountTypeID: "starsAmount#bbb6b4a3", + MessagesFoundStickersNotModifiedTypeID: "messages.foundStickersNotModified#6010c534", + MessagesFoundStickersTypeID: "messages.foundStickers#82c9e290", InvokeAfterMsgRequestTypeID: "invokeAfterMsg#cb9f372d", InvokeAfterMsgsRequestTypeID: "invokeAfterMsgs#3dc4b4f0", InitConnectionRequestTypeID: "initConnection#c1cd5ea9", @@ -1569,7 +1575,7 @@ func TypesMap() map[uint32]string { ContactsUnblockRequestTypeID: "contacts.unblock#b550d328", ContactsGetBlockedRequestTypeID: "contacts.getBlocked#9a868f80", ContactsSearchRequestTypeID: "contacts.search#11f812d8", - ContactsResolveUsernameRequestTypeID: "contacts.resolveUsername#f93ccba3", + ContactsResolveUsernameRequestTypeID: "contacts.resolveUsername#725afbbc", ContactsGetTopPeersRequestTypeID: "contacts.getTopPeers#973478b6", ContactsResetTopPeerRatingRequestTypeID: "contacts.resetTopPeerRating#1ae373ac", ContactsResetSavedRequestTypeID: "contacts.resetSaved#879537f1", @@ -1808,6 +1814,7 @@ func TypesMap() map[uint32]string { MessagesGetSponsoredMessagesRequestTypeID: "messages.getSponsoredMessages#9bd2f439", MessagesSavePreparedInlineMessageRequestTypeID: "messages.savePreparedInlineMessage#f21f7f2f", MessagesGetPreparedInlineMessageRequestTypeID: "messages.getPreparedInlineMessage#857ebdb8", + MessagesSearchStickersRequestTypeID: "messages.searchStickers#29b1c66a", UpdatesGetStateRequestTypeID: "updates.getState#edd4882a", UpdatesGetDifferenceRequestTypeID: "updates.getDifference#19c2f763", UpdatesGetChannelDifferenceRequestTypeID: "updates.getChannelDifference#3173d78", @@ -1936,6 +1943,8 @@ func TypesMap() map[uint32]string { BotsUpdateUserEmojiStatusRequestTypeID: "bots.updateUserEmojiStatus#ed9f30c5", BotsToggleUserEmojiStatusPermissionRequestTypeID: "bots.toggleUserEmojiStatusPermission#6de6392", BotsCheckDownloadFileParamsRequestTypeID: "bots.checkDownloadFileParams#50077589", + BotsGetAdminedBotsRequestTypeID: "bots.getAdminedBots#b0711d83", + BotsUpdateStarRefProgramRequestTypeID: "bots.updateStarRefProgram#778b5ab3", PaymentsGetPaymentFormRequestTypeID: "payments.getPaymentForm#37148dbb", PaymentsGetPaymentReceiptRequestTypeID: "payments.getPaymentReceipt#2478d1cc", PaymentsValidateRequestedInfoRequestTypeID: "payments.validateRequestedInfo#b6c8f12b", @@ -1970,7 +1979,12 @@ func TypesMap() map[uint32]string { PaymentsGetUserStarGiftsRequestTypeID: "payments.getUserStarGifts#5e72c7e1", PaymentsSaveStarGiftRequestTypeID: "payments.saveStarGift#87acf08e", PaymentsConvertStarGiftRequestTypeID: "payments.convertStarGift#421e027", - PaymentsBotCancelStarsSubscriptionRequestTypeID: "payments.botCancelStarsSubscription#57f9ece6", + PaymentsBotCancelStarsSubscriptionRequestTypeID: "payments.botCancelStarsSubscription#6dfa0622", + PaymentsGetConnectedStarRefBotsRequestTypeID: "payments.getConnectedStarRefBots#5869a553", + PaymentsGetConnectedStarRefBotRequestTypeID: "payments.getConnectedStarRefBot#b7d998f0", + PaymentsGetSuggestedStarRefBotsRequestTypeID: "payments.getSuggestedStarRefBots#d6b48f7", + PaymentsConnectStarRefBotRequestTypeID: "payments.connectStarRefBot#7ed5348a", + PaymentsEditConnectedStarRefBotRequestTypeID: "payments.editConnectedStarRefBot#e4fca4a3", StickersCreateStickerSetRequestTypeID: "stickers.createStickerSet#9021ab67", StickersRemoveStickerFromSetRequestTypeID: "stickers.removeStickerFromSet#f7760f51", StickersChangeStickerPositionRequestTypeID: "stickers.changeStickerPosition#ffb6d4ca", @@ -2472,7 +2486,6 @@ func NamesMap() map[string]uint32 { "updateStarsRevenueStatus": UpdateStarsRevenueStatusTypeID, "updateBotPurchasedPaidMedia": UpdateBotPurchasedPaidMediaTypeID, "updatePaidReactionPrivacy": UpdatePaidReactionPrivacyTypeID, - "updateBotSubscriptionExpire": UpdateBotSubscriptionExpireTypeID, "updates.state": UpdatesStateTypeID, "updates.differenceEmpty": UpdatesDifferenceEmptyTypeID, "updates.difference": UpdatesDifferenceTypeID, @@ -3471,6 +3484,13 @@ func NamesMap() map[string]uint32 { "messages.botPreparedInlineMessage": MessagesBotPreparedInlineMessageTypeID, "messages.preparedInlineMessage": MessagesPreparedInlineMessageTypeID, "botAppSettings": BotAppSettingsTypeID, + "starRefProgram": StarRefProgramTypeID, + "connectedBotStarRef": ConnectedBotStarRefTypeID, + "payments.connectedStarRefBots": PaymentsConnectedStarRefBotsTypeID, + "payments.suggestedStarRefBots": PaymentsSuggestedStarRefBotsTypeID, + "starsAmount": StarsAmountTypeID, + "messages.foundStickersNotModified": MessagesFoundStickersNotModifiedTypeID, + "messages.foundStickers": MessagesFoundStickersTypeID, "invokeAfterMsg": InvokeAfterMsgRequestTypeID, "invokeAfterMsgs": InvokeAfterMsgsRequestTypeID, "initConnection": InitConnectionRequestTypeID, @@ -3869,6 +3889,7 @@ func NamesMap() map[string]uint32 { "messages.getSponsoredMessages": MessagesGetSponsoredMessagesRequestTypeID, "messages.savePreparedInlineMessage": MessagesSavePreparedInlineMessageRequestTypeID, "messages.getPreparedInlineMessage": MessagesGetPreparedInlineMessageRequestTypeID, + "messages.searchStickers": MessagesSearchStickersRequestTypeID, "updates.getState": UpdatesGetStateRequestTypeID, "updates.getDifference": UpdatesGetDifferenceRequestTypeID, "updates.getChannelDifference": UpdatesGetChannelDifferenceRequestTypeID, @@ -3997,6 +4018,8 @@ func NamesMap() map[string]uint32 { "bots.updateUserEmojiStatus": BotsUpdateUserEmojiStatusRequestTypeID, "bots.toggleUserEmojiStatusPermission": BotsToggleUserEmojiStatusPermissionRequestTypeID, "bots.checkDownloadFileParams": BotsCheckDownloadFileParamsRequestTypeID, + "bots.getAdminedBots": BotsGetAdminedBotsRequestTypeID, + "bots.updateStarRefProgram": BotsUpdateStarRefProgramRequestTypeID, "payments.getPaymentForm": PaymentsGetPaymentFormRequestTypeID, "payments.getPaymentReceipt": PaymentsGetPaymentReceiptRequestTypeID, "payments.validateRequestedInfo": PaymentsValidateRequestedInfoRequestTypeID, @@ -4032,6 +4055,11 @@ func NamesMap() map[string]uint32 { "payments.saveStarGift": PaymentsSaveStarGiftRequestTypeID, "payments.convertStarGift": PaymentsConvertStarGiftRequestTypeID, "payments.botCancelStarsSubscription": PaymentsBotCancelStarsSubscriptionRequestTypeID, + "payments.getConnectedStarRefBots": PaymentsGetConnectedStarRefBotsRequestTypeID, + "payments.getConnectedStarRefBot": PaymentsGetConnectedStarRefBotRequestTypeID, + "payments.getSuggestedStarRefBots": PaymentsGetSuggestedStarRefBotsRequestTypeID, + "payments.connectStarRefBot": PaymentsConnectStarRefBotRequestTypeID, + "payments.editConnectedStarRefBot": PaymentsEditConnectedStarRefBotRequestTypeID, "stickers.createStickerSet": StickersCreateStickerSetRequestTypeID, "stickers.removeStickerFromSet": StickersRemoveStickerFromSetRequestTypeID, "stickers.changeStickerPosition": StickersChangeStickerPositionRequestTypeID, @@ -4533,7 +4561,6 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UpdateStarsRevenueStatusTypeID: func() bin.Object { return &UpdateStarsRevenueStatus{} }, UpdateBotPurchasedPaidMediaTypeID: func() bin.Object { return &UpdateBotPurchasedPaidMedia{} }, UpdatePaidReactionPrivacyTypeID: func() bin.Object { return &UpdatePaidReactionPrivacy{} }, - UpdateBotSubscriptionExpireTypeID: func() bin.Object { return &UpdateBotSubscriptionExpire{} }, UpdatesStateTypeID: func() bin.Object { return &UpdatesState{} }, UpdatesDifferenceEmptyTypeID: func() bin.Object { return &UpdatesDifferenceEmpty{} }, UpdatesDifferenceTypeID: func() bin.Object { return &UpdatesDifference{} }, @@ -5532,6 +5559,13 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessagesBotPreparedInlineMessageTypeID: func() bin.Object { return &MessagesBotPreparedInlineMessage{} }, MessagesPreparedInlineMessageTypeID: func() bin.Object { return &MessagesPreparedInlineMessage{} }, BotAppSettingsTypeID: func() bin.Object { return &BotAppSettings{} }, + StarRefProgramTypeID: func() bin.Object { return &StarRefProgram{} }, + ConnectedBotStarRefTypeID: func() bin.Object { return &ConnectedBotStarRef{} }, + PaymentsConnectedStarRefBotsTypeID: func() bin.Object { return &PaymentsConnectedStarRefBots{} }, + PaymentsSuggestedStarRefBotsTypeID: func() bin.Object { return &PaymentsSuggestedStarRefBots{} }, + StarsAmountTypeID: func() bin.Object { return &StarsAmount{} }, + MessagesFoundStickersNotModifiedTypeID: func() bin.Object { return &MessagesFoundStickersNotModified{} }, + MessagesFoundStickersTypeID: func() bin.Object { return &MessagesFoundStickers{} }, InvokeAfterMsgRequestTypeID: func() bin.Object { return &InvokeAfterMsgRequest{} }, InvokeAfterMsgsRequestTypeID: func() bin.Object { return &InvokeAfterMsgsRequest{} }, InitConnectionRequestTypeID: func() bin.Object { return &InitConnectionRequest{} }, @@ -5930,6 +5964,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessagesGetSponsoredMessagesRequestTypeID: func() bin.Object { return &MessagesGetSponsoredMessagesRequest{} }, MessagesSavePreparedInlineMessageRequestTypeID: func() bin.Object { return &MessagesSavePreparedInlineMessageRequest{} }, MessagesGetPreparedInlineMessageRequestTypeID: func() bin.Object { return &MessagesGetPreparedInlineMessageRequest{} }, + MessagesSearchStickersRequestTypeID: func() bin.Object { return &MessagesSearchStickersRequest{} }, UpdatesGetStateRequestTypeID: func() bin.Object { return &UpdatesGetStateRequest{} }, UpdatesGetDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetDifferenceRequest{} }, UpdatesGetChannelDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetChannelDifferenceRequest{} }, @@ -6058,6 +6093,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { BotsUpdateUserEmojiStatusRequestTypeID: func() bin.Object { return &BotsUpdateUserEmojiStatusRequest{} }, BotsToggleUserEmojiStatusPermissionRequestTypeID: func() bin.Object { return &BotsToggleUserEmojiStatusPermissionRequest{} }, BotsCheckDownloadFileParamsRequestTypeID: func() bin.Object { return &BotsCheckDownloadFileParamsRequest{} }, + BotsGetAdminedBotsRequestTypeID: func() bin.Object { return &BotsGetAdminedBotsRequest{} }, + BotsUpdateStarRefProgramRequestTypeID: func() bin.Object { return &BotsUpdateStarRefProgramRequest{} }, PaymentsGetPaymentFormRequestTypeID: func() bin.Object { return &PaymentsGetPaymentFormRequest{} }, PaymentsGetPaymentReceiptRequestTypeID: func() bin.Object { return &PaymentsGetPaymentReceiptRequest{} }, PaymentsValidateRequestedInfoRequestTypeID: func() bin.Object { return &PaymentsValidateRequestedInfoRequest{} }, @@ -6093,6 +6130,11 @@ func TypesConstructorMap() map[uint32]func() bin.Object { PaymentsSaveStarGiftRequestTypeID: func() bin.Object { return &PaymentsSaveStarGiftRequest{} }, PaymentsConvertStarGiftRequestTypeID: func() bin.Object { return &PaymentsConvertStarGiftRequest{} }, PaymentsBotCancelStarsSubscriptionRequestTypeID: func() bin.Object { return &PaymentsBotCancelStarsSubscriptionRequest{} }, + PaymentsGetConnectedStarRefBotsRequestTypeID: func() bin.Object { return &PaymentsGetConnectedStarRefBotsRequest{} }, + PaymentsGetConnectedStarRefBotRequestTypeID: func() bin.Object { return &PaymentsGetConnectedStarRefBotRequest{} }, + PaymentsGetSuggestedStarRefBotsRequestTypeID: func() bin.Object { return &PaymentsGetSuggestedStarRefBotsRequest{} }, + PaymentsConnectStarRefBotRequestTypeID: func() bin.Object { return &PaymentsConnectStarRefBotRequest{} }, + PaymentsEditConnectedStarRefBotRequestTypeID: func() bin.Object { return &PaymentsEditConnectedStarRefBotRequest{} }, StickersCreateStickerSetRequestTypeID: func() bin.Object { return &StickersCreateStickerSetRequest{} }, StickersRemoveStickerFromSetRequestTypeID: func() bin.Object { return &StickersRemoveStickerFromSetRequest{} }, StickersChangeStickerPositionRequestTypeID: func() bin.Object { return &StickersChangeStickerPositionRequest{} }, @@ -7074,6 +7116,10 @@ func ClassConstructorsMap() map[string][]uint32 { MessagesFoundStickerSetsNotModifiedTypeID, MessagesFoundStickerSetsTypeID, }, + MessagesFoundStickersClassName: { + MessagesFoundStickersNotModifiedTypeID, + MessagesFoundStickersTypeID, + }, MessagesMessagesClassName: { MessagesMessagesTypeID, MessagesMessagesSliceTypeID, @@ -7626,7 +7672,6 @@ func ClassConstructorsMap() map[string][]uint32 { UpdateStarsRevenueStatusTypeID, UpdateBotPurchasedPaidMediaTypeID, UpdatePaidReactionPrivacyTypeID, - UpdateBotSubscriptionExpireTypeID, }, UpdatesChannelDifferenceClassName: { UpdatesChannelDifferenceEmptyTypeID, diff --git a/tg/tl_server_gen.go b/tg/tl_server_gen.go index 72d3ad0c16..fcf46c41a3 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -2850,14 +2850,14 @@ func (s *ServerDispatcher) OnContactsSearch(f func(ctx context.Context, request s.handlers[ContactsSearchRequestTypeID] = handler } -func (s *ServerDispatcher) OnContactsResolveUsername(f func(ctx context.Context, username string) (*ContactsResolvedPeer, error)) { +func (s *ServerDispatcher) OnContactsResolveUsername(f func(ctx context.Context, request *ContactsResolveUsernameRequest) (*ContactsResolvedPeer, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request ContactsResolveUsernameRequest if err := request.Decode(b); err != nil { return nil, err } - response, err := f(ctx, request.Username) + response, err := f(ctx, &request) if err != nil { return nil, err } @@ -7153,6 +7153,23 @@ func (s *ServerDispatcher) OnMessagesGetPreparedInlineMessage(f func(ctx context s.handlers[MessagesGetPreparedInlineMessageRequestTypeID] = handler } +func (s *ServerDispatcher) OnMessagesSearchStickers(f func(ctx context.Context, request *MessagesSearchStickersRequest) (MessagesFoundStickersClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesSearchStickersRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &MessagesFoundStickersBox{FoundStickers: response}, nil + } + + s.handlers[MessagesSearchStickersRequestTypeID] = 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 @@ -9469,6 +9486,40 @@ func (s *ServerDispatcher) OnBotsCheckDownloadFileParams(f func(ctx context.Cont s.handlers[BotsCheckDownloadFileParamsRequestTypeID] = handler } +func (s *ServerDispatcher) OnBotsGetAdminedBots(f func(ctx context.Context) ([]UserClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request BotsGetAdminedBotsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx) + if err != nil { + return nil, err + } + return &UserClassVector{Elems: response}, nil + } + + s.handlers[BotsGetAdminedBotsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnBotsUpdateStarRefProgram(f func(ctx context.Context, request *BotsUpdateStarRefProgramRequest) (*StarRefProgram, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request BotsUpdateStarRefProgramRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[BotsUpdateStarRefProgramRequestTypeID] = handler +} + func (s *ServerDispatcher) OnPaymentsGetPaymentForm(f func(ctx context.Context, request *PaymentsGetPaymentFormRequest) (PaymentsPaymentFormClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request PaymentsGetPaymentFormRequest @@ -10092,6 +10143,91 @@ func (s *ServerDispatcher) OnPaymentsBotCancelStarsSubscription(f func(ctx conte s.handlers[PaymentsBotCancelStarsSubscriptionRequestTypeID] = handler } +func (s *ServerDispatcher) OnPaymentsGetConnectedStarRefBots(f func(ctx context.Context, request *PaymentsGetConnectedStarRefBotsRequest) (*PaymentsConnectedStarRefBots, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsGetConnectedStarRefBotsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[PaymentsGetConnectedStarRefBotsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsGetConnectedStarRefBot(f func(ctx context.Context, request *PaymentsGetConnectedStarRefBotRequest) (*PaymentsConnectedStarRefBots, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsGetConnectedStarRefBotRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[PaymentsGetConnectedStarRefBotRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsGetSuggestedStarRefBots(f func(ctx context.Context, request *PaymentsGetSuggestedStarRefBotsRequest) (*PaymentsSuggestedStarRefBots, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsGetSuggestedStarRefBotsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[PaymentsGetSuggestedStarRefBotsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsConnectStarRefBot(f func(ctx context.Context, request *PaymentsConnectStarRefBotRequest) (*PaymentsConnectedStarRefBots, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsConnectStarRefBotRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[PaymentsConnectStarRefBotRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnPaymentsEditConnectedStarRefBot(f func(ctx context.Context, request *PaymentsEditConnectedStarRefBotRequest) (*PaymentsConnectedStarRefBots, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PaymentsEditConnectedStarRefBotRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[PaymentsEditConnectedStarRefBotRequestTypeID] = 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_star_ref_program_gen.go b/tg/tl_star_ref_program_gen.go new file mode 100644 index 0000000000..a5b31fe946 --- /dev/null +++ b/tg/tl_star_ref_program_gen.go @@ -0,0 +1,350 @@ +// 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{} +) + +// StarRefProgram represents TL type `starRefProgram#dd0c66f2`. +// +// See https://core.telegram.org/constructor/starRefProgram for reference. +type StarRefProgram struct { + // Flags field of StarRefProgram. + Flags bin.Fields + // BotID field of StarRefProgram. + BotID int64 + // CommissionPermille field of StarRefProgram. + CommissionPermille int + // DurationMonths field of StarRefProgram. + // + // Use SetDurationMonths and GetDurationMonths helpers. + DurationMonths int + // EndDate field of StarRefProgram. + // + // Use SetEndDate and GetEndDate helpers. + EndDate int + // DailyRevenuePerUser field of StarRefProgram. + // + // Use SetDailyRevenuePerUser and GetDailyRevenuePerUser helpers. + DailyRevenuePerUser StarsAmount +} + +// StarRefProgramTypeID is TL type id of StarRefProgram. +const StarRefProgramTypeID = 0xdd0c66f2 + +// Ensuring interfaces in compile-time for StarRefProgram. +var ( + _ bin.Encoder = &StarRefProgram{} + _ bin.Decoder = &StarRefProgram{} + _ bin.BareEncoder = &StarRefProgram{} + _ bin.BareDecoder = &StarRefProgram{} +) + +func (s *StarRefProgram) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.BotID == 0) { + return false + } + if !(s.CommissionPermille == 0) { + return false + } + if !(s.DurationMonths == 0) { + return false + } + if !(s.EndDate == 0) { + return false + } + if !(s.DailyRevenuePerUser.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarRefProgram) String() string { + if s == nil { + return "StarRefProgram(nil)" + } + type Alias StarRefProgram + return fmt.Sprintf("StarRefProgram%+v", Alias(*s)) +} + +// FillFrom fills StarRefProgram from given interface. +func (s *StarRefProgram) FillFrom(from interface { + GetBotID() (value int64) + GetCommissionPermille() (value int) + GetDurationMonths() (value int, ok bool) + GetEndDate() (value int, ok bool) + GetDailyRevenuePerUser() (value StarsAmount, ok bool) +}) { + s.BotID = from.GetBotID() + s.CommissionPermille = from.GetCommissionPermille() + if val, ok := from.GetDurationMonths(); ok { + s.DurationMonths = val + } + + if val, ok := from.GetEndDate(); ok { + s.EndDate = val + } + + if val, ok := from.GetDailyRevenuePerUser(); ok { + s.DailyRevenuePerUser = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarRefProgram) TypeID() uint32 { + return StarRefProgramTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarRefProgram) TypeName() string { + return "starRefProgram" +} + +// TypeInfo returns info about TL type. +func (s *StarRefProgram) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starRefProgram", + ID: StarRefProgramTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "BotID", + SchemaName: "bot_id", + }, + { + Name: "CommissionPermille", + SchemaName: "commission_permille", + }, + { + Name: "DurationMonths", + SchemaName: "duration_months", + Null: !s.Flags.Has(0), + }, + { + Name: "EndDate", + SchemaName: "end_date", + Null: !s.Flags.Has(1), + }, + { + Name: "DailyRevenuePerUser", + SchemaName: "daily_revenue_per_user", + Null: !s.Flags.Has(2), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *StarRefProgram) SetFlags() { + if !(s.DurationMonths == 0) { + s.Flags.Set(0) + } + if !(s.EndDate == 0) { + s.Flags.Set(1) + } + if !(s.DailyRevenuePerUser.Zero()) { + s.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (s *StarRefProgram) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starRefProgram#dd0c66f2 as nil") + } + b.PutID(StarRefProgramTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarRefProgram) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starRefProgram#dd0c66f2 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode starRefProgram#dd0c66f2: field flags: %w", err) + } + b.PutLong(s.BotID) + b.PutInt(s.CommissionPermille) + if s.Flags.Has(0) { + b.PutInt(s.DurationMonths) + } + if s.Flags.Has(1) { + b.PutInt(s.EndDate) + } + if s.Flags.Has(2) { + if err := s.DailyRevenuePerUser.Encode(b); err != nil { + return fmt.Errorf("unable to encode starRefProgram#dd0c66f2: field daily_revenue_per_user: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarRefProgram) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starRefProgram#dd0c66f2 to nil") + } + if err := b.ConsumeID(StarRefProgramTypeID); err != nil { + return fmt.Errorf("unable to decode starRefProgram#dd0c66f2: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarRefProgram) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starRefProgram#dd0c66f2 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode starRefProgram#dd0c66f2: field flags: %w", err) + } + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode starRefProgram#dd0c66f2: field bot_id: %w", err) + } + s.BotID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starRefProgram#dd0c66f2: field commission_permille: %w", err) + } + s.CommissionPermille = value + } + if s.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starRefProgram#dd0c66f2: field duration_months: %w", err) + } + s.DurationMonths = value + } + if s.Flags.Has(1) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starRefProgram#dd0c66f2: field end_date: %w", err) + } + s.EndDate = value + } + if s.Flags.Has(2) { + if err := s.DailyRevenuePerUser.Decode(b); err != nil { + return fmt.Errorf("unable to decode starRefProgram#dd0c66f2: field daily_revenue_per_user: %w", err) + } + } + return nil +} + +// GetBotID returns value of BotID field. +func (s *StarRefProgram) GetBotID() (value int64) { + if s == nil { + return + } + return s.BotID +} + +// GetCommissionPermille returns value of CommissionPermille field. +func (s *StarRefProgram) GetCommissionPermille() (value int) { + if s == nil { + return + } + return s.CommissionPermille +} + +// SetDurationMonths sets value of DurationMonths conditional field. +func (s *StarRefProgram) SetDurationMonths(value int) { + s.Flags.Set(0) + s.DurationMonths = value +} + +// GetDurationMonths returns value of DurationMonths conditional field and +// boolean which is true if field was set. +func (s *StarRefProgram) GetDurationMonths() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.DurationMonths, true +} + +// SetEndDate sets value of EndDate conditional field. +func (s *StarRefProgram) SetEndDate(value int) { + s.Flags.Set(1) + s.EndDate = value +} + +// GetEndDate returns value of EndDate conditional field and +// boolean which is true if field was set. +func (s *StarRefProgram) GetEndDate() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(1) { + return value, false + } + return s.EndDate, true +} + +// SetDailyRevenuePerUser sets value of DailyRevenuePerUser conditional field. +func (s *StarRefProgram) SetDailyRevenuePerUser(value StarsAmount) { + s.Flags.Set(2) + s.DailyRevenuePerUser = value +} + +// GetDailyRevenuePerUser returns value of DailyRevenuePerUser conditional field and +// boolean which is true if field was set. +func (s *StarRefProgram) GetDailyRevenuePerUser() (value StarsAmount, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(2) { + return value, false + } + return s.DailyRevenuePerUser, true +} diff --git a/tg/tl_star_ref_program_slices_gen.go b/tg/tl_star_ref_program_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_star_ref_program_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_amount_gen.go b/tg/tl_stars_amount_gen.go new file mode 100644 index 0000000000..e28aa9ca6f --- /dev/null +++ b/tg/tl_stars_amount_gen.go @@ -0,0 +1,188 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// StarsAmount represents TL type `starsAmount#bbb6b4a3`. +// +// See https://core.telegram.org/constructor/starsAmount for reference. +type StarsAmount struct { + // Amount field of StarsAmount. + Amount int64 + // Nanos field of StarsAmount. + Nanos int +} + +// StarsAmountTypeID is TL type id of StarsAmount. +const StarsAmountTypeID = 0xbbb6b4a3 + +// Ensuring interfaces in compile-time for StarsAmount. +var ( + _ bin.Encoder = &StarsAmount{} + _ bin.Decoder = &StarsAmount{} + _ bin.BareEncoder = &StarsAmount{} + _ bin.BareDecoder = &StarsAmount{} +) + +func (s *StarsAmount) Zero() bool { + if s == nil { + return true + } + if !(s.Amount == 0) { + return false + } + if !(s.Nanos == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarsAmount) String() string { + if s == nil { + return "StarsAmount(nil)" + } + type Alias StarsAmount + return fmt.Sprintf("StarsAmount%+v", Alias(*s)) +} + +// FillFrom fills StarsAmount from given interface. +func (s *StarsAmount) FillFrom(from interface { + GetAmount() (value int64) + GetNanos() (value int) +}) { + s.Amount = from.GetAmount() + s.Nanos = from.GetNanos() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarsAmount) TypeID() uint32 { + return StarsAmountTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarsAmount) TypeName() string { + return "starsAmount" +} + +// TypeInfo returns info about TL type. +func (s *StarsAmount) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starsAmount", + ID: StarsAmountTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Amount", + SchemaName: "amount", + }, + { + Name: "Nanos", + SchemaName: "nanos", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarsAmount) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsAmount#bbb6b4a3 as nil") + } + b.PutID(StarsAmountTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarsAmount) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starsAmount#bbb6b4a3 as nil") + } + b.PutLong(s.Amount) + b.PutInt(s.Nanos) + return nil +} + +// Decode implements bin.Decoder. +func (s *StarsAmount) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsAmount#bbb6b4a3 to nil") + } + if err := b.ConsumeID(StarsAmountTypeID); err != nil { + return fmt.Errorf("unable to decode starsAmount#bbb6b4a3: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarsAmount) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starsAmount#bbb6b4a3 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode starsAmount#bbb6b4a3: field amount: %w", err) + } + s.Amount = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starsAmount#bbb6b4a3: field nanos: %w", err) + } + s.Nanos = value + } + return nil +} + +// GetAmount returns value of Amount field. +func (s *StarsAmount) GetAmount() (value int64) { + if s == nil { + return + } + return s.Amount +} + +// GetNanos returns value of Nanos field. +func (s *StarsAmount) GetNanos() (value int) { + if s == nil { + return + } + return s.Nanos +} diff --git a/tg/tl_stars_amount_slices_gen.go b/tg/tl_stars_amount_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_stars_amount_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_revenue_status_gen.go b/tg/tl_stars_revenue_status_gen.go index 8cb4bdd165..fc615574b5 100644 --- a/tg/tl_stars_revenue_status_gen.go +++ b/tg/tl_stars_revenue_status_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// StarsRevenueStatus represents TL type `starsRevenueStatus#79342946`. +// StarsRevenueStatus represents TL type `starsRevenueStatus#febe5491`. // Describes Telegram Star revenue balances »¹. // // Links: @@ -50,11 +50,11 @@ type StarsRevenueStatus struct { // 1) https://core.telegram.org/api/stars#withdrawing-revenue WithdrawalEnabled bool // Amount of not-yet-withdrawn Telegram Stars. - CurrentBalance int64 + CurrentBalance StarsAmount // Amount of withdrawable Telegram Stars. - AvailableBalance int64 + AvailableBalance StarsAmount // Total amount of earned Telegram Stars. - OverallRevenue int64 + OverallRevenue StarsAmount // Unixtime indicating when will withdrawal be available to the user. If not set, // withdrawal can be started now. // @@ -63,7 +63,7 @@ type StarsRevenueStatus struct { } // StarsRevenueStatusTypeID is TL type id of StarsRevenueStatus. -const StarsRevenueStatusTypeID = 0x79342946 +const StarsRevenueStatusTypeID = 0xfebe5491 // Ensuring interfaces in compile-time for StarsRevenueStatus. var ( @@ -83,13 +83,13 @@ func (s *StarsRevenueStatus) Zero() bool { if !(s.WithdrawalEnabled == false) { return false } - if !(s.CurrentBalance == 0) { + if !(s.CurrentBalance.Zero()) { return false } - if !(s.AvailableBalance == 0) { + if !(s.AvailableBalance.Zero()) { return false } - if !(s.OverallRevenue == 0) { + if !(s.OverallRevenue.Zero()) { return false } if !(s.NextWithdrawalAt == 0) { @@ -111,9 +111,9 @@ func (s *StarsRevenueStatus) String() string { // FillFrom fills StarsRevenueStatus from given interface. func (s *StarsRevenueStatus) FillFrom(from interface { GetWithdrawalEnabled() (value bool) - GetCurrentBalance() (value int64) - GetAvailableBalance() (value int64) - GetOverallRevenue() (value int64) + GetCurrentBalance() (value StarsAmount) + GetAvailableBalance() (value StarsAmount) + GetOverallRevenue() (value StarsAmount) GetNextWithdrawalAt() (value int, ok bool) }) { s.WithdrawalEnabled = from.GetWithdrawalEnabled() @@ -188,7 +188,7 @@ func (s *StarsRevenueStatus) SetFlags() { // Encode implements bin.Encoder. func (s *StarsRevenueStatus) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starsRevenueStatus#79342946 as nil") + return fmt.Errorf("can't encode starsRevenueStatus#febe5491 as nil") } b.PutID(StarsRevenueStatusTypeID) return s.EncodeBare(b) @@ -197,15 +197,21 @@ func (s *StarsRevenueStatus) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *StarsRevenueStatus) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starsRevenueStatus#79342946 as nil") + return fmt.Errorf("can't encode starsRevenueStatus#febe5491 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsRevenueStatus#79342946: field flags: %w", err) + return fmt.Errorf("unable to encode starsRevenueStatus#febe5491: field flags: %w", err) + } + if err := s.CurrentBalance.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsRevenueStatus#febe5491: field current_balance: %w", err) + } + if err := s.AvailableBalance.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsRevenueStatus#febe5491: field available_balance: %w", err) + } + if err := s.OverallRevenue.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsRevenueStatus#febe5491: field overall_revenue: %w", err) } - b.PutLong(s.CurrentBalance) - b.PutLong(s.AvailableBalance) - b.PutLong(s.OverallRevenue) if s.Flags.Has(1) { b.PutInt(s.NextWithdrawalAt) } @@ -215,10 +221,10 @@ func (s *StarsRevenueStatus) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *StarsRevenueStatus) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode starsRevenueStatus#79342946 to nil") + return fmt.Errorf("can't decode starsRevenueStatus#febe5491 to nil") } if err := b.ConsumeID(StarsRevenueStatusTypeID); err != nil { - return fmt.Errorf("unable to decode starsRevenueStatus#79342946: %w", err) + return fmt.Errorf("unable to decode starsRevenueStatus#febe5491: %w", err) } return s.DecodeBare(b) } @@ -226,39 +232,33 @@ func (s *StarsRevenueStatus) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *StarsRevenueStatus) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode starsRevenueStatus#79342946 to nil") + return fmt.Errorf("can't decode starsRevenueStatus#febe5491 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode starsRevenueStatus#79342946: field flags: %w", err) + return fmt.Errorf("unable to decode starsRevenueStatus#febe5491: field flags: %w", err) } } s.WithdrawalEnabled = s.Flags.Has(0) { - value, err := b.Long() - if err != nil { - return fmt.Errorf("unable to decode starsRevenueStatus#79342946: field current_balance: %w", err) + if err := s.CurrentBalance.Decode(b); err != nil { + return fmt.Errorf("unable to decode starsRevenueStatus#febe5491: field current_balance: %w", err) } - s.CurrentBalance = value } { - value, err := b.Long() - if err != nil { - return fmt.Errorf("unable to decode starsRevenueStatus#79342946: field available_balance: %w", err) + if err := s.AvailableBalance.Decode(b); err != nil { + return fmt.Errorf("unable to decode starsRevenueStatus#febe5491: field available_balance: %w", err) } - s.AvailableBalance = value } { - value, err := b.Long() - if err != nil { - return fmt.Errorf("unable to decode starsRevenueStatus#79342946: field overall_revenue: %w", err) + if err := s.OverallRevenue.Decode(b); err != nil { + return fmt.Errorf("unable to decode starsRevenueStatus#febe5491: field overall_revenue: %w", err) } - s.OverallRevenue = value } if s.Flags.Has(1) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode starsRevenueStatus#79342946: field next_withdrawal_at: %w", err) + return fmt.Errorf("unable to decode starsRevenueStatus#febe5491: field next_withdrawal_at: %w", err) } s.NextWithdrawalAt = value } @@ -285,7 +285,7 @@ func (s *StarsRevenueStatus) GetWithdrawalEnabled() (value bool) { } // GetCurrentBalance returns value of CurrentBalance field. -func (s *StarsRevenueStatus) GetCurrentBalance() (value int64) { +func (s *StarsRevenueStatus) GetCurrentBalance() (value StarsAmount) { if s == nil { return } @@ -293,7 +293,7 @@ func (s *StarsRevenueStatus) GetCurrentBalance() (value int64) { } // GetAvailableBalance returns value of AvailableBalance field. -func (s *StarsRevenueStatus) GetAvailableBalance() (value int64) { +func (s *StarsRevenueStatus) GetAvailableBalance() (value StarsAmount) { if s == nil { return } @@ -301,7 +301,7 @@ func (s *StarsRevenueStatus) GetAvailableBalance() (value int64) { } // GetOverallRevenue returns value of OverallRevenue field. -func (s *StarsRevenueStatus) GetOverallRevenue() (value int64) { +func (s *StarsRevenueStatus) GetOverallRevenue() (value StarsAmount) { if s == nil { return } diff --git a/tg/tl_stars_transaction_gen.go b/tg/tl_stars_transaction_gen.go index 89ad1db103..8443d5ecbd 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#35d4f276`. +// StarsTransaction represents TL type `starsTransaction#64dfc926`. // Represents a Telegram Stars transaction »¹. // // Links: @@ -60,7 +60,7 @@ type StarsTransaction struct { // Transaction ID. ID string // Amount of Stars (negative for outgoing transactions). - Stars int64 + Stars StarsAmount // Date of the transaction (unixtime). Date int // Source of the incoming transaction, or its recipient for outgoing transactions. @@ -150,10 +150,22 @@ type StarsTransaction struct { // // Use SetFloodskipNumber and GetFloodskipNumber helpers. FloodskipNumber int + // StarrefCommissionPermille field of StarsTransaction. + // + // Use SetStarrefCommissionPermille and GetStarrefCommissionPermille helpers. + StarrefCommissionPermille int + // StarrefPeer field of StarsTransaction. + // + // Use SetStarrefPeer and GetStarrefPeer helpers. + StarrefPeer PeerClass + // StarrefAmount field of StarsTransaction. + // + // Use SetStarrefAmount and GetStarrefAmount helpers. + StarrefAmount StarsAmount } // StarsTransactionTypeID is TL type id of StarsTransaction. -const StarsTransactionTypeID = 0x35d4f276 +const StarsTransactionTypeID = 0x64dfc926 // Ensuring interfaces in compile-time for StarsTransaction. var ( @@ -188,7 +200,7 @@ func (s *StarsTransaction) Zero() bool { if !(s.ID == "") { return false } - if !(s.Stars == 0) { + if !(s.Stars.Zero()) { return false } if !(s.Date == 0) { @@ -233,6 +245,15 @@ func (s *StarsTransaction) Zero() bool { if !(s.FloodskipNumber == 0) { return false } + if !(s.StarrefCommissionPermille == 0) { + return false + } + if !(s.StarrefPeer == nil) { + return false + } + if !(s.StarrefAmount.Zero()) { + return false + } return true } @@ -254,7 +275,7 @@ func (s *StarsTransaction) FillFrom(from interface { GetGift() (value bool) GetReaction() (value bool) GetID() (value string) - GetStars() (value int64) + GetStars() (value StarsAmount) GetDate() (value int) GetPeer() (value StarsTransactionPeerClass) GetTitle() (value string, ok bool) @@ -269,6 +290,9 @@ func (s *StarsTransaction) FillFrom(from interface { GetGiveawayPostID() (value int, ok bool) GetStargift() (value StarGift, ok bool) GetFloodskipNumber() (value int, ok bool) + GetStarrefCommissionPermille() (value int, ok bool) + GetStarrefPeer() (value PeerClass, ok bool) + GetStarrefAmount() (value StarsAmount, ok bool) }) { s.Refund = from.GetRefund() s.Pending = from.GetPending() @@ -327,6 +351,18 @@ func (s *StarsTransaction) FillFrom(from interface { s.FloodskipNumber = val } + if val, ok := from.GetStarrefCommissionPermille(); ok { + s.StarrefCommissionPermille = val + } + + if val, ok := from.GetStarrefPeer(); ok { + s.StarrefPeer = val + } + + if val, ok := from.GetStarrefAmount(); ok { + s.StarrefAmount = val + } + } // TypeID returns type id in TL schema. @@ -453,6 +489,21 @@ func (s *StarsTransaction) TypeInfo() tdp.Type { SchemaName: "floodskip_number", Null: !s.Flags.Has(15), }, + { + Name: "StarrefCommissionPermille", + SchemaName: "starref_commission_permille", + Null: !s.Flags.Has(16), + }, + { + Name: "StarrefPeer", + SchemaName: "starref_peer", + Null: !s.Flags.Has(17), + }, + { + Name: "StarrefAmount", + SchemaName: "starref_amount", + Null: !s.Flags.Has(17), + }, } return typ } @@ -510,12 +561,21 @@ func (s *StarsTransaction) SetFlags() { if !(s.FloodskipNumber == 0) { s.Flags.Set(15) } + if !(s.StarrefCommissionPermille == 0) { + s.Flags.Set(16) + } + if !(s.StarrefPeer == nil) { + s.Flags.Set(17) + } + if !(s.StarrefAmount.Zero()) { + s.Flags.Set(17) + } } // Encode implements bin.Encoder. func (s *StarsTransaction) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starsTransaction#35d4f276 as nil") + return fmt.Errorf("can't encode starsTransaction#64dfc926 as nil") } b.PutID(StarsTransactionTypeID) return s.EncodeBare(b) @@ -524,20 +584,22 @@ 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#35d4f276 as nil") + return fmt.Errorf("can't encode starsTransaction#64dfc926 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsTransaction#35d4f276: field flags: %w", err) + return fmt.Errorf("unable to encode starsTransaction#64dfc926: field flags: %w", err) } b.PutString(s.ID) - b.PutLong(s.Stars) + if err := s.Stars.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsTransaction#64dfc926: field stars: %w", err) + } b.PutInt(s.Date) if s.Peer == nil { - return fmt.Errorf("unable to encode starsTransaction#35d4f276: field peer is nil") + return fmt.Errorf("unable to encode starsTransaction#64dfc926: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsTransaction#35d4f276: field peer: %w", err) + return fmt.Errorf("unable to encode starsTransaction#64dfc926: field peer: %w", err) } if s.Flags.Has(0) { b.PutString(s.Title) @@ -547,10 +609,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#35d4f276: field photo is nil") + return fmt.Errorf("unable to encode starsTransaction#64dfc926: field photo is nil") } if err := s.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsTransaction#35d4f276: field photo: %w", err) + return fmt.Errorf("unable to encode starsTransaction#64dfc926: field photo: %w", err) } } if s.Flags.Has(5) { @@ -569,10 +631,10 @@ func (s *StarsTransaction) EncodeBare(b *bin.Buffer) error { b.PutVectorHeader(len(s.ExtendedMedia)) for idx, v := range s.ExtendedMedia { if v == nil { - return fmt.Errorf("unable to encode starsTransaction#35d4f276: field extended_media element with index %d is nil", idx) + return fmt.Errorf("unable to encode starsTransaction#64dfc926: field extended_media element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsTransaction#35d4f276: field extended_media element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode starsTransaction#64dfc926: field extended_media element with index %d: %w", idx, err) } } } @@ -584,22 +646,38 @@ func (s *StarsTransaction) EncodeBare(b *bin.Buffer) error { } if s.Flags.Has(14) { if err := s.Stargift.Encode(b); err != nil { - return fmt.Errorf("unable to encode starsTransaction#35d4f276: field stargift: %w", err) + return fmt.Errorf("unable to encode starsTransaction#64dfc926: field stargift: %w", err) } } if s.Flags.Has(15) { b.PutInt(s.FloodskipNumber) } + if s.Flags.Has(16) { + b.PutInt(s.StarrefCommissionPermille) + } + if s.Flags.Has(17) { + if s.StarrefPeer == nil { + return fmt.Errorf("unable to encode starsTransaction#64dfc926: field starref_peer is nil") + } + if err := s.StarrefPeer.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsTransaction#64dfc926: field starref_peer: %w", err) + } + } + if s.Flags.Has(17) { + if err := s.StarrefAmount.Encode(b); err != nil { + return fmt.Errorf("unable to encode starsTransaction#64dfc926: field starref_amount: %w", err) + } + } return nil } // Decode implements bin.Decoder. func (s *StarsTransaction) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode starsTransaction#35d4f276 to nil") + return fmt.Errorf("can't decode starsTransaction#64dfc926 to nil") } if err := b.ConsumeID(StarsTransactionTypeID); err != nil { - return fmt.Errorf("unable to decode starsTransaction#35d4f276: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: %w", err) } return s.DecodeBare(b) } @@ -607,11 +685,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#35d4f276 to nil") + return fmt.Errorf("can't decode starsTransaction#64dfc926 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode starsTransaction#35d4f276: field flags: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: field flags: %w", err) } } s.Refund = s.Flags.Has(3) @@ -622,84 +700,82 @@ func (s *StarsTransaction) DecodeBare(b *bin.Buffer) error { { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#35d4f276: field id: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: field id: %w", err) } s.ID = value } { - value, err := b.Long() - if err != nil { - return fmt.Errorf("unable to decode starsTransaction#35d4f276: field stars: %w", err) + if err := s.Stars.Decode(b); err != nil { + return fmt.Errorf("unable to decode starsTransaction#64dfc926: field stars: %w", err) } - s.Stars = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#35d4f276: field date: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: field date: %w", err) } s.Date = value } { value, err := DecodeStarsTransactionPeer(b) if err != nil { - return fmt.Errorf("unable to decode starsTransaction#35d4f276: field peer: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: 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#35d4f276: field title: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: 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#35d4f276: field description: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: 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#35d4f276: field photo: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: 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#35d4f276: field transaction_date: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: 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#35d4f276: field transaction_url: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: 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#35d4f276: field bot_payload: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: 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#35d4f276: field msg_id: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: 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#35d4f276: field extended_media: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: field extended_media: %w", err) } if headerLen > 0 { @@ -708,7 +784,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#35d4f276: field extended_media: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: field extended_media: %w", err) } s.ExtendedMedia = append(s.ExtendedMedia, value) } @@ -716,29 +792,48 @@ 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#35d4f276: field subscription_period: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: 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#35d4f276: field giveaway_post_id: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: field giveaway_post_id: %w", err) } s.GiveawayPostID = value } if s.Flags.Has(14) { if err := s.Stargift.Decode(b); err != nil { - return fmt.Errorf("unable to decode starsTransaction#35d4f276: field stargift: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: field stargift: %w", err) } } if s.Flags.Has(15) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode starsTransaction#35d4f276: field floodskip_number: %w", err) + return fmt.Errorf("unable to decode starsTransaction#64dfc926: field floodskip_number: %w", err) } s.FloodskipNumber = value } + if s.Flags.Has(16) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starsTransaction#64dfc926: field starref_commission_permille: %w", err) + } + s.StarrefCommissionPermille = value + } + if s.Flags.Has(17) { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode starsTransaction#64dfc926: field starref_peer: %w", err) + } + s.StarrefPeer = value + } + if s.Flags.Has(17) { + if err := s.StarrefAmount.Decode(b); err != nil { + return fmt.Errorf("unable to decode starsTransaction#64dfc926: field starref_amount: %w", err) + } + } return nil } @@ -846,7 +941,7 @@ func (s *StarsTransaction) GetID() (value string) { } // GetStars returns value of Stars field. -func (s *StarsTransaction) GetStars() (value int64) { +func (s *StarsTransaction) GetStars() (value StarsAmount) { if s == nil { return } @@ -1085,6 +1180,60 @@ func (s *StarsTransaction) GetFloodskipNumber() (value int, ok bool) { return s.FloodskipNumber, true } +// SetStarrefCommissionPermille sets value of StarrefCommissionPermille conditional field. +func (s *StarsTransaction) SetStarrefCommissionPermille(value int) { + s.Flags.Set(16) + s.StarrefCommissionPermille = value +} + +// GetStarrefCommissionPermille returns value of StarrefCommissionPermille conditional field and +// boolean which is true if field was set. +func (s *StarsTransaction) GetStarrefCommissionPermille() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(16) { + return value, false + } + return s.StarrefCommissionPermille, true +} + +// SetStarrefPeer sets value of StarrefPeer conditional field. +func (s *StarsTransaction) SetStarrefPeer(value PeerClass) { + s.Flags.Set(17) + s.StarrefPeer = value +} + +// GetStarrefPeer returns value of StarrefPeer conditional field and +// boolean which is true if field was set. +func (s *StarsTransaction) GetStarrefPeer() (value PeerClass, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(17) { + return value, false + } + return s.StarrefPeer, true +} + +// SetStarrefAmount sets value of StarrefAmount conditional field. +func (s *StarsTransaction) SetStarrefAmount(value StarsAmount) { + s.Flags.Set(17) + s.StarrefAmount = value +} + +// GetStarrefAmount returns value of StarrefAmount conditional field and +// boolean which is true if field was set. +func (s *StarsTransaction) GetStarrefAmount() (value StarsAmount, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(17) { + return value, false + } + return s.StarrefAmount, 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 3867b44c91..690cc1e576 100644 --- a/tg/tl_update_gen.go +++ b/tg/tl_update_gen.go @@ -27540,7 +27540,7 @@ func (u *UpdateBroadcastRevenueTransactions) GetBalances() (value BroadcastReven return u.Balances } -// UpdateStarsBalance represents TL type `updateStarsBalance#fb85198`. +// UpdateStarsBalance represents TL type `updateStarsBalance#4e80a379`. // The current account's Telegram Stars balance »¹ has changed. // // Links: @@ -27549,11 +27549,11 @@ func (u *UpdateBroadcastRevenueTransactions) GetBalances() (value BroadcastReven // See https://core.telegram.org/constructor/updateStarsBalance for reference. type UpdateStarsBalance struct { // New balance. - Balance int64 + Balance StarsAmount } // UpdateStarsBalanceTypeID is TL type id of UpdateStarsBalance. -const UpdateStarsBalanceTypeID = 0xfb85198 +const UpdateStarsBalanceTypeID = 0x4e80a379 // construct implements constructor of UpdateClass. func (u UpdateStarsBalance) construct() UpdateClass { return &u } @@ -27572,7 +27572,7 @@ func (u *UpdateStarsBalance) Zero() bool { if u == nil { return true } - if !(u.Balance == 0) { + if !(u.Balance.Zero()) { return false } @@ -27590,7 +27590,7 @@ func (u *UpdateStarsBalance) String() string { // FillFrom fills UpdateStarsBalance from given interface. func (u *UpdateStarsBalance) FillFrom(from interface { - GetBalance() (value int64) + GetBalance() (value StarsAmount) }) { u.Balance = from.GetBalance() } @@ -27629,7 +27629,7 @@ func (u *UpdateStarsBalance) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (u *UpdateStarsBalance) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateStarsBalance#fb85198 as nil") + return fmt.Errorf("can't encode updateStarsBalance#4e80a379 as nil") } b.PutID(UpdateStarsBalanceTypeID) return u.EncodeBare(b) @@ -27638,19 +27638,21 @@ func (u *UpdateStarsBalance) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UpdateStarsBalance) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateStarsBalance#fb85198 as nil") + return fmt.Errorf("can't encode updateStarsBalance#4e80a379 as nil") + } + if err := u.Balance.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateStarsBalance#4e80a379: field balance: %w", err) } - b.PutLong(u.Balance) return nil } // Decode implements bin.Decoder. func (u *UpdateStarsBalance) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateStarsBalance#fb85198 to nil") + return fmt.Errorf("can't decode updateStarsBalance#4e80a379 to nil") } if err := b.ConsumeID(UpdateStarsBalanceTypeID); err != nil { - return fmt.Errorf("unable to decode updateStarsBalance#fb85198: %w", err) + return fmt.Errorf("unable to decode updateStarsBalance#4e80a379: %w", err) } return u.DecodeBare(b) } @@ -27658,20 +27660,18 @@ func (u *UpdateStarsBalance) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UpdateStarsBalance) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateStarsBalance#fb85198 to nil") + return fmt.Errorf("can't decode updateStarsBalance#4e80a379 to nil") } { - value, err := b.Long() - if err != nil { - return fmt.Errorf("unable to decode updateStarsBalance#fb85198: field balance: %w", err) + if err := u.Balance.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateStarsBalance#4e80a379: field balance: %w", err) } - u.Balance = value } return nil } // GetBalance returns value of Balance field. -func (u *UpdateStarsBalance) GetBalance() (value int64) { +func (u *UpdateStarsBalance) GetBalance() (value StarsAmount) { if u == nil { return } @@ -28567,248 +28567,6 @@ func (u *UpdatePaidReactionPrivacy) GetPrivate() (value bool) { return u.Private } -// UpdateBotSubscriptionExpire represents TL type `updateBotSubscriptionExpire#2d13c6ee`. -// -// See https://core.telegram.org/constructor/updateBotSubscriptionExpire for reference. -type UpdateBotSubscriptionExpire struct { - // UserID field of UpdateBotSubscriptionExpire. - UserID int64 - // Payload field of UpdateBotSubscriptionExpire. - Payload string - // InvoiceSlug field of UpdateBotSubscriptionExpire. - InvoiceSlug string - // UntilDate field of UpdateBotSubscriptionExpire. - UntilDate int - // Qts field of UpdateBotSubscriptionExpire. - Qts int -} - -// UpdateBotSubscriptionExpireTypeID is TL type id of UpdateBotSubscriptionExpire. -const UpdateBotSubscriptionExpireTypeID = 0x2d13c6ee - -// construct implements constructor of UpdateClass. -func (u UpdateBotSubscriptionExpire) construct() UpdateClass { return &u } - -// Ensuring interfaces in compile-time for UpdateBotSubscriptionExpire. -var ( - _ bin.Encoder = &UpdateBotSubscriptionExpire{} - _ bin.Decoder = &UpdateBotSubscriptionExpire{} - _ bin.BareEncoder = &UpdateBotSubscriptionExpire{} - _ bin.BareDecoder = &UpdateBotSubscriptionExpire{} - - _ UpdateClass = &UpdateBotSubscriptionExpire{} -) - -func (u *UpdateBotSubscriptionExpire) Zero() bool { - if u == nil { - return true - } - if !(u.UserID == 0) { - return false - } - if !(u.Payload == "") { - return false - } - if !(u.InvoiceSlug == "") { - return false - } - if !(u.UntilDate == 0) { - return false - } - if !(u.Qts == 0) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (u *UpdateBotSubscriptionExpire) String() string { - if u == nil { - return "UpdateBotSubscriptionExpire(nil)" - } - type Alias UpdateBotSubscriptionExpire - return fmt.Sprintf("UpdateBotSubscriptionExpire%+v", Alias(*u)) -} - -// FillFrom fills UpdateBotSubscriptionExpire from given interface. -func (u *UpdateBotSubscriptionExpire) FillFrom(from interface { - GetUserID() (value int64) - GetPayload() (value string) - GetInvoiceSlug() (value string) - GetUntilDate() (value int) - GetQts() (value int) -}) { - u.UserID = from.GetUserID() - u.Payload = from.GetPayload() - u.InvoiceSlug = from.GetInvoiceSlug() - u.UntilDate = from.GetUntilDate() - u.Qts = from.GetQts() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*UpdateBotSubscriptionExpire) TypeID() uint32 { - return UpdateBotSubscriptionExpireTypeID -} - -// TypeName returns name of type in TL schema. -func (*UpdateBotSubscriptionExpire) TypeName() string { - return "updateBotSubscriptionExpire" -} - -// TypeInfo returns info about TL type. -func (u *UpdateBotSubscriptionExpire) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "updateBotSubscriptionExpire", - ID: UpdateBotSubscriptionExpireTypeID, - } - if u == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "UserID", - SchemaName: "user_id", - }, - { - Name: "Payload", - SchemaName: "payload", - }, - { - Name: "InvoiceSlug", - SchemaName: "invoice_slug", - }, - { - Name: "UntilDate", - SchemaName: "until_date", - }, - { - Name: "Qts", - SchemaName: "qts", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (u *UpdateBotSubscriptionExpire) Encode(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't encode updateBotSubscriptionExpire#2d13c6ee as nil") - } - b.PutID(UpdateBotSubscriptionExpireTypeID) - return u.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (u *UpdateBotSubscriptionExpire) EncodeBare(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't encode updateBotSubscriptionExpire#2d13c6ee as nil") - } - b.PutLong(u.UserID) - b.PutString(u.Payload) - b.PutString(u.InvoiceSlug) - b.PutInt(u.UntilDate) - b.PutInt(u.Qts) - return nil -} - -// Decode implements bin.Decoder. -func (u *UpdateBotSubscriptionExpire) Decode(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't decode updateBotSubscriptionExpire#2d13c6ee to nil") - } - if err := b.ConsumeID(UpdateBotSubscriptionExpireTypeID); err != nil { - return fmt.Errorf("unable to decode updateBotSubscriptionExpire#2d13c6ee: %w", err) - } - return u.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (u *UpdateBotSubscriptionExpire) DecodeBare(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't decode updateBotSubscriptionExpire#2d13c6ee to nil") - } - { - value, err := b.Long() - if err != nil { - return fmt.Errorf("unable to decode updateBotSubscriptionExpire#2d13c6ee: field user_id: %w", err) - } - u.UserID = value - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode updateBotSubscriptionExpire#2d13c6ee: field payload: %w", err) - } - u.Payload = value - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode updateBotSubscriptionExpire#2d13c6ee: field invoice_slug: %w", err) - } - u.InvoiceSlug = value - } - { - value, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode updateBotSubscriptionExpire#2d13c6ee: field until_date: %w", err) - } - u.UntilDate = value - } - { - value, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode updateBotSubscriptionExpire#2d13c6ee: field qts: %w", err) - } - u.Qts = value - } - return nil -} - -// GetUserID returns value of UserID field. -func (u *UpdateBotSubscriptionExpire) GetUserID() (value int64) { - if u == nil { - return - } - return u.UserID -} - -// GetPayload returns value of Payload field. -func (u *UpdateBotSubscriptionExpire) GetPayload() (value string) { - if u == nil { - return - } - return u.Payload -} - -// GetInvoiceSlug returns value of InvoiceSlug field. -func (u *UpdateBotSubscriptionExpire) GetInvoiceSlug() (value string) { - if u == nil { - return - } - return u.InvoiceSlug -} - -// GetUntilDate returns value of UntilDate field. -func (u *UpdateBotSubscriptionExpire) GetUntilDate() (value int) { - if u == nil { - return - } - return u.UntilDate -} - -// GetQts returns value of Qts field. -func (u *UpdateBotSubscriptionExpire) GetQts() (value int) { - if u == nil { - return - } - return u.Qts -} - // UpdateClassName is schema name of UpdateClass. const UpdateClassName = "Update" @@ -28959,12 +28717,11 @@ const UpdateClassName = "Update" // case *tg.UpdateBotDeleteBusinessMessage: // updateBotDeleteBusinessMessage#a02a982e // case *tg.UpdateNewStoryReaction: // updateNewStoryReaction#1824e40b // case *tg.UpdateBroadcastRevenueTransactions: // updateBroadcastRevenueTransactions#dfd961f5 -// case *tg.UpdateStarsBalance: // updateStarsBalance#fb85198 +// case *tg.UpdateStarsBalance: // updateStarsBalance#4e80a379 // case *tg.UpdateBusinessBotCallbackQuery: // updateBusinessBotCallbackQuery#1ea2fda7 // case *tg.UpdateStarsRevenueStatus: // updateStarsRevenueStatus#a584b019 // case *tg.UpdateBotPurchasedPaidMedia: // updateBotPurchasedPaidMedia#283bd312 // case *tg.UpdatePaidReactionPrivacy: // updatePaidReactionPrivacy#51ca7aec -// case *tg.UpdateBotSubscriptionExpire: // updateBotSubscriptionExpire#2d13c6ee // default: panic(v) // } type UpdateClass interface { @@ -29946,7 +29703,7 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { } return &v, nil case UpdateStarsBalanceTypeID: - // Decoding updateStarsBalance#fb85198. + // Decoding updateStarsBalance#4e80a379. v := UpdateStarsBalance{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) @@ -29980,13 +29737,6 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil - case UpdateBotSubscriptionExpireTypeID: - // Decoding updateBotSubscriptionExpire#2d13c6ee. - v := UpdateBotSubscriptionExpire{} - 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 9b4e738fc3..2586f5041e 100644 --- a/tg/tl_update_slices_gen.go +++ b/tg/tl_update_slices_gen.go @@ -1741,19 +1741,6 @@ func (s UpdateClassArray) AsUpdatePaidReactionPrivacy() (to UpdatePaidReactionPr return to } -// AsUpdateBotSubscriptionExpire returns copy with only UpdateBotSubscriptionExpire constructors. -func (s UpdateClassArray) AsUpdateBotSubscriptionExpire() (to UpdateBotSubscriptionExpireArray) { - for _, elem := range s { - value, ok := elem.(*UpdateBotSubscriptionExpire) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - // UpdateNewMessageArray is adapter for slice of UpdateNewMessage. type UpdateNewMessageArray []UpdateNewMessage @@ -12269,85 +12256,3 @@ func (s *UpdatePaidReactionPrivacyArray) Pop() (v UpdatePaidReactionPrivacy, ok return v, true } - -// UpdateBotSubscriptionExpireArray is adapter for slice of UpdateBotSubscriptionExpire. -type UpdateBotSubscriptionExpireArray []UpdateBotSubscriptionExpire - -// Sort sorts slice of UpdateBotSubscriptionExpire. -func (s UpdateBotSubscriptionExpireArray) Sort(less func(a, b UpdateBotSubscriptionExpire) bool) UpdateBotSubscriptionExpireArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of UpdateBotSubscriptionExpire. -func (s UpdateBotSubscriptionExpireArray) SortStable(less func(a, b UpdateBotSubscriptionExpire) bool) UpdateBotSubscriptionExpireArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of UpdateBotSubscriptionExpire. -func (s UpdateBotSubscriptionExpireArray) Retain(keep func(x UpdateBotSubscriptionExpire) bool) UpdateBotSubscriptionExpireArray { - 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 UpdateBotSubscriptionExpireArray) First() (v UpdateBotSubscriptionExpire, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s UpdateBotSubscriptionExpireArray) Last() (v UpdateBotSubscriptionExpire, 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 *UpdateBotSubscriptionExpireArray) PopFirst() (v UpdateBotSubscriptionExpire, 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 UpdateBotSubscriptionExpire - 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 *UpdateBotSubscriptionExpireArray) Pop() (v UpdateBotSubscriptionExpire, 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 b2aac6294a..7d887f6675 100644 --- a/tg/tl_updates_classifier_gen.go +++ b/tg/tl_updates_classifier_gen.go @@ -86,8 +86,6 @@ func IsQtsUpdate(u UpdateClass) (qts int, ok bool) { return u.Qts, true case *UpdateBotPurchasedPaidMedia: return u.Qts, true - case *UpdateBotSubscriptionExpire: - return u.Qts, true } return diff --git a/tg/tl_user_full_gen.go b/tg/tl_user_full_gen.go index 51db60f63b..f32289b8eb 100644 --- a/tg/tl_user_full_gen.go +++ b/tg/tl_user_full_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// UserFull represents TL type `userFull#1f58e369`. +// UserFull represents TL type `userFull#979d2376`. // Extended user info // When updating the local peer database »¹, all fields from the newly received // constructor take priority over the old constructor cached locally (including by @@ -284,10 +284,14 @@ type UserFull struct { // // Use SetStargiftsCount and GetStargiftsCount helpers. StargiftsCount int + // StarrefProgram field of UserFull. + // + // Use SetStarrefProgram and GetStarrefProgram helpers. + StarrefProgram StarRefProgram } // UserFullTypeID is TL type id of UserFull. -const UserFullTypeID = 0x1f58e369 +const UserFullTypeID = 0x979d2376 // Ensuring interfaces in compile-time for UserFull. var ( @@ -439,6 +443,9 @@ func (u *UserFull) Zero() bool { if !(u.StargiftsCount == 0) { return false } + if !(u.StarrefProgram.Zero()) { + return false + } return true } @@ -498,6 +505,7 @@ func (u *UserFull) FillFrom(from interface { GetPersonalChannelID() (value int64, ok bool) GetPersonalChannelMessage() (value int, ok bool) GetStargiftsCount() (value int, ok bool) + GetStarrefProgram() (value StarRefProgram, ok bool) }) { u.Blocked = from.GetBlocked() u.PhoneCallsAvailable = from.GetPhoneCallsAvailable() @@ -615,6 +623,10 @@ func (u *UserFull) FillFrom(from interface { u.StargiftsCount = val } + if val, ok := from.GetStarrefProgram(); ok { + u.StarrefProgram = val + } + } // TypeID returns type id in TL schema. @@ -856,6 +868,11 @@ func (u *UserFull) TypeInfo() tdp.Type { SchemaName: "stargifts_count", Null: !u.Flags2.Has(8), }, + { + Name: "StarrefProgram", + SchemaName: "starref_program", + Null: !u.Flags2.Has(11), + }, } return typ } @@ -982,12 +999,15 @@ func (u *UserFull) SetFlags() { if !(u.StargiftsCount == 0) { u.Flags2.Set(8) } + if !(u.StarrefProgram.Zero()) { + u.Flags2.Set(11) + } } // Encode implements bin.Encoder. func (u *UserFull) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode userFull#1f58e369 as nil") + return fmt.Errorf("can't encode userFull#979d2376 as nil") } b.PutID(UserFullTypeID) return u.EncodeBare(b) @@ -996,52 +1016,52 @@ func (u *UserFull) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UserFull) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode userFull#1f58e369 as nil") + return fmt.Errorf("can't encode userFull#979d2376 as nil") } u.SetFlags() if err := u.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field flags: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field flags: %w", err) } if err := u.Flags2.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field flags2: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field flags2: %w", err) } b.PutLong(u.ID) if u.Flags.Has(1) { b.PutString(u.About) } if err := u.Settings.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field settings: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field settings: %w", err) } if u.Flags.Has(21) { if u.PersonalPhoto == nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field personal_photo is nil") + return fmt.Errorf("unable to encode userFull#979d2376: field personal_photo is nil") } if err := u.PersonalPhoto.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field personal_photo: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field personal_photo: %w", err) } } if u.Flags.Has(2) { if u.ProfilePhoto == nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field profile_photo is nil") + return fmt.Errorf("unable to encode userFull#979d2376: field profile_photo is nil") } if err := u.ProfilePhoto.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field profile_photo: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field profile_photo: %w", err) } } if u.Flags.Has(22) { if u.FallbackPhoto == nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field fallback_photo is nil") + return fmt.Errorf("unable to encode userFull#979d2376: field fallback_photo is nil") } if err := u.FallbackPhoto.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field fallback_photo: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field fallback_photo: %w", err) } } if err := u.NotifySettings.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field notify_settings: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field notify_settings: %w", err) } if u.Flags.Has(3) { if err := u.BotInfo.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field bot_info: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field bot_info: %w", err) } } if u.Flags.Has(6) { @@ -1062,63 +1082,63 @@ func (u *UserFull) EncodeBare(b *bin.Buffer) error { } if u.Flags.Has(17) { if err := u.BotGroupAdminRights.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field bot_group_admin_rights: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field bot_group_admin_rights: %w", err) } } if u.Flags.Has(18) { if err := u.BotBroadcastAdminRights.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field bot_broadcast_admin_rights: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field bot_broadcast_admin_rights: %w", err) } } if u.Flags.Has(19) { b.PutVectorHeader(len(u.PremiumGifts)) for idx, v := range u.PremiumGifts { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field premium_gifts element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode userFull#979d2376: field premium_gifts element with index %d: %w", idx, err) } } } if u.Flags.Has(24) { if u.Wallpaper == nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field wallpaper is nil") + return fmt.Errorf("unable to encode userFull#979d2376: field wallpaper is nil") } if err := u.Wallpaper.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field wallpaper: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field wallpaper: %w", err) } } if u.Flags.Has(25) { if err := u.Stories.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field stories: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field stories: %w", err) } } if u.Flags2.Has(0) { if err := u.BusinessWorkHours.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field business_work_hours: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field business_work_hours: %w", err) } } if u.Flags2.Has(1) { if err := u.BusinessLocation.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field business_location: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field business_location: %w", err) } } if u.Flags2.Has(2) { if err := u.BusinessGreetingMessage.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field business_greeting_message: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field business_greeting_message: %w", err) } } if u.Flags2.Has(3) { if err := u.BusinessAwayMessage.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field business_away_message: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field business_away_message: %w", err) } } if u.Flags2.Has(4) { if err := u.BusinessIntro.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field business_intro: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field business_intro: %w", err) } } if u.Flags2.Has(5) { if err := u.Birthday.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#1f58e369: field birthday: %w", err) + return fmt.Errorf("unable to encode userFull#979d2376: field birthday: %w", err) } } if u.Flags2.Has(6) { @@ -1130,16 +1150,21 @@ func (u *UserFull) EncodeBare(b *bin.Buffer) error { if u.Flags2.Has(8) { b.PutInt(u.StargiftsCount) } + if u.Flags2.Has(11) { + if err := u.StarrefProgram.Encode(b); err != nil { + return fmt.Errorf("unable to encode userFull#979d2376: field starref_program: %w", err) + } + } return nil } // Decode implements bin.Decoder. func (u *UserFull) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode userFull#1f58e369 to nil") + return fmt.Errorf("can't decode userFull#979d2376 to nil") } if err := b.ConsumeID(UserFullTypeID); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: %w", err) } return u.DecodeBare(b) } @@ -1147,11 +1172,11 @@ func (u *UserFull) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UserFull) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode userFull#1f58e369 to nil") + return fmt.Errorf("can't decode userFull#979d2376 to nil") } { if err := u.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field flags: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field flags: %w", err) } } u.Blocked = u.Flags.Has(0) @@ -1169,7 +1194,7 @@ func (u *UserFull) DecodeBare(b *bin.Buffer) error { u.ReadDatesPrivate = u.Flags.Has(30) { if err := u.Flags2.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field flags2: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field flags2: %w", err) } } u.SponsoredEnabled = u.Flags2.Has(7) @@ -1178,109 +1203,109 @@ func (u *UserFull) DecodeBare(b *bin.Buffer) error { { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field id: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field id: %w", err) } u.ID = value } if u.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field about: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field about: %w", err) } u.About = value } { if err := u.Settings.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field settings: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field settings: %w", err) } } if u.Flags.Has(21) { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field personal_photo: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field personal_photo: %w", err) } u.PersonalPhoto = value } if u.Flags.Has(2) { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field profile_photo: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field profile_photo: %w", err) } u.ProfilePhoto = value } if u.Flags.Has(22) { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field fallback_photo: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field fallback_photo: %w", err) } u.FallbackPhoto = value } { if err := u.NotifySettings.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field notify_settings: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field notify_settings: %w", err) } } if u.Flags.Has(3) { if err := u.BotInfo.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field bot_info: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field bot_info: %w", err) } } if u.Flags.Has(6) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field pinned_msg_id: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field pinned_msg_id: %w", err) } u.PinnedMsgID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field common_chats_count: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field common_chats_count: %w", err) } u.CommonChatsCount = value } if u.Flags.Has(11) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field folder_id: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field folder_id: %w", err) } u.FolderID = value } if u.Flags.Has(14) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field ttl_period: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field ttl_period: %w", err) } u.TTLPeriod = value } if u.Flags.Has(15) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field theme_emoticon: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field theme_emoticon: %w", err) } u.ThemeEmoticon = value } if u.Flags.Has(16) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field private_forward_name: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field private_forward_name: %w", err) } u.PrivateForwardName = value } if u.Flags.Has(17) { if err := u.BotGroupAdminRights.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field bot_group_admin_rights: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field bot_group_admin_rights: %w", err) } } if u.Flags.Has(18) { if err := u.BotBroadcastAdminRights.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field bot_broadcast_admin_rights: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field bot_broadcast_admin_rights: %w", err) } } if u.Flags.Has(19) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field premium_gifts: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field premium_gifts: %w", err) } if headerLen > 0 { @@ -1289,7 +1314,7 @@ func (u *UserFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value PremiumGiftOption if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field premium_gifts: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field premium_gifts: %w", err) } u.PremiumGifts = append(u.PremiumGifts, value) } @@ -1297,66 +1322,71 @@ func (u *UserFull) DecodeBare(b *bin.Buffer) error { if u.Flags.Has(24) { value, err := DecodeWallPaper(b) if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field wallpaper: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field wallpaper: %w", err) } u.Wallpaper = value } if u.Flags.Has(25) { if err := u.Stories.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field stories: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field stories: %w", err) } } if u.Flags2.Has(0) { if err := u.BusinessWorkHours.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field business_work_hours: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field business_work_hours: %w", err) } } if u.Flags2.Has(1) { if err := u.BusinessLocation.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field business_location: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field business_location: %w", err) } } if u.Flags2.Has(2) { if err := u.BusinessGreetingMessage.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field business_greeting_message: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field business_greeting_message: %w", err) } } if u.Flags2.Has(3) { if err := u.BusinessAwayMessage.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field business_away_message: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field business_away_message: %w", err) } } if u.Flags2.Has(4) { if err := u.BusinessIntro.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field business_intro: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field business_intro: %w", err) } } if u.Flags2.Has(5) { if err := u.Birthday.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field birthday: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field birthday: %w", err) } } if u.Flags2.Has(6) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field personal_channel_id: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field personal_channel_id: %w", err) } u.PersonalChannelID = value } if u.Flags2.Has(6) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field personal_channel_message: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field personal_channel_message: %w", err) } u.PersonalChannelMessage = value } if u.Flags2.Has(8) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#1f58e369: field stargifts_count: %w", err) + return fmt.Errorf("unable to decode userFull#979d2376: field stargifts_count: %w", err) } u.StargiftsCount = value } + if u.Flags2.Has(11) { + if err := u.StarrefProgram.Decode(b); err != nil { + return fmt.Errorf("unable to decode userFull#979d2376: field starref_program: %w", err) + } + } return nil } @@ -2128,6 +2158,24 @@ func (u *UserFull) GetStargiftsCount() (value int, ok bool) { return u.StargiftsCount, true } +// SetStarrefProgram sets value of StarrefProgram conditional field. +func (u *UserFull) SetStarrefProgram(value StarRefProgram) { + u.Flags2.Set(11) + u.StarrefProgram = value +} + +// GetStarrefProgram returns value of StarrefProgram conditional field and +// boolean which is true if field was set. +func (u *UserFull) GetStarrefProgram() (value StarRefProgram, ok bool) { + if u == nil { + return + } + if !u.Flags2.Has(11) { + return value, false + } + return u.StarrefProgram, true +} + // GetPersonalPhotoAsNotEmpty returns mapped value of PersonalPhoto conditional field and // boolean which is true if field was set. func (u *UserFull) GetPersonalPhotoAsNotEmpty() (*Photo, bool) {