diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index db0285489b..b3dd9448cc 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: 177 -// SHA256: a5110909d1c88f8858263bac74c3ca3443cb02e34f71f7f830301ca76cf62f3a +// Layer: 178 +// SHA256: 7a4c0f192ad4dd77a24614884fd716bcf680b683c45bd2b921af13369ebcf68a boolFalse#bc799737 = Bool; @@ -166,9 +166,9 @@ channel#aadfc8f flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5 channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat; -chatFull#c9d31138 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions = ChatFull; +chatFull#2633421b flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions reactions_limit:flags.20?int = ChatFull; -channelFull#44c054a7 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet = ChatFull; +channelFull#bbab348d flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet = ChatFull; chatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant; @@ -382,7 +382,7 @@ inputReportReasonIllegalDrugs#a8eb2be = ReportReason; inputReportReasonPersonalDetails#9ec7863d = ReportReason; -userFull#cc997720 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int = UserFull; +userFull#cc997720 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int = UserFull; contact#145ade0b user_id:long mutual:Bool = Contact; @@ -724,6 +724,8 @@ updateBotEditBusinessMessage#7df587c flags:# connection_id:string message:Messag updateBotDeleteBusinessMessage#a02a982e connection_id:string peer:Peer messages:Vector qts:int = Update; +updateNewStoryReaction#1824e40b story_id:int peer:Peer reaction:Reaction = 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; @@ -1860,7 +1862,7 @@ account.wallPapersNotModified#1c199183 = account.WallPapers; account.wallPapers#cdc3858c hash:long wallpapers:Vector = account.WallPapers; -codeSettings#ad253d78 flags:# allow_flashcall:flags.0?true current_number:flags.1?true allow_app_hash:flags.4?true allow_missed_call:flags.5?true allow_firebase:flags.7?true logout_tokens:flags.6?Vector token:flags.8?string app_sandbox:flags.8?Bool = CodeSettings; +codeSettings#ad253d78 flags:# allow_flashcall:flags.0?true current_number:flags.1?true allow_app_hash:flags.4?true allow_missed_call:flags.5?true allow_firebase:flags.7?true unknown_number:flags.9?true logout_tokens:flags.6?Vector token:flags.8?string app_sandbox:flags.8?Bool = CodeSettings; wallPaperSettings#372efcd0 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int second_background_color:flags.4?int third_background_color:flags.5?int fourth_background_color:flags.6?int intensity:flags.3?int rotation:flags.4?int emoticon:flags.7?string = WallPaperSettings; @@ -1940,6 +1942,8 @@ webPageAttributeTheme#54b56617 flags:# documents:flags.0?Vector settin webPageAttributeStory#2e94c3e7 flags:# peer:Peer id:int story:flags.0?StoryItem = WebPageAttribute; +webPageAttributeStickerSet#50cc03d3 flags:# emojis:flags.0?true text_color:flags.1?true stickers:Vector = WebPageAttribute; + messages.votesList#4899484e flags:# count:int votes:Vector chats:Vector users:Vector next_offset:flags.0?string = messages.VotesList; bankCardOpenUrl#f568028a url:string name:string = BankCardOpenUrl; @@ -2088,7 +2092,7 @@ account.resetPasswordRequestedWait#e9effc7d until_date:int = account.ResetPasswo account.resetPasswordOk#e926d63e = account.ResetPasswordResult; -sponsoredMessage#ed5383f7 flags:# recommended:flags.5?true show_peer_photo:flags.6?true can_report:flags.12?true random_id:bytes from_id:flags.3?Peer chat_invite:flags.4?ChatInvite chat_invite_hash:flags.4?string channel_post:flags.2?int start_param:flags.0?string webpage:flags.9?SponsoredWebPage app:flags.10?BotApp message:string entities:flags.1?Vector button_text:flags.11?string sponsor_info:flags.7?string additional_info:flags.8?string = SponsoredMessage; +sponsoredMessage#bdedf566 flags:# recommended:flags.5?true can_report:flags.12?true random_id:bytes url:string title:string message:string entities:flags.1?Vector photo:flags.6?Photo color:flags.13?PeerColor button_text:string sponsor_info:flags.7?string additional_info:flags.8?string = SponsoredMessage; messages.sponsoredMessages#c9ee1d87 flags:# posts_between:flags.0?int messages:Vector chats:Vector users:Vector = messages.SponsoredMessages; @@ -2336,8 +2340,6 @@ messagePeerVoteInputOption#74cda504 peer:Peer date:int = MessagePeerVote; messagePeerVoteMultiple#4628f6e6 peer:Peer options:Vector date:int = MessagePeerVote; -sponsoredWebPage#3db8ec63 flags:# url:string site_name:string photo:flags.0?Photo = SponsoredWebPage; - storyViews#8d595cd6 flags:# has_viewers:flags.1?true views_count:int forwards_count:flags.2?int reactions:flags.3?Vector reactions_count:flags.4?int recent_viewers:flags.0?Vector = StoryViews; storyItemDeleted#51e6ee4f id:int = StoryItem; @@ -2350,7 +2352,7 @@ stories.allStoriesNotModified#1158fe3e flags:# state:string stealth_mode:Stories stories.allStories#6efc5e81 flags:# has_more:flags.0?true count:int state:string peer_stories:Vector chats:Vector users:Vector stealth_mode:StoriesStealthMode = stories.AllStories; -stories.stories#5dd8c3c8 count:int stories:Vector chats:Vector users:Vector = stories.Stories; +stories.stories#63c3dd0a flags:# count:int stories:Vector pinned_to_top:flags.0?Vector chats:Vector users:Vector = stories.Stories; storyView#b0bdeac5 flags:# blocked:flags.0?true blocked_my_stories_from:flags.1?true user_id:long date:int reaction:flags.2?Reaction = StoryView; @@ -2574,6 +2576,12 @@ broadcastRevenueTransactionRefund#42d30d2e amount:long date:int provider:string stats.broadcastRevenueTransactions#87158466 count:int transactions:Vector = stats.BroadcastRevenueTransactions; +reactionNotificationsFromContacts#bac3a61a = ReactionNotificationsFrom; + +reactionNotificationsFromAll#4b9e22a0 = ReactionNotificationsFrom; + +reactionsNotifySettings#56e34970 flags:# messages_notify_from:flags.0?ReactionNotificationsFrom stories_notify_from:flags.1?ReactionNotificationsFrom sound:NotificationSound show_previews:Bool = ReactionsNotifySettings; + ---functions--- @@ -2855,6 +2863,12 @@ account.resolveBusinessChatLink#5492e5ee slug:string = account.ResolvedBusinessC account.updatePersonalChannel#d94305e0 channel:InputChannel = Bool; +account.toggleSponsoredMessages#b9d9a38d enabled:Bool = Bool; + +account.getReactionsNotifySettings#6dd654c = ReactionsNotifySettings; + +account.setReactionsNotifySettings#316ce548 settings:ReactionsNotifySettings = ReactionsNotifySettings; + users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#b60f5918 id:InputUser = users.UserFull; @@ -3009,7 +3023,7 @@ messages.editChatAdmin#a85bd1c2 chat_id:long user_id:InputUser is_admin:Bool = B messages.migrateChat#a2875319 chat_id:long = Updates; -messages.searchGlobal#4bc6589a flags:# folder_id:flags.0?int q:string filter:MessagesFilter min_date:int max_date:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; +messages.searchGlobal#4bc6589a flags:# broadcasts_only:flags.1?true folder_id:flags.0?int q:string filter:MessagesFilter min_date:int max_date:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; messages.reorderStickerSets#78337739 flags:# masks:flags.0?true emojis:flags.1?true order:Vector = Bool; @@ -3217,7 +3231,7 @@ messages.getMessagesReactions#8bba90e6 peer:InputPeer id:Vector = Updates; messages.getMessageReactionsList#461b3f48 flags:# peer:InputPeer id:int reaction:flags.0?Reaction offset:flags.1?string limit:int = messages.MessageReactionsList; -messages.setChatAvailableReactions#feb16771 peer:InputPeer available_reactions:ChatReactions = Updates; +messages.setChatAvailableReactions#5a150bd4 flags:# peer:InputPeer available_reactions:ChatReactions reactions_limit:flags.0?int = Updates; messages.getAvailableReactions#18dea0ac hash:int = messages.AvailableReactions; @@ -3529,7 +3543,7 @@ channels.updateColor#d8aa3671 flags:# for_profile:flags.1?true channel:InputChan channels.toggleViewForumAsMessages#9738bb15 channel:InputChannel enabled:Bool = Updates; -channels.getChannelRecommendations#83b70d97 channel:InputChannel = messages.Chats; +channels.getChannelRecommendations#25a71742 flags:# channel:flags.0?InputChannel = messages.Chats; channels.updateEmojiStatus#f0d3e6a8 channel:InputChannel emoji_status:EmojiStatus = Updates; @@ -3791,6 +3805,8 @@ stories.togglePeerStoriesHidden#bd0415c4 peer:InputPeer hidden:Bool = Bool; stories.getStoryReactionsList#b9b2881f flags:# forwards_first:flags.2?true peer:InputPeer id:int reaction:flags.0?Reaction offset:flags.1?string limit:int = stories.StoryReactionsList; +stories.togglePinnedToTop#b297e9b peer:InputPeer id:Vector = Bool; + premium.getBoostsList#60f67660 flags:# gifts:flags.0?true peer:InputPeer offset:string limit:int = premium.BoostsList; premium.getMyBoosts#be77b4a = premium.MyBoosts; @@ -3817,4 +3833,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 177 +// LAYER 178 diff --git a/_schema/telegram.tl b/_schema/telegram.tl index 6e80769dc9..05d839610b 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: 177 -// SHA256: a5110909d1c88f8858263bac74c3ca3443cb02e34f71f7f830301ca76cf62f3a +// Layer: 178 +// SHA256: 7a4c0f192ad4dd77a24614884fd716bcf680b683c45bd2b921af13369ebcf68a boolFalse#bc799737 = Bool; @@ -167,9 +167,9 @@ channel#aadfc8f flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5 channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat; -chatFull#c9d31138 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions = ChatFull; +chatFull#2633421b flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions reactions_limit:flags.20?int = ChatFull; -channelFull#44c054a7 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet = ChatFull; +channelFull#bbab348d flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet = ChatFull; chatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant; @@ -383,7 +383,7 @@ inputReportReasonIllegalDrugs#a8eb2be = ReportReason; inputReportReasonPersonalDetails#9ec7863d = ReportReason; -userFull#cc997720 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int = UserFull; +userFull#cc997720 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int = UserFull; contact#145ade0b user_id:long mutual:Bool = Contact; @@ -725,6 +725,8 @@ updateBotEditBusinessMessage#7df587c flags:# connection_id:string message:Messag updateBotDeleteBusinessMessage#a02a982e connection_id:string peer:Peer messages:Vector qts:int = Update; +updateNewStoryReaction#1824e40b story_id:int peer:Peer reaction:Reaction = 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; @@ -1861,7 +1863,7 @@ account.wallPapersNotModified#1c199183 = account.WallPapers; account.wallPapers#cdc3858c hash:long wallpapers:Vector = account.WallPapers; -codeSettings#ad253d78 flags:# allow_flashcall:flags.0?true current_number:flags.1?true allow_app_hash:flags.4?true allow_missed_call:flags.5?true allow_firebase:flags.7?true logout_tokens:flags.6?Vector token:flags.8?string app_sandbox:flags.8?Bool = CodeSettings; +codeSettings#ad253d78 flags:# allow_flashcall:flags.0?true current_number:flags.1?true allow_app_hash:flags.4?true allow_missed_call:flags.5?true allow_firebase:flags.7?true unknown_number:flags.9?true logout_tokens:flags.6?Vector token:flags.8?string app_sandbox:flags.8?Bool = CodeSettings; wallPaperSettings#372efcd0 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int second_background_color:flags.4?int third_background_color:flags.5?int fourth_background_color:flags.6?int intensity:flags.3?int rotation:flags.4?int emoticon:flags.7?string = WallPaperSettings; @@ -1941,6 +1943,8 @@ webPageAttributeTheme#54b56617 flags:# documents:flags.0?Vector settin webPageAttributeStory#2e94c3e7 flags:# peer:Peer id:int story:flags.0?StoryItem = WebPageAttribute; +webPageAttributeStickerSet#50cc03d3 flags:# emojis:flags.0?true text_color:flags.1?true stickers:Vector = WebPageAttribute; + messages.votesList#4899484e flags:# count:int votes:Vector chats:Vector users:Vector next_offset:flags.0?string = messages.VotesList; bankCardOpenUrl#f568028a url:string name:string = BankCardOpenUrl; @@ -2089,7 +2093,7 @@ account.resetPasswordRequestedWait#e9effc7d until_date:int = account.ResetPasswo account.resetPasswordOk#e926d63e = account.ResetPasswordResult; -sponsoredMessage#ed5383f7 flags:# recommended:flags.5?true show_peer_photo:flags.6?true can_report:flags.12?true random_id:bytes from_id:flags.3?Peer chat_invite:flags.4?ChatInvite chat_invite_hash:flags.4?string channel_post:flags.2?int start_param:flags.0?string webpage:flags.9?SponsoredWebPage app:flags.10?BotApp message:string entities:flags.1?Vector button_text:flags.11?string sponsor_info:flags.7?string additional_info:flags.8?string = SponsoredMessage; +sponsoredMessage#bdedf566 flags:# recommended:flags.5?true can_report:flags.12?true random_id:bytes url:string title:string message:string entities:flags.1?Vector photo:flags.6?Photo color:flags.13?PeerColor button_text:string sponsor_info:flags.7?string additional_info:flags.8?string = SponsoredMessage; messages.sponsoredMessages#c9ee1d87 flags:# posts_between:flags.0?int messages:Vector chats:Vector users:Vector = messages.SponsoredMessages; @@ -2337,8 +2341,6 @@ messagePeerVoteInputOption#74cda504 peer:Peer date:int = MessagePeerVote; messagePeerVoteMultiple#4628f6e6 peer:Peer options:Vector date:int = MessagePeerVote; -sponsoredWebPage#3db8ec63 flags:# url:string site_name:string photo:flags.0?Photo = SponsoredWebPage; - storyViews#8d595cd6 flags:# has_viewers:flags.1?true views_count:int forwards_count:flags.2?int reactions:flags.3?Vector reactions_count:flags.4?int recent_viewers:flags.0?Vector = StoryViews; storyItemDeleted#51e6ee4f id:int = StoryItem; @@ -2351,7 +2353,7 @@ stories.allStoriesNotModified#1158fe3e flags:# state:string stealth_mode:Stories stories.allStories#6efc5e81 flags:# has_more:flags.0?true count:int state:string peer_stories:Vector chats:Vector users:Vector stealth_mode:StoriesStealthMode = stories.AllStories; -stories.stories#5dd8c3c8 count:int stories:Vector chats:Vector users:Vector = stories.Stories; +stories.stories#63c3dd0a flags:# count:int stories:Vector pinned_to_top:flags.0?Vector chats:Vector users:Vector = stories.Stories; storyView#b0bdeac5 flags:# blocked:flags.0?true blocked_my_stories_from:flags.1?true user_id:long date:int reaction:flags.2?Reaction = StoryView; @@ -2575,6 +2577,12 @@ broadcastRevenueTransactionRefund#42d30d2e amount:long date:int provider:string stats.broadcastRevenueTransactions#87158466 count:int transactions:Vector = stats.BroadcastRevenueTransactions; +reactionNotificationsFromContacts#bac3a61a = ReactionNotificationsFrom; + +reactionNotificationsFromAll#4b9e22a0 = ReactionNotificationsFrom; + +reactionsNotifySettings#56e34970 flags:# messages_notify_from:flags.0?ReactionNotificationsFrom stories_notify_from:flags.1?ReactionNotificationsFrom sound:NotificationSound show_previews:Bool = ReactionsNotifySettings; + ---functions--- @@ -2856,6 +2864,12 @@ account.resolveBusinessChatLink#5492e5ee slug:string = account.ResolvedBusinessC account.updatePersonalChannel#d94305e0 channel:InputChannel = Bool; +account.toggleSponsoredMessages#b9d9a38d enabled:Bool = Bool; + +account.getReactionsNotifySettings#6dd654c = ReactionsNotifySettings; + +account.setReactionsNotifySettings#316ce548 settings:ReactionsNotifySettings = ReactionsNotifySettings; + users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#b60f5918 id:InputUser = users.UserFull; @@ -3010,7 +3024,7 @@ messages.editChatAdmin#a85bd1c2 chat_id:long user_id:InputUser is_admin:Bool = B messages.migrateChat#a2875319 chat_id:long = Updates; -messages.searchGlobal#4bc6589a flags:# folder_id:flags.0?int q:string filter:MessagesFilter min_date:int max_date:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; +messages.searchGlobal#4bc6589a flags:# broadcasts_only:flags.1?true folder_id:flags.0?int q:string filter:MessagesFilter min_date:int max_date:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; messages.reorderStickerSets#78337739 flags:# masks:flags.0?true emojis:flags.1?true order:Vector = Bool; @@ -3218,7 +3232,7 @@ messages.getMessagesReactions#8bba90e6 peer:InputPeer id:Vector = Updates; messages.getMessageReactionsList#461b3f48 flags:# peer:InputPeer id:int reaction:flags.0?Reaction offset:flags.1?string limit:int = messages.MessageReactionsList; -messages.setChatAvailableReactions#feb16771 peer:InputPeer available_reactions:ChatReactions = Updates; +messages.setChatAvailableReactions#5a150bd4 flags:# peer:InputPeer available_reactions:ChatReactions reactions_limit:flags.0?int = Updates; messages.getAvailableReactions#18dea0ac hash:int = messages.AvailableReactions; @@ -3530,7 +3544,7 @@ channels.updateColor#d8aa3671 flags:# for_profile:flags.1?true channel:InputChan channels.toggleViewForumAsMessages#9738bb15 channel:InputChannel enabled:Bool = Updates; -channels.getChannelRecommendations#83b70d97 channel:InputChannel = messages.Chats; +channels.getChannelRecommendations#25a71742 flags:# channel:flags.0?InputChannel = messages.Chats; channels.updateEmojiStatus#f0d3e6a8 channel:InputChannel emoji_status:EmojiStatus = Updates; @@ -3792,6 +3806,8 @@ stories.togglePeerStoriesHidden#bd0415c4 peer:InputPeer hidden:Bool = Bool; stories.getStoryReactionsList#b9b2881f flags:# forwards_first:flags.2?true peer:InputPeer id:int reaction:flags.0?Reaction offset:flags.1?string limit:int = stories.StoryReactionsList; +stories.togglePinnedToTop#b297e9b peer:InputPeer id:Vector = Bool; + premium.getBoostsList#60f67660 flags:# gifts:flags.0?true peer:InputPeer offset:string limit:int = premium.BoostsList; premium.getMyBoosts#be77b4a = premium.MyBoosts; @@ -3850,4 +3866,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 177 +// LAYER 178 diff --git a/telegram/query/messages/queries.gen.go b/telegram/query/messages/queries.gen.go index 24ba7378c1..6f67c87e40 100644 --- a/telegram/query/messages/queries.gen.go +++ b/telegram/query/messages/queries.gen.go @@ -971,6 +971,12 @@ func (b *SearchGlobalQueryBuilder) OffsetID(offsetID int) *SearchGlobalQueryBuil return b } +// BroadcastsOnly sets BroadcastsOnly field of SearchGlobal query. +func (b *SearchGlobalQueryBuilder) BroadcastsOnly(paramBroadcastsOnly bool) *SearchGlobalQueryBuilder { + b.req.BroadcastsOnly = paramBroadcastsOnly + return b +} + // Filter sets Filter field of SearchGlobal query. func (b *SearchGlobalQueryBuilder) Filter(paramFilter tg.MessagesFilterClass) *SearchGlobalQueryBuilder { b.req.Filter = paramFilter @@ -1105,6 +1111,7 @@ func (b *SearchGlobalQueryBuilder) Query(ctx context.Context, req Request) (tg.M Limit: req.Limit, } + r.BroadcastsOnly = b.req.BroadcastsOnly r.Filter = b.req.Filter r.FolderID = b.req.FolderID r.MaxDate = b.req.MaxDate diff --git a/tg/tl_account_get_reactions_notify_settings_gen.go b/tg/tl_account_get_reactions_notify_settings_gen.go new file mode 100644 index 0000000000..0dbc640a6f --- /dev/null +++ b/tg/tl_account_get_reactions_notify_settings_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{} +) + +// AccountGetReactionsNotifySettingsRequest represents TL type `account.getReactionsNotifySettings#6dd654c`. +// +// See https://core.telegram.org/method/account.getReactionsNotifySettings for reference. +type AccountGetReactionsNotifySettingsRequest struct { +} + +// AccountGetReactionsNotifySettingsRequestTypeID is TL type id of AccountGetReactionsNotifySettingsRequest. +const AccountGetReactionsNotifySettingsRequestTypeID = 0x6dd654c + +// Ensuring interfaces in compile-time for AccountGetReactionsNotifySettingsRequest. +var ( + _ bin.Encoder = &AccountGetReactionsNotifySettingsRequest{} + _ bin.Decoder = &AccountGetReactionsNotifySettingsRequest{} + _ bin.BareEncoder = &AccountGetReactionsNotifySettingsRequest{} + _ bin.BareDecoder = &AccountGetReactionsNotifySettingsRequest{} +) + +func (g *AccountGetReactionsNotifySettingsRequest) Zero() bool { + if g == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (g *AccountGetReactionsNotifySettingsRequest) String() string { + if g == nil { + return "AccountGetReactionsNotifySettingsRequest(nil)" + } + type Alias AccountGetReactionsNotifySettingsRequest + return fmt.Sprintf("AccountGetReactionsNotifySettingsRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountGetReactionsNotifySettingsRequest) TypeID() uint32 { + return AccountGetReactionsNotifySettingsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountGetReactionsNotifySettingsRequest) TypeName() string { + return "account.getReactionsNotifySettings" +} + +// TypeInfo returns info about TL type. +func (g *AccountGetReactionsNotifySettingsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.getReactionsNotifySettings", + ID: AccountGetReactionsNotifySettingsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (g *AccountGetReactionsNotifySettingsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode account.getReactionsNotifySettings#6dd654c as nil") + } + b.PutID(AccountGetReactionsNotifySettingsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *AccountGetReactionsNotifySettingsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode account.getReactionsNotifySettings#6dd654c as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (g *AccountGetReactionsNotifySettingsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode account.getReactionsNotifySettings#6dd654c to nil") + } + if err := b.ConsumeID(AccountGetReactionsNotifySettingsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.getReactionsNotifySettings#6dd654c: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *AccountGetReactionsNotifySettingsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode account.getReactionsNotifySettings#6dd654c to nil") + } + return nil +} + +// AccountGetReactionsNotifySettings invokes method account.getReactionsNotifySettings#6dd654c returning error if any. +// +// See https://core.telegram.org/method/account.getReactionsNotifySettings for reference. +func (c *Client) AccountGetReactionsNotifySettings(ctx context.Context) (*ReactionsNotifySettings, error) { + var result ReactionsNotifySettings + + request := &AccountGetReactionsNotifySettingsRequest{} + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_sponsored_web_page_slices_gen.go b/tg/tl_account_get_reactions_notify_settings_slices_gen.go similarity index 100% rename from tg/tl_sponsored_web_page_slices_gen.go rename to tg/tl_account_get_reactions_notify_settings_slices_gen.go diff --git a/tg/tl_account_set_reactions_notify_settings_gen.go b/tg/tl_account_set_reactions_notify_settings_gen.go new file mode 100644 index 0000000000..3567bd82b5 --- /dev/null +++ b/tg/tl_account_set_reactions_notify_settings_gen.go @@ -0,0 +1,176 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AccountSetReactionsNotifySettingsRequest represents TL type `account.setReactionsNotifySettings#316ce548`. +// +// See https://core.telegram.org/method/account.setReactionsNotifySettings for reference. +type AccountSetReactionsNotifySettingsRequest struct { + // Settings field of AccountSetReactionsNotifySettingsRequest. + Settings ReactionsNotifySettings +} + +// AccountSetReactionsNotifySettingsRequestTypeID is TL type id of AccountSetReactionsNotifySettingsRequest. +const AccountSetReactionsNotifySettingsRequestTypeID = 0x316ce548 + +// Ensuring interfaces in compile-time for AccountSetReactionsNotifySettingsRequest. +var ( + _ bin.Encoder = &AccountSetReactionsNotifySettingsRequest{} + _ bin.Decoder = &AccountSetReactionsNotifySettingsRequest{} + _ bin.BareEncoder = &AccountSetReactionsNotifySettingsRequest{} + _ bin.BareDecoder = &AccountSetReactionsNotifySettingsRequest{} +) + +func (s *AccountSetReactionsNotifySettingsRequest) Zero() bool { + if s == nil { + return true + } + if !(s.Settings.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *AccountSetReactionsNotifySettingsRequest) String() string { + if s == nil { + return "AccountSetReactionsNotifySettingsRequest(nil)" + } + type Alias AccountSetReactionsNotifySettingsRequest + return fmt.Sprintf("AccountSetReactionsNotifySettingsRequest%+v", Alias(*s)) +} + +// FillFrom fills AccountSetReactionsNotifySettingsRequest from given interface. +func (s *AccountSetReactionsNotifySettingsRequest) FillFrom(from interface { + GetSettings() (value ReactionsNotifySettings) +}) { + s.Settings = from.GetSettings() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountSetReactionsNotifySettingsRequest) TypeID() uint32 { + return AccountSetReactionsNotifySettingsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountSetReactionsNotifySettingsRequest) TypeName() string { + return "account.setReactionsNotifySettings" +} + +// TypeInfo returns info about TL type. +func (s *AccountSetReactionsNotifySettingsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.setReactionsNotifySettings", + ID: AccountSetReactionsNotifySettingsRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Settings", + SchemaName: "settings", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *AccountSetReactionsNotifySettingsRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode account.setReactionsNotifySettings#316ce548 as nil") + } + b.PutID(AccountSetReactionsNotifySettingsRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *AccountSetReactionsNotifySettingsRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode account.setReactionsNotifySettings#316ce548 as nil") + } + if err := s.Settings.Encode(b); err != nil { + return fmt.Errorf("unable to encode account.setReactionsNotifySettings#316ce548: field settings: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *AccountSetReactionsNotifySettingsRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode account.setReactionsNotifySettings#316ce548 to nil") + } + if err := b.ConsumeID(AccountSetReactionsNotifySettingsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.setReactionsNotifySettings#316ce548: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *AccountSetReactionsNotifySettingsRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode account.setReactionsNotifySettings#316ce548 to nil") + } + { + if err := s.Settings.Decode(b); err != nil { + return fmt.Errorf("unable to decode account.setReactionsNotifySettings#316ce548: field settings: %w", err) + } + } + return nil +} + +// GetSettings returns value of Settings field. +func (s *AccountSetReactionsNotifySettingsRequest) GetSettings() (value ReactionsNotifySettings) { + if s == nil { + return + } + return s.Settings +} + +// AccountSetReactionsNotifySettings invokes method account.setReactionsNotifySettings#316ce548 returning error if any. +// +// See https://core.telegram.org/method/account.setReactionsNotifySettings for reference. +func (c *Client) AccountSetReactionsNotifySettings(ctx context.Context, settings ReactionsNotifySettings) (*ReactionsNotifySettings, error) { + var result ReactionsNotifySettings + + request := &AccountSetReactionsNotifySettingsRequest{ + Settings: settings, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_account_set_reactions_notify_settings_slices_gen.go b/tg/tl_account_set_reactions_notify_settings_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_account_set_reactions_notify_settings_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_account_toggle_sponsored_messages_gen.go b/tg/tl_account_toggle_sponsored_messages_gen.go new file mode 100644 index 0000000000..55e139f716 --- /dev/null +++ b/tg/tl_account_toggle_sponsored_messages_gen.go @@ -0,0 +1,177 @@ +// 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{} +) + +// AccountToggleSponsoredMessagesRequest represents TL type `account.toggleSponsoredMessages#b9d9a38d`. +// +// See https://core.telegram.org/method/account.toggleSponsoredMessages for reference. +type AccountToggleSponsoredMessagesRequest struct { + // Enabled field of AccountToggleSponsoredMessagesRequest. + Enabled bool +} + +// AccountToggleSponsoredMessagesRequestTypeID is TL type id of AccountToggleSponsoredMessagesRequest. +const AccountToggleSponsoredMessagesRequestTypeID = 0xb9d9a38d + +// Ensuring interfaces in compile-time for AccountToggleSponsoredMessagesRequest. +var ( + _ bin.Encoder = &AccountToggleSponsoredMessagesRequest{} + _ bin.Decoder = &AccountToggleSponsoredMessagesRequest{} + _ bin.BareEncoder = &AccountToggleSponsoredMessagesRequest{} + _ bin.BareDecoder = &AccountToggleSponsoredMessagesRequest{} +) + +func (t *AccountToggleSponsoredMessagesRequest) Zero() bool { + if t == nil { + return true + } + if !(t.Enabled == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (t *AccountToggleSponsoredMessagesRequest) String() string { + if t == nil { + return "AccountToggleSponsoredMessagesRequest(nil)" + } + type Alias AccountToggleSponsoredMessagesRequest + return fmt.Sprintf("AccountToggleSponsoredMessagesRequest%+v", Alias(*t)) +} + +// FillFrom fills AccountToggleSponsoredMessagesRequest from given interface. +func (t *AccountToggleSponsoredMessagesRequest) FillFrom(from interface { + GetEnabled() (value bool) +}) { + t.Enabled = from.GetEnabled() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountToggleSponsoredMessagesRequest) TypeID() uint32 { + return AccountToggleSponsoredMessagesRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountToggleSponsoredMessagesRequest) TypeName() string { + return "account.toggleSponsoredMessages" +} + +// TypeInfo returns info about TL type. +func (t *AccountToggleSponsoredMessagesRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.toggleSponsoredMessages", + ID: AccountToggleSponsoredMessagesRequestTypeID, + } + if t == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Enabled", + SchemaName: "enabled", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (t *AccountToggleSponsoredMessagesRequest) Encode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode account.toggleSponsoredMessages#b9d9a38d as nil") + } + b.PutID(AccountToggleSponsoredMessagesRequestTypeID) + return t.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (t *AccountToggleSponsoredMessagesRequest) EncodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode account.toggleSponsoredMessages#b9d9a38d as nil") + } + b.PutBool(t.Enabled) + return nil +} + +// Decode implements bin.Decoder. +func (t *AccountToggleSponsoredMessagesRequest) Decode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode account.toggleSponsoredMessages#b9d9a38d to nil") + } + if err := b.ConsumeID(AccountToggleSponsoredMessagesRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.toggleSponsoredMessages#b9d9a38d: %w", err) + } + return t.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (t *AccountToggleSponsoredMessagesRequest) DecodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode account.toggleSponsoredMessages#b9d9a38d to nil") + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode account.toggleSponsoredMessages#b9d9a38d: field enabled: %w", err) + } + t.Enabled = value + } + return nil +} + +// GetEnabled returns value of Enabled field. +func (t *AccountToggleSponsoredMessagesRequest) GetEnabled() (value bool) { + if t == nil { + return + } + return t.Enabled +} + +// AccountToggleSponsoredMessages invokes method account.toggleSponsoredMessages#b9d9a38d returning error if any. +// +// See https://core.telegram.org/method/account.toggleSponsoredMessages for reference. +func (c *Client) AccountToggleSponsoredMessages(ctx context.Context, enabled bool) (bool, error) { + var result BoolBox + + request := &AccountToggleSponsoredMessagesRequest{ + Enabled: enabled, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return false, err + } + _, ok := result.Bool.(*BoolTrue) + return ok, nil +} diff --git a/tg/tl_account_toggle_sponsored_messages_slices_gen.go b/tg/tl_account_toggle_sponsored_messages_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_account_toggle_sponsored_messages_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_channels_get_channel_recommendations_gen.go b/tg/tl_channels_get_channel_recommendations_gen.go index a011abf524..df7338f3a3 100644 --- a/tg/tl_channels_get_channel_recommendations_gen.go +++ b/tg/tl_channels_get_channel_recommendations_gen.go @@ -31,18 +31,22 @@ var ( _ = tdjson.Encoder{} ) -// ChannelsGetChannelRecommendationsRequest represents TL type `channels.getChannelRecommendations#83b70d97`. +// ChannelsGetChannelRecommendationsRequest represents TL type `channels.getChannelRecommendations#25a71742`. // Obtain a list of similarly themed public channels, selected based on similarities in // their subscriber bases. // // See https://core.telegram.org/method/channels.getChannelRecommendations for reference. type ChannelsGetChannelRecommendationsRequest struct { + // Flags field of ChannelsGetChannelRecommendationsRequest. + Flags bin.Fields // The method will return channels related to the passed channel. + // + // Use SetChannel and GetChannel helpers. Channel InputChannelClass } // ChannelsGetChannelRecommendationsRequestTypeID is TL type id of ChannelsGetChannelRecommendationsRequest. -const ChannelsGetChannelRecommendationsRequestTypeID = 0x83b70d97 +const ChannelsGetChannelRecommendationsRequestTypeID = 0x25a71742 // Ensuring interfaces in compile-time for ChannelsGetChannelRecommendationsRequest. var ( @@ -56,6 +60,9 @@ func (g *ChannelsGetChannelRecommendationsRequest) Zero() bool { if g == nil { return true } + if !(g.Flags.Zero()) { + return false + } if !(g.Channel == nil) { return false } @@ -74,9 +81,12 @@ func (g *ChannelsGetChannelRecommendationsRequest) String() string { // FillFrom fills ChannelsGetChannelRecommendationsRequest from given interface. func (g *ChannelsGetChannelRecommendationsRequest) FillFrom(from interface { - GetChannel() (value InputChannelClass) + GetChannel() (value InputChannelClass, ok bool) }) { - g.Channel = from.GetChannel() + if val, ok := from.GetChannel(); ok { + g.Channel = val + } + } // TypeID returns type id in TL schema. @@ -105,15 +115,23 @@ func (g *ChannelsGetChannelRecommendationsRequest) TypeInfo() tdp.Type { { Name: "Channel", SchemaName: "channel", + Null: !g.Flags.Has(0), }, } return typ } +// SetFlags sets flags for non-zero fields. +func (g *ChannelsGetChannelRecommendationsRequest) SetFlags() { + if !(g.Channel == nil) { + g.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (g *ChannelsGetChannelRecommendationsRequest) Encode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode channels.getChannelRecommendations#83b70d97 as nil") + return fmt.Errorf("can't encode channels.getChannelRecommendations#25a71742 as nil") } b.PutID(ChannelsGetChannelRecommendationsRequestTypeID) return g.EncodeBare(b) @@ -122,13 +140,19 @@ func (g *ChannelsGetChannelRecommendationsRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (g *ChannelsGetChannelRecommendationsRequest) EncodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode channels.getChannelRecommendations#83b70d97 as nil") + return fmt.Errorf("can't encode channels.getChannelRecommendations#25a71742 as nil") } - if g.Channel == nil { - return fmt.Errorf("unable to encode channels.getChannelRecommendations#83b70d97: field channel is nil") + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.getChannelRecommendations#25a71742: field flags: %w", err) } - if err := g.Channel.Encode(b); err != nil { - return fmt.Errorf("unable to encode channels.getChannelRecommendations#83b70d97: field channel: %w", err) + if g.Flags.Has(0) { + if g.Channel == nil { + return fmt.Errorf("unable to encode channels.getChannelRecommendations#25a71742: field channel is nil") + } + if err := g.Channel.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.getChannelRecommendations#25a71742: field channel: %w", err) + } } return nil } @@ -136,10 +160,10 @@ func (g *ChannelsGetChannelRecommendationsRequest) EncodeBare(b *bin.Buffer) err // Decode implements bin.Decoder. func (g *ChannelsGetChannelRecommendationsRequest) Decode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode channels.getChannelRecommendations#83b70d97 to nil") + return fmt.Errorf("can't decode channels.getChannelRecommendations#25a71742 to nil") } if err := b.ConsumeID(ChannelsGetChannelRecommendationsRequestTypeID); err != nil { - return fmt.Errorf("unable to decode channels.getChannelRecommendations#83b70d97: %w", err) + return fmt.Errorf("unable to decode channels.getChannelRecommendations#25a71742: %w", err) } return g.DecodeBare(b) } @@ -147,32 +171,51 @@ func (g *ChannelsGetChannelRecommendationsRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (g *ChannelsGetChannelRecommendationsRequest) DecodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode channels.getChannelRecommendations#83b70d97 to nil") + return fmt.Errorf("can't decode channels.getChannelRecommendations#25a71742 to nil") } { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode channels.getChannelRecommendations#25a71742: field flags: %w", err) + } + } + if g.Flags.Has(0) { value, err := DecodeInputChannel(b) if err != nil { - return fmt.Errorf("unable to decode channels.getChannelRecommendations#83b70d97: field channel: %w", err) + return fmt.Errorf("unable to decode channels.getChannelRecommendations#25a71742: field channel: %w", err) } g.Channel = value } return nil } -// GetChannel returns value of Channel field. -func (g *ChannelsGetChannelRecommendationsRequest) GetChannel() (value InputChannelClass) { +// SetChannel sets value of Channel conditional field. +func (g *ChannelsGetChannelRecommendationsRequest) SetChannel(value InputChannelClass) { + g.Flags.Set(0) + g.Channel = value +} + +// GetChannel returns value of Channel conditional field and +// boolean which is true if field was set. +func (g *ChannelsGetChannelRecommendationsRequest) GetChannel() (value InputChannelClass, ok bool) { if g == nil { return } - return g.Channel + if !g.Flags.Has(0) { + return value, false + } + return g.Channel, true } -// GetChannelAsNotEmpty returns mapped value of Channel field. +// GetChannelAsNotEmpty returns mapped value of Channel conditional field and +// boolean which is true if field was set. func (g *ChannelsGetChannelRecommendationsRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) { - return g.Channel.AsNotEmpty() + if value, ok := g.GetChannel(); ok { + return value.AsNotEmpty() + } + return nil, false } -// ChannelsGetChannelRecommendations invokes method channels.getChannelRecommendations#83b70d97 returning error if any. +// ChannelsGetChannelRecommendations invokes method channels.getChannelRecommendations#25a71742 returning error if any. // Obtain a list of similarly themed public channels, selected based on similarities in // their subscriber bases. // @@ -181,12 +224,9 @@ func (g *ChannelsGetChannelRecommendationsRequest) GetChannelAsNotEmpty() (NotEm // 400 CHANNEL_INVALID: The provided channel is invalid. // // See https://core.telegram.org/method/channels.getChannelRecommendations for reference. -func (c *Client) ChannelsGetChannelRecommendations(ctx context.Context, channel InputChannelClass) (MessagesChatsClass, error) { +func (c *Client) ChannelsGetChannelRecommendations(ctx context.Context, request *ChannelsGetChannelRecommendationsRequest) (MessagesChatsClass, error) { var result MessagesChatsBox - request := &ChannelsGetChannelRecommendationsRequest{ - Channel: channel, - } if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } diff --git a/tg/tl_chat_full_gen.go b/tg/tl_chat_full_gen.go index b3bac2bcda..bbb29a4eb7 100644 --- a/tg/tl_chat_full_gen.go +++ b/tg/tl_chat_full_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// ChatFull represents TL type `chatFull#c9d31138`. +// ChatFull represents TL type `chatFull#2633421b`. // Full info about a basic group¹. // // Links: @@ -128,10 +128,14 @@ type ChatFull struct { // // Use SetAvailableReactions and GetAvailableReactions helpers. AvailableReactions ChatReactionsClass + // ReactionsLimit field of ChatFull. + // + // Use SetReactionsLimit and GetReactionsLimit helpers. + ReactionsLimit int } // ChatFullTypeID is TL type id of ChatFull. -const ChatFullTypeID = 0xc9d31138 +const ChatFullTypeID = 0x2633421b // construct implements constructor of ChatFullClass. func (c ChatFull) construct() ChatFullClass { return &c } @@ -210,6 +214,9 @@ func (c *ChatFull) Zero() bool { if !(c.AvailableReactions == nil) { return false } + if !(c.ReactionsLimit == 0) { + return false + } return true } @@ -244,6 +251,7 @@ func (c *ChatFull) FillFrom(from interface { GetRequestsPending() (value int, ok bool) GetRecentRequesters() (value []int64, ok bool) GetAvailableReactions() (value ChatReactionsClass, ok bool) + GetReactionsLimit() (value int, ok bool) }) { c.CanSetUsername = from.GetCanSetUsername() c.HasScheduled = from.GetHasScheduled() @@ -300,6 +308,10 @@ func (c *ChatFull) FillFrom(from interface { c.AvailableReactions = val } + if val, ok := from.GetReactionsLimit(); ok { + c.ReactionsLimit = val + } + } // TypeID returns type id in TL schema. @@ -416,6 +428,11 @@ func (c *ChatFull) TypeInfo() tdp.Type { SchemaName: "available_reactions", Null: !c.Flags.Has(18), }, + { + Name: "ReactionsLimit", + SchemaName: "reactions_limit", + Null: !c.Flags.Has(20), + }, } return typ } @@ -467,12 +484,15 @@ func (c *ChatFull) SetFlags() { if !(c.AvailableReactions == nil) { c.Flags.Set(18) } + if !(c.ReactionsLimit == 0) { + c.Flags.Set(20) + } } // Encode implements bin.Encoder. func (c *ChatFull) Encode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode chatFull#c9d31138 as nil") + return fmt.Errorf("can't encode chatFull#2633421b as nil") } b.PutID(ChatFullTypeID) return c.EncodeBare(b) @@ -481,44 +501,44 @@ func (c *ChatFull) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (c *ChatFull) EncodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode chatFull#c9d31138 as nil") + return fmt.Errorf("can't encode chatFull#2633421b as nil") } c.SetFlags() if err := c.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field flags: %w", err) + return fmt.Errorf("unable to encode chatFull#2633421b: field flags: %w", err) } b.PutLong(c.ID) b.PutString(c.About) if c.Participants == nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field participants is nil") + return fmt.Errorf("unable to encode chatFull#2633421b: field participants is nil") } if err := c.Participants.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field participants: %w", err) + return fmt.Errorf("unable to encode chatFull#2633421b: field participants: %w", err) } if c.Flags.Has(2) { if c.ChatPhoto == nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field chat_photo is nil") + return fmt.Errorf("unable to encode chatFull#2633421b: field chat_photo is nil") } if err := c.ChatPhoto.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field chat_photo: %w", err) + return fmt.Errorf("unable to encode chatFull#2633421b: field chat_photo: %w", err) } } if err := c.NotifySettings.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field notify_settings: %w", err) + return fmt.Errorf("unable to encode chatFull#2633421b: field notify_settings: %w", err) } if c.Flags.Has(13) { if c.ExportedInvite == nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field exported_invite is nil") + return fmt.Errorf("unable to encode chatFull#2633421b: field exported_invite is nil") } if err := c.ExportedInvite.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field exported_invite: %w", err) + return fmt.Errorf("unable to encode chatFull#2633421b: field exported_invite: %w", err) } } if c.Flags.Has(3) { b.PutVectorHeader(len(c.BotInfo)) for idx, v := range c.BotInfo { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field bot_info element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode chatFull#2633421b: field bot_info element with index %d: %w", idx, err) } } } @@ -530,7 +550,7 @@ func (c *ChatFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(12) { if err := c.Call.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field call: %w", err) + return fmt.Errorf("unable to encode chatFull#2633421b: field call: %w", err) } } if c.Flags.Has(14) { @@ -538,10 +558,10 @@ func (c *ChatFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(15) { if c.GroupcallDefaultJoinAs == nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field groupcall_default_join_as is nil") + return fmt.Errorf("unable to encode chatFull#2633421b: field groupcall_default_join_as is nil") } if err := c.GroupcallDefaultJoinAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field groupcall_default_join_as: %w", err) + return fmt.Errorf("unable to encode chatFull#2633421b: field groupcall_default_join_as: %w", err) } } if c.Flags.Has(16) { @@ -558,22 +578,25 @@ func (c *ChatFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(18) { if c.AvailableReactions == nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field available_reactions is nil") + return fmt.Errorf("unable to encode chatFull#2633421b: field available_reactions is nil") } if err := c.AvailableReactions.Encode(b); err != nil { - return fmt.Errorf("unable to encode chatFull#c9d31138: field available_reactions: %w", err) + return fmt.Errorf("unable to encode chatFull#2633421b: field available_reactions: %w", err) } } + if c.Flags.Has(20) { + b.PutInt(c.ReactionsLimit) + } return nil } // Decode implements bin.Decoder. func (c *ChatFull) Decode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode chatFull#c9d31138 to nil") + return fmt.Errorf("can't decode chatFull#2633421b to nil") } if err := b.ConsumeID(ChatFullTypeID); err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: %w", err) } return c.DecodeBare(b) } @@ -581,11 +604,11 @@ func (c *ChatFull) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (c *ChatFull) DecodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode chatFull#c9d31138 to nil") + return fmt.Errorf("can't decode chatFull#2633421b to nil") } { if err := c.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field flags: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field flags: %w", err) } } c.CanSetUsername = c.Flags.Has(7) @@ -594,47 +617,47 @@ func (c *ChatFull) DecodeBare(b *bin.Buffer) error { { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field id: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field id: %w", err) } c.ID = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field about: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field about: %w", err) } c.About = value } { value, err := DecodeChatParticipants(b) if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field participants: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field participants: %w", err) } c.Participants = value } if c.Flags.Has(2) { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field chat_photo: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field chat_photo: %w", err) } c.ChatPhoto = value } { if err := c.NotifySettings.Decode(b); err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field notify_settings: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field notify_settings: %w", err) } } if c.Flags.Has(13) { value, err := DecodeExportedChatInvite(b) if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field exported_invite: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field exported_invite: %w", err) } c.ExportedInvite = value } if c.Flags.Has(3) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field bot_info: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field bot_info: %w", err) } if headerLen > 0 { @@ -643,7 +666,7 @@ func (c *ChatFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value BotInfo if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field bot_info: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field bot_info: %w", err) } c.BotInfo = append(c.BotInfo, value) } @@ -651,54 +674,54 @@ func (c *ChatFull) DecodeBare(b *bin.Buffer) error { if c.Flags.Has(6) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field pinned_msg_id: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field pinned_msg_id: %w", err) } c.PinnedMsgID = value } if c.Flags.Has(11) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field folder_id: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field folder_id: %w", err) } c.FolderID = value } if c.Flags.Has(12) { if err := c.Call.Decode(b); err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field call: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field call: %w", err) } } if c.Flags.Has(14) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field ttl_period: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field ttl_period: %w", err) } c.TTLPeriod = value } if c.Flags.Has(15) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field groupcall_default_join_as: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field groupcall_default_join_as: %w", err) } c.GroupcallDefaultJoinAs = value } if c.Flags.Has(16) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field theme_emoticon: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field theme_emoticon: %w", err) } c.ThemeEmoticon = value } if c.Flags.Has(17) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field requests_pending: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field requests_pending: %w", err) } c.RequestsPending = value } if c.Flags.Has(17) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field recent_requesters: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field recent_requesters: %w", err) } if headerLen > 0 { @@ -707,7 +730,7 @@ func (c *ChatFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field recent_requesters: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field recent_requesters: %w", err) } c.RecentRequesters = append(c.RecentRequesters, value) } @@ -715,10 +738,17 @@ func (c *ChatFull) DecodeBare(b *bin.Buffer) error { if c.Flags.Has(18) { value, err := DecodeChatReactions(b) if err != nil { - return fmt.Errorf("unable to decode chatFull#c9d31138: field available_reactions: %w", err) + return fmt.Errorf("unable to decode chatFull#2633421b: field available_reactions: %w", err) } c.AvailableReactions = value } + if c.Flags.Has(20) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode chatFull#2633421b: field reactions_limit: %w", err) + } + c.ReactionsLimit = value + } return nil } @@ -1027,7 +1057,25 @@ func (c *ChatFull) GetAvailableReactions() (value ChatReactionsClass, ok bool) { return c.AvailableReactions, true } -// ChannelFull represents TL type `channelFull#44c054a7`. +// SetReactionsLimit sets value of ReactionsLimit conditional field. +func (c *ChatFull) SetReactionsLimit(value int) { + c.Flags.Set(20) + c.ReactionsLimit = value +} + +// GetReactionsLimit returns value of ReactionsLimit conditional field and +// boolean which is true if field was set. +func (c *ChatFull) GetReactionsLimit() (value int, ok bool) { + if c == nil { + return + } + if !c.Flags.Has(20) { + return value, false + } + return c.ReactionsLimit, true +} + +// ChannelFull represents TL type `channelFull#bbab348d`. // Full info about a channel¹, supergroup² or gigagroup³. // // Links: @@ -1268,6 +1316,10 @@ type ChannelFull struct { // // Use SetAvailableReactions and GetAvailableReactions helpers. AvailableReactions ChatReactionsClass + // ReactionsLimit field of ChannelFull. + // + // Use SetReactionsLimit and GetReactionsLimit helpers. + ReactionsLimit int // Channel stories¹ // // Links: @@ -1297,7 +1349,7 @@ type ChannelFull struct { } // ChannelFullTypeID is TL type id of ChannelFull. -const ChannelFullTypeID = 0x44c054a7 +const ChannelFullTypeID = 0xbbab348d // construct implements constructor of ChatFullClass. func (c ChannelFull) construct() ChatFullClass { return &c } @@ -1475,6 +1527,9 @@ func (c *ChannelFull) Zero() bool { if !(c.AvailableReactions == nil) { return false } + if !(c.ReactionsLimit == 0) { + return false + } if !(c.Stories.Zero()) { return false } @@ -1556,6 +1611,7 @@ func (c *ChannelFull) FillFrom(from interface { GetRecentRequesters() (value []int64, ok bool) GetDefaultSendAs() (value PeerClass, ok bool) GetAvailableReactions() (value ChatReactionsClass, ok bool) + GetReactionsLimit() (value int, ok bool) GetStories() (value PeerStories, ok bool) GetWallpaper() (value WallPaperClass, ok bool) GetBoostsApplied() (value int, ok bool) @@ -1691,6 +1747,10 @@ func (c *ChannelFull) FillFrom(from interface { c.AvailableReactions = val } + if val, ok := from.GetReactionsLimit(); ok { + c.ReactionsLimit = val + } + if val, ok := from.GetStories(); ok { c.Stories = val } @@ -1982,6 +2042,11 @@ func (c *ChannelFull) TypeInfo() tdp.Type { SchemaName: "available_reactions", Null: !c.Flags.Has(30), }, + { + Name: "ReactionsLimit", + SchemaName: "reactions_limit", + Null: !c.Flags2.Has(13), + }, { Name: "Stories", SchemaName: "stories", @@ -2139,6 +2204,9 @@ func (c *ChannelFull) SetFlags() { if !(c.AvailableReactions == nil) { c.Flags.Set(30) } + if !(c.ReactionsLimit == 0) { + c.Flags2.Set(13) + } if !(c.Stories.Zero()) { c.Flags2.Set(4) } @@ -2159,7 +2227,7 @@ func (c *ChannelFull) SetFlags() { // Encode implements bin.Encoder. func (c *ChannelFull) Encode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channelFull#44c054a7 as nil") + return fmt.Errorf("can't encode channelFull#bbab348d as nil") } b.PutID(ChannelFullTypeID) return c.EncodeBare(b) @@ -2168,14 +2236,14 @@ func (c *ChannelFull) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channelFull#44c054a7 as nil") + return fmt.Errorf("can't encode channelFull#bbab348d as nil") } c.SetFlags() if err := c.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field flags: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field flags: %w", err) } if err := c.Flags2.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field flags2: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field flags2: %w", err) } b.PutLong(c.ID) b.PutString(c.About) @@ -2198,26 +2266,26 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { b.PutInt(c.ReadOutboxMaxID) b.PutInt(c.UnreadCount) if c.ChatPhoto == nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field chat_photo is nil") + return fmt.Errorf("unable to encode channelFull#bbab348d: field chat_photo is nil") } if err := c.ChatPhoto.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field chat_photo: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field chat_photo: %w", err) } if err := c.NotifySettings.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field notify_settings: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field notify_settings: %w", err) } if c.Flags.Has(23) { if c.ExportedInvite == nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field exported_invite is nil") + return fmt.Errorf("unable to encode channelFull#bbab348d: field exported_invite is nil") } if err := c.ExportedInvite.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field exported_invite: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field exported_invite: %w", err) } } b.PutVectorHeader(len(c.BotInfo)) for idx, v := range c.BotInfo { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field bot_info element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field bot_info element with index %d: %w", idx, err) } } if c.Flags.Has(4) { @@ -2231,7 +2299,7 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(8) { if err := c.Stickerset.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field stickerset: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field stickerset: %w", err) } } if c.Flags.Has(9) { @@ -2245,10 +2313,10 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(15) { if c.Location == nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field location is nil") + return fmt.Errorf("unable to encode channelFull#bbab348d: field location is nil") } if err := c.Location.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field location: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field location: %w", err) } } if c.Flags.Has(17) { @@ -2263,7 +2331,7 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { b.PutInt(c.Pts) if c.Flags.Has(21) { if err := c.Call.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field call: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field call: %w", err) } } if c.Flags.Has(24) { @@ -2277,10 +2345,10 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(26) { if c.GroupcallDefaultJoinAs == nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field groupcall_default_join_as is nil") + return fmt.Errorf("unable to encode channelFull#bbab348d: field groupcall_default_join_as is nil") } if err := c.GroupcallDefaultJoinAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field groupcall_default_join_as: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field groupcall_default_join_as: %w", err) } } if c.Flags.Has(27) { @@ -2297,31 +2365,34 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(29) { if c.DefaultSendAs == nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field default_send_as is nil") + return fmt.Errorf("unable to encode channelFull#bbab348d: field default_send_as is nil") } if err := c.DefaultSendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field default_send_as: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field default_send_as: %w", err) } } if c.Flags.Has(30) { if c.AvailableReactions == nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field available_reactions is nil") + return fmt.Errorf("unable to encode channelFull#bbab348d: field available_reactions is nil") } if err := c.AvailableReactions.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field available_reactions: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field available_reactions: %w", err) } } + if c.Flags2.Has(13) { + b.PutInt(c.ReactionsLimit) + } if c.Flags2.Has(4) { if err := c.Stories.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field stories: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field stories: %w", err) } } if c.Flags2.Has(7) { if c.Wallpaper == nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field wallpaper is nil") + return fmt.Errorf("unable to encode channelFull#bbab348d: field wallpaper is nil") } if err := c.Wallpaper.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field wallpaper: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field wallpaper: %w", err) } } if c.Flags2.Has(8) { @@ -2332,7 +2403,7 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { } if c.Flags2.Has(10) { if err := c.Emojiset.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#44c054a7: field emojiset: %w", err) + return fmt.Errorf("unable to encode channelFull#bbab348d: field emojiset: %w", err) } } return nil @@ -2341,10 +2412,10 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (c *ChannelFull) Decode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channelFull#44c054a7 to nil") + return fmt.Errorf("can't decode channelFull#bbab348d to nil") } if err := b.ConsumeID(ChannelFullTypeID); err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: %w", err) } return c.DecodeBare(b) } @@ -2352,11 +2423,11 @@ func (c *ChannelFull) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channelFull#44c054a7 to nil") + return fmt.Errorf("can't decode channelFull#bbab348d to nil") } { if err := c.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field flags: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field flags: %w", err) } } c.CanViewParticipants = c.Flags.Has(3) @@ -2369,7 +2440,7 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { c.Blocked = c.Flags.Has(22) { if err := c.Flags2.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field flags2: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field flags2: %w", err) } } c.CanDeleteChannel = c.Flags2.Has(0) @@ -2383,96 +2454,96 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field id: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field id: %w", err) } c.ID = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field about: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field about: %w", err) } c.About = value } if c.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field participants_count: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field participants_count: %w", err) } c.ParticipantsCount = value } if c.Flags.Has(1) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field admins_count: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field admins_count: %w", err) } c.AdminsCount = value } if c.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field kicked_count: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field kicked_count: %w", err) } c.KickedCount = value } if c.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field banned_count: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field banned_count: %w", err) } c.BannedCount = value } if c.Flags.Has(13) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field online_count: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field online_count: %w", err) } c.OnlineCount = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field read_inbox_max_id: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field read_inbox_max_id: %w", err) } c.ReadInboxMaxID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field read_outbox_max_id: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field read_outbox_max_id: %w", err) } c.ReadOutboxMaxID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field unread_count: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field unread_count: %w", err) } c.UnreadCount = value } { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field chat_photo: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field chat_photo: %w", err) } c.ChatPhoto = value } { if err := c.NotifySettings.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field notify_settings: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field notify_settings: %w", err) } } if c.Flags.Has(23) { value, err := DecodeExportedChatInvite(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field exported_invite: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field exported_invite: %w", err) } c.ExportedInvite = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field bot_info: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field bot_info: %w", err) } if headerLen > 0 { @@ -2481,7 +2552,7 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value BotInfo if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field bot_info: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field bot_info: %w", err) } c.BotInfo = append(c.BotInfo, value) } @@ -2489,101 +2560,101 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { if c.Flags.Has(4) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field migrated_from_chat_id: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field migrated_from_chat_id: %w", err) } c.MigratedFromChatID = value } if c.Flags.Has(4) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field migrated_from_max_id: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field migrated_from_max_id: %w", err) } c.MigratedFromMaxID = value } if c.Flags.Has(5) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field pinned_msg_id: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field pinned_msg_id: %w", err) } c.PinnedMsgID = value } if c.Flags.Has(8) { if err := c.Stickerset.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field stickerset: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field stickerset: %w", err) } } if c.Flags.Has(9) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field available_min_id: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field available_min_id: %w", err) } c.AvailableMinID = value } if c.Flags.Has(11) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field folder_id: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field folder_id: %w", err) } c.FolderID = value } if c.Flags.Has(14) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field linked_chat_id: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field linked_chat_id: %w", err) } c.LinkedChatID = value } if c.Flags.Has(15) { value, err := DecodeChannelLocation(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field location: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field location: %w", err) } c.Location = value } if c.Flags.Has(17) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field slowmode_seconds: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field slowmode_seconds: %w", err) } c.SlowmodeSeconds = value } if c.Flags.Has(18) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field slowmode_next_send_date: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field slowmode_next_send_date: %w", err) } c.SlowmodeNextSendDate = value } if c.Flags.Has(12) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field stats_dc: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field stats_dc: %w", err) } c.StatsDC = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field pts: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field pts: %w", err) } c.Pts = value } if c.Flags.Has(21) { if err := c.Call.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field call: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field call: %w", err) } } if c.Flags.Has(24) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field ttl_period: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field ttl_period: %w", err) } c.TTLPeriod = value } if c.Flags.Has(25) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field pending_suggestions: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field pending_suggestions: %w", err) } if headerLen > 0 { @@ -2592,7 +2663,7 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field pending_suggestions: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field pending_suggestions: %w", err) } c.PendingSuggestions = append(c.PendingSuggestions, value) } @@ -2600,28 +2671,28 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { if c.Flags.Has(26) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field groupcall_default_join_as: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field groupcall_default_join_as: %w", err) } c.GroupcallDefaultJoinAs = value } if c.Flags.Has(27) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field theme_emoticon: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field theme_emoticon: %w", err) } c.ThemeEmoticon = value } if c.Flags.Has(28) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field requests_pending: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field requests_pending: %w", err) } c.RequestsPending = value } if c.Flags.Has(28) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field recent_requesters: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field recent_requesters: %w", err) } if headerLen > 0 { @@ -2630,7 +2701,7 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field recent_requesters: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field recent_requesters: %w", err) } c.RecentRequesters = append(c.RecentRequesters, value) } @@ -2638,46 +2709,53 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { if c.Flags.Has(29) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field default_send_as: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field default_send_as: %w", err) } c.DefaultSendAs = value } if c.Flags.Has(30) { value, err := DecodeChatReactions(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field available_reactions: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field available_reactions: %w", err) } c.AvailableReactions = value } + if c.Flags2.Has(13) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channelFull#bbab348d: field reactions_limit: %w", err) + } + c.ReactionsLimit = value + } if c.Flags2.Has(4) { if err := c.Stories.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field stories: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field stories: %w", err) } } if c.Flags2.Has(7) { value, err := DecodeWallPaper(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field wallpaper: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field wallpaper: %w", err) } c.Wallpaper = value } if c.Flags2.Has(8) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field boosts_applied: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field boosts_applied: %w", err) } c.BoostsApplied = value } if c.Flags2.Has(9) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field boosts_unrestrict: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field boosts_unrestrict: %w", err) } c.BoostsUnrestrict = value } if c.Flags2.Has(10) { if err := c.Emojiset.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#44c054a7: field emojiset: %w", err) + return fmt.Errorf("unable to decode channelFull#bbab348d: field emojiset: %w", err) } } return nil @@ -3527,6 +3605,24 @@ func (c *ChannelFull) GetAvailableReactions() (value ChatReactionsClass, ok bool return c.AvailableReactions, true } +// SetReactionsLimit sets value of ReactionsLimit conditional field. +func (c *ChannelFull) SetReactionsLimit(value int) { + c.Flags2.Set(13) + c.ReactionsLimit = value +} + +// GetReactionsLimit returns value of ReactionsLimit conditional field and +// boolean which is true if field was set. +func (c *ChannelFull) GetReactionsLimit() (value int, ok bool) { + if c == nil { + return + } + if !c.Flags2.Has(13) { + return value, false + } + return c.ReactionsLimit, true +} + // SetStories sets value of Stories conditional field. func (c *ChannelFull) SetStories(value PeerStories) { c.Flags2.Set(4) @@ -3631,8 +3727,8 @@ const ChatFullClassName = "ChatFull" // panic(err) // } // switch v := g.(type) { -// case *tg.ChatFull: // chatFull#c9d31138 -// case *tg.ChannelFull: // channelFull#44c054a7 +// case *tg.ChatFull: // chatFull#2633421b +// case *tg.ChannelFull: // channelFull#bbab348d // default: panic(v) // } type ChatFullClass interface { @@ -3721,6 +3817,9 @@ type ChatFullClass interface { // Links: // 1) https://core.telegram.org/api/reactions GetAvailableReactions() (value ChatReactionsClass, ok bool) + + // ReactionsLimit field of ChatFull. + GetReactionsLimit() (value int, ok bool) } // DecodeChatFull implements binary de-serialization for ChatFullClass. @@ -3731,14 +3830,14 @@ func DecodeChatFull(buf *bin.Buffer) (ChatFullClass, error) { } switch id { case ChatFullTypeID: - // Decoding chatFull#c9d31138. + // Decoding chatFull#2633421b. v := ChatFull{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ChatFullClass: %w", err) } return &v, nil case ChannelFullTypeID: - // Decoding channelFull#44c054a7. + // Decoding channelFull#bbab348d. v := ChannelFull{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ChatFullClass: %w", err) diff --git a/tg/tl_code_settings_gen.go b/tg/tl_code_settings_gen.go index 3d32f8c26c..eccf4eb78c 100644 --- a/tg/tl_code_settings_gen.go +++ b/tg/tl_code_settings_gen.go @@ -68,6 +68,8 @@ type CodeSettings struct { AllowMissedCall bool // Whether Firebase auth is supported AllowFirebase bool + // UnknownNumber field of CodeSettings. + UnknownNumber bool // Previously stored future auth tokens, see the documentation for more info »¹ // // Links: @@ -119,6 +121,9 @@ func (c *CodeSettings) Zero() bool { if !(c.AllowFirebase == false) { return false } + if !(c.UnknownNumber == false) { + return false + } if !(c.LogoutTokens == nil) { return false } @@ -148,6 +153,7 @@ func (c *CodeSettings) FillFrom(from interface { GetAllowAppHash() (value bool) GetAllowMissedCall() (value bool) GetAllowFirebase() (value bool) + GetUnknownNumber() (value bool) GetLogoutTokens() (value [][]byte, ok bool) GetToken() (value string, ok bool) GetAppSandbox() (value bool, ok bool) @@ -157,6 +163,7 @@ func (c *CodeSettings) FillFrom(from interface { c.AllowAppHash = from.GetAllowAppHash() c.AllowMissedCall = from.GetAllowMissedCall() c.AllowFirebase = from.GetAllowFirebase() + c.UnknownNumber = from.GetUnknownNumber() if val, ok := from.GetLogoutTokens(); ok { c.LogoutTokens = val } @@ -219,6 +226,11 @@ func (c *CodeSettings) TypeInfo() tdp.Type { SchemaName: "allow_firebase", Null: !c.Flags.Has(7), }, + { + Name: "UnknownNumber", + SchemaName: "unknown_number", + Null: !c.Flags.Has(9), + }, { Name: "LogoutTokens", SchemaName: "logout_tokens", @@ -255,6 +267,9 @@ func (c *CodeSettings) SetFlags() { if !(c.AllowFirebase == false) { c.Flags.Set(7) } + if !(c.UnknownNumber == false) { + c.Flags.Set(9) + } if !(c.LogoutTokens == nil) { c.Flags.Set(6) } @@ -325,6 +340,7 @@ func (c *CodeSettings) DecodeBare(b *bin.Buffer) error { c.AllowAppHash = c.Flags.Has(4) c.AllowMissedCall = c.Flags.Has(5) c.AllowFirebase = c.Flags.Has(7) + c.UnknownNumber = c.Flags.Has(9) if c.Flags.Has(6) { headerLen, err := b.VectorHeader() if err != nil { @@ -454,6 +470,25 @@ func (c *CodeSettings) GetAllowFirebase() (value bool) { return c.Flags.Has(7) } +// SetUnknownNumber sets value of UnknownNumber conditional field. +func (c *CodeSettings) SetUnknownNumber(value bool) { + if value { + c.Flags.Set(9) + c.UnknownNumber = true + } else { + c.Flags.Unset(9) + c.UnknownNumber = false + } +} + +// GetUnknownNumber returns value of UnknownNumber conditional field. +func (c *CodeSettings) GetUnknownNumber() (value bool) { + if c == nil { + return + } + return c.Flags.Has(9) +} + // SetLogoutTokens sets value of LogoutTokens conditional field. func (c *CodeSettings) SetLogoutTokens(value [][]byte) { c.Flags.Set(6) diff --git a/tg/tl_handlers_gen.go b/tg/tl_handlers_gen.go index fdd1c06b58..123ed501eb 100644 --- a/tg/tl_handlers_gen.go +++ b/tg/tl_handlers_gen.go @@ -1445,3 +1445,13 @@ func (u UpdateDispatcher) OnBotDeleteBusinessMessage(handler BotDeleteBusinessMe return handler(ctx, e, update.(*UpdateBotDeleteBusinessMessage)) } } + +// NewStoryReactionHandler is a NewStoryReaction event handler. +type NewStoryReactionHandler func(ctx context.Context, e Entities, update *UpdateNewStoryReaction) error + +// OnNewStoryReaction sets NewStoryReaction handler. +func (u UpdateDispatcher) OnNewStoryReaction(handler NewStoryReactionHandler) { + u.handlers[UpdateNewStoryReactionTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateNewStoryReaction)) + } +} diff --git a/tg/tl_messages_search_global_gen.go b/tg/tl_messages_search_global_gen.go index 26a21145f3..988977398b 100644 --- a/tg/tl_messages_search_global_gen.go +++ b/tg/tl_messages_search_global_gen.go @@ -41,6 +41,8 @@ type MessagesSearchGlobalRequest struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields + // BroadcastsOnly field of MessagesSearchGlobalRequest. + BroadcastsOnly bool // Peer folder ID, for more info click here¹ // // Links: @@ -98,6 +100,9 @@ func (s *MessagesSearchGlobalRequest) Zero() bool { if !(s.Flags.Zero()) { return false } + if !(s.BroadcastsOnly == false) { + return false + } if !(s.FolderID == 0) { return false } @@ -140,6 +145,7 @@ func (s *MessagesSearchGlobalRequest) String() string { // FillFrom fills MessagesSearchGlobalRequest from given interface. func (s *MessagesSearchGlobalRequest) FillFrom(from interface { + GetBroadcastsOnly() (value bool) GetFolderID() (value int, ok bool) GetQ() (value string) GetFilter() (value MessagesFilterClass) @@ -150,6 +156,7 @@ func (s *MessagesSearchGlobalRequest) FillFrom(from interface { GetOffsetID() (value int) GetLimit() (value int) }) { + s.BroadcastsOnly = from.GetBroadcastsOnly() if val, ok := from.GetFolderID(); ok { s.FolderID = val } @@ -187,6 +194,11 @@ func (s *MessagesSearchGlobalRequest) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "BroadcastsOnly", + SchemaName: "broadcasts_only", + Null: !s.Flags.Has(1), + }, { Name: "FolderID", SchemaName: "folder_id", @@ -230,6 +242,9 @@ func (s *MessagesSearchGlobalRequest) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (s *MessagesSearchGlobalRequest) SetFlags() { + if !(s.BroadcastsOnly == false) { + s.Flags.Set(1) + } if !(s.FolderID == 0) { s.Flags.Set(0) } @@ -298,6 +313,7 @@ func (s *MessagesSearchGlobalRequest) DecodeBare(b *bin.Buffer) error { return fmt.Errorf("unable to decode messages.searchGlobal#4bc6589a: field flags: %w", err) } } + s.BroadcastsOnly = s.Flags.Has(1) if s.Flags.Has(0) { value, err := b.Int() if err != nil { @@ -364,6 +380,25 @@ func (s *MessagesSearchGlobalRequest) DecodeBare(b *bin.Buffer) error { return nil } +// SetBroadcastsOnly sets value of BroadcastsOnly conditional field. +func (s *MessagesSearchGlobalRequest) SetBroadcastsOnly(value bool) { + if value { + s.Flags.Set(1) + s.BroadcastsOnly = true + } else { + s.Flags.Unset(1) + s.BroadcastsOnly = false + } +} + +// GetBroadcastsOnly returns value of BroadcastsOnly conditional field. +func (s *MessagesSearchGlobalRequest) GetBroadcastsOnly() (value bool) { + if s == nil { + return + } + return s.Flags.Has(1) +} + // SetFolderID sets value of FolderID conditional field. func (s *MessagesSearchGlobalRequest) SetFolderID(value int) { s.Flags.Set(0) diff --git a/tg/tl_messages_set_chat_available_reactions_gen.go b/tg/tl_messages_set_chat_available_reactions_gen.go index b63249a010..7056e21622 100644 --- a/tg/tl_messages_set_chat_available_reactions_gen.go +++ b/tg/tl_messages_set_chat_available_reactions_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSetChatAvailableReactionsRequest represents TL type `messages.setChatAvailableReactions#feb16771`. +// MessagesSetChatAvailableReactionsRequest represents TL type `messages.setChatAvailableReactions#5a150bd4`. // Change the set of message reactions »¹ that can be used in a certain group, // supergroup or channel // @@ -40,14 +40,20 @@ var ( // // See https://core.telegram.org/method/messages.setChatAvailableReactions for reference. type MessagesSetChatAvailableReactionsRequest struct { + // Flags field of MessagesSetChatAvailableReactionsRequest. + Flags bin.Fields // Group where to apply changes Peer InputPeerClass // Allowed reaction emojis AvailableReactions ChatReactionsClass + // ReactionsLimit field of MessagesSetChatAvailableReactionsRequest. + // + // Use SetReactionsLimit and GetReactionsLimit helpers. + ReactionsLimit int } // MessagesSetChatAvailableReactionsRequestTypeID is TL type id of MessagesSetChatAvailableReactionsRequest. -const MessagesSetChatAvailableReactionsRequestTypeID = 0xfeb16771 +const MessagesSetChatAvailableReactionsRequestTypeID = 0x5a150bd4 // Ensuring interfaces in compile-time for MessagesSetChatAvailableReactionsRequest. var ( @@ -61,12 +67,18 @@ func (s *MessagesSetChatAvailableReactionsRequest) Zero() bool { if s == nil { return true } + if !(s.Flags.Zero()) { + return false + } if !(s.Peer == nil) { return false } if !(s.AvailableReactions == nil) { return false } + if !(s.ReactionsLimit == 0) { + return false + } return true } @@ -84,9 +96,14 @@ func (s *MessagesSetChatAvailableReactionsRequest) String() string { func (s *MessagesSetChatAvailableReactionsRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) GetAvailableReactions() (value ChatReactionsClass) + GetReactionsLimit() (value int, ok bool) }) { s.Peer = from.GetPeer() s.AvailableReactions = from.GetAvailableReactions() + if val, ok := from.GetReactionsLimit(); ok { + s.ReactionsLimit = val + } + } // TypeID returns type id in TL schema. @@ -120,14 +137,26 @@ func (s *MessagesSetChatAvailableReactionsRequest) TypeInfo() tdp.Type { Name: "AvailableReactions", SchemaName: "available_reactions", }, + { + Name: "ReactionsLimit", + SchemaName: "reactions_limit", + Null: !s.Flags.Has(0), + }, } return typ } +// SetFlags sets flags for non-zero fields. +func (s *MessagesSetChatAvailableReactionsRequest) SetFlags() { + if !(s.ReactionsLimit == 0) { + s.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (s *MessagesSetChatAvailableReactionsRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.setChatAvailableReactions#feb16771 as nil") + return fmt.Errorf("can't encode messages.setChatAvailableReactions#5a150bd4 as nil") } b.PutID(MessagesSetChatAvailableReactionsRequestTypeID) return s.EncodeBare(b) @@ -136,19 +165,26 @@ func (s *MessagesSetChatAvailableReactionsRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSetChatAvailableReactionsRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.setChatAvailableReactions#feb16771 as nil") + return fmt.Errorf("can't encode messages.setChatAvailableReactions#5a150bd4 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.setChatAvailableReactions#5a150bd4: field flags: %w", err) } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.setChatAvailableReactions#feb16771: field peer is nil") + return fmt.Errorf("unable to encode messages.setChatAvailableReactions#5a150bd4: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.setChatAvailableReactions#feb16771: field peer: %w", err) + return fmt.Errorf("unable to encode messages.setChatAvailableReactions#5a150bd4: field peer: %w", err) } if s.AvailableReactions == nil { - return fmt.Errorf("unable to encode messages.setChatAvailableReactions#feb16771: field available_reactions is nil") + return fmt.Errorf("unable to encode messages.setChatAvailableReactions#5a150bd4: field available_reactions is nil") } if err := s.AvailableReactions.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.setChatAvailableReactions#feb16771: field available_reactions: %w", err) + return fmt.Errorf("unable to encode messages.setChatAvailableReactions#5a150bd4: field available_reactions: %w", err) + } + if s.Flags.Has(0) { + b.PutInt(s.ReactionsLimit) } return nil } @@ -156,10 +192,10 @@ func (s *MessagesSetChatAvailableReactionsRequest) EncodeBare(b *bin.Buffer) err // Decode implements bin.Decoder. func (s *MessagesSetChatAvailableReactionsRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.setChatAvailableReactions#feb16771 to nil") + return fmt.Errorf("can't decode messages.setChatAvailableReactions#5a150bd4 to nil") } if err := b.ConsumeID(MessagesSetChatAvailableReactionsRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.setChatAvailableReactions#feb16771: %w", err) + return fmt.Errorf("unable to decode messages.setChatAvailableReactions#5a150bd4: %w", err) } return s.DecodeBare(b) } @@ -167,22 +203,34 @@ func (s *MessagesSetChatAvailableReactionsRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSetChatAvailableReactionsRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.setChatAvailableReactions#feb16771 to nil") + return fmt.Errorf("can't decode messages.setChatAvailableReactions#5a150bd4 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.setChatAvailableReactions#5a150bd4: field flags: %w", err) + } } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.setChatAvailableReactions#feb16771: field peer: %w", err) + return fmt.Errorf("unable to decode messages.setChatAvailableReactions#5a150bd4: field peer: %w", err) } s.Peer = value } { value, err := DecodeChatReactions(b) if err != nil { - return fmt.Errorf("unable to decode messages.setChatAvailableReactions#feb16771: field available_reactions: %w", err) + return fmt.Errorf("unable to decode messages.setChatAvailableReactions#5a150bd4: field available_reactions: %w", err) } s.AvailableReactions = value } + if s.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.setChatAvailableReactions#5a150bd4: field reactions_limit: %w", err) + } + s.ReactionsLimit = value + } return nil } @@ -202,7 +250,25 @@ func (s *MessagesSetChatAvailableReactionsRequest) GetAvailableReactions() (valu return s.AvailableReactions } -// MessagesSetChatAvailableReactions invokes method messages.setChatAvailableReactions#feb16771 returning error if any. +// SetReactionsLimit sets value of ReactionsLimit conditional field. +func (s *MessagesSetChatAvailableReactionsRequest) SetReactionsLimit(value int) { + s.Flags.Set(0) + s.ReactionsLimit = value +} + +// GetReactionsLimit returns value of ReactionsLimit conditional field and +// boolean which is true if field was set. +func (s *MessagesSetChatAvailableReactionsRequest) GetReactionsLimit() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.ReactionsLimit, true +} + +// MessagesSetChatAvailableReactions invokes method messages.setChatAvailableReactions#5a150bd4 returning error if any. // Change the set of message reactions »¹ that can be used in a certain group, // supergroup or channel // diff --git a/tg/tl_reaction_notifications_from_gen.go b/tg/tl_reaction_notifications_from_gen.go new file mode 100644 index 0000000000..1f0f312a27 --- /dev/null +++ b/tg/tl_reaction_notifications_from_gen.go @@ -0,0 +1,323 @@ +// 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{} +) + +// ReactionNotificationsFromContacts represents TL type `reactionNotificationsFromContacts#bac3a61a`. +// +// See https://core.telegram.org/constructor/reactionNotificationsFromContacts for reference. +type ReactionNotificationsFromContacts struct { +} + +// ReactionNotificationsFromContactsTypeID is TL type id of ReactionNotificationsFromContacts. +const ReactionNotificationsFromContactsTypeID = 0xbac3a61a + +// construct implements constructor of ReactionNotificationsFromClass. +func (r ReactionNotificationsFromContacts) construct() ReactionNotificationsFromClass { return &r } + +// Ensuring interfaces in compile-time for ReactionNotificationsFromContacts. +var ( + _ bin.Encoder = &ReactionNotificationsFromContacts{} + _ bin.Decoder = &ReactionNotificationsFromContacts{} + _ bin.BareEncoder = &ReactionNotificationsFromContacts{} + _ bin.BareDecoder = &ReactionNotificationsFromContacts{} + + _ ReactionNotificationsFromClass = &ReactionNotificationsFromContacts{} +) + +func (r *ReactionNotificationsFromContacts) Zero() bool { + if r == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (r *ReactionNotificationsFromContacts) String() string { + if r == nil { + return "ReactionNotificationsFromContacts(nil)" + } + type Alias ReactionNotificationsFromContacts + return fmt.Sprintf("ReactionNotificationsFromContacts%+v", Alias(*r)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ReactionNotificationsFromContacts) TypeID() uint32 { + return ReactionNotificationsFromContactsTypeID +} + +// TypeName returns name of type in TL schema. +func (*ReactionNotificationsFromContacts) TypeName() string { + return "reactionNotificationsFromContacts" +} + +// TypeInfo returns info about TL type. +func (r *ReactionNotificationsFromContacts) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "reactionNotificationsFromContacts", + ID: ReactionNotificationsFromContactsTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (r *ReactionNotificationsFromContacts) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reactionNotificationsFromContacts#bac3a61a as nil") + } + b.PutID(ReactionNotificationsFromContactsTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *ReactionNotificationsFromContacts) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reactionNotificationsFromContacts#bac3a61a as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (r *ReactionNotificationsFromContacts) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reactionNotificationsFromContacts#bac3a61a to nil") + } + if err := b.ConsumeID(ReactionNotificationsFromContactsTypeID); err != nil { + return fmt.Errorf("unable to decode reactionNotificationsFromContacts#bac3a61a: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *ReactionNotificationsFromContacts) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reactionNotificationsFromContacts#bac3a61a to nil") + } + return nil +} + +// ReactionNotificationsFromAll represents TL type `reactionNotificationsFromAll#4b9e22a0`. +// +// See https://core.telegram.org/constructor/reactionNotificationsFromAll for reference. +type ReactionNotificationsFromAll struct { +} + +// ReactionNotificationsFromAllTypeID is TL type id of ReactionNotificationsFromAll. +const ReactionNotificationsFromAllTypeID = 0x4b9e22a0 + +// construct implements constructor of ReactionNotificationsFromClass. +func (r ReactionNotificationsFromAll) construct() ReactionNotificationsFromClass { return &r } + +// Ensuring interfaces in compile-time for ReactionNotificationsFromAll. +var ( + _ bin.Encoder = &ReactionNotificationsFromAll{} + _ bin.Decoder = &ReactionNotificationsFromAll{} + _ bin.BareEncoder = &ReactionNotificationsFromAll{} + _ bin.BareDecoder = &ReactionNotificationsFromAll{} + + _ ReactionNotificationsFromClass = &ReactionNotificationsFromAll{} +) + +func (r *ReactionNotificationsFromAll) Zero() bool { + if r == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (r *ReactionNotificationsFromAll) String() string { + if r == nil { + return "ReactionNotificationsFromAll(nil)" + } + type Alias ReactionNotificationsFromAll + return fmt.Sprintf("ReactionNotificationsFromAll%+v", Alias(*r)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ReactionNotificationsFromAll) TypeID() uint32 { + return ReactionNotificationsFromAllTypeID +} + +// TypeName returns name of type in TL schema. +func (*ReactionNotificationsFromAll) TypeName() string { + return "reactionNotificationsFromAll" +} + +// TypeInfo returns info about TL type. +func (r *ReactionNotificationsFromAll) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "reactionNotificationsFromAll", + ID: ReactionNotificationsFromAllTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (r *ReactionNotificationsFromAll) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reactionNotificationsFromAll#4b9e22a0 as nil") + } + b.PutID(ReactionNotificationsFromAllTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *ReactionNotificationsFromAll) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reactionNotificationsFromAll#4b9e22a0 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (r *ReactionNotificationsFromAll) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reactionNotificationsFromAll#4b9e22a0 to nil") + } + if err := b.ConsumeID(ReactionNotificationsFromAllTypeID); err != nil { + return fmt.Errorf("unable to decode reactionNotificationsFromAll#4b9e22a0: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *ReactionNotificationsFromAll) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reactionNotificationsFromAll#4b9e22a0 to nil") + } + return nil +} + +// ReactionNotificationsFromClassName is schema name of ReactionNotificationsFromClass. +const ReactionNotificationsFromClassName = "ReactionNotificationsFrom" + +// ReactionNotificationsFromClass represents ReactionNotificationsFrom generic type. +// +// See https://core.telegram.org/type/ReactionNotificationsFrom for reference. +// +// Example: +// +// g, err := tg.DecodeReactionNotificationsFrom(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.ReactionNotificationsFromContacts: // reactionNotificationsFromContacts#bac3a61a +// case *tg.ReactionNotificationsFromAll: // reactionNotificationsFromAll#4b9e22a0 +// default: panic(v) +// } +type ReactionNotificationsFromClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() ReactionNotificationsFromClass + + // 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 +} + +// DecodeReactionNotificationsFrom implements binary de-serialization for ReactionNotificationsFromClass. +func DecodeReactionNotificationsFrom(buf *bin.Buffer) (ReactionNotificationsFromClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case ReactionNotificationsFromContactsTypeID: + // Decoding reactionNotificationsFromContacts#bac3a61a. + v := ReactionNotificationsFromContacts{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ReactionNotificationsFromClass: %w", err) + } + return &v, nil + case ReactionNotificationsFromAllTypeID: + // Decoding reactionNotificationsFromAll#4b9e22a0. + v := ReactionNotificationsFromAll{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ReactionNotificationsFromClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode ReactionNotificationsFromClass: %w", bin.NewUnexpectedID(id)) + } +} + +// ReactionNotificationsFrom boxes the ReactionNotificationsFromClass providing a helper. +type ReactionNotificationsFromBox struct { + ReactionNotificationsFrom ReactionNotificationsFromClass +} + +// Decode implements bin.Decoder for ReactionNotificationsFromBox. +func (b *ReactionNotificationsFromBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode ReactionNotificationsFromBox to nil") + } + v, err := DecodeReactionNotificationsFrom(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.ReactionNotificationsFrom = v + return nil +} + +// Encode implements bin.Encode for ReactionNotificationsFromBox. +func (b *ReactionNotificationsFromBox) Encode(buf *bin.Buffer) error { + if b == nil || b.ReactionNotificationsFrom == nil { + return fmt.Errorf("unable to encode ReactionNotificationsFromClass as nil") + } + return b.ReactionNotificationsFrom.Encode(buf) +} diff --git a/tg/tl_reaction_notifications_from_slices_gen.go b/tg/tl_reaction_notifications_from_slices_gen.go new file mode 100644 index 0000000000..a451fbdebe --- /dev/null +++ b/tg/tl_reaction_notifications_from_slices_gen.go @@ -0,0 +1,117 @@ +//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{} +) + +// ReactionNotificationsFromClassArray is adapter for slice of ReactionNotificationsFromClass. +type ReactionNotificationsFromClassArray []ReactionNotificationsFromClass + +// Sort sorts slice of ReactionNotificationsFromClass. +func (s ReactionNotificationsFromClassArray) Sort(less func(a, b ReactionNotificationsFromClass) bool) ReactionNotificationsFromClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ReactionNotificationsFromClass. +func (s ReactionNotificationsFromClassArray) SortStable(less func(a, b ReactionNotificationsFromClass) bool) ReactionNotificationsFromClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ReactionNotificationsFromClass. +func (s ReactionNotificationsFromClassArray) Retain(keep func(x ReactionNotificationsFromClass) bool) ReactionNotificationsFromClassArray { + 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 ReactionNotificationsFromClassArray) First() (v ReactionNotificationsFromClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ReactionNotificationsFromClassArray) Last() (v ReactionNotificationsFromClass, 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 *ReactionNotificationsFromClassArray) PopFirst() (v ReactionNotificationsFromClass, 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 ReactionNotificationsFromClass + 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 *ReactionNotificationsFromClassArray) Pop() (v ReactionNotificationsFromClass, 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_reactions_notify_settings_gen.go b/tg/tl_reactions_notify_settings_gen.go new file mode 100644 index 0000000000..27254d0d14 --- /dev/null +++ b/tg/tl_reactions_notify_settings_gen.go @@ -0,0 +1,317 @@ +// 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{} +) + +// ReactionsNotifySettings represents TL type `reactionsNotifySettings#56e34970`. +// +// See https://core.telegram.org/constructor/reactionsNotifySettings for reference. +type ReactionsNotifySettings struct { + // Flags field of ReactionsNotifySettings. + Flags bin.Fields + // MessagesNotifyFrom field of ReactionsNotifySettings. + // + // Use SetMessagesNotifyFrom and GetMessagesNotifyFrom helpers. + MessagesNotifyFrom ReactionNotificationsFromClass + // StoriesNotifyFrom field of ReactionsNotifySettings. + // + // Use SetStoriesNotifyFrom and GetStoriesNotifyFrom helpers. + StoriesNotifyFrom ReactionNotificationsFromClass + // Sound field of ReactionsNotifySettings. + Sound NotificationSoundClass + // ShowPreviews field of ReactionsNotifySettings. + ShowPreviews bool +} + +// ReactionsNotifySettingsTypeID is TL type id of ReactionsNotifySettings. +const ReactionsNotifySettingsTypeID = 0x56e34970 + +// Ensuring interfaces in compile-time for ReactionsNotifySettings. +var ( + _ bin.Encoder = &ReactionsNotifySettings{} + _ bin.Decoder = &ReactionsNotifySettings{} + _ bin.BareEncoder = &ReactionsNotifySettings{} + _ bin.BareDecoder = &ReactionsNotifySettings{} +) + +func (r *ReactionsNotifySettings) Zero() bool { + if r == nil { + return true + } + if !(r.Flags.Zero()) { + return false + } + if !(r.MessagesNotifyFrom == nil) { + return false + } + if !(r.StoriesNotifyFrom == nil) { + return false + } + if !(r.Sound == nil) { + return false + } + if !(r.ShowPreviews == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *ReactionsNotifySettings) String() string { + if r == nil { + return "ReactionsNotifySettings(nil)" + } + type Alias ReactionsNotifySettings + return fmt.Sprintf("ReactionsNotifySettings%+v", Alias(*r)) +} + +// FillFrom fills ReactionsNotifySettings from given interface. +func (r *ReactionsNotifySettings) FillFrom(from interface { + GetMessagesNotifyFrom() (value ReactionNotificationsFromClass, ok bool) + GetStoriesNotifyFrom() (value ReactionNotificationsFromClass, ok bool) + GetSound() (value NotificationSoundClass) + GetShowPreviews() (value bool) +}) { + if val, ok := from.GetMessagesNotifyFrom(); ok { + r.MessagesNotifyFrom = val + } + + if val, ok := from.GetStoriesNotifyFrom(); ok { + r.StoriesNotifyFrom = val + } + + r.Sound = from.GetSound() + r.ShowPreviews = from.GetShowPreviews() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ReactionsNotifySettings) TypeID() uint32 { + return ReactionsNotifySettingsTypeID +} + +// TypeName returns name of type in TL schema. +func (*ReactionsNotifySettings) TypeName() string { + return "reactionsNotifySettings" +} + +// TypeInfo returns info about TL type. +func (r *ReactionsNotifySettings) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "reactionsNotifySettings", + ID: ReactionsNotifySettingsTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "MessagesNotifyFrom", + SchemaName: "messages_notify_from", + Null: !r.Flags.Has(0), + }, + { + Name: "StoriesNotifyFrom", + SchemaName: "stories_notify_from", + Null: !r.Flags.Has(1), + }, + { + Name: "Sound", + SchemaName: "sound", + }, + { + Name: "ShowPreviews", + SchemaName: "show_previews", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (r *ReactionsNotifySettings) SetFlags() { + if !(r.MessagesNotifyFrom == nil) { + r.Flags.Set(0) + } + if !(r.StoriesNotifyFrom == nil) { + r.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (r *ReactionsNotifySettings) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reactionsNotifySettings#56e34970 as nil") + } + b.PutID(ReactionsNotifySettingsTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *ReactionsNotifySettings) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode reactionsNotifySettings#56e34970 as nil") + } + r.SetFlags() + if err := r.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field flags: %w", err) + } + if r.Flags.Has(0) { + if r.MessagesNotifyFrom == nil { + return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field messages_notify_from is nil") + } + if err := r.MessagesNotifyFrom.Encode(b); err != nil { + return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field messages_notify_from: %w", err) + } + } + if r.Flags.Has(1) { + if r.StoriesNotifyFrom == nil { + return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field stories_notify_from is nil") + } + if err := r.StoriesNotifyFrom.Encode(b); err != nil { + return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field stories_notify_from: %w", err) + } + } + if r.Sound == nil { + return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field sound is nil") + } + if err := r.Sound.Encode(b); err != nil { + return fmt.Errorf("unable to encode reactionsNotifySettings#56e34970: field sound: %w", err) + } + b.PutBool(r.ShowPreviews) + return nil +} + +// Decode implements bin.Decoder. +func (r *ReactionsNotifySettings) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reactionsNotifySettings#56e34970 to nil") + } + if err := b.ConsumeID(ReactionsNotifySettingsTypeID); err != nil { + return fmt.Errorf("unable to decode reactionsNotifySettings#56e34970: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *ReactionsNotifySettings) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode reactionsNotifySettings#56e34970 to nil") + } + { + if err := r.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode reactionsNotifySettings#56e34970: field flags: %w", err) + } + } + if r.Flags.Has(0) { + value, err := DecodeReactionNotificationsFrom(b) + if err != nil { + return fmt.Errorf("unable to decode reactionsNotifySettings#56e34970: field messages_notify_from: %w", err) + } + r.MessagesNotifyFrom = value + } + if r.Flags.Has(1) { + value, err := DecodeReactionNotificationsFrom(b) + if err != nil { + return fmt.Errorf("unable to decode reactionsNotifySettings#56e34970: field stories_notify_from: %w", err) + } + r.StoriesNotifyFrom = value + } + { + value, err := DecodeNotificationSound(b) + if err != nil { + return fmt.Errorf("unable to decode reactionsNotifySettings#56e34970: field sound: %w", err) + } + r.Sound = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode reactionsNotifySettings#56e34970: field show_previews: %w", err) + } + r.ShowPreviews = value + } + return nil +} + +// SetMessagesNotifyFrom sets value of MessagesNotifyFrom conditional field. +func (r *ReactionsNotifySettings) SetMessagesNotifyFrom(value ReactionNotificationsFromClass) { + r.Flags.Set(0) + r.MessagesNotifyFrom = value +} + +// GetMessagesNotifyFrom returns value of MessagesNotifyFrom conditional field and +// boolean which is true if field was set. +func (r *ReactionsNotifySettings) GetMessagesNotifyFrom() (value ReactionNotificationsFromClass, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(0) { + return value, false + } + return r.MessagesNotifyFrom, true +} + +// SetStoriesNotifyFrom sets value of StoriesNotifyFrom conditional field. +func (r *ReactionsNotifySettings) SetStoriesNotifyFrom(value ReactionNotificationsFromClass) { + r.Flags.Set(1) + r.StoriesNotifyFrom = value +} + +// GetStoriesNotifyFrom returns value of StoriesNotifyFrom conditional field and +// boolean which is true if field was set. +func (r *ReactionsNotifySettings) GetStoriesNotifyFrom() (value ReactionNotificationsFromClass, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(1) { + return value, false + } + return r.StoriesNotifyFrom, true +} + +// GetSound returns value of Sound field. +func (r *ReactionsNotifySettings) GetSound() (value NotificationSoundClass) { + if r == nil { + return + } + return r.Sound +} + +// GetShowPreviews returns value of ShowPreviews field. +func (r *ReactionsNotifySettings) GetShowPreviews() (value bool) { + if r == nil { + return + } + return r.ShowPreviews +} diff --git a/tg/tl_reactions_notify_settings_slices_gen.go b/tg/tl_reactions_notify_settings_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_reactions_notify_settings_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 2324faab8a..d178db6fed 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 177 +const Layer = 178 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -118,8 +118,8 @@ func TypesMap() map[uint32]string { ChatForbiddenTypeID: "chatForbidden#6592a1a7", ChannelTypeID: "channel#aadfc8f", ChannelForbiddenTypeID: "channelForbidden#17d493d5", - ChatFullTypeID: "chatFull#c9d31138", - ChannelFullTypeID: "channelFull#44c054a7", + ChatFullTypeID: "chatFull#2633421b", + ChannelFullTypeID: "channelFull#bbab348d", ChatParticipantTypeID: "chatParticipant#c02d4007", ChatParticipantCreatorTypeID: "chatParticipantCreator#e46bcee4", ChatParticipantAdminTypeID: "chatParticipantAdmin#a0933f5b", @@ -397,6 +397,7 @@ func TypesMap() map[uint32]string { UpdateBotNewBusinessMessageTypeID: "updateBotNewBusinessMessage#9ddb347c", UpdateBotEditBusinessMessageTypeID: "updateBotEditBusinessMessage#7df587c", UpdateBotDeleteBusinessMessageTypeID: "updateBotDeleteBusinessMessage#a02a982e", + UpdateNewStoryReactionTypeID: "updateNewStoryReaction#1824e40b", UpdatesStateTypeID: "updates.state#a56c2a3e", UpdatesDifferenceEmptyTypeID: "updates.differenceEmpty#5d75a138", UpdatesDifferenceTypeID: "updates.difference#f49ca0", @@ -1005,6 +1006,7 @@ func TypesMap() map[uint32]string { ThemeSettingsTypeID: "themeSettings#fa58b6d4", WebPageAttributeThemeTypeID: "webPageAttributeTheme#54b56617", WebPageAttributeStoryTypeID: "webPageAttributeStory#2e94c3e7", + WebPageAttributeStickerSetTypeID: "webPageAttributeStickerSet#50cc03d3", MessagesVotesListTypeID: "messages.votesList#4899484e", BankCardOpenURLTypeID: "bankCardOpenUrl#f568028a", PaymentsBankCardDataTypeID: "payments.bankCardData#3e24e573", @@ -1079,7 +1081,7 @@ func TypesMap() map[uint32]string { AccountResetPasswordFailedWaitTypeID: "account.resetPasswordFailedWait#e3779861", AccountResetPasswordRequestedWaitTypeID: "account.resetPasswordRequestedWait#e9effc7d", AccountResetPasswordOkTypeID: "account.resetPasswordOk#e926d63e", - SponsoredMessageTypeID: "sponsoredMessage#ed5383f7", + SponsoredMessageTypeID: "sponsoredMessage#bdedf566", MessagesSponsoredMessagesTypeID: "messages.sponsoredMessages#c9ee1d87", MessagesSponsoredMessagesEmptyTypeID: "messages.sponsoredMessagesEmpty#1839490f", SearchResultsCalendarPeriodTypeID: "searchResultsCalendarPeriod#c9b0539f", @@ -1203,14 +1205,13 @@ func TypesMap() map[uint32]string { MessagePeerVoteTypeID: "messagePeerVote#b6cc2d5c", MessagePeerVoteInputOptionTypeID: "messagePeerVoteInputOption#74cda504", MessagePeerVoteMultipleTypeID: "messagePeerVoteMultiple#4628f6e6", - SponsoredWebPageTypeID: "sponsoredWebPage#3db8ec63", StoryViewsTypeID: "storyViews#8d595cd6", StoryItemDeletedTypeID: "storyItemDeleted#51e6ee4f", StoryItemSkippedTypeID: "storyItemSkipped#ffadc913", StoryItemTypeID: "storyItem#79b26a24", StoriesAllStoriesNotModifiedTypeID: "stories.allStoriesNotModified#1158fe3e", StoriesAllStoriesTypeID: "stories.allStories#6efc5e81", - StoriesStoriesTypeID: "stories.stories#5dd8c3c8", + StoriesStoriesTypeID: "stories.stories#63c3dd0a", StoryViewTypeID: "storyView#b0bdeac5", StoryViewPublicForwardTypeID: "storyViewPublicForward#9083670b", StoryViewPublicRepostTypeID: "storyViewPublicRepost#bd74cf49", @@ -1322,6 +1323,9 @@ func TypesMap() map[uint32]string { BroadcastRevenueTransactionWithdrawalTypeID: "broadcastRevenueTransactionWithdrawal#5a590978", BroadcastRevenueTransactionRefundTypeID: "broadcastRevenueTransactionRefund#42d30d2e", StatsBroadcastRevenueTransactionsTypeID: "stats.broadcastRevenueTransactions#87158466", + ReactionNotificationsFromContactsTypeID: "reactionNotificationsFromContacts#bac3a61a", + ReactionNotificationsFromAllTypeID: "reactionNotificationsFromAll#4b9e22a0", + ReactionsNotifySettingsTypeID: "reactionsNotifySettings#56e34970", InvokeAfterMsgRequestTypeID: "invokeAfterMsg#cb9f372d", InvokeAfterMsgsRequestTypeID: "invokeAfterMsgs#3dc4b4f0", InitConnectionRequestTypeID: "initConnection#c1cd5ea9", @@ -1461,6 +1465,9 @@ func TypesMap() map[uint32]string { AccountGetBusinessChatLinksRequestTypeID: "account.getBusinessChatLinks#6f70dde1", AccountResolveBusinessChatLinkRequestTypeID: "account.resolveBusinessChatLink#5492e5ee", AccountUpdatePersonalChannelRequestTypeID: "account.updatePersonalChannel#d94305e0", + AccountToggleSponsoredMessagesRequestTypeID: "account.toggleSponsoredMessages#b9d9a38d", + AccountGetReactionsNotifySettingsRequestTypeID: "account.getReactionsNotifySettings#6dd654c", + AccountSetReactionsNotifySettingsRequestTypeID: "account.setReactionsNotifySettings#316ce548", UsersGetUsersRequestTypeID: "users.getUsers#d91a548", UsersGetFullUserRequestTypeID: "users.getFullUser#b60f5918", UsersSetSecureValueErrorsRequestTypeID: "users.setSecureValueErrors#90c894b5", @@ -1642,7 +1649,7 @@ func TypesMap() map[uint32]string { MessagesSendReactionRequestTypeID: "messages.sendReaction#d30d78d4", MessagesGetMessagesReactionsRequestTypeID: "messages.getMessagesReactions#8bba90e6", MessagesGetMessageReactionsListRequestTypeID: "messages.getMessageReactionsList#461b3f48", - MessagesSetChatAvailableReactionsRequestTypeID: "messages.setChatAvailableReactions#feb16771", + MessagesSetChatAvailableReactionsRequestTypeID: "messages.setChatAvailableReactions#5a150bd4", MessagesGetAvailableReactionsRequestTypeID: "messages.getAvailableReactions#18dea0ac", MessagesSetDefaultReactionRequestTypeID: "messages.setDefaultReaction#4f47a016", MessagesTranslateTextRequestTypeID: "messages.translateText#63183030", @@ -1798,7 +1805,7 @@ func TypesMap() map[uint32]string { ChannelsClickSponsoredMessageRequestTypeID: "channels.clickSponsoredMessage#18afbc93", ChannelsUpdateColorRequestTypeID: "channels.updateColor#d8aa3671", ChannelsToggleViewForumAsMessagesRequestTypeID: "channels.toggleViewForumAsMessages#9738bb15", - ChannelsGetChannelRecommendationsRequestTypeID: "channels.getChannelRecommendations#83b70d97", + ChannelsGetChannelRecommendationsRequestTypeID: "channels.getChannelRecommendations#25a71742", ChannelsUpdateEmojiStatusRequestTypeID: "channels.updateEmojiStatus#f0d3e6a8", ChannelsSetBoostsToUnblockRestrictionsRequestTypeID: "channels.setBoostsToUnblockRestrictions#ad399cee", ChannelsSetEmojiStickersRequestTypeID: "channels.setEmojiStickers#3cd930b7", @@ -1929,6 +1936,7 @@ func TypesMap() map[uint32]string { StoriesGetChatsToSendRequestTypeID: "stories.getChatsToSend#a56a8b60", StoriesTogglePeerStoriesHiddenRequestTypeID: "stories.togglePeerStoriesHidden#bd0415c4", StoriesGetStoryReactionsListRequestTypeID: "stories.getStoryReactionsList#b9b2881f", + StoriesTogglePinnedToTopRequestTypeID: "stories.togglePinnedToTop#b297e9b", PremiumGetBoostsListRequestTypeID: "premium.getBoostsList#60f67660", PremiumGetMyBoostsRequestTypeID: "premium.getMyBoosts#be77b4a", PremiumApplyBoostRequestTypeID: "premium.applyBoost#6b7da746", @@ -2321,6 +2329,7 @@ func NamesMap() map[string]uint32 { "updateBotNewBusinessMessage": UpdateBotNewBusinessMessageTypeID, "updateBotEditBusinessMessage": UpdateBotEditBusinessMessageTypeID, "updateBotDeleteBusinessMessage": UpdateBotDeleteBusinessMessageTypeID, + "updateNewStoryReaction": UpdateNewStoryReactionTypeID, "updates.state": UpdatesStateTypeID, "updates.differenceEmpty": UpdatesDifferenceEmptyTypeID, "updates.difference": UpdatesDifferenceTypeID, @@ -2929,6 +2938,7 @@ func NamesMap() map[string]uint32 { "themeSettings": ThemeSettingsTypeID, "webPageAttributeTheme": WebPageAttributeThemeTypeID, "webPageAttributeStory": WebPageAttributeStoryTypeID, + "webPageAttributeStickerSet": WebPageAttributeStickerSetTypeID, "messages.votesList": MessagesVotesListTypeID, "bankCardOpenUrl": BankCardOpenURLTypeID, "payments.bankCardData": PaymentsBankCardDataTypeID, @@ -3127,7 +3137,6 @@ func NamesMap() map[string]uint32 { "messagePeerVote": MessagePeerVoteTypeID, "messagePeerVoteInputOption": MessagePeerVoteInputOptionTypeID, "messagePeerVoteMultiple": MessagePeerVoteMultipleTypeID, - "sponsoredWebPage": SponsoredWebPageTypeID, "storyViews": StoryViewsTypeID, "storyItemDeleted": StoryItemDeletedTypeID, "storyItemSkipped": StoryItemSkippedTypeID, @@ -3246,6 +3255,9 @@ func NamesMap() map[string]uint32 { "broadcastRevenueTransactionWithdrawal": BroadcastRevenueTransactionWithdrawalTypeID, "broadcastRevenueTransactionRefund": BroadcastRevenueTransactionRefundTypeID, "stats.broadcastRevenueTransactions": StatsBroadcastRevenueTransactionsTypeID, + "reactionNotificationsFromContacts": ReactionNotificationsFromContactsTypeID, + "reactionNotificationsFromAll": ReactionNotificationsFromAllTypeID, + "reactionsNotifySettings": ReactionsNotifySettingsTypeID, "invokeAfterMsg": InvokeAfterMsgRequestTypeID, "invokeAfterMsgs": InvokeAfterMsgsRequestTypeID, "initConnection": InitConnectionRequestTypeID, @@ -3385,6 +3397,9 @@ func NamesMap() map[string]uint32 { "account.getBusinessChatLinks": AccountGetBusinessChatLinksRequestTypeID, "account.resolveBusinessChatLink": AccountResolveBusinessChatLinkRequestTypeID, "account.updatePersonalChannel": AccountUpdatePersonalChannelRequestTypeID, + "account.toggleSponsoredMessages": AccountToggleSponsoredMessagesRequestTypeID, + "account.getReactionsNotifySettings": AccountGetReactionsNotifySettingsRequestTypeID, + "account.setReactionsNotifySettings": AccountSetReactionsNotifySettingsRequestTypeID, "users.getUsers": UsersGetUsersRequestTypeID, "users.getFullUser": UsersGetFullUserRequestTypeID, "users.setSecureValueErrors": UsersSetSecureValueErrorsRequestTypeID, @@ -3853,6 +3868,7 @@ func NamesMap() map[string]uint32 { "stories.getChatsToSend": StoriesGetChatsToSendRequestTypeID, "stories.togglePeerStoriesHidden": StoriesTogglePeerStoriesHiddenRequestTypeID, "stories.getStoryReactionsList": StoriesGetStoryReactionsListRequestTypeID, + "stories.togglePinnedToTop": StoriesTogglePinnedToTopRequestTypeID, "premium.getBoostsList": PremiumGetBoostsListRequestTypeID, "premium.getMyBoosts": PremiumGetMyBoostsRequestTypeID, "premium.applyBoost": PremiumApplyBoostRequestTypeID, @@ -4245,6 +4261,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UpdateBotNewBusinessMessageTypeID: func() bin.Object { return &UpdateBotNewBusinessMessage{} }, UpdateBotEditBusinessMessageTypeID: func() bin.Object { return &UpdateBotEditBusinessMessage{} }, UpdateBotDeleteBusinessMessageTypeID: func() bin.Object { return &UpdateBotDeleteBusinessMessage{} }, + UpdateNewStoryReactionTypeID: func() bin.Object { return &UpdateNewStoryReaction{} }, UpdatesStateTypeID: func() bin.Object { return &UpdatesState{} }, UpdatesDifferenceEmptyTypeID: func() bin.Object { return &UpdatesDifferenceEmpty{} }, UpdatesDifferenceTypeID: func() bin.Object { return &UpdatesDifference{} }, @@ -4853,6 +4870,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { ThemeSettingsTypeID: func() bin.Object { return &ThemeSettings{} }, WebPageAttributeThemeTypeID: func() bin.Object { return &WebPageAttributeTheme{} }, WebPageAttributeStoryTypeID: func() bin.Object { return &WebPageAttributeStory{} }, + WebPageAttributeStickerSetTypeID: func() bin.Object { return &WebPageAttributeStickerSet{} }, MessagesVotesListTypeID: func() bin.Object { return &MessagesVotesList{} }, BankCardOpenURLTypeID: func() bin.Object { return &BankCardOpenURL{} }, PaymentsBankCardDataTypeID: func() bin.Object { return &PaymentsBankCardData{} }, @@ -5051,7 +5069,6 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessagePeerVoteTypeID: func() bin.Object { return &MessagePeerVote{} }, MessagePeerVoteInputOptionTypeID: func() bin.Object { return &MessagePeerVoteInputOption{} }, MessagePeerVoteMultipleTypeID: func() bin.Object { return &MessagePeerVoteMultiple{} }, - SponsoredWebPageTypeID: func() bin.Object { return &SponsoredWebPage{} }, StoryViewsTypeID: func() bin.Object { return &StoryViews{} }, StoryItemDeletedTypeID: func() bin.Object { return &StoryItemDeleted{} }, StoryItemSkippedTypeID: func() bin.Object { return &StoryItemSkipped{} }, @@ -5170,6 +5187,9 @@ func TypesConstructorMap() map[uint32]func() bin.Object { BroadcastRevenueTransactionWithdrawalTypeID: func() bin.Object { return &BroadcastRevenueTransactionWithdrawal{} }, BroadcastRevenueTransactionRefundTypeID: func() bin.Object { return &BroadcastRevenueTransactionRefund{} }, StatsBroadcastRevenueTransactionsTypeID: func() bin.Object { return &StatsBroadcastRevenueTransactions{} }, + ReactionNotificationsFromContactsTypeID: func() bin.Object { return &ReactionNotificationsFromContacts{} }, + ReactionNotificationsFromAllTypeID: func() bin.Object { return &ReactionNotificationsFromAll{} }, + ReactionsNotifySettingsTypeID: func() bin.Object { return &ReactionsNotifySettings{} }, InvokeAfterMsgRequestTypeID: func() bin.Object { return &InvokeAfterMsgRequest{} }, InvokeAfterMsgsRequestTypeID: func() bin.Object { return &InvokeAfterMsgsRequest{} }, InitConnectionRequestTypeID: func() bin.Object { return &InitConnectionRequest{} }, @@ -5309,6 +5329,9 @@ func TypesConstructorMap() map[uint32]func() bin.Object { AccountGetBusinessChatLinksRequestTypeID: func() bin.Object { return &AccountGetBusinessChatLinksRequest{} }, AccountResolveBusinessChatLinkRequestTypeID: func() bin.Object { return &AccountResolveBusinessChatLinkRequest{} }, AccountUpdatePersonalChannelRequestTypeID: func() bin.Object { return &AccountUpdatePersonalChannelRequest{} }, + AccountToggleSponsoredMessagesRequestTypeID: func() bin.Object { return &AccountToggleSponsoredMessagesRequest{} }, + AccountGetReactionsNotifySettingsRequestTypeID: func() bin.Object { return &AccountGetReactionsNotifySettingsRequest{} }, + AccountSetReactionsNotifySettingsRequestTypeID: func() bin.Object { return &AccountSetReactionsNotifySettingsRequest{} }, UsersGetUsersRequestTypeID: func() bin.Object { return &UsersGetUsersRequest{} }, UsersGetFullUserRequestTypeID: func() bin.Object { return &UsersGetFullUserRequest{} }, UsersSetSecureValueErrorsRequestTypeID: func() bin.Object { return &UsersSetSecureValueErrorsRequest{} }, @@ -5777,6 +5800,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { StoriesGetChatsToSendRequestTypeID: func() bin.Object { return &StoriesGetChatsToSendRequest{} }, StoriesTogglePeerStoriesHiddenRequestTypeID: func() bin.Object { return &StoriesTogglePeerStoriesHiddenRequest{} }, StoriesGetStoryReactionsListRequestTypeID: func() bin.Object { return &StoriesGetStoryReactionsListRequest{} }, + StoriesTogglePinnedToTopRequestTypeID: func() bin.Object { return &StoriesTogglePinnedToTopRequest{} }, PremiumGetBoostsListRequestTypeID: func() bin.Object { return &PremiumGetBoostsListRequest{} }, PremiumGetMyBoostsRequestTypeID: func() bin.Object { return &PremiumGetMyBoostsRequest{} }, PremiumApplyBoostRequestTypeID: func() bin.Object { return &PremiumApplyBoostRequest{} }, @@ -6827,6 +6851,10 @@ func ClassConstructorsMap() map[string][]uint32 { ReactionEmojiTypeID, ReactionCustomEmojiTypeID, }, + ReactionNotificationsFromClassName: { + ReactionNotificationsFromContactsTypeID, + ReactionNotificationsFromAllTypeID, + }, RecentMeURLClassName: { RecentMeURLUnknownTypeID, RecentMeURLUserTypeID, @@ -7135,6 +7163,7 @@ func ClassConstructorsMap() map[string][]uint32 { UpdateBotNewBusinessMessageTypeID, UpdateBotEditBusinessMessageTypeID, UpdateBotDeleteBusinessMessageTypeID, + UpdateNewStoryReactionTypeID, }, UpdatesChannelDifferenceClassName: { UpdatesChannelDifferenceEmptyTypeID, @@ -7196,6 +7225,7 @@ func ClassConstructorsMap() map[string][]uint32 { WebPageAttributeClassName: { WebPageAttributeThemeTypeID, WebPageAttributeStoryTypeID, + WebPageAttributeStickerSetTypeID, }, WebPageClassName: { WebPageEmptyTypeID, diff --git a/tg/tl_server_gen.go b/tg/tl_server_gen.go index 58b4cc98b9..107d3a3665 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -2520,6 +2520,61 @@ func (s *ServerDispatcher) OnAccountUpdatePersonalChannel(f func(ctx context.Con s.handlers[AccountUpdatePersonalChannelRequestTypeID] = handler } +func (s *ServerDispatcher) OnAccountToggleSponsoredMessages(f func(ctx context.Context, enabled bool) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountToggleSponsoredMessagesRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Enabled) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[AccountToggleSponsoredMessagesRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnAccountGetReactionsNotifySettings(f func(ctx context.Context) (*ReactionsNotifySettings, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountGetReactionsNotifySettingsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[AccountGetReactionsNotifySettingsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnAccountSetReactionsNotifySettings(f func(ctx context.Context, settings ReactionsNotifySettings) (*ReactionsNotifySettings, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountSetReactionsNotifySettingsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Settings) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[AccountSetReactionsNotifySettingsRequestTypeID] = handler +} + func (s *ServerDispatcher) OnUsersGetUsers(f func(ctx context.Context, id []InputUserClass) ([]UserClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request UsersGetUsersRequest @@ -8581,14 +8636,14 @@ func (s *ServerDispatcher) OnChannelsToggleViewForumAsMessages(f func(ctx contex s.handlers[ChannelsToggleViewForumAsMessagesRequestTypeID] = handler } -func (s *ServerDispatcher) OnChannelsGetChannelRecommendations(f func(ctx context.Context, channel InputChannelClass) (MessagesChatsClass, error)) { +func (s *ServerDispatcher) OnChannelsGetChannelRecommendations(f func(ctx context.Context, request *ChannelsGetChannelRecommendationsRequest) (MessagesChatsClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request ChannelsGetChannelRecommendationsRequest if err := request.Decode(b); err != nil { return nil, err } - response, err := f(ctx, request.Channel) + response, err := f(ctx, &request) if err != nil { return nil, err } @@ -10916,6 +10971,27 @@ func (s *ServerDispatcher) OnStoriesGetStoryReactionsList(f func(ctx context.Con s.handlers[StoriesGetStoryReactionsListRequestTypeID] = handler } +func (s *ServerDispatcher) OnStoriesTogglePinnedToTop(f func(ctx context.Context, request *StoriesTogglePinnedToTopRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request StoriesTogglePinnedToTopRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[StoriesTogglePinnedToTopRequestTypeID] = handler +} + func (s *ServerDispatcher) OnPremiumGetBoostsList(f func(ctx context.Context, request *PremiumGetBoostsListRequest) (*PremiumBoostsList, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request PremiumGetBoostsListRequest diff --git a/tg/tl_sponsored_message_gen.go b/tg/tl_sponsored_message_gen.go index 648e21f604..0237f560df 100644 --- a/tg/tl_sponsored_message_gen.go +++ b/tg/tl_sponsored_message_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// SponsoredMessage represents TL type `sponsoredMessage#ed5383f7`. +// SponsoredMessage represents TL type `sponsoredMessage#bdedf566`. // A sponsored message¹. // // Links: @@ -46,45 +46,14 @@ type SponsoredMessage struct { Flags bin.Fields // Whether the message needs to be labeled as "recommended" instead of "sponsored" Recommended bool - // Whether a profile photo bubble should be displayed for this message, like for messages - // sent in groups. The photo shown in the bubble is obtained either from the peer - // contained in from_id, or from chat_invite. - ShowPeerPhoto bool // CanReport field of SponsoredMessage. CanReport bool // Message ID RandomID []byte - // ID of the sender of the message - // - // Use SetFromID and GetFromID helpers. - FromID PeerClass - // Information about the chat invite hash specified in chat_invite_hash - // - // Use SetChatInvite and GetChatInvite helpers. - ChatInvite ChatInviteClass - // Chat invite - // - // Use SetChatInviteHash and GetChatInviteHash helpers. - ChatInviteHash string - // Optional link to a channel post if from_id points to a channel - // - // Use SetChannelPost and GetChannelPost helpers. - ChannelPost int - // Parameter for the bot start message if the sponsored chat is a chat with a bot. - // - // Use SetStartParam and GetStartParam helpers. - StartParam string - // Sponsored website - // - // Use SetWebpage and GetWebpage helpers. - Webpage SponsoredWebPage - // Mini App »¹ to open when the sponsored message is clicked. - // - // Links: - // 1) https://core.telegram.org/api/bots/webapps - // - // Use SetApp and GetApp helpers. - App BotAppClass + // URL field of SponsoredMessage. + URL string + // Title field of SponsoredMessage. + Title string // Sponsored message Message string // Message entities for styled text¹ @@ -94,9 +63,15 @@ type SponsoredMessage struct { // // Use SetEntities and GetEntities helpers. Entities []MessageEntityClass - // Text of the sponsored message button. + // Photo field of SponsoredMessage. // - // Use SetButtonText and GetButtonText helpers. + // Use SetPhoto and GetPhoto helpers. + Photo PhotoClass + // Color field of SponsoredMessage. + // + // Use SetColor and GetColor helpers. + Color PeerColor + // Text of the sponsored message button. ButtonText string // If set, contains additional information about the sponsor to be shown along with the // message. @@ -111,7 +86,7 @@ type SponsoredMessage struct { } // SponsoredMessageTypeID is TL type id of SponsoredMessage. -const SponsoredMessageTypeID = 0xed5383f7 +const SponsoredMessageTypeID = 0xbdedf566 // Ensuring interfaces in compile-time for SponsoredMessage. var ( @@ -131,40 +106,28 @@ func (s *SponsoredMessage) Zero() bool { if !(s.Recommended == false) { return false } - if !(s.ShowPeerPhoto == false) { - return false - } if !(s.CanReport == false) { return false } if !(s.RandomID == nil) { return false } - if !(s.FromID == nil) { - return false - } - if !(s.ChatInvite == nil) { - return false - } - if !(s.ChatInviteHash == "") { - return false - } - if !(s.ChannelPost == 0) { + if !(s.URL == "") { return false } - if !(s.StartParam == "") { + if !(s.Title == "") { return false } - if !(s.Webpage.Zero()) { + if !(s.Message == "") { return false } - if !(s.App == nil) { + if !(s.Entities == nil) { return false } - if !(s.Message == "") { + if !(s.Photo == nil) { return false } - if !(s.Entities == nil) { + if !(s.Color.Zero()) { return false } if !(s.ButtonText == "") { @@ -192,63 +155,37 @@ func (s *SponsoredMessage) String() string { // FillFrom fills SponsoredMessage from given interface. func (s *SponsoredMessage) FillFrom(from interface { GetRecommended() (value bool) - GetShowPeerPhoto() (value bool) GetCanReport() (value bool) GetRandomID() (value []byte) - GetFromID() (value PeerClass, ok bool) - GetChatInvite() (value ChatInviteClass, ok bool) - GetChatInviteHash() (value string, ok bool) - GetChannelPost() (value int, ok bool) - GetStartParam() (value string, ok bool) - GetWebpage() (value SponsoredWebPage, ok bool) - GetApp() (value BotAppClass, ok bool) + GetURL() (value string) + GetTitle() (value string) GetMessage() (value string) GetEntities() (value []MessageEntityClass, ok bool) - GetButtonText() (value string, ok bool) + GetPhoto() (value PhotoClass, ok bool) + GetColor() (value PeerColor, ok bool) + GetButtonText() (value string) GetSponsorInfo() (value string, ok bool) GetAdditionalInfo() (value string, ok bool) }) { s.Recommended = from.GetRecommended() - s.ShowPeerPhoto = from.GetShowPeerPhoto() s.CanReport = from.GetCanReport() s.RandomID = from.GetRandomID() - if val, ok := from.GetFromID(); ok { - s.FromID = val - } - - if val, ok := from.GetChatInvite(); ok { - s.ChatInvite = val - } - - if val, ok := from.GetChatInviteHash(); ok { - s.ChatInviteHash = val - } - - if val, ok := from.GetChannelPost(); ok { - s.ChannelPost = val - } - - if val, ok := from.GetStartParam(); ok { - s.StartParam = val - } - - if val, ok := from.GetWebpage(); ok { - s.Webpage = val - } - - if val, ok := from.GetApp(); ok { - s.App = val - } - + s.URL = from.GetURL() + s.Title = from.GetTitle() s.Message = from.GetMessage() if val, ok := from.GetEntities(); ok { s.Entities = val } - if val, ok := from.GetButtonText(); ok { - s.ButtonText = val + if val, ok := from.GetPhoto(); ok { + s.Photo = val } + if val, ok := from.GetColor(); ok { + s.Color = val + } + + s.ButtonText = from.GetButtonText() if val, ok := from.GetSponsorInfo(); ok { s.SponsorInfo = val } @@ -287,11 +224,6 @@ func (s *SponsoredMessage) TypeInfo() tdp.Type { SchemaName: "recommended", Null: !s.Flags.Has(5), }, - { - Name: "ShowPeerPhoto", - SchemaName: "show_peer_photo", - Null: !s.Flags.Has(6), - }, { Name: "CanReport", SchemaName: "can_report", @@ -302,39 +234,12 @@ func (s *SponsoredMessage) TypeInfo() tdp.Type { SchemaName: "random_id", }, { - Name: "FromID", - SchemaName: "from_id", - Null: !s.Flags.Has(3), - }, - { - Name: "ChatInvite", - SchemaName: "chat_invite", - Null: !s.Flags.Has(4), - }, - { - Name: "ChatInviteHash", - SchemaName: "chat_invite_hash", - Null: !s.Flags.Has(4), + Name: "URL", + SchemaName: "url", }, { - Name: "ChannelPost", - SchemaName: "channel_post", - Null: !s.Flags.Has(2), - }, - { - Name: "StartParam", - SchemaName: "start_param", - Null: !s.Flags.Has(0), - }, - { - Name: "Webpage", - SchemaName: "webpage", - Null: !s.Flags.Has(9), - }, - { - Name: "App", - SchemaName: "app", - Null: !s.Flags.Has(10), + Name: "Title", + SchemaName: "title", }, { Name: "Message", @@ -345,10 +250,19 @@ func (s *SponsoredMessage) TypeInfo() tdp.Type { SchemaName: "entities", Null: !s.Flags.Has(1), }, + { + Name: "Photo", + SchemaName: "photo", + Null: !s.Flags.Has(6), + }, + { + Name: "Color", + SchemaName: "color", + Null: !s.Flags.Has(13), + }, { Name: "ButtonText", SchemaName: "button_text", - Null: !s.Flags.Has(11), }, { Name: "SponsorInfo", @@ -369,38 +283,17 @@ func (s *SponsoredMessage) SetFlags() { if !(s.Recommended == false) { s.Flags.Set(5) } - if !(s.ShowPeerPhoto == false) { - s.Flags.Set(6) - } if !(s.CanReport == false) { s.Flags.Set(12) } - if !(s.FromID == nil) { - s.Flags.Set(3) - } - if !(s.ChatInvite == nil) { - s.Flags.Set(4) - } - if !(s.ChatInviteHash == "") { - s.Flags.Set(4) - } - if !(s.ChannelPost == 0) { - s.Flags.Set(2) - } - if !(s.StartParam == "") { - s.Flags.Set(0) - } - if !(s.Webpage.Zero()) { - s.Flags.Set(9) - } - if !(s.App == nil) { - s.Flags.Set(10) - } if !(s.Entities == nil) { s.Flags.Set(1) } - if !(s.ButtonText == "") { - s.Flags.Set(11) + if !(s.Photo == nil) { + s.Flags.Set(6) + } + if !(s.Color.Zero()) { + s.Flags.Set(13) } if !(s.SponsorInfo == "") { s.Flags.Set(7) @@ -413,7 +306,7 @@ func (s *SponsoredMessage) SetFlags() { // Encode implements bin.Encoder. func (s *SponsoredMessage) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode sponsoredMessage#ed5383f7 as nil") + return fmt.Errorf("can't encode sponsoredMessage#bdedf566 as nil") } b.PutID(SponsoredMessageTypeID) return s.EncodeBare(b) @@ -422,66 +315,41 @@ func (s *SponsoredMessage) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *SponsoredMessage) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode sponsoredMessage#ed5383f7 as nil") + return fmt.Errorf("can't encode sponsoredMessage#bdedf566 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode sponsoredMessage#ed5383f7: field flags: %w", err) + return fmt.Errorf("unable to encode sponsoredMessage#bdedf566: field flags: %w", err) } b.PutBytes(s.RandomID) - if s.Flags.Has(3) { - if s.FromID == nil { - return fmt.Errorf("unable to encode sponsoredMessage#ed5383f7: field from_id is nil") - } - if err := s.FromID.Encode(b); err != nil { - return fmt.Errorf("unable to encode sponsoredMessage#ed5383f7: field from_id: %w", err) - } - } - if s.Flags.Has(4) { - if s.ChatInvite == nil { - return fmt.Errorf("unable to encode sponsoredMessage#ed5383f7: field chat_invite is nil") - } - if err := s.ChatInvite.Encode(b); err != nil { - return fmt.Errorf("unable to encode sponsoredMessage#ed5383f7: field chat_invite: %w", err) - } - } - if s.Flags.Has(4) { - b.PutString(s.ChatInviteHash) - } - if s.Flags.Has(2) { - b.PutInt(s.ChannelPost) - } - if s.Flags.Has(0) { - b.PutString(s.StartParam) - } - if s.Flags.Has(9) { - if err := s.Webpage.Encode(b); err != nil { - return fmt.Errorf("unable to encode sponsoredMessage#ed5383f7: field webpage: %w", err) - } - } - if s.Flags.Has(10) { - if s.App == nil { - return fmt.Errorf("unable to encode sponsoredMessage#ed5383f7: field app is nil") - } - if err := s.App.Encode(b); err != nil { - return fmt.Errorf("unable to encode sponsoredMessage#ed5383f7: field app: %w", err) - } - } + b.PutString(s.URL) + b.PutString(s.Title) b.PutString(s.Message) if s.Flags.Has(1) { b.PutVectorHeader(len(s.Entities)) for idx, v := range s.Entities { if v == nil { - return fmt.Errorf("unable to encode sponsoredMessage#ed5383f7: field entities element with index %d is nil", idx) + return fmt.Errorf("unable to encode sponsoredMessage#bdedf566: field entities element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode sponsoredMessage#ed5383f7: field entities element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode sponsoredMessage#bdedf566: field entities element with index %d: %w", idx, err) } } } - if s.Flags.Has(11) { - b.PutString(s.ButtonText) + if s.Flags.Has(6) { + if s.Photo == nil { + return fmt.Errorf("unable to encode sponsoredMessage#bdedf566: field photo is nil") + } + if err := s.Photo.Encode(b); err != nil { + return fmt.Errorf("unable to encode sponsoredMessage#bdedf566: field photo: %w", err) + } + } + if s.Flags.Has(13) { + if err := s.Color.Encode(b); err != nil { + return fmt.Errorf("unable to encode sponsoredMessage#bdedf566: field color: %w", err) + } } + b.PutString(s.ButtonText) if s.Flags.Has(7) { b.PutString(s.SponsorInfo) } @@ -494,10 +362,10 @@ func (s *SponsoredMessage) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *SponsoredMessage) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode sponsoredMessage#ed5383f7 to nil") + return fmt.Errorf("can't decode sponsoredMessage#bdedf566 to nil") } if err := b.ConsumeID(SponsoredMessageTypeID); err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: %w", err) + return fmt.Errorf("unable to decode sponsoredMessage#bdedf566: %w", err) } return s.DecodeBare(b) } @@ -505,81 +373,47 @@ func (s *SponsoredMessage) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *SponsoredMessage) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode sponsoredMessage#ed5383f7 to nil") + return fmt.Errorf("can't decode sponsoredMessage#bdedf566 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field flags: %w", err) + return fmt.Errorf("unable to decode sponsoredMessage#bdedf566: field flags: %w", err) } } s.Recommended = s.Flags.Has(5) - s.ShowPeerPhoto = s.Flags.Has(6) s.CanReport = s.Flags.Has(12) { value, err := b.Bytes() if err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field random_id: %w", err) + return fmt.Errorf("unable to decode sponsoredMessage#bdedf566: field random_id: %w", err) } s.RandomID = value } - if s.Flags.Has(3) { - value, err := DecodePeer(b) - if err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field from_id: %w", err) - } - s.FromID = value - } - if s.Flags.Has(4) { - value, err := DecodeChatInvite(b) - if err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field chat_invite: %w", err) - } - s.ChatInvite = value - } - if s.Flags.Has(4) { + { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field chat_invite_hash: %w", err) - } - s.ChatInviteHash = value - } - if s.Flags.Has(2) { - value, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field channel_post: %w", err) + return fmt.Errorf("unable to decode sponsoredMessage#bdedf566: field url: %w", err) } - s.ChannelPost = value + s.URL = value } - if s.Flags.Has(0) { + { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field start_param: %w", err) + return fmt.Errorf("unable to decode sponsoredMessage#bdedf566: field title: %w", err) } - s.StartParam = value - } - if s.Flags.Has(9) { - if err := s.Webpage.Decode(b); err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field webpage: %w", err) - } - } - if s.Flags.Has(10) { - value, err := DecodeBotApp(b) - if err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field app: %w", err) - } - s.App = value + s.Title = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field message: %w", err) + return fmt.Errorf("unable to decode sponsoredMessage#bdedf566: field message: %w", err) } s.Message = value } if s.Flags.Has(1) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field entities: %w", err) + return fmt.Errorf("unable to decode sponsoredMessage#bdedf566: field entities: %w", err) } if headerLen > 0 { @@ -588,29 +422,41 @@ func (s *SponsoredMessage) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageEntity(b) if err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field entities: %w", err) + return fmt.Errorf("unable to decode sponsoredMessage#bdedf566: field entities: %w", err) } s.Entities = append(s.Entities, value) } } - if s.Flags.Has(11) { + if s.Flags.Has(6) { + value, err := DecodePhoto(b) + if err != nil { + return fmt.Errorf("unable to decode sponsoredMessage#bdedf566: field photo: %w", err) + } + s.Photo = value + } + if s.Flags.Has(13) { + if err := s.Color.Decode(b); err != nil { + return fmt.Errorf("unable to decode sponsoredMessage#bdedf566: field color: %w", err) + } + } + { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field button_text: %w", err) + return fmt.Errorf("unable to decode sponsoredMessage#bdedf566: field button_text: %w", err) } s.ButtonText = value } if s.Flags.Has(7) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field sponsor_info: %w", err) + return fmt.Errorf("unable to decode sponsoredMessage#bdedf566: field sponsor_info: %w", err) } s.SponsorInfo = value } if s.Flags.Has(8) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode sponsoredMessage#ed5383f7: field additional_info: %w", err) + return fmt.Errorf("unable to decode sponsoredMessage#bdedf566: field additional_info: %w", err) } s.AdditionalInfo = value } @@ -636,25 +482,6 @@ func (s *SponsoredMessage) GetRecommended() (value bool) { return s.Flags.Has(5) } -// SetShowPeerPhoto sets value of ShowPeerPhoto conditional field. -func (s *SponsoredMessage) SetShowPeerPhoto(value bool) { - if value { - s.Flags.Set(6) - s.ShowPeerPhoto = true - } else { - s.Flags.Unset(6) - s.ShowPeerPhoto = false - } -} - -// GetShowPeerPhoto returns value of ShowPeerPhoto conditional field. -func (s *SponsoredMessage) GetShowPeerPhoto() (value bool) { - if s == nil { - return - } - return s.Flags.Has(6) -} - // SetCanReport sets value of CanReport conditional field. func (s *SponsoredMessage) SetCanReport(value bool) { if value { @@ -682,174 +509,90 @@ func (s *SponsoredMessage) GetRandomID() (value []byte) { return s.RandomID } -// SetFromID sets value of FromID conditional field. -func (s *SponsoredMessage) SetFromID(value PeerClass) { - s.Flags.Set(3) - s.FromID = value -} - -// GetFromID returns value of FromID conditional field and -// boolean which is true if field was set. -func (s *SponsoredMessage) GetFromID() (value PeerClass, ok bool) { - if s == nil { - return - } - if !s.Flags.Has(3) { - return value, false - } - return s.FromID, true -} - -// SetChatInvite sets value of ChatInvite conditional field. -func (s *SponsoredMessage) SetChatInvite(value ChatInviteClass) { - s.Flags.Set(4) - s.ChatInvite = value -} - -// GetChatInvite returns value of ChatInvite conditional field and -// boolean which is true if field was set. -func (s *SponsoredMessage) GetChatInvite() (value ChatInviteClass, ok bool) { +// GetURL returns value of URL field. +func (s *SponsoredMessage) GetURL() (value string) { if s == nil { return } - if !s.Flags.Has(4) { - return value, false - } - return s.ChatInvite, true + return s.URL } -// SetChatInviteHash sets value of ChatInviteHash conditional field. -func (s *SponsoredMessage) SetChatInviteHash(value string) { - s.Flags.Set(4) - s.ChatInviteHash = value -} - -// GetChatInviteHash returns value of ChatInviteHash conditional field and -// boolean which is true if field was set. -func (s *SponsoredMessage) GetChatInviteHash() (value string, ok bool) { +// GetTitle returns value of Title field. +func (s *SponsoredMessage) GetTitle() (value string) { if s == nil { return } - if !s.Flags.Has(4) { - return value, false - } - return s.ChatInviteHash, true -} - -// SetChannelPost sets value of ChannelPost conditional field. -func (s *SponsoredMessage) SetChannelPost(value int) { - s.Flags.Set(2) - s.ChannelPost = value + return s.Title } -// GetChannelPost returns value of ChannelPost conditional field and -// boolean which is true if field was set. -func (s *SponsoredMessage) GetChannelPost() (value int, ok bool) { - if s == nil { - return - } - if !s.Flags.Has(2) { - return value, false - } - return s.ChannelPost, true -} - -// SetStartParam sets value of StartParam conditional field. -func (s *SponsoredMessage) SetStartParam(value string) { - s.Flags.Set(0) - s.StartParam = value -} - -// GetStartParam returns value of StartParam conditional field and -// boolean which is true if field was set. -func (s *SponsoredMessage) GetStartParam() (value string, ok bool) { +// GetMessage returns value of Message field. +func (s *SponsoredMessage) GetMessage() (value string) { if s == nil { return } - if !s.Flags.Has(0) { - return value, false - } - return s.StartParam, true + return s.Message } -// SetWebpage sets value of Webpage conditional field. -func (s *SponsoredMessage) SetWebpage(value SponsoredWebPage) { - s.Flags.Set(9) - s.Webpage = value +// SetEntities sets value of Entities conditional field. +func (s *SponsoredMessage) SetEntities(value []MessageEntityClass) { + s.Flags.Set(1) + s.Entities = value } -// GetWebpage returns value of Webpage conditional field and +// GetEntities returns value of Entities conditional field and // boolean which is true if field was set. -func (s *SponsoredMessage) GetWebpage() (value SponsoredWebPage, ok bool) { +func (s *SponsoredMessage) GetEntities() (value []MessageEntityClass, ok bool) { if s == nil { return } - if !s.Flags.Has(9) { + if !s.Flags.Has(1) { return value, false } - return s.Webpage, true + return s.Entities, true } -// SetApp sets value of App conditional field. -func (s *SponsoredMessage) SetApp(value BotAppClass) { - s.Flags.Set(10) - s.App = value +// SetPhoto sets value of Photo conditional field. +func (s *SponsoredMessage) SetPhoto(value PhotoClass) { + s.Flags.Set(6) + s.Photo = value } -// GetApp returns value of App conditional field and +// GetPhoto returns value of Photo conditional field and // boolean which is true if field was set. -func (s *SponsoredMessage) GetApp() (value BotAppClass, ok bool) { +func (s *SponsoredMessage) GetPhoto() (value PhotoClass, ok bool) { if s == nil { return } - if !s.Flags.Has(10) { + if !s.Flags.Has(6) { return value, false } - return s.App, true + return s.Photo, true } -// GetMessage returns value of Message field. -func (s *SponsoredMessage) GetMessage() (value string) { - if s == nil { - return - } - return s.Message +// SetColor sets value of Color conditional field. +func (s *SponsoredMessage) SetColor(value PeerColor) { + s.Flags.Set(13) + s.Color = value } -// SetEntities sets value of Entities conditional field. -func (s *SponsoredMessage) SetEntities(value []MessageEntityClass) { - s.Flags.Set(1) - s.Entities = value -} - -// GetEntities returns value of Entities conditional field and +// GetColor returns value of Color conditional field and // boolean which is true if field was set. -func (s *SponsoredMessage) GetEntities() (value []MessageEntityClass, ok bool) { +func (s *SponsoredMessage) GetColor() (value PeerColor, ok bool) { if s == nil { return } - if !s.Flags.Has(1) { + if !s.Flags.Has(13) { return value, false } - return s.Entities, true + return s.Color, true } -// SetButtonText sets value of ButtonText conditional field. -func (s *SponsoredMessage) SetButtonText(value string) { - s.Flags.Set(11) - s.ButtonText = value -} - -// GetButtonText returns value of ButtonText conditional field and -// boolean which is true if field was set. -func (s *SponsoredMessage) GetButtonText() (value string, ok bool) { +// GetButtonText returns value of ButtonText field. +func (s *SponsoredMessage) GetButtonText() (value string) { if s == nil { return } - if !s.Flags.Has(11) { - return value, false - } - return s.ButtonText, true + return s.ButtonText } // SetSponsorInfo sets value of SponsorInfo conditional field. @@ -888,15 +631,6 @@ func (s *SponsoredMessage) GetAdditionalInfo() (value string, ok bool) { return s.AdditionalInfo, true } -// GetAppAsModified returns mapped value of App conditional field and -// boolean which is true if field was set. -func (s *SponsoredMessage) GetAppAsModified() (*BotApp, bool) { - if value, ok := s.GetApp(); ok { - return value.AsModified() - } - return nil, false -} - // MapEntities returns field Entities wrapped in MessageEntityClassArray helper. func (s *SponsoredMessage) MapEntities() (value MessageEntityClassArray, ok bool) { if !s.Flags.Has(1) { @@ -904,3 +638,12 @@ func (s *SponsoredMessage) MapEntities() (value MessageEntityClassArray, ok bool } return MessageEntityClassArray(s.Entities), true } + +// GetPhotoAsNotEmpty returns mapped value of Photo conditional field and +// boolean which is true if field was set. +func (s *SponsoredMessage) GetPhotoAsNotEmpty() (*Photo, bool) { + if value, ok := s.GetPhoto(); ok { + return value.AsNotEmpty() + } + return nil, false +} diff --git a/tg/tl_sponsored_web_page_gen.go b/tg/tl_sponsored_web_page_gen.go deleted file mode 100644 index 5ac9fe37cb..0000000000 --- a/tg/tl_sponsored_web_page_gen.go +++ /dev/null @@ -1,272 +0,0 @@ -// 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{} -) - -// SponsoredWebPage represents TL type `sponsoredWebPage#3db8ec63`. -// Represents a sponsored website. -// -// See https://core.telegram.org/constructor/sponsoredWebPage for reference. -type SponsoredWebPage struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Web page URL. - URL string - // Website name. - SiteName string - // Optional image preview. - // - // Use SetPhoto and GetPhoto helpers. - Photo PhotoClass -} - -// SponsoredWebPageTypeID is TL type id of SponsoredWebPage. -const SponsoredWebPageTypeID = 0x3db8ec63 - -// Ensuring interfaces in compile-time for SponsoredWebPage. -var ( - _ bin.Encoder = &SponsoredWebPage{} - _ bin.Decoder = &SponsoredWebPage{} - _ bin.BareEncoder = &SponsoredWebPage{} - _ bin.BareDecoder = &SponsoredWebPage{} -) - -func (s *SponsoredWebPage) Zero() bool { - if s == nil { - return true - } - if !(s.Flags.Zero()) { - return false - } - if !(s.URL == "") { - return false - } - if !(s.SiteName == "") { - return false - } - if !(s.Photo == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (s *SponsoredWebPage) String() string { - if s == nil { - return "SponsoredWebPage(nil)" - } - type Alias SponsoredWebPage - return fmt.Sprintf("SponsoredWebPage%+v", Alias(*s)) -} - -// FillFrom fills SponsoredWebPage from given interface. -func (s *SponsoredWebPage) FillFrom(from interface { - GetURL() (value string) - GetSiteName() (value string) - GetPhoto() (value PhotoClass, ok bool) -}) { - s.URL = from.GetURL() - s.SiteName = from.GetSiteName() - if val, ok := from.GetPhoto(); ok { - s.Photo = val - } - -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*SponsoredWebPage) TypeID() uint32 { - return SponsoredWebPageTypeID -} - -// TypeName returns name of type in TL schema. -func (*SponsoredWebPage) TypeName() string { - return "sponsoredWebPage" -} - -// TypeInfo returns info about TL type. -func (s *SponsoredWebPage) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "sponsoredWebPage", - ID: SponsoredWebPageTypeID, - } - if s == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "URL", - SchemaName: "url", - }, - { - Name: "SiteName", - SchemaName: "site_name", - }, - { - Name: "Photo", - SchemaName: "photo", - Null: !s.Flags.Has(0), - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (s *SponsoredWebPage) SetFlags() { - if !(s.Photo == nil) { - s.Flags.Set(0) - } -} - -// Encode implements bin.Encoder. -func (s *SponsoredWebPage) Encode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode sponsoredWebPage#3db8ec63 as nil") - } - b.PutID(SponsoredWebPageTypeID) - return s.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (s *SponsoredWebPage) EncodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode sponsoredWebPage#3db8ec63 as nil") - } - s.SetFlags() - if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode sponsoredWebPage#3db8ec63: field flags: %w", err) - } - b.PutString(s.URL) - b.PutString(s.SiteName) - if s.Flags.Has(0) { - if s.Photo == nil { - return fmt.Errorf("unable to encode sponsoredWebPage#3db8ec63: field photo is nil") - } - if err := s.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode sponsoredWebPage#3db8ec63: field photo: %w", err) - } - } - return nil -} - -// Decode implements bin.Decoder. -func (s *SponsoredWebPage) Decode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode sponsoredWebPage#3db8ec63 to nil") - } - if err := b.ConsumeID(SponsoredWebPageTypeID); err != nil { - return fmt.Errorf("unable to decode sponsoredWebPage#3db8ec63: %w", err) - } - return s.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (s *SponsoredWebPage) DecodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode sponsoredWebPage#3db8ec63 to nil") - } - { - if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode sponsoredWebPage#3db8ec63: field flags: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode sponsoredWebPage#3db8ec63: field url: %w", err) - } - s.URL = value - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode sponsoredWebPage#3db8ec63: field site_name: %w", err) - } - s.SiteName = value - } - if s.Flags.Has(0) { - value, err := DecodePhoto(b) - if err != nil { - return fmt.Errorf("unable to decode sponsoredWebPage#3db8ec63: field photo: %w", err) - } - s.Photo = value - } - return nil -} - -// GetURL returns value of URL field. -func (s *SponsoredWebPage) GetURL() (value string) { - if s == nil { - return - } - return s.URL -} - -// GetSiteName returns value of SiteName field. -func (s *SponsoredWebPage) GetSiteName() (value string) { - if s == nil { - return - } - return s.SiteName -} - -// SetPhoto sets value of Photo conditional field. -func (s *SponsoredWebPage) SetPhoto(value PhotoClass) { - s.Flags.Set(0) - s.Photo = value -} - -// GetPhoto returns value of Photo conditional field and -// boolean which is true if field was set. -func (s *SponsoredWebPage) GetPhoto() (value PhotoClass, ok bool) { - if s == nil { - return - } - if !s.Flags.Has(0) { - return value, false - } - return s.Photo, true -} - -// GetPhotoAsNotEmpty returns mapped value of Photo conditional field and -// boolean which is true if field was set. -func (s *SponsoredWebPage) GetPhotoAsNotEmpty() (*Photo, bool) { - if value, ok := s.GetPhoto(); ok { - return value.AsNotEmpty() - } - return nil, false -} diff --git a/tg/tl_stories_stories_gen.go b/tg/tl_stories_stories_gen.go index 67f14e8b41..ff3ce2ebe4 100644 --- a/tg/tl_stories_stories_gen.go +++ b/tg/tl_stories_stories_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// StoriesStories represents TL type `stories.stories#5dd8c3c8`. +// StoriesStories represents TL type `stories.stories#63c3dd0a`. // List of stories¹ // // Links: @@ -39,10 +39,16 @@ var ( // // See https://core.telegram.org/constructor/stories.stories for reference. type StoriesStories struct { + // Flags field of StoriesStories. + Flags bin.Fields // Total number of stories that can be fetched Count int // Stories Stories []StoryItemClass + // PinnedToTop field of StoriesStories. + // + // Use SetPinnedToTop and GetPinnedToTop helpers. + PinnedToTop []int // Mentioned chats Chats []ChatClass // Mentioned users @@ -50,7 +56,7 @@ type StoriesStories struct { } // StoriesStoriesTypeID is TL type id of StoriesStories. -const StoriesStoriesTypeID = 0x5dd8c3c8 +const StoriesStoriesTypeID = 0x63c3dd0a // Ensuring interfaces in compile-time for StoriesStories. var ( @@ -64,12 +70,18 @@ func (s *StoriesStories) Zero() bool { if s == nil { return true } + if !(s.Flags.Zero()) { + return false + } if !(s.Count == 0) { return false } if !(s.Stories == nil) { return false } + if !(s.PinnedToTop == nil) { + return false + } if !(s.Chats == nil) { return false } @@ -93,11 +105,16 @@ func (s *StoriesStories) String() string { func (s *StoriesStories) FillFrom(from interface { GetCount() (value int) GetStories() (value []StoryItemClass) + GetPinnedToTop() (value []int, ok bool) GetChats() (value []ChatClass) GetUsers() (value []UserClass) }) { s.Count = from.GetCount() s.Stories = from.GetStories() + if val, ok := from.GetPinnedToTop(); ok { + s.PinnedToTop = val + } + s.Chats = from.GetChats() s.Users = from.GetUsers() } @@ -133,6 +150,11 @@ func (s *StoriesStories) TypeInfo() tdp.Type { Name: "Stories", SchemaName: "stories", }, + { + Name: "PinnedToTop", + SchemaName: "pinned_to_top", + Null: !s.Flags.Has(0), + }, { Name: "Chats", SchemaName: "chats", @@ -145,10 +167,17 @@ func (s *StoriesStories) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (s *StoriesStories) SetFlags() { + if !(s.PinnedToTop == nil) { + s.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (s *StoriesStories) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode stories.stories#5dd8c3c8 as nil") + return fmt.Errorf("can't encode stories.stories#63c3dd0a as nil") } b.PutID(StoriesStoriesTypeID) return s.EncodeBare(b) @@ -157,34 +186,44 @@ func (s *StoriesStories) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *StoriesStories) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode stories.stories#5dd8c3c8 as nil") + return fmt.Errorf("can't encode stories.stories#63c3dd0a as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode stories.stories#63c3dd0a: field flags: %w", err) } b.PutInt(s.Count) b.PutVectorHeader(len(s.Stories)) for idx, v := range s.Stories { if v == nil { - return fmt.Errorf("unable to encode stories.stories#5dd8c3c8: field stories element with index %d is nil", idx) + return fmt.Errorf("unable to encode stories.stories#63c3dd0a: field stories element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode stories.stories#5dd8c3c8: field stories element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode stories.stories#63c3dd0a: field stories element with index %d: %w", idx, err) + } + } + if s.Flags.Has(0) { + b.PutVectorHeader(len(s.PinnedToTop)) + for _, v := range s.PinnedToTop { + b.PutInt(v) } } b.PutVectorHeader(len(s.Chats)) for idx, v := range s.Chats { if v == nil { - return fmt.Errorf("unable to encode stories.stories#5dd8c3c8: field chats element with index %d is nil", idx) + return fmt.Errorf("unable to encode stories.stories#63c3dd0a: field chats element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode stories.stories#5dd8c3c8: field chats element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode stories.stories#63c3dd0a: 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 stories.stories#5dd8c3c8: field users element with index %d is nil", idx) + return fmt.Errorf("unable to encode stories.stories#63c3dd0a: field users element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode stories.stories#5dd8c3c8: field users element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode stories.stories#63c3dd0a: field users element with index %d: %w", idx, err) } } return nil @@ -193,10 +232,10 @@ func (s *StoriesStories) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *StoriesStories) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode stories.stories#5dd8c3c8 to nil") + return fmt.Errorf("can't decode stories.stories#63c3dd0a to nil") } if err := b.ConsumeID(StoriesStoriesTypeID); err != nil { - return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: %w", err) + return fmt.Errorf("unable to decode stories.stories#63c3dd0a: %w", err) } return s.DecodeBare(b) } @@ -204,19 +243,24 @@ func (s *StoriesStories) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *StoriesStories) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode stories.stories#5dd8c3c8 to nil") + return fmt.Errorf("can't decode stories.stories#63c3dd0a to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode stories.stories#63c3dd0a: field flags: %w", err) + } } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field count: %w", err) + return fmt.Errorf("unable to decode stories.stories#63c3dd0a: field count: %w", err) } s.Count = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field stories: %w", err) + return fmt.Errorf("unable to decode stories.stories#63c3dd0a: field stories: %w", err) } if headerLen > 0 { @@ -225,15 +269,32 @@ func (s *StoriesStories) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeStoryItem(b) if err != nil { - return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field stories: %w", err) + return fmt.Errorf("unable to decode stories.stories#63c3dd0a: field stories: %w", err) } s.Stories = append(s.Stories, value) } } + if s.Flags.Has(0) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode stories.stories#63c3dd0a: field pinned_to_top: %w", err) + } + + if headerLen > 0 { + s.PinnedToTop = make([]int, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode stories.stories#63c3dd0a: field pinned_to_top: %w", err) + } + s.PinnedToTop = append(s.PinnedToTop, value) + } + } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field chats: %w", err) + return fmt.Errorf("unable to decode stories.stories#63c3dd0a: field chats: %w", err) } if headerLen > 0 { @@ -242,7 +303,7 @@ func (s *StoriesStories) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeChat(b) if err != nil { - return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field chats: %w", err) + return fmt.Errorf("unable to decode stories.stories#63c3dd0a: field chats: %w", err) } s.Chats = append(s.Chats, value) } @@ -250,7 +311,7 @@ func (s *StoriesStories) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field users: %w", err) + return fmt.Errorf("unable to decode stories.stories#63c3dd0a: field users: %w", err) } if headerLen > 0 { @@ -259,7 +320,7 @@ func (s *StoriesStories) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeUser(b) if err != nil { - return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field users: %w", err) + return fmt.Errorf("unable to decode stories.stories#63c3dd0a: field users: %w", err) } s.Users = append(s.Users, value) } @@ -283,6 +344,24 @@ func (s *StoriesStories) GetStories() (value []StoryItemClass) { return s.Stories } +// SetPinnedToTop sets value of PinnedToTop conditional field. +func (s *StoriesStories) SetPinnedToTop(value []int) { + s.Flags.Set(0) + s.PinnedToTop = value +} + +// GetPinnedToTop returns value of PinnedToTop conditional field and +// boolean which is true if field was set. +func (s *StoriesStories) GetPinnedToTop() (value []int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.PinnedToTop, true +} + // GetChats returns value of Chats field. func (s *StoriesStories) GetChats() (value []ChatClass) { if s == nil { diff --git a/tg/tl_stories_toggle_pinned_to_top_gen.go b/tg/tl_stories_toggle_pinned_to_top_gen.go new file mode 100644 index 0000000000..6a3e153ee1 --- /dev/null +++ b/tg/tl_stories_toggle_pinned_to_top_gen.go @@ -0,0 +1,219 @@ +// 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{} +) + +// StoriesTogglePinnedToTopRequest represents TL type `stories.togglePinnedToTop#b297e9b`. +// +// See https://core.telegram.org/method/stories.togglePinnedToTop for reference. +type StoriesTogglePinnedToTopRequest struct { + // Peer field of StoriesTogglePinnedToTopRequest. + Peer InputPeerClass + // ID field of StoriesTogglePinnedToTopRequest. + ID []int +} + +// StoriesTogglePinnedToTopRequestTypeID is TL type id of StoriesTogglePinnedToTopRequest. +const StoriesTogglePinnedToTopRequestTypeID = 0xb297e9b + +// Ensuring interfaces in compile-time for StoriesTogglePinnedToTopRequest. +var ( + _ bin.Encoder = &StoriesTogglePinnedToTopRequest{} + _ bin.Decoder = &StoriesTogglePinnedToTopRequest{} + _ bin.BareEncoder = &StoriesTogglePinnedToTopRequest{} + _ bin.BareDecoder = &StoriesTogglePinnedToTopRequest{} +) + +func (t *StoriesTogglePinnedToTopRequest) Zero() bool { + if t == nil { + return true + } + if !(t.Peer == nil) { + return false + } + if !(t.ID == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (t *StoriesTogglePinnedToTopRequest) String() string { + if t == nil { + return "StoriesTogglePinnedToTopRequest(nil)" + } + type Alias StoriesTogglePinnedToTopRequest + return fmt.Sprintf("StoriesTogglePinnedToTopRequest%+v", Alias(*t)) +} + +// FillFrom fills StoriesTogglePinnedToTopRequest from given interface. +func (t *StoriesTogglePinnedToTopRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetID() (value []int) +}) { + t.Peer = from.GetPeer() + t.ID = from.GetID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StoriesTogglePinnedToTopRequest) TypeID() uint32 { + return StoriesTogglePinnedToTopRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*StoriesTogglePinnedToTopRequest) TypeName() string { + return "stories.togglePinnedToTop" +} + +// TypeInfo returns info about TL type. +func (t *StoriesTogglePinnedToTopRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "stories.togglePinnedToTop", + ID: StoriesTogglePinnedToTopRequestTypeID, + } + if t == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "ID", + SchemaName: "id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (t *StoriesTogglePinnedToTopRequest) Encode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode stories.togglePinnedToTop#b297e9b as nil") + } + b.PutID(StoriesTogglePinnedToTopRequestTypeID) + return t.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (t *StoriesTogglePinnedToTopRequest) EncodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode stories.togglePinnedToTop#b297e9b as nil") + } + if t.Peer == nil { + return fmt.Errorf("unable to encode stories.togglePinnedToTop#b297e9b: field peer is nil") + } + if err := t.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode stories.togglePinnedToTop#b297e9b: field peer: %w", err) + } + b.PutVectorHeader(len(t.ID)) + for _, v := range t.ID { + b.PutInt(v) + } + return nil +} + +// Decode implements bin.Decoder. +func (t *StoriesTogglePinnedToTopRequest) Decode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode stories.togglePinnedToTop#b297e9b to nil") + } + if err := b.ConsumeID(StoriesTogglePinnedToTopRequestTypeID); err != nil { + return fmt.Errorf("unable to decode stories.togglePinnedToTop#b297e9b: %w", err) + } + return t.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (t *StoriesTogglePinnedToTopRequest) DecodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode stories.togglePinnedToTop#b297e9b to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode stories.togglePinnedToTop#b297e9b: field peer: %w", err) + } + t.Peer = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode stories.togglePinnedToTop#b297e9b: field id: %w", err) + } + + if headerLen > 0 { + t.ID = make([]int, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode stories.togglePinnedToTop#b297e9b: field id: %w", err) + } + t.ID = append(t.ID, value) + } + } + return nil +} + +// GetPeer returns value of Peer field. +func (t *StoriesTogglePinnedToTopRequest) GetPeer() (value InputPeerClass) { + if t == nil { + return + } + return t.Peer +} + +// GetID returns value of ID field. +func (t *StoriesTogglePinnedToTopRequest) GetID() (value []int) { + if t == nil { + return + } + return t.ID +} + +// StoriesTogglePinnedToTop invokes method stories.togglePinnedToTop#b297e9b returning error if any. +// +// See https://core.telegram.org/method/stories.togglePinnedToTop for reference. +func (c *Client) StoriesTogglePinnedToTop(ctx context.Context, request *StoriesTogglePinnedToTopRequest) (bool, error) { + var result BoolBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return false, err + } + _, ok := result.Bool.(*BoolTrue) + return ok, nil +} diff --git a/tg/tl_stories_toggle_pinned_to_top_slices_gen.go b/tg/tl_stories_toggle_pinned_to_top_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_stories_toggle_pinned_to_top_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_update_gen.go b/tg/tl_update_gen.go index 27ae10e720..e00f5f0887 100644 --- a/tg/tl_update_gen.go +++ b/tg/tl_update_gen.go @@ -26938,6 +26938,204 @@ func (u *UpdateBotDeleteBusinessMessage) GetQts() (value int) { return u.Qts } +// UpdateNewStoryReaction represents TL type `updateNewStoryReaction#1824e40b`. +// +// See https://core.telegram.org/constructor/updateNewStoryReaction for reference. +type UpdateNewStoryReaction struct { + // StoryID field of UpdateNewStoryReaction. + StoryID int + // Peer field of UpdateNewStoryReaction. + Peer PeerClass + // Reaction field of UpdateNewStoryReaction. + Reaction ReactionClass +} + +// UpdateNewStoryReactionTypeID is TL type id of UpdateNewStoryReaction. +const UpdateNewStoryReactionTypeID = 0x1824e40b + +// construct implements constructor of UpdateClass. +func (u UpdateNewStoryReaction) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateNewStoryReaction. +var ( + _ bin.Encoder = &UpdateNewStoryReaction{} + _ bin.Decoder = &UpdateNewStoryReaction{} + _ bin.BareEncoder = &UpdateNewStoryReaction{} + _ bin.BareDecoder = &UpdateNewStoryReaction{} + + _ UpdateClass = &UpdateNewStoryReaction{} +) + +func (u *UpdateNewStoryReaction) Zero() bool { + if u == nil { + return true + } + if !(u.StoryID == 0) { + return false + } + if !(u.Peer == nil) { + return false + } + if !(u.Reaction == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateNewStoryReaction) String() string { + if u == nil { + return "UpdateNewStoryReaction(nil)" + } + type Alias UpdateNewStoryReaction + return fmt.Sprintf("UpdateNewStoryReaction%+v", Alias(*u)) +} + +// FillFrom fills UpdateNewStoryReaction from given interface. +func (u *UpdateNewStoryReaction) FillFrom(from interface { + GetStoryID() (value int) + GetPeer() (value PeerClass) + GetReaction() (value ReactionClass) +}) { + u.StoryID = from.GetStoryID() + u.Peer = from.GetPeer() + u.Reaction = from.GetReaction() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateNewStoryReaction) TypeID() uint32 { + return UpdateNewStoryReactionTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateNewStoryReaction) TypeName() string { + return "updateNewStoryReaction" +} + +// TypeInfo returns info about TL type. +func (u *UpdateNewStoryReaction) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateNewStoryReaction", + ID: UpdateNewStoryReactionTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "StoryID", + SchemaName: "story_id", + }, + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "Reaction", + SchemaName: "reaction", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateNewStoryReaction) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateNewStoryReaction#1824e40b as nil") + } + b.PutID(UpdateNewStoryReactionTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateNewStoryReaction) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateNewStoryReaction#1824e40b as nil") + } + b.PutInt(u.StoryID) + if u.Peer == nil { + return fmt.Errorf("unable to encode updateNewStoryReaction#1824e40b: field peer is nil") + } + if err := u.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateNewStoryReaction#1824e40b: field peer: %w", err) + } + if u.Reaction == nil { + return fmt.Errorf("unable to encode updateNewStoryReaction#1824e40b: field reaction is nil") + } + if err := u.Reaction.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateNewStoryReaction#1824e40b: field reaction: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateNewStoryReaction) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateNewStoryReaction#1824e40b to nil") + } + if err := b.ConsumeID(UpdateNewStoryReactionTypeID); err != nil { + return fmt.Errorf("unable to decode updateNewStoryReaction#1824e40b: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateNewStoryReaction) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateNewStoryReaction#1824e40b to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode updateNewStoryReaction#1824e40b: field story_id: %w", err) + } + u.StoryID = value + } + { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode updateNewStoryReaction#1824e40b: field peer: %w", err) + } + u.Peer = value + } + { + value, err := DecodeReaction(b) + if err != nil { + return fmt.Errorf("unable to decode updateNewStoryReaction#1824e40b: field reaction: %w", err) + } + u.Reaction = value + } + return nil +} + +// GetStoryID returns value of StoryID field. +func (u *UpdateNewStoryReaction) GetStoryID() (value int) { + if u == nil { + return + } + return u.StoryID +} + +// GetPeer returns value of Peer field. +func (u *UpdateNewStoryReaction) GetPeer() (value PeerClass) { + if u == nil { + return + } + return u.Peer +} + +// GetReaction returns value of Reaction field. +func (u *UpdateNewStoryReaction) GetReaction() (value ReactionClass) { + if u == nil { + return + } + return u.Reaction +} + // UpdateClassName is schema name of UpdateClass. const UpdateClassName = "Update" @@ -27086,6 +27284,7 @@ const UpdateClassName = "Update" // case *tg.UpdateBotNewBusinessMessage: // updateBotNewBusinessMessage#9ddb347c // case *tg.UpdateBotEditBusinessMessage: // updateBotEditBusinessMessage#7df587c // case *tg.UpdateBotDeleteBusinessMessage: // updateBotDeleteBusinessMessage#a02a982e +// case *tg.UpdateNewStoryReaction: // updateNewStoryReaction#1824e40b // default: panic(v) // } type UpdateClass interface { @@ -28052,6 +28251,13 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case UpdateNewStoryReactionTypeID: + // Decoding updateNewStoryReaction#1824e40b. + v := UpdateNewStoryReaction{} + 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 67818b5fc2..656129e2cb 100644 --- a/tg/tl_update_slices_gen.go +++ b/tg/tl_update_slices_gen.go @@ -1650,6 +1650,19 @@ func (s UpdateClassArray) AsUpdateBotDeleteBusinessMessage() (to UpdateBotDelete return to } +// AsUpdateNewStoryReaction returns copy with only UpdateNewStoryReaction constructors. +func (s UpdateClassArray) AsUpdateNewStoryReaction() (to UpdateNewStoryReactionArray) { + for _, elem := range s { + value, ok := elem.(*UpdateNewStoryReaction) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // UpdateNewMessageArray is adapter for slice of UpdateNewMessage. type UpdateNewMessageArray []UpdateNewMessage @@ -11591,3 +11604,85 @@ func (s *UpdateBotDeleteBusinessMessageArray) Pop() (v UpdateBotDeleteBusinessMe return v, true } + +// UpdateNewStoryReactionArray is adapter for slice of UpdateNewStoryReaction. +type UpdateNewStoryReactionArray []UpdateNewStoryReaction + +// Sort sorts slice of UpdateNewStoryReaction. +func (s UpdateNewStoryReactionArray) Sort(less func(a, b UpdateNewStoryReaction) bool) UpdateNewStoryReactionArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateNewStoryReaction. +func (s UpdateNewStoryReactionArray) SortStable(less func(a, b UpdateNewStoryReaction) bool) UpdateNewStoryReactionArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateNewStoryReaction. +func (s UpdateNewStoryReactionArray) Retain(keep func(x UpdateNewStoryReaction) bool) UpdateNewStoryReactionArray { + 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 UpdateNewStoryReactionArray) First() (v UpdateNewStoryReaction, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateNewStoryReactionArray) Last() (v UpdateNewStoryReaction, 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 *UpdateNewStoryReactionArray) PopFirst() (v UpdateNewStoryReaction, 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 UpdateNewStoryReaction + 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 *UpdateNewStoryReactionArray) Pop() (v UpdateNewStoryReaction, 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_user_full_gen.go b/tg/tl_user_full_gen.go index 208117b8d5..5543eb17e4 100644 --- a/tg/tl_user_full_gen.go +++ b/tg/tl_user_full_gen.go @@ -87,6 +87,8 @@ type UserFull struct { ReadDatesPrivate bool // Flags2 field of UserFull. Flags2 bin.Fields + // SponsoredEnabled field of UserFull. + SponsoredEnabled bool // User ID ID int64 // Bio of the user @@ -273,6 +275,9 @@ func (u *UserFull) Zero() bool { if !(u.Flags2.Zero()) { return false } + if !(u.SponsoredEnabled == false) { + return false + } if !(u.ID == 0) { return false } @@ -382,6 +387,7 @@ func (u *UserFull) FillFrom(from interface { GetWallpaperOverridden() (value bool) GetContactRequirePremium() (value bool) GetReadDatesPrivate() (value bool) + GetSponsoredEnabled() (value bool) GetID() (value int64) GetAbout() (value string, ok bool) GetSettings() (value PeerSettings) @@ -423,6 +429,7 @@ func (u *UserFull) FillFrom(from interface { u.WallpaperOverridden = from.GetWallpaperOverridden() u.ContactRequirePremium = from.GetContactRequirePremium() u.ReadDatesPrivate = from.GetReadDatesPrivate() + u.SponsoredEnabled = from.GetSponsoredEnabled() u.ID = from.GetID() if val, ok := from.GetAbout(); ok { u.About = val @@ -609,6 +616,11 @@ func (u *UserFull) TypeInfo() tdp.Type { SchemaName: "read_dates_private", Null: !u.Flags.Has(30), }, + { + Name: "SponsoredEnabled", + SchemaName: "sponsored_enabled", + Null: !u.Flags2.Has(7), + }, { Name: "ID", SchemaName: "id", @@ -785,6 +797,9 @@ func (u *UserFull) SetFlags() { if !(u.ReadDatesPrivate == false) { u.Flags.Set(30) } + if !(u.SponsoredEnabled == false) { + u.Flags2.Set(7) + } if !(u.About == "") { u.Flags.Set(1) } @@ -1041,6 +1056,7 @@ func (u *UserFull) DecodeBare(b *bin.Buffer) error { return fmt.Errorf("unable to decode userFull#cc997720: field flags2: %w", err) } } + u.SponsoredEnabled = u.Flags2.Has(7) { value, err := b.Long() if err != nil { @@ -1466,6 +1482,25 @@ func (u *UserFull) GetReadDatesPrivate() (value bool) { return u.Flags.Has(30) } +// SetSponsoredEnabled sets value of SponsoredEnabled conditional field. +func (u *UserFull) SetSponsoredEnabled(value bool) { + if value { + u.Flags2.Set(7) + u.SponsoredEnabled = true + } else { + u.Flags2.Unset(7) + u.SponsoredEnabled = false + } +} + +// GetSponsoredEnabled returns value of SponsoredEnabled conditional field. +func (u *UserFull) GetSponsoredEnabled() (value bool) { + if u == nil { + return + } + return u.Flags2.Has(7) +} + // GetID returns value of ID field. func (u *UserFull) GetID() (value int64) { if u == nil { diff --git a/tg/tl_web_page_attribute_gen.go b/tg/tl_web_page_attribute_gen.go index 1241f0326b..7ecee2a30c 100644 --- a/tg/tl_web_page_attribute_gen.go +++ b/tg/tl_web_page_attribute_gen.go @@ -530,6 +530,251 @@ func (w *WebPageAttributeStory) GetStory() (value StoryItemClass, ok bool) { return w.Story, true } +// WebPageAttributeStickerSet represents TL type `webPageAttributeStickerSet#50cc03d3`. +// +// See https://core.telegram.org/constructor/webPageAttributeStickerSet for reference. +type WebPageAttributeStickerSet struct { + // Flags field of WebPageAttributeStickerSet. + Flags bin.Fields + // Emojis field of WebPageAttributeStickerSet. + Emojis bool + // TextColor field of WebPageAttributeStickerSet. + TextColor bool + // Stickers field of WebPageAttributeStickerSet. + Stickers []DocumentClass +} + +// WebPageAttributeStickerSetTypeID is TL type id of WebPageAttributeStickerSet. +const WebPageAttributeStickerSetTypeID = 0x50cc03d3 + +// construct implements constructor of WebPageAttributeClass. +func (w WebPageAttributeStickerSet) construct() WebPageAttributeClass { return &w } + +// Ensuring interfaces in compile-time for WebPageAttributeStickerSet. +var ( + _ bin.Encoder = &WebPageAttributeStickerSet{} + _ bin.Decoder = &WebPageAttributeStickerSet{} + _ bin.BareEncoder = &WebPageAttributeStickerSet{} + _ bin.BareDecoder = &WebPageAttributeStickerSet{} + + _ WebPageAttributeClass = &WebPageAttributeStickerSet{} +) + +func (w *WebPageAttributeStickerSet) Zero() bool { + if w == nil { + return true + } + if !(w.Flags.Zero()) { + return false + } + if !(w.Emojis == false) { + return false + } + if !(w.TextColor == false) { + return false + } + if !(w.Stickers == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (w *WebPageAttributeStickerSet) String() string { + if w == nil { + return "WebPageAttributeStickerSet(nil)" + } + type Alias WebPageAttributeStickerSet + return fmt.Sprintf("WebPageAttributeStickerSet%+v", Alias(*w)) +} + +// FillFrom fills WebPageAttributeStickerSet from given interface. +func (w *WebPageAttributeStickerSet) FillFrom(from interface { + GetEmojis() (value bool) + GetTextColor() (value bool) + GetStickers() (value []DocumentClass) +}) { + w.Emojis = from.GetEmojis() + w.TextColor = from.GetTextColor() + w.Stickers = from.GetStickers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*WebPageAttributeStickerSet) TypeID() uint32 { + return WebPageAttributeStickerSetTypeID +} + +// TypeName returns name of type in TL schema. +func (*WebPageAttributeStickerSet) TypeName() string { + return "webPageAttributeStickerSet" +} + +// TypeInfo returns info about TL type. +func (w *WebPageAttributeStickerSet) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "webPageAttributeStickerSet", + ID: WebPageAttributeStickerSetTypeID, + } + if w == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Emojis", + SchemaName: "emojis", + Null: !w.Flags.Has(0), + }, + { + Name: "TextColor", + SchemaName: "text_color", + Null: !w.Flags.Has(1), + }, + { + Name: "Stickers", + SchemaName: "stickers", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (w *WebPageAttributeStickerSet) SetFlags() { + if !(w.Emojis == false) { + w.Flags.Set(0) + } + if !(w.TextColor == false) { + w.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (w *WebPageAttributeStickerSet) Encode(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't encode webPageAttributeStickerSet#50cc03d3 as nil") + } + b.PutID(WebPageAttributeStickerSetTypeID) + return w.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (w *WebPageAttributeStickerSet) EncodeBare(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't encode webPageAttributeStickerSet#50cc03d3 as nil") + } + w.SetFlags() + if err := w.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode webPageAttributeStickerSet#50cc03d3: field flags: %w", err) + } + b.PutVectorHeader(len(w.Stickers)) + for idx, v := range w.Stickers { + if v == nil { + return fmt.Errorf("unable to encode webPageAttributeStickerSet#50cc03d3: field stickers element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode webPageAttributeStickerSet#50cc03d3: field stickers element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (w *WebPageAttributeStickerSet) Decode(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't decode webPageAttributeStickerSet#50cc03d3 to nil") + } + if err := b.ConsumeID(WebPageAttributeStickerSetTypeID); err != nil { + return fmt.Errorf("unable to decode webPageAttributeStickerSet#50cc03d3: %w", err) + } + return w.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (w *WebPageAttributeStickerSet) DecodeBare(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't decode webPageAttributeStickerSet#50cc03d3 to nil") + } + { + if err := w.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode webPageAttributeStickerSet#50cc03d3: field flags: %w", err) + } + } + w.Emojis = w.Flags.Has(0) + w.TextColor = w.Flags.Has(1) + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode webPageAttributeStickerSet#50cc03d3: field stickers: %w", err) + } + + if headerLen > 0 { + w.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 webPageAttributeStickerSet#50cc03d3: field stickers: %w", err) + } + w.Stickers = append(w.Stickers, value) + } + } + return nil +} + +// SetEmojis sets value of Emojis conditional field. +func (w *WebPageAttributeStickerSet) SetEmojis(value bool) { + if value { + w.Flags.Set(0) + w.Emojis = true + } else { + w.Flags.Unset(0) + w.Emojis = false + } +} + +// GetEmojis returns value of Emojis conditional field. +func (w *WebPageAttributeStickerSet) GetEmojis() (value bool) { + if w == nil { + return + } + return w.Flags.Has(0) +} + +// SetTextColor sets value of TextColor conditional field. +func (w *WebPageAttributeStickerSet) SetTextColor(value bool) { + if value { + w.Flags.Set(1) + w.TextColor = true + } else { + w.Flags.Unset(1) + w.TextColor = false + } +} + +// GetTextColor returns value of TextColor conditional field. +func (w *WebPageAttributeStickerSet) GetTextColor() (value bool) { + if w == nil { + return + } + return w.Flags.Has(1) +} + +// GetStickers returns value of Stickers field. +func (w *WebPageAttributeStickerSet) GetStickers() (value []DocumentClass) { + if w == nil { + return + } + return w.Stickers +} + +// MapStickers returns field Stickers wrapped in DocumentClassArray helper. +func (w *WebPageAttributeStickerSet) MapStickers() (value DocumentClassArray) { + return DocumentClassArray(w.Stickers) +} + // WebPageAttributeClassName is schema name of WebPageAttributeClass. const WebPageAttributeClassName = "WebPageAttribute" @@ -546,6 +791,7 @@ const WebPageAttributeClassName = "WebPageAttribute" // switch v := g.(type) { // case *tg.WebPageAttributeTheme: // webPageAttributeTheme#54b56617 // case *tg.WebPageAttributeStory: // webPageAttributeStory#2e94c3e7 +// case *tg.WebPageAttributeStickerSet: // webPageAttributeStickerSet#50cc03d3 // default: panic(v) // } type WebPageAttributeClass interface { @@ -588,6 +834,13 @@ func DecodeWebPageAttribute(buf *bin.Buffer) (WebPageAttributeClass, error) { return nil, fmt.Errorf("unable to decode WebPageAttributeClass: %w", err) } return &v, nil + case WebPageAttributeStickerSetTypeID: + // Decoding webPageAttributeStickerSet#50cc03d3. + v := WebPageAttributeStickerSet{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode WebPageAttributeClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode WebPageAttributeClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_web_page_attribute_slices_gen.go b/tg/tl_web_page_attribute_slices_gen.go index af150f6bf6..81e978622b 100644 --- a/tg/tl_web_page_attribute_slices_gen.go +++ b/tg/tl_web_page_attribute_slices_gen.go @@ -142,6 +142,19 @@ func (s WebPageAttributeClassArray) AsWebPageAttributeStory() (to WebPageAttribu return to } +// AsWebPageAttributeStickerSet returns copy with only WebPageAttributeStickerSet constructors. +func (s WebPageAttributeClassArray) AsWebPageAttributeStickerSet() (to WebPageAttributeStickerSetArray) { + for _, elem := range s { + value, ok := elem.(*WebPageAttributeStickerSet) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // WebPageAttributeThemeArray is adapter for slice of WebPageAttributeTheme. type WebPageAttributeThemeArray []WebPageAttributeTheme @@ -333,3 +346,85 @@ func (s WebPageAttributeStoryArray) ToMap() map[int]WebPageAttributeStory { s.FillMap(r) return r } + +// WebPageAttributeStickerSetArray is adapter for slice of WebPageAttributeStickerSet. +type WebPageAttributeStickerSetArray []WebPageAttributeStickerSet + +// Sort sorts slice of WebPageAttributeStickerSet. +func (s WebPageAttributeStickerSetArray) Sort(less func(a, b WebPageAttributeStickerSet) bool) WebPageAttributeStickerSetArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of WebPageAttributeStickerSet. +func (s WebPageAttributeStickerSetArray) SortStable(less func(a, b WebPageAttributeStickerSet) bool) WebPageAttributeStickerSetArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of WebPageAttributeStickerSet. +func (s WebPageAttributeStickerSetArray) Retain(keep func(x WebPageAttributeStickerSet) bool) WebPageAttributeStickerSetArray { + 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 WebPageAttributeStickerSetArray) First() (v WebPageAttributeStickerSet, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s WebPageAttributeStickerSetArray) Last() (v WebPageAttributeStickerSet, 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 *WebPageAttributeStickerSetArray) PopFirst() (v WebPageAttributeStickerSet, 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 WebPageAttributeStickerSet + 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 *WebPageAttributeStickerSetArray) Pop() (v WebPageAttributeStickerSet, 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 +}